protected function SubmitComment() { /** * Проверям авторизован ли пользователь */ if (!E::ModuleUser()->IsAuthorization()) { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('need_authorization'), E::ModuleLang()->Get('error')); return; } $xResult = E::Module('PluginMagicrules\\Rule')->CheckRuleAction('create_comment', $this->oUserCurrent); if (true === $xResult) { $xResult = E::Module('PluginMagicrules\\Rule')->CheckRuleCreateAction('comment', $this->oUserCurrent); } if (true === $xResult) { return parent::SubmitComment(); } else { if (is_string($xResult)) { E::ModuleMessage()->AddErrorSingle($xResult, E::ModuleLang()->Get('attention')); return; } else { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('plugin.magicrules.check_rule_action_error'), E::ModuleLang()->Get('attention')); return; } } }
public function AddVote(ModuleVote_EntityVote $oVote) { $bResult = parent::AddVote($oVote); if ($bResult) { E::Module('PluginMagicrules\\Rule')->CheckForCreateBlockVote($oVote); } return $bResult; }
protected function EventAdd() { $xResult = E::Module('PluginMagicrules\\Rule')->CheckRuleAction('create_topic', $this->oUserCurrent); if ($xResult === true) { return parent::EventAdd(); } else { if (is_string($xResult)) { E::ModuleMessage()->AddErrorSingle($xResult, E::ModuleLang()->Get('attention')); return Router::Action('error'); } else { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('plugin.magicrules.check_rule_action_error'), E::ModuleLang()->Get('attention')); return Router::Action('error'); } } }
/** * Добавление записи на стену */ public function EventWallAdd() { // * Устанавливаем формат Ajax ответа E::ModuleViewer()->SetResponseAjax('json'); // * Пользователь авторизован? if (!E::IsUser()) { return parent::EventNotFound(); } $xResult = E::Module('PluginMagicrules\\Rule')->CheckRuleAction('create_wall', E::User()); if ($xResult === true) { return parent::EventWallAdd(); } else { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('plugin.magicrules.check_rule_action_error'), E::ModuleLang()->Get('attention')); return Router::Action('error'); } }
/** * @return string|void */ protected function EventVoteUser() { // * Пользователь авторизован? if (!E::IsUser()) { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('need_authorization'), E::ModuleLang()->Get('error')); return; } $xResult = E::Module('PluginMagicrules\\Rule')->CheckRuleAction('vote_user', E::User(), array('vote_value' => (int) $this->getPost('value'))); if (true === $xResult) { return parent::EventVoteUser(); } else { if (is_string($xResult)) { E::ModuleMessage()->AddErrorSingle($xResult, E::ModuleLang()->Get('attention')); return Router::Action('error'); } else { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('plugin.magicrules.check_rule_action_error'), E::ModuleLang()->Get('attention')); return Router::Action('error'); } } }
/** * @return bool|string */ public function MakeCacheKey() { $aStack = debug_backtrace(false); $sCaller = ''; $sFile = false; foreach ($aStack as $aItem) { if ($sFile) { if (!empty($aItem['class']) && !empty($aItem['type']) && !empty($aItem['function'])) { $sCaller = $sFile . '|' . $aItem['class'] . $aItem['type'] . $aItem['function']; break; } } if (!empty($aItem['file']) && !empty($aItem['function']) && $aItem['function'] === __FUNCTION__) { $sFile = $aItem['file']; } } if ($sCaller) { $sActivePlugins = E::GetActivePluginsHash(); return E::Module('Cache')->Key($sActivePlugins . '|' . $sCaller, func_get_args()); } return false; }
protected function _initHooks() { $this->oModuleHook = E::Module('Hook'); $this->oModuleHook->AddObserver($this->sHookPrefix, array($this, 'HookObserver')); }