/** * Method that permits to create a new comment * * @access private */ private function create() { if (VPost::submit() == 'Submit Reply') { $comment = new Comment(); $comment->_name = $this->_user['user_username']; $comment->_email = $this->_user['user_email']; $comment->_content = VPost::comment_content(); $comment->_rel_id = VPost::id(); $comment->_rel_type = VPost::type(); $comment->_status = 'approved'; try { $comment->create(); $this->_action_msg = ActionMessages::reply_comment(true); } catch (Exception $e) { $this->_action_msg = ActionMessages::reply_comment($e->getMessage()); } } }
/** * Method that permits to create a new category * * @access private */ private function create() { if (VPost::add_cat(false) && VPost::name() && VPost::type() != 'no') { try { $cat = new Category(); $cat->_name = VPost::name(); $cat->_type = VPost::type(); $cat->create(); Session::monitor_activity('created a new category: ' . $cat->_name); $result = true; } catch (Exception $e) { $result = $e->getMessage(); } $this->_action_msg = ActionMessages::created($result); } elseif (VPost::add_cat(false) && (!VPost::name() || VPost::type() == 'no')) { $this->_action_msg = ActionMessages::custom_wrong('Make sure you\'ve filled all inputs!'); } }
/** * Delete medias from database and on hard drive * * @access private */ private function delete() { if ($this->_user['delete_content'] && VPost::delete(false) && VPost::media_id()) { $results = array(); $global_result = true; foreach (VPost::media_id() as $id) { try { $media = new Media(); $media->_id = $id; $media->read('_permalink'); $path = $media->_permalink; $media->delete(); unset($media); HandleMedia::delete(PATH . $path); $this->_db->query('DELETE FROM `' . DB_PREFIX . 'comment` WHERE comment_rel_id = ' . $id . ' AND comment_rel_type = "media"'); if (VPost::type() == 'alien') { $to_update['table'] = 'media'; $to_update['columns'] = array(':attach' => 'media_attachment'); $to_update['condition_columns'] = array(':ca' => 'media_attachment'); $to_update['column_values'] = array(':attach' => null, ':ca' => $id); $to_update['value_types'] = array(':attach' => 'null', ':ca' => 'int'); $this->_db->update($to_update); } array_push($results, true); } catch (Exception $e) { array_push($results, false); } } foreach ($results as $result) { if ($result !== true) { $global_result = false; } } Session::monitor_activity('deleted ' . count(VPost::media_id()) . ' file(s)'); $this->_action_msg = ActionMessages::deleted($global_result); } elseif ($this->_user['delete_content'] && VGet::action() == 'delete' && VGet::id()) { try { $media = new Media(); $media->_id = VGet::id(); $media->read('_permalink'); $path = $media->_permalink; $media->delete(); unset($media); HandleMedia::delete(PATH . $path); $this->_db->query('DELETE FROM `' . DB_PREFIX . 'comment` WHERE comment_rel_id = ' . VGet::id() . ' AND comment_rel_type = "media"'); if (VGet::type() == 'alien') { $to_update['table'] = 'media'; $to_update['columns'] = array(':attach' => 'media_attachment'); $to_update['condition_columns'] = array(':ca' => 'media_attachment'); $to_update['column_values'] = array(':attach' => null, ':ca' => VGet::id()); $to_update['value_types'] = array(':attach' => 'null', ':ca' => 'int'); $this->_db->update($to_update); } Session::monitor_activity('deleted a file'); $result = true; } catch (Exception $e) { error_log($e->getMessage(), 0); $result = false; } $this->_action_msg = ActionMessages::deleted($result); } elseif (!$this->_user['delete_content'] && (VPost::delete(false) || VGet::action() == 'delete')) { $this->_action_msg = ActionMessages::action_no_perm(); } }