Example #1
0
 protected function link($data)
 {
     $link_ids = Database::get_table('post_update_link', 'id', 'update_id = ?', $this->model->get_id());
     Database::delete('post_update_link_url', Database::array_in('link_id', $link_ids), $link_ids);
     Database::delete('post_update_link', 'update_id = ?', $this->model->get_id());
     $links = Check::link_array($data['link']);
     $links = Transform_Link::parse($links);
     foreach ($links as $link) {
         $link = new Model_Post_Update_Link($link);
         $this->model->add_link($link);
     }
 }
Example #2
0
 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('Запись успешно обновлена');
 }
Example #3
0
 protected function extra($data)
 {
     Database::delete('post_extra', 'post_id = ?', $this->model->get_id());
     $extras = Check::link_array($data['extra']);
     $extras = Transform_Link::parse($extras);
     foreach ($extras as $extra) {
         $extra = new Model_Post_Extra($extra);
         $this->model->add_extra($extra);
     }
 }