/**
  * Executes the widgets
  */
 public function run()
 {
     // Some member stats
     Yii::import('application.modules.mail.models.*');
     $statsTotalUsers = User::model()->count();
     $criteria = new CDbCriteria();
     $criteria->group = 'user_id';
     $criteria->condition = 'user_id IS NOT null';
     $statsUserOnline = UserHttpSession::model()->count($criteria);
     $statsMessageEntries = 0;
     if (Yii::app()->moduleManager->isEnabled('mail')) {
         $statsMessageEntries = MessageEntry::model()->count();
     }
     $statsUserFollow = UserFollow::model()->countByAttributes(array('object_model' => 'User'));
     // Render widgets view
     $this->render('memberStats', array('statsTotalUsers' => $statsTotalUsers, 'statsUserOnline' => $statsUserOnline, 'statsMessageEntries' => $statsMessageEntries, 'statsUserFollow' => $statsUserFollow));
 }
Exemple #2
0
 /**
  * Allows third party applications to convert a valid sessionId
  * into a username.
  */
 public function actionGetSessionUserJson()
 {
     $sessionId = Yii::app()->request->getQuery('sessionId');
     $output = array();
     $output['valid'] = false;
     $httpSession = UserHttpSession::model()->with('user')->findByAttributes(array('id' => $sessionId));
     if ($httpSession != null && $httpSession->user != null) {
         $output['valid'] = true;
         $output['userName'] = $httpSession->user->username;
         $output['fullName'] = $httpSession->user->displayName;
         $output['email'] = $httpSession->user->email;
     }
     print CJSON::encode($output);
     Yii::app()->end();
 }
Exemple #3
0
<div class="container">

    <div class="row">
        <div class="panel panel-default">

            <div class="panel-heading">Invite People</div>


            <div class="panel-body">
               <?php 
// Some member stats
//Yii::import('application.modules.mail.models.*');
$criteria = new CDbCriteria();
$criteria->group = 'user_id';
$criteria->condition = 'user_id IS NOT null';
$onlineUsers = UserHttpSession::model()->findAll($criteria);
?>

               <input id='recipient'>
               <button onclick="javascript:invite();">Send Invitation</button>
               <?php 
$this->widget('application.modules_core.user.widgets.UserPickerWidget', array('inputId' => 'recipient', 'attribute' => 'recipient', 'userGuid' => Yii::app()->user->guid, 'focus' => true));
?>
            </div>


        </div>

    </div>

Exemple #4
0
 protected function beforeSave()
 {
     if ($this->isNewRecord) {
         if ($this->seen == "") {
             $this->seen = 0;
         }
     }
     $userOnline = UserHttpSession::model()->exists('user_id = ' . $this->user_id);
     if (!$userOnline) {
         $this->desktop_notified = 1;
     }
     return parent::beforeSave();
 }
Exemple #5
0
 /**
  * Before Delete of a User
  *
  */
 public function beforeDelete()
 {
     // We don't allow deletion of users who owns a space - validate that
     foreach (SpaceMembership::GetUserSpaces($this->id) as $workspace) {
         if ($workspace->isSpaceOwner($this->id)) {
             throw new Exception("Tried to delete a user which is owner of a space!");
         }
     }
     UserSetting::model()->deleteAllByAttributes(array('user_id' => $this->id));
     // Disable all enabled modules
     foreach ($this->getAvailableModules() as $moduleId => $module) {
         if ($this->isModuleEnabled($moduleId)) {
             $this->disableModule($moduleId);
         }
     }
     HSearch::getInstance()->deleteModel($this);
     // Delete user session
     UserHttpSession::model()->deleteAllByAttributes(array('user_id' => $this->id));
     // Delete Profile Image
     $this->getProfileImage()->delete();
     // Delete all pending invites
     UserInvite::model()->deleteAllByAttributes(array('user_originator_id' => $this->id));
     UserFollow::model()->deleteAllByAttributes(array('user_id' => $this->id));
     UserFollow::model()->deleteAllByAttributes(array('object_model' => 'User', 'object_id' => $this->id));
     // Delete all group admin assignments
     GroupAdmin::model()->deleteAllByAttributes(array('user_id' => $this->id));
     // Delete wall entries
     WallEntry::model()->deleteAllByAttributes(array('wall_id' => $this->wall_id));
     // Delete user profile
     Profile::model()->deleteAllByAttributes(array('user_id' => $this->id));
     // Deletes all content created by this user
     foreach (Content::model()->findAllByAttributes(array('user_id' => $this->id)) as $content) {
         $content->delete();
     }
     foreach (Content::model()->findAllByAttributes(array('created_by' => $this->id)) as $content) {
         $content->delete();
     }
     // Delete all passwords
     foreach (UserPassword::model()->findAllByAttributes(array('user_id' => $this->id)) as $password) {
         $password->delete();
     }
     return parent::beforeDelete();
 }