コード例 #1
1
 public function save()
 {
     $this->grant->save();
     /**
      * Работа с участниками
      */
     $members = array();
     if (array_key_exists("members", $this->_fields)) {
         $members = $this->_fields["members"];
     }
     /**
      * Делаем руководителя тоже участником
      */
     if ($this->grant->manager_id != "0") {
         $members[] = $this->grant->manager_id;
     }
     /**
      * Удаляем старых участников
      */
     foreach (CActiveRecordProvider::getWithCondition(TABLE_GRANT_MEMBERS, "grant_id= " . $this->grant->getId())->getItems() as $ar) {
         $ar->remove();
     }
     /**
      * Добавляем новых
      */
     foreach ($members as $member) {
         $ar = new CActiveRecord(array("id" => null, "grant_id" => $this->grant->getId(), "person_id" => $member));
         $ar->setTable(TABLE_GRANT_MEMBERS);
         $ar->insert();
     }
 }
コード例 #2
1
 public function save()
 {
     $group = $this->group;
     $roles = array();
     if (array_key_exists("roles", $group)) {
         $roles = $group["roles"];
         unset($group["roles"]);
     }
     $groupObj = new CUserGroup();
     $groupObj->setAttributes($group);
     /**
      * Удаляем старые задачи группы и пользователей
      */
     foreach (CActiveRecordProvider::getWithCondition(TABLE_USER_GROUP_HAS_ROLES, "user_group_id = " . $groupObj->getId())->getItems() as $ar) {
         $ar->remove();
     }
     $groupObj->save();
     /**
      * Создаем новые задачи группы и пользователей
      */
     foreach ($roles as $role => $level) {
         if ($level != 0) {
             $ar = new CActiveRecord(array("id" => null, "user_group_id" => $groupObj->getId(), "task_id" => $role, "task_rights_id" => $level));
             $ar->setTable(TABLE_USER_GROUP_HAS_ROLES);
             $ar->insert();
         }
     }
 }
コード例 #3
0
 /**
  * Магический метод получения любых классов
  *
  * @param $name
  * @param array $params
  * @throws Exception
  */
 public static function __callStatic($name, $params = array())
 {
     /**
      * Получаем имя класса из имени функции
      */
     $className = "C" . CUtils::strRight($name, "get");
     if (!class_exists($className)) {
         throw new Exception("В приложении не объявлен класс " . $className);
     }
     /**
      * @var CActiveModel $simpleClass
      */
     $simpleClass = new $className();
     $table = $simpleClass->getRecord()->getTable();
     $id = $params[0];
     /**
      * Попробуем сначала получить из кэша
      */
     $keySeek = $table . "_" . $id;
     if (CApp::getApp()->cache->hasCache($keySeek)) {
         return CApp::getApp()->cache->get($keySeek);
     }
     $ar = CActiveRecordProvider::getById($table, $id);
     if (!is_null($ar)) {
         $obj = new $className($ar);
         CApp::getApp()->cache->set($keySeek, $obj, 60);
         return $obj;
     }
 }
コード例 #4
0
 /**
  * @return CArrayList|null
  */
 protected function getDiplomPreviews()
 {
     if (is_null($this->_previews)) {
         $this->_previews = new CArrayList();
         if ($this->getId() != "") {
             /**
              * Если есть ключ диплома, то ищем по нему,
              * если нету, то ищем по студенту
              */
             foreach (CActiveRecordProvider::getWithCondition(TABLE_DIPLOM_PREVIEWS, "diplom_id = " . $this->getId())->getItems() as $item) {
                 $preview = new CDiplomPreview($item);
                 $this->_previews->add($preview->getId(), $preview);
             }
             if ($this->_previews->getCount() == 0) {
                 if (!is_null($this->student)) {
                     foreach (CActiveRecordProvider::getWithCondition(TABLE_DIPLOM_PREVIEWS, "student_id = " . $this->student->getId())->getItems() as $item) {
                         $preview = new CDiplomPreview($item);
                         $this->_previews->add($preview->getId(), $preview);
                     }
                 }
             }
         }
     }
     return $this->_previews;
 }
