/** * Test fetch method */ function testFetch() { $subscriber = ezcomSubscriber::fetch(1); $this->assertType('ezcomSubscriber', $subscriber); $subscriber = ezcomSubscriber::fetch(100); $this->assertEquals(null, $subscriber); }
/** * Activate subscription * If there is error,set 'error_message' to the template, * If activation succeeds, set 'subscriber' to the template * @param string: $hashString * @return void */ public function activateSubscription($hashString) { // 1. fetch the subscription object $subscription = ezcomSubscription::fetchByHashString($hashString); if (is_null($subscription)) { $this->tpl->setVariable('error_message', ezpI18n::tr('ezcomments/comment/activate', 'There is no subscription with the hash string!')); } else { if ($subscription->attribute('enabled')) { ezDebugSetting::writeNotice('extension-ezcomments', 'Subscription activated', __METHOD__); } $subscriber = ezcomSubscriber::fetch($subscription->attribute('subscriber_id')); if ($subscriber->attribute('enabled')) { $subscription->enable(); $this->tpl->setVariable('subscriber', $subscriber); } else { $this->tpl->setVariable('error_message', ezpI18n::tr('ezcomments/comment/activate', 'The subscriber is disabled!')); } } }
$contentLanguage = $contentObjectArray['language_id']; $notifications = $db->arrayQuery('SELECT * FROM ezcomment_notification ' . 'WHERE contentobject_id = ' . $contentObjectID); // fetch content object $contentObject = eZContentObject::fetch($contentObjectID, true); $contentLanguageLocale = eZContentLanguage::fetch($contentLanguage)->attribute('locale'); $contentObject->setCurrentLanguage($contentLanguageLocale); 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();