/** * Returns default skin name * * @param string $sPluginName * @param string $sCompatibility * * @return string */ public static function GetDefaultSkin($sPluginName, $sCompatibility = null) { $sPluginDirName = self::_pluginDirName($sPluginName); if (!$sCompatibility) { $sCompatibility = Config::Val('view.compatible', 'alto'); } $sResult = Config::Get('plugin.' . $sPluginDirName . '.default.skin.' . $sCompatibility); if (!$sResult) { $sResult = 'default'; } return $sResult; }
protected function _eventRecoveryRequest($sMail) { if ($oUser = E::ModuleUser()->GetUserByMail($sMail)) { // Формируем и отправляем ссылку на смену пароля /** @var ModuleUser_EntityReminder $oReminder */ $oReminder = E::GetEntity('User_Reminder'); $oReminder->setCode(F::RandomStr(32)); $oReminder->setDateAdd(F::Now()); $oReminder->setDateExpire(date('Y-m-d H:i:s', time() + Config::Val('module.user.pass_recovery_delay', 60 * 60 * 24 * 7))); $oReminder->setDateUsed(null); $oReminder->setIsUsed(0); $oReminder->setUserId($oUser->getId()); if (E::ModuleUser()->AddReminder($oReminder)) { E::ModuleNotify()->SendReminderCode($oUser, $oReminder); E::ModuleMessage()->AddNotice(E::ModuleLang()->Get('password_reminder_send_link')); return true; } } return false; }
/** * Проверяет URL топика на совпадения и, если нужно, делает его уникальным * * @param string $sUrl * * @return string */ public function CorrectTopicUrl($sUrl) { $iOnDuplicateUrl = Config::Val('module.topic.on_duplicate_url', 1); if ($iOnDuplicateUrl) { // Получаем список топиков с похожим URL $aTopics = $this->GetTopicsLikeUrl($sUrl); if ($aTopics) { $aExistUrls = array(); foreach ($aTopics as $oTopic) { $aExistUrls[] = $oTopic->GetTopicUrl(); } $nNum = count($aTopics) + 1; $sNewUrl = $sUrl . '-' . $nNum; while (in_array($sNewUrl, $aExistUrls)) { $sNewUrl = $sUrl . '-' . ++$nNum; } $sUrl = $sNewUrl; } } return $sUrl; }
public function ValidatePassword($sValue, $aParams) { $iMinLength = Config::Val('module.security.password_len', 3); if ($sValue && $this->getLogin() && $sValue === $this->getLogin()) { return E::ModuleLang()->Get('registration_password_error', array('min' => $iMinLength)); } if (mb_strlen($sValue, 'UTF-8') < $iMinLength) { return E::ModuleLang()->Get('registration_password_error', array('min' => $iMinLength)); } return true; }
public function EventDashboard() { $this->sMainMenuItem = 'info'; $aDashboardWidgets = array('admin_dashboard_updates' => array('name' => 'admin_dashboard_updates', 'key' => 'admin.dashboard.updates', 'status' => Config::Val('admin.dashboard.updates', true), 'label' => E::ModuleLang()->Get('action.admin.dashboard_updates_title')), 'admin_dashboard_news' => array('name' => 'admin_dashboard_news', 'key' => 'admin.dashboard.news', 'status' => Config::Val('admin.dashboard.news', true), 'label' => E::ModuleLang()->Get('action.admin.dashboard_news_title'))); if ($this->IsPost('widgets')) { $aWidgets = F::Array_FlipIntKeys($this->GetPost('widgets')); $aConfig = array(); foreach ($aDashboardWidgets as $aDashboardWidget) { if (isset($aWidgets[$aDashboardWidget['name']])) { $aConfig[$aDashboardWidget['key']] = 1; } else { $aConfig[$aDashboardWidget['key']] = 0; } } Config::WriteCustomConfig($aConfig); R::Location('admin'); } $this->_setTitle(E::ModuleLang()->Get('action.admin.menu_info_dashboard')); $this->SetTemplateAction('info/index'); $this->sMenuItem = $this->_getMode(0, 'index'); $aData = array('e-alto' => ALTO_VERSION, 'e-uniq' => E::ModuleSecurity()->GetUniqKey()); $aPlugins = E::ModulePlugin()->GetPluginsList(true); foreach ($aPlugins as $oPlugin) { $aData['p-' . $oPlugin->GetId()] = $oPlugin->GetVersion(); } $aSkins = E::ModuleSkin()->GetSkinsList(); foreach ($aSkins as $oSkin) { $aData['s-' . $oSkin->GetId()] = $oSkin->GetVersion(); } E::ModuleViewer()->Assign('sUpdatesRequest', base64_encode(http_build_query($aData))); E::ModuleViewer()->Assign('sUpdatesRefresh', true); E::ModuleViewer()->Assign('aDashboardWidgets', $aDashboardWidgets); }
/** * Генерация URL топиков. Процесс может быть долгим, поэтому стараемся предотвратить ошибку по таймауту */ public function GenerateTopicsUrl() { $nRecLimit = 500; $nTimeLimit = F::ToSeconds(ini_get('max_execution_time')) * 0.8 - 5 + time(); $nResult = -1; while (true) { $aData = $this->oMapper->GetTitleTopicsWithoutUrl($nRecLimit); if (!$aData) { $nResult = 0; break; } foreach ($aData as $nTopicId => $sTopicTitle) { $aData[$nTopicId]['topic_url'] = substr(F::TranslitUrl($aData[$nTopicId]['topic_title']), 0, 240); } if (!$this->oMapper->SaveTopicsUrl($aData)) { return -1; } // если время на исходе, то завершаем if (time() >= $nTimeLimit) { break; } } if ($nResult == 0) { // нужно ли проверять ссылки на дубликаты $iOnDuplicateUrl = Config::Val('module.topic.on_duplicate_url', 1); if ($iOnDuplicateUrl) { $this->CheckDuplicateTopicsUrl(); } } else { $nResult = $this->GetNumTopicsWithoutUrl(); } return $nResult; }
/** * Updates comment * */ protected function AjaxUpdateComment() { // * Устанавливаем формат Ajax ответа E::ModuleViewer()->SetResponseAjax('json'); // * Пользователь авторизован? if (!$this->oUserCurrent) { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('need_authorization'), E::ModuleLang()->Get('error')); return; } if (!E::ModuleSecurity()->ValidateSendForm(false) || $this->GetPost('comment_mode') != 'edit') { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('system_error'), E::ModuleLang()->Get('error')); return; } // * Проверяем текст комментария $sNewText = E::ModuleText()->Parse($this->GetPost('comment_text')); $iMin = Config::Val('module.comment.min_length', 2); $iMax = Config::Val('module.comment.max_length', 0); if (!F::CheckVal($sNewText, 'text', $iMin, $iMax)) { if ($iMax) { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('topic_comment_text_len', array('min' => $iMin, 'max' => $iMax)), E::ModuleLang()->Get('error')); } else { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('topic_comment_text_min', array('min' => $iMin)), E::ModuleLang()->Get('error')); } return; } // * Получаем комментарий $iCommentId = intval($this->GetPost('comment_id')); /** var ModuleComment_EntityComment $oComment */ if (!$iCommentId || !($oComment = E::ModuleComment()->GetCommentById($iCommentId))) { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('system_error'), E::ModuleLang()->Get('error')); return; } if (!$oComment->isEditable()) { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('comment_cannot_edit'), E::ModuleLang()->Get('error')); return; } if (!$oComment->getEditTime() && !$oComment->isEditable(false)) { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('comment_edit_timeout'), E::ModuleLang()->Get('error')); return; } // Если все нормально, то обновляем текст $oComment->setText($sNewText); if (E::ModuleComment()->UpdateComment($oComment)) { $oComment = E::ModuleComment()->GetCommentById($iCommentId); E::ModuleViewer()->AssignAjax('nCommentId', $oComment->getId()); E::ModuleViewer()->AssignAjax('sText', $oComment->getText()); E::ModuleViewer()->AssignAjax('sDateEdit', $oComment->getCommentDateEdit()); E::ModuleViewer()->AssignAjax('sDateEditText', E::ModuleLang()->Get('date_now')); E::ModuleMessage()->AddNoticeSingle(E::ModuleLang()->Get('comment_updated')); } else { E::ModuleMessage()->AddErrorSingle(E::ModuleLang()->Get('system_error'), E::ModuleLang()->Get('error')); } }
/** * @param int|string $xSize * * @return string */ public function getAvatarImageSizeStyle($xSize = null) { // Gets default size from config or sets it to default if (empty($xSize)) { $xSize = Config::Val('module.user.profile_avatar_size', self::DEFAULT_AVATAR_SIZE); } $aImgSize = $this->_defineImageSize('profile_avatar', $xSize); return $aImgSize['style']; }