コード例 #5
0
 public function actionGetViewData()
 {
     $result = array();
     // комиссии по защите дипломов. показываем только комиссии этого года
     foreach (CActiveRecordProvider::getWithCondition(TABLE_SAB_COMMISSIONS, "year_id=" . CUtils::getCurrentYear()->getId())->getItems() as $ar) {
         $comm = new CSABCommission($ar);
         $value = $comm->title;
         if (!is_null($comm->manager)) {
             $value .= " " . $comm->manager->getName();
         }
         if (!is_null($comm->secretar)) {
             $value .= " (" . $comm->secretar->getName() . ")";
         }
         $diplom = CStaffManager::getDiplom(CRequest::getInt("diplom_id"));
         if (!is_null($diplom)) {
             $cnt = 0;
             foreach ($comm->diploms->getItems() as $d) {
                 if (strtotime($diplom->date_act) == strtotime($d->date_act)) {
                     $cnt++;
                 }
             }
             $value .= " " . $cnt;
         }
         $result[$comm->getId()] = $value;
     }
     return $result;
 }
コード例 #6
0
 public function remove()
 {
     foreach (CActiveRecordProvider::getWithCondition(TABLE_DIPLOM_PREVIEW_MEMBERS, "comm_id=" . $this->getId())->getItems() as $ar) {
         $ar->remove();
     }
     parent::remove();
 }
コード例 #7
0
ファイル: CMenu.class.php プロジェクト: Rustam44/ASUPortalPHP
 /**
  * Все опубликованные пункты текущего меню с учетом иерархии
  * Показываются только опубликованные и доступные текущему пользователю
  *
  * @return CArrayList
  */
 public function getMenuPublishedItems()
 {
     if (is_null($this->_itemsPublished)) {
         $this->_itemsPublished = new CArrayList();
         foreach (CActiveRecordProvider::getWithCondition(TABLE_MENU_ITEMS, "menu_id=" . $this->getId() . " and published=1")->getItems() as $i) {
             $item = new CMenuItem($i);
             if ($item->getRoles()->getCount() == 0) {
                 $this->_itemsPublished->add($item->getId(), $item);
             } else {
                 if (is_null(CSession::getCurrentUser())) {
                     if ($item->getRoles()->getCount() == 0) {
                         $this->_itemsPublished->add($item->getId(), $item);
                     }
                 } else {
                     foreach ($item->getRoles()->getItems() as $role) {
                         if (CSession::getCurrentUser()->getRoles()->hasElement($role->getId())) {
                             $this->_itemsPublished->add($item->getId(), $item);
                             break;
                         }
                     }
                 }
             }
             CMenuManager::getCacheItems()->add($item->getId(), $item);
         }
         // инициализируем иерархический вывод
     }
     return $this->_itemsPublished;
 }
コード例 #8
0
 /**
  * Сохранение пункта меню
  */
 public function actionSaveItem()
 {
     if (!CSession::isAuth()) {
         $this->redirectNoAccess();
     }
     $item = new CMenuItem();
     $item->setAttributes(CRequest::getArray(CMenuItem::getClassName()));
     if ($item->validate()) {
         $item->save();
         // сохранение ролей. удаляем старые, записываем новые
         foreach (CActiveRecordProvider::getWithCondition(TABLE_MENU_ITEMS_ACCESS, "item_id = " . $item->id)->getItems() as $val) {
             $val->remove();
         }
         // делаем новые и сохраняем их
         $items = CRequest::getArray(CMenuItem::getClassName());
         if (array_key_exists("roles", $items)) {
             foreach ($items["roles"] as $role) {
                 $r = new CMenuItemRole();
                 $r->item_id = $item->id;
                 $r->role_id = $role;
                 $r->save();
             }
         }
         $this->redirect("?action=view&id=" . $item->getMenu()->getId());
     }
     $this->setData("item", $item);
     $this->setData("menu", CMenuManager::getMenu(CRequest::getInt("menu_id", CMenuItem::getClassName())));
     $this->renderView("_menumanager/editItem.tpl");
 }
