Example #1
0
File: add.php Project: legende91/ez
    if ($http->hasVariable('BackButton')) {
        return $module->redirectTo($redirectURI);
    }
}
if ($module->isCurrentAction('AddComment')) {
    $contentCheck = ezcomPostHelper::checkContentRequirements($module, $http);
    extract($contentCheck);
    // Check to see if commenting is turned on, on the object level
    $commentContent = ezcomPostHelper::checkCommentPermission($contentObject, $languageCode, $foundCommentAttribute);
    if (!$commentContent['show_comments'] || !$commentContent['enable_comment']) {
        $tpl->setVariable('error_message', ezpI18n::tr('ezcomments/comment/add', 'Commenting has been turned off for this content.'));
        $Result['content'] = $tpl->fetch('design:comment/add.tpl');
        return $Result;
    } else {
        // Validate given input date against form setup
        $formTool = ezcomAddCommentTool::instance();
        $formStatus = $formTool->checkVars();
        if (!$formStatus) {
            // missing form data
            $tpl->setVariable('error_message', ezpI18n::tr('ezcomments/comment/add/form', 'There is a problem with your comment form '));
            $tpl->setVariable('validation_messages', $formTool->messages());
            $Result['content'] = $tpl->fetch('design:comment/add.tpl');
            return $Result;
        }
        //TODO: from 63, most of the code can be implemented in a class see another TODO in edit.php
        // Build ezcomcomment object
        $comment = ezcomComment::create();
        $formTool->fillObject($comment);
        $comment->setAttribute('contentobject_id', $contentObjectId);
        $languageId = eZContentLanguage::idByLocale($languageCode);
        $comment->setAttribute('language_id', $languageId);
 public static function instance()
 {
     if (is_null(self::$instance)) {
         $ini = eZINI::instance('ezcomments.ini');
         $className = $ini->variable('ManagerClasses', 'AddCommentToolClass');
         self::$instance = new $className();
     }
     return self::$instance;
 }