/** * Method that permits to update a comment * * @access private */ private function update() { $action_return = array(); if (VPost::submit() == 'Update Comment') { $comment = new Comment(); $comment->_id = VPost::comment_id(); $comment->_name = VPost::comment_name(); $comment->_email = VPost::comment_email(); $comment->_content = VPost::comment_content(); $comment->_status = VPost::comment_status(); try { $comment->update('_name', 'str'); $comment->update('_email', 'str'); $comment->update('_content', 'str'); $comment->update('_status', 'str'); array_push($action_return, true); } catch (Exception $e) { array_push($action_return, false); } } elseif ((VGet::action() || VPost::apply_action(false)) && in_array(VRequest::action(), $this->_actions) && VRequest::comment_id()) { if (VPost::apply_action(false)) { foreach (VPost::comment_id() as $id) { try { $comment = new Comment(); $comment->_id = $id; $comment->_status = $this->_action_value[VPost::action()]; $comment->update('_status', 'str'); unset($comment); array_push($action_return, true); } catch (Exception $e) { array_push($action_return, false); } } } else { try { $comment = new Comment(); $comment->_id = VGet::comment_id(); $comment->_status = $this->_action_value[VGet::action()]; $comment->update('_status', 'str'); unset($comment); array_push($action_return, true); } catch (Exception $e) { array_push($action_return, false); } } } if (!empty($action_return)) { $this->_action_msg = ActionMessages::update_comment($action_return); } }
/** * Delete files on hard drive and metadata in database * * @access private */ private function delete() { if (VPost::apply_action(false) && VPost::action() == 'delete' && $this->_user['delete_content']) { if (VPost::album_id()) { try { foreach (VPost::album_id() as $id) { $album = new Media(); $album->_id = $id; $album->read('_permalink'); $to_read['table'] = 'media'; $to_read['columns'] = array('MEDIA_ID'); $to_read['condition_columns'][':id'] = 'media_album'; $to_read['condition_select_types'][':id'] = '='; $to_read['condition_values'][':id'] = $id; $to_read['value_types'][':id'] = 'int'; $ids = $this->_db->read($to_read); if (!empty($ids)) { foreach ($ids as $pid) { $pic = new Media(); $pic->_id = $pid['MEDIA_ID']; $pic->read('_permalink'); $permalink = $pic->_permalink; HandleMedia::delete(PATH . $permalink); $pic->delete(); } } $permalink = $album->_permalink; HandleMedia::delete(PATH . $permalink . 'cover.png'); @rmdir(PATH . $permalink); $album->delete(); $this->_db->query('DELETE FROM `' . DB_PREFIX . 'comment` WHERE comment_rel_id = ' . $id . ' AND comment_rel_type = "media"'); } Session::monitor_activity('deleted ' . count(VPost::album_id()) . ' album(s)'); $result = true; } catch (Exception $e) { $result = $e->getMessage(); } $this->_action_msg = ActionMessages::deleted($result); } } elseif (VGet::action() == 'delete' && VGet::id() && $this->_user['delete_content']) { try { $pic = new Media(); $pic->_id = VGet::id(); $pic->read('_permalink'); $permalink = $pic->_permalink; HandleMedia::delete(PATH . $permalink); $pic->delete(); $this->_db->query('DELETE FROM `' . DB_PREFIX . 'comment` WHERE comment_rel_id = ' . VGet::id() . ' AND comment_rel_type = "media"'); Session::monitor_activity('deleted a picture of an album'); $result = true; } catch (Exception $e) { $result = $e->getMessage(); } $this->_action_msg = ActionMessages::deleted($result); } elseif (VPost::delete_pics(false)) { if (VPost::picture_id()) { try { foreach (VPost::picture_id() as $id) { $pic = new Media(); $pic->_id = $id; $pic->read('_permalink'); $permalink = $pic->_permalink; HandleMedia::delete(PATH . $permalink); $pic->delete(); } Session::monitor_activity('deleted ' . count(VPost::picture_id(array())) . ' picture(s) of an album'); $result = true; } catch (Exception $e) { $result = $e->getMessage(); } } } elseif ((VPost::apply_action(false) && VPost::action() == 'delete' || VGet::action() == 'delete' || VPost::delete_pics(false)) && !$this->_user['delete_content']) { $this->_action_msg = ActionMessages::action_no_perm(); } }