User management for the world wide web

Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

ApacheDBM.php

00001 <?php
00002 /* Register self. */
00003 $this->addListener(new GenieGate_Api_Plugin_ApacheDBM($this->CFG)); 
00004 
00026 class GenieGate_Api_Plugin_ApacheDBM extends GenieGate_Api_Plugin {
00027     
00028     var $CFG;   
00034     function GenieGate_Api_Plugin_ApacheDBM(&$conf){
00035         $this->CFG = $conf[ApacheDBM];
00036     }
00040     function setupUser($ua,$fields,$conf_id){      
00041         $uid = $fields[uid];
00042         $pass = $fields[password];
00043         $cp = crypt($pass,$pass);
00044         $comment = $fields[name];
00045         $h = $this->_apache_get_handle();
00046         dba_replace($uid,"$cp::$comment",$h); // Insert or replace next record.
00047         dba_close($h);
00048     }
00049     function _apache_get_handle(){
00050         $handler = $this->CFG[DBMHandler];
00051         $file = $this->CFG[AuthDBMFile];
00052         $h = dba_open($file,"cd",$handler) or die("Can't open $file");
00053         return($h);
00054     }
00055     function userInfoChanged(&$um,$uid,&$old_values,&$new_values) {
00056         $h = $this->_apache_get_handle();
00057         $val = dba_fetch($uid,0,$h);
00058         list($pass,$groups,$comment) = explode(":",$val);
00059         $np = $new_values[password];
00060         $nc = $new_values[name];
00061         $cp = crypt($np,$np);
00062         dba_replace($uid,"$cp:$groups:$nc",$h); // Insert or replace next record.
00063         dba_close($h);
00064     }
00065     // Group modification.
00066     function userGroupsChanged(&$gm,$uid,&$oldg,&$newg) {    
00067         $h = $this->_apache_get_handle();
00068         $val = dba_fetch($uid,0,$h);
00069         list($pass,$groups,$comment) = explode(":",$val);
00070         $groups = implode(",",$newg);
00071         dba_replace($uid,"$pass:$groups:$comment",$h);
00072         dba_close($h);
00073     }
00074     
00075     // Removes the gid from all users who are known to be members.
00076     function groupNameDelete(&$gm,$gid,&$info){
00077         $members = $gm->getMembers($gid); // Get all members who are part of the group.
00078         $h = $this->_apache_get_handle();
00079         foreach($members as $user){
00080             $uid = $user[uid];
00081             $val = dba_fetch($uid,0,$h);
00082             if($val){
00083                 list($pass,$gsr,$comment) = explode(":",$val);
00084                 $groups = explode(",",$gsr);
00085                 $i = array_search($gid,$groups);
00086                 if(is_integer($i)){ // sanity check.
00087                     array_splice($groups,$i,1); // Remove the ID.
00088                     $gsr = implode($groups);
00089                     dba_replace($uid,"$pass:$gsr:$comment",$h);
00090                 }
00091             }
00092         }
00093         dba_close($h);
00094     }
00095     
00096     function removeUser(&$ua,$uid,&$fields){
00097         $h = $this->_apache_get_handle();
00098         dba_delete($uid,$h); // Remove user (and their groups)
00099     }
00100 
00101 }
00102 ?>

DoxyGen Documentation generated by DoxyGen