コード例 #9
0
 /**
  * Получить настройку по псевдониму или ключевому полю
  *
  * @param $key
  * @return CSetting
  */
 public static function getSetting($key)
 {
     if (is_string($key)) {
         $key = strtoupper($key);
     }
     $cacheKey = CACHE_APPLICATION_SETTINGS . '_' . $key;
     if (!CApp::getApp()->cache->hasCache($cacheKey)) {
         $found = false;
         if (is_string($key)) {
             foreach (CActiveRecordProvider::getWithCondition(TABLE_SETTINGS, "UPPER(alias) = '" . $key . "'")->getItems() as $item) {
                 $found = true;
                 $setting = new CSetting($item);
                 CApp::getApp()->cache->set(CACHE_APPLICATION_SETTINGS . '_' . $setting->getId(), $setting);
                 CApp::getApp()->cache->set($cacheKey, $setting);
             }
         } elseif (is_numeric($key)) {
             $item = CActiveRecordProvider::getById(TABLE_SETTINGS, $key);
             if (!is_null($item)) {
                 $found = true;
                 $setting = new CSetting($item);
                 CApp::getApp()->cache->set(CACHE_APPLICATION_SETTINGS . '_' . $setting->alias, $setting);
                 CApp::getApp()->cache->set($cacheKey, $setting);
             }
         }
         if (!$found) {
             CApp::getApp()->cache->set($cacheKey, null);
         }
     }
     return CApp::getApp()->cache->get($cacheKey);
 }
コード例 #10
0
 public function remove()
 {
     foreach (CActiveRecordProvider::getWithCondition(TABLE_SAB_COMMISSION_MEMBERS, "commission_id=" . $this->getId())->getItems() as $ar) {
         $ar->remove();
     }
     parent::remove();
 }
コード例 #11
0
 /**
  * Автоподстановка людей
  * Выбираем только людей, у которых есть показатели
  */
 public function actionGetPersons()
 {
     $data = $_GET["data"];
     $name = $data["term"];
     // определяем, в каких годах искать
     $years = new CArrayList();
     if (array_key_exists("years", $data)) {
         foreach ($data['years'] as $item) {
             $year = CTaxonomyManager::getYear($item);
             if (!is_null($year)) {
                 $years->add($year->getId(), $year);
             }
         }
     } else {
         $years->add(CUtils::getCurrentYear()->getId(), CUtils::getCurrentYear());
     }
     $res = array();
     $personQuery->select("person.id, person.fio")->from(TABLE_PERSON . " as person")->innerJoin(TABLE_PUBLICATION_BY_PERSONS . " as p", "p.kadri_id = person.id")->order("person.fio asc");
     foreach (CActiveRecordProvider::getWithCondition(TABLE_PERSON, "fio like '%" . $name . "%'")->getItems() as $item) {
         $person = CStaffManager::getPerson($item->getItemValue("id"));
         $flag = false;
         foreach ($years->getItems() as $year) {
             if ($person->getPublications($year)->getCount() > 0) {
                 $flag = true;
             }
         }
         if ($flag) {
             $res[] = array("label" => $person->getName(), "value" => $person->getName());
         }
     }
     echo json_encode($res);
 }
コード例 #12
0
 /**
  * Ресурс, к которому календарь привязан
  *
  * @return CResource
  */
 public function getResource()
 {
     if (is_null($this->_resource)) {
         $ar = CActiveRecordProvider::getById(TABLE_RESOURCES, $this->getResourceId());
         $this->_resource = new CResource($ar);
     }
     return $this->_resource;
 }
コード例 #13
0
 /**
  * @param $id
  * @return CWorkPlanCompetention
  */
 public static function getWorkplanCompetention($id)
 {
     $competention = null;
     $ar = CActiveRecordProvider::getById(TABLE_WORK_PLAN_COMPETENTIONS, $id);
     if (!is_null($ar)) {
         $competention = new CWorkPlanCompetention($ar);
     }
     return $competention;
 }
コード例 #14
0
 public function actionGetViewData()
 {
     $result = array();
     foreach (CActiveRecordProvider::getAllFromTable(TABLE_PROTOCOL_OPINIONS)->getItems() as $ar) {
         $opinion = new CProtocolOpinion($ar);
         $result[$opinion->getId()] = $opinion->name;
     }
     return $result;
 }
