private function handleGET_deleteContent($request_data) { $location = $request_data['back_page']; if (!empty($request_data['cid']) && !empty(PA::$login_uid)) { $params = array('permissions' => 'delete_content', 'uid' => PA::$login_uid, 'cid' => $request_data['cid']); if (PermissionsHandler::can_user(PA::$login_uid, $params)) { Content::delete_by_id($request_data['cid']); Activities::update(array('type' => 'user_post_a_blog', 'subject' => PA::$login_uid, 'object' => $request_data['cid']), 'deleted'); } else { $location .= '&msg_id=7033'; $this->controller->redirect($location); exit; } if (PA::$network_info) { $nid = '_network_' . PA::$network_info->network_id; } else { $nid = ''; } //unique name $cache_id = 'content_' . $request_data['cid'] . $nid; CachedTemplate::invalidate_cache($cache_id); $location .= '&msg_id=7024'; $this->controller->redirect($location); exit; } else { $this->controller->redirect($location); exit; } }
public function delete() { Logger::log("Enter: Event::delete"); $event_id = $this->event_id; $content_id = $this->get_cid_from_eid($event_id); Content::delete_by_id($content_id); // remove all EventAssociations for this Event EventAssociation::delete_for_event($event_id); $sql = "DELETE FROM {events} WHERE event_id = ?"; $data = array($event_id); try { Dal::query($sql, $data); } catch (PAException $e) { throw $e; } Logger::log("Exit: Event::delete"); }
/** * disapprove content/user in moderated queue * @access public * @param int id of user/content * @param string type ie user/content */ public function disapprove($item_id, $type) { Logger::log("Enter : Group::disapprove() | Args: \$item_id = {$item_id}, \$type = {$type}"); $res = Dal::query("DELETE FROM {moderation_queue} WHERE collection_id = ? AND item_id = ? and type= ?", array($this->collection_id, $item_id, $type)); Content::delete_by_id($item_id); Logger::log("Exit : Group::disapprove()"); }
$content_id = $_GET["cid"]; // added check for ownership --Martin if (Content::is_owner_of(PA::$login_user->user_id, $content_id)) { // $msg .= "Deleting cid " . $content_id . "<br/>\n"; Content::delete_by_id($content_id); } else { $msg .= "You are not owner of cid " . $content_id . "<br/>\n"; } } // Code for Deleting the Content Other than Media: Starts if (!empty($_POST["delete_content"])) { $id_array = $_POST["delete_content"]; for ($counter = 0; $counter < count($id_array); $counter++) { // added check for ownership --Martin if (Content::is_owner_of(PA::$login_user->user_id, $id_array[$counter])) { Content::delete_by_id($id_array[$counter]); } else { $msg .= "You are not owner of cid " . $id_array[$counter] . "<br/>\n"; } } } function setup_module($column, $moduleName, $obj) { global $content_type, $users, $uid, $_GET, $user; switch ($column) { case 'left': $obj->mode = PRI; if ($moduleName != 'LogoModule') { $obj->block_type = HOMEPAGE; } if ($moduleName == 'RecentCommentsModule') {
/** * deletes an object from database * @access protected */ protected function delete() { Logger::log("Enter: Content::delete()"); // soft deleting Content::delete_by_id($this->content_id); Logger::log("Exit: Content::delete()"); $this->is_active = 0; return; }
/** * disapprove content/user in moderated queue * @access public * @param int id of user/content * @param string type ie user/content */ public function disapprove_content($content_id, $type = 'content') { Logger::log("Enter : Network::disapprove_content() | Args: \$item_id = {$content_id}, \$type = {$type}"); $res = Dal::query("DELETE FROM {moderation_queue} WHERE item_id = ? and type= ?", array($content_id, $type)); Content::delete_by_id($content_id); Logger::log("Exit : Network::disapprove_content()"); return; }
/** * Disapprove suggestion and remove it from {moderation_queue} database table * * @access public * @param int id of content */ public static function disapprove_suggestion($suggestion_id) { Logger::log("Enter: ModerationQueue::disapprove_suggestion() | Args: \$suggestion_id = {$suggestion_id}"); $sql = 'DELETE FROM {moderation_queue} WHERE item_id = ? and type = ?'; Dal::query($sql, array($suggestion_id, self::TYPE_SUGGESTION)); Content::delete_by_id($suggestion_id); Logger::log("Exit: ModerationQueue::disapprove_suggestion()"); }
function testAddDeleteContentComments() { // Dal::register_query_callback("explain_query"); echo "getting a user\n"; $user = Test::get_test_user(); echo "test user = {$user->first_name} {$user->last_name}\n"; echo "adding some content\n"; $post = new BlogPost(); $post->author_id = $user->user_id; $post->parent_collection_id = -1; $post->title = "Test blog post (from testAddDeleteContentComments)"; $post->body = "<p>This is the post body!</p><p>Foo <b>foo</b> foo</p>"; $post->allow_comments = 1; $post->is_active = 1; $post->display_on = DISPLAY_ON_HOMEPAGE; $post->save(); echo "... saved as content_id={$post->content_id}\n"; echo "testing that it is retrievable\n"; $post_retr = Content::load_content($post->content_id, $user->user_id); $this->assertEquals($post_retr->content_id, $post->content_id); $this->assertEquals($post_retr->title, $post->title); $this->assertEquals($post_retr->body, $post->body); $this->assertEquals($post_retr->author_id, $user->user_id); $this->assertEquals($post_retr->is_active, 1); echo "posting a comment\n"; $cmt = new Comment(); $cmt->content_id = $post->content_id; $cmt_comment = "This is an automatic comment - on an autogenerated post"; $cmt->comment = $cmt_comment; $cmt->user_id = $user->user_id; $cmt->name = $cmt->email = $cmt->homepage = ''; $cmt->ip_addr = '127.0.0.1'; $cmt->referrer = 'http://example.com/'; $cmt->user_agent = 'phpunit auto-test'; $cmt->save(); echo "... saved as comment_id={$cmt->comment_id}\n"; echo "testing that the comment is retrievable\n"; $cmt_retr = new Comment(); $cmt_retr->load($cmt->comment_id); $this->assertEquals($cmt_retr->comment_id, $cmt->comment_id); $this->assertEquals($cmt_retr->content_id, $post->content_id); $this->assertEquals($cmt_retr->comment, $cmt_comment); $this->assertEquals($cmt_retr->is_active, 1); echo "testing that we see one comment on the post\n"; $comments = Comment::get_comment_for_content($post->content_id); echo count($comments) . " comments\n"; //var_dump($comments); $this->assertEquals(count($comments), 1); echo "testing that we have no trackbacks on the post\n"; $trackbacks = Content::get_trackbacks_for_content($post->content_id); echo count($trackbacks) . " trackbacks\n"; //var_dump($trackbacks); $this->assertEquals(count($trackbacks), 0); echo "posting ANOTHER comment\n"; $cmt2 = new Comment(); $cmt2->content_id = $post->content_id; $cmt2_comment = "This is ANOTHER automatic comment - on the same autogenerated post"; $cmt2->comment = $cmt_comment; $cmt2->user_id = $user->user_id; $cmt2->name = $cmt2->email = $cmt2->homepage = ''; $cmt2->ip_addr = '127.0.0.1'; $cmt2->referrer = 'http://example.com/'; $cmt2->user_agent = 'phpunit auto-test'; $cmt2->save(); echo "... saved as comment_id={$cmt2->comment_id}\n"; echo "testing that we see two comments on the post\n"; $comments = Comment::get_comment_for_content($post->content_id); $this->assertEquals(count($comments), 2); echo "deleting the first comment\n"; $cmt_retr->delete(); echo "testing that we see one comment on the post again (not seeing the deleted one)\n"; $comments = Comment::get_comment_for_content($post->content_id); $this->assertEquals(count($comments), 1); echo "testing that the first comment (now deleted) is not retrievable\n"; $cmt_retr_fail = new Comment(); try { $cmt_retr_fail->load($cmt->comment_id); $this->assertTrue(FALSE); // shouldn't get here } catch (PAException $e) { $this->assertEquals($e->getCode(), COMMENT_NOT_EXIST); } echo "deleting the post\n"; Content::delete_by_id($post->content_id); echo "testing that the post is not retrievable\n"; try { $post_retr_fail = Content::load_content($post->content_id, $user->user_id); $this->assertTrue(FALSE); // shouldn't get here } catch (PAException $e) { $this->assertEquals($e->getCode(), CONTENT_NOT_FOUND); } echo "testing that the last comment is not retrievable\n"; $cmt_retr_fail = new Comment(); try { $cmt_retr_fail->load($cmt->comment_id); $this->assertTrue(FALSE); // shouldn't get here } catch (PAException $e) { $this->assertEquals($e->getCode(), COMMENT_NOT_EXIST); } // summarize_timed_queries(); }
/** ! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * [filename] is a part of PeopleAggregator. * [description including history] * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @author [creator, or "Original Author"] * @license http://bit.ly/aVWqRV PayAsYouGo License * @copyright Copyright (c) 2010 Broadband Mechanics * @package PeopleAggregator */ $login_required = TRUE; include_once "web/includes/page.php"; require_once "api/Content/Content.php"; if ($_GET['cid']) { Content::delete_by_id($_GET['cid']); } if (PA::$network_info) { $nid = PA::$network_info->network_id; } else { $nid = ''; } //unique name $cache_id = 'content_' . $_GET['cid'] . $nid; CachedTemplate::invalidate_cache($cache_id); $location = PA::$url . '/network_manage_content.php?nid=' . $nid . '&msg_id=7024'; if (isset($_REQUEST['gid'])) { $location = PA::$url . '/manage_group_content.php?gid=' . $_GET['gid'] . '&msg_id=7024'; } header("Location: {$location}"); exit;
function blogger_deletePost($args) { $postid = $args['postid']; $login = $args['login']; $password = $args['password']; $publish = $args['publish']; // ignored $user = api_load_user($login, $password); // try to locate the content list($context, $context_id, $cid) = explode(":", $postid); //FIXME: $ccid isn't required for editing/deletion, but it would be nice to verify it // list($ccid, $post_id_prefix) = api_ccid_from_blogid($user, $context, $context_id); $cid = (int) $cid; // delete it! $content = Content::load_content($cid, $user->user_id); if ($content->author_id == $user->user_id) { Content::delete_by_id($cid); } return TRUE; }
/** Adding function delete for deleting this We are sending a request to the tekmedia server for deleting the content But at present we used Softdelete from our side */ function delete_video($content_id) { Logger::log("Enter: TekVideo::delete_video()"); if (empty($content_id)) { return true; } // for deleting this content, retrive all the information of that content $this->load($content_id); try { $video_id = $this->video_id; $sql = 'DELETE FROM {media_videos} WHERE content_id = ?'; $data = array($this->content_id); Dal::query($sql, $data); // Content_deleted successfully from video table Content::delete_by_id($this->content_id); // Content deleted successfully from Content table $tekmedia_obj = new Tekmedia(); $tekmedia_obj->delete_video_from_server($video_id); // Video deleted successfully from tekmedia server // all done - commit to database Dal::commit(); } catch (PAException $e) { Dal::rollback(); throw $e; } Logger::log("Exit: TekVideo::delete_video()"); return true; }
function render_for_ajax() { $op = $this->params["op"]; $this->gid = @$this->params['blog_id']; if ($op != 'paging' && empty(PA::$login_user)) { return __("Login required"); } switch ($op) { case "save_post": // $this->note = "Save piost goes here."; // validation // return "<pre>".print_r($this->params,1)."</pre>"; $post = $this->params; $this->cid = @$post['cid']; $errmsg = ''; $err = FALSE; if (empty($post['title'])) { $errmsg .= __("Please add a title."); $err = TRUE; } else { $post['title'] = $this->html($post['title']); } if (empty($post['body'])) { $errmsg .= __("Please add some text."); $err = TRUE; } else { $post['body'] = $this->html($post['body']); } if ($err) { $this->err = $errmsg; foreach ($post as $k => $v) { $this->content->{$k} = $v; } $this->inner_template = 'newpost.tpl'; } else { $tags = array(); if (!empty($post['tags'])) { foreach (explode(',', $post['tags']) as $term) { $tr = trim($term); if ($tr) { $tags[] = $tr; } } } $post_saved = BlogPost::save_blogpost($this->cid, PA::$login_user->user_id, $post["title"], $post["body"], NULL, $tags, $this->gid); if (empty($post_saved['cid'])) { $this->note = "<pre>" . print_r($this, 1) . "</pre>"; $this->err = "<pre>" . print_r($post_saved['errors'], 1) . "</pre>"; foreach ($post as $k => $v) { $this->content->{$k} = $v; } $this->inner_template = 'newpost.tpl'; } } break; case "new_post": $this->inner_template = 'newpost.tpl'; break; case "edit_post": $this->inner_template = 'newpost.tpl'; $this->cid = @$this->params['cid']; $this->content = NULL; if ($this->cid) { $this->content = Content::load_content((int) $this->cid, (int) PA::$login_uid); } break; case "delete_post": $post = $this->params; // owner check would go here try { Content::delete_by_id($post['cid']); $this->note = __("Post was deleted successfully."); unset($this->params['cid']); // or we'd have a permalink to a post we no longer have } catch (PAException $e) { $this->err = __("There was an error deleting this post: ") . $e->getMessage(); } break; case "remove_author": // the group is not loaded at this point soo we do it here $g = ContentCollection::load_collection($this->gid, PA::$login_user->user_id); // unjoin user to group if ($g->leave($this->params['pa_id'])) { $this->note = "Successfully removed author."; } else { $this->err = "Couldn't remove author."; } break; case "add_author": // the group is not loaded at this point soo we do it here $g = ContentCollection::load_collection($this->gid, PA::$login_user->user_id); // find real PA user_id $su = new ShadowUser($this->skin); try { $su->load($this->params['remote_id']); if ($su->user_id) { // join user to group if ($g->join($su->user_id)) { $this->note = "Successfully removed author."; unset($this->params['remote_id']); } else { $this->err = "Couldn't add author."; } } else { $this->err = "Couldn't add author with UserID " . $this->params['remote_id'] . " no such user."; } } catch (PAException $e) { $this->err = "There was an error adding author: " . $e->getMessage(); } break; default: break; } return $this->render(); }
/** *Delete poll from database. *access public */ public function delete_poll($poll_id, $content_id) { Logger::log("Enter: Poll::delete_poll"); //soft deletion $sql = "UPDATE {polls} SET is_active = 0 WHERE poll_id = ?"; $res = Dal::query($sql, $poll_id); Logger::log("Calling: parent::delete()"); parent::delete_by_id($content_id); Logger::log("Exit: Poll::delete()"); }
/** * disapprove content/user in moderated queue * @access public * @param int id of user/content * @param string type ie user/content */ public function disapprove($item_id, $type) { Logger::log("Enter : Group::disapprove() | Args: \$item_id = {$item_id}, \$type = {$type}"); ModerationQueue::remove($item_id, $this->collection_id, $type); Content::delete_by_id($item_id); Logger::log("Exit : Group::disapprove()"); }