public function run()
 {
     $currentSpace = null;
     $currentSpaceGuid = "";
     if (isset(Yii::app()->params['currentSpace']) && Yii::app()->params['currentSpace'] != null) {
         $currentSpace = Yii::app()->params['currentSpace'];
         $currentSpaceGuid = $currentSpace->guid;
     }
     $this->render('yourSpacesMenu', array('currentSpace' => $currentSpace, 'currentSpaceGuid' => $currentSpaceGuid, 'usersSpaces' => SpaceMembership::GetUserSpaces()));
 }
Beispiel #2
0
 /**
  * On User delete, also delete his space related stuff
  *
  * @param type $event
  */
 public static function onUserDelete($event)
 {
     $user = $event->sender;
     // Check if the user owns some spaces
     foreach (SpaceMembership::GetUserSpaces($user->id) as $space) {
         if ($space->isSpaceOwner($user->id)) {
             throw new CHttpException(500, Yii::t('SpaceModule.base', 'Could not delete user who is a space owner! Name of Space: {spaceName}', array('spaceName' => $space->name)));
         }
     }
     // Cancel all space memberships
     foreach (SpaceMembership::model()->findAllByAttributes(array('user_id' => $user->id)) as $membership) {
         $membership->space->removeMember($user->id);
     }
     // Cancel all space invites by the user
     foreach (SpaceMembership::model()->findAllByAttributes(array('originator_user_id' => $user->id, 'status' => SpaceMembership::STATUS_INVITED)) as $membership) {
         $membership->space->removeMember($membership->user_id);
     }
     return true;
 }
Beispiel #3
0
 public function run()
 {
     $showSpaces = 30;
     $spaces = array();
     $i = 0;
     foreach (SpaceMembership::GetUserSpaces($this->user->id) as $space) {
         if ($space->visibility == Space::VISIBILITY_NONE) {
             continue;
         }
         if ($space->status != Space::STATUS_ENABLED) {
             continue;
         }
         $i++;
         if ($i > $showSpaces) {
             break;
         }
         $spaces[] = $space;
     }
     $this->render('userSpaces', array('spaces' => $spaces));
 }
Beispiel #4
0
 /**
  * This is a special case, because we need to find a space to start the tour
  */
 public function actionStartSpaceTour()
 {
     $space = null;
     // Loop over all spaces where the user is member
     foreach (SpaceMembership::GetUserSpaces() as $space) {
         if ($space->isAdmin()) {
             // If user is admin on this space, it´s the perfect match
             break;
         }
     }
     if ($space === null) {
         // If user is not member of any space, try to find a public space
         // to run tour in
         $space = Space::model()->find('visibility!=' . Space::VISIBILITY_NONE);
     }
     if ($space === null) {
         throw new CHttpException(404, 'Could not find any public space to run tour!');
     }
     $this->redirect($space->getUrl(array('tour' => true)));
 }
Beispiel #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 Profile Image
     $this->getProfileImage()->delete();
     // Delete all pending invites
     UserInvite::model()->deleteAllByAttributes(array('user_originator_id' => $this->id));
     Follow::model()->deleteAllByAttributes(array('user_id' => $this->id));
     Follow::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));
     // 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();
 }
Beispiel #6
0
<?php

$count = 0;
?>