コード例 #15
0
 public static function getPage($key)
 {
     if (!self::getCachePages()->hasElement($key)) {
         $ar = CActiveRecordProvider::getById(TABLE_PAGES, $key);
         if (!is_null($ar)) {
             $page = new CPage($ar);
             self::getCachePages()->add($page->getId(), $page);
         }
     }
     return self::getCachePages()->getItem($key);
 }
コード例 #16
0
 /**
  * @return CArrayList|null
  */
 public function getChildFolders()
 {
     if (is_null($this->_childFolders)) {
         $this->_childFolders = new CArrayList();
         foreach (CActiveRecordProvider::getWithCondition(TABLE_DOCUMENT_FOLDERS, "parent_id=" . $this->getId())->getItems() as $ar) {
             $folder = new CDocumentFolder($ar);
             $this->_childFolders->add($folder->getId(), $folder);
         }
     }
     return $this->_childFolders;
 }
コード例 #17
0
 /**
  * Вопросы, которые по данной дисциплине есть
  *
  * @return CArrayList
  */
 public function getQuestions()
 {
     if (is_null($this->_questions)) {
         $this->_questions = new CArrayList();
         foreach (CActiveRecordProvider::getWithCondition(TABLE_SEB_QUESTIONS, "discipline_id=" . $this->getId())->getItems() as $ar) {
             $q = new CSEBQuestion($ar);
             $this->_questions->add($q->getId(), $q);
         }
     }
     return $this->_questions;
 }
コード例 #18
0
 /**
  * @param $key
  * @return CNewsItem
  */
 public static function getNewsItem($key)
 {
     if (!self::getCacheNews()->hasElement($key)) {
         $ar = CActiveRecordProvider::getById(TABLE_NEWS, $key);
         if (!is_null($ar)) {
             $newsItem = new CNewsItem($ar);
             self::getCacheNews()->add($newsItem->getId(), $newsItem);
         }
     }
     return self::getCacheNews()->getItem($key);
 }
コード例 #19
0
 /**
  * Дисциплина с поиском и кэшем
  *
  * @static
  * @param $key
  * @return CDiscipline
  */
 public static function getDiscipline($key)
 {
     if (!self::getCacheDisciplines()->hasElement($key)) {
         $ar = CActiveRecordProvider::getById(TABLE_DISCIPLINES, $key);
         if (!is_null($ar)) {
             $disc = new CDiscipline($ar);
             self::getCacheDisciplines()->add($disc->getId(), $disc);
         }
     }
     return self::getCacheDisciplines()->getItem($key);
 }
コード例 #20
0
 public static function getBiography($key)
 {
     if (!self::getCacheBiographys()->hasElement($key)) {
         $ar = CActiveRecordProvider::getById(TABLE_BIOGRAPHY, $key);
         if (!is_null($ar)) {
             $biography = new CBiography($ar);
             self::getCacheBiographys()->add($biography->getId(), $biography);
         }
     }
     return self::getCacheBiographys()->getItem($key);
 }
コード例 #21
0
 public static function getCacheQuestionStatus()
 {
     if (is_null(self::$_cacheQuestionStatus)) {
         self::$_cacheQuestionStatus = new CArrayList();
         foreach (CActiveRecordProvider::getAllFromTable(TABLE_QUESTION_STATUS)->getItems() as $item) {
             $term = new CTerm($item);
             self::$_cacheQuestionStatus->add($term->getId(), $term);
         }
     }
     return self::$_cacheQuestionStatus;
 }
コード例 #22
0
 /**
  * @param $key
  * @return CRate
  */
 public static function getRate($key)
 {
     if (!self::getCacheRates()->hasElement($key)) {
         $ar = CActiveRecordProvider::getById(TABLE_RATES, $key);
         if (!is_null($ar)) {
             $rate = new CRate($ar);
             self::addToCache($rate);
         }
     }
     return self::getCacheRates()->getItem($key);
 }
