public function actionAdd() { $biography = new CBiography(); $biography->user_id = CSession::getCurrentUser()->getId(); $this->setData("biography", $biography); $this->renderView("_biography/add.tpl"); }
public function actionSave() { $quest = new CQuestion(); $quest->setAttributes(CRequest::getArray($quest::getClassName())); if ($quest->validate()) { if (!CSession::isAuth()) { $user = ""; } else { $user = CStaffManager::getUser(CSession::getCurrentUser()->getId())->getName(); } $quest->contact_info .= " " . $user . '; ip ' . $_SERVER["REMOTE_ADDR"]; if ($quest->answer_text != '') { $quest->datetime_answ = date("Y-d-m H:i:s", time()); } $quest->save(); if ($this->continueEdit()) { $this->redirect("?action=edit&id=" . $quest->getId()); } else { $this->redirect(WEB_ROOT); } return true; } $this->setData("quest", $quest); $this->renderView("__public/_question_add/edit.tpl"); }
public function onCreate(CModel $model) { $result = false; if (CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_WRITE_ALL) { /** * Пользователь может создавать что-нибудь только если у него уровень * Чтение и запись всех записей. */ $result = true; } return $result; }
public function actionIndex() { $parent = 0; $title = "Нормативные документы"; if (CRequest::getInt("parent")) { $parent = CRequest::getInt("parent"); $parentFolder = CDocumentsManager::getFolder($parent); if (!is_null($parentFolder)) { $title = $parentFolder->title; } } // извлекаем все папки с учетом иерархии $query = new CQuery(); $query->select("f.*")->from(TABLE_DOCUMENT_FOLDERS . " as f")->condition("f.parent_id = " . $parent)->order("f.title asc"); $objects = new CArrayList(); foreach ($query->execute()->getItems() as $ar) { $folder = new CDocumentFolder(new CActiveRecord($ar)); $objects->add($objects->getCount(), $folder); } // теперь извлекаем все файлы $query = new CQuery(); $query->select("f.*")->from(TABLE_DOCUMENTS . " as f")->condition("f.folder_id = " . $parent . " and f.nameFolder like 'gost%'")->order("f.browserFile asc"); foreach ($query->execute()->getItems() as $ar) { $file = new CDocumentFile(new CDocumentActiveRecord($ar)); $objects->add($objects->getCount(), $file); } $this->setData("title", $title); $this->setData("objects", $objects); /** * Генерация меню */ // если есть родительская папка, то переходим в нее if ($parent != 0) { $parentFolder = CDocumentsManager::getFolder($parent); if (!is_null($parentFolder)) { $this->addActionsMenuItem(array("title" => "Назад", "link" => "index.php?action=index&parent=" . $parentFolder->parent_id, "icon" => "actions/edit-undo.png")); } } // если пользователь может чего-нибудь добавлять, то пусть добавит $this->setData("canEdit", false); if (CSession::isAuth()) { if (CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_WRITE_ALL || CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_WRITE_OWN_ONLY) { $this->addActionsMenuItem(array("title" => "Создать папку", "link" => "index.php?action=add&parent=" . $parent, "icon" => "actions/folder-new.png")); $this->addActionsMenuItem(array("title" => "Загрузить файл", "link" => "files.php?action=add&parent=" . $parent, "icon" => "actions/bookmark-new.png")); $this->setData("canEdit", true); } } /** * Отображение представления */ $this->addCSSInclude("_modules/_documents/style.css"); $this->renderView("_documents/_folder/index.tpl"); }
public function actionIndex() { $settings = new CUserSettings(); $settings->user_id = CSession::getCurrentUser()->getId(); if (!is_null(CSession::getCurrentUser()->getPersonalSettings())) { $settings = CSession::getCurrentUser()->getPersonalSettings(); } $sizes = array(5, 6, 7, 8); $this->setData("sizes", $sizes); $this->setData("settings", $settings); $this->addActionsMenuItem(array("title" => "Добавить инфографику", "link" => "reports.php?action=add&id=" . $settings->getId(), "icon" => "actions/list-add.png")); $this->renderView("_settings/index.tpl"); }
public function actionAdd() { $newsItem = new CNewsItem(); $newsItem->user_id_insert = CSession::getCurrentUser()->getId(); $newsItem->date_time = date("d.m.Y"); $newsItem->news_type = "notice"; $this->addJSInclude(JQUERY_UI_JS_PATH); $this->addCSSInclude(JQUERY_UI_CSS_PATH); $this->addCSSInclude("_modules/_redactor/redactor.css"); $this->addJSInclude("_modules/_redactor/redactor.min.js"); $this->setData("newsItem", $newsItem); $this->renderView("_news/add.tpl"); }
public function actionIndex() { $this->addActionsMenuItem(array(array("title" => "Показатели преподавателей", "link" => "persons.php", "icon" => "apps/system-users.png"), array("title" => "Публикации", "link" => WEB_ROOT . "_modules/_staff/publications.php", "icon" => "actions/document-open.png"))); if (CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_WRITE_ALL) { $this->addActionsMenuItem(array(array("title" => "Типы изданий", "link" => "?action=types", "icon" => "actions/address-book-new.png"))); } $this->addJSInclude("_core/HighCharts/highcharts.src.js"); $this->addJSInclude("_core/HighCharts/modules/exporting.src.js"); $this->addJSInclude("_modules/_rating/ratingPublications.js"); $this->addJSInclude("_core/jquery-ui-1.8.20.custom.min.js"); $this->addJSInclude("_core/jTagIt/tag-it.js"); $this->addCSSInclude("_core/jUI/jquery-ui-1.8.2.custom.css"); $this->addCSSInclude("_core/jTagIt/jquery.tagit.css"); $this->renderView("_rating_publications/index.tpl"); }
/** * Проверяем, что текущий пользователь имеет право редактировать записи * * @param CModel $model * @return bool */ public function onUpdate(CModel $model) { $result = true; if (CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_NO_ACCESS) { /** * Проверим, что пользователь имеет доступ к текущей задаче */ $result = false; } elseif (CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_READ_OWN_ONLY || CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_READ_ALL) { /** * Пользователь с правом только на чтение не может что-либо сохранять */ $result = false; } elseif (CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_WRITE_OWN_ONLY) { /** * Проверим, что текущий пользователь есть в authors-полях модели, * которую будет сохранять */ $result = false; $coreModel = CCoreObjectsManager::getCoreModel($model); if (is_null($coreModel)) { /** * Если модели нет, то будем считать, что отвалидировано * успешно. Иначе сломается все остальное */ $result = true; } else { if ($coreModel->getAuthorsFields()->getCount() == 0) { /** * Не стопорим систему если она не настроена. * Если поля не указаны, то не валидируем */ $result = true; } else { /** * Проверяем, что текущий пользователь прописан в authors-полях модели */ foreach ($coreModel->getAuthorsFields()->getItems() as $field) { $fieldName = $field->field_name; if ($model->{$fieldName} == CSession::getCurrentPerson()->getId()) { $result = true; } } } } } return $result; }
public function actionSearch() { $res = array(); $term = CRequest::getString("query"); /** * Сначала поищем по названию группы */ $query = new CQuery(); $query->select("distinct(page.id) as id, page.title as name")->from(TABLE_PAGES . " as page")->condition("page.title like '%" . $term . "%'")->limit(0, 5); if (CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_READ_OWN_ONLY or CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_WRITE_OWN_ONLY) { $query->condition("page.title like '%" . $term . "%' AND page.user_id_insert = " . CSession::getCurrentUser()->getId()); } foreach ($query->execute()->getItems() as $item) { $res[] = array("field" => "id", "value" => $item["id"], "label" => $item["name"], "class" => "CPage"); } echo json_encode($res); }
public function actionIndex() { $set = new CRecordSet(); $query = new CQuery(); $query->select("gr.*")->from(TABLE_GRANTS . " as gr")->order("gr.id desc"); if (CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_READ_OWN_ONLY || CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_WRITE_OWN_ONLY) { $query->leftJoin(TABLE_GRANT_MEMBERS . " as m", "m.grant_id = gr.id"); $query->condition("gr.author_id=" . CSession::getCurrentPerson()->getId() . " OR m.person_id=" . CSession::getCurrentPerson()->getId() . " or gr.manager_id=" . CSession::getCurrentUser()->getId()); } $set->setQuery($query); $grants = new CArrayList(); foreach ($set->getPaginated()->getItems() as $ar) { $grant = new CGrant($ar); $grants->add($grant->getId(), $grant); } $this->setData("grants", $grants); $this->setData("paginator", $set->getPaginator()); $this->renderView("_grants/grant/index.tpl"); }
public function __construct() { if (!CSession::isAuth()) { $action = CRequest::getString("action"); if ($action == "") { $action = "index"; } if (!in_array($action, $this->allowedAnonymous)) { $this->redirectNoAccess(); } } else { if (CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_NO_ACCESS) { $this->redirectNoAccess(); } } $this->_smartyEnabled = true; $this->setPageTitle("Управление таксономиями"); parent::__construct(); }
public function actionAddNewsItem() { $order = CStaffManager::getUsatuOrder(CRequest::getInt("id")); $newsItem = new CNewsItem(); $newsItem->user_id_insert = CSession::getCurrentUser()->getId(); $newsItem->date_time = date("Y-m-d H:i:s"); $newsItem->news_type = "notice"; $newsItem->related_id = $order->getId(); $newsItem->related_type_name = get_class($order); $newsItem->title = "Добавлен приказ №" . $order->num . " от " . $order->date . ": " . $order->title; $newsItem->file = $order->text; // скопируем файл, если он есть if ($order->attachment != "") { $propOrder = $order->fieldsProperty(); $propNews = $newsItem->fieldsProperty(); copy($propOrder["attachment"]["upload_dir"] . $order->attachment, $propNews["file_attach"]["upload_dir"] . $order->attachment); $newsItem->file_attach = $order->attachment; } $newsItem->save(); $this->redirect("?action=edit&id=" . $order->getId()); }
public function actionIndex() { $selectedYear = null; $set = new CRecordSet(); $query = new CQuery(); $set->setQuery($query); $query->select("p.*")->from(TABLE_PERSON . " as p")->order("p.fio asc"); if (CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_WRITE_OWN_ONLY || CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_READ_OWN_ONLY) { if (is_null(CSession::getCurrentPerson())) { $query->condition("p.id = 0"); } else { $query->condition("p.id = " . CSession::getCurrentPerson()->getId()); } } // фильтр по году if (!is_null(CRequest::getFilter("year.id"))) { $query->innerJoin(TABLE_IND_PLAN_LOADS . " as l", "l.person_id = p.id"); $query->innerJoin(TABLE_YEARS . " as year", "l.year_id = year.id"); $selectedYear = CRequest::getFilter("year.id"); } $yearsQuery = new CQuery(); $yearsQuery->select("year.*")->from(TABLE_YEARS . " as year")->order("year.name asc"); $years = array(); foreach ($yearsQuery->execute()->getItems() as $ar) { $year = new CTimeIntervals(new CActiveRecord($ar)); $years[$year->getId()] = $year->name; } $persons = new CArrayList(); foreach ($set->getPaginated()->getItems() as $ar) { $person = new CPerson($ar); $persons->add($person->getId(), $person); } $this->addActionsMenuItem(array(array("title" => "Назад", "link" => "index.php", "icon" => "actions/edit-undo.png"), array("title" => "Печать по шаблону", "link" => "#", "icon" => "devices/printer.png", "template" => "formset_ind_plan_view"))); $this->setData("paginator", $set->getPaginator()); $this->setData("persons", $persons); $this->setData("years", $years); $this->setData("selectedYear", $selectedYear); $this->renderView("_individual_plan/load/index.tpl"); }
public function actionIndex() { $set = new CRecordSet(true); $query = new CQuery(); $set->setQuery($query); $query->select("p.*")->from(TABLE_PERSON . " as p")->order("p.fio asc"); if (CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_WRITE_OWN_ONLY || CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_READ_OWN_ONLY) { if (is_null(CSession::getCurrentPerson())) { $query->condition("p.id = 0"); } else { $query->condition("p.id = " . CSession::getCurrentPerson()->getId()); } } $persons = new CArrayList(); foreach ($set->getPaginated()->getItems() as $ar) { $person = new CPerson($ar); $persons->add($person->getId(), $person); } $this->addActionsMenuItem(array(array("title" => "Назад", "link" => "index.php", "icon" => "actions/edit-undo.png"), array("title" => "Печать по шаблону", "link" => "#", "icon" => "devices/printer.png", "template" => "formset_ind_plan_view"))); $this->setData("paginator", $set->getPaginator()); $this->setData("persons", $persons); $this->renderView("_individual_plan/load/index.tpl"); }
/** * Меню задач для текущего пользователя. * Возвращаются только доступные ему задачи * * @static * @return CMenu */ private static function getTasksMenu() { if (!self::getCacheMenu()->hasElement("admin_menu")) { $user = CSession::getCurrentUser(); /** * Чтобы не выбиваться из общей концепции придется адаптировать существующую таблицу * задач портала под вывод в виде меню. Также было бы неплохо сделать редактор этой * гадости в виде такого же простого вида, как и с моими меню * * 1. Создадим фиктивную activeRecord из моего меню для ссылки в другое меню * 2. Берем из таблицы группы меню (из task_menu_names) * 3. Выберем пункты меню из нужной таблицы и добавим их как обычные пункты. * 4. Добавим недостающие * 5. Исключим недоступные текущему пользователю * * Обновление от 06.02.2014 - все пункты меню хранятся в базе */ // дополнительный пункт "Прочее" $arr = array(); $arr['id'] = 100000; $arr['title'] = "Меню админки"; $arr['alias'] = "admin_menu"; $arr['description'] = "Фиктивное меню для отображения задач портала"; $arr['published'] = 1; $menu = new CMenu(new CActiveRecord($arr)); foreach (CActiveRecordProvider::getWithCondition("task_menu_names", "1=1 order by name desc")->getItems() as $i) { $arr = $i->getItems(); // адаптер для моей системы меню $arr['id'] = $arr['id'] + 100000; $arr['title'] = $arr['name']; $arr['anchor'] = "#"; $arr['menu_id'] = $menu->getId(); $arr['parent_id'] = 0; $i->setItems($arr); $menuItem = new CMenuItem($i); $menu->addMenuItem($menuItem); } // дополнительный пункт "Прочее" $arr = array(); $arr['id'] = 100000; $arr['title'] = CUtils::getTextStringInCorrectEncoding("Прочее"); $arr['anchor'] = "#"; $arr['menu_id'] = $menu->getId(); $arr['parent_id'] = 0; $menuItem = new CMenuItem(new CActiveRecord($arr)); $menu->addMenuItem($menuItem); foreach (CActiveRecordProvider::getWithCondition("tasks", "hidden=0 order by name asc")->getItems() as $i) { $arr = $i->getItems(); // адаптер для совместимости с моей системой $arr['title'] = $arr['name']; $arr['anchor'] = $arr['url']; $arr['parent_id'] = $arr['menu_name_id'] + 100000; $arr['menu_id'] = $menu->getId(); unset($arr['name']); unset($arr['url']); unset($arr['menu_name_id']); unset($arr['hidden']); unset($arr['kadri_in_task']); unset($arr['students_in_task']); unset($arr['comment']); $i->setItems($arr); $menuItem = new CMenuItem($i); $menu->addMenuItem($menuItem); } // дополнительный пункт меню "Выход" $arr = array(); $arr['id'] = 200000; $arr['title'] = CUtils::getTextStringInCorrectEncoding("Выход"); $arr['anchor'] = "p_administration.php?exit=1"; $arr['menu_id'] = $menu->getId(); $arr['parent_id'] = 0; $menuItem = new CMenuItem(new CActiveRecord($arr)); $menu->addMenuItem($menuItem); // теперь исключаем все задачи недоступные текущему пользователю foreach ($menu->getMenuItems()->getItems() as $menuItem) { if ($menuItem->getId() < 100000) { if (!$user->getRoles()->hasElement($menuItem->getId())) { $menu->getMenuItems()->removeItem($menuItem->getId()); } } } self::getCacheMenu()->add("admin_menu", $menu); } return self::getCacheMenu()->getItem("admin_menu"); }
public function actionIndex() { if (CSettingsManager::getSettingValue("hide_person_data_rule")) { $set = new CRecordSet(); $query = new CQuery(); $query->select("users.*")->from(TABLE_USERS . " as users")->innerJoin(TABLE_USER_IN_GROUPS . " as userGroup", "userGroup.user_id=users.id")->condition("userGroup.group_id=1")->order("users.FIO asc"); $queryLetter = new CQuery(); $queryLetter->select("users.*, UPPER(left(users.FIO,1)) as name, count(*) as cnt")->from(TABLE_USERS . " as users")->innerJoin(TABLE_USER_IN_GROUPS . " as userGroup", "userGroup.user_id=users.id")->condition("userGroup.group_id=1 ")->group(1)->order("users.FIO asc"); $resRus = array(); foreach ($queryLetter->execute()->getItems() as $ar) { $res = new CLecturerOuter(new CActiveRecord($ar)); $resRus[$res->id] = $res->name; } $resRusLetters = array(); $resRusLetters = array_count_values($resRus); $firstLet = array(1); foreach ($resRusLetters as $key => $value) { $firstLet[] = $key; } $letter = $firstLet[CRequest::getInt("getsub")]; $letterId = -1; if (CRequest::getInt("getsub") > 0 and is_null(CRequest::getFilter("user.id"))) { if (CRequest::getInt("getsub") > 0) { $letterId = CRequest::getInt("getsub"); } $query->condition('users.FIO like "' . $letter . '%" and userGroup.group_id=1'); } $lects = new CArrayList(); $set->setQuery($query); foreach ($set->getPaginated()->getItems() as $ar) { $lect = new CLecturerOuter($ar); $lects->add($lect->getId(), $lect); } } else { $set = new CRecordSet(); $query = new CQuery(); $query->select("person.*")->from(TABLE_PERSON . " as person")->innerJoin(TABLE_USERS . " as users", "users.kadri_id=person.id")->innerJoin(TABLE_USER_IN_GROUPS . " as userGroup", "userGroup.user_id=users.id")->condition("userGroup.group_id=1")->order("person.fio asc"); $queryLetter = new CQuery(); $queryLetter->select("person.*, UPPER(left(person.fio,1)) as name, count(*) as cnt")->from(TABLE_PERSON . " as person")->innerJoin(TABLE_USERS . " as users", "users.kadri_id=person.id")->innerJoin(TABLE_USER_IN_GROUPS . " as userGroup", "userGroup.user_id=users.id")->condition("userGroup.group_id=1 ")->group(1)->order("person.fio asc"); $resRus = array(); foreach ($queryLetter->execute()->getItems() as $ar) { $res = new CPerson(new CActiveRecord($ar)); $resRus[$res->id] = $res->name; } $resRusLetters = array(); $resRusLetters = array_count_values($resRus); $firstLet = array(1); foreach ($resRusLetters as $key => $value) { $firstLet[] = $key; } $letter = $firstLet[CRequest::getInt("getsub")]; $letterId = -1; if (CRequest::getInt("getsub") > 0 and is_null(CRequest::getFilter("person.id"))) { if (CRequest::getInt("getsub") > 0) { $letterId = CRequest::getInt("getsub"); } $query->condition('person.fio like "' . $letter . '%" and userGroup.group_id=1'); } if (CSession::isAuth() and (CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_WRITE_OWN_ONLY or CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_WRITE_ALL)) { $this->addActionsMenuItem(array(array("title" => "Добавить биографию", "link" => WEB_ROOT . "_modules/_biography/index.php", "icon" => "actions/list-add.png"))); } $lects = new CArrayList(); $set->setQuery($query); foreach ($set->getPaginated()->getItems() as $ar) { $lect = new CPerson($ar); $lects->add($lect->getId(), $lect); } } $this->setData("resRusLetters", $resRusLetters); $this->setData("letterId", $letterId); $this->setData("firstLet", $firstLet); $this->setData("paginator", $set->getPaginator()); $this->setData("lects", $lects); $this->renderView("__public/_lecturers/index.tpl"); }
/** * Протоколирование действий пользователя */ private function logUserActivity() { $query = new CQuery($this->getDbLogConnection()); $query->insert(LOG_TABLE_STATS, array("url" => basename($_SERVER["SCRIPT_NAME"]), "host_ip" => $_SERVER["REMOTE_ADDR"], "port" => $_SERVER["REMOTE_PORT"], "agent" => $_SERVER["HTTP_USER_AGENT"], "user_name" => is_null(CSession::getCurrentUser()) ? 0 : CSession::getCurrentUser()->getId(), "q_string" => $_SERVER['QUERY_STRING'], "referer" => array_key_exists("HTTP_REFERER", $_SERVER) ? $_SERVER["HTTP_REFERER"] : 0, "is_bot" => CUtils::isHTTPRefererIsBot() ? 1 : 0)); $query->execute(); }
public function actionSaveGradebook() { $search = new CStudentActivitySearchForm(); $search->setAttributes(CRequest::getArray($search::getClassName())); if ($search->validate()) { $record = new CGradebook(); $record->person_id = CSession::getCurrentUser()->getId(); $record->kadri_id = $search->kadri_id; $record->subject_id = $search->subject_id; $record->group_id = $search->group_id; $record->date_start = $search->date_start; $record->date_end = $search->date_end; $record->save(); $this->redirect("?action=viewGradebook&id=" . $record->getId()); return true; } $this->addJSInclude("_core/jquery-ui-1.8.20.custom.min.js"); $this->addCSSInclude("_core/jUI/jquery-ui-1.8.2.custom.css"); $this->addJSInclude("_core/personTypeFilter.js"); $groups = array(); foreach (CStaffManager::getStudentGroupsByYear(CUtils::getCurrentYear())->getItems() as $group) { if ($group->getStudents()->getCount() > 0) { $groups[$group->getId()] = $group->getName(); } } $this->setData("groups", $groups); $this->setData("search", $search); $this->renderView("_gradebook/gradebook.create.tpl"); }
header("Location:" . $_GET['url'] . ""); } else { header("Location:p_administration.php"); } } } } } } //include_once('_mantis_integ.php'); include 'header.php'; // <abarmin date="22.12.2012"> // мы пережили конец света! if (!is_null(CSession::getCurrentUser())) { if (!is_null(CSession::getCurrentUser()->getPersonalSettings())) { if (CSession::getCurrentUser()->getPersonalSettings()->isDashboardEnabled()) { header("Location:_modules/_dashboard/index.php"); } else { header("Location:_modules/_dashboard/index.php?action=tasks"); } } } // </abarmin> echo $head; if (!isset($_SESSION['auth']) || $_SESSION['auth'] != 1) { if ($msg != '') { err_show($msg); } } else { //include_once 'task_menu.php'; echo '<br><div class="main">Консоль управления </div>
public function actionForward() { $mail = CStaffManager::getMessage(CRequest::getInt("id")); $mail->mail_title = "Пересылка: " . $mail->mail_title; $mail->mail_text = "<p> </p><hr>" . $mail->mail_text; $mail->to_user_id = null; $mail->from_user_id = CSession::getCurrentUser()->getId(); $this->addJSInclude(JQUERY_UI_JS_PATH); $this->addCSSInclude(JQUERY_UI_CSS_PATH); $this->addCSSInclude("_modules/_redactor/redactor.css"); $this->addJSInclude("_modules/_redactor/redactor.min.js"); $this->setData("message", $mail); $this->renderView("_messages/edit.tpl"); }
/** * Обновление поискового запроса с учетом прав доступа * Делается из допущения, что текущая задача - эта задача, по * которой выполняется основной запрос * * @return bool */ private function updateQueryForACLLimitations() { /** * Для начала проверим, что текущая задача определяется * Если не определяется, то менять ничего мы не можем - * данных недостаточно */ $task = CSession::getCurrentTask(); if (is_null($task)) { return false; } /** * Теперь проверим, что найденная задача связана с какой-либо моделью * Если модель определить не можем, то тоже выходим */ $targetModel = null; foreach ($task->models->getItems() as $model) { if (mb_strtolower($model->getModelTable()) == mb_strtolower($this->getTableName())) { $targetModel = $model; } } if (is_null($targetModel)) { return false; } /** * Теперь проверим, поддерживает ли эта модель работу с readers/authors-полями * Если таких полей нет, то тоже нет смысла что-либо проверять */ if ($targetModel->getReadersFields()->getCount() == 0) { return false; } /** * Если у пользователя нет доступа к текущей задаче, то * ставим в поля, регламентирующие доступ 0 - нулевого пользователя у нас точно нет * * Если доступ на чтение/запись только своего, то добавляем в readers-поля * id текущего пользователя */ $q = array(); if (CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_NO_ACCESS) { foreach ($targetModel->getReadersFields()->getItems() as $field) { $q[] = "(" . $this->getTableAlias() . "." . $field->field_name . "= 0)"; } } elseif (CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_READ_OWN_ONLY || CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_WRITE_OWN_ONLY) { foreach ($targetModel->getReadersFields()->getItems() as $field) { $q[] = "(" . $this->getTableAlias() . "." . $field->field_name . "=" . CSession::getCurrentPerson()->getId() . ")"; } } if (count($q) > 0) { $query = $this->getQuery(); $condition = $query->getCondition(); if (!is_null($condition)) { $condition .= " AND "; } $condition .= "(" . implode(" OR ", $q) . ")"; $this->getQuery()->condition($condition); } }
public function actionGlobalSearch() { /** * Запрос, который отправил пользователь */ $userQuery = CRequest::getString("keyword"); /** * Задачи, в которые у него есть доступ */ $tasks = array(); foreach (CSession::getCurrentUser()->getRoles()->getItems() as $role) { $tasks[] = $role->getId(); } /** * Непосредственно, поиск */ $params = array("_is_main_" => 1, "_highlight_" => "doc_body"); $resultObj = CSolr::search($userQuery, $params); /** * Формируем модель данных для рисования результата */ $result = array(); $userQuery = mb_strtolower($userQuery); foreach ($resultObj->getDocuments() as $doc) { $hl = $resultObj->getHighlighingByDocument($doc); $res = array("text" => implode(", ", $hl)); /** * Получаем метамодель для этого типа объекта * Смотрим, какие задачи с ней связны */ $model = CCoreObjectsManager::getCoreModel($doc->_class_); $tasks = array(); if (!is_null($model)) { foreach ($model->tasks->getItems() as $task) { /** * Для каждой задачи формируем URL с фильтром */ $title = $task->name; $url = $task->url; $urlParams = array(); $urlParams[] = "filterClass=" . $doc->_class_; $urlParams[] = "filterLabel=" . str_replace("</em>", "", str_replace("<em>", "", implode(", ", $hl))); foreach ($model->fields->getItems() as $field) { if (property_exists($doc, $field->field_name)) { $fieldName = $field->field_name; $fieldValue = mb_strtolower($doc->{$fieldName}); if (mb_strpos($fieldValue, $userQuery) !== false) { if (mb_strlen($fieldValue) < 100) { $urlParams[] = "filter=" . $fieldName . ":" . $fieldValue; } else { $urlParams[] = "filter=" . $fieldName . ":" . $userQuery; } } } } $url .= "?" . implode("&", $urlParams); $tasks[$url] = $title; } } $res["tasks"] = $tasks; $result[] = $res; } /** * Склеиваем результаты с одинаковым текстом */ $outResults = array(); foreach ($result as $res) { $key = $res["text"]; if (array_key_exists($key, $outResults)) { $obj = $outResults[$key]; $tasks = $obj["tasks"]; foreach ($res["tasks"] as $url => $title) { $tasks[$url] = $title; } $obj["tasks"] = $tasks; } else { $obj = $res; } $outResults[$key] = $obj; } /** * Отображением */ $this->setData("results", $outResults); $this->renderView("_search/results.tpl"); }
private function initDefaultIncludes() { // подключаем jQuery по умолчанию $this->addJSInclude(CSettingsManager::getSettingValue("jquery_path")); $this->addJSInclude(CSettingsManager::getSettingValue("jquery_migrate_path")); $this->addJSInclude("_core/jquery.cookie.js"); $this->addJSInlineInclude("var web_root = '" . WEB_ROOT . "';"); // ядреные модули $this->addJSInclude("_core/core.js"); $this->setData("wap_mode", false); $this->setData("no_wap_link", CUtils::getNoWapLink()); // подключение системы уведомлений $this->addJSInclude("_modules/_messages/sticky.full.js"); $this->addCSSInclude("_modules/_messages/sticky.full.css"); // выключение режима wap if (array_key_exists("nowap", $_GET)) { if (array_key_exists("wap_mode", $_COOKIE)) { if (!setcookie("wap_mode", "false", 1)) { die("Ошибка работы с cookie!"); } unset($_COOKIE["wap_mode"]); } } // включение режима wap if (array_key_exists("wap_mode", $_COOKIE)) { if ($_COOKIE["wap_mode"] == "true") { $this->setData("wap_mode", true); } } // фиксы для IE $this->addJSIEOnly(8, "_core/iefix8.js"); /** * Пришло время помощника =) * Если у пользователя включена проверка ящика, * то подключаем скрипт проверки */ if (!is_null(CSession::getCurrentUser())) { if (!is_null(CSession::getCurrentUser()->getPersonalSettings())) { $settings = CSession::getCurrentUser()->getPersonalSettings(); if ($settings->isCheckMessages()) { $this->addJSInclude("_modules/_messages/checker.js"); } } } /** * AJAX для портала */ $this->addJSInclude("_core/jquery.ajax.js"); /** * Рабочие процессы - последовательности действий */ $this->addJSInclude("_core/jquery.flow.js"); /** * Bootstrap для красоты */ $this->addJSInclude(CSettingsManager::getSettingValue("bootstrap_path") . "js/bootstrap.js"); $this->addJSInclude("_core/datepicker/js/bootstrap-datepicker.js"); $this->addJSInclude("_core/timepicker/js/bootstrap-timepicker.js"); /** * Поиск по каталогам */ $this->addJSInclude("_core/jquery.lookup.js"); $this->addJSInclude("_core/jquery.bootbox.js"); /** * Загрузка файлов */ $this->addJSInclude("_core/jquery.form.js"); $this->addJSInclude("_core/jquery.upload.js"); $this->addJSInclude("_core/jquery.colorbox.js"); $this->addCSSInclude("_core/jColorbox/colorbox.css"); /** * Компоненты */ $this->addJSInclude("_core/jquery.component.js"); /** * Select 2 */ $this->addJSInclude('_core/select2/select2.js'); $this->addCSSInclude('_core/select2/select2.css'); }
public function actionSave() { $item = new CDashboardItem(); $item->setAttributes(CRequest::getArray($item::getClassName())); if ($item->validate()) { $item->save(); $this->redirect("?action=list"); return true; } $parents = new CArrayList(); foreach (CActiveRecordProvider::getWithCondition(TABLE_DASHBOARD, "user_id = " . CSession::getCurrentUser()->getId() . " and parent_id = 0")->getItems() as $ar) { $item = new CDashboardItem($ar); $parents->add($item->getId(), $item->title); foreach ($item->children->getItems() as $child) { $parents->add($child->getId(), " - " . $child->title); } } $this->setData("parents", $item); $this->setData("item", $item); $this->renderView("_dashboard/edit.tpl"); }
public function actionSearch() { $res = array(); $term = CRequest::getString("query"); /** * Сначала поищем по названию публикации */ $query = new CQuery(); $query->select("distinct(pub.id) as id, pub.name as title")->from(TABLE_PUBLICATIONS . " as pub")->condition("pub.name like '%" . $term . "%'")->limit(0, 5); if (CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_READ_OWN_ONLY or CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_WRITE_OWN_ONLY) { $query->innerJoin(TABLE_PUBLICATION_BY_PERSONS . " as p", "p.izdan_id = pub.id"); $query->condition("p.kadri_id=" . CSession::getCurrentPerson()->getId()); } foreach ($query->execute()->getItems() as $item) { $res[] = array("field" => "t.id", "value" => $item["id"], "label" => $item["title"], "class" => "CPublication"); } echo json_encode($res); }
public function actionIndex() { $set = new CRecordSet(false); $query = new CQuery(); $currentPerson = null; $currentGroup = null; $query->select("diplom.*")->from(TABLE_DIPLOMS . " as diplom")->order("diplom.date_act desc"); $managersQuery = new CQuery(); $managersQuery->select("person.*")->from(TABLE_PERSON . " as person")->order("person.fio asc")->innerJoin(TABLE_DIPLOMS . " as diplom", "person.id = diplom.kadri_id"); $groupsQuery = new CQuery(); $groupsQuery->select("stgroup.*")->from(TABLE_STUDENT_GROUPS . " as stgroup")->order("stgroup.name asc")->innerJoin(TABLE_STUDENTS . " as student", "stgroup.id = student.group_id")->innerJoin(TABLE_DIPLOMS . " as diplom", "student.id = diplom.student_id")->condition('diplom.date_act between "' . date("Y-m-d", strtotime(CUtils::getCurrentYear()->date_start)) . '" and "' . date("Y-m-d", strtotime(CUtils::getCurrentYear()->date_end)) . '"'); $set->setQuery($query); if (CRequest::getString("order") == "st_group.name") { $direction = "asc"; if (CRequest::getString("direction") != "") { $direction = CRequest::getString("direction"); } $query->innerJoin(TABLE_STUDENTS . " as student", "diplom.student_id=student.id"); $query->innerJoin(TABLE_STUDENT_GROUPS . " as st_group", "student.group_id = st_group.id"); $query->order("st_group.name " . $direction); } elseif (CRequest::getString("order") == "dipl_prew.date_preview") { $direction = "asc"; if (CRequest::getString("direction") != "") { $direction = CRequest::getString("direction"); } $query->innerJoin(TABLE_STUDENTS . " as student", "diplom.student_id=student.id"); $query->leftJoin(TABLE_DIPLOM_PREVIEWS . " as dipl_prew", "student.id = dipl_prew.student_id"); $query->order("dipl_prew.date_preview " . $direction); } elseif (CRequest::getString("order") == "prepod.fio") { $direction = "asc"; if (CRequest::getString("direction") != "") { $direction = CRequest::getString("direction"); } $query->innerJoin(TABLE_PERSON . " as prepod", "diplom.kadri_id = prepod.id"); $query->order("prepod.fio " . $direction); } elseif (CRequest::getString("order") == "student.fio") { $direction = "asc"; if (CRequest::getString("direction") != "") { $direction = CRequest::getString("direction"); } $query->innerJoin(TABLE_STUDENTS . " as student", "diplom.student_id=student.id"); $query->order("student.fio " . $direction); } elseif (CRequest::getString("order") == "diplom_confirm") { $direction = "asc"; if (CRequest::getString("direction") != "") { $direction = CRequest::getString("direction"); } $query->order("diplom_confirm " . $direction); } elseif (CRequest::getString("order") == "dipl_name") { $direction = "asc"; if (CRequest::getString("direction") != "") { $direction = CRequest::getString("direction"); } $query->order("dipl_name " . $direction); } elseif (CRequest::getString("order") == "pract_place_id") { $direction = "asc"; if (CRequest::getString("direction") != "") { $direction = CRequest::getString("direction"); } $query->order("pract_place_id " . $direction); } elseif (CRequest::getString("order") == "date_act") { $direction = "asc"; if (CRequest::getString("direction") != "") { $direction = CRequest::getString("direction"); } $query->order("date_act " . $direction); } elseif (CRequest::getString("order") == "foreign_lang") { $direction = "asc"; if (CRequest::getString("direction") != "") { $direction = CRequest::getString("direction"); } $query->order("foreign_lang " . $direction); } elseif (CRequest::getString("order") == "protocol_2aspir_id") { $direction = "asc"; if (CRequest::getString("direction") != "") { $direction = CRequest::getString("direction"); } $query->order("protocol_2aspir_id " . $direction); } elseif (CRequest::getString("order") == "recenz_id") { $direction = "asc"; if (CRequest::getString("direction") != "") { $direction = CRequest::getString("direction"); } $query->order("recenz_id " . $direction); } elseif (CRequest::getString("order") == "study_mark") { $direction = "asc"; if (CRequest::getString("direction") != "") { $direction = CRequest::getString("direction"); } $query->order("study_mark " . $direction); } elseif (CRequest::getString("order") == "gak_num") { $direction = "asc"; if (CRequest::getString("direction") != "") { $direction = CRequest::getString("direction"); } $query->order("gak_num " . $direction); } elseif (CRequest::getString("order") == "comment") { $direction = "asc"; if (CRequest::getString("direction") != "") { $direction = CRequest::getString("direction"); } $query->order("comment " . $direction); } // фильтр по руководителю if (!is_null(CRequest::getFilter("person"))) { $query->innerJoin(TABLE_PERSON . " as person", "diplom.kadri_id = person.id and person.id = " . CRequest::getFilter("person")); $currentPerson = CRequest::getFilter("person"); // фильтруем еще и группы $groupsQuery->innerJoin(TABLE_PERSON . " as person", "diplom.kadri_id = person.id and person.id = " . CRequest::getFilter("person")); } // фильтр по группе if (!is_null(CRequest::getFilter("group"))) { $arr = explode(",", CRequest::getFilter("group")); foreach ($arr as $key => $value) { $arrs[] = 'st_group.id = ' . $value; } $currentGroup = CRequest::getFilter("group"); $query->innerJoin(TABLE_STUDENTS . " as student", "diplom.student_id=student.id"); $query->innerJoin(TABLE_STUDENT_GROUPS . " as st_group", "student.group_id = st_group.id and (" . implode(" or ", $arrs) . ")"); $managersQuery->innerJoin(TABLE_STUDENTS . " as student", "diplom.student_id = student.id"); $managersQuery->innerJoin(TABLE_STUDENT_GROUPS . " as st_group", "student.group_id = st_group.id and (" . implode(" or ", $arrs) . ")"); } // фильтр по теме if (!is_null(CRequest::getFilter("theme"))) { $query->condition("diplom.id = " . CRequest::getFilter("theme")); } // фильтр по студенту if (!is_null(CRequest::getFilter("student"))) { $query->innerJoin(TABLE_STUDENTS . " as student", "diplom.student_id=student.id and student.id = " . CRequest::getFilter("student")); } // фильтр по степени утверждения if (!is_null(CRequest::getFilter("confirm"))) { $query->innerJoin(TABLE_DIPLOM_CONFIRMATIONS . " as confirm", "diplom.diplom_confirm = confirm.id and confirm.id = " . CRequest::getFilter("confirm")); } // фильтр по месту практики if (!is_null(CRequest::getFilter("pract"))) { $query->condition("diplom.id = " . CRequest::getFilter("pract")); } // фильтр по месту практики по id if (!is_null(CRequest::getFilter("practId"))) { $query->innerJoin(TABLE_PRACTICE_PLACES . " as pract", "diplom.pract_place_id = pract.id and pract.id = " . CRequest::getFilter("practId")); } // фильтр по ин.яз. if (!is_null(CRequest::getFilter("foreign"))) { $query->innerJoin(TABLE_LANGUAGES . " as lang", "diplom.foreign_lang=lang.id and lang.id = " . CRequest::getFilter("foreign")); } // фильтр по рецензенту if (!is_null(CRequest::getFilter("recenz"))) { $query->innerJoin(TABLE_PERSON . " as person", "diplom.recenz_id = person.id and person.id = " . CRequest::getFilter("recenz")); } // фильтр по оценке if (!is_null(CRequest::getFilter("mark"))) { $query->innerJoin(TABLE_MARKS . " as mark", "diplom.study_mark = mark.id and mark.id = " . CRequest::getFilter("mark")); } // фильтр по комментарию if (!is_null(CRequest::getFilter("comment"))) { $query->condition("diplom.id = " . CRequest::getFilter("comment")); } // получение дипломных тем $diploms = new CArrayList(); $isApprove = CRequest::getString("isApprove") == "1"; $isArchive = CRequest::getString("isArchive") == "1"; if (!$isArchive) { if (CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_READ_OWN_ONLY or CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_WRITE_OWN_ONLY) { $query->condition('diplom.kadri_id = "' . CSession::getCurrentPerson()->getId() . '" and diplom.date_act between "' . date("Y-m-d", strtotime(CUtils::getCurrentYear()->date_start)) . '" and "' . date("Y-m-d", strtotime(CUtils::getCurrentYear()->date_end)) . '"'); } else { $query->condition('diplom.date_act between "' . date("Y-m-d", strtotime(CUtils::getCurrentYear()->date_start)) . '" and "' . date("Y-m-d", strtotime(CUtils::getCurrentYear()->date_end)) . '"'); } } else { if (CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_READ_OWN_ONLY or CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_WRITE_OWN_ONLY) { $query->condition("diplom.kadri_id = " . CSession::getCurrentPerson()->getId()); } } //Не имеющие предзащиты зимой if (CRequest::getInt("winterNotPreviews") == 1) { $query->leftJoin(TABLE_DIPLOM_PREVIEWS . " as preview", "diplom.student_id = preview.student_id"); $query->condition('preview.student_id is null and diplom.date_act between "' . (date("Y") - 1) . "-12-01" . '" and "' . date("Y") . "-02-28" . '"'); } //Не имеющие предзащиты летом if (CRequest::getInt("summerNotPreviews") == 1) { $query->leftJoin(TABLE_DIPLOM_PREVIEWS . " as preview", "diplom.student_id = preview.student_id"); $query->condition('preview.student_id is null and diplom.date_act between "' . date("Y") . "-05-01" . '" and "' . date("Y") . "-06-30" . '"'); } foreach ($set->getPaginated()->getItems() as $item) { $diplom = new CDiplom($item); $diploms->add($diplom->getId(), $diplom); } /** * Формируем меню */ $this->addActionsMenuItem(array(array("title" => "Печать по шаблону", "link" => "#", "icon" => "devices/printer.png", "template" => "formset_diploms_theme"), array("title" => "Добавить тему ВКР", "link" => "?action=add", "icon" => "actions/list-add.png"), array("title" => "Список студентов", "link" => WEB_ROOT . "_modules/_students/index.php", "icon" => "apps/system-users.png"), array("title" => "Групповые операции", "link" => "#", "icon" => "apps/utilities-terminal.png", "child" => array(array("title" => "Удалить выделенные", "icon" => "actions/edit-delete.png", "form" => "#MainView", "link" => "index.php", "action" => "Delete"), array("title" => "Сменить дату защиты", "icon" => "actions/edit-redo.png", "form" => "#MainView", "link" => "index.php", "action" => "changeDateAct"), array("title" => "Сменить место практики", "icon" => "actions/edit-redo.png", "form" => "#MainView", "link" => "index.php", "action" => "changePractPlace"))))); if ($isArchive) { $requestParams = array(); foreach (CRequest::getGlobalRequestVariables()->getItems() as $key => $value) { if ($key != "isArchive") { $requestParams[] = $key . "=" . $value; } } $this->addActionsMenuItem(array(array("title" => "Текущий год", "link" => "?" . implode("&", $requestParams), "icon" => "mimetypes/x-office-calendar.png"))); } else { $requestParams = array(); foreach (CRequest::getGlobalRequestVariables()->getItems() as $key => $value) { $requestParams[] = $key . "=" . $value; } $requestParams[] = "isArchive=1"; $this->addActionsMenuItem(array(array("title" => "Архив", "link" => "?" . implode("&", $requestParams), "icon" => "devices/media-floppy.png"))); } $this->addActionsMenuItem(array(array("title" => "Утверждение темы", "link" => "#", "icon" => "apps/accessories-text-editor.png", "child" => array(array("title" => "Утвердили полностью", "icon" => "actions/edit-find-replace.png", "form" => "#MainView", "link" => "index.php?type=1", "action" => "approveTheme"), array("title" => "Утвердили c правкой", "icon" => "actions/edit-find-replace.png", "form" => "#MainView", "link" => "index.php?type=2", "action" => "approveTheme"), array("title" => "Утвердили c переформулировкой", "icon" => "actions/edit-find-replace.png", "form" => "#MainView", "link" => "index.php?type=3", "action" => "approveTheme"), array("title" => "Не утвердили, но смотрели", "icon" => "actions/edit-find-replace.png", "form" => "#MainView", "link" => "index.php?type=4", "action" => "approveTheme"), array("title" => "Отменить утверждение темы", "icon" => "actions/edit-find-replace.png", "form" => "#MainView", "link" => "index.php?type=0", "action" => "approveTheme"))))); $managers = array(); foreach ($managersQuery->execute()->getItems() as $ar) { $person = new CPerson(new CActiveRecord($ar)); $managers[$person->getId()] = $person->getName(); } $studentGroups = array(); foreach ($groupsQuery->execute()->getItems() as $ar) { $group = new CStudentGroup(new CActiveRecord($ar)); $studentGroups[$group->getId()] = $group->getName(); } $this->setData("isArchive", $isArchive); $this->setData("isApprove", $isApprove); $this->setData("studentGroups", $studentGroups); $this->setData("diplomManagers", $managers); $this->setData("currentPerson", $currentPerson); $this->setData("currentGroup", $currentGroup); $this->setData("diploms", $diploms); $this->setData("paginator", $set->getPaginator()); if (!$isApprove) { $requestParams = array(); foreach (CRequest::getGlobalRequestVariables()->getItems() as $key => $value) { $requestParams[] = $key . "=" . $value; } $requestParams[] = "isApprove=1"; $this->addActionsMenuItem(array(array("title" => "Утверждение тем ВКР", "link" => "?" . implode("&", $requestParams), "icon" => "actions/bookmark-new.png"))); $this->renderView("_diploms/index.tpl"); } else { $requestParams = array(); foreach (CRequest::getGlobalRequestVariables()->getItems() as $key => $value) { if ($key != "isApprove") { $requestParams[] = $key . "=" . $value; } } $this->addActionsMenuItem(array(array("title" => "Список тем ВКР", "link" => "?" . implode("&", $requestParams), "icon" => "actions/format-justify-center.png"))); $this->renderView("_diploms/approve.tpl"); } }
public function actionEditFile() { $file = CLibraryManager::getFile(CRequest::getInt("id_file")); if (!is_null(CRequest::getFilter("author"))) { $author = CRequest::getFilter("author"); } else { $author = CSession::getCurrentUser()->getId(); } $this->addActionsMenuItem(array(array("title" => "Назад", "link" => WEB_ROOT . "_modules/_library/index.php?action=viewFiles&id=" . $file->nameFolder . "&filter=author:" . $author, "icon" => "actions/edit-undo.png"))); $this->setData("file", $file); $this->renderView("_library/editFile.tpl"); }
/** * Опубликованные пункты меню в виде иерархии * * @return CArrayList */ public function getMenuPublishedItemsInHierarchy() { if (is_null($this->_itemsPublishedHierarchy)) { $this->_itemsPublishedHierarchy = new CArrayList(); if ($this->alias == "admin_menu") { foreach ($this->getMenuPublishedItems()->getItems() as $i) { $i->initChilds(); if ($i->getParentId() != 0) { $parent = $this->getMenuPublishedItems()->getItem($i->getParentId()); if (!is_null($parent)) { if (CSession::getCurrentUser()->getRoles()->hasElement($i->getId()) || $i->getId() > 200000) { $parent->getChilds()->add($i->getId(), $i); } } } else { $this->_itemsPublishedHierarchy->add($i->getId(), $i); } } } else { foreach ($this->getMenuPublishedItems()->getItems() as $i) { $i->initChilds(); if ($i->getParentId() != 0) { $parent = $this->getMenuPublishedItems()->getItem($i->getParentId()); if (!is_null($parent)) { $parent->getChilds()->add($i->getId(), $i); } } else { $this->_itemsPublishedHierarchy->add($i->getId(), $i); } } } } return $this->_itemsPublishedHierarchy; }
public static function helpForCurrentPage() { if (!is_null(CHelpManager::getHelpForCurrentPage())) { echo '<div class="alert alert-info">'; echo '<h4>' . CHelpManager::getHelpForCurrentPage()->title . '</h4>'; $printHelpBox = false; if (mb_strlen(CHelpManager::getHelpForCurrentPage()->content) > 512) { $symbols = 512; // Количество символов которые надо вывести $text = ""; $words = explode(" ", CHelpManager::getHelpForCurrentPage()->content); for ($i = 0; $i < count($words); $i++) { $nv_str = $text . $words[$i] . " "; if (strlen($nv_str) < $symbols) { $text = $nv_str; } else { break; } } echo $text . "..."; echo '<p><a href="#help" data-toggle="modal">Читать полностью</a></p>'; $printHelpBox = true; } else { echo CHelpManager::getHelpForCurrentPage()->content; } if (CSession::getCurrentUser()->hasRole("help_add_inline")) { echo '<p>'; echo '<a href="' . WEB_ROOT . '_modules/_help/index.php?action=edit&id=' . CHelpManager::getHelpForCurrentPage()->getId() . '" target="_blank">Редактировать справку</a>'; echo '</p>'; } echo '</div>'; if ($printHelpBox) { echo ' <div class="modal hide fade" id="help"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">?</button> <h3 id="myModalLabel">Справка</h3> </div> <div class="modal-body"> ' . CHelpManager::getHelpForCurrentPage()->content . ' </div> <div class="modal-footer"> <button class="btn" data-dismiss="modal" aria-hidden="true">Закрыть</button> </div> </div> '; } } elseif (CSession::getCurrentUser()->hasRole("help_add_inline")) { echo '<div class="alert alert-info">'; $uri = ""; if (array_key_exists("REQUEST_URI", $_SERVER)) { $uri = $_SERVER["REQUEST_URI"]; $uri = str_replace(ROOT_FOLDER, "", $uri); } echo '<a href="' . WEB_ROOT . '_modules/_help/index.php?action=add&page=' . $uri . '" target="_blank">Добавить справку для текущей страницы</a>'; echo '</div>'; } }