<?php 
foreach (SpaceMembership::GetUserSpaces() as $space) {
    ?>
    <li>
        <a href="<?php 
    echo $space->getUrl();
    ?>
">
            <div class="media">
                <!-- Show user image -->
                <img class="media-object img-rounded pull-left" alt="24x24" data-src="holder.js/24x24"
                     style="width: 24px; height: 24px;"
                     src="<?php 
    echo $space->getProfileImage()->getUrl();
    ?>
">
                <!-- Show space image, if you are outside from a space -->
                <div class="media-body">
                    <!-- Show content -->
                    <strong><?php 
    echo $space->name;
    ?>
</strong>

                    <div id="space-badge-<?php 
    echo $count;
Beispiel #7
0
 /**
  * Delete Action
  *
  * Its only possible if the user is not owner of a workspace.
  */
 public function actionDelete()
 {
     $isSpaceOwner = false;
     $user = Yii::app()->user->getModel();
     if ($user->auth_mode != User::AUTH_MODE_LOCAL) {
         throw new CHttpException(500, 'This is not a local account! You cannot delete it. (e.g. LDAP)!');
     }
     foreach (SpaceMembership::GetUserSpaces() as $space) {
         // Oups, we are owner in this workspace!
         if ($space->isSpaceOwner($user->id)) {
             $isSpaceOwner = true;
         }
     }
     $model = new AccountDeleteForm();
     if (!$isSpaceOwner) {
         // Uncomment the following line if AJAX validation is needed
         // $this->performAjaxValidation($model);
         if (isset($_POST['AccountDeleteForm'])) {
             $_POST['AccountDeleteForm'] = Yii::app()->input->stripClean($_POST['AccountDeleteForm']);
             $model->attributes = $_POST['AccountDeleteForm'];
             if ($model->validate()) {
                 $user->delete();
                 Yii::app()->user->logout();
                 $this->redirect(Yii::app()->homeUrl);
             }
         }
     }
     $this->render('delete', array('model' => $model, 'isSpaceOwner' => $isSpaceOwner));
 }
$this->widget('application.modules_core.user.widgets.UserPickerWidget', array('inputId' => 'notifyUserInput', 'userSearchUrl' => $userSearchUrl, 'maxUsers' => 10, 'userGuid' => Yii::app()->user->guid, 'placeholderText' => Yii::t('WallModule.widgets_views_contentForm', 'Add a member to notify'), 'focus' => true));
?>
        </div>

        <?php 
/**  
 * If they're looking at a Space or User, use default functionality.
 * If they're on the dashboard, implement "post to space" selector.
 *
 * Once we've established they are on a "post to space" page and check 
 * if the user is a member of more than one group. If the user is only 
 * in one space, we prefill the fields and the select box is hidden.
 * If the user is in multiple spaces, we set up our listeners and disable
 * the post button until a selection is made
 */
$userSpaces = SpaceMembership::GetUserSpaces();
$showSpacePicker = count($userSpaces) > 1 ? true : false;
// Use default behaviour when in a Space or Profile
if (Yii::app()->params['currentSpace'] || Yii::app()->params['currentUser']) {
    echo CHtml::hiddenField("containerGuid", $contentContainer->guid);
    echo CHtml::hiddenField("containerClass", get_class($contentContainer));
} else {
    if (count($userSpaces) == 0) {
        // if the user isn't in any spaces hide post area
        ?>
            <script type="text/javascript">
                $(function() {
                    $("#contentFormBody").hide();
                });
            </script>
        <?php 
 /**
  * Deletes a user permanently
  */
 public function actionDelete()
 {
     $id = (int) Yii::app()->request->getQuery('id');
     $doit = (int) Yii::app()->request->getQuery('doit');
     $user = User::model()->resetScope()->findByPk($id);
     if ($user == null) {
         throw new CHttpException(404, Yii::t('AdminModule.controllers_UserController', 'User not found!'));
     } elseif (Yii::app()->user->id == $id) {
         throw new CHttpException(400, Yii::t('AdminModule.controllers_UserController', 'You cannot delete yourself!'));
     }
     if ($doit == 2) {
         $this->forcePostRequest();
         foreach (SpaceMembership::GetUserSpaces() as $workspace) {
             if ($workspace->isSpaceOwner($user->id)) {
                 $workspace->addMember(Yii::app()->user->id);
                 $workspace->setSpaceOwner(Yii::app()->user->id);
             }
         }
         $user->delete();
         $this->redirect(Yii::app()->createUrl('admin/user'));
     }
     $this->render('delete', array('model' => $user));
 }