Example #1
0
 public function getClone($id = null)
 {
     // We need to reverse the UI specific logic for our
     // permissions here before we update the user.
     $permissions = Input::get('permissions', array());
     $this->decodePermissions($permissions);
     app('request')->request->set('permissions', $permissions);
     try {
         // Get the user information
         $user_to_clone = Sentry::getUserProvider()->findById($id);
         $user = clone $user_to_clone;
         $user->first_name = '';
         $user->last_name = '';
         $user->email = substr($user->email, ($pos = strpos($user->email, '@')) !== false ? $pos : 0);
         $user->id = null;
         // Get this user groups
         $userGroups = $user_to_clone->groups()->lists('group_id', 'name');
         // Get this user permissions
         $userPermissions = array_merge(Input::old('permissions', array('superuser' => -1)), $user_to_clone->getPermissions());
         $this->encodePermissions($userPermissions);
         // Get a list of all the available groups
         $groups = Sentry::getGroupProvider()->findAll();
         // Get all the available permissions
         $permissions = Config::get('permissions');
         $this->encodeAllPermissions($permissions);
         $location_list = array('' => '') + Location::lists('name', 'id');
         $company_list = companyList();
         $manager_list = array('' => 'Select a User') + DB::table('users')->select(DB::raw('concat(last_name,", ",first_name," (",email,")") as full_name, id'))->whereNull('deleted_at')->where('id', '!=', $id)->orderBy('last_name', 'asc')->orderBy('first_name', 'asc')->lists('full_name', 'id');
         // Show the page
         return View::make('backend/users/edit', compact('groups', 'userGroups', 'permissions', 'userPermissions'))->with('location_list', $location_list)->with('company_list', $company_list)->with('manager_list', $manager_list)->with('user', $user)->with('clone_user', $user_to_clone);
     } catch (UserNotFoundException $e) {
         // Prepare the error message
         $error = Lang::get('admin/users/message.user_not_found', compact('id'));
         // Redirect to the user management page
         return Redirect::route('users')->with('error', $error);
     }
 }
 public function getClone($licenseId = null)
 {
     // Check if the license exists
     if (is_null($license_to_clone = License::find($licenseId))) {
         // Redirect to the blogs management page
         return Redirect::to('admin/licenses')->with('error', Lang::get('admin/licenses/message.does_not_exist'));
     } else {
         if (!Company::isCurrentUserHasAccess($license_to_clone)) {
             return Redirect::to('admin/licenses')->with('error', Lang::get('general.insufficient_permissions'));
         }
     }
     // Show the page
     $license_options = array('0' => 'Top Level') + License::lists('name', 'id');
     $maintained_list = array('' => 'Maintained', '1' => 'Yes', '0' => 'No');
     $company_list = companyList();
     //clone the orig
     $license = clone $license_to_clone;
     $license->id = null;
     $license->serial = null;
     // Show the page
     $depreciation_list = array('0' => Lang::get('admin/licenses/form.no_depreciation')) + Depreciation::lists('name', 'id');
     $supplier_list = array('' => 'Select Supplier') + Supplier::orderBy('name', 'asc')->lists('name', 'id');
     return View::make('backend/licenses/edit')->with('license_options', $license_options)->with('depreciation_list', $depreciation_list)->with('supplier_list', $supplier_list)->with('license', $license)->with('maintained_list', $maintained_list)->with('company_list', $company_list);
 }
 /**
  * Accessory update.
  *
  * @param  int  $accessoryId
  * @return View
  */
 public function getEdit($accessoryId = null)
 {
     // Check if the accessory exists
     if (is_null($accessory = Accessory::find($accessoryId))) {
         // Redirect to the blogs management page
         return Redirect::to('admin/accessories')->with('error', Lang::get('admin/accessories/message.does_not_exist'));
     } else {
         if (!Company::isCurrentUserHasAccess($accessory)) {
             return Redirect::to('admin/accessories')->with('error', Lang::get('general.insufficient_permissions'));
         }
     }
     $category_list = array('' => '') + DB::table('categories')->where('category_type', '=', 'accessory')->whereNull('deleted_at')->orderBy('name', 'ASC')->lists('name', 'id');
     $company_list = companyList();
     $location_list = locationsList();
     return View::make('backend/accessories/edit', compact('accessory'))->with('category_list', $category_list)->with('company_list', $company_list)->with('location_list', $location_list);
 }
Example #4
0
 /**
  *  Display bulk edit screen
  *
  * @return View
  **/
 public function postBulkEdit($assets = null)
 {
     if (!Company::isCurrentUserAuthorized()) {
         return Redirect::to('hardware')->with('error', Lang::get('general.insufficient_permissions'));
     } elseif (!Input::has('edit_asset')) {
         return Redirect::back()->with('error', 'No assets selected');
     } else {
         $asset_raw_array = Input::get('edit_asset');
         foreach ($asset_raw_array as $asset_id => $value) {
             $asset_ids[] = $asset_id;
         }
     }
     if (Input::has('bulk_actions')) {
         // Create labels
         if (Input::get('bulk_actions') == 'labels') {
             $settings = Setting::getSettings();
             if ($settings->qr_code == '1') {
                 $assets = Asset::find($asset_ids);
                 $assetcount = count($assets);
                 $count = 0;
                 return View::make('backend/hardware/labels')->with('assets', $assets)->with('settings', $settings)->with('count', $count);
             } else {
                 // QR codes are not enabled
                 return Redirect::to("hardware")->with('error', 'Barcodes are not enabled in Admin > Settings');
             }
         } elseif (Input::get('bulk_actions') == 'delete') {
             $assets = Asset::with('assigneduser', 'assetloc')->find($asset_ids);
             return View::make('backend/hardware/bulk-delete')->with('assets', $assets);
             // Bulk edit
         } elseif (Input::get('bulk_actions') == 'edit') {
             $assets = Input::get('edit_asset');
             $supplier_list = array('' => '') + suppliersList();
             $statuslabel_list = array('' => '') + statusLabelList();
             $location_list = array('' => '') + locationsList();
             $models_list = array('' => '') + modelList();
             $companies_list = array('' => '') + array('clear' => Lang::get('general.remove_company')) + companyList();
             return View::make('backend/hardware/bulk')->with('assets', $assets)->with('supplier_list', $supplier_list)->with('statuslabel_list', $statuslabel_list)->with('location_list', $location_list)->with('models_list', $models_list)->with('companies_list', $companies_list);
         }
     } else {
         return Redirect::back()->with('error', 'No action selected');
     }
 }