function get_content_object_from_id($id) { // returns an object for the content with id == $id global $db, $config_vars, $userdata, $filetypes; // get content $uncontent = new album_content(); if ($uncontent->generate_from_id($id) == OP_SUCCESSFUL) { // check if user has view perms to that content if (check_content_action_allowed($uncontent->get_contentgroup_id(), $userdata['user_id'], 'view')) { $objtyp = $filetypes[getext($uncontent->file)]; if (isset($objtyp)) { $incontent = new $objtyp(); //this sucks (additional sql query) but its ok for now $incontent->generate_from_id($id); } else { // unsupported filetype } return $incontent; } else { return OP_MISSING_VIEW; } } else { return OP_FAILED; } }
function delete() { global $db, $config_vars, $userdata; // remove from content table // check is user is allowed $content = new album_content(); $content->generate_from_id($this->owner_id); if ($userdata['user_id'] == $this->user_id or check_content_action_allowed($content->get_contentgroup_id(), $userdata['user_id'], 'content_edit')) { // check wether the comment has child comments if (is_array($this->get_childs())) { // comment has childs $this->set_feedback('DELETED'); $this->commit(); } else { // comment has no childs $sql = "DELETE FROM " . $config_vars['table_prefix'] . "content_comments WHERE id = " . $this->id; if (!($result = $db->sql_query($sql))) { error_report(SQL_ERROR, 'delete', __LINE__, __FILE__, $sql); } $content->dec_comments_amount(); $content->commit(); unset($this->id); } } }