Exemplo n.º 1
0
 /**
  * Test fetch method
  */
 public function testFetch()
 {
     $subscription = ezcomSubscription::fetch(1);
     $this->assertType('ezcomSubscription', $subscription);
     $subscription = ezcomSubscription::fetch(1001);
     $this->assertEquals(null, $subscription);
 }
 public function testActivateSubscription()
 {
     $subscriber = ezcomSubscriber::create();
     $subscriber->setAttribute('email', '*****@*****.**');
     $subscriber->setAttribute('user_id', 10);
     $subscriber->store();
     $subscription = ezcomSubscription::create();
     $subscription->setAttribute('subscriber_id', $subscriber->attribute('id'));
     $subscription->setAttribute('subscriber_type', 'ezcomcomment');
     $subscription->setAttribute('enabled', 0);
     $subscription->setAttribute('content_id', '10_2');
     $hashString = ezcomUtility::instance()->generateSubscriptionHashString($subscription);
     $subscription->setAttribute('hash_string', $hashString);
     $subscription->store();
     $id = $subscription->attribute('id');
     $tpl = eZTemplate::factory();
     $subscriptionManager = ezcomSubscriptionManager::instance($tpl, null, null, 'ezcomSubscriptionManager');
     $subscriptionManager->activateSubscription($hashString);
     $subscriptionActivated = ezcomSubscription::fetch($id);
     $this->assertEquals(1, $subscriptionActivated->attribute('enabled'));
 }
Exemplo n.º 3
0
    return $Result;
}
$tpl->setVariable('subscriber', $subscriber);
$email = $subscriber->attribute('email');
$module = $Params['Module'];
if ($module->isCurrentAction('Save')) {
    $subscriberID = $http->postVariable('SubscriberID');
    if ($http->hasPostVariable('CheckboxName')) {
        $checkboxNameList = $http->postVariable('CheckboxName');
        foreach ($checkboxNameList as $checkboxName) {
            $subscriptionID = substr($checkboxName, strlen('Checkbox'));
            $subscribed = false;
            if ($http->hasPostVariable($checkboxName)) {
                $subscribed = true;
            }
            $subscription = ezcomSubscription::fetch($subscriptionID);
            if (!$subscribed) {
                $subscription->remove();
            }
        }
        $tpl->setVariable('update_success', 1);
        $redirectURI = 'comment/setting';
        if (!is_null($hashString)) {
            $redirectURI = $redirectURI . '/' . $hashString;
        }
        $module->redirectTo($redirectURI);
        return;
    }
}
//1.fetch Contents
$ini = eZINI::instance('ezcomments.ini');