header("Location: /" . $_SESSION["user_name"]); break; } break; // post // post case "comment": require_once "lib/api/comments.php"; require_once "lib/api/likes.php"; switch ($url_parts[3]) { case "add": $result = comment_add(); header("Location: " . $_SERVER["HTTP_REFERER"] . "#comments"); break; case "delete": $result = comment_delete($url_parts[4]); header("Location: " . $_SERVER["HTTP_REFERER"] . "#comments"); break; case "like": $result = comment_like($url_parts[4], $url_parts[5]); header('Content-Type: application/json'); print json_encode($result); break; case "unlike": $result = comment_unlike($url_parts[4], $url_parts[5]); header('Content-Type: application/json'); print json_encode($result); break; } break; // comment
/** * Used to load the requested page from POST or GET * @global type $input */ function load_page() { global $input; $action = $input['action']; $redraw = false; // // Actions // // Controller goes here switch ($action) { // The user clicked on an album, we display its content to them // Display the help page case 'view_help': view_help(); break; case 'view_settings': view_settings(); break; // In case we want to log out // In case we want to log out case 'logout': user_logout(); break; // The only case when we could possibly arrive here with a session created // and a "login" action is when the user refreshed the page. In that case, // we redraw the page with the last information saved in the session variables. // The only case when we could possibly arrive here with a session created // and a "login" action is when the user refreshed the page. In that case, // we redraw the page with the last information saved in the session variables. case 'login': redraw_page(); break; case 'anonymous_login': anonymous_login(); break; case 'admin_mode_update': admin_mode_update(); break; case 'view_album_assets': view_album_assets(); break; case 'view_asset_details': view_asset_details(); break; case 'view_asset_bookmark': view_asset_bookmark(); break; case 'search_bookmark': bookmarks_search(); break; case 'sort_asset_bookmark': bookmarks_sort(); break; case 'add_asset_bookmark': bookmark_add(); break; case 'add_asset_thread': thread_add(); break; case 'add_thread_comment': comment_add(); break; case 'add_thread_comment_answer': comment_add_reply(); break; case 'update_thread_comment': comment_edit(); break; case 'update_asset_thread': thread_edit(); break; case 'thread_details_view': thread_details_update(); break; case 'delete_asset_thread': thread_delete(); break; case 'delete_thread_comment': comment_delete(); break; case 'edit_settings': preferences_update(); break; case 'edit_asset_meta': asset_edit_meta(); break; case 'vote': vote_add(); break; case 'approve': comment_edit_approval(); break; case 'threads_list_view': threads_list_update(); break; case 'copy_bookmark': bookmark_copy(); break; case 'share_popup': share_popup(); break; case 'bookmark_popup': bookmark_popup(); break; case 'bookmarks_popup': bookmarks_popup(); break; case 'remove_asset_bookmark': bookmark_delete(); break; case 'remove_asset_bookmarks': bookmarks_delete_all(); break; case 'view_import': view_import(); break; case 'upload_bookmarks': bookmarks_upload(); break; case 'import_bookmarks': bookmarks_import(); break; case 'export_bookmarks': bookmarks_export(); break; case 'export_album_bookmarks': bookmarks_export_all(); break; case 'export_asset_bookmarks': bookmarks_export_all(true); break; case 'delete_bookmarks': bookmarks_delete(); break; case 'move_album_token': album_token_move(); break; case 'delete_album_token': album_token_delete(); break; case 'client_trace': client_trace(); break; // No action selected: we choose to display the homepage again // No action selected: we choose to display the homepage again default: // TODO: check session var here view_main(); } }
/** * Delete the comment programmatically. * * @return bool * Returns TRUE. */ public function deleteProgrammatically() { comment_delete($this->getId()); return TRUE; }
/** * Delete entities. This is a copy of entity_delete_multiple() function in * entity.module since entity module may not be present. * * @param string $entity_type * Entity type. * @param int $min_entity_id * Minimum entity id over which all entities will be deleted. * * @return bool * TRUE if entities got deleted and FALSE otherwise. */ public static function deleteEntities($entity_type, $min_entity_id) { $query = new \EntityFieldQuery(); $results = $query->entityCondition('entity_type', $entity_type)->entityCondition('entity_id', $min_entity_id, '>')->execute(); if (isset($results[$entity_type])) { $entity_ids = array_keys($results[$entity_type]); $info = entity_get_info($entity_type); if (isset($info['deletion callback'])) { foreach ($entity_ids as $id) { $info['deletion callback']($id); } } elseif (in_array('EntityAPIControllerInterface', class_implements($info['controller class']))) { entity_get_controller($entity_type)->delete($entity_ids); } else { if ($entity_type == 'node') { node_delete_multiple($entity_ids); } elseif ($entity_type == 'user') { user_delete_multiple($entity_ids); } elseif ($entity_type == 'taxonomy_term') { foreach ($entity_ids as $entity_id) { taxonomy_term_delete($entity_id); } } elseif ($entity_type == 'comment') { foreach ($entity_ids as $entity_id) { comment_delete($entity_id); } } return FALSE; } } }
die; } $err_code = ""; if (!comment_create($blog_serial, $_POST['comment_author'], $_POST['comment_content'], $_POST['comment_vcode'])) { $err_code = '&e=comment_failed'; } header('Location:index.php?b=' . $blog_serial . '&c=' . $category_name . $err_code); exit; break; case '11': // delete comment if (!referer_check()) { die; } if (admin_check()) { comment_delete($comment_serial); header('Location:index.php?b=' . $blog_serial . '&c=' . $category_name); exit; } else { header('Location:index.php?ac=1&f=' . urlencode('index.php?b=' . $blog_serial . '&c=' . $category_name)); exit; } break; case '12': // settings form if (admin_check()) { if (isset($_GET['e'])) { $has_error = true; } else { $has_error = false; }
post_view($to); break; case 'edit': post_edit($to); break; case 'delete': post_delete($to); break; case 'reply': comment_add($to, TRUE); break; case 'comment': comment_edit($to); break; case 'clear': comment_delete($to); break; case 'post': post_add($at); break; case 'board': board_view($at); break; case 'join': member_join(); break; case 'modify': member_modify(); break; case 'member': member_view($to);
<?php // Custom PHP script to delete comments made by a user id // Usage: drush php-script --script-path=locationofthisfile delete-comments $uid = 100; // The user id (uid). Set this to the uid of the user whose comments you want to delete. $result = db_select('comment', 'c')->fields('c', array('cid'))->condition('uid', $uid)->execute(); $counter = 0; foreach ($result as $record) { comment_delete($record['cid']); $counter++; } print "Deleted " . $counter . " comments.";
public function post($route, $form) { global $user; if ($route == 'comments.json') { $options = $this->getOptions(); $node = node_load($options['nid']); if ($options['uid'] != $user->uid || !is_object($node)) { return false; } // Should we let the comment pass ? if ($node->comment != COMMENT_NODE_OPEN || !user_access('post comments')) { // Access denied. return false; } if (!empty($form->values['cid'])) { $comment = comment_load($form->values['cid']); if (!is_object($comment)) { // Not existent CID.. Access denied return false; } $nodeSubmittedComment = node_load($comment->nid); if (!is_object($nodeSubmittedComment) || $nodeSubmittedComment->nid != $node->nid) { return FALSE; // BAD nid.. Or node non existent } // Publish if ($form->values['toPublish']) { if (user_access('administer comments') && user_access('post comments')) { $comment->status = COMMENT_PUBLISHED; comment_save($comment); } return; } // Deletion if ($form->values['toDelete']) { if (user_access('administer comments') && user_access('post comments')) { comment_delete($comment->cid); } return; } if (!comment_access('edit', $comment)) { return FALSE; // No access to edit the comment. } } if (empty($comment)) { $pid = NULL; if (!empty($form->values['pid'])) { if ($form->values['pid'] == (int) $form->values['pid']) { if ($comment_parent = comment_load((int) $form->values['pid'])) { $pid = $form->values['pid']; } } } $comment = new stdClass(); $comment->nid = $node->nid; $comment->pid = $pid; $comment->uid = $user->uid; $comment->name = check_plain($form->values['author']); } $comment->subject = check_plain($form->values['subject']); $field = field_info_field('comment_body'); $langcode = field_is_translatable('comment', $field) ? entity_language('comment', $comment) : LANGUAGE_NONE; $field_infos = field_info_instance('comment', 'comment_body', 'comment_node_' . $node->type); $format = $options['comment-body-format']; $text_processing = $field_infos['settings']['text_processing']; $body = $form->values['body']; $body = $format != 'plain_text' && $text_processing ? check_markup($body, $format) : check_plain($body); if ($text_processing) { $comment->comment_body[$langcode][0]['format'] = $format; } $comment->comment_body = array($langcode => array()); $comment->comment_body[$langcode][0]['value'] = $body; comment_submit($comment); comment_save($comment); cache_clear_all(); } }
function dodelete($commentid) { $this->smarty->assign('success', comment_delete($_GET['entry'], $commentid) ? 1 : -1); return PANEL_REDIRECT_CURRENT; }