mango r138 - in trunk: . lib templates www



Author: ovitters
Date: Tue May 20 19:24:03 2008
New Revision: 138
URL: http://svn.gnome.org/viewvc/mango?rev=138&view=rev

Log:
	* lib/user.php:
	* templates/user_instructions.xsl:
	* www/new_user.php:
	* www/update_user.xsl: Prepare work to inform the user regarding key
	changes.



Modified:
   trunk/ChangeLog
   trunk/lib/user.php
   trunk/templates/user_instructions.xsl
   trunk/www/new_user.php
   trunk/www/update_user.xsl

Modified: trunk/lib/user.php
==============================================================================
--- trunk/lib/user.php	(original)
+++ trunk/lib/user.php	Tue May 20 19:24:03 2008
@@ -219,15 +219,15 @@
         if($olduser->cn != $this->cn) {
             $userchanges['cn'][] = $this->cn;
             $userchanges['sn'][] = $this->cn;
-            $changes[] = "cn";
+            $changes[] = array('id'=>"cn")
         }
         if($olduser->mail != $this->mail) {
             $userchanges['mail'][] = $this->mail;
-            $changes[] = "mail";
+            $changes[] = array('id'=>"mail")
         }
         if($olduser->description != $this->description) {
             $userchanges['description'][] = $this->description;
-            $changes[] = "description";
+            $changes[] = array('id'=>"description")
         }
         // Dropping out of 'gnomecvs'?
         if(in_array("gnomecvs", $olduser->groups) && !in_array("gnomecvs", $this->groups)) {
@@ -243,13 +243,13 @@
         if(in_array("ftpadmin", $olduser->groups) && !in_array("ftpadmin", $this->groups)) {
             $userchanges['loginShell'][] = $this->which_shell();
             $userchanges['homeDirectory'][] = $this->which_homedir();
-            $changes[] = "shellaccessrevoked";
+            $changes[] = array('id'=>"shellaccessrevoked")
         }
         // Joining 'ftpadmin'?
         if(!in_array("ftpadmin", $olduser->groups) && in_array("ftpadmin", $this->groups)) {
             $userchanges['loginShell'][] = $this->which_shell();
             $userchanges['homeDirectory'][] = $this->which_homedir();
-            $changes[] = "shellaccessgranted";
+            $changes[] = array('id'=>"shellaccessgranted")
         }
         if(count($userchanges) > 0) {
             $result = ldap_modify($ldap, $dn, $userchanges);
@@ -268,14 +268,14 @@
             }
             if(count($this->authorizedKeys) == 0) {
                 $keychanges['objectclass'][] = "pubkeyAuthenticationUser";
-                $changes[] = "pubkeyauthdisabled";
+                $changes[] = array('id'=>"pubkeyauthdisabled")
             }
             $result = ldap_mod_del($ldap, $dn, $keychanges);
             if(!$result) {
                 $pe = PEAR::raiseError("LDAP (user keys) delete failed: ".ldap_error($ldap));
                 return $pe;
             }
-            $changes[] = "keysremoved";
+            $changes[] = array('id'=>"keysremoved")
         }
         $newkeys = array_diff($this->authorizedKeys, $olduser->authorizedKeys);
         if(is_array($newkeys) && count($newkeys) > 0) {
@@ -285,14 +285,14 @@
             }
             if (!$olduser->pubkeyauthenticationuser) {
                 $keychanges['objectclass'][] = "pubkeyAuthenticationUser";
-                $changes[] = "pubkeyauthenabled";
+                $changes[] = array('id'=>"pubkeyauthenabled")
             }
             $result = ldap_mod_add($ldap, $dn, $keychanges);
             if(!$result) {
                 $pe = PEAR::raiseError("LDAP (user keys) add failed: ".ldap_error($ldap));
                 return $pe;
             }
-            $changes[] = "keysadded";
+            $changes[] = array('id'=>"keysadded")
         }
 
         // What groups are we dropping out of?
