Index: trunk/core/kernel/startup.php =================================================================== diff -u -N -r3431 -r3576 --- trunk/core/kernel/startup.php (.../startup.php) (revision 3431) +++ trunk/core/kernel/startup.php (.../startup.php) (revision 3576) @@ -47,6 +47,7 @@ define('MODULES_PATH', FULL_PATH); define('EXPORT_PATH', FULL_PATH.'/admin/export'); define('GW_CLASS_PATH', MODULES_PATH.'/in-commerce/units/gateways/gw_classes'); // Payment Gateway Classes Path + define('SYNC_CLASS_PATH', FULL_PATH.'/sync'); // path for 3rd party user syncronization scripts safeDefine('ENV_VAR_NAME','env'); Index: trunk/kernel/include/parseditem.php =================================================================== diff -u -N -r3476 -r3576 --- trunk/kernel/include/parseditem.php (.../parseditem.php) (revision 3476) +++ trunk/kernel/include/parseditem.php (.../parseditem.php) (revision 3576) @@ -1738,7 +1738,7 @@ } - function GetPageLinkList($dest_template=NULL,$page = "",$PagesToList=10, $HideEmpty=TRUE,$EnvSuffix = '') + function GetPageLinkList($dest_template=NULL,$page = "",$PagesToList=10, $HideEmpty=TRUE,$EnvSuffix = '', $extra_attributes = '') { global $objConfig, $var_list_update, $var_list; @@ -1778,7 +1778,7 @@ ${$v}[$this->PageEnvarIndex] = $this->Page - $PagesToList; $prev_url = HREF_Wrapper('', $url_params); - $o .= '<<'; + $o .= '<<'; } for($p = $StartPage; $p <= $EndPage; $p++) @@ -1787,19 +1787,19 @@ { ${$v}[$this->PageEnvarIndex] = $p; $href = HREF_Wrapper('', $url_params); - $o .= ' '.$p.' '; + $o .= ' '.$p.' '; } else { - $o .= " $p"; + $o .= ' '.$p.''; } } if($EndPage < $NumPages && $EndPage > 0) { ${$v}[$this->PageEnvarIndex] = $this->Page + $PagesToList; $next_url = HREF_Wrapper('', $url_params); - $o .= " >>"; + $o .= ' >>'; } unset(${$v}[$this->PageEnvarIndex],$var_list_update["t"] ); return $o; Index: trunk/kernel/units/users/users_event_handler.php =================================================================== diff -u -N -r3484 -r3576 --- trunk/kernel/units/users/users_event_handler.php (.../users_event_handler.php) (revision 3484) +++ trunk/kernel/units/users/users_event_handler.php (.../users_event_handler.php) (revision 3576) @@ -76,11 +76,13 @@ $event->status = erFAIL; } - $next_template = $this->Application->GetVar('next_template'); - if($next_template) $event->redirect = $next_template; - if ($this->Application->ConfigValue('UseJSRedirect')) { - $event->SetRedirectParam('js_redirect', 1); - } + $next_template = $this->Application->GetVar('next_template'); + if($next_template) $event->redirect = $next_template; + if ($this->Application->ConfigValue('UseJSRedirect')) { + $event->SetRedirectParam('js_redirect', 1); + } + $sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array(), 'InPortalSyncronize'); + $sync_manager->performAction('LoginUser', $object->GetDBField('Login'), $password); } else { @@ -101,11 +103,26 @@ */ function OnInpLogin(&$event) { - + $sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array(), 'InPortalSyncronize'); + $sync_manager->performAction('LoginUser', $event->getEventParam('user'), $event->getEventParam('pass') ); } + /** + * Called when user logs in using old in-portal + * + * @param kEvent $event + */ + function OnInpLogout(&$event) + { + $sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array(), 'InPortalSyncronize'); + $sync_manager->performAction('LogoutUser'); + } + function OnLogout(&$event) { + $sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array(), 'InPortalSyncronize'); + $sync_manager->performAction('LogoutUser'); + $session =& $this->Application->recallObject('Session'); $session->SetField('PortalUserId', -2); $this->Application->SetVar('u_id', -2); Index: trunk/core/units/users/users_item.php =================================================================== diff -u -N -r3307 -r3576 --- trunk/core/units/users/users_item.php (.../users_item.php) (revision 3307) +++ trunk/core/units/users/users_item.php (.../users_item.php) (revision 3576) @@ -161,6 +161,10 @@ if ($ret) { $this->UpdateCustomFields(); + + // find out how to syncronize user only when it's copied to live table + $sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array(), 'InPortalSyncronize'); + $sync_manager->performAction('createUser', $this->FieldValues); } return $ret; } @@ -172,10 +176,33 @@ if ($ret) { $this->UpdateCustomFields(); + + // find out how to syncronize user only when it's copied to live table + $sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array(), 'InPortalSyncronize'); + $sync_manager->performAction('updateUser', $this->FieldValues); } return $ret; } + /** + * Deletes the record from databse + * + * @access public + * @return bool + */ + function Delete($id = null) + { + $ret = parent::Delete($id); + + if ($ret) + { + $sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array(), 'InPortalSyncronize'); + $sync_manager->performAction('deleteUser', $this->FieldValues); + } + + return $ret; + } + } ?> \ No newline at end of file Index: trunk/core/units/users/users_event_handler.php =================================================================== diff -u -N -r3484 -r3576 --- trunk/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 3484) +++ trunk/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 3576) @@ -76,11 +76,13 @@ $event->status = erFAIL; } - $next_template = $this->Application->GetVar('next_template'); - if($next_template) $event->redirect = $next_template; - if ($this->Application->ConfigValue('UseJSRedirect')) { - $event->SetRedirectParam('js_redirect', 1); - } + $next_template = $this->Application->GetVar('next_template'); + if($next_template) $event->redirect = $next_template; + if ($this->Application->ConfigValue('UseJSRedirect')) { + $event->SetRedirectParam('js_redirect', 1); + } + $sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array(), 'InPortalSyncronize'); + $sync_manager->performAction('LoginUser', $object->GetDBField('Login'), $password); } else { @@ -101,11 +103,26 @@ */ function OnInpLogin(&$event) { - + $sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array(), 'InPortalSyncronize'); + $sync_manager->performAction('LoginUser', $event->getEventParam('user'), $event->getEventParam('pass') ); } + /** + * Called when user logs in using old in-portal + * + * @param kEvent $event + */ + function OnInpLogout(&$event) + { + $sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array(), 'InPortalSyncronize'); + $sync_manager->performAction('LogoutUser'); + } + function OnLogout(&$event) { + $sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array(), 'InPortalSyncronize'); + $sync_manager->performAction('LogoutUser'); + $session =& $this->Application->recallObject('Session'); $session->SetField('PortalUserId', -2); $this->Application->SetVar('u_id', -2); Index: trunk/kernel/units/users/users_item.php =================================================================== diff -u -N -r3307 -r3576 --- trunk/kernel/units/users/users_item.php (.../users_item.php) (revision 3307) +++ trunk/kernel/units/users/users_item.php (.../users_item.php) (revision 3576) @@ -161,6 +161,10 @@ if ($ret) { $this->UpdateCustomFields(); + + // find out how to syncronize user only when it's copied to live table + $sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array(), 'InPortalSyncronize'); + $sync_manager->performAction('createUser', $this->FieldValues); } return $ret; } @@ -172,10 +176,33 @@ if ($ret) { $this->UpdateCustomFields(); + + // find out how to syncronize user only when it's copied to live table + $sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array(), 'InPortalSyncronize'); + $sync_manager->performAction('updateUser', $this->FieldValues); } return $ret; } + /** + * Deletes the record from databse + * + * @access public + * @return bool + */ + function Delete($id = null) + { + $ret = parent::Delete($id); + + if ($ret) + { + $sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array(), 'InPortalSyncronize'); + $sync_manager->performAction('deleteUser', $this->FieldValues); + } + + return $ret; + } + } ?> \ No newline at end of file Index: trunk/kernel/include/searchconfig.php =================================================================== diff -u -N -r3537 -r3576 --- trunk/kernel/include/searchconfig.php (.../searchconfig.php) (revision 3537) +++ trunk/kernel/include/searchconfig.php (.../searchconfig.php) (revision 3576) @@ -263,18 +263,26 @@ break;*/ case "boolean": - $ret = "'; + + $ret .= ''; + + $ret .= ''; + $ret .= ''; break; case 'range': @@ -294,8 +302,11 @@ $checked[ $FormValues[$Field] ] = ' checked'; if(!$FormValues[$Field]) $checked[1] = ' checked'; - $ret = "".language("lu_and"); - $ret .= "".language("lu_or"); + $ret = ''; + $ret .= ''; + $ret .= ''; + $ret .= '
'.language('lu_and').''.language('lu_or').'
'; + return $ret; break; } Index: trunk/kernel/include/parse.php =================================================================== diff -u -N -r3428 -r3576 --- trunk/kernel/include/parse.php (.../parse.php) (revision 3428) +++ trunk/kernel/include/parse.php (.../parse.php) (revision 3576) @@ -424,245 +424,229 @@ function clsTemplateList($root_dir) { - $this->templates = array(); + $this->templates = Array(); $this->root_dir = $root_dir; - $this->ErrorStr = ""; + $this->ErrorStr = ''; $this->ErrorNo = 0; $this->SkipIncludes = 0; - $this->stack = array(); + $this->stack = Array(); } function InStack($template) { - return in_array($template,$this->stack) ? true : false; + return in_array($template, $this->stack) ? true : false; } - function GetTemplate($name,$SupressError=FALSE, $tbody=null) + function GetTemplate($name, $SupressError = false, $tbody = null) { - if(!strlen($name)) - { - $ret = FALSE; - if(!$SupressError) - { + if (!$name) { + $ret = false; + if (!$SupressError) { $this->ErrorNo = -2; - $this->ErrorStr=language("lu_template_error").":".language("lu_no_template_error"); + $this->ErrorStr = language('lu_template_error').':'.language('lu_no_template_error'); } } - else - { - $ret = FALSE; + else { + $ret = false; if ( !isset($tbody) ) { //Kernel4 fix $ret = isset($this->templates[$name]) ? $this->templates[$name] : false; - // this was original: - /*foreach($this->templates as $n => $t) - { - if($n == $name) - { - $ret = $t; - break; - } - }*/ } - if(!is_object($ret)) - { + + if (!is_object($ret)) { $ret = new clsTemplate($name); - if($ret->LoadFile($this->root_dir, $SupressError, $tbody)) - { - $this->templates[$name]=$ret; + if ($ret->LoadFile($this->root_dir, $SupressError, $tbody)) { + $this->templates[$name] = $ret; } - else - { - if( IsDebugMode() ) - { + else { + if ( IsDebugMode() ) { $GLOBALS['debugger']->appendHTML('Warning: Template '.$name.' not found'); } - if(!$SupressError) - { + + if (!$SupressError) { $this->ErrorNo = -1; - $this->ErrorStr = language("lu_template_error").":".language($ret->error).":"."'$name'"; + $this->ErrorStr = language('lu_template_error').':'.language($ret->error).':'.'"'.$name.'"'; LogEntry($this->ErrorStr); } } } } + return $ret; } - function GetTemplateCache($template,$SupressError=FALSE) + function GetTemplateCache($template, $SupressError = false) { global $CurrentTheme, $pathtoroot; + $ret = ''; - if(!is_object($CurrentTheme)) { - $CurrentTheme = $objThemes->GetItem($m_var_list["theme"]); + if (!is_object($CurrentTheme)) { + $CurrentTheme = $objThemes->GetItem($m_var_list['theme']); } - if( $CurrentTheme->Get("CacheTimeout") > 0) - { + + if ($CurrentTheme->Get('CacheTimeout') > 0) { $id = $CurrentTheme->GetTemplateId($template); - if($id) - { + + if ($id) { $exp = isset($CurrentTheme->ParseCacheDate[$id]) ? $CurrentTheme->ParseCacheDate[$id] : false; - if($exp) - { + + if($exp) { //echo "$template Cache expires: ".adodb_date("m-d-Y h:m s",$exp)."
\n"; - if( $exp > adodb_mktime() ) - { + if ($exp > adodb_mktime()) { /* look for a cache file */ $t = new clsTemplate($template); $dir = $CurrentTheme->ThemeDirectory(); - if( $t->LoadFile($dir."/_cache/",$SupressError) ) $ret = $t->source; + if( $t->LoadFile($dir.'/_cache/', $SupressError) ) { + $ret = $t->source; + } } } } } + return $ret; } function SaveTemplateCache($objTemplate) { global $CurrentTheme, $objThemes, $pathtoroot; - if(!is_object($CurrentTheme)) - $CurrentTheme = $objThemes->GetItem($m_var_list["theme"]); + if (!is_object($CurrentTheme)) { + $CurrentTheme = $objThemes->GetItem($m_var_list['theme']); + } - if($CurrentTheme->Get("CacheTimeout")>0) - { + if ($CurrentTheme->Get('CacheTimeout') > 0) { $TemplateId = $CurrentTheme->GetTemplateId($objTemplate->name); - if($TemplateId) - { - if(isset($CurrentTheme->ParseCacheDate[$TemplateId])) - { + + if($TemplateId) { + if (isset($CurrentTheme->ParseCacheDate[$TemplateId])) { //echo "Writing Template ".$objTemplate->name."
\n"; $interval = $CurrentTheme->ParseCacheTimeout[$TemplateId]; - $CurrentTheme->UpdateFileCacheData($TemplateId,adodb_mktime()+$interval); - $dir = $CurrentTheme->ThemeDirectory()."/_cache/"; + $CurrentTheme->UpdateFileCacheData($TemplateId, adodb_mktime() + $interval); + $dir = $CurrentTheme->ThemeDirectory().'/_cache/'; $objTemplate->WriteFile($dir); } } } } - function IncludeTemplate($tag, $SupressError=FALSE) - { - global $LogLevel, $objSession,$objLanguages, $var_list; + function IncludeTemplate($tag, $SupressError = false) + { + global $LogLevel, $objSession, $objLanguages, $var_list; - $t = ''; - $ret = ''; - $SupressError = ($SupressError || $tag->GetAttributeByName("_supresserror")); - switch($tag->name) - { - case 'perm_include': - $perms = $tag->GetAttributeByName('_permission'); - if(strlen($perms)) - { - $plist = explode(',',$perms); - $value=0; - $CheckSys = $tag->GetAttributeByName('_system'); - for($p=0;$pGetAttributeByName('_supresserror')); + switch ($tag->name) { + case 'perm_include': + $perms = $tag->GetAttributeByName('_permission'); + if ($perms) { + $plist = explode(',', $perms); + $value = 0; + $CheckSys = $tag->GetAttributeByName('_system'); + for ($p = 0; $p < count($plist); $p++) { + if ($plist[$p] == 'login') { + $var_list['dest'] = $var_list['t']; + } + + $perm_name = trim($plist[$p]); + if ($objSession->HasCatPermission($perm_name)) { + $value = 1; + break; + } + elseif ($CheckSys && $objSession->HasSystemPermission($perm_name)) { + $value = 1; + break; + } + } + $t = $tag->GetAttributeByName( $value ? '_template' : '_noaccess'); + + } + else { + $module = $tag->GetAttributeByName('_module'); + if ($module) { + $t = $tag->GetAttributeByName( ModuleEnabled($module) ? '_template' : '_noaccess' ); + } + } + break; - if($objSession->HasCatPermission(trim($plist[$p]))) - { - $value = 1; - break; + case 'lang_include': + $lang = $tag->GetAttributeByName('_language'); + if ($lang) { + $LangId = $objSession->Get('Language'); + $l = $objLanguages->GetItem($LangId); + if (strtolower($lang) == strtolower($l->Get('PackName'))) { + $t = $tag->GetAttributeByName('_template'); } - else + } + break; + + case 'include': + $t = $tag->GetAttributeByName('_template'); + break; + } + + LogEntry("Parsing $t\n"); + $LogLevel++; + + if ($t) { + if (!$this->InStack($t)) { + $parser_params = GetVar('parser_params'); // backup parser params from include we are currentry processing + + $ret = $this->GetTemplateCache($t, $SupressError); + if (!$ret) { + SetVar('parser_params', $tag->attributes); // set new parser params from new include statement + + $req = $tag->GetAttributeByName("_dataexists"); + if($req) { - if($CheckSys) + global $content_set; + $content_set=1; + $temp = $this->ParseTemplate($t,0,0,$SupressError); + if($content_set) { - if($objSession->HasSystemPermission(trim($plist[$p]))) + $ret = $temp; + } + else + { + $t_nodata = $tag->GetAttributeByName("_nodatatemplate"); + if(strlen($t_nodata)) { - $value = 1; - break; + $nodata_tag = new clsHtmlTag(); + $nodata = $tag; + $nodata->attributes = $tag->attributes; + $nodata->SetAttributeByName("_template",$t_nodata); + $nodata->SetAttributeByName("_nodatatemplate",""); + $nodata->SetAttributeByName("_dataexists",""); + + $ret = $this->IncludeTemplate($nodata,$SupressError); } + else + $ret = ""; } } - } - $t = $tag->GetAttributeByName( $value ? '_template' : '_noaccess'); + else { + $ret = $this->ParseTemplate($t,0,0,$SupressError); + } - } - else - { - $module = $tag->GetAttributeByName('_module'); - if(strlen($module)) - { - $t = $tag->GetAttributeByName( ModuleEnabled($module) ? '_template' : '_noaccess' ); + SetVar('parser_params', $parser_params); // restore parser params to backuped ones } } - break; + else { + $ret = ''; + } + } + + $LogLevel--; + if ($LogLevel < 0) { + $LogLevel = 0; + } + + LogEntry("Finished Parsing $t\n"); + return $ret; + } - case "lang_include": - $lang = $tag->GetAttributeByName("_language"); - if(strlen($lang)) - { - $LangId = $objSession->Get("Language"); - $l = $objLanguages->GetItem($LangId); - if(strtolower($lang)==strtolower($l->Get("PackName"))) - { - $t = $tag->GetAttributeByName("_template"); - } - } - break; - case 'include': - $t = $tag->GetAttributeByName("_template"); - break; - } - - LogEntry("Parsing $t\n"); - $LogLevel++; - - if($t) - { - if(!$this->InStack($t)) - { - //return $this->ParseTemplate($t); - //if(!$tag->GetAttributeByName("_nocache")); - $ret = $this->GetTemplateCache($t,$SupressError); - if(!strlen($ret)) - { - $req = $tag->GetAttributeByName("_dataexists"); - if($req) - { - global $content_set; - $content_set=1; - $temp = $this->ParseTemplate($t,0,0,$SupressError); - if($content_set) - { - $ret = $temp; - } - else - { - $t_nodata = $tag->GetAttributeByName("_nodatatemplate"); - if(strlen($t_nodata)) - { - $nodata_tag = new clsHtmlTag(); - $nodata = $tag; - $nodata->attributes = $tag->attributes; - $nodata->SetAttributeByName("_template",$t_nodata); - $nodata->SetAttributeByName("_nodatatemplate",""); - $nodata->SetAttributeByName("_dataexists",""); - $ret = $this->IncludeTemplate($nodata,$SupressError); - } - else - $ret = ""; - } - } - else - $ret = $this->ParseTemplate($t,0,0,$SupressError); - } - } - else - $ret = ""; - } - $LogLevel--; - if($LogLevel<0) - $LogLevel=0; - LogEntry("Finished Parsing $t\n"); - return $ret; - } - /* attributes = $tag->attributes; $el->attributes["_template"] = $tpath[$m].$t; $el->attributes["_module"] = $m; Index: trunk/kernel/include/adodb/adodb.inc.php =================================================================== diff -u -N -r3282 -r3576 --- trunk/kernel/include/adodb/adodb.inc.php (.../adodb.inc.php) (revision 3282) +++ trunk/kernel/include/adodb/adodb.inc.php (.../adodb.inc.php) (revision 3576) @@ -733,7 +733,10 @@ //$debugger->appendTrace(); } $this->_queryID = $this->_query($sql,$inputarr,$arg3); - if($profileSQLs && !$isSkipTable) $debugger->profileFinish('sql_'.$queryID); + if ($profileSQLs && !$isSkipTable) { + $debugger->profileFinish('sql_'.$queryID); + $debugger->profilerAddTotal('sql', 'sql_'.$queryID); + } /* Alexios Fakios notes that ErrorMsg() must be called before ErrorNo() for mssql because ErrorNo() calls Execute('SELECT @ERROR'), causing recure Index: trunk/kernel/units/general/inp1_parser.php =================================================================== diff -u -N -r3250 -r3576 --- trunk/kernel/units/general/inp1_parser.php (.../inp1_parser.php) (revision 3250) +++ trunk/kernel/units/general/inp1_parser.php (.../inp1_parser.php) (revision 3576) @@ -72,7 +72,7 @@ $lastExpire, $diffZone, $date, $nowDate, $lastExpireDate, $SearchPerformed, $TotalMessagesSent, $ado, $adminDir, $rootURL, $secureURL, $html, $timeout, $pathchar, $objTemplate, $objTopicList, $objArticleList, $objPostingList, $objCensorList, - $objSmileys, $objPMList; + $objSmileys, $objPMList, $SubscribeAddress, $SubscribeError, $SubscribeResult; $pathtoroot = $this->Application->IsAdmin() ? '../' : './'; $pathtoroot = realpath($pathtoroot)."/"; Index: trunk/kernel/include/itemdb.php =================================================================== diff -u -N -r3330 -r3576 --- trunk/kernel/include/itemdb.php (.../itemdb.php) (revision 3330) +++ trunk/kernel/include/itemdb.php (.../itemdb.php) (revision 3576) @@ -30,6 +30,12 @@ return $this->HasFormatter($field) ? $this->Formatters[$field] : false; } + function isLiveTable() + { + global $objSession; + return !preg_match('/'.GetTablePrefix().'ses_'.$objSession->GetSessionKey().'_edit_(.*)/', $this->tablename); + } + function SetFormatter($field, $type, $params) { // by Alex Index: trunk/core/units/general/inp1_parser.php =================================================================== diff -u -N -r3250 -r3576 --- trunk/core/units/general/inp1_parser.php (.../inp1_parser.php) (revision 3250) +++ trunk/core/units/general/inp1_parser.php (.../inp1_parser.php) (revision 3576) @@ -72,7 +72,7 @@ $lastExpire, $diffZone, $date, $nowDate, $lastExpireDate, $SearchPerformed, $TotalMessagesSent, $ado, $adminDir, $rootURL, $secureURL, $html, $timeout, $pathchar, $objTemplate, $objTopicList, $objArticleList, $objPostingList, $objCensorList, - $objSmileys, $objPMList; + $objSmileys, $objPMList, $SubscribeAddress, $SubscribeError, $SubscribeResult; $pathtoroot = $this->Application->IsAdmin() ? '../' : './'; $pathtoroot = realpath($pathtoroot)."/"; Index: trunk/core/units/users/users_syncronize.php =================================================================== diff -u -N --- trunk/core/units/users/users_syncronize.php (revision 0) +++ trunk/core/units/users/users_syncronize.php (revision 3576) @@ -0,0 +1,166 @@ +skipClass = $skip_class; + + $defs_file = SYNC_CLASS_PATH.'/sync_config.php'; + + if (file_exists($defs_file)) + { + include_once $defs_file; + foreach ($sync_classes as $class_info) { + $this->addSyncClass($class_info['class_name'], SYNC_CLASS_PATH.'/'.$class_info['class_file'], $class_info['sub_folder']); + } + } + } + + function addSyncClass($class_name, $class_file, $sub_folder) + { + $this->syncClasses[$class_name] = Array('file' => $class_file, 'sub_folder' => $sub_folder); + } + + /** + * Performs action specified for all syncronization classes. + * You can pass other arguments to function, they will be passed to action handler + * + * @param string $action + */ + function performAction($action) + { + $args = func_get_args(); + array_shift($args); + + foreach ($this->syncClasses as $class_name => $class_info) { + if ($class_name == $this->skipClass) continue; + $this->Application->registerClass($class_name, $class_info['file']); + $sync_object =& $this->Application->recallObject($class_name, null, Array(), $class_info['sub_folder'], $class_name); + call_user_func_array( Array(&$sync_object, $action), $args); + } + } + + /** + * Create new instance of object + * + * @return kBase + */ + function &makeClass($skip_class) + { + return new UsersSyncronizeManager($skip_class); + } + } + + + /** + * Base class for 3rd party site user syncronizations + * + */ + class UsersSyncronize extends kBase { + + /** + * Sub folder to which syncronizable tool is installed + * + * @var string + */ + var $subFolder = ''; + + /** + * Connection to database + * + * @var kDBConnection + * @access public + */ + var $Conn; + + function UsersSyncronize($sub_folder) + { + parent::kBase(); + $this->subFolder = $sub_folder; + $this->Conn =& $this->Application->GetADODBConnection(); + } + + /** + * Used to login user with given username & password + * + * @param string $user + * @param string $password + * @return bool + */ + function LoginUser($user, $password) + { + return true; + } + + /** + * Used to logout currently logged in user (if any) + * + */ + function LogoutUser() + { + + } + + /** + * Creates user + * + * @param Array $user_data + * @return bool + */ + function createUser($user_data) + { + return true; + } + + /** + * Update user info with given $user_id + * + * @param Array $user_data + * @return bool + */ + function updateUser($user_data) + { + return true; + } + + /** + * Deletes user + * + * @param Array $user_data + * @return bool + */ + function deleteUser($user_data) + { + return true; + } + + /** + * Create new instance of object + * + * @return kBase + */ + function &makeClass($sub_folder, $class_name) + { + return new $class_name($sub_folder); + } + } + +?> \ No newline at end of file Index: trunk/kernel/include/item.php =================================================================== diff -u -N -r3282 -r3576 --- trunk/kernel/include/item.php (.../item.php) (revision 3282) +++ trunk/kernel/include/item.php (.../item.php) (revision 3576) @@ -271,7 +271,7 @@ } } } - parent::Delete(); + return parent::Delete(); } /* item relationships */ Index: trunk/kernel/units/users/users_syncronize.php =================================================================== diff -u -N --- trunk/kernel/units/users/users_syncronize.php (revision 0) +++ trunk/kernel/units/users/users_syncronize.php (revision 3576) @@ -0,0 +1,166 @@ +skipClass = $skip_class; + + $defs_file = SYNC_CLASS_PATH.'/sync_config.php'; + + if (file_exists($defs_file)) + { + include_once $defs_file; + foreach ($sync_classes as $class_info) { + $this->addSyncClass($class_info['class_name'], SYNC_CLASS_PATH.'/'.$class_info['class_file'], $class_info['sub_folder']); + } + } + } + + function addSyncClass($class_name, $class_file, $sub_folder) + { + $this->syncClasses[$class_name] = Array('file' => $class_file, 'sub_folder' => $sub_folder); + } + + /** + * Performs action specified for all syncronization classes. + * You can pass other arguments to function, they will be passed to action handler + * + * @param string $action + */ + function performAction($action) + { + $args = func_get_args(); + array_shift($args); + + foreach ($this->syncClasses as $class_name => $class_info) { + if ($class_name == $this->skipClass) continue; + $this->Application->registerClass($class_name, $class_info['file']); + $sync_object =& $this->Application->recallObject($class_name, null, Array(), $class_info['sub_folder'], $class_name); + call_user_func_array( Array(&$sync_object, $action), $args); + } + } + + /** + * Create new instance of object + * + * @return kBase + */ + function &makeClass($skip_class) + { + return new UsersSyncronizeManager($skip_class); + } + } + + + /** + * Base class for 3rd party site user syncronizations + * + */ + class UsersSyncronize extends kBase { + + /** + * Sub folder to which syncronizable tool is installed + * + * @var string + */ + var $subFolder = ''; + + /** + * Connection to database + * + * @var kDBConnection + * @access public + */ + var $Conn; + + function UsersSyncronize($sub_folder) + { + parent::kBase(); + $this->subFolder = $sub_folder; + $this->Conn =& $this->Application->GetADODBConnection(); + } + + /** + * Used to login user with given username & password + * + * @param string $user + * @param string $password + * @return bool + */ + function LoginUser($user, $password) + { + return true; + } + + /** + * Used to logout currently logged in user (if any) + * + */ + function LogoutUser() + { + + } + + /** + * Creates user + * + * @param Array $user_data + * @return bool + */ + function createUser($user_data) + { + return true; + } + + /** + * Update user info with given $user_id + * + * @param Array $user_data + * @return bool + */ + function updateUser($user_data) + { + return true; + } + + /** + * Deletes user + * + * @param Array $user_data + * @return bool + */ + function deleteUser($user_data) + { + return true; + } + + /** + * Create new instance of object + * + * @return kBase + */ + function &makeClass($sub_folder, $class_name) + { + return new $class_name($sub_folder); + } + } + +?> \ No newline at end of file Index: trunk/kernel/include/portaluser.php =================================================================== diff -u -N -r3282 -r3576 --- trunk/kernel/include/portaluser.php (.../portaluser.php) (revision 3282) +++ trunk/kernel/include/portaluser.php (.../portaluser.php) (revision 3576) @@ -25,15 +25,48 @@ $this->LoadFromDatabase($UserId); } + function Create() + { + $ret = parent::Create(); + if ($ret && $this->isLiveTable()) + { + $application =& kApplication::Instance(); + $sync_manager =& $application->recallObject('UsersSyncronizeManager', null, Array(), 'InPortalSyncronize'); + $sync_manager->performAction('createUser', $this->Data); + } + return $ret; + } + + function Update($UpdatedBy = null, $modificationDate = null) + { + $ret = parent::Update($UpdatedBy, $modificationDate); + if ($ret && $this->isLiveTable()) + { + $application =& kApplication::Instance(); + $sync_manager =& $application->recallObject('UsersSyncronizeManager', null, Array(), 'InPortalSyncronize'); + $sync_manager->performAction('updateUser', $this->Data); + } + return $ret; + } + function Delete() { global $objGroups, $objFavorites; - + $g = $objGroups->GetPersonalGroup($this->Get("Login")); - if(is_object($g)) - $g->Delete(); + if (is_object($g)) $g->Delete(); + $objFavorites->DeleteUser($this->Get("PortalUserId")); //delete favorites - parent::Delete(); + $ret = parent::Delete(); + + if($ret && $this->isLiveTable()) + { + $application =& kApplication::Instance(); + $sync_manager =& $application->recallObject('UsersSyncronizeManager', null, Array(), 'InPortalSyncronize'); + $sync_manager->performAction('deleteUser', $this->Data); + } + + return $ret; } function RemoveFromAllGroups() Index: trunk/core/units/users/users_config.php =================================================================== diff -u -N -r3306 -r3576 --- trunk/core/units/users/users_config.php (.../users_config.php) (revision 3306) +++ trunk/core/units/users/users_config.php (.../users_config.php) (revision 3576) @@ -6,6 +6,10 @@ 'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'), 'EventHandlerClass' => Array('class'=>'UsersEventHandler','file'=>'users_event_handler.php','build_event'=>'OnBuild'), 'TagProcessorClass' => Array('class'=>'UsersTagProcessor','file'=>'users_tag_processor.php','build_event'=>'OnBuild'), + 'RegisterClasses' => Array( + Array('pseudo' => 'UsersSyncronizeManager', 'class' => 'UsersSyncronizeManager', 'file' => 'users_syncronize.php', 'build_event' => ''), + ), + 'AutoLoad' => true, 'Hooks' => Array( Array( Index: trunk/kernel/parser.php =================================================================== diff -u -N -r3351 -r3576 --- trunk/kernel/parser.php (.../parser.php) (revision 3351) +++ trunk/kernel/parser.php (.../parser.php) (revision 3576) @@ -209,9 +209,10 @@ */ function m_suggest_result() { - global $suggest_result; - - return $suggest_result; + global $objSession; + $ret = $objSession->GetVariable('suggest_result'); + $objSession->SetVariable('suggest_result', ''); + return $ret; } /* @@ -231,24 +232,19 @@ */ function m_subscribe_address() { - global $SubscribeAddress; - - if(strlen($_GET["subscribe_email"])) - return $_GET["subscribe_email"]; - - return ""; + global $objSession; + + return $objSession->GetVariable('SubscribeAddress'); } /* @description: Error message of subscribe to mailing list action */ function m_subscribe_error() { - global $SubscribeError; - - if(strlen($SubscribeError)) - return language($SubscribeError); - return ""; + global $objSession; + $error_phrase = $objSession->GetVariable('SubscribeError'); + return $error_phrase ? language($error_phrase) : ''; } @@ -1563,15 +1559,15 @@ if(!$notable) { $per_row = ceil($objCatList->NumItems()/$cols); - $o = ""; - $o .= "
"; + $o = ''; + $o .= '"; + $o .= ''; $o .= "\n
'; $CatCount = $objCatList->NumItems(); foreach($objCatList->Items as $cat) { $parsed=0; if($count==$per_row) { - $o .= ""; + $o .= ''; $count=0; } if($row==0 && strlen($attribs["_firstitemtemplate"])) @@ -1599,7 +1595,7 @@ $row++; } if($count != $per_row) - $o .= "
\n"; } else @@ -1808,12 +1804,12 @@ LoadLinkList($attribs); } */ - $o = $objCatList->GetPageLinkList($DestTemplate); + $o = $objCatList->GetPageLinkList($DestTemplate, '', 10, true, ExtraAttributes($attribs) ); if (strlen($image)) { $o_i = ' '; } if(strlen($o) && strlen($attribs["_label"])) - $o = $o_i.language($attribs["_label"]).$o; + $o = $o_i.language($attribs["_label"]).' '.$o; return $o; } @@ -1846,9 +1842,9 @@ { LoadCatSearchResults($attribs); } - $o = $objSearchCats->GetPageLinkList($DestTemplate); + $o = $objSearchCats->GetPageLinkList($DestTemplate, '', 10, true, ExtraAttributes($attribs)); if(strlen($o) && strlen($attribs["_label"])) - $o = language($attribs["_label"]).$o; + $o = language($attribs["_label"]).' '.$o; return $o; } @@ -2313,8 +2309,9 @@ */ function m_codevalidationresult($attribs=Array()) { - global $m_var_list_update; - return $m_var_list_update['codevalidationresult']; + global $objSession; + $result_phrase = $objSession->GetVariable('codevalidationresult'); + return $result_phrase ? language($result_phrase) : ''; } /* @@ -3710,6 +3707,49 @@ return IsDebugMode() ? true : ''; } + function m_param($params) + { + $parser_params = GetVar('parser_params'); + $param_name = strtolower($params['_name']); + $value = getArrayValue($parser_params, $param_name); + + if ($value) { + if (getArrayValue($params, '_asphrase')) { + $value = language($value); + } + } + + return $value; + } + + function m_set_category($params) + { + global $m_var_list; + + if (getArrayValue($params, '_onlyonce') && $m_var_list['cat']) return ; + + $db =& GetADODBConnection(); + $category_id = getArrayValue($params, '_catid'); + if (!$category_id) { + $module = getArrayValue($params, '_module'); + if ($module) { + + $sql = 'SELECT RootCat FROM '.GetTablePrefix().'Modules WHERE LOWER(Name) = '.$db->qstr( strtolower($module) ); + $category_id = $db->GetOne($sql); + } + } + + if ($category_id) { + $m_var_list['cat'] = $category_id; + } + } + + function m_template_equals($params) + { + $t = preg_replace('/(.*)\.tpl/', '\\1', $params['_template']); + return $GLOBALS['var_list']['t'] == $t ? true : ''; + } + /*function m_object($attribs=Array()) { $element = new clsHtmlTag(); Index: trunk/kernel/units/users/users_config.php =================================================================== diff -u -N -r3306 -r3576 --- trunk/kernel/units/users/users_config.php (.../users_config.php) (revision 3306) +++ trunk/kernel/units/users/users_config.php (.../users_config.php) (revision 3576) @@ -6,6 +6,10 @@ 'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'), 'EventHandlerClass' => Array('class'=>'UsersEventHandler','file'=>'users_event_handler.php','build_event'=>'OnBuild'), 'TagProcessorClass' => Array('class'=>'UsersTagProcessor','file'=>'users_tag_processor.php','build_event'=>'OnBuild'), + 'RegisterClasses' => Array( + Array('pseudo' => 'UsersSyncronizeManager', 'class' => 'UsersSyncronizeManager', 'file' => 'users_syncronize.php', 'build_event' => ''), + ), + 'AutoLoad' => true, 'Hooks' => Array( Array( Index: trunk/kernel/frontaction.php =================================================================== diff -u -N -r3282 -r3576 --- trunk/kernel/frontaction.php (.../frontaction.php) (revision 3282) +++ trunk/kernel/frontaction.php (.../frontaction.php) (revision 3576) @@ -61,7 +61,8 @@ $var_list['t'] = 'index'; } - $application->HandleEvent( new kEvent('u:OnInpLogin') ); + $event_params = Array('user' => $_POST['login_user'], 'pass' => $_POST['login_password']); + $application->HandleEvent( new kEvent('u:OnInpLogin', $event_params) ); $redirect_template = getArrayValue($var_list_update, 't') ? $var_list_update['t'] : $var_list['t']; $application->Redirect($redirect_template); @@ -98,7 +99,7 @@ $u->Set("PwRequestTime", 0); if ($exp_time > adodb_mktime()) { - $m_var_list_update['codevalidationresult'] = 'lu_resetpw_confirm_text'; + $objSession->SetVariable('codevalidationresult', 'lu_resetpw_confirm_text'); $newpw = makepassword(); SetVar('user_password', $newpw); $u->Set("Password",$newpw); @@ -112,10 +113,10 @@ $u->Update(); $u->Clean(); } else { - $m_var_list_update['codevalidationresult'] = 'lu_code_expired'; + $objSession->SetVariable('codevalidationresult', 'lu_code_expired'); } } else { - $m_var_list_update['codevalidationresult'] = 'lu_code_is_not_valid'; + $objSession->SetVariable('codevalidationresult', 'lu_code_is_not_valid'); } break; @@ -217,7 +218,7 @@ if(!ValidEmail($SubscribeAddress)&& strlen($SubscribeAddress)) { $t = $_GET["Error"]; - $SubscribeError = "lu_invalid_emailaddress"; + $objSession->SetVariable('SubscribeError', 'lu_invalid_emailaddress'); } else { @@ -236,7 +237,7 @@ if($u->CheckBanned()) { $t = $_GET["Error"]; - $SubscribeError ="lu_subscribe_banned"; + $objSession->SetVariable('SubscribeError', 'lu_subscribe_banned'); } else { @@ -254,22 +255,22 @@ else { $t = $_GET["Error"]; - $SubscribeError ="lu_subscribe_no_address"; + $objSession->SetVariable('SubscribeError', 'lu_subscribe_no_address'); } } else { $t = $_GET["Error"]; - $SubscribeError ="lu_subscribe_unknown_error"; + $objSession->SetVariable('SubscribeError', 'lu_subscribe_unknown_error'); } } } if(strlen($t)) { $var_list["t"] = $t; $var_list_update["t"] = $t; - } - + } + $objSession->SetVariable('SubscribeAddress', $SubscribeAddress); break; case "m_subscribe": @@ -829,6 +830,7 @@ } DeleteModuleTagCache('kernel'); break; + case "m_suggest_email": $cutoff = adodb_mktime()+(int)$objConfig->Get("Suggest_MinInterval"); $email = inp_striptags($_POST["suggest_email"]); @@ -847,7 +849,7 @@ { if(strlen($_GET["Error"])>0) $var_list["t"] = $_GET["Error"]; - $suggest_result = "$email ".language("lu_already_suggested ")." ".LangDate($rs->fields["sent"]); + $objSession->SetVariable('suggest_result', "$email ".language("lu_already_suggested ")." ".LangDate($rs->fields["sent"]) ); } else { @@ -862,7 +864,7 @@ $sql = "INSERT INTO ".GetTablePrefix()."SuggestMail (email,sent) VALUES ('".$email."','".adodb_mktime()."')"; $rs = $adodbConnection->Execute($sql); - $suggest_result=language("lu_suggest_success")." ".$email; + $objSession->SetVariable('suggest_result', language("lu_suggest_success")." ".$email); } } $e =& $objMessageList->GetEmailEventObject("USER.SUGGEST",1); @@ -878,14 +880,14 @@ { if(strlen($_GET["Error"])>0) $var_list["t"] = $_GET["Error"]; - $suggest_result=language("lu_invalid_emailaddress"); + $objSession->SetVariable('suggest_result', language("lu_invalid_emailaddress")); } } else { if(strlen($_GET["Error"])>0) $var_list["t"] = $_GET["Error"]; - $suggest_result=language("lu_suggest_no_address"); + $objSession->SetVariable('suggest_result', language("lu_suggest_no_address")); } break; case "m_simple_search": Index: trunk/kernel/include/category.php =================================================================== diff -u -N -r3330 -r3576 --- trunk/kernel/include/category.php (.../category.php) (revision 3330) +++ trunk/kernel/include/category.php (.../category.php) (revision 3576) @@ -1766,7 +1766,7 @@ return TableCount($this->SourceTable,"Status=".STATUS_PENDING,0); } - function GetPageLinkList($dest_template=NULL,$page="",$PagesToList=10,$HideEmpty=TRUE) + function GetPageLinkList($dest_template=NULL,$page="",$PagesToList=10,$HideEmpty=TRUE, $extra_attributes = '') { global $objConfig, $m_var_list_update, $var_list_update, $var_list; @@ -1806,7 +1806,7 @@ { $m_var_list_update["p"] = $this->Page-$PagesToList; $prev_url = HREF_Wrapper(); - $o .= "<<"; + $o .= '<<'; } @@ -1816,7 +1816,7 @@ { $m_var_list_update["p"]=$p; $href = HREF_Wrapper(); - $o .= " $p "; + $o .= ' '.$p.' '; } else { @@ -1827,7 +1827,7 @@ { $m_var_list_update["p"]=$this->Page+$PagesToList; $next_url = HREF_Wrapper(); - $o .= " >>"; + $o .= ' >>'; } unset($m_var_list_update,$var_list_update["t"] ); return $o; Index: trunk/kernel/include/modules.php =================================================================== diff -u -N -r3330 -r3576 --- trunk/kernel/include/modules.php (.../modules.php) (revision 3330) +++ trunk/kernel/include/modules.php (.../modules.php) (revision 3576) @@ -856,6 +856,10 @@ if($Action == 'm_logout') { $u = new clsUserSession($var_list['sid'] ,($SessionQueryString && $FrontEnd==1)); + + $application =& kApplication::Instance(); + $application->HandleEvent( new kEvent('u:OnInpLogout') ); + $u->Logout(); unset($u); $var_list_update['t'] = 'index'; Index: trunk/core/kernel/db/db_connection.php =================================================================== diff -u -N -r1560 -r3576 --- trunk/core/kernel/db/db_connection.php (.../db_connection.php) (revision 1560) +++ trunk/core/kernel/db/db_connection.php (.../db_connection.php) (revision 3576) @@ -538,5 +538,35 @@ { return $this->errorMessage; } + + function doInsert($fields_hash, $table) + { + $fields_sql = ''; + $values_sql = ''; + foreach ($fields_hash as $field_name => $field_value) { + $fields_sql .= '`'.$field_name.'`,'; + $values_sql .= $this->qstr($field_value).','; + } + + $fields_sql = preg_replace('/(.*),$/', '\\1', $fields_sql); + $values_sql = preg_replace('/(.*),$/', '\\1', $values_sql); + $sql = 'INSERT INTO `'.$table.'` ('.$fields_sql.') VALUES ('.$values_sql.')'; + + return $this->ChangeQuery($sql); + } + + function doUpdate($fields_hash, $table, $key_clause) + { + $fields_sql = ''; + foreach ($fields_hash as $field_name => $field_value) { + $fields_sql .= '`'.$field_name.'` = '.$this->qstr($field_value).','; + } + + $fields_sql = preg_replace('/(.*),$/', '\\1', $fields_sql); + + $sql = 'UPDATE `'.$table.'` SET '.$fields_sql.' WHERE '.$key_clause; + + return $this->ChangeQuery($sql); + } } ?> \ No newline at end of file