/** * 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!')); } } }
/** * check if the user has Acceess to the object with limitation of class, section, owner, language, nodes, subtrees * * return true if has, false if not */ public function hasFunctionAccess($user, $functionName, $contentObject, $languageCode, $comment = null, $scope = null, $node = null) { $result = $user->hasAccessTo(self::$moduleName, $functionName); if ($result['accessWord'] !== 'limited') { $return = $result['accessWord'] === 'yes' and $scope !== 'personal'; } else { foreach ($result['policies'] as $limitationArray) { // eZDebug::writeDebug( $limitationArray, "limitationArray for function $functionName" ); $return = true; foreach ($limitationArray as $limitationKey => $limitation) { // deal with limitation checking $resultItem = $this->checkPermission($user, $limitationKey, $limitation, $contentObject, $languageCode, $comment, $scope, $node); ezDebugSetting::writeNotice('extension-ezcomments', "Permission check result for function '{$functionName}' with limitation '{$limitationKey}': " . ($resultItem === true ? 'true' : 'false'), __METHOD__); $return = ($return and $resultItem); } if ($return === true) { break; } } } return $return; }