/** * 1. Fetch ezcomComment object * 2. Check is object is instance of ezcomComment class * 3. Fetch ezcomComment object which does not exist * 4. Check if result equals to null * */ public function testFetchObject() { $comment = ezcomComment::fetch(1); $this->assertInstanceOf('ezcomComment', $comment); $comment = ezcomComment::fetch(2); $this->assertEquals(null, $comment); }
* File containing logic of removecomments view * * @copyright Copyright (C) 1999-2012 eZ Systems AS. All rights reserved. * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2 * */ $Module = $Params['Module']; $http = eZHTTPTool::instance(); if ($http->hasPostVariable('ConfirmButton')) { $deleteIDArray = $http->hasSessionVariable('DeleteCommentsIDArray') ? $http->sessionVariable('DeleteCommentsIDArray') : array(); if (is_array($deleteIDArray) && !empty($deleteIDArray)) { $db = eZDB::instance(); $db->begin(); $commentManager = ezcomCommentManager::instance(); foreach ($deleteIDArray as $deleteID) { $commentToRemove = ezcomComment::fetch($deleteID); $deleteResult = $commentManager->deleteComment($commentToRemove); if ($deleteResult === true) { eZContentCacheManager::clearContentCacheIfNeeded($commentToRemove->attribute('contentobject_id')); } } $db->commit(); } $Module->redirectTo('/comment/list/'); } if ($http->hasPostVariable('CancelButton')) { $Module->redirectTo('/comment/list/'); } $contentInfoArray = array(); $tpl = eZTemplate::factory(); $tpl->setVariable('persistent_variable', false);
$tpl = eZTemplate::factory(); $user = eZUser::currentUser(); $http = eZHttpTool::instance(); // get the action parameter $Module = $Params['Module']; $commentID = $Params['CommentID']; // fetch comment object if (is_null($commentID) || $commentID == '') { eZDebug::writeError('The parameter comment id is null.', 'ezcomments'); return; } if (!is_numeric($commentID)) { eZDebug::writeError('The parameter comment id is not a number.', 'ezcomments'); return; } $comment = ezcomComment::fetch($commentID); if (is_null($comment)) { eZDebug::writeError('The comment doesn\'t exist.', 'ezcomments'); return; } //check the permission $contentObject = $comment->contentObject(); $contentNode = $contentObject->mainNode(); $languageID = $comment->attribute('language_id'); $languageCode = eZContentLanguage::fetch($languageID)->attribute('locale'); $canEdit = false; $canEditResult = ezcomPermission::hasAccessToFunction('edit', $contentObject, $languageCode, $comment, null, $contentNode); $canEdit = $canEditResult['result']; $tpl->setVariable('can_edit', $canEdit); if (!$canEdit) { $Result['path'] = array(array('url' => false, 'text' => ezpI18n::tr('ezcomments/comment/edit', 'Edit comment')));
if (is_null($contentObject)) { $cli->output("Content doesn't exist, delete the notification. Content ID:" . $contentObjectID); $db->query('DELETE FROM ezcomment_notification WHERE contentobject_id=' . $contentObjectID); continue; } // fetch subscribers $subscriptionList = $db->arrayQuery("SELECT subscriber_id FROM ezcomment_subscription" . " WHERE enabled = 1" . " AND content_id = {$contentObjectID}" . " AND language_id = {$contentLanguage}"); $subscriberList = array(); foreach ($subscriptionList as $subscription) { $subscriberList[] = ezcomSubscriber::fetch($subscription['subscriber_id']); } //fetch comment list $commentList = array(); foreach ($notifications as $notification) { // fetch comment object $comment = ezcomComment::fetch($notification['comment_id']); if (is_null($comment)) { $cli->output("Comment doesn't exist, delete the notification. Comment ID:" . $notification['comment_id']); $db->query('DELETE FROM ezcomment_notification WHERE id=' . $notification['id']); continue; } $commentList[] = $comment; } try { $notificationManager = ezcomNotificationManager::instance(); $commentsInOne = $ezcommentsINI->variable('NotificationSettings', 'CommentsInOne'); foreach ($subscriberList as $subscriber) { if ($commentsInOne !== 'true') { foreach ($commentList as $comment) { if ($comment->attribute('email') != $subscriber->attribute('email')) { $notificationManager->sendNotificationInMany($subscriber, $contentObject, $comment);