Esempio n. 1
0
 /**
  * Delete the specified group
  *
  * @param Group $group
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  * @throws \Exception
  */
 public function destroy(Group $group)
 {
     $this->authorize('edit_users');
     $group->delete();
     flash()->success('Group Deleted', 'The group has been removed');
     return redirect('group');
 }
Esempio n. 2
0
 /**
  * @param Group $Group
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function destroy(Group $Group)
 {
     if ($count = $Group->users->count()) {
         return redirect(route('admin.groups.list'))->with('error', "В группе есть пользователи ({$count})");
     }
     $Group->delete();
     return redirect(route('admin.groups.list'));
 }
Esempio n. 3
0
 /**
  * @param Event $event
  */
 public function handle(Event $event)
 {
     $cloneModel = $this->clone->find($event->request['clone_id']);
     $group = $this->group->find($event->request['group_id']);
     $sitePath = Str::camel($event->request['name']);
     $event->site->updateStatus('Cloning the repo');
     $this->envoy->run('clone --path="' . $group->starting_path . '" --name="' . $sitePath . '" --url=' . $cloneModel->url, true);
 }
Esempio n. 4
0
 /**
  * @param Event $event
  */
 public function handle(Event $event)
 {
     $event->site->updateStatus('Running the installer');
     $installerType = $event->request['installType'] == 'base' ? null : '"--' . $event->request['installType'] . '"';
     $group = $this->group->find($event->request['group_id']);
     $sitePath = Str::camel($event->request['name']);
     $this->envoy->run('make-site --path="' . $group->starting_path . '" --name="' . $sitePath . '" --type=' . $installerType, true);
 }
Esempio n. 5
0
 /**
  * 项目添加用户
  *
  * @param $projectId
  * @param $userId
  * @return bool
  */
 public static function addGroupUser($projectId, $userId)
 {
     // 是否已在组内
     $exists = Group::find()->where(['project_id' => $projectId, 'user_id' => $userId])->count();
     if ($exists) {
         return true;
     }
     $group = new Group();
     $group->attributes = ['project_id' => $projectId, 'user_id' => $userId];
     return $group->save();
 }
 /**
  * Run the migrations.
  */
 public function up()
 {
     Schema::create('groups', function ($table) {
         $table->increments('id');
         $table->string('name');
         $table->string('address1');
         $table->string('address2');
         $table->string('city');
         $table->string('state');
         $table->string('postal_code');
         $table->string('phone_number');
         $table->string('display_name');
         $table->enum('status', Group::getStatuses());
         $table->timestamps();
         $table->softDeletes();
     });
     Schema::create('group_members', function ($table) {
         $table->increments('id');
         $table->integer('group_id')->unsigned();
         $table->integer('user_id')->unsigned();
         $table->enum('role', Group::getRoles());
         $table->timestamps();
         $table->softDeletes();
         $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
         $table->foreign('group_id')->references('id')->on('groups')->onDelete('cascade');
     });
 }
 public function all($params)
 {
     $params['order'] = isset($params['order']) ? $params['order'] : ['display_name|ASC'];
     $groups = Group::select("groups.*");
     $groups = parent::execute($groups, $params);
     return $groups;
 }
 public function actionSubcat()
 {
     $out = [];
     $isEmpty = true;
     if (isset($_POST['depdrop_parents'])) {
         $parents = $_POST['depdrop_parents'];
         if ($parents != null) {
             $cat_id = $parents[0];
             $out = Group::getDropDownList($cat_id);
             //$out = [['id'=>'1', 'name'=>$cat_id],['id'=>'2', 'name'=>json_encode(Group::getDropDownList($cat_id))]];
             $isEmpty = false;
             $selected = '';
             if (!empty($_POST['depdrop_params'])) {
                 $params = $_POST['depdrop_params'];
                 $selected = $params[0];
                 // get the value of input-type-1
                 $param2 = $params[1];
                 // get the value of input-type-2
             }
             echo Json::encode(['output' => $out, 'selected' => $selected]);
         }
     }
     if ($isEmpty) {
         echo Json::encode(['output' => [['id' => '1', 'name' => '<sub-cat-name1>'], ['id' => '2', 'name' => '<sub-cat-name2>']], 'selected' => '']);
     }
 }
Esempio n. 9
0
 public function delete($id)
 {
     if (Group::destroy($id)) {
         return redirect()->back()->with('msg', 'Группа удалена');
     }
     return redirect()->back()->with('warning', 'Не удалось удалить');
 }
Esempio n. 10
0
 public function portfolioItem($groupLink, $id)
 {
     $group = Group::where('link', '=', $groupLink)->firstOrFail();
     $portfolios = PortfolioRepository::byGroup($groupLink);
     $view = Agent::isTablet() || Request::has('t') ? 'tablet.portfolio_item' : (Agent::isMobile() || Request::has('m') ? 'mobile.portfolio_item' : 'index.portfolio_item');
     return view($view, array('group' => $group, 'portfolios' => $portfolios, 'id' => $id, 'title' => $group->title . ' | TWIGA'));
 }
Esempio n. 11
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $data['groups'] = Group::orderBy('groupname')->get();
     $data['setting'] = Setting::find($id);
     $data['themes'] = array('cerulean' => 'cerulean', 'cosmo' => 'cosmo', 'cyborg' => 'cyborg', 'darkly' => 'darkly', 'flatly' => 'flatly', 'journal' => 'journal', 'lumen' => 'lumen', 'paper' => 'paper', 'readable' => 'readable', 'sandstone' => 'sandstone', 'simplex' => 'simplex', 'slate' => 'slate', 'spacelab' => 'spacelab', 'superhero' => 'superhero', 'united' => 'united', 'yeti' => 'yeti');
     return View::make('settings.edit', $data);
 }
Esempio n. 12
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit(User $User)
 {
     $this->data['Roles'] = Role::all();
     $this->data['Groups'] = Group::all();
     $this->data['User'] = $User;
     return view('admin.users.edit', $this->data);
 }
Esempio n. 13
0
 /**
  * 提交任务
  *
  * @param $projectId
  * @return string
  */
 public function actionSubmit($projectId = null)
 {
     $task = new Task();
     if ($projectId) {
         $conf = Project::find()->where(['id' => $projectId, 'status' => Project::STATUS_VALID])->one();
     }
     if (\Yii::$app->request->getIsPost()) {
         if (!$conf) {
             throw new \Exception('未知的项目,请确认:)');
         }
         $group = Group::find()->where(['user_id' => $this->uid, 'project_id' => $projectId])->count();
         if (!$group) {
             throw new \Exception('非该项目成员,无权限');
         }
         if ($task->load(\Yii::$app->request->post())) {
             // 是否需要审核
             $status = $conf->audit == Project::AUDIT_YES ? Task::STATUS_SUBMIT : Task::STATUS_PASS;
             $task->user_id = $this->uid;
             $task->project_id = $projectId;
             $task->status = $status;
             if ($task->save()) {
                 $this->redirect('/task/');
             }
         }
     }
     if ($projectId) {
         return $this->render('submit', ['task' => $task, 'conf' => $conf]);
     }
     // 成员所属项目
     $projects = Project::find()->leftJoin(Group::tableName(), '`group`.project_id=project.id')->where(['project.status' => Project::STATUS_VALID, '`group`.user_id' => $this->uid])->asArray()->all();
     return $this->render('select-project', ['projects' => $projects]);
 }
Esempio n. 14
0
 public function run()
 {
     $adminEmail = Config::get('madison.seeder.admin_email');
     $adminPassword = Config::get('madison.seeder.admin_password');
     // Login as admin to create docs
     $credentials = array('email' => $adminEmail, 'password' => $adminPassword);
     Auth::attempt($credentials);
     $admin = Auth::user();
     $group = Group::where('id', '=', 1)->first();
     // Create first doc
     $docSeedPath = app_path() . '/database/seeds/example.md';
     if (file_exists($docSeedPath)) {
         $content = file_get_contents($docSeedPath);
     } else {
         $content = "New Document Content";
     }
     $docOptions = array('title' => 'Example Document', 'content' => $content, 'sponsor' => $group->id, 'publish_state' => 'published', 'sponsorType' => Doc::SPONSOR_TYPE_GROUP);
     $document = Doc::createEmptyDocument($docOptions);
     //Set first doc as featured doc
     $featuredSetting = new Setting();
     $featuredSetting->meta_key = 'featured-doc';
     $featuredSetting->meta_value = $document->id;
     $featuredSetting->save();
     // Create second doc
     $docSeedPath = app_path() . '/database/seeds/example2.md';
     if (file_exists($docSeedPath)) {
         $content = file_get_contents($docSeedPath);
     } else {
         $content = "New Document Content";
     }
     $docOptions = array('title' => 'Second Example Document', 'sponsor' => $group->id, 'publish_state' => 'published', 'sponsorType' => Doc::SPONSOR_TYPE_GROUP);
     $document = Doc::createEmptyDocument($docOptions);
 }
Esempio n. 15
0
 public function putVerify($groupId)
 {
     $this->beforeFilter('admin');
     $newGroup = (object) Input::all();
     if (!Group::isValidStatus($newGroup->status)) {
         throw new \Exception("Invalid value for verify request");
     }
     $group = Group::where('id', '=', $groupId)->first();
     if (!$group) {
         throw new \Exception("Invalid Group");
     }
     $group->status = $newGroup->status;
     DB::transaction(function () use($group) {
         $group->save();
         switch ($group->status) {
             case Group::STATUS_ACTIVE:
                 $group->createRbacRules();
                 break;
             case Group::STATUS_PENDING:
                 $group->destroyRbacRules();
                 break;
         }
     });
     return Response::json($group);
 }
Esempio n. 16
0
 public function run()
 {
     $total = [];
     foreach (Group::find()->all() as $key => $group) {
         $total[$group->name] = GroupClient::find()->where(['groups_id' => $group->id])->count();
     }
     return $this->render('groups/index', ['group' => new Group(), 'total' => $total]);
 }
Esempio n. 17
0
 /**
  * Finds the User model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return User the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Group::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('groups', function (Blueprint $table) {
         $table->increments('id');
         $table->string('name');
         $table->timestamps();
         $table->softDeletes();
         $table->unsignedInteger('created_user_id')->nullable();
         $table->unsignedInteger('updated_user_id')->nullable();
         $table->unsignedInteger('deleted_user_id')->nullable();
     });
     foreach (['System', 'Admin', 'Develop', 'Guest', '*', '*', '*', '*', '*', '*'] as $key => $value) {
         $group = new Group();
         $group->name = $value;
         $group->save();
     }
 }
Esempio n. 19
0
 private function load(Request $request, &$data, $params)
 {
     $columnsInfo = ['name' => ['alias' => 'نام', 'class' => \App\User::class], 'email' => ['alias' => 'ایمیل', 'class' => \App\User::class], 'group_id' => ['alias' => 'گروه کاربری', 'class' => \App\Models\Group::class, 'wherethrough' => ['key' => 'alias', 'value' => 'id']]];
     $data['user']['info'] = Filter::Rendering(\App\User::class, $columnsInfo, $params['search'], $params['perPage']);
     //        \Symfony\Component\VarDumper\VarDumper::dump($data['user']['info']);
     $data['user']['load'] = \App\Models\Group::all();
     $data['params'] = $params;
     $this->init_data($request, $data);
 }
 /**
  * Return a user with specified permission
  *
  * @return \___PHPSTORM_HELPERS\static|mixed
  */
 protected function getUserWithPermission($permission = 'admin')
 {
     $user = App\User::find(46);
     $groups = App\Models\Group::all();
     foreach ($groups as $group) {
         if ($group->hasPermission($permission)) {
             $user = App\User::fromGroup($group)->first();
         }
     }
     return $user;
 }
Esempio n. 21
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Group::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
Esempio n. 22
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Group::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['p_id' => $this->p_id]);
     $query->andFilterWhere(['like', 'bezeichnung', $this->bezeichnung]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Group::find();
     $pageSize = Yii::$app->session->get('pageSize', Yii::$app->params['defaultPageSize']);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => $pageSize]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['p_id' => $this->p_id]);
     $query->andFilterWhere(['like', 'bezeichnung', $this->bezeichnung]);
     return $dataProvider;
 }
Esempio n. 24
0
 public function showGallery()
 {
     $app = Yii::$app;
     $groups = Group::getRoots();
     $products = [];
     if (!empty($groups)) {
         $default_group = $groups[0]->id;
         $group = $app->request->getQueryParam('group', $default_group);
         $products = Group::findOne($group)->linkedProducts;
     }
     return $this->renderPartial('_gallery', ['groups' => (array) $groups, 'products' => (array) $products]);
 }
 public function groups()
 {
     $groups = Group::find('all', array('conditions' => array('y2011' => array('$gte' => 0)), 'order' => array('name' => 'asc'), 'limit' => 9))->to('array');
     $total = 0;
     foreach ($groups as $group) {
         $total += $group['y2011'];
     }
     foreach ($groups as &$group) {
         $group['percentage'] = round($group['y2011'] / $total, 4);
     }
     return compact('total', 'groups');
 }
Esempio n. 26
0
 public function run()
 {
     DB::statement('TRUNCATE TABLE t_px_group CASCADE');
     $group = Group::create(array('name' => '超级管理员'));
     $group->permissions()->sync(['setting.edit', 'user.add', 'user.edit', 'user.show', 'user.list', 'user.save', 'user.update', 'user.delete', 'user.reset', 'user.change', 'user.saveChange', 'user.profile', 'group.add', 'group.edit', 'group.show', 'group.list', 'group.save', 'group.update', 'group.delete', 'group.grant', 'group.saveGrant', 'permission.add', 'permission.edit', 'permission.show', 'permission.list', 'permission.save', 'permission.update', 'permission.delete', 'pjzb.add', 'pjzb.edit', 'pjzb.show', 'pjzb.list', 'pjzb.save', 'pjzb.update', 'pjzb.delete', 'pjbz.add', 'pjbz.edit', 'pjbz.show', 'pjbz.list', 'pjbz.save', 'pjbz.update', 'pjbz.delete', 'pfdj.add', 'pfdj.edit', 'pfdj.show', 'pfdj.list', 'pfdj.save', 'pfdj.update', 'pfdj.delete', 'pfjg.monitor', 'pfjg.departmentMonitor', 'pfjg.statistics', 'pfjg.departmentStatistics', 'pfjg.majorStatistics', 'pfjg.exportMonitor', 'pfjg.exportDepartmentMonitor', 'pfjg.exportStatistics', 'pfjg.exportDepartmentStatistics', 'pfjg.exportMajorStatistics']);
     $group = Group::create(array('name' => '年级辅导员'));
     $group->permissions()->sync(['user.change', 'user.saveChange', 'user.profile', 'pfjg.majorStatistics', 'pfjg.exportMajorStatistics']);
     $group = Group::create(array('name' => '教学秘书'));
     $group->permissions()->sync(['user.change', 'user.saveChange', 'user.profile', 'pfjg.departmentMonitor', 'pfjg.exportDepartmentMonitor', 'pfjg.departmentStatistics', 'pfjg.exportDepartmentStatistics']);
     $group = Group::create(array('name' => '学校领导'));
     $group->permissions()->sync(['user.change', 'user.saveChange', 'user.profile', 'pfjg.statistics', 'pfjg.exportStatistics']);
 }
Esempio n. 27
0
 /**
  * Use first criteria to get a list of all possible groups for the search.
  * This will be further reduced by other criteria elsewhere.
  * @return mixed
  */
 private function getSuperset()
 {
     // Pull the first category
     $cat = array_shift($this->categories);
     // Get the tags for the category choices
     $tags = $this->getTagList($cat);
     // Save the full list of groups
     $this->allGroups = Group::whereHas('tags', function ($q) use($tags) {
         $q->whereIn('tag_id', $tags);
     })->with(['tags' => function ($q) {
         $q->select('tags.id', 'tags.name');
     }])->get()->toArray();
 }
Esempio n. 28
0
 public function run()
 {
     $group = new Group();
     $group->status = Group::STATUS_ACTIVE;
     $group->name = 'Example Group';
     $group->display_name = 'Example Group Display';
     $group->address1 = '1234 Somewhere';
     $group->city = 'City';
     $group->state = 'DC';
     $group->postal_code = '12345';
     $group->phone_number = '555-555-5555';
     $group->save();
     $adminEmail = Config::get('madison.seeder.admin_email');
     $adminPassword = Config::get('madison.seeder.admin_password');
     $userEmail = Config::get('madison.seeder.user_email');
     // Login as admin to add members to group
     $credentials = array('email' => $adminEmail, 'password' => $adminPassword);
     Auth::attempt($credentials);
     $admin = User::where('email', '=', $adminEmail)->first();
     $user = User::where('email', '=', $userEmail)->first();
     $group->addMember($admin->id, Group::ROLE_OWNER);
     $group->addMember($user->id, Group::ROLE_EDITOR);
 }
Esempio n. 29
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Group::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'nama', $this->nama]);
     return $dataProvider;
 }
Esempio n. 30
-1
 public function getEdit($id)
 {
     $user = User::find($id);
     $departments = Department::orderBy('dw', 'asc')->get();
     $majors = Major::orderBy('zy', 'asc')->get();
     $groups = Group::orderBy('id', 'asc')->get();
     return view('user.edit', ['title' => '编辑用户', 'user' => $user, 'departments' => $departments, 'majors' => $majors, 'groups' => $groups]);
 }