コード例 #23
0
 /**
  * @param $key
  * @return CDashboardReport
  */
 public static function getDashboardReport($key)
 {
     if (!self::getCacheDashboardReports()->hasElement($key)) {
         $ar = CActiveRecordProvider::getById(TABLE_DASHBOARD_REPORTS, $key);
         if (!is_null($ar)) {
             $obj = new CDashboardReport($ar);
             self::getCacheDashboardReports()->add($key, $obj);
         }
     }
     return self::getCacheDashboardReports()->getItem($key);
 }
コード例 #24
0
 public function actionIndex()
 {
     $set = CActiveRecordProvider::getAllFromTable(TABLE_PRINT_FORMS);
     $forms = new CArrayList();
     foreach ($set->getPaginated()->getItems() as $item) {
         $form = new CPrintForm($item);
         $forms->add($form->getId(), $form);
     }
     $this->setData("forms", $forms);
     $this->setData("paginator", $set->getPaginator());
     $this->renderView("_print/form/index.tpl");
 }
コード例 #25
0
 /**
  * Все студенты группы.
  * Отсортированы по ФИО
  *
  * @return CArrayList
  */
 public function getStudents()
 {
     if (is_null($this->_students)) {
         $this->_students = new CArrayList();
         foreach (CActiveRecordProvider::getWithCondition(TABLE_STUDENTS, "group_id=" . $this->getId(), "fio asc")->getItems() as $item) {
             $student = new CStudent($item);
             $this->_students->add($student->getId(), $student);
             CStaffManager::getCacheStudents()->add($student->getId(), $student);
         }
     }
     return $this->_students;
 }
コード例 #26
0
 public function actionIndex()
 {
     $set = CActiveRecordProvider::getAllFromTable(TABLE_HELP);
     $items = new CArrayList();
     foreach ($set->getPaginated()->getItems() as $item) {
         $help = new CHelp($item);
         $items->add($help->getId(), $help);
     }
     $this->setData("helps", $items);
     $this->setData("paginator", $set->getPaginator());
     $this->renderView("_help/index.tpl");
 }
コード例 #27
0
 public function actionIndex()
 {
     $set = CActiveRecordProvider::getAllFromTable(TABLE_SETTINGS, "title asc");
     $settings = new CArrayList();
     foreach ($set->getPaginated()->getItems() as $item) {
         $setting = new CSetting($item);
         $settings->add($setting->getId(), $setting);
     }
     $this->setData("settings", $settings);
     $this->setData("paginator", $set->getPaginator());
     $this->renderView("_configuration/index.tpl");
 }
コード例 #28
0
 /**
  * @param int $key
  * @return CDocumentFile
  */
 public static function getFile($key = 0)
 {
     if (!self::getCacheFiles()->hasElement($key)) {
         foreach (CActiveRecordProvider::getWithCondition(TABLE_DOCUMENTS, "id=" . $key)->getItems() as $ar) {
             $dar = new CDocumentActiveRecord($ar->getItems());
             $dar->setTable(TABLE_DOCUMENTS);
             $obj = new CDocumentFile($dar);
             self::getCacheFiles()->add($obj->getId(), $obj);
         }
     }
     return self::getCacheFiles()->getItem($key);
 }
コード例 #29
0
 public function actionIndex()
 {
     $set = CActiveRecordProvider::getAllFromTable(TABLE_USER_GROUPS);
     $groups = new CArrayList();
     foreach ($set->getPaginated()->getItems() as $r) {
         $group = new CUserGroup($r);
         $groups->add($group->getId(), $group);
     }
     $this->setData("groups", $groups);
     $this->setData("paginator", $set->getPaginator());
     $this->renderView("_acl_manager/groups/index.tpl");
 }
コード例 #30
0
 /**
  * Пользователи, которые ведут дисциплину из этой папки
  *
  * @return CArrayList|null
  */
 public function getUsers()
 {
     if (is_null($this->_users)) {
         $this->_users = new CArrayList();
         foreach (CActiveRecordProvider::getWithCondition(TABLE_LIBRARY_DOCUMENTS, "subj_id = " . $this->getDiscipline()->getId())->getItems() as $ar) {
             $user = CStaffManager::getUser($ar->getItemValue("user_id"));
             if (!is_null($user)) {
                 $this->_users->add($user->getId(), $user);
             }
         }
     }
     return $this->_users;
 }