public function executeFormComment(sfWebRequest $request)
 {
     $this->form = new CommentForm();
     $this->form->setDefault('record_model', $this->object->getTable()->getComponentName());
     $this->form->setDefault('record_id', $this->object->get('id'));
     if ($request->isMethod('post')) {
         //preparing temporary array with sent values
         $formValues = $request->getParameter($this->form->getName());
         if (vjComment::isCaptchaEnabled() && !vjComment::isUserBoundAndAuthenticated()) {
             $captcha = array('recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'), 'recaptcha_response_field' => $request->getParameter('recaptcha_response_field'));
             //Adding captcha
             $formValues = array_merge($formValues, array('captcha' => $captcha));
         }
         if (vjComment::isUserBoundAndAuthenticated()) {
             //adding user id
             $formValues = array_merge($formValues, array('user_id' => $this->getUser()->getGuardUser()->getId()));
         }
         $this->form->bind($formValues);
         if ($this->form->isValid()) {
             $this->form->save();
             $url = $request->getUri() . "#" . $this->getUser()->getAttribute("nextComment");
             $this->getUser()->offsetUnset("nextComment");
             sfContext::getInstance()->getController()->redirect($url, 0, 302);
         }
     }
 }
Esempio n. 2
0
 /**
  * Check wheter or not the comment form can be accessed
  * @return boolean
  */
 static function checkAccessToForm()
 {
     if (sfConfig::get('app_vjCommentPlugin_restricted')) {
         return vjComment::isUserBoundAndAuthenticated();
     } else {
         return true;
     }
 }
Esempio n. 3
0
 private function isGuardBindAndUserId()
 {
   if(vjComment::isGuardBindEnabled())
   {
     return !is_null($this->getUserId());
   }
   return false;
 }
Esempio n. 4
0
 public function getAdminQuery(Doctrine_Query $q)
 {
     $ra = $q->getRootAlias($q);
     if(vjComment::isGuardBindEnabled())
     {
         $q->leftJoin($ra . '.User u');
     }
     return $q;
 }
Esempio n. 5
0
 public function setup()
 {
     parent::setup();
     unset($this['id'], $this['is_active'], $this['is_delete'], $this['created_at'], $this['updated_at'], $this['edition_reason']);
     $this->widgetSchema['reply_author'] = new sfWidgetFormInputText(array(), array('readonly' => "readonly"));
     $this->widgetSchema->setLabel('reply_author', __('Reply to', array(), 'vjComment'));
     $this->widgetSchema->setHelp('author_email', __('Your email will never be published', array(), 'vjComment'));
     $this->widgetSchema['user_id'] = new sfWidgetFormInputHidden();
     if (vjComment::isUserBoundAndAuthenticated()) {
         unset($this['author_email'], $this['author_website'], $this['author_name']);
     } else {
         unset($this['user_id']);
     }
     if (vjComment::isCaptchaEnabled() && !vjComment::isUserBoundAndAuthenticated()) {
         $this->addCaptcha();
     }
 }
Esempio n. 6
0
  public function setup()
  {
    parent::setup();
    
    $user = $this->getOption('user');
    $fields = array(
      'record_model',
      'record_id',
      'author_name',
      'author_email',
      'author_website',
      'body',
      'reply'
    );
    if(vjComment::isGuardBindEnabled())
    {
      $fields[] = 'user_id';
    }
    $this->useFields($fields);
    
    $this->widgetSchema['reply_author'] = new sfWidgetFormInputText(array(), array('readonly' => "readonly"));
    $this->widgetSchema->setLabel('reply_author', __('Reply to', array(), 'vjComment'));
    $this->widgetSchema->setHelp('author_email', __('Your email will never be published', array(), 'vjComment'));
    $this->widgetSchema['user_id'] = new sfWidgetFormInputHidden();

    if( vjComment::isUserBoundAndAuthenticated($user) )
    {
        unset( $this['author_email'], $this['author_website'], $this['author_name'] );
    }
    else
    {
        unset( $this['user_id'] );
    }
    if (vjComment::isCaptchaEnabled() && !vjComment::isUserBoundAndAuthenticated($user) )
    {
      $this->addCaptcha();
    }
    $this->widgetSchema->setNameFormat($this->getOption('name').'[%s]');
  }
 public function generateCryptModel()
 {
   $model = $this->object->getTable()->getComponentName();
   $id = $this->object->get('id');
   $this->crypt = vjComment::hashTo8($model.$id);
   return $this->crypt;
 }
Esempio n. 8
0
<?php use_helper('I18N', 'JavascriptBase') ?>
<?php use_stylesheet("/vjCommentPlugin/css/form.min.css") ?>
<?php use_stylesheet("/vjCommentPlugin/css/formComment.min.css") ?>
<a name="comments-<?php echo $crypt ?>"></a>
<div class="form-comment">
<?php if( vjComment::checkAccessToForm($sf_user) ): ?>
  <form action="<?php echo url_for($sf_request->getUri()) ?>" method="post">
  <fieldset>
    <legend><?php echo __('Add new comment', array(), 'vjComment') ?></legend>
    <?php include_partial("comment/form", array('form' => $form)) ?>
  </fieldset>
  </form>
<?php else: ?>
  <div id="notlogged"><?php echo __('Please log in to comment', array(), 'vjComment') ?></div>
<?php endif ?>
</div>