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();
         }
     }
 }
 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();
     }
 }
 /**
  * Сохранение пункта меню
  */
 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");
 }
 /**
  * Получить настройку по псевдониму или ключевому полю
  *
  * @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);
 }
 public function remove()
 {
     foreach (CActiveRecordProvider::getWithCondition(TABLE_SAB_COMMISSION_MEMBERS, "commission_id=" . $this->getId())->getItems() as $ar) {
         $ar->remove();
     }
     parent::remove();
 }
 public function remove()
 {
     foreach (CActiveRecordProvider::getWithCondition(TABLE_DIPLOM_PREVIEW_MEMBERS, "comm_id=" . $this->getId())->getItems() as $ar) {
         $ar->remove();
     }
     parent::remove();
 }
 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;
 }
 /**
  * @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;
 }
 /**
  * Автоподстановка людей
  * Выбираем только людей, у которых есть показатели
  */
 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);
 }
Exemple #10
0
 /**
  * Все опубликованные пункты текущего меню с учетом иерархии
  * Показываются только опубликованные и доступные текущему пользователю
  *
  * @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;
 }
 /**
  * @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;
 }
 /**
  * Вопросы, которые по данной дисциплине есть
  *
  * @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;
 }
 /**
  * @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);
 }
 /**
  * Все студенты группы.
  * Отсортированы по ФИО
  *
  * @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;
 }
 protected function getWorks()
 {
     if (is_null($this->_works)) {
         $this->_works = new CArrayList();
         if (!is_null($this->getId())) {
             foreach (CActiveRecordProvider::getWithCondition(TABLE_IND_PLAN_WORKS, "load_id=" . $this->getId())->getItems() as $ar) {
                 $work = new CIndPlanPersonWork($ar);
                 $this->_works->add($work->getId(), $work);
             }
         }
     }
     return $this->_works;
 }
 /**
  * Пользователи, которые ведут дисциплину из этой папки
  *
  * @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;
 }
 /**
  * @static
  * @param $key
  * @return CNotificationTemplate
  */
 public static function getTemplate($key)
 {
     if (!self::getCacheTemplates()->hasElement($key)) {
         if (is_numeric($key)) {
             $item = CActiveRecordProvider::getById(TABLE_NOTIFICATION_TEMPLATES, $key);
             if (!is_numeric($item)) {
                 $template = new CNotificationTemplate($item);
                 self::getCacheTemplates()->add($template->getId(), $template);
                 self::getCacheTemplates()->add($template->alias, $template);
             }
         } else {
             foreach (CActiveRecordProvider::getWithCondition(TABLE_NOTIFICATION_TEMPLATES, "alias='" . $key . "'")->getItems() as $item) {
                 $template = new CNotificationTemplate($item);
                 self::getCacheTemplates()->add($template->getId(), $template);
                 self::getCacheTemplates()->add($template->alias, $template);
             }
         }
     }
     return self::getCacheTemplates()->getItem($key);
 }
 public function save()
 {
     $commission = $this->commission;
     $members = array();
     if (array_key_exists("members", $commission)) {
         $members = $commission["members"];
         unset($commission["members"]);
     }
     $commObj = new CDiplomPreviewComission();
     $commObj->setAttributes($commission);
     $commObj->save();
     $this->commission = $commObj;
     foreach (CActiveRecordProvider::getWithCondition(TABLE_DIPLOM_PREVIEW_MEMBERS, "comm_id=" . $commObj->getId())->getItems() as $ar) {
         $ar->remove();
     }
     foreach ($members as $m) {
         if ($m !== 0) {
             $ar = new CActiveRecord(array("comm_id" => $commObj->getId(), "kadri_id" => $m, "id" => null));
             $ar->setTable(TABLE_DIPLOM_PREVIEW_MEMBERS);
             $ar->insert();
         }
     }
 }
 /**
  * Получить настройку по псевдониму или ключевому полю
  *
  * @param $key
  * @return CSetting
  */
 public static function getSetting($key)
 {
     if (is_string($key)) {
         $key = strtoupper($key);
     }
     if (!self::getCacheSettings()->hasElement($key)) {
         if (is_string($key)) {
             foreach (CActiveRecordProvider::getWithCondition(TABLE_SETTINGS, "UPPER(alias) = '" . $key . "'")->getItems() as $item) {
                 $setting = new CSetting($item);
                 self::getCacheSettings()->add($setting->getId(), $setting);
                 self::getCacheSettings()->add($key, $setting);
             }
         } elseif (is_numeric($key)) {
             $item = CActiveRecordProvider::getById(TABLE_SETTINGS, $key);
             if (!is_null($item)) {
                 $setting = new CSetting($item);
                 self::getCacheSettings()->add(strtoupper($setting->alias), $setting);
                 self::getCacheSettings()->add($key, $setting);
             }
         }
     }
     return self::getCacheSettings()->getItem($key);
 }
 public function save()
 {
     $personArr = $this->person;
     /**
      * Сохраняем сотрудника
      */
     $this->person->save();
     /**
      * Удаляем старые типы участия на кафедре
      */
     foreach (CActiveRecordProvider::getWithCondition(TABLE_PERSON_BY_TYPES, "kadri_id=" . $this->person->getId())->getItems() as $ar) {
         $ar->remove();
     }
     /**
      * Сохраняем новые типы участия на кафедре
      */
     foreach ($this->_types as $type) {
         if ($type != "" && $type != "0") {
             $ar = new CActiveRecord(array("kadri_id" => $this->person->getId(), "person_type_id" => $type, "id" => null));
             $ar->setTable(TABLE_PERSON_BY_TYPES);
             $ar->insert();
         }
     }
 }
 /**
  * @param $category
  * @return array
  */
 public static function getWorklistByCategory($category)
 {
     $result = array();
     foreach (CActiveRecordProvider::getWithCondition(TABLE_IND_PLAN_WORKTYPES, "id_razdel=" . $category)->getItems() as $ar) {
         $w = new CIndPlanWorktype($ar);
         self::getCacheWorktypes()->add($w->getId(), $w);
         $result[$w->getId()] = $w->name;
     }
     return $result;
 }
 public function actionUpdate()
 {
     $plan = CWorkPlanManager::getWorkplan(CRequest::getInt("plan_id"));
     if (!is_null($plan->corriculumDiscipline)) {
         foreach (CActiveRecordProvider::getWithCondition(TABLE_CORRICULUM_DISCIPLINE_SECTIONS, "discipline_id=" . $plan->corriculumDiscipline->getId())->getItems() as $ar) {
             $term = new CActiveModel($ar);
             $object = new CWorkPlanTerm();
             $object->plan_id = $plan->getId();
             $object->number = $term->getId();
             $object->save();
         }
     }
     $this->redirect("workplanterms.php?action=index&plan_id=" . $plan->getId());
 }
 /**
  * Термин по названию, идентификатору или псевдониму
  *
  * @param $key
  * @return CTerm
  */
 public function getTerm($key)
 {
     $term = null;
     if (is_numeric($key)) {
         $term = $this->getCacheTerms()->getItem($key);
     } elseif (is_string($key)) {
         $key = mb_strtoupper($key);
         if (!$this->getCacheTerms()->hasElement($key)) {
             foreach (CActiveRecordProvider::getWithCondition(TABLE_TAXONOMY_TERMS, "UPPER(name) = '" . $key . "'")->getItems() as $item) {
                 $term = new CTerm($item);
                 $this->getCacheTerms()->add($term->getId(), $term);
                 $this->getCacheTerms()->add($key, $term);
             }
         } else {
             $term = $this->getCacheTerms()->getItem($key);
         }
     }
     return $term;
 }
 /**
  * Все модели, которые связаны с указанной задачей
  *
  * @param $key
  * @return CArrayList
  */
 public static function getModelsByTask($key)
 {
     $result = new CArrayList();
     foreach (CActiveRecordProvider::getWithCondition(TABLE_CORE_MODEL_TASKS, "task_id=" . $key)->getItems() as $ar) {
         $modelTask = new CCoreModelTask($ar);
         if (!is_null($modelTask->model)) {
             $model = $modelTask->model;
             $result->add($model->getId(), $model);
         }
     }
     return $result;
 }
 /**
  * Меню задач для текущего пользователя.
  * Возвращаются только доступные ему задачи
  *
  * @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");
 }
 /**
  * @param $key
  * @return CPrintField
  */
 public static function getField($key)
 {
     if (!self::getCacheField()->hasElement($key)) {
         $item = null;
         if (is_numeric($key)) {
             $item = CActiveRecordProvider::getById(TABLE_PRINT_FIELDS, $key);
         } elseif (is_string($key)) {
             foreach (CActiveRecordProvider::getWithCondition(TABLE_PRINT_FIELDS, "LCASE(alias) = '" . mb_strtolower($key) . "'")->getItems() as $i) {
                 $item = $i;
             }
         }
         if (!is_null($item)) {
             $field = new CPrintField($item);
             self::getCacheField()->add($field->getId(), $field);
             self::getCacheField()->add($field->alias, $field);
         }
     }
     return self::getCacheField()->getItem($key);
 }
 public function save()
 {
     // удаляем старые данные
     foreach (CActiveRecordProvider::getWithCondition(TABLE_IND_PLAN_WORKS, "load_id=" . $this->getLoad()->getId() . " and work_type=1")->getItems() as $ar) {
         $ar->remove();
     }
     // добавляем новые
     foreach ($this->data as $isContract => $works) {
         foreach ($works as $type_id => $months) {
             foreach ($months as $month_id => $value) {
                 $obj = new CIndPlanPersonWork();
                 $obj->load_id = $this->getLoad()->getId();
                 $obj->work_type = "1";
                 $obj->load_month_id = $month_id;
                 $obj->load_type_id = $type_id;
                 $obj->load_is_contract = $isContract;
                 $obj->load_value = $value;
                 $obj->save();
             }
         }
     }
 }
 /**
  * Список вопросов по дисциплине
  *
  * @static
  * @param CTerm $discipline
  * @return CArrayList
  */
 public static function getQuestionsByDiscipline(CTerm $discipline)
 {
     $arr = new CArrayList();
     foreach (CActiveRecordProvider::getWithCondition(TABLE_SEB_QUESTIONS, "discipline_id=" . $discipline->getId())->getItems() as $i) {
         $q = new CSEBQuestion($i);
         $arr->add($q->getId(), $q);
         self::getCacheQuestions()->add($q->getId(), $q);
     }
     return $arr;
 }
 /**
  * Удалить все записи из таблицы
  *
  * @param $table
  * @param $condition
  */
 public static function removeWithCondition($table, $condition)
 {
     /**
      * @var CActiveRecord $ar
      */
     foreach (CActiveRecordProvider::getWithCondition($table, $condition)->getItems() as $ar) {
         $ar->remove();
     }
 }
 public function actionMyGradebooks()
 {
     $gradebooks = new CArrayList();
     $set = CActiveRecordProvider::getWithCondition(TABLE_GRADEBOOKS, "person_id = " . CSession::getCurrentUser()->getId());
     foreach ($set->getPaginated()->getItems() as $item) {
         $gradebook = new CGradebook($item);
         $gradebooks->add($gradebook->getId(), $gradebook);
     }
     $this->setData("paginator", $set->getPaginator());
     $this->setData("gradebooks", $gradebooks);
     $this->renderView("_gradebook/gradebooks.tpl");
 }