/** * 用户组绑定权限 */ public function actionIndex($id) { $id = (int) $id; $model = Group::model()->findByPk($id); if ($model->access) { foreach ($model->access as $g) { $access[] = $g->access_id; } } $cache = cache('auth_controller_file'); if (!$cache) { $d = $this->_get_modules(\Yii::getPathOfAlias('application.modules')); if ($d) { Access::generate($d); } DirHelper::$kep_list_file = false; cache('auth_controller_file', true); } $rows = DB::all('access', array('select' => "id,name,pid")); foreach ($rows as $v) { $out[$v['id']] = $v; } $rows = ArrHelper::_tree_id($rows); if ($_POST) { $auth = $_POST['auth']; GroupAccess::saveAccess($id, $auth); cache('acl', false); flash('success', __('set access success')); $this->redirect(url('admin/auth/index', array('id' => $id))); } return $this->render('index', array('rows' => $rows, 'out' => $out, 'model' => $model, 'id' => $id, 'access' => $access)); }
public function run() { $model = new UserForm(); if (($post = $this->request->getPost('UserForm', false)) !== false) { $model->attributes = $post; if ($model->save()) { $this->response(200, '更新用户成功'); } else { $this->response(500, '更新用户失败'); } $this->app->end(); } else { if (($id = $this->request->getQuery('id', 0)) != false) { if (($user = User::model()->findByPk($id)) != false) { $model->attributes = ['id' => $user->id, 'username' => $user->username, 'realname' => $user->realname, 'nickname' => $user->nickname, 'email' => $user->email, 'state' => $user->state]; $auth = $this->app->getAuthManager(); $roles = $auth->getRoleByUserId($id); $role = []; foreach ($roles as $item) { $role[] = $item->getId(); } $groups = $auth->getGroupByUserId($id); $group = []; foreach ($groups as $item) { $group[] = $item->getId(); } $this->render('edit', ['model' => $model, 'role' => $role, 'group' => $group, 'roleList' => Role::model()->findAll(), 'groupList' => Group::model()->findAll()]); $this->app->end(); } } } $this->response(404, '参数错误'); }
/** * Edit a karma record */ public function actionEdit() { $_POST = Yii::app()->input->stripClean($_POST); $id = (int) Yii::app()->request->getQuery('id'); $user = User::model()->resetScope()->findByPk($id); $karma = Karma::model()->resetScope()->findByPk($id); if ($karma == null) { throw new CHttpException(404, "Karma record not found!"); } // Build Form Definition $definition = array(); $definition['elements'] = array(); $groupModels = Group::model()->findAll(array('order' => 'name')); // Define Form Eleements $definition['elements']['Karma'] = array('type' => 'form', 'title' => 'Karma', 'elements' => array('name' => array('type' => 'text', 'class' => 'form-control', 'maxlength' => 25), 'points' => array('type' => 'text', 'class' => 'form-control', 'maxlength' => 10), 'description' => array('type' => 'text', 'class' => 'form-control', 'maxlength' => 1000))); // Get Form Definition $definition['buttons'] = array('save' => array('type' => 'submit', 'label' => 'Save', 'class' => 'btn btn-primary'), 'delete' => array('type' => 'submit', 'label' => 'Delete', 'class' => 'btn btn-danger')); $form = new HForm($definition); $form['Karma']->model = $karma; if ($form->submitted('save') && $form->validate()) { $this->forcePostRequest(); if ($form['Karma']->model->save()) { $this->redirect($this->createUrl('edit', array('id' => $karma->id))); return; } } if ($form->submitted('delete')) { $this->redirect(Yii::app()->createUrl('karma/admin/delete', array('id' => $user->id))); } $this->render('edit', array('form' => $form)); }
public function actionDynamicRows() { $selectionid = $_POST['selection']; switch ($selectionid) { case '1': die; case '2': $selectedData = Group::model()->findAll(); $dataOptions = array('' => '--- Select Group ---'); foreach ($selectedData as $row) { //$group = Group::model()->findByAttributes(array('name'=>$row->name)); $dataOptions[$row->id] = $row->name; } break; case '3': $selectedData = User::model()->findAll('name != :name', array(':name' => Yii::app()->user->getId())); $dataOptions = array('' => '--- Select User ---'); foreach ($selectedData as $row) { //$user = User::model()->findByAttributes(array('name'=>$row->name)); $dataOptions[$row->id] = $row->name; } break; default: break; } foreach ($dataOptions as $value => $name) { $opt = array(); $opt['value'] = $value; echo CHtml::tag('option', $opt, CHtml::encode($name), true); } die; }
public function actionIndex() { Yii::app()->getModule('aud'); Yii::app()->getModule('group'); Yii::app()->getModule('lesson'); Yii::app()->getModule('sch'); Yii::app()->getModule('spec'); Yii::app()->getModule('teacher'); $schs = Sch::model()->findAll(array('order' => 'modified_time DESC', 'limit' => 100)); $auds = Aud::model()->findAll(array('order' => 'updated_time DESC', 'limit' => 100)); $specs = Spec::model()->findAll(array('order' => 'updated_time DESC', 'limit' => 100)); $groups = Group::model()->findAll(array('order' => 'updated_time DESC', 'limit' => 100)); $lessons = Lesson::model()->findAll(array('order' => 'updated_time DESC', 'limit' => 100)); $teachers = Teacher::model()->findAll(array('order' => 'updated_time DESC', 'limit' => 100)); $entries = $this->addEntries(array($auds, $specs, $groups, $lessons, $teachers)); foreach ($schs as $value) { $entries[] = array('id' => $value->group_id, 'module' => strtolower(get_class($value)), 'time' => $value->modified_time . rand(100000, 999999), 'time' => $value->modified_time, 'user' => $value->modified_by, 'action' => 'update'); } $entriesNew = array(); foreach ($entries as $value) { $entriesNew[$value['time'] . rand(10000, 99999)] = $value; } krsort($entriesNew); $this->render('index', array('entries' => $entriesNew)); }
/** * Deletes a group * * On deletion all group members will be moved to another group. */ public function actionDelete() { Yii::import('admin.forms.*'); $id = (int) Yii::app()->request->getQuery('id'); $group = Group::model()->findByPk($id); if ($group == null) { throw new CHttpException(404, Yii::t('AdminModule.controllers_GroupController', 'Group not found!')); } // uncomment the following code to enable ajax-based validation if (isset($_POST['ajax']) && $_POST['ajax'] === 'admin-deleteGroup-form') { echo CActiveForm::validate($group); Yii::app()->end(); } $model = new AdminDeleteGroupForm(); if (isset($_POST['AdminDeleteGroupForm'])) { $model->attributes = $_POST['AdminDeleteGroupForm']; if ($model->validate()) { foreach (User::model()->findAllByAttributes(array('group_id' => $group->id)) as $user) { $user->group_id = $model->group_id; $user->save(); } $group->delete(); $this->redirect(Yii::app()->createUrl('//admin/group')); } } $this->render('delete', array('group' => $group, 'model' => $model)); }
function actionShowedit() { $user = Yii::app()->session['member']; $this->data['user'] = $this->connection->createCommand("select * from xm_user where user_id = {$user['user_id']}")->queryRow(); $this->data['group'] = Group::model()->findByPk($user['group_id']); $this->render('showedit', $this->data); }
public function run() { $this->userinfo = User::model()->findByPk($this->userid); if (!empty($this->isgroup)) { $this->groupinfo = Group::model()->findByAttributes(array('group_id' => $this->isgroup)); } $this->render('_topmenu', array('tilescount' => $this->alltiles, 'userinfo' => $this->userinfo, 'finaocount' => $this->finaocount, 'imgcount' => $this->imgcount, 'videocount' => $this->videocount, 'isshare' => $this->isshare, 'followcnt' => $this->followcnt, 'userid' => $this->userid, 'groupcnt' => $this->groupcnt, 'isgroup' => $this->isgroup, 'groupinfo' => $this->groupinfo)); }
public function existingGroups() { Yii::app()->getModule('group'); foreach (Group::model()->findAll() as $group) { $groups[] = array($group->code, $group->year, $group->number); } return $groups; }
static function getCurrentGroup() { if (!isset(Yii::app()->user->group)) { $group = Group::model()->findByPk(1); Yii::app()->user->setState('group', $group); } return Yii::app()->user->group; }
protected function loadModel($id) { $model = Group::model()->findByPk($id); if ($model === NULL) { $this->show404(); } return $model; }
public function run() { $gid = $this->gid; $group = Group::model()->loadGroup($gid); $new_topics = $group->getGroupNewThreads(); $data = array('group' => $group, 'new_topics' => $new_topics); $this->render('WGroupTopicSidebar', $data); }
public function actionHistory($id) { $model = new Sch(); if (!($models = $model->schHistory($id))) { $this->redirect('/group'); } $this->render('history', array('models' => $models, 'group' => Group::model()->findByPk($id))); }
/** * Executes the widgets */ public function run() { $groups = Group::model()->count(); $users = User::model()->count(); $statsAvgMembers = $users / $groups; $statsTopGroup = Group::model()->find('id = (SELECT group_id FROM user GROUP BY group_id ORDER BY count(*) DESC LIMIT 1)'); // Render widgets view $this->render('groupStats', array('statsTotalGroups' => $groups, 'statsAvgMembers' => round($statsAvgMembers, 1), 'statsTopGroup' => $statsTopGroup, 'statsTotalUsers' => $users)); }
public function modifyData() { $criteria = new CDbCriteria(); $items = Group::model()->findAll($criteria); foreach ($items as $item) { $groupRelation = MiniGroupRelation::getInstance()->getByGroupId($item->id); $group = Group::model()->findByPk($item->id); $group->parent_group_id = $groupRelation['parent_group_id']; $group->save(); } }
public function run() { $gid = $this->gid; $group = Group::model()->loadGroup($gid); //友情小租 //$friend_groups = $group->getGroupNewFriends(); //最近加入 #$group_members = $group->getGroupNewMembers(); $data = array('group' => $group); $this->render('WGroupShowSidebar', $data); }
public function actionPhone($group, $os) { $group = Group::model()->filled()->findByAttributes(['number' => $group]); if (!in_array(strtolower($os), array_keys(self::$os))) { throw new CHttpException(404, "Инструкции для данной системы нет"); } if (!$group) { throw new CHttpException(404, "Данной группы не найдено"); } $this->render('phone/' . $os, ['group' => $group]); }
public function actionUpdate($id) { $model = Group::model()->findByPk($id); $list = $model->dropDownList(); $model->scenario = 'update'; if (isset($_POST[$this->key])) { $model->attributes = $_POST[$this->key]; if ($model->save()) { flash('success', __('create group sucessful')); $this->refresh(); } } return $this->render('form', array('model' => $model, 'name' => 'group_create', 'list' => $list)); }
public function actionPost($groupid, $postid) { $group = Group::model()->findByPk($groupid); $group->viewNum = $group->viewNum + 1; $post = Post::model()->findByPk($postid); $post->viewNum = $post->viewNum + 1; if ($group->save() && $post->save()) { $postView = new PostView(); $postView->userId = Yii::app()->user->isGuest ? 0 : Yii::app()->user->id; $postView->ip = Yii::app()->request->getUserHostAddress(); $postView->postid = $postid; $postView->save(); } }
/** * 编译小组发布类型通知 */ public function compileGroupPublish() { $owner = $this->getOwner(); $data = $owner->getData(); try { $groupId = isset($data['groupId']) ? $data['groupId'] : $data['groupid']; $group = Group::model()->findByPk($groupId); $viewFile = "_group_published"; $viewData = array('group' => $group); } catch (Exception $e) { return false; } return array('viewFile' => $viewFile, 'viewData' => $viewData); }
public function run() { switch ($this->type) { case 'group': $resultinfo = Group::model()->findByAttributes(array('group_id' => $this->pid)); break; case 'tile': $resulttileinfo = Lookups::model()->findByAttributes(array('lookup_id' => $this->pid)); break; case 'video': $resultgroupinfo = ''; break; } $this->render('_easyregister', array('type' => $this->type, 'pid' => $this->pid, 'resultinfo' => $resultinfo, 'resulttileinfo' => $resulttileinfo)); }
public function afterSave() { if ($this->getScenario() == 'insert') { $user = Users::model()->findByAttributes(['email' => $this->email]); if (!$user) { $group = Group::model()->findByPk($this->group_id); $mail = new YiiMailer(); $mail->setView('invite'); $mail->setData(array('group' => $group, 'hash' => $this->hash)); $mail->setFrom(isset(Yii::app()->params->YiiMailer->Username) ? Yii::app()->params->YiiMailer->Username : Yii::app()->params->adminEmail, 'Система управления учебным расписанием'); $mail->setTo($this->email); $mail->setSubject('Приглашение'); $mail->send(); } } }
/** * Create * @param integer $groupId * @param integer $courseId */ public function actionCreate($groupId, $courseId) { $model = new GroupCourse(); $course = Course::model()->findByPk($courseId); $group = Group::model()->findByPk($groupId); // $member = $group->findMember(array('userId'=>Yii::app()->user->id)); $member = GroupMember::model()->findByAttributes(array('groupId' => $groupId, 'userId' => Yii::app()->user->id)); if ($course && $member && $member->inRoles(array('admin', 'superAdmin'))) { $model->groupId = $groupId; $model->courseId = $courseId; $model->userId = Yii::app()->user->id; $model->addTime = time(); echo $model->save(); Yii::app()->user->setFlash('success', '收藏成功!'); } echo false; }
/** * Edits a user * * @return type */ public function actionEdit() { $_POST = Yii::app()->input->stripClean($_POST); $id = (int) Yii::app()->request->getQuery('id'); $user = User::model()->resetScope()->findByPk($id); if ($user == null) { throw new CHttpException(404, Yii::t('AdminModule.controllers_UserController', 'User not found!')); } $user->scenario = 'adminEdit'; $user->profile->scenario = 'adminEdit'; $profile = $user->profile; // Build Form Definition $definition = array(); $definition['elements'] = array(); $groupModels = Group::model()->findAll(array('order' => 'name')); // Add User Form $definition['elements']['User'] = array('type' => 'form', 'title' => 'Account', 'elements' => array('username' => array('type' => 'text', 'class' => 'form-control', 'maxlength' => 25), 'email' => array('type' => 'text', 'class' => 'form-control', 'maxlength' => 100), 'group_id' => array('type' => 'dropdownlist', 'class' => 'form-control', 'items' => CHtml::listData($groupModels, 'id', 'name')), 'super_admin' => array('type' => 'checkbox'), 'status' => array('type' => 'dropdownlist', 'class' => 'form-control', 'items' => array(User::STATUS_ENABLED => Yii::t('AdminModule.controllers_UserController', 'Enabled'), User::STATUS_DISABLED => Yii::t('AdminModule.controllers_UserController', 'Disabled'), User::STATUS_NEED_APPROVAL => Yii::t('AdminModule.controllers_UserController', 'Unapproved'))))); // Add Profile Form $definition['elements']['Profile'] = array_merge(array('type' => 'form'), $profile->getFormDefinition()); // Get Form Definition $definition['buttons'] = array('save' => array('type' => 'submit', 'label' => Yii::t('AdminModule.controllers_UserController', 'Save'), 'class' => 'btn btn-primary'), 'become' => array('type' => 'submit', 'label' => Yii::t('AdminModule.controllers_UserController', 'Become this user'), 'class' => 'btn btn-danger'), 'delete' => array('type' => 'submit', 'label' => Yii::t('AdminModule.controllers_UserController', 'Delete'), 'class' => 'btn btn-danger')); $form = new HForm($definition); $form['User']->model = $user; $form['Profile']->model = $profile; if ($form->submitted('save') && $form->validate()) { $this->forcePostRequest(); if ($form['User']->model->save()) { $form['Profile']->model->save(); $this->redirect(Yii::app()->createUrl('admin/user')); return; } } // This feature is used primary for testing, maybe remove this in future if ($form->submitted('become')) { // Switch Identity Yii::import('application.modules_core.user.components.*'); $newIdentity = new UserIdentity($user->username, ''); $newIdentity->fakeAuthenticate(); Yii::app()->user->login($newIdentity); $this->redirect(Yii::app()->createUrl('//')); } if ($form->submitted('delete')) { $this->redirect(Yii::app()->createUrl('admin/user/delete', array('id' => $user->id))); } $this->render('edit', array('form' => $form)); }
public function name($module = null, $id = null) { Yii::app()->getModule('aud'); Yii::app()->getModule('group'); Yii::app()->getModule('lesson'); Yii::app()->getModule('sch'); Yii::app()->getModule('spec'); Yii::app()->getModule('teacher'); $item = ''; switch ($module) { case 'aud': if ($aud = Aud::model()->findByPk($id)) { $item = $aud->name . ' (' . Yii::app()->params['aud_types'][$aud->type] . ')'; } break; case 'group': if ($group = Group::model()->findByPk($id)) { $item = $group->group_spec->code . '-' . $group->year . '-0' . $group->number . ' (' . $group->group_spec->name . ', ' . Yii::app()->sch->course($group->year) . ' курс)'; } break; case 'lesson': if ($lesson = Lesson::model()->findByPk($id)) { $item = isset($lesson->fullname) ? $lesson->fullname : $lesson->name; } break; case 'sch': if ($sch = Sch::model()->findByPk($id)) { $item = $sch->group->groupName() . ' (' . $sch->group->group_spec->name . ', ' . Yii::app()->sch->course($sch->group->year) . ' курс)'; } break; case 'spec': if ($spec = Spec::model()->findByPk($id)) { $item = $spec->name; } break; case 'teacher': if ($teacher = Teacher::model()->findByPk($id)) { $item = $teacher->surname . ' ' . $teacher->initials; } break; default: $item = ''; break; } return $item; }
public function filterGroupControl($filterChain) { if (!isset($_GET['id'])) { throw new CHttpException(404); } /** @var Group $group */ $group = Group::model()->findByAttributes(['number' => $_GET['id']]); if (!$group) { throw new CHttpException(404, 'Данной группы не существует'); } $is_admin = Yii::app()->user->checkAccess('admin'); $is_owner = $group->owner_id == Yii::app()->user->getId(); $is_member = GroupMember::model()->findByAttributes(['group_id' => $group->id, 'user_id' => Yii::app()->user->getId()]); if (!$is_admin && !$is_owner && !$is_member) { throw new CHttpException(403, 'У вас нет доступа к данной группе'); } self::$group = $group; $filterChain->run(); }
public function save() { try { if ($this->id) { $model = Group::model()->findByPk($this->id); if (empty($model)) { throw new CDbException('参数出错', 1, []); } } else { $model = new Group(); } $model->attributes = ['name' => $this->name, 'description' => $this->description, 'status' => $this->status]; if ($model->save() === false) { throw new CDbException('更新用户出错', 2, $model->getErrors()); } } catch (CDbException $e) { $this->addErrors($e->errorInfo); return false; } return true; }
public function actionIndex() { $_POST = Yii::app()->input->stripClean($_POST); $assetPrefix = Yii::app()->assetManager->publish(dirname(__FILE__) . '/../resources', true, 0, defined('YII_DEBUG')); Yii::app()->clientScript->registerScriptFile($assetPrefix . '/md5.min.js'); Yii::app()->clientScript->registerScriptFile($assetPrefix . '/jdenticon-1.3.0.min.js'); $needApproval = HSetting::Get('needApproval', 'authentication_internal'); if (!Yii::app()->user->isGuest) { throw new CHttpException(401, 'Your are already logged in! - Logout first!'); } // Check for valid user invite $userInvite = UserInvite::model()->findByAttributes(array('token' => Yii::app()->request->getQuery('token'))); if (!$userInvite) { throw new CHttpException(404, 'Token not found!'); } if ($userInvite->language) { Yii::app()->setLanguage($userInvite->language); } $userModel = new User('register'); $userModel->email = $userInvite->email; $userPasswordModel = new UserPassword('newPassword'); $profileModel = $userModel->profile; $profileModel->scenario = 'register'; /////////////////////////////////////////////////////// // Generate a random first name $firstNameOptions = explode("\n", HSetting::GetText('anonAccountsFirstNameOptions')); $randomFirstName = trim(ucfirst($firstNameOptions[array_rand($firstNameOptions)])); // Generate a random last name $lastNameOptions = explode("\n", HSetting::GetText('anonAccountsLastNameOptions')); $randomLastName = trim(ucfirst($lastNameOptions[array_rand($lastNameOptions)])); // Pre-set the random first and last name $profileModel->lastname = $randomLastName; $profileModel->firstname = $randomFirstName; // Make the username from the first and lastnames (only first 25 chars) $userModel->username = substr(str_replace(" ", "_", strtolower($profileModel->firstname . "_" . $profileModel->lastname)), 0, 25); /////////////////////////////////////////////////////// // Build Form Definition $definition = array(); $definition['elements'] = array(); $groupModels = Group::model()->findAll(array('order' => 'name')); $defaultUserGroup = HSetting::Get('defaultUserGroup', 'authentication_internal'); $groupFieldType = "dropdownlist"; if ($defaultUserGroup != "") { $groupFieldType = "hidden"; } else { if (count($groupModels) == 1) { $groupFieldType = "hidden"; $defaultUserGroup = $groupModels[0]->id; } } // Add Identicon Form $identiconForm = new IdenticonForm(); $definition['elements']['IdenticonForm'] = array('type' => 'form', 'elements' => array('image' => array('type' => 'hidden', 'class' => 'form-control', 'id' => 'image'))); // Add Profile Form $definition['elements']['Profile'] = array_merge(array('type' => 'form'), $profileModel->getFormDefinition()); // Add User Form $definition['elements']['User'] = array('type' => 'form', 'title' => 'Password', 'elements' => array('username' => array('type' => 'hidden', 'class' => 'form-control', 'maxlength' => 25), 'email' => array('type' => 'hidden', 'class' => 'form-control'), 'group_id' => array('type' => $groupFieldType, 'class' => 'form-control', 'items' => CHtml::listData($groupModels, 'id', 'name'), 'value' => $defaultUserGroup))); // Add User Password Form $definition['elements']['UserPassword'] = array('type' => 'form', 'elements' => array('newPassword' => array('type' => 'password', 'class' => 'form-control', 'maxlength' => 255), 'newPasswordConfirm' => array('type' => 'password', 'class' => 'form-control', 'maxlength' => 255))); // Get Form Definition $definition['buttons'] = array('save' => array('type' => 'submit', 'class' => 'btn btn-primary', 'label' => Yii::t('UserModule.controllers_AuthController', 'Create account'))); $form = new HForm($definition); $form['User']->model = $userModel; $form['UserPassword']->model = $userPasswordModel; $form['Profile']->model = $profileModel; $form['IdenticonForm']->model = $identiconForm; /// ----- WE DONT WANT TO SAVE YET ------- if ($form->submitted('save') && $form->validate() && $identiconForm->validate()) { $this->forcePostRequest(); // Registe User $form['User']->model->email = $userInvite->email; $form['User']->model->language = Yii::app()->getLanguage(); if ($form['User']->model->save()) { // Save User Profile $form['Profile']->model->user_id = $form['User']->model->id; $form['Profile']->model->save(); // Save User Password $form['UserPassword']->model->user_id = $form['User']->model->id; $form['UserPassword']->model->setPassword($form['UserPassword']->model->newPassword); $form['UserPassword']->model->save(); // Autologin user if (!$needApproval) { $user = $form['User']->model; $newIdentity = new UserIdentity($user->username, ''); $newIdentity->fakeAuthenticate(); Yii::app()->user->login($newIdentity); // Prepend Data URI scheme (stripped out for safety) $identiconForm->image = str_replace("[removed]", "data:image/png;base64,", $identiconForm->image); // Upload new Profile Picture for user $this->uploadProfilePicture(Yii::app()->user->guid, $identiconForm->image); // Redirect to dashboard $this->redirect(array('//dashboard/dashboard')); return; } $this->render('createAccount_success', array('form' => $form, 'needApproval' => $needApproval)); return; } } $this->render('createAccount', array('form' => $form, 'identiconForm' => $identiconForm, 'needAproval' => $needApproval)); }
echo $form->error($model, 'status'); ?> </div> <br/> <div class="row"> <?php //$gprofile = Profile::model()->with('groups')->findbyPk($model->id); ?> <?php echo $form->labelEx($profile, 'group_id'); ?> <?php echo TbHtml::activeListBox($profile, 'group_id', TbHtml::listData(Group::model()->findAll(), 'id', 'name'), array('multiple' => 'multiple')); ?> <?php echo $form->error($profile, 'group_id'); ?> </div> <br/> <?php $profileFields = ProfileField::model()->forOwner()->sort()->findAll(); if ($profileFields) { foreach ($profileFields as $field) { if ($field->varname == 'branch_id') { ?> <div class="row"> <?php echo $form->labelEx($profile, $field->varname);
/** * 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(); }