17 public $moderatorEmail;
22 public $notifyModeratorOnNew =
true;
27 public $allowAnonymous =
true;
32 public $requiredForAnonymous = null;
36 public $dontNeedApprove =
false;
51 'contentId' => $this->contentId,
52 'moderatorEmail' => $this->moderatorEmail,
53 'notifyModeratorOnNew' => $this->notifyModeratorOnNew,
54 'allowAnonymous' => $this->allowAnonymous,
55 'requiredForAnonymous' => $this->requiredForAnonymous,
56 'dontNeedApprove' => $this->dontNeedApprove
58 $this->hash = md5(serialize($options) . Yii::app()->getModule(
'comments')->hashSalt);
59 if (Yii::app()->cache->get($this->hash) != $options) {
60 Yii::app()->cache->set($this->hash, $options);
72 if (!$this->allowAnonymous && Yii::app()->user->isGuest) {
73 $this->render(
'CommentsFormWidget_Login');
75 $model =
new Comment(Yii::app()->user->isGuest ?
'createAnonymous' :
'create');
76 if(isset($this->requiredForAnonymous)){
77 $model->setRequiredForAnonymous($this->requiredForAnonymous);
79 if (!Yii::app()->user->isGuest) {
80 $model->email = Yii::app()->user->email;
82 $model->firstname = $profile->firstname;
83 $model->lastname = $profile->lastname;
85 if (($modelData = Yii::app()->user->getState(
'Comment' . $this->contentId)) !== null) {
86 $model->attributes = $modelData[
'attributes'];
87 foreach ($modelData[
'errors'] as $attribute => $errors) {
88 foreach ($errors as $e) {
89 $model->addError($attribute, $e);
92 Yii::app()->user->setState(
'Comment' . $this->contentId, null);
94 $this->render(
'CommentsFormWidget', array(
'model' => $model));