예제 #1
0
 protected function get_links()
 {
     $id = $this->get_id();
     $update = new Model_Post_Update($id);
     $links = Database::join('post_update_link_url', 'pulu.link_id = pul.id')->join('post_url', 'pulu.url_id = pu.id')->get_full_table('post_update_link', 'pul.update_id = ?', $id);
     foreach ($links as $link) {
         $link = new Model_Post_Update_Link($link);
         $update->add_link($link);
     }
     return $update->get('link');
 }
예제 #2
0
 public function __construct($reader, $writer)
 {
     parent::__construct($reader, $writer);
     $data = $this->reader->get_data();
     if (empty($data['id']) || !Check::id($data['id'])) {
         throw new Error_Update('Incorrect Id');
     }
     $model = new Model_Post_Update($data['id']);
     $model->load();
     if ($model->is_phantom()) {
         throw new Error_Update('Incorrect Id');
     }
     $this->model = $model;
 }
예제 #3
0
파일: post.php 프로젝트: 4otaku/4otaku
 public function update()
 {
     if (!is_numeric(query::$post['id'])) {
         $this->writer->set_message('Что-то странное с формой обновления, сообщите администрации');
         return;
     }
     $author = trim(strip_tags(query::$post['author']));
     if (empty($author)) {
         $this->writer->set_message('Вы забыли указать автора обновления');
         return;
     }
     $text = Transform_Text::format(query::$post['text']);
     if (!trim(strip_tags($text))) {
         $this->writer->set_message('Вы забыли добавить описание обновления');
         return;
     }
     $links = array();
     foreach (query::$post['link'] as $link) {
         if (!empty($link['use'])) {
             unset($link['use']);
             $links[] = $link;
         }
     }
     $links = Transform_Link::parse($links);
     if (empty($links)) {
         $this->writer->set_message('Проверьте ссылки, с ними была какая-то проблема');
         return;
     }
     $update = new Model_Post_Update(array('post_id' => query::$post['id'], 'username' => $author, 'text' => $text, 'pretty_text' => undo_safety(query::$post['text'])));
     foreach ($links as $link) {
         $link = new Model_Post_Update_Link($link);
         $update->add_link($link);
     }
     $update->insert();
     $this->writer->set_success()->set_message('Запись успешно обновлена');
 }