Example #1
0
 public function action_edit()
 {
     $id = $this->request->param('id', 0);
     $opinion = ORM::factory('Expert_Opinion', $id);
     $experts = ORM::factory('Expert')->order_by('name_' . I18n::$lang)->find_all();
     $user_id = $this->user->id;
     $this->set('opinion', $opinion);
     $this->set('experts', $experts);
     if ($this->request->method() == Request::POST) {
         try {
             $opinion->expert_id = Arr::get($_POST, 'expert_id', '');
             $opinion->title = Arr::get($_POST, 'title', '');
             $opinion->description = Arr::get($_POST, 'description', '');
             $opinion->text = Arr::get($_POST, 'text', '');
             $opinion->protected = Arr::get($_POST, 'protected', '');
             $opinion->date = date('Y-m-d H:i:s');
             $opinion->user_id = $user_id;
             $opinion->save();
             $event = $id ? 'edit' : 'create';
             $loger = new Loger($event, $opinion->title);
             $loger->logThis($opinion);
             Message::success(i18n::get('The position of an expert retained'));
             $this->redirect('manage/expertopinions/view/' . $opinion->id . '/page-' . $this->page);
         } catch (ORM_Validation_Exception $e) {
             $errors = $e->errors($e->alias());
             foreach ($errors as $key => $item) {
                 $errors[preg_replace("/(_ru|_kz|_en)/", '', $key)] = preg_replace("/(_ru|_kz|_en)/", '', $item);
             }
             $this->set('opinion', $_POST);
             $this->set('errors', $errors);
         }
     }
 }
Example #2
0
 public function action_delete()
 {
     $id = (int) $this->request->param('id', 0);
     $point = ORM::factory('Point', $id);
     if (!$point->loaded()) {
         throw new HTTP_Exception_404();
     }
     $token = Arr::get($_POST, 'token', false);
     if ($this->request->method() == Request::POST && Security::token() === $token) {
         $loger = new Loger($event, $point->name);
         $loger->logThis($point);
         $redirect = 'manage/maps/view/' . $point->district_id;
         $point->delete();
         $this->redirect($redirect);
     } else {
         $this->set('record', $point)->set('token', Security::token(true))->set('cancel_url', Url::media('manage/maps/view/' . $point->district_id));
     }
 }
Example #3
0
 public function action_edit()
 {
     $id = (int) $this->request->param('id');
     $exhibit = ORM::factory('Exhibit', $id);
     if ($this->request->method() == Request::POST) {
         try {
             $exhibit->values($_POST, array('title', 'description', 'image_storage_id', 'published'))->save();
             $event = $id ? 'edit' : 'create';
             $loger = new Loger($event, $exhibit->title);
             $loger->logThis($exhibit);
             $this->redirect('manage/exhibits');
         } catch (ORM_Validation_Exception $e) {
             $this->set('error', $e->errors('error'));
         }
     }
     $uploader = View::factory('storage/image')->set('user_id', $this->user->id)->render();
     $this->set('item', $exhibit)->set('uploader', $uploader);
 }
Example #4
0
 public function action_delete()
 {
     $id = (int) $this->request->param('id', 0);
     $item = ORM::factory('Chronology_Line', $id);
     if (!$item->loaded()) {
         throw new HTTP_Exception_404('Page not found');
     }
     $period = ORM::factory('Chronology', $item->period_id);
     $token = Arr::get($_POST, 'token', false);
     if ($this->request->post() and Security::token() === $token) {
         $loger = new Loger('delete', $item->title);
         $loger->logThis($item);
         $item->delete();
         Message::success('Событие удалено');
         $this->redirect('manage/lines/list/' . $period->id);
     } else {
         $this->set('token', Security::token(true))->set('r', Url::media('manage/lines/list/' . $period->id))->set('period', $period);
     }
 }
Example #5
0
 public function action_delete()
 {
     $id = (int) $this->request->param('id', 0);
     $item = ORM::factory('Calendar', $id);
     if (!$item->loaded()) {
         throw new HTTP_Exception_404();
     }
     $month = $item->month;
     $day = $item->day;
     $token = Arr::get($_POST, 'token', false);
     if ($this->request->method() == Request::POST && Security::token() === $token) {
         $loger = new Loger('delete', $item->title);
         $loger->logThis($item);
         $item->delete();
         Message::success('Удалено');
         $this->redirect('manage/calendar/list?m=' . $month . '&d=' . $day);
     } else {
         $this->set('record', $item)->set('month', $month)->set('day', $day)->set('token', Security::token(true))->set('cancel_url', Url::media('manage/calendar/list?m=' . $month . '&d=' . $day));
     }
 }
Example #6
0
 public function action_delete()
 {
     $type = $this->request->param('type');
     $id = (int) $this->request->param('id', 0);
     $zhuzid = (int) Arr::get($_GET, 'zhuzid', 0);
     $public = ORM::factory('Publication', $id);
     if (!$public->loaded()) {
         throw new HTTP_Exception_404();
     }
     $token = Arr::get($_POST, 'token', false);
     if ($this->request->method() == Request::POST && Security::token() === $token) {
         $tags = $public->tags->where('type', '=', $type)->find_all();
         foreach ($tags as $tag) {
             ORM::factory('Tag', $tag->id)->delete();
         }
         $loger = new Loger('delete', $public->title);
         $loger->logThis($public);
         $public->delete();
         if ($zhuzid != 0) {
             $zhuz = ORM::factory('Zhuze', $zhuzid);
             $zhuz->id_publication = '';
             $zhuz->save();
             Message::success('Удалено');
             $this->redirect('manage/specprojects/zhuzes');
         } else {
             $spectab = ORM::factory('Specproject')->where('id_publication', '=', $id)->find();
             $spectab->delete();
             Message::success('Удалено');
             $this->redirect('manage/specprojects/' . $type);
         }
     } else {
         $this->set('record', $public)->set('type', $type)->set('token', Security::token(true))->set('cancel_url', Url::media('manage/specprojects/' . $type));
     }
 }
Example #7
0
 public function action_delete()
 {
     $id = (int) $this->request->param('id', 0);
     $content = ORM::factory('Pages_Content', $id);
     if (!$content->loaded()) {
         throw new HTTP_Exception_404('Page not found');
     }
     $page = ORM::factory('Page', $content->page_id);
     $token = Arr::get($_POST, 'token', false);
     if ($this->request->post() and Security::token() === $token) {
         $loger = new Loger('delete', $content->title);
         $loger->logThis($content);
         $content->delete();
         Message::success('Контент удален');
         $this->redirect('manage/contents/list/' . $page->id);
     } else {
         $this->set('token', Security::token(true))->set('r', Url::media('manage/contents/list/' . $page->id))->set('page', $page);
     }
 }
Example #8
0
 public function action_delete()
 {
     $id = (int) $this->request->param('id', 0);
     $briefing = ORM::factory('Briefing', $id);
     if (!$briefing->loaded()) {
         throw new HTTP_Exception_404();
     }
     $token = Arr::get($_POST, 'token', false);
     if ($this->request->method() == Request::POST && Security::token() === $token) {
         $loger = new Loger('delete', $briefing->title);
         $loger->logThis($briefing);
         $briefing->delete();
         Message::success('Брифинг удален');
         $this->redirect('manage/briefings');
     } else {
         $this->set('record', $briefing)->set('token', Security::token(true))->set('cancel_url', Url::media('manage/briefing'));
     }
 }
Example #9
0
 public function action_delete()
 {
     $id = (int) $this->request->param('id', 0);
     $biography = ORM::factory('Biography', $id);
     if (!$biography->loaded()) {
         throw new HTTP_Exception_404();
     }
     $token = Arr::get($_POST, 'token', false);
     if ($this->request->method() == Request::POST && Security::token() === $token) {
         $loger = new Loger('delete', $biography->name);
         $loger->logThis($biography);
         $biography->delete();
         $list = ORM::factory('Biography');
         $paginate = Paginate::factory($list);
         $list = $list->find_all();
         $last_page = $paginate->page_count();
         if ($this->page > $last_page) {
             $this->page = $this->page - 1;
         }
         if ($this->page <= 0) {
             $this->page = 1;
         }
         Message::success('Удалено');
         $this->redirect('manage/biography/page-' . $this->page);
     } else {
         $this->set('record', $biography)->set('token', Security::token(true))->set('cancel_url', Url::media('manage/biography/page-' . $this->page));
     }
 }
Example #10
0
 public function action_delete()
 {
     $id = (int) $this->request->param('id', 0);
     $news = ORM::factory('News', $id);
     if (!$news->loaded()) {
         throw new HTTP_Exception_404();
     }
     $token = Arr::get($_POST, 'token', false);
     if ($this->request->method() == Request::POST && Security::token() === $token) {
         $tags = $news->tags->find_all();
         foreach ($tags as $tag) {
             ORM::factory('Tag', $tag->id)->delete();
         }
         $loger = new Loger('delete', $news->title);
         $loger->logThis($news);
         $news->delete();
         Message::success('Новость удалена');
         $this->redirect('manage/news');
     } else {
         $this->set('record', $news)->set('token', Security::token(true))->set('cancel_url', Url::media('manage/news'));
     }
 }