示例#1
0
文件: text.php 项目: ak826843/bmf
 /**
  * Receive data from user, prepare and keep it our databse
  */
 public function save($post_id, $module_id)
 {
     $data = array();
     $data['module_id'] = $module_id;
     $data['original'] = param('original', TRUE, FALSE);
     $this->text->save($data);
     // keep in safe place ;)
     set_flash_ok('Текст сохранён');
     redirect('post/form/' . $post_id . '#mod-' . $module_id);
 }
示例#2
0
文件: code.php 项目: ak826843/bmf
 /**
  * 
  */
 public function save($post_id, $module_id)
 {
     $data = array();
     $data['module_id'] = $module_id;
     $data['language'] = param('language');
     $data['full'] = param('full', FALSE, FALSE);
     $this->code->save($data);
     // keep in safe place ;)
     set_flash_ok('Код сохранён');
     redirect('post/form/' . $post_id . '/' . $module_id . '#mod-' . $module_id);
 }
示例#3
0
文件: photo.php 项目: ak826843/bmf
 /**
  * Method saves the picture in post $post_id, module $module_id
  * 
  * @param number $post_id
  * @param number $module_id
  */
 public function save($post_id, $module_id)
 {
     // Uploading an image file & resize
     if (!empty($_FILES['image'])) {
         // если есть изображение пробуем загрузить, откорректировать и сделать превью
         try {
             $this->photo->upload('image')->resize_image(array('width' => $this->settings['max_width'], 'height' => $this->settings['max_height'], 'adaptive' => TRUE));
             $data['image'] = $this->photo->file_name;
             $data['alt'] = param('alt');
             $data['module_id'] = $module_id;
             $this->photo->save($data);
             set_flash_ok('Картиночка сохранена');
         } catch (Exception $e) {
             log_message('error', $e->code . ' : ' . $e->message);
             set_flash_ok('Ошибка во время сохранения изображения!');
         }
     }
     redirect('post/form/' . $post_id . '/' . $module_id . '#mod-' . $module_id);
 }
示例#4
0
文件: picture.php 项目: ak826843/bmf
 /**
  * Method saves the picture in post $post_id, module $module_id
  * 
  * @param number $post_id
  * @param number $module_id
  */
 public function save($post_id, $module_id)
 {
     $post = $this->post->find($post_id, 1);
     user_can_rule($post);
     // Uploading an image file & resize
     if (!empty($_FILES['image'])) {
         try {
             $this->picture->upload('image')->resize_image(array('width' => $this->settings['max_width'], 'height' => $this->settings['max_height'], 'thumb' => TRUE));
             $data['image'] = $this->picture->file_name;
             $data['alt'] = param('alt');
             $data['module_id'] = $module_id;
             $this->picture->save($data);
             set_flash_ok('Изображение сохранено');
         } catch (Exception $e) {
             log_message('error', $e->getCode() . ' : ' . $e->getMessage());
             set_flash_ok('Ошибка во время сохранения изображения');
             redirect(post_form_save_path($post, $module_id));
         }
     }
     redirect(post_form_path($post));
 }
示例#5
0
文件: user.php 项目: ak826843/bmf
 public function unban()
 {
     $user = $this->get_admin_user_params();
     $ban = array('id' => $user['id'], 'banned' => 0);
     $this->user->save($ban);
     set_flash_ok('Пользователь разбанен :(');
     redirect('user/profile/' . $user['login']);
 }
示例#6
0
文件: post.php 项目: ak826843/bmf
 /**
  * Add new comment to topic
  */
 public function comment()
 {
     $this->load->model('comment');
     $comment['post_id'] = param('post_id');
     if (empty($comment['post_id'])) {
         set_flash_error('Ошибка в параметрах комментария');
         redirect();
     }
     $post = $this->post->find($comment['post_id'], 1);
     if (empty($post)) {
         set_flash_error('Такого топика не существует');
         redirect();
     }
     $comment['parent_id'] = param('parent_id');
     $comment['text'] = prepare_text(param('text', TRUE, FALSE));
     if (empty($comment['text'])) {
         set_flash_error('Вы не написали свой комментарий к топику');
         redirect(post_link($post));
     }
     $comment['user_id'] = $this->current_user['id'];
     $comment['added_at'] = now2mysql();
     $id = $this->comment->save($comment);
     if ($id) {
         set_flash_ok('Спасибо за ваш комментарий');
     } else {
         set_flash_error('Извините, но произошла ошибка и ваш комментарий сохранить не удалось');
     }
     redirect(post_link($post) . '#com' . $id);
 }