public function actionAdd($id)
 {
     $model = new Wall();
     $model->text = Yii::app()->getRequest()->getPost('text');
     $model->timestamp = time();
     $model->author_id = Yii::app()->user->id;
     $model->user_id = $id;
     if ($model->save()) {
         if (Yii::app()->request->isAjaxRequest) {
             $wall = Wall::model()->getLast(0, 10, $id);
             $res = '';
             foreach ($wall as $item) {
                 $res .= $this->renderPartial('//profile/profile/_wallItem', array('item' => $item), true);
             }
             echo json_encode(array('status' => 'ok', 'data' => $res));
         } else {
             $this->redirect(Yii::app()->createUrl('id' . $id));
         }
     } else {
         if (Yii::app()->request->isAjaxRequest) {
             echo json_encode(array('status' => 'error'));
         } else {
             throw new CException('Server error', 500);
         }
     }
 }
示例#2
0
 /**
  * On run of integrity check command, validate all user data
  *
  * @param type $event
  */
 public static function onIntegrityCheck($event)
 {
     $integrityChecker = $event->sender;
     $integrityChecker->showTestHeadline("Validating User Module (" . User::model()->count() . " entries)");
     foreach (User::model()->findAll() as $u) {
         $profile = $u->getProfile();
         if ($profile == null || $profile->isNewRecord) {
             $integrityChecker->showWarning("No profile table record found for " . $u->username);
         }
         if ($u->wall_id == "") {
             $wall = new Wall();
             $wall->object_model = 'User';
             $wall->object_id = $u->id;
             $wall->save();
             $u->wall_id = $wall->id;
             $u->save();
             $integrityChecker->showFix("Created wall table entry for " . $u->username);
         }
     }
 }
示例#3
0
文件: User.php 项目: ahdail/humhub
 /**
  * After Save Addons
  *
  * @return type
  */
 protected function afterSave()
 {
     // Search Stuff
     if (!$this->isNewRecord) {
         HSearch::getInstance()->deleteModel($this);
     }
     if ($this->status == User::STATUS_ENABLED) {
         HSearch::getInstance()->addModel($this);
     }
     if ($this->isNewRecord) {
         $userInvite = UserInvite::model()->findByAttributes(array('email' => $this->email));
         if ($userInvite !== null) {
             // User was invited to a space
             if ($userInvite->source == UserInvite::SOURCE_INVITE) {
                 $space = Space::model()->findByPk($userInvite->space_invite_id);
                 if ($space != null) {
                     $space->addMember($this->id);
                 }
             }
             // Delete/Cleanup Invite Entry
             $userInvite->delete();
         }
         // Auto Assign User to the Group Space
         $group = Group::model()->findByPk($this->group_id);
         if ($group != null && $group->space_id != "") {
             $space = Space::model()->findByPk($group->space_id);
             if ($space !== null) {
                 $space->addMember($this->id);
             }
         }
         $this->notifyGroupAdminsForApproval();
         // Auto Add User to the default spaces
         foreach (Space::model()->findAllByAttributes(array('auto_add_new_members' => 1)) as $space) {
             $space->addMember($this->id);
         }
         // Create new wall record for this user
         $wall = new Wall();
         $wall->type = Wall::TYPE_USER;
         $wall->object_model = 'User';
         $wall->object_id = $this->id;
         $wall->save();
         $this->wall_id = $wall->id;
         $this->wall = $wall;
         User::model()->updateByPk($this->id, array('wall_id' => $wall->id));
     }
     return parent::afterSave();
 }
示例#4
0
 public function postInsert($event)
 {
     $wall = new Wall();
     $wall->decision_id = $this->id;
     $token = substr(md5(uniqid()), 0, 6);
     while (WallTable::getInstance()->findOneBy('token', $token)) {
         $token = substr(md5(uniqid()), 0, 6);
     }
     $wall->token = $token;
     $wall->save();
     $this->createDashboard();
 }
示例#5
0
文件: Space.php 项目: skapl/design
 /**
  * After Save Addons
  */
 protected function afterSave()
 {
     // Try To Delete Search Model
     HSearch::getInstance()->deleteModel($this);
     // Newer index a hidden workspace
     if ($this->visibility != self::VISIBILITY_NONE) {
         HSearch::getInstance()->addModel($this);
     }
     $userId = $this->created_by;
     if ($this->isNewRecord) {
         // Create new wall record for this space
         $wall = new Wall();
         $wall->object_model = 'Space';
         $wall->object_id = $this->id;
         $wall->save();
         $this->wall_id = $wall->id;
         $this->wall = $wall;
         Space::model()->updateByPk($this->id, array('wall_id' => $wall->id));
         // Auto add creator as admin
         $membership = new SpaceMembership();
         $membership->space_id = $this->id;
         $membership->user_id = $userId;
         $membership->status = SpaceMembership::STATUS_MEMBER;
         $membership->invite_role = 1;
         $membership->admin_role = 1;
         $membership->share_role = 1;
         $membership->save();
         $activity = new Activity();
         $activity->content->created_by = $userId;
         $activity->content->space_id = $this->id;
         $activity->content->user_id = $userId;
         $activity->content->visibility = Content::VISIBILITY_PUBLIC;
         $activity->created_by = $userId;
         $activity->type = "ActivitySpaceCreated";
         $activity->save();
         $activity->fire();
     }
     Yii::app()->cache->delete('userSpaces_' . $userId);
     parent::afterSave();
 }
示例#6
0
 /**
  * After Save Addons
  */
 protected function afterSave()
 {
     if ($this->status != self::VISIBILITY_NONE) {
         Yii::app()->search->update($this);
     } else {
         Yii::app()->search->delete($this);
     }
     $userId = $this->created_by;
     if ($this->isNewRecord) {
         // Create new wall record for this room
         $wall = new Wall();
         $wall->object_model = 'Room';
         $wall->object_id = $this->id;
         $wall->save();
         $this->wall_id = $wall->id;
         $this->wall = $wall;
         Room::model()->updateByPk($this->id, array('wall_id' => $wall->id));
         // Auto add creator as admin
         $membership = new RoomMembership();
         $membership->room_id = $this->id;
         $membership->user_id = $userId;
         $membership->status = RoomMembership::STATUS_MEMBER;
         $membership->invite_role = 1;
         $membership->admin_role = 1;
         $membership->share_role = 1;
         $membership->save();
         $activity = new Activity();
         $activity->content->created_by = $userId;
         $activity->content->room_id = $this->id;
         $activity->content->user_id = $userId;
         $activity->content->visibility = Content::VISIBILITY_PUBLIC;
         $activity->created_by = $userId;
         $activity->type = "ActivityRoomCreated";
         $activity->save();
         $activity->fire();
     }
     Yii::app()->cache->delete('userRooms_' . $userId);
     parent::afterSave();
 }
示例#7
0
 public function setUpApproved()
 {
     $userInvite = UserInvite::model()->findByAttributes(array('email' => $this->email));
     if ($userInvite !== null) {
         // User was invited to a space
         if ($userInvite->source == UserInvite::SOURCE_INVITE) {
             $space = Space::model()->findByPk($userInvite->space_invite_id);
             if ($space != null) {
                 $space->addMember($this->id);
             }
         }
         // Delete/Cleanup Invite Entry
         $userInvite->delete();
     }
     // Auto Assign User to the Group Space
     $group = Group::model()->findByPk($this->group_id);
     if ($group != null && $group->space_id != "") {
         $space = Space::model()->findByPk($group->space_id);
         if ($space !== null) {
             $space->addMember($this->id);
         }
     }
     //
     // Auto Add User to the default spaces
     foreach (Space::model()->findAllByAttributes(array('auto_add_new_members' => 1)) as $space) {
         $space->addMember($this->id);
     }
     // Create new wall record for this user
     $wall = new Wall();
     $wall->object_model = 'User';
     $wall->object_id = $this->id;
     $wall->save();
     $this->wall_id = $wall->id;
     $this->wall = $wall;
     User::model()->updateByPk($this->id, array('wall_id' => $wall->id));
 }