@@ -307,7 +307,7 @@
                     $pe = PEAR::raiseError("LDAP (group '$group') delete failed: ".ldap_error($ldap));
                     return $pe;
                 }
-                $changes[] = "left-".$group;
+                $changes[] = array('id'=>"left-group", 'cn'=>$group);
             }
         }
         $newgroups = array_diff($this->groups, $olduser->groups);
@@ -321,7 +321,7 @@
                     $pe = PEAR::raiseError("LDAP (group '$group') add failed: ".ldap_error($ldap));
                     return $pe;
                 }
-                $changes[] = "joined-".$group;
+                $changes[] = array('id'=>"joined-group", 'cn'=>$group);
             }
         }
         
@@ -341,10 +341,16 @@
         $usernode = $mailnode->appendChild($maildom->createElement("user"));
         $this->add_to_node($maildom, $usernode);
 
+        $is_new_account = false;
+
         // Report successes
         foreach($changes as $change) {
             $node = $mailnode->appendChild($maildom->createElement("change"));
-            $node->setAttribute("id", $change);
+            foreach ($change as $key=>$val) {
+                $node->setAttribute($key, $val);
+            }
+
+            if ($change['id'] == 'newuser') $is_new_account = true;
         }
 
         // Process the mail body template
@@ -357,7 +363,9 @@
         if (empty($body))
             return false;
 
-        $subject = in_array('newuser', $changes) ?
+        $changes[] = array('id'=>"informed-user');
+
+        $subject = $is_new_account ?
                'Your new GNOME account' :
                'Changes to your GNOME account';
 

Modified: trunk/templates/user_instructions.xsl
==============================================================================
--- trunk/templates/user_instructions.xsl	(original)
+++ trunk/templates/user_instructions.xsl	Tue May 20 19:24:03 2008
@@ -12,15 +12,15 @@
 
   <xsl:template match="user_instructions"><xsl:variable
       name="output"><xsl:if
-	test="boolean(change[ id='joined-gnomecvs']) or
+	test="boolean(change[ id='joined-group' and @cn='gnomecvs']) or
 	(boolean(change[ id='newuser']) and
 	boolean(user/group[ cn='gnomecvs']))"><xsl:call-template
 	  name="svnintro"/></xsl:if><xsl:if
-	test="boolean(change[ id='joined-ftpadmin']) or
+	test="boolean(change[ id='joined-group' and @cn='ftpadmin']) or
 	(boolean(change[ id='newuser']) and
 	boolean(user/group[ cn='ftpadmin']))"><xsl:call-template
 	  name="shellintro" /></xsl:if><xsl:if
-	test="boolean(change[ id='joined-mailusers']) or
+	test="boolean(change[ id='joined-group' and @cn='mailusers']) or
 	(boolean(change[ id='newuser']) and
 	boolean(user/group[ cn='mailusers']))"><xsl:call-template
 	  name="mailintro"/></xsl:if></xsl:variable><xsl:if

Modified: trunk/www/new_user.php
==============================================================================
--- trunk/www/new_user.php	(original)
+++ trunk/www/new_user.php	Tue May 20 19:24:03 2008
@@ -128,7 +128,7 @@
         }
 
         // Inform the user (email)
-        $changes = array('newuser');
+        $changes = array(array('id'=>'newuser'));
         $this->user->inform_user($changes);
 
         // Report success

Modified: trunk/www/update_user.xsl
==============================================================================
--- trunk/www/update_user.xsl	(original)
+++ trunk/www/update_user.xsl	Tue May 20 19:24:03 2008
@@ -343,6 +343,9 @@
     <xsl:when test="@id='authtokensent'">
      <p>Authentication token sent</p>
     </xsl:when>
+    <xsl:when test="@id='informed-user'">
+     <p>User received an email explaining (some?) of the changes</p>
+    </xsl:when>
     <xsl:when test="@id='welcomesent'">
      <p>Welcome message sent</p>
     </xsl:when>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]