function akismet_ContentActionHandler($module, $http, $objectID)
{
    $object = eZContentObject::fetch($objectID);
    $version = $object->attribute('current');
    if ($http->hasPostVariable('AkismetSubmitSpam')) {
        $user = eZUser::currentUser();
        $accessResult = $user->hasAccessTo('akismet', 'submit');
        if ($accessResult['accessWord'] === 'yes') {
            $mainNode = $object->attribute('main_node');
            $module->redirectTo($mainNode->attribute('url_alias'));
            $akismetObject = new eZContentObjectAkismet();
            $comment = $akismetObject->akismetInformationExtractor($version);
            if ($comment) {
                $akismet = new eZAkismet($comment);
                if ($akismet) {
                    $feedback = $akismet->submitSpam();
                    $response[] = $feedback[1];
                } else {
                    $response[] = ezi18n('extension/contactivity/akismet/submit', "An error has occured, unable to submit spam to Akismet.");
                }
            } else {
                $response[] = ezi18n('extension/contactivity/akismet/submit', "An error has occured, unable to submit spam to Akismet.");
            }
        }
        $mainNode = $object->attribute('main_node');
        $module->redirectTo($mainNode->attribute('url_alias'));
        return true;
    }
}
 function execute($process, $event)
 {
     $parameters = $process->attribute('parameter_list');
     $object = eZContentObject::fetch($parameters['object_id']);
     $versionID = $parameters['version'];
     if (!$object) {
         return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
     }
     $version = $object->version($versionID);
     if (!$version) {
         return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
     }
     $akismetObject = new eZContentObjectAkismet();
     $comment = $akismetObject->akismetInformationExtractor($version);
     if ($comment) {
         $akismet = new eZAkismet($comment);
         if ($akismet) {
             $isSpam = $akismet->isCommentSpam();
             eZDebug::writeDebug($comment);
             eZDebug::writeDebug("this is spam: " . $isSpam);
         } else {
             return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
         }
         if (!$isSpam) {
             $response = $akismet->submitHam();
             return eZWorkflowType::STATUS_ACCEPTED;
         }
         return eZWorkflowType::STATUS_REJECTED;
     }
 }
 function getExtractableNodesCount()
 {
     $classList = eZContentObjectAkismet::getExtractableClassList();
     $params = array('ClassFilterType' => 'include', 'ClassFilterArray' => $classList);
     $node = eZContentObjectTreeNode::fetchNode(1, 1);
     $nodeCount = $node->subTreeCount($params, 1);
     return $nodeCount;
 }
Пример #4
0
            foreach (array_keys($assignedNodes) as $assignedNodeKey) {
                if ($assignedNodes[$assignedNodeKey]->attribute('can_remove')) {
                    $nodeIdArray[] = $assignedNodes[$assignedNodeKey]->attribute('node_id');
                } else {
                    $nodeIdArray = false;
                    break;
                }
            }
            if ($nodeIdArray) {
                eZContentObjectTreeNode::removeSubtrees($nodeIdArray, false);
            } else {
                $object->remove();
                $object->purge();
            }
        }
    }
}
$akismet = new eZContentObjectAkismet();
$extractableNodes = $akismet->getExtractableNodes($limit, $Offset);
$extractableNodesCount = $akismet->getExtractableNodesCount();
include_once 'kernel/common/template.php';
$tpl = templateInit();
$tpl->setVariable('object_id_list', $objectIDList);
$tpl->setVariable('view_parameters', $viewParameters);
$tpl->setVariable('nodes', $extractableNodes);
$tpl->setVariable('nodes_count', $extractableNodesCount);
$tpl->setVariable('limit', $limit);
$tpl->setVariable('feedback', $response);
$Result = array();
$Result['content'] = $tpl->fetch('design:akismet/submit.tpl');
$Result['path'] = array(array('url' => false, 'text' => 'Akismet'), array('url' => false, 'text' => 'Report spam'));