当前位置: 首页>>代码示例>>PHP>>正文


PHP Company::isCurrentUserHasAccess方法代码示例

本文整理汇总了PHP中app\models\Company::isCurrentUserHasAccess方法的典型用法代码示例。如果您正苦于以下问题:PHP Company::isCurrentUserHasAccess方法的具体用法?PHP Company::isCurrentUserHasAccess怎么用?PHP Company::isCurrentUserHasAccess使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Company的用法示例。


在下文中一共展示了Company::isCurrentUserHasAccess方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: displayFile

 /**
  * Check for permissions and display the file.
  *
  * @author [A. Gianotto] [<snipe@snipe.net>]
  * @param  int  $assetId
  * @param  int  $fileId
  * @since [v1.0]
  * @return View
  */
 public function displayFile($assetId = null, $fileId = null)
 {
     $asset = Asset::find($assetId);
     // the asset is valid
     if (isset($asset->id)) {
         if (!Company::isCurrentUserHasAccess($asset)) {
             return redirect()->to('hardware')->with('error', trans('general.insufficient_permissions'));
         }
         $log = Actionlog::find($fileId);
         $file = $log->get_src('assets');
         $filetype = Helper::checkUploadIsImage($file);
         if ($filetype) {
             $contents = file_get_contents($file);
             return Response::make($contents)->header('Content-Type', $filetype);
         } else {
             return Response::download($file);
         }
     } else {
         // Prepare the error message
         $error = trans('admin/hardware/message.does_not_exist', compact('id'));
         // Redirect to the hardware management page
         return redirect()->route('hardware')->with('error', $error);
     }
 }
开发者ID:stijni,项目名称:snipe-it,代码行数:33,代码来源:AssetsController.php

示例2: getView

 /**
  *  View an asset maintenance
  *
  * @author  Vincent Sposato <vincent.sposato@gmail.com>
  * @param int $assetMaintenanceId
  * @version v1.0
  * @since [v1.8]
  * @return View
  */
 public function getView($assetMaintenanceId)
 {
     // Check if the asset maintenance exists
     if (is_null($assetMaintenance = AssetMaintenance::find($assetMaintenanceId))) {
         // Redirect to the asset maintenance management page
         return redirect()->to('admin/asset_maintenances')->with('error', trans('admin/asset_maintenances/message.not_found'));
     } elseif (!Company::isCurrentUserHasAccess($assetMaintenance->asset)) {
         return static::getInsufficientPermissionsRedirect();
     }
     return View::make('asset_maintenances/view')->with('assetMaintenance', $assetMaintenance);
 }
开发者ID:jbirdkerr,项目名称:snipe-it,代码行数:20,代码来源:AssetMaintenancesController.php

示例3: getDataView

 /**
  * Returns a JSON response containing details on the users associated with this consumable.
  *
  * @author [A. Gianotto] [<snipe@snipe.net>]
  * @see ConsumablesController::getView() method that returns the form.
  * @since [v1.0]
  * @param int $consumableId
  * @return View
  */
 public function getDataView($consumableId)
 {
     //$consumable = Consumable::find($consumableID);
     $consumable = Consumable::with(array('consumableAssigments' => function ($query) {
         $query->orderBy('created_at', 'DESC');
     }, 'consumableAssigments.admin' => function ($query) {
     }, 'consumableAssigments.user' => function ($query) {
     }))->find($consumableId);
     //  $consumable->load('consumableAssigments.admin','consumableAssigments.user');
     if (!Company::isCurrentUserHasAccess($consumable)) {
         return ['total' => 0, 'rows' => []];
     }
     $rows = array();
     foreach ($consumable->consumableAssigments as $consumable_assignment) {
         $rows[] = array('name' => (string) link_to('/admin/users/' . $consumable_assignment->user->id . '/view', e($consumable_assignment->user->fullName())), 'created_at' => $consumable_assignment->created_at->format('Y-m-d H:i:s') == '-0001-11-30 00:00:00' ? '' : $consumable_assignment->created_at->format('Y-m-d H:i:s'), 'admin' => $consumable_assignment->admin ? e($consumable_assignment->admin->fullName()) : '');
     }
     $consumableCount = $consumable->users->count();
     $data = array('total' => $consumableCount, 'rows' => $rows);
     return $data;
 }
开发者ID:jbirdkerr,项目名称:snipe-it,代码行数:29,代码来源:ConsumablesController.php

示例4: getDataView

 /**
  * Return JSON data to populate the components view,
  *
  * @author [A. Gianotto] [<snipe@snipe.net>]
  * @see ComponentsController::getView() method that returns the view.
  * @since [v3.0]
  * @param int $componentId
  * @return string JSON
  */
 public function getDataView($componentId)
 {
     //$component = Component::find($componentID);
     $component = Component::with('assets')->find($componentId);
     if (!Company::isCurrentUserHasAccess($component)) {
         return ['total' => 0, 'rows' => []];
     }
     $rows = array();
     foreach ($component->assets as $component_assignment) {
         $rows[] = array('name' => (string) link_to('/hardware/' . $component_assignment->id . '/view', e($component_assignment->showAssetName())), 'qty' => e($component_assignment->pivot->assigned_qty), 'created_at' => $component_assignment->created_at->format('Y-m-d H:i:s') == '-0001-11-30 00:00:00' ? '' : $component_assignment->created_at->format('Y-m-d H:i:s'));
     }
     $componentCount = $component->assets->count();
     $data = array('total' => $componentCount, 'rows' => $rows);
     return $data;
 }
开发者ID:stijni,项目名称:snipe-it,代码行数:24,代码来源:ComponentsController.php

示例5: displayFile

 /**
  * Allows the selected file to be viewed.
  *
  * @author [A. Gianotto] [<snipe@snipe.net>]
  * @since [v1.4]
  * @param int $licenseId
  * @param int $fileId
  * @return Redirect
  */
 public function displayFile($licenseId = null, $fileId = null)
 {
     $license = License::find($licenseId);
     // the license is valid
     if (isset($license->id)) {
         if (!Company::isCurrentUserHasAccess($license)) {
             return redirect()->to('admin/licenses')->with('error', trans('general.insufficient_permissions'));
         }
         $log = Actionlog::find($fileId);
         $file = $log->get_src('licenses');
         return Response::download($file);
     } else {
         // Prepare the error message
         $error = trans('admin/licenses/message.does_not_exist', compact('id'));
         // Redirect to the licence management page
         return redirect()->route('licenses')->with('error', $error);
     }
 }
开发者ID:jbirdkerr,项目名称:snipe-it,代码行数:27,代码来源:LicensesController.php

示例6: getDataView

 /**
  * Generates the JSON response for accessory detail view.
  *
  * Example:
  * <code>
  * {
  * "rows": [
  * {
  * "actions": "(link to available actions)",
  * "name": "(link to user)"
  * }
  * ],
  * "total": 1
  * }
  * </code>
  *
  * The names of the fields in the returns JSON correspond directly to the the
  * names of the fields in the bootstrap-tables in the view.
  *
  * For debugging, see at /api/accessories/$accessoryID/view
  *
  * @author [A. Gianotto] [<snipe@snipe.net>]
  * @param  int  $accessoryId
  * @return string JSON containing accessories and their associated atrributes.
  **/
 public function getDataView(Request $request, $accessoryID)
 {
     $accessory = Accessory::find($accessoryID);
     if (!Company::isCurrentUserHasAccess($accessory)) {
         return ['total' => 0, 'rows' => []];
     }
     $accessory_users = $accessory->users;
     $count = $accessory_users->count();
     $rows = array();
     foreach ($accessory_users as $user) {
         $actions = '<a href="' . route('checkin/accessory', $user->pivot->id) . '" class="btn btn-info btn-sm">Checkin</a>';
         $rows[] = array('name' => (string) link_to('/admin/users/' . $user->id . '/view', e($user->fullName())), 'actions' => $actions);
     }
     $data = array('total' => $count, 'rows' => $rows);
     return $data;
 }
开发者ID:dmeltzer,项目名称:snipe-it,代码行数:41,代码来源:AccessoriesController.php

示例7: getAcceptAsset

 public function getAcceptAsset($logID = null)
 {
     if (!($findlog = DB::table('asset_logs')->where('id', '=', $logID)->first())) {
         echo 'no record';
         //return redirect()->to('account')->with('error', trans('admin/hardware/message.does_not_exist'));
     }
     $user = Auth::user();
     if ($user->id != $findlog->checkedout_to) {
         return redirect()->to('account/view-assets')->with('error', trans('admin/users/message.error.incorrect_user_accepted'));
     }
     // Asset
     if ($findlog->asset_id != '' && $findlog->asset_type == 'hardware') {
         $item = Asset::find($findlog->asset_id);
         // software
     } elseif ($findlog->asset_id != '' && $findlog->asset_type == 'software') {
         $item = License::find($findlog->asset_id);
         // accessories
     } elseif ($findlog->accessory_id != '') {
         $item = Accessory::find($findlog->accessory_id);
         // consumable
     } elseif ($findlog->consumable_id != '') {
         $item = Consumable::find($findlog->consumable_id);
         // components
     } elseif ($findlog->component_id != '') {
         $item = Component::find($findlog->component_id);
     }
     // Check if the asset exists
     if (is_null($item)) {
         // Redirect to the asset management page
         return redirect()->to('account')->with('error', trans('admin/hardware/message.does_not_exist'));
     } elseif (!Company::isCurrentUserHasAccess($item)) {
         return redirect()->route('requestable-assets')->with('error', trans('general.insufficient_permissions'));
     } else {
         return View::make('account/accept-asset', compact('item'))->with('findlog', $findlog);
     }
 }
开发者ID:dmeltzer,项目名称:snipe-it,代码行数:36,代码来源:ViewAssetsController.php


注:本文中的app\models\Company::isCurrentUserHasAccess方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。