/**
  * Obtain all current notifications/events for the current web user.
  */
 public function actionGet()
 {
     if (Yii::app()->user->isGuest) {
         header('Content-type: application/json');
         echo CJSON::encode(array('sessionError' => Yii::t('app', 'Your X2Engine session has expired. You may select "cancel" to ignore this message and recover unsaved data from the current page. Otherwise, you will be redirected to the login page.')));
         Yii::app()->end();
     }
     if (!isset($_GET['lastNotifId'])) {
         // if the client doesn't specify the last
         $_GET['lastNotifId'] = 0;
     }
     // message ID received, send everything
     $notifications = $this->getNotifications($_GET['lastNotifId']);
     $notifCount = 0;
     if (count($notifications)) {
         $notifCount = X2Model::model('Notification')->countByAttributes(array('user' => Yii::app()->user->name), 'createDate < ' . time());
     }
     $chatMessages = array();
     $lastEventId = 0;
     $lastTimestamp = 0;
     // if the client specifies the last message ID received,
     if (isset($_GET['lastEventId']) && is_numeric($_GET['lastEventId'])) {
         // only send newer messages
         $lastEventId = $_GET['lastEventId'];
     }
     if (isset($_GET['lastTimestamp']) && is_numeric($_GET['lastTimestamp'])) {
         $lastTimestamp = $_GET['lastTimestamp'];
     }
     if ($lastEventId == 0) {
         // get page of newest events
         $retVal = Events::getFilteredEventsDataProvider(null, true, null, isset($_SESSSION['filters']));
         $dataProvider = $retVal['dataProvider'];
         $events = $dataProvider->getData();
     } else {
         // get new events
         $limit = null;
         $result = Events::getEvents($lastEventId, $lastTimestamp, $limit);
         $events = $result['events'];
     }
     $i = count($events) - 1;
     for ($i; $i > -1; --$i) {
         if (isset($events[$i])) {
             $userLink = '<span class="widget-event">' . $events[$i]->user . '</span>';
             $chatMessages[] = array((int) $events[$i]->id, (int) $events[$i]->timestamp, $userLink, $events[$i]->getText(array('truncated' => true)), Formatter::formatFeedTimestamp($events[$i]->timestamp));
         }
     }
     if (!empty($notifications) || !empty($chatMessages)) {
         header('Content-type: application/json');
         echo CJSON::encode(array('notifCount' => $notifCount, 'notifData' => $notifications, 'chatData' => $chatMessages));
     }
 }
Exemple #2
0
        </span>
        <div class='event-bottom-row'>
            <span class="comment-age x2-hint" id="<?php 
echo $data->id . "-" . $data->timestamp;
?>
" 
                  style="<?php 
echo $style;
?>
"
                  title="<?php 
echo Formatter::formatFeedTimestamp($data->timestamp);
?>
">
                  <?php 
echo Formatter::formatFeedTimestamp($data->timestamp);
?>
            </span> 
            <span>
                
            </span>
            <span class='event-icon-button-container'>
                <?php 
echo CHtml::link(CHtml::tag('span', array('class' => 'feed-comment-icon fa fa-comment-o active-icon', 'title' => Yii::t('profile', 'Comment on this post')), ' ') . '<span title="' . CHtml::encode(Yii::t('profile', 'View comments')) . '"
                           id="' . $data->id . '-comment-count" class="comment-count" 
                           val="' . $commentCount . '">' . ($commentCount > 0 ? "<b>" . $commentCount . "</b>" : $commentCount) . '</span>', '#', array('class' => 'comment-link', 'id' => $data->id . '-link'));
?>
                <?php 
echo CHtml::link(CHtml::tag('span', array('class' => 'feed-comment-icon fa fa-comment inactive-icon', 'title' => Yii::t('profile', 'Hide comments'), 'style' => 'font-weight: bold;'), ' '), '#', array('class' => 'comment-hide-link', 'id' => $data->id . '-hide-link', 'style' => 'display:none;'));
?>
                
Exemple #3
0
 *****************************************************************************************/
?>
<div class="view top-level">
	<div class="deleteButton">
		<?php 
$parent = Events::model()->findByPk($data->associationId);
if ($data->user == Yii::app()->user->getName() || $parent->associationId == Yii::app()->user->getId() || Yii::app()->params->isAdmin) {
    echo CHtml::link('', array('/profile/deletePost', 'id' => $data->id, 'profileId' => $profileId), array('class' => 'fa fa-close'));
}
//,array('class'=>'x2-button')
?>
	</div>
	<?php 
echo User::getUserLinks($data->user);
echo ' ';
echo X2Html::tag('span', array('class' => 'comment-age x2-hint', 'id' => "-{$data->timestamp}", 'title' => Formatter::formatFeedTimestamp($data->timestamp)), Formatter::formatFeedTimestamp($data->timestamp));
?>
 
	<br/>
	<?php 
echo $data->text;
?>
</div>


<?php 
/*
<div class="view">
	<div class="deleteButton">
		<?php echo CHtml::link('[x]',array('deleteNote','id'=>$data->id)); //,array('class'=>'x2-button') ?>
		<?php //echo CHtml::link("<img src='".Yii::app()->request->baseUrl."/images/deleteButton.png' />",array("deleteNote","id"=>$data->id)); ?>