00001 <?php
00002
00003 $this->addListener(new GenieGate_Api_Plugin_Logger($this->CFG,"/tmp/pluglogger.txt"));
00004
00018 class GenieGate_Api_Plugin_Logger extends GenieGate_Api_Plugin {
00019
00020 var $LOG_HANDLE;
00021
00022
00028 function GenieGate_Api_Plugin_Logger($cfg,$logfile){
00029 $this->LOG_HANDLE = fopen($logfile,"a");
00030 fwrite($this->LOG_HANDLE,"Start Logging\n");
00031 }
00032
00033 function _send_struct($label,&$what){
00034 ob_start();
00035 echo "-------------------------------------------------------------------\n";
00036 echo "Label: $label\n";
00037 print_r($what);
00038 echo "-------------------------------------------------------------------\n";
00039 $data = ob_get_contents();
00040 ob_clean();
00041 fwrite($this->LOG_HANDLE,$data);
00042 }
00043 function _log($string){
00044 fwrite($this->LOG_HANDLE,"$string\n");
00045 }
00046 function preCheck(&$ua,&$fields,&$errors){
00047 $this->_log("METHOD: preCheck($ua,$fields,$errors)");
00048 $this->_send_struct("ua",$ua);
00049 $this->_send_struct("\$fields",$fields);
00050 $this->_send_struct("\$errors",$errors);
00051 fwrite($this->LOG_HANDLE,"END: preCheck\n");
00052 return;
00053 }
00054 function preConfirm(&$ua,&$fields,$conf_id,&$errors) {
00055 $this->_log("METHOD: preConfirm($ua,&$fields,$conf_id,$errors)");
00056 $this->_send_struct("ua",$ua);
00057 $this->_send_struct("fields",$fields);
00058 $this->_log("conf_id: $conf_id");
00059 $this->_send_struct("errors",$errors);
00060 $this->_log("END: preConfirm");
00061 return(array());
00062 }
00063 function setupUser(&$ua,&$fields,$confirm_id){
00064 $this->_log("METHOD: setupUser($ua,$fields,$confirm_id)");
00065 $this->_send_struct("ua",$ua);
00066 $this->_send_struct("fields",$fields);
00067 $this->_log("conf_id: $confirm_id");
00068 $this->_log("END: setupUser");
00069 }
00070 function removeUser(&$ua,$uid,&$fields) {
00071 $this->_log("METHOD: removeUser($ua,$uid,&$fields)");
00072 $this->_send_struct("ua",$ua);
00073 $this->_log("uid: $uid");
00074 $this->_send_struct("fields",$fields);
00075 $this->_log("END: removeUser");
00076 }
00077 function groupNameChange(&$gm,$gid,$name,$sign_ok,$is_new) {
00078 $this->_log("METHOD: groupNameChange($gm,$gid,$name,$sign_ok,$is_new)");
00079 $this->_send_struct("gm",$gm);
00080 $this->_log("gid: $gid");
00081 $this->_log("name: $name");
00082 $this->_log("sign_ok: $sign_ok");
00083 $this->_log("is_new: $is_new");
00084 $this->_log("END: groupNameChange");
00085 }
00086 function groupNameDelete(&$gm,$gid,&$info) {
00087 $this->_log("METHOD: groupNameDelete($gm,$gid,&$info)");
00088 $this->_send_struct("gm",$gm);
00089 $this->_log("gid: $gid");
00090 $this->_send_struct("info",$info);
00091 $this->_log("END: groupNameDelete");
00092 }
00093 function userInfoChanged(&$um,$uid,&$old_values,&$new_values) {
00094 $this->_log("METHOD: userInfoChanged($um,$uid,$old_values,$new_values)");
00095 $this->_send_struct("gm",$um);
00096 $this->_log("uid: $uid");
00097 $this->_send_struct("old_values",$old_values);
00098 $this->_send_struct("old_values",$new_values);
00099 $this->_log("END: userInfoChanged");
00100 }
00101 function userGroupsChanged(&$gm,$uid,&$oldg,&$newg){
00102 $this->_log("METHOD: userGroupsChanged($gm,$uid,$oldg,$newg)");
00103 $this->_send_struct("gm",$gm);
00104 $this->_log("uid: $uid");
00105 $this->_send_struct("old_gid",$oldg);
00106 $this->_send_struct("new_gid",$newg);
00107 $this->_log("END: userGroupsChanged");
00108 }
00109 function propertyCreated(&$prop, &$section, &$property, &$description) {
00110 $this->_log("METHOD: propertyCreated($prop, $section, $property, $description)");
00111 $this->_send_struct("prop",$prop);
00112 $this->_log("section: $section");
00113 $this->_log("property: $section");
00114 $this->_log("description: $section");
00115 $this->_log("END: propertyCreated");
00116 }
00117 function propertyChanged(&$prop, $uid, &$section, &$property, &$old_value, &$new_value) {
00118 $this->_log("METHOD: propertyChanged($prop, $uid, $section, $property, $old_value, $new_value)");
00119 $this->_send_struct("prop",$prop);
00120 $this->_log("uid: $uid");
00121 $this->_log("section: $section");
00122 $this->_log("property: $property");
00123 $this->_log("old_value: $old_value");
00124 $this->_log("new_value: $new_value");
00125 $this->_log("END: propertyChanged:");
00126 }
00127 function propertyRemoved(&$prop,$uid,$section,$property,$old_value) {
00128 $this->_log("METHOD: propertyRemoved($prop,$uid,$section,$property,$old_value)");
00129 $this->_send_struct("prop",$prop);
00130 $this->_log("uid: $uid");
00131 $this->_log("section: $section");
00132 $this->_log("property: $property");
00133 $this->_log("old_value: $old_value");
00134 $this->_log("END: propertyRemoved");
00135 }
00136 function propertyUndefine(&$prop,$section,$property) {
00137 $this->_log("METHOD: propertyUndefine($prop,$section,$property)");
00138 $this->_send_struct("prop",$prop);
00139 $this->_log("section: $section");
00140 $this->_log("property: $property");
00141 $this->_log("END: propertyUndefine");
00142 }
00143 function dispatchStart(&$controller,$trigger,$method) {
00144 $this->_log("METHOD: dispatchStart($controller,$trigger,$method)");
00145 $this->_send_struct("controller",$controller);
00146 $this->_log("trigger: $trigger");
00147 $this->_log("trigger: $method");
00148 $this->_log("END: dispatchStart");
00149 }
00150 function dispatchEnd(&$controller,$method,&$view) {
00151 $this->_log("METHOD: dispatchEnd($controller,$method,$view)");
00152 $this->_send_struct("controller",$controller);
00153 $this->_log("method: $method");
00154 $this->_send_struct("view",$view);
00155 $this->_log("END: dispatchEnd");
00156 }
00157 }
00158
00159 ?>