protected function invalidateUserCacheByUserId($userId) { if (empty($userId) or !is_numeric($userId)) { throw new InvalidArgumentException("\$userId have to be non zero integer"); } if ($this->memcache != null) { $this->memcache->invalidateCacheByTag(self::USER_TAG . $userId); } $hookParams = array('userId' => $userId); HookManager::callHook("ClearUserCache", $hookParams); }
/** * Load plugin * * @param boolean $overrideObjects */ public final function load($overrideObjects = false) { $hookArgs = array('packageName' => $this->packageName, 'pluginName' => $this->pluginName, 'pluginConfig' => $this->config); HookManager::callHook("BeforePluginInit", $hookArgs); $this->includes(); $this->customInitBeforeObjects(); $this->loadObjects($overrideObjects); $this->customInitAfterObjects(); $this->registerHooks(); HookManager::callHook("AfterPluginInit", $hookArgs); }
/** * Load all plugin that have been loaded to the queue */ public function load() { $this->buildAllowanceTables($this->pluginsToLoad); foreach ($this->pluginsToLoad as $packageName => $plugins) { foreach ($plugins as $pluginName) { $this->usePlugin($packageName, $pluginName); } HookManager::callHook("AfterThisPluginTreeInit"); HookManager::unRegisterHook("AfterThisPluginTreeInit"); } $this->customConfigs = new Config(); }
/** * Load plugin * * @param boolean $overrideObjects */ public final function load($overrideObjects = false, $forceIncludes = false) { $hookArgs = array('packageName' => $this->packageName, 'pluginName' => $this->pluginName, 'pluginConfig' => $this->config); HookManager::callHook("BeforePluginInit", $hookArgs); if ($forceIncludes or (!isset($GLOBALS['doNotIncludeClasses']) or $GLOBALS['doNotIncludeClasses'] !== true)) { $this->includes(); } $this->customInitBeforeObjects(); $this->loadObjects($overrideObjects); $this->customInitAfterObjects(); $this->registerHooks(); HookManager::callHook("AfterPluginInit", $hookArgs); }
/** * Login user of given user id * * @param integer $userId * @param boolean $writeCookie * * @return User */ public function doLogin($userId, $additionalCredentials = array(), $writeCookie = false) { if (empty($userId) or !is_numeric($userId)) { throw new InvalidArgumentException("\$userId have to be non zero integer!"); } $usr = $this->um->getUserById($userId); $this->checkIfLoginIsAllowed($usr); $hookParams = array("user" => $usr, "additionalCredentials" => $additionalCredentials); HookManager::callHook("OnUserLogin", $hookParams); $this->saveUserIdInSession($usr); $this->updateUserLastLoginDateAndIP($usr); if ($writeCookie) { $this->writeLoginCookie($usr); } return $usr; }
Debug::setMode($config->Debug->enabled); SiteMode::set($config->SiteMode->mode); // Register User Hooks if (isset($config->Hooks)) { foreach (get_object_vars($config->Hooks) as $hookName => $funcName) { if (is_object($funcName)) { foreach (get_object_vars($funcName) as $regFuncName) { HookManager::registerHook(new Hook($hookName, $regFuncName)); } } else { HookManager::registerHook(new Hook($hookName, $funcName)); } } } // Init packages/plugins HookManager::callHook("BeforePackagesLoad"); foreach (get_object_vars($config->Packages) as $package) { $package = get_object_vars($package); if (!isset($package[1])) { $package[1] = array(); } Reg::get('packageMgr')->addPackage($package[0], $package[1]); } Reg::get('packageMgr')->load(); HookManager::callHook("AfterPackagesLoad"); // Request Parser HookManager::callHook("BeforeRequestParser"); HookManager::callHook("BeforeRequestParserStep2"); HookManager::callHook("RequestParser"); HookManager::callHook("AfterRequestParser");
if (!empty($file['precompileCode'])) { $fileContents .= $file['precompileCode'] . "\n\n"; } $fileContents .= $content . "\n\n"; if (!empty($file['postcompileCode'])) { $fileContents .= $file['postcompileCode'] . "\n\n"; } } file_put_contents($classesCacheFilename, $fileContents); } } } // Request Parser HookManager::callHook("BeforeRequestParser"); HookManager::callHook("BeforeRequestParserStep2"); HookManager::callHook("RequestParser"); HookManager::callHook("AfterRequestParser"); HookManager::callHook("BeforeController"); HookManager::callHook("Controller"); HookManager::callHook("AfterController"); //$time = microtime(true); HookManager::callHook("BeforeOutput"); HookManager::callHook("Output"); HookManager::callHook("AfterOutput"); if (ConfigManager::getGlobalConfig()->Stingle->BootCompiler === true) { if (!file_exists($configCacheFilename) and !$isGetConfigFromCache) { file_put_contents($configCacheFilename, serialize(ConfigManager::mergeConfigs(ConfigManager::getGlobalConfig(), ConfigManager::getCache()))); } } //echo "out - " . (microtime(true) - $time) . "<br>"; // Finish
<?php require_once STINGLE_PATH . "configs/config.inc.php"; require_once SITE_CONFIGS_PATH . "config.inc.php"; require_once STINGLE_PATH . "init/init.php"; HookManager::callHook("BeforeController"); HookManager::callHook("Controller"); HookManager::callHook("AfterController"); HookManager::callHook("InitEnd");
public function changeConversationHasAttachmentStatus($uuid, $status, $userId = null) { if (empty($uuid) or !is_numeric($uuid)) { throw new InvalidIntegerArgumentException("\$uuid have to be non zero integer."); } if (!is_numeric($status) or !in_array($status, $this->getConstsArray("STATUS_HAS_ATTACHMENT"))) { throw new InvalidIntegerArgumentException("Invalid \$status specified"); } if ($userId !== null and (empty($userId) or !is_numeric($userId))) { throw new InvalidIntegerArgumentException("\$userId have to be non zero integer."); } $qb = new QueryBuilder(); $qb->update(Tbl::get('TBL_CONVERSATIONS'))->set(new Field('has_attachment'), $status)->where($qb->expr()->equal(new Field('uuid'), $uuid)); if ($userId !== null and !empty($userId) and is_numeric($userId)) { $qb->andWhere($qb->expr()->equal(new Field('user_id'), $userId)); } $this->query->exec($qb->getSQL()); $hookParams = array('type' => 'hasAttach', 'uuid' => $uuid, 'hasAttach' => $status); HookManager::callHook("ConversationUpdate", $hookParams); }
/** * Display a module page. <b>The $tpl var should be relative to /templates/modules * folder without a '/' at the begining.</b> * Examples: * home/home.tpl * users/profile.tpl * * @param string $tpl * @return SmartyWrapper */ public function output() { // Do not display anything if output is disabled if ($this->isOutputDisabled) { return; } // Call layout init hook if there is any $hookFunctionName = 'initLayout_' . $this->layoutName; if (function_exists($hookFunctionName)) { $hookName = 'hookInitLayout_' . $this->layoutName; $layoutHook = new Hook($hookName, $hookFunctionName); HookManager::registerHook($layoutHook); HookManager::callHook($hookName); } // Call per template hook $hookFunctionName = 'initTemplate_' . $this->template; if (function_exists($hookFunctionName)) { $hookName = 'hookInitTemplate_' . $this->template; $templateHook = new Hook($hookName, $hookFunctionName); HookManager::registerHook($templateHook); HookManager::callHook($hookName); } // Check if page exists and if not show 404 error page if (!file_exists($this->getFilePathFromTemplate("{$this->modulesPath}{$this->module}/{$this->page}.tpl", true))) { header("HTTP/1.0 404 Not Found"); $this->module = $this->errorsModule; $this->page = $this->error404Page; $this->removeWrapper(); } $this->defaultAssingns(); // Check if wrapper is set and if yes include it if (!empty($this->wrapper)) { $this->assign('modulePageTpl', $this->getFilePathFromTemplate($this->modulesPath . $this->module . "/" . $this->page . ".tpl")); $this->assign('__modulePageTpl', $this->getFilePathFromTemplate($this->modulesPath . $this->module . "/" . $this->wrappersDir . $this->wrapper . ".tpl")); } else { $this->assign('__modulePageTpl', $this->getFilePathFromTemplate($this->modulesPath . $this->module . "/" . $this->page . ".tpl")); } // Finally display parent::display($this->layoutPath); }
function shutdown() { HookManager::callHook('Shutdown'); }
/** * Set user permissions * * @param string $user_id * @param array $permissions_list * @return bool */ public function setUserPermissions($user_id, $permissions_list) { $user_id = intval($user_id); $perms_ids = $this->getPermsIds($permissions_list); $this->query->exec("delete from `" . Tbl::get('TBL_USERS_PERMISSIONS') . "` where `user_id`='{$user_id}'"); foreach ($perms_ids as $perm_id) { $this->query->exec("insert into `" . Tbl::get('TBL_USERS_PERMISSIONS') . "`(`user_id`,`permission_id`) values('{$user_id}', '{$perm_id}')"); } $hookArgs = array("userId" => $user_id, 'permissions' => $permissions_list); HookManager::callHook("postUserSetPermissions", $hookArgs); return true; }