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); } } }
public function index() { $writter = new \XMLWriter(); $writter->openMemory(); $writter->startDocument('1.0', 'UTF-8'); $writter->setIndent(TRUE); $writter->startElement('rss'); $writter->writeAttribute('version', '2.0'); $writter->startElement('channel'); //header $writter->writeElement('title', 'phpMint RSS'); $writter->writeElement('link', 'mein LINK'); $writter->writeElement('description', 'Ein PHP-Blog über PHP, jQuery, JavaScript und weiteren Technik-Themen.'); //body foreach ($this->getPosts() as $key => $post) { $writter->startElement('item'); $writter->writeElement('title', $post['title']); $writter->writeElement('pubDate', $post['datum']); $writter->writeElement('link', $post['slug']); $writter->writeElement('description', $post['preview']); $writter->endElement(); } while ($writter->endElement() !== false) { continue; } $writter->endDocument(); $test = $writter->outputMemory(TRUE); $loger = new \Loger('session'); $loger->write($test); $this->response->addHeader('Content-type: text/xml; charset=UTF-8'); $this->response->setOutput($test); }
public function action_delete() { $id = (int) $this->request->param('id', 0); $type = Arr::get($_GET, 'type', 'slider'); $token = Arr::get($_POST, 'token', false); if ($this->request->method() == Request::POST && Security::token() === $token) { $slider = ORM::factory('Slider', $id); $loger = new Loger('delete', $slider->link_ru); $loger->log($slider); $slider->delete(); $this->redirect('manage/sliders/?type=' . $type); } else { $this->set('token', Security::token(true))->set('r', Url::media('manage/sliders?type=' . $type)); } }
public function action_delete() { $id = (int) $this->request->param('id', 0); $infograph = ORM::factory('Infograph', $id); if (!$infograph->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', $infograph->title); $loger->log($infograph); $infograph->delete(); Message::success('Запись удалена'); $this->redirect('manage/infographs'); } else { $this->set('record', $infograph)->set('token', Security::token(true))->set('cancel_url', Url::media('manage/infographs')); } }
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); }
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)); } }
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); } }
public function action_addedit() { $id = $this->request->param('id', 0); $params = explode('-', $id); array_walk($params, 'intval'); $ent_id = $params[0]; if (isset($params[1])) { $quest_id = $params[1]; $quest = ORM::factory('Qv', $quest_id); } else { $quest = ORM::factory('Qv'); } $kt = ORM::factory('kt', $ent_id); $this->set('quest', $quest); if (!$kt->loaded()) { throw new HTTP_Exception_404(); } $this->set('kt', $kt); if ($id) { $vk = ORM::factory('Vk', $id); $this->set('vk', $vk); } else { } if ($this->request->method() == 'POST') { $title = Security::xss_clean(Arr::get($_POST, 'title', '')); try { $vk = ORM::factory('vk', $id); $vk->id_kt = $ent_id; $vk->title = $title; $vk->published = 1; $vk->date = date("Y-m-d H:i:s"); $vk->save(); $event = $id ? 'edit' : 'create'; $loger = new Loger($event, $vk->title); $loger->log($vk); $this->redirect('manage/tests/addvar/' . $ent_id); } catch (ORM_Validation_Exception $e) { $errors = $e->errors($e->alias()); $this->set('errors', $errors); } } }
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)); } }
public function action_delete() { $id = (int) $this->request->param('id', 0); $book = ORM::factory('Book', $id); if (!$book->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', $book->title); $loger->log($book); $book->delete(); Message::success(I18n::get('Record deleted')); $this->redirect('manage/library'); } else { $this->set('record', $book)->set('token', Security::token(true))->set('cancel_url', Url::media('manage/library')); } }
public function action_delete() { $id = (int) $this->request->param('id', 0); $video = ORM::factory('Video', $id); if (!$video->loaded()) { throw new HTTP_Exception_404(); } $category = 0; if ($video->category_id) { $category = $video->category; } $token = Arr::get($_POST, 'token', false); if ($this->request->method() == Request::POST && Security::token() === $token) { $loger = new Loger('delete', $video->title); $loger->log($video); $video->delete(); Message::success('Запись удалена'); $this->redirect('manage/video/category/' . $category); } else { $this->set('record', $video)->set('token', Security::token(true))->set('cancel_url', Url::media('manage/video/category/' . $category))->set('category', $category); } }
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)); } }
public function action_edit() { $id = (int) $this->request->param('id', 0); if ($id) { $ent = ORM::factory('Test_variant', $id); $this->set('ent', $ent); } else { } if ($this->request->method() == 'POST') { $title = Security::xss_clean(Arr::get($_POST, 'title', '')); try { $ent = ORM::factory('Test_variant', $id); $ent->title = $title; $ent->date = date("Y-m-d H:i:s"); $ent->save(); $event = $id ? 'edit' : 'create'; $loger = new Loger($event, $ent->title); $loger->log($ent); $this->redirect('manage/tests/'); } catch (ORM_Validation_Exception $e) { $errors = $e->errors($e->alias()); $this->set('errors', $errors); } } }
public function action_delete() { $id = (int) $this->request->param('id', 0); $photoset = ORM::factory('Photoset', $id); if (!$photoset->loaded()) { throw new HTTP_Exception_404(); } $token = Arr::get($_POST, 'token', false); if ($this->request->method() == Request::POST && Security::token() === $token) { $attachments = $photoset->attach->find_all(); foreach ($attachments as $attach) { ORM::factory('Photosets_Attachment', $attach->id)->delete(); } $loger = new Loger('delete', $photoset->name ? $photoset->name : 'без навания'); $loger->log($photoset); $photoset->delete(); Message::success('Фотоальбом удален'); $this->redirect('manage/photosets'); } else { $this->set('record', $photoset)->set('token', Security::token(true))->set('cancel_url', Url::media('manage/photosets')); } }
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')); } }
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)); } }
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); } }
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')); } }