Example #1
0
 /**
  * Все комментарии сгруппировать по материалам и отослать
  * @param CommentUser $u
  * @param Comment[] $cs
  */
 public function sendForUser($u, &$cs)
 {
     $items = $this->getRelatedItems($cs);
     $groups = array();
     foreach ($cs as $c) {
         if (!($item = $c->getCommentableItem())) {
             continue;
         }
         $groups[$item->id][] = $c->id;
     }
     $from = $this->behavior->notifyMailFrom ?: $this->cm->notifyMailFrom;
     $subject = $this->behavior->notifyMailSubject;
     $to = $u->getUEmail();
     $body = Yii::app()->controller->widget('ycomments.widgets.CommentsWidget', array('commentableType' => $this->commentableType, 'view' => 'notify', 'options' => array('user' => $u, 'items' => $items, 'comments' => $cs, 'groups' => $groups)), true);
     $this->log($body);
     $emailParams = compact('from', 'to', 'subject', 'body');
     if (is_callable($this->cm->emailSenderCallable)) {
         $sent = $this->cm->emailSenderCallable($emailParams);
     } else {
         $sent = $this->sendEmail($emailParams);
     }
     // 		$testMode = Yii::app()->params['notifyTestMode'];
     // 		$testEmails = Yii::app()->params['notifyTestEmails'];
     $msg = $sent ? 'mail sent' : 'mail not sent';
     $this->log($msg . " : " . json_encode(array('to' => $to, 'subject' => $subject)));
     return true;
 }
Example #2
0
 /**
  * подписка/отписка на материал
  */
 public function actionItemSubscribe()
 {
     $postNS = @$_POST['NotifySubscription'];
     $active = @$postNS['active'];
     $ns = NotifySubscription::findOrCreate(@$postNS['commentable_type'], @$postNS['item_id'], Yii::app()->user->id);
     if (!$ns->validate()) {
         print_r($ns->getErrors());
         return;
     }
     if ($active) {
         $ns->save();
         Yii::app()->user->setFlash('user-notify', YCommentsModule::t('Subscription performed'));
     } else {
         if (!$ns->isNewRecord) {
             $ns->delete();
             Yii::app()->user->setFlash('user-notify', YCommentsModule::t('Subscription canceled'));
         }
     }
     $this->widget('ycomments.widgets.NotifyItemSubscriptionWidget', array('commentableType' => $ns->commentable_type, 'itemId' => $ns->item_id));
 }
Example #3
0
<?php

/* @var $this CommentsWidget */
/* @var $model CActiveRecord - commentable model */
$model = $this->model;
$this->registerAssets();
$widgetId = $this->id;
/** @var CArrayDataProvider $comments */
$comments = $model->getComments();
?>

<div class="comment-list-wrap">
	<a name="commentblock"></a>
	<h3 class="comment-list-head"><?php 
echo YCommentsModule::t('Comments');
?>
</h3>

<?php 
echo CHtml::openTag('div', array('id' => $widgetId, 'class' => 'comment-list ' . @$this->htmlOptions['class'], 'data-comments-sets' => json_encode($this->getJSCommentsSets())));
if (!$this->readOnly && Yii::app()->user->checkAccess('commentator')) {
    $this->renderTyped('_form');
    /* 	
    	if ($this->getCommentableBehavior()->notifyEnabled &&
    		$this->getCommentableBehavior()->notifySubscriptionEnabled) 
    	{
    		$this->widget('comment.widgets.NotifyItemSubscriptionWidget',
    				array('commentableType' => $this->commentableType, 'itemId' => $this->model->id));
    	}
    */
}
Example #4
0
 public function attributeLabels()
 {
     return array('id' => 'ID', 'commentable_type' => YCommentsModule::t('Commentable Type'), 'last_check_at' => YCommentsModule::t('Last Check At'));
 }
Example #5
0
 public function attributeLabels()
 {
     return array('comment_id' => YCommentsModule::t('Comment'), 'user_id' => YCommentsModule::t('User'));
 }
Example #6
0
// 	echo $form->checkBoxRow($this->notifyUser, 'notify_reply', array(
//         'id' => 'nr-'.$wid,
//         'onclick' => $ajax
//     ));
?>
	<br><br>
	
	<?php 
NotifySubscription::$commentableType = $this->commentableType;
// respect dynamic relation
$itemCount = $this->subProvider->getTotalItemCount();
?>
	<?php 
if ($itemCount) {
    ?>
		<h3><?php 
    echo YCommentsModule::t('Item subscriptions');
    ?>
</h3>
		<?php 
    $this->widget('zii.widgets.CListView', array('id' => 'subs-items-' . $this->commentableType, 'dataProvider' => $this->subProvider, 'itemView' => '_notifySubItem', 'emptyText' => YCommentsModule::t('no subscriptions'), 'template' => "<table> {items}\n </table> {pager}\n{summary}"));
    ?>
	<?php 
}
?>
 
</div>

<?php 
$this->endWidget();
echo CHtml::closeTag('div');
Example #7
0
 /**
  * @return array customized attribute labels (name=>label)
  */
 public function attributeLabels()
 {
     return array('id' => 'ID', 'message' => YCommentsModule::t('Comment'), 'user_id' => YCommentsModule::t('User ID'), 'userName' => YCommentsModule::t('Name'), 'userEmail' => YCommentsModule::t('E-Mail'), 'created_at' => YCommentsModule::t('Created'), 'updated_at' => YCommentsModule::t('Updated'));
 }
Example #8
0
<?php

/* @var $this CommentsWidget */
/* @var $user CommentUser */
/* @var $items CActiveRecord[] */
/* @var $comments Comment[] */
/* @var $groups [] */
extract($this->options);
foreach ($groups as $iid => $cids) {
    $item = $items[$iid];
    echo "<p>\n";
    echo CHtml::link($item->name, $item->getAbsoluteUrl()), "\n";
    echo "</p>\n";
    foreach ($cids as $cid) {
        /* @var $c Comment */
        echo "<p>\n";
        $c = $comments[$cid];
        echo CHtml::tag('span', array('style' => 'color:gray'), sprintf("%s, %s:  ", Yii::app()->dateFormatter->format('HH:mm dd MMM', $c->created_at), $c->getUserName()));
        echo $c->message;
        echo "</p>", "\n\n";
    }
    echo "\n\n";
}
?>

<p>
<?php 
echo YCommentsModule::t('Subscription canceling can be done at your profile page');
?>
</p>
Example #9
0
        }
        ?>

		<?php 
    } else {
        ?>
			<?php 
        echo CHtml::link(YCommentsModule::t('Save'), '#', array('class' => 'comment__button comment__button-post comment-cmd', 'data-comment' => json_encode(array('cmd' => 'post', 'cid' => $comment->id), JSON_NUMERIC_CHECK)));
        echo CHtml::link(YCommentsModule::t('Close'), '#', array('class' => 'comment__button comment__button-close comment-cmd', 'data-comment' => json_encode(array('cmd' => 'close', 'cid' => $comment->id, 'parent' => $comment->parent_id), JSON_NUMERIC_CHECK)));
        ?>

		<?php 
    }
    ?>
		<span class="comment__form__stat" title="<?php 
    echo YCommentsModule::t('Symbols left');
    ?>
"></span>

		<?php 
    if ($this->getCommentableBehavior()->notifyEnabled && $this->getCommentableBehavior()->notifySubscriptionEnabled) {
        $this->widget('comment.widgets.NotifyItemSubscriptionWidget', array('commentableType' => $this->commentableType, 'itemId' => $this->model->id ?: $comment->key));
    }
    ?>
		
	</div>

<?php 
    $this->endWidget();
    // form
    ?>
Example #10
0
<?php

/* @var $this CommentsWidget */
/* @var $model CActiveRecord - commentable model */
$model = $this->model;
$this->registerAssets();
$widgetId = $this->id;
/** @var CArrayDataProvider $comments */
$comments = $model->getComments();
?>

<div class="comment-list-wrap">
	<a id="commentblock"></a>
	<h3 class="comment-list-head"><?php 
echo YCommentsModule::t('Reviews');
?>
</h3>

<?php 
echo CHtml::openTag('div', array('id' => $widgetId, 'class' => 'comment-list ' . @$this->htmlOptions['class'], 'data-comments-sets' => json_encode($this->getJSCommentsSets())));
if (!$this->readOnly && Yii::app()->user->checkAccess('commentator')) {
    $this->renderTyped('_form');
}
$widget = $this;
/**
 * recursive comments print
 */
$printComments = function ($cs, $level = 1) use(&$printComments, $widget) {
    foreach ($cs as $c) {
        $widget->renderTyped('_view', array('data' => $c, 'level' => $level, 'printComments' => $printComments));
    }
Example #11
0
 public function attributeLabels()
 {
     return array('id' => 'ID', 'user_id' => YCommentsModule::t('User'), 'commentable_type' => YCommentsModule::t('Commentable Type'), 'item_id' => YCommentsModule::t('Item'), 'active' => $this->active ? YCommentsModule::t('You are subscribed') : YCommentsModule::t('Subscribe'));
 }
Example #12
0
	    <?php 
    if ($comment->isNewRecord) {
        ?>
	    	<?php 
        echo CHtml::link(YCommentsModule::t('Add review'), '#', array('class' => 'btn btn-small comment__button-post comment-cmd', 'title' => 'Ctrl+Enter', 'data-comment' => json_encode(array('cmd' => 'post', 'cid' => 0, 'parent_id' => $comment->parent_id), JSON_NUMERIC_CHECK)));
        if ($comment->parent_id) {
            echo CHtml::link(YCommentsModule::t('Close'), '#', array('class' => 'btn btn-small comment__button-close comment-cmd', 'data-comment' => json_encode(array('cmd' => 'close', 'cid' => 0, 'parent' => $comment->parent_id), JSON_NUMERIC_CHECK)));
        }
        ?>

		<?php 
    } else {
        ?>
			<?php 
        echo CHtml::link(YCommentsModule::t('Save review'), '#', array('class' => 'btn btn-small comment__button-post comment-cmd', 'data-comment' => json_encode(array('cmd' => 'post', 'cid' => $comment->id), JSON_NUMERIC_CHECK)));
        echo CHtml::link(YCommentsModule::t('Close'), '#', array('class' => 'btn btn-small comment__button-close comment-cmd', 'data-comment' => json_encode(array('cmd' => 'close', 'cid' => $comment->id, 'parent' => $comment->parent_id), JSON_NUMERIC_CHECK)));
        ?>

		<?php 
    }
    ?>
		</div>
		<span class="comment__form__stat" title="Осталось символов"></span>

		<?php 
    if ($this->getCommentableBehavior()->notifyEnabled && $this->getCommentableBehavior()->notifySubscriptionEnabled) {
        $this->widget('comment.widgets.NotifyItemSubscriptionWidget', array('commentableType' => $this->commentableType, 'itemId' => $this->model->id ?: $comment->key));
    }
    ?>
		
	</div>
Example #13
0
		<?php 
}
?>
	</ul>
	<?php 
foreach ($types as $type => $meta) {
    ?>
		<div id="<?php 
    echo $type;
    ?>
">
		<?php 
    if ($type == $typeSelected) {
        ?>
		<?php 
        $columns = array('id', 'message', array('name' => 'created_at', 'htmlOptions' => array('style' => 'white-space:nowrap;')), array('header' => YCommentsModule::t('Author'), 'name' => 'user_id', 'value' => '$data->user ? $data->user->uname ." [". $data->user_id ."]" : "[". $data->user_id ."]"'));
        if ($behavior->getCommentInstance() instanceof Review) {
            $columns[] = array('name' => 'rating');
        }
        if ($behavior->commentableUrl) {
            $columns[0] = array('name' => 'id', 'value' => 'CHtml::link($data->id, $data->getUrlData())', 'type' => 'html');
        }
        $this->widget('zii.widgets.grid.CGridView', array('dataProvider' => $provider, 'columns' => $columns));
        ?>
		<?php 
    }
    ?>
		</div>
	<?php 
}
?>
Example #14
0
 /**
  * @return array customized attribute labels (name=>label)
  */
 public function attributeLabels()
 {
     return array_merge(parent::attributeLabels(), array('rating' => YCommentsModule::t('Rating'), 'message' => YCommentsModule::t('Review')));
 }
Example #15
0
 public function attributeLabels()
 {
     return array('id' => 'ID', 'commentable_type' => YCommentsModule::t('Commentable Type'), 'user_id' => YCommentsModule::t('User'), 'notify_all' => YCommentsModule::t('All messages subscription'), 'notify_reply' => YCommentsModule::t('Replies to my messages'));
 }
Example #16
0
}
?>
		
			<?php 
if ($behavior->allowReply && $comment->checkAccess('commentator')) {
    ?>
			
				<?php 
    $levelAllowed = $behavior->maxReplyLevel && $level > $behavior->maxReplyLevel ? false : true;
    // ответы могут быть разрешены не для всех уровней
    ?>
				<?php 
    if (!$this->readOnly && $levelAllowed) {
        ?>
				<?php 
        echo CHtml::link(YCommentsModule::t('Reply'), "#", array('class' => "comment__button comment__button-reply comment-cmd ", 'data-comment' => json_encode(array('cmd' => 'reply', 'cid' => $comment->id), JSON_NUMERIC_CHECK)));
        ?>
				<?php 
    }
    ?>
			
			<?php 
}
?>
			
			<?php 
if ($behavior->allowVotes) {
    ?>
				
				<span class="comment-likes" data-likes="<?php 
    echo $comment->votes_up;
Example #17
0
 public function attributeLabels()
 {
     return array('UName' => YCommentsModule::t('Name'), 'UEmail' => YCommentsModule::t('Email'));
 }