foreach ($tutorials as $tutorial) { if ($tutorial->published == 1) { if (Sentry::check()) { $usere = Sentry::getUser(); $usergroup = $usere->getGroups(); $usergroupe = json_decode($usergroup, true); $usergroupe[0]['pivot']['group_id']; $group = Sentry::findGroupById($usergroupe[0]['pivot']['group_id']); $groupname = $group->name; if ($groupname == 'teachers') { $user = Teacher::findOrFail($usere->id); } elseif ($groupname == 'students') { $user = Student::findOrFail($usere->id); } elseif ($groupname == 'admin') { $userw = Sentry::getUser(); $user = Teacher::findOrFail($userw->id); } $ssubjects = $user->extra; $subjects = unserialize($ssubjects); $truth = 0; if ($subjects != null) { $truth = checkSubject($subjects, $tutorial->subjectid); } if ($truth == 0 && !Sentry::getUser()->inGroup(Sentry::findGroupByName('admin'))) { continue; } } $subject = Subject::find($tutorial->subjectid); $teacher = Teacher::find($tutorial->createdby); $username = Sentry::findUserByLogin($teacher->email); echo "<tr>";
/** * Display a listing of teachers * * @return Response */ public function dashboard() { $data = Auth::Teacher()->get(); $teacher = Teacher::findOrFail($data->id); return View::make('teachers.dashboard')->withTeacher($teacher); }
private function createtutorial($dash) { $user = Sentry::getUser(); $userid = Sentry::getUser()->id; $teacher = Teacher::findOrFail($user->id); $ssubjects = $teacher->extra; $subjects = unserialize($ssubjects); $truth = self::subjectValidator($user->id, $subjects, Input::get('subject')); if ($truth == 0) { if (!Sentry::getUser()->inGroup(Sentry::findGroupByName('admin'))) { return Redirect::to(URL::previous()); } } $tutorial = new Tutorials(); $tutorial->name = Input::get('title'); $tutorial->description = Input::get('description'); $tutorial->content = Input::get('tutorial'); $tutorial->createdby = Sentry::getUser()->id; $tutorial->subjectid = Input::get('subject'); if (Input::get('published') == 'on') { $tutorial->published = 1; } else { $tutorial->published = 0; } $tutorial->save(); $newtutorial = DB::table('tutorials')->orderby('id', 'desc')->first(); if (Input::hasFile('attachments')) { $files = Input::file('attachments'); foreach ($files as $file) { if ($file) { $name = $file->getClientOriginalName(); $file->move(app_path() . '/attachments/tutorial-' . $newtutorial->id . '/', $name); } } } $newid = $newtutorial->id; Cache::forget("tutorial_listing_dash"); return $newid; }
public function manage($dash, $id, $mode) { switch ($mode) { case 'view': $theme = Theme::uses('dashboard')->layout('default'); $view = array('name' => 'Dashboard User', 'id' => $id); $theme->breadcrumb()->add([['label' => 'Dashboard', 'url' => Setting::get('system.dashurl')], ['label' => 'Users', 'url' => Setting::get('system.dashurl') . '/users'], ['label' => $id, 'url' => Setting::get('system.dashurl') . '/user/1/view']]); $theme->setTitle(Setting::get('system.adminsitename') . ' User'); $theme->setType('User'); return $theme->scope('user.view', $view)->render(); break; case 'edit': if (Sentry::getUser()->inGroup(Sentry::findGroupByName('admin'))) { $theme = Theme::uses('dashboard')->layout('default'); $view = array('name' => 'Dashboard User', 'id' => $id); $theme->breadcrumb()->add([['label' => 'Dashboard', 'url' => Setting::get('system.dashurl')], ['label' => 'Users', 'url' => Setting::get('system.dashurl') . '/users'], ['label' => $id, 'url' => Setting::get('system.dashurl') . '/user/1/edit']]); $theme->setTitle(Setting::get('system.adminsitename') . ' User'); $theme->setType('User'); return $theme->scope('user.edit', $view)->render(); } else { return "NOT AUTHORISED"; } break; case 'delete': $user = Sentry::getUser(); // Find the Administrator group $admin = Sentry::findGroupByName('admin'); // Check if the user is in the administrator group if ($user->inGroup($admin)) { $deleteuser = Sentry::findUserById($id); $usergroup = $deleteuser->getGroups(); $usergroupe = json_decode($usergroup, true); $usergroupe[0]['pivot']['group_id']; $group = Sentry::findGroupById($usergroupe[0]['pivot']['group_id']); $groupname = $group->name; if ($groupname == 'teachers') { Teacher::findOrFail($id)->delete(); } elseif ($groupname == 'students') { Student::findOrFail($id)->delete(); } $deleteuser->delete(); return Redirect::to(URL::previous()); } else { return "UNAUTHORISED ACTION"; } break; case 'suspend': $user = Sentry::getUser(); // Find the Administrator group $admin = Sentry::findGroupByName('admin'); // Check if the user is in the administrator group if ($user->inGroup($admin)) { $throttle = Sentry::findThrottlerByUserId($id); // Suspend the user $throttle->suspend(); return Redirect::to(URL::previous()); } else { return "UNAUTHORISED ACTION"; } break; case 'unsuspend': $throttle = Sentry::findThrottlerByUserId($id); // Suspend the user $throttle->unsuspend(); return Redirect::to(URL::previous()); break; case 'ban': $user = Sentry::getUser(); // Find the Administrator group $admin = Sentry::findGroupByName('admin'); // Check if the user is in the administrator group if ($user->inGroup($admin)) { $throttle = Sentry::findThrottlerByUserId($id); // Suspend the user $throttle->ban(); return Redirect::to(URL::previous()); } else { return "UNAUTHORISED ACTION"; } break; case 'unban': $throttle = Sentry::findThrottlerByUserId($id); // Suspend the user $throttle->unban(); return Redirect::to(URL::previous()); break; } }