/** * Start test */ public function startIndexAction() { Assets::reset()->add('main'); $token = $this->getToken(); if (!$token) { return Redirect::route('info')->with('message', 'Токен не найден'); } if ($token->status == Token::TOKEN_STATUS_EMPTY) { /** * вывести форму где пользователь введёт свои данные */ $departments = Department::all(); $groups = Group::all(); $selectedDepartments = array(); $selectGroups = array(); $selectedDepartments[] = 'Не выбран'; $selectGroups[] = 'Не выбран'; foreach ($departments as $department) { $selectedDepartments[$department->id] = $department->name; } foreach ($groups as $group) { $selectGroups[$group->id] = $group->name; } return View::make('test.start', ['token' => $token, 'departments' => $selectedDepartments, 'groups' => $selectGroups]); } elseif ($token->status == Token::TOKEN_STATUS_STARTED) { if ($this->isTokenValid($token)) { return Redirect::route('test.index'); } else { Session::forget('token_string'); $token->status = Token::TOKEN_STATUS_EXPIRED; $token->save(); return Redirect::route('info')->with('message', 'Время теста истекло'); } } }
/** * Execute the console command. * * @return void */ public function fire() { $x = 1; foreach (Group::all() as $group) { $contents = Content::where('group_id', $group->getKey())->count(); $entries = Entry::where('group_id', $group->getKey())->count(); $total = $contents + $entries; // Default activity is medium = 2 $group->activity = 2; // Low activity, when nothing was added last week if ($total == 0) { $group->activity = 1; } if ($total > 15) { $group->activity = 3; } if ($total > 50) { $group->activity = 4; } $group->save(); if (!($x % 100)) { $this->info($x . ' groups processed'); } $x++; } $this->info('All groups processed'); }
public function post_login() { $credentials = array('email' => Input::get('username'), 'password' => Input::get('password')); $remember = Input::has('remember') ? true : false; $rules = array('email' => array('required', 'min:2'), 'password' => array('required', 'min:6')); $messages = array('email.required' => 'È necessario specificare il proprio username e la propria password per accedere', 'email.min' => 'Lo username deve essere lungo almeno 2 caratteri', 'password.required' => 'È necessario specificare il proprio username e la propria password per accedere', 'password.min' => 'La password deve essere lunga almeno 6 caratteri'); $validator = Validator::make($credentials, $rules, $messages); if ($validator->passes()) { try { $user = Sentry::findUserByCredentials($credentials); $groups = Group::all(); if ($user) { foreach ($groups as $group) { if ($user->inGroup($group->name)) { $userAuth = Sentry::authenticate($credentials, $remember); if ($userAuth) { return $this->make_response($credentials, false, array($user->first_name . ' ' . $user->first_last . ', Accesso ' . $group->name . ' consentito'), URL::to('admin/dashboard')); } } } } } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) { return $this->make_response($credentials, true, array('Non hai inserito la password')); } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) { return $this->make_response($credentials, true, array('Utente non trovato')); } catch (Cartalyst\Sentry\Users\WrongPasswordException $e) { return $this->make_response($credentials, true, array('Password o nome utente non corretti')); } catch (\Exception $e) { return $this->make_response($credentials, true, array("errore non previsto: " . $e->getMessage())); } } else { $errors = $validator->messages; return $this->make_response($credentials, true, $errors); } }
public function getEdit($id) { Allow::permission($this->module['group'], 'groups'); if ($id == 1 && !Allow::superuser()) { Redirect(link::auth($this->module['rest'])); } $groups = Group::all(); $group = Group::find($id); $mod_actions = Config::get('mod_actions'); $mod_info = Config::get('mod_info'); #Helper::dd($mod_actions); #Helper::dd($mod_info); $group_actions = Action::where('group_id', $group->id)->get(); #$actions = $group->actions(); $actions = array(); foreach ($group_actions as $action) { #Helper::d($action->status); #continue; if ($action->status) { $actions[$action->module][$action->action] = $action->status; } } #Helper::dd($actions); $group_actions = $actions; return View::make($this->module['tpl'] . 'edit', compact('groups', 'group', 'mod_actions', 'mod_info', 'group_actions')); }
/** * Display a listing of the resource. * * @return Response */ public function index() { //get all the groups $groups = Group::all(); //load the view make and pass the groups return View::make('groups.index')->with('groups', $groups); }
public static function index() { self::check_logged_in(); self::check_admin(); $groups = Group::all(); View::make('group/index.html', array('groups' => $groups)); }
public function add_info() { $groups = Group::all(); $students = Student::all(); $disps = Disp::all(); return view('students.add-info', ['groups' => $groups, 'students' => $students, 'disps' => $disps]); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($schoolName, $surveyName) { $school = School::where('name', '=', $schoolName)->first(); if (!$school) { return Redirect::to('/schools/'); } $survey = Survey::where('name', '=', $surveyName)->first(); if (!$survey) { return Redirect::to("/schools/{$schoolName}"); } $groupStats = array(); foreach (Group::all() as $group) { $possibleLink = $group->surveys()->where('survey_id', $survey->id)->first(); $active = !is_null($possibleLink); $groupInfo = array('group' => $group, 'open_time' => 'no time set', 'close_time' => 'no time set'); if ($active) { $active = strtotime($possibleLink->pivot->open_time) < time() && strtotime($possibleLink->pivot->close_time) > time(); if (strtotime($possibleLink->pivot->open_time)) { $groupInfo['open_time'] = $possibleLink->pivot->open_time; } if (strtotime($possibleLink->pivot->close_time)) { $groupInfo['close_time'] = $possibleLink->pivot->close_time; } } $groupInfo['active'] = $active; array_push($groupStats, $groupInfo); } return View::make('content.surveyShow')->with('school', $school)->with('survey', $survey)->with('groupStats', $groupStats); }
public static function formSelect() { $result = array(); foreach (Group::all() as $group) { $result[$group->id] = $group->name; } return $result; }
public function getHome() { $events = Myevent::all(); $groups = Group::all(); $subgroups = Subgroup::all(); $users = User::all(); return View::make('home')->with('events', $events)->with('groups', $groups)->with('subgroups', $subgroups)->with('users', $users); }
/** * Display a listing of the resource. * * @return Response */ public function index() { // Show a listing of groups. $employeeId = Session::get('userEmployeeId'); $employee = new Employee(); $employeeInfo = $employee->getEmployeeInfoById($employeeId); $groups = Group::all(); return View::make('admin.indexgroup')->with('groups', $groups)->with('employeeInfo', $employeeInfo); }
/** * This is the publicly viewable page, a group of works * identified by the group id * * @param $id The id of the group requested * @return mixed * */ public function home() { // get the groups $groups = Group::all(); $texts = Text::all(); $body_class = 'top-photo'; // show the view and pass the group to it return View::make('pages.home')->with('groups', $groups)->with('texts', $texts)->with('body_class', $body_class)->with('title', 'Sharon Hall'); }
public static function groups() { self::checkLoggedIn(); $user = self::getUserLoggedIn(); if ($user->admin) { $groups = Group::all(); } else { $groups = Group_Member::findGroupByUserId($user->id); } View::make('groups.html', array('groups' => $groups)); }
public function getVerify() { $this->beforeFilter('admin'); $status = Input::get('status'); if ($status) { $groups = Group::where('status', '=', $status)->get(); } else { $groups = Group::all(); } return Response::json($groups); }
public function showDice($groupid = 0) { /** * Steps Involved: * 1. Check if the user has more than one group * 2. IF the user is a part of more than one group then display the * group list or else display the dice */ /** * Get the current user */ $user = Auth::user(); /** * Execute if we are looking for a specific group */ if (!empty($groupid)) { // TODO: either the user should be admin or should be a part of // this group if (!($group = Group::find($groupid))) { App::abort(404); } /** * Check if the user can view the group/post in it */ if (!$user->hasGroup($groupid) && !$user->hasRole('admin')) { App::abort(404); } // Check if the user has a pending task if ($pendingTask = DB::table('user_tasks')->where('user_id', $user->id)->where('group_id', $group->id)->where('complete', 0)->get()) { return Redirect::action('PlayController@showStatusPage', array('id' => $group->id))->with('task', $pendingTask); } return Redirect::action('PlayController@showStatusPage', array('id' => $group->id))->with('task', $pendingTask); // TODO: pass the group id as well...This will help us fetch the // latest task } else { if ($user->getGroupCount() > 1 || $user->hasRole('admin')) { // TODO: Also check if the user can view all the groups if ($user->hasRole('admin')) { $groups = Group::all(); } else { $groups = $user->getGroups(); } $this->layout->content = View::make('play.groups')->with('groups', $groups)->with('user', $user); } elseif ($user->getGroupCount() == 1) { $group = $user->getGroups()->first(); return Redirect::action('PlayController@showStatusPage', array('id' => $group->id)); } elseif ($user->getGroupCount() == 0) { // TODO: tell the user that there are no groups and he/she needs // to be part of atleast one group $this->layout->content = View::make('play.nogroup'); } } }
/** * Execute the console command. * * @return void */ public function fire() { // Generate groups sitemap $sitemap = App::make("sitemap"); $x = 1; foreach (Group::all() as $group) { $sitemap->add(URL::to(route('group_contents', $group->getKey())), null, '1.0', 'daily'); $sitemap->add(URL::to(route('group_contents_new', $group->getKey())), null, '1.0', 'daily'); $sitemap->add(URL::to(route('group_entries', $group->getKey())), null, '1.0', 'daily'); if (!($x % 100)) { $this->info($x . ' groups processed'); } $x++; } $this->info('All groups processed'); $sitemap->store('xml', 'sitemap-groups'); unset($sitemap); // Generate entries sitemap $sitemap = App::make("sitemap"); $x = 1; foreach (Content::all() as $content) { $route = route('content_comments_slug', [$content->getKey(), Str::slug($content->title)]); $sitemap->add(URL::to($route), $content->modified_at, '1.0', 'daily'); if (!($x % 100)) { $this->info($x . ' contents processed'); } $x++; } $this->info('All contents processed'); $sitemap->store('xml', 'sitemap-contents'); unset($sitemap); // Generate contents sitemap $sitemap = App::make("sitemap"); $x = 1; foreach (Entry::all() as $entry) { $route = route('single_entry', $entry->getKey()); $sitemap->add(URL::to($route), $entry->modified_at, '1.0', 'daily'); if (!($x % 100)) { $this->info($x . ' entries processed'); } $x++; } $this->info('All entries processed'); $sitemap->store('xml', 'sitemap-entries'); unset($sitemap); // Generate global sitemap $sitemap = App::make("sitemap"); $sitemap->addSitemap(URL::to('sitemap-groups.xml')); $sitemap->addSitemap(URL::to('sitemap-contents.xml')); $sitemap->addSitemap(URL::to('sitemap-entries.xml')); $sitemap->store('sitemapindex', 'sitemap'); }
/** * Fetch a list of groups based on the value of a given column. Returns empty array if no match is found. * * @param value $value The value to find. (defaults to null, which means return all records in the table) * @param string $name The name of the column to match (defaults to null) * @return array An array of Group objects, indexed by group_id */ public static function fetchAll($value = null, $name = null) { if (!$value || !$name) { $result = Group::all(); } else { $result = Group::where($name, $value)->get(); } $groups = []; foreach ($result as $group) { $groups[$group->id] = $group; } return $groups; }
/** * Execute the console command. * * @return void */ public function fire() { DB::connection()->disableQueryLog(); foreach (Group::all() as $group) { $builder = Content::where('group_id', $group->getKey())->orderBy('uv', 'desc')->take(50); $count = $builder->count(); //$averageUv = $builder->avg('uv'); if ($count < 10) { $threshold = 2; } else { $threshold = $this->median($builder->lists('uv')); $threshold = round($threshold); $threshold = max(2, $threshold); } $group->popular_threshold = $threshold; $group->save(); } }
public static function update($id) { parent::check_logged_in(); $p = $_POST; // because i am a lazy piece of shit $task = Task::find($id); $task->name = $p['name']; $task->description = $p['description']; $task->priority = intval($p['priority']); $task->completed = isset($p['completed']) ? $p['completed'] : false; $errors = $task->validate(); if (count($errors) > 0) { View::make('task/edit.html', array('errors' => $errors, 'attributes' => $p, 'title' => 'edit ' . $task->name, 'groups' => Group::all())); } else { //$task->update(); Task::update($id); Redirect::to('/task/' . $task->id, array('message' => 'Task has been modified successfully.')); } }
/** * @param $id * @return mixed */ public function assign_work($id) { if (Auth::check()) { // store $work = Work::find($id); $links = $work->groups; $arr = array(); foreach ($work->groups as $link) { $arr[] = $link->pivot->group_id; } $groups = Group::all(); // show the edit form and pass the group return View::make('works.assign')->with('work', $work)->with('entity', 'work')->with('links', $links)->with('arr', $arr)->with('groups', $groups)->with('title', 'Assign the work to a group or groups'); // redirect Session::flash('message', 'Successfully assigned work to group(s)'); return Redirect::to('works'); } else { Session::flash('message', 'Please log in'); return Redirect::to('/'); } }
public function run() { DB::table('acl_group_permissions')->truncate(); DB::table('acl_groups')->truncate(); $groups = array(array('name' => 'Super Admin', 'description' => 'Super Admin Account', 'date_created' => new DateTime()), array('name' => 'Admin', 'description' => 'Admin Account', 'date_created' => new DateTime())); DB::table('acl_groups')->insert($groups); $permission = Permission::all(); $grouplist = Group::all(); foreach ($grouplist as $group) { foreach ($permission as $row) { $group_permission = new GroupPermissions(); $group_permission->permission_id = $row->id; $group_permission->group_id = $group->id; $group_permission->save(); } } $operator = array(array('name' => 'Operator', 'description' => 'Operator Account', 'date_created' => new DateTime())); DB::table('acl_groups')->insert($operator); $player = array(array('name' => 'Player', 'description' => 'Player Account', 'date_created' => new DateTime())); DB::table('acl_groups')->insert($player); $this->command->info('Group table seeded!'); }
/** * Display a listing of groups * * @return Response */ public function index() { $groups = Group::all(); return View::make('groups.index', compact('groups')); }
/** * View groups * * @param Request $request * @return mixed */ public function groups_list(Request $request) { $filter = []; if ($request->order) { $filter['order'] = $request->order; } /** @var Listing $paginator */ $paginator = NCService::load('Paginator.Listing', [$request->page, \Group::count()]); $filter = array_merge($filter, $paginator->limit()); // Filter groups $groups = \Group::all($filter); $groups = array_map(function ($i) { return $i->to_array(); }, $groups); return $this->view->render('users/groups.twig', ['title' => $this->lang->translate('user.groups'), 'groups_list' => $groups, 'listing' => $paginator->pages(), 'page' => $paginator->cur_page]); }
$mycourses = unserialize(Auth::user()->courseids); ?> @forelse($mycourses as $courseid) <?php $course = Course::where('uid', '=', $courseid)->first(); ?> <tr><td><a href="{{ URL::to('c/' . $courseid) }}">{{ $courseid }}: {{ $course->name }}</a></td></tr> @empty <tr><td><i>You do not belong to any course groups! Please contact your instructor to add you to the course group.</i></td></tr> @endforelse </table> <hr> <p class="lead">My Groups</p> <table class="table table-condensed"> <?php $allgroups = Group::all(); ?> @forelse($allgroups as $g) <?php $gmembers = unserialize($g->members); ?> @forelse($gmembers as $gm) @if($gm === Auth::user()->id) <tr><td><a href="{{ URL::to('g/' . $g->uid) }}">{{ $g->name }}</a></td></tr> @endif @empty <tr><td><i>You do not belong to any groups! Create a group by clicking the 'Create Group' link at the right or search for a group to join using the search bar at the top right of the page.</i></td></tr> @endforelse @empty <tr><td><i>There are no groups available to join. Click the 'Create Group' link at the right to create a new group!</i></td></tr> @endforelse
public function getEdit($id) { Allow::permission($this->module['group'], 'users'); $groups = Group::all(); $groups_data = array('' => 'Выберите группу'); foreach ($groups as $grp) { $groups_data[$grp->id] = $grp->desc; } $user = User::find($id); return View::make($this->module['tpl'] . 'edit', compact('user', 'groups', 'groups_data')); }
/** * Display a listing of groups * * @return Response */ public function index() { //print_r( Auth::user());die; $groups = Group::all(); return View::make('groups.index', compact('groups')); }
public function getVerify() { $this->beforeFilter('admin'); $groups = Group::all(); return Response::json($groups); }
public function findAllGroups() { $groups = \Group::all(); return $groups; }
/** * Renders the form for creating a new user. * * This does NOT render a complete page. Instead, it renders the HTML for the form, which can be embedded in other pages. * The form can be rendered in "modal" (for popup) or "panel" mode, depending on the value of the GET parameter `render`. * If the currently logged-in user has permission to modify user group membership, then the group toggles will be displayed. * Otherwise, the user will be added to the default groups automatically. * This page requires authentication. * Request type: GET */ public function formUserCreate() { // Access-controlled resource if (!$this->_app->user->checkAccess('create_account')) { $this->_app->notFound(); } $get = $this->_app->request->get(); if (isset($get['render'])) { $render = $get['render']; } else { $render = "modal"; } // Get a list of all groups $groups = Group::all()->getDictionary(); // Get a list of all locales $locale_list = $this->_app->site->getLocales(); // Get default primary group (is_default = GROUP_DEFAULT_PRIMARY) $primary_group = Group::where("is_default", GROUP_DEFAULT_PRIMARY)->first(); // If there is no default primary group, there is a problem. Show an error message for now. if (!$primary_group) { $this->_app->alerts->addMessageTranslated("danger", "GROUP_DEFAULT_PRIMARY_NOT_DEFINED"); $this->_app->halt(500); } // Get the default groups $default_groups = Group::all()->where("is_default", GROUP_DEFAULT)->getDictionary(); // Set default groups, including default primary group foreach ($groups as $group_id => $group) { $group_list[$group_id] = $group->export(); if (isset($default_groups[$group_id]) || $group_id == $primary_group->id) { $group_list[$group_id]['member'] = true; } else { $group_list[$group_id]['member'] = false; } } $data['primary_group_id'] = $primary_group->id; // Set default title for new users $data['title'] = $primary_group->new_user_title; // Set default locale $data['locale'] = $this->_app->site->default_locale; // Create a dummy user to prepopulate fields $target_user = new User($data); if ($render == "modal") { $template = "components/common/user-info-modal.twig"; } else { $template = "components/common/user-info-panel.twig"; } // Determine authorized fields for those that have default values. Don't hide any fields $fields = ['title', 'locale', 'groups', 'primary_group_id']; $show_fields = []; $disabled_fields = []; $hidden_fields = []; foreach ($fields as $field) { if ($this->_app->user->checkAccess("update_account_setting", ["user" => $target_user, "property" => $field])) { $show_fields[] = $field; } else { $disabled_fields[] = $field; } } // Load validator rules $schema = new \Fortress\RequestSchema($this->_app->config('schema.path') . "/forms/user-create.json"); $this->_app->jsValidator->setSchema($schema); $this->_app->render($template, ["box_id" => $get['box_id'], "box_title" => "Create User", "submit_button" => "Create user", "form_action" => $this->_app->site->uri['public'] . "/users", "target_user" => $target_user, "groups" => $group_list, "locales" => $locale_list, "fields" => ["disabled" => $disabled_fields, "hidden" => $hidden_fields], "buttons" => ["hidden" => ["edit", "enable", "delete", "activate"]], "validators" => $this->_app->jsValidator->rules()]); }
/** * This function returns the list of all the groups that the logged in user * has access to * @return JSON groupList */ public function getGroupList() { $user = Auth::user(); if ($user->hasRole('admin')) { $groups = Group::all(); } else { //$groups = $user->getGroups(); //Group::all(); //print_r($groups); $groups = Group::where('keycode', '=', $user->keycode)->get(); //$groups = $groups[0]; //print_r($user->keycode); } foreach ($groups as $group) { $group->members = $group->getUserCount(); $group->thumbnailSrc = $group->APIGetThumbnailSrc(); $group->preSurveyCompleted = $user->preSurveyCompleted($group->id); $group->postSurveyCompleted = $user->postSurveyCompleted($group->id); $group->daysPassed = daysDiff(new DateTime($user->created_at), new DateTime('now')) + 1; } //TODO: Get the user progress in group return $groups->toJson(); }