embient.plugin.php

Go to the documentation of this file.
00001 <?php
00002 
00036 require_once("embient.util.php");
00037 require_once("embient.db.php");
00038 
00043 class EmbientPlugin
00044 {
00046   var $user;
00047 
00049   var $name;
00050 
00051   // -------------------------
00052 
00054   var $_db;
00055 
00067   var $_mapping = array();
00068 
00069   // -------------------------
00070 
00088   var $_common_fields = array
00089       (
00090         'name',
00091         'passwd',
00092         'mail',
00093         'firstname',
00094         'lastname',
00095         'signature',
00096         'timezone',
00097       );
00098 
00099   // -------------------------
00100 
00107   function EmbientPlugin($systemname)
00108   {
00109     $this->user = array();
00110     $this->name = $systemname;
00111 
00112     $this->_db  = new EmbientDatabase();
00113   }
00114 
00129   function Init($cfg)
00130   {
00131     return $this->_db->Init($cfg);
00132   }
00133 
00140   function Login($username)
00141   {
00142     // to be implented in derived class
00143     embient_error("Plugin does not implement Login function", __FILE__, __LINE__);
00144   }
00145 
00152   function Logout($username)
00153   {
00154     // to be implented in derived class
00155     embient_error("Plugin does not implement Logout function", __FILE__, __LINE__);
00156   }
00157 
00164   function Add($user)
00165   {
00166     // to be implented in derived class
00167     embient_error("Plugin does not implement Add function", __FILE__, __LINE__);
00168   }
00169 
00178   function Update($username, $user)
00179   {
00180     // to be implented in derived class
00181     embient_error("Plugin does not implement Update function", __FILE__, __LINE__);
00182   }
00183 
00193   function Delete($username)
00194   {
00195     // to be implented in derived class
00196     embient_error("Plugin does not implement Delete function", __FILE__, __LINE__);
00197     return false;
00198   }
00199 
00200   // -------------------------
00201 
00212   function _Load($username)
00213   {
00214     // to be implented in derived class
00215     embient_error("Plugin does not implement _Load function", __FILE__, __LINE__);
00216     return false;
00217   }
00218 
00231   function _ConvertUserInfo($embientuser, $default = true)
00232   {
00233 
00234     embient_debug("Mapping is ". print_r($this->_mapping, true));
00235     embient_debug("Input user info is ". print_r($embientuser, true));
00236 
00237     foreach ($this->_common_fields as $field)
00238     {
00239       embient_debug("Checking [$field] ...");
00240       embient_debug("   input   : user[$field] = ". $embientuser[$field]);
00241       embient_debug("   mapping : $field => ". $this->_mapping[$field]);
00242 
00243       // check, if mapping is not empty?
00244       if ( ! empty($this->_mapping[$field]) )
00245       {
00246         // check, if value for this field is available?
00247         if ( ! empty($embientuser[$field]) )
00248         {
00249           // load with value from Embient
00250           $this->user[$this->_mapping[$field]] = $embientuser[$field];
00251           embient_debug("   output  : user[". $this->_mapping[$field] ."] is set to ". $embientuser[$field]);
00252         }
00253         else
00254         {
00255           embient_debug("   output  : user[". $this->_mapping[$field] ."] is not set");
00256         }
00257       }
00258     }
00259   }
00260 }

Generated on Fri Feb 10 15:05:54 2006 for Embient by  doxygen 1.4.6-NO