Ejemplo n.º 1
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $this->theme->title(trans('pages.admin_roles_title'));
     $this->theme->description(trans('pages.admin_roles_desc'));
     $roles = Role::orderBy('created_at', 'desc')->paginate(AppConfig::DEFAULT_ITEMS_PER_PAGE);
     // 2 items per page
     $query = new QueryStringBuilder(['page' => $roles->currentPage()], adminUrl('user-roles'));
     return $this->_list(['roles' => $roles, 'query' => $query, 'page_helper' => new PaginationHelper($roles->lastPage(), $roles->currentPage(), $roles->perPage())]);
 }
Ejemplo n.º 2
0
 public function run()
 {
     $admin_access_permission = Permission::create(['name' => 'access-admin', 'display_name' => 'Access admin', 'description' => 'Access admin pages']);
     $owner_role = Role::create(array('name' => 'owner', 'display_name' => 'Owner', 'description' => 'Owner of the system', 'status' => Role::STATUS_HIDDEN));
     $owner_role->attachPermission($admin_access_permission);
     $admin_role = Role::create(array('name' => 'admin', 'display_name' => 'Administrator', 'description' => 'Manage operation of the system and important modules'));
     $admin_role->attachPermission($admin_access_permission);
     $tester_role = Role::create(array('name' => 'tester', 'display_name' => 'Tester', 'description' => 'Tester of the system', 'status' => Role::STATUS_HIDDEN));
     $tester_role->attachPermission($admin_access_permission);
     $user_role = Role::create(array('name' => 'user', 'display_name' => 'User', 'description' => 'Normal user'));
     // TODO: Add 1 administrator
     $owner = User::create(array('display_name' => 'Owner', 'name' => 'owner', 'email' => '*****@*****.**', 'password' => bcrypt(')^KM$bB-W7:Z@8eG'), 'url_avatar' => appDefaultUserProfilePicture(), 'url_avatar_thumb' => appDefaultUserProfilePicture(), 'activation_code' => str_random(32), 'active' => true));
     $owner->attachRole($owner_role);
     $admin = User::create(array('display_name' => 'Administrator', 'name' => 'admin', 'email' => '*****@*****.**', 'password' => bcrypt('123456'), 'url_avatar' => appDefaultUserProfilePicture(), 'url_avatar_thumb' => appDefaultUserProfilePicture(), 'activation_code' => str_random(32), 'active' => true));
     $admin->attachRoles([$admin_role, $owner_role]);
     $tester = User::create(array('display_name' => 'Tester', 'name' => 'tester', 'email' => '*****@*****.**', 'password' => bcrypt('123456'), 'url_avatar' => appDefaultUserProfilePicture(), 'url_avatar_thumb' => appDefaultUserProfilePicture(), 'activation_code' => str_random(32), 'active' => true));
     $tester->attachRole($tester_role);
     $locales = ['en', 'vi'];
     $category = new Category();
     $category->type = Category::LINK;
     $data = ['en' => ['name' => 'Example link category', 'slug' => 'example-link-category', 'description' => 'Example link category'], 'vi' => ['name' => 'Chuyên mục liên kết ví dụ', 'slug' => 'chuyen-muc-lien-ket-vi-du', 'description' => 'Chuyên mục liên kết ví dụ']];
     foreach ($locales as $locale) {
         $transData = $data[$locale];
         $trans = $category->translateOrNew($locale);
         $trans->name = $transData['name'];
         $trans->slug = $transData['slug'];
         $trans->description = $transData['description'];
     }
     $category->save();
     $data = [['en' => ['name' => 'Author on Facebook', 'url' => 'https://www.facebook.com/linhntaim', 'description' => 'Author on Facebook'], 'vi' => ['name' => 'Hồ sơ tác giả trên Facebook', 'url' => 'https://www.facebook.com/linhntaim', 'description' => 'Hồ sơ tác giả trên Facebook']], ['en' => ['name' => 'Author\'s Personal Site', 'url' => 'http://linhntaim.com', 'description' => 'Author\'s Personal Site'], 'vi' => ['name' => 'Trang cá nhân của tác giả', 'url' => 'http://linhntaim.com', 'description' => 'Trang cá nhân của tác giả']], ['en' => ['name' => 'Katniss on Github', 'url' => 'https://github.com/linhntaim/katniss', 'description' => 'Katniss on Github'], 'vi' => ['name' => 'Katniss trên Github', 'url' => 'https://github.com/linhntaim/katniss', 'description' => 'Katniss trên Github']]];
     foreach ($data as $item) {
         $link = new Link();
         foreach ($locales as $locale) {
             $transData = $item[$locale];
             $trans = $link->translateOrNew($locale);
             $trans->name = $transData['name'];
             $trans->description = $transData['description'];
             $trans->url = $transData['url'];
         }
         $link->save();
         $link->categories()->attach($category->id);
     }
     ThemeWidget::create(['widget_name' => 'base_links', 'theme_name' => '', 'placeholder' => 'default_placeholder', 'constructing_data' => '{"category_id":"' . $category->id . '","en":{"name":"Widget named Base Links","description":""},"vi":{"name":"Ví dụ về Công cụ hiển thị Base Links","description":""}}', 'active' => true, 'order' => 1]);
     ThemeWidget::create(['widget_name' => 'extra_html', 'theme_name' => '', 'placeholder' => 'default_placeholder', 'constructing_data' => '{"en":{"name":"Widget named Extra HTML","description":"","content":"<p><strong>Lorem Ipsum<\\/strong><sup>&reg;<\\/sup> is simply dummy text of the <em>printing and typesetting industry<\\/em>. <span style=\\"color:#FFFF00\\"><span style=\\"background-color:#000000\\">Lorem Ipsum<\\/span><\\/span> has been the industry&#39;s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like <span style=\\"font-size:16px\\">Aldus PageMaker <\\/span>including versions of <em><strong><u>Lorem Ipsum<\\/u><\\/strong><\\/em>. <img alt=\\"smiley\\" src=\\"http:\\/\\/katniss.linhntaim.com\\/assets\\/libraries\\/ckeditor-4.5.5\\/plugins\\/smiley\\/images\\/regular_smile.png\\" style=\\"height:23px; width:23px\\" title=\\"smiley\\"><\\/p>\\r\\n\\r\\n<p><img alt=\\"\\" src=\\"http:\\/\\/katniss.linhntaim.com\\/files\\/user_2\\/katniss.png\\" style=\\"height:120px; width:120px\\"><\\/p>\\r\\n"},"vi":{"name":"V\\u00ed d\\u1ee5 v\\u1ec1 C\\u00f4ng c\\u1ee5 hi\\u1ec3n th\\u1ecb Extra HTML","description":"","content":"<p><strong>Lorem Ipsum<\\/strong><sup>&reg;<\\/sup> is simply dummy text of the <em>printing and typesetting industry<\\/em>. <span style=\\"color:#FFFF00\\"><span style=\\"background-color:#000000\\">Lorem Ipsum<\\/span><\\/span> has been the industry&#39;s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like <span style=\\"font-size:16px\\">Aldus PageMaker <\\/span>including versions of <em><strong><u>Lorem Ipsum<\\/u><\\/strong><\\/em>. <img alt=\\"smiley\\" src=\\"http:\\/\\/katniss.linhntaim.com\\/assets\\/libraries\\/ckeditor-4.5.5\\/plugins\\/smiley\\/images\\/regular_smile.png\\" style=\\"height:23px; width:23px\\" title=\\"smiley\\"><\\/p>\\r\\n\\r\\n<p><img alt=\\"\\" src=\\"http:\\/\\/katniss.linhntaim.com\\/files\\/user_2\\/katniss.png\\" style=\\"height:120px; width:120px\\"><\\/p>\\r\\n"}}', 'active' => true, 'order' => 2]);
 }
Ejemplo n.º 3
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param array $data
  * @param boolean $fromSocial
  * @return User
  */
 protected function create(array $data, $fromSocial = false)
 {
     DB::beginTransaction();
     try {
         $user = User::create(['display_name' => $data['display_name'], 'email' => $data['email'], 'name' => $data['name'], 'password' => bcrypt($data['password']), 'url_avatar' => $data['url_avatar'], 'url_avatar_thumb' => $data['url_avatar'], 'activation_code' => str_random(32)]);
         $defaultRole = Role::where('name', 'user')->firstOrFail();
         $user->attachRole($defaultRole->id);
         if ($fromSocial) {
             $user->socialProviders()->save(new UserSocial(['provider' => $data['provider'], 'provider_id' => $data['provider_id']]));
         }
         DB::commit();
     } catch (\Exception $ex) {
         DB::rollBack();
         return false;
     }
     return $user;
 }
Ejemplo n.º 4
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int $id
  * @return Response
  */
 public function edit(Request $request, $id)
 {
     $user = User::findOrFail($id);
     $this->theme->title([trans('pages.admin_users_title'), trans('form.action_edit')]);
     $this->theme->description(trans('pages.admin_users_desc'));
     return $this->_edit(['user' => $user, 'user_roles' => $user->roles, 'roles' => Role::haveStatuses([Role::STATUS_NORMAL])->get(), 'date_js_format' => DateTimeHelper::shortDatePickerJsFormat()]);
 }