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


PHP ControllerSecurityUtil::doesCurrentUserHavePermissionOnSecurableItem方法代码示例

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


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

示例1: groupTasksByKanbanTypeAndGetStats

 /**
  * Group tasks by kanban type and get stats
  * @param Project $project
  * @return array
  */
 protected static function groupTasksByKanbanTypeAndGetStats(Project $project)
 {
     $tasks = $project->tasks;
     $kanbanItemsArray = array();
     $totalTasksToDoCount = 0;
     $completedTasksCount = 0;
     foreach ($tasks as $task) {
         if (ControllerSecurityUtil::doesCurrentUserHavePermissionOnSecurableItem($task, Permission::READ)) {
             $totalTasksToDoCount++;
             if ($task->status == Task::STATUS_COMPLETED) {
                 $completedTasksCount++;
             }
             $kanbanItem = KanbanItem::getByTask($task->id);
             if ($kanbanItem == null) {
                 //Create KanbanItem here
                 $kanbanItem = TasksUtil::createKanbanItemFromTask($task);
             }
             $kanbanItemsArray[$kanbanItem->type][] = $kanbanItem->id;
         }
     }
     $stats = array();
     $kanbanTypeDropDownData = KanbanItem::getTypeDropDownArray();
     foreach ($kanbanTypeDropDownData as $type => $label) {
         if (isset($kanbanItemsArray[$type])) {
             $stats[$type] = count($kanbanItemsArray[$type]);
         } else {
             $stats[$type] = 0;
         }
     }
     $stats['completionPercent'] = static::resolveCompletionPercentage($completedTasksCount, $totalTasksToDoCount);
     return $stats;
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:37,代码来源:DashboardActiveProjectListViewColumnAdapter.php

示例2: renderTotalBarDetails

 /**
  * Render totals in a product portlet view
  */
 protected function renderTotalBarDetails()
 {
     $persistantProductConfigItemValue = ProductsPortletPersistentConfigUtil::getForCurrentUserByPortletIdAndKey($this->params['portletId'], 'filteredByStage');
     $relationModelClassName = get_class($this->params["relationModel"]);
     $relationModelId = $this->params["relationModel"]->id;
     $relationModel = $relationModelClassName::getById($relationModelId);
     $models = $relationModel->products;
     $oneTimeTotal = 0;
     $monthlyTotal = 0;
     $annualTotal = 0;
     foreach ($models as $model) {
         if (ControllerSecurityUtil::doesCurrentUserHavePermissionOnSecurableItem($model, Permission::READ)) {
             if ($persistantProductConfigItemValue === null) {
                 $persistantProductConfigItemValue = ProductsConfigurationForm::FILTERED_BY_ALL_STAGES;
             }
             if ($persistantProductConfigItemValue != ProductsConfigurationForm::FILTERED_BY_ALL_STAGES) {
                 if ($model->stage->value != $persistantProductConfigItemValue) {
                     continue;
                 }
             }
             if ($model->priceFrequency == ProductTemplate::PRICE_FREQUENCY_ONE_TIME) {
                 $oneTimeTotal += $this->getAdjustedTotalByCurrency($model);
             }
             if ($model->priceFrequency == ProductTemplate::PRICE_FREQUENCY_MONTHLY) {
                 $monthlyTotal += $this->getAdjustedTotalByCurrency($model);
             }
             if ($model->priceFrequency == ProductTemplate::PRICE_FREQUENCY_ANNUALLY) {
                 $annualTotal += $this->getAdjustedTotalByCurrency($model);
             }
         }
     }
     $content = Zurmo::t("Core", "Total: ");
     $contentArray = array();
     if ($oneTimeTotal > 0) {
         $contentArray[] = Yii::app()->numberFormatter->formatCurrency($oneTimeTotal, Yii::app()->currencyHelper->getCodeForCurrentUserForDisplay()) . Zurmo::t("Core", " One Time");
     }
     if ($monthlyTotal > 0) {
         $contentArray[] = Yii::app()->numberFormatter->formatCurrency($monthlyTotal, Yii::app()->currencyHelper->getCodeForCurrentUserForDisplay()) . Zurmo::t("Core", " Monthly");
     }
     if ($annualTotal > 0) {
         $contentArray[] = Yii::app()->numberFormatter->formatCurrency($annualTotal, Yii::app()->currencyHelper->getCodeForCurrentUserForDisplay()) . Zurmo::t("Core", " Annually");
     }
     if (empty($contentArray)) {
         $content = '';
     } else {
         $content .= implode(', ', $contentArray);
     }
     echo $content;
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:52,代码来源:ProductPortletExtendedGridView.php

示例3: resolveAfterSaveHasPermissionsProblem

 protected function resolveAfterSaveHasPermissionsProblem(SavedReport $savedReport, $modelToStringValue)
 {
     assert('is_string($modelToStringValue)');
     if (ControllerSecurityUtil::doesCurrentUserHavePermissionOnSecurableItem($savedReport, Permission::READ)) {
         return false;
     } else {
         $notificationContent = Zurmo::t('ZurmoModule', 'You no longer have permissions to access {modelName}.', array('{modelName}' => $modelToStringValue));
         Yii::app()->user->setFlash('notification', $notificationContent);
         return true;
     }
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:11,代码来源:DefaultController.php

示例4: export

 protected function export($stickySearchKey = null, $modelClassName = null, $exportFileName = null)
 {
     assert('$stickySearchKey == null || is_string($stickySearchKey)');
     assert('$modelClassName == null || is_string($modelClassName)');
     assert('$exportFileName == null || is_string($exportFileName)');
     if ($modelClassName == null) {
         $modelClassName = $this->getModelName();
     }
     $searchFormClassName = static::getSearchFormClassName();
     $pageSize = null;
     $model = new $modelClassName(false);
     if ($searchFormClassName != null) {
         $searchForm = new $searchFormClassName($model);
     } else {
         throw new NotSupportedException();
     }
     $stateMetadataAdapterClassName = $this->resolveStateMetadataAdapterClassNameForExport();
     $dataProvider = $this->getDataProviderByResolvingSelectAllFromGet($searchForm, $pageSize, Yii::app()->user->userModel->id, $stateMetadataAdapterClassName, $stickySearchKey);
     if (!$dataProvider) {
         $idsToExport = array_filter(explode(",", trim($_GET['selectedIds'], " ,")));
         // Not Coding Standard
     }
     $totalItems = static::getSelectedRecordCountByResolvingSelectAllFromGet($dataProvider, false);
     $data = array();
     if ($totalItems > 0) {
         if ($totalItems <= ExportModule::$asynchronousThreshold) {
             // Output csv file directly to user browser
             if ($dataProvider) {
                 $modelsToExport = ExportUtil::getDataForExport($dataProvider);
                 if (count($modelsToExport) > 0) {
                     $modelToExportAdapter = new ModelToExportAdapter($modelsToExport[0]);
                     $headerData = $modelToExportAdapter->getHeaderData();
                 }
                 foreach ($modelsToExport as $model) {
                     if (ControllerSecurityUtil::doesCurrentUserHavePermissionOnSecurableItem($model, Permission::READ)) {
                         $modelToExportAdapter = new ModelToExportAdapter($model);
                         $data[] = $modelToExportAdapter->getData();
                     }
                 }
             } else {
                 $headerData = array();
                 foreach ($idsToExport as $idToExport) {
                     $model = $modelClassName::getById(intval($idToExport));
                     if (ControllerSecurityUtil::doesCurrentUserHavePermissionOnSecurableItem($model, Permission::READ)) {
                         $modelToExportAdapter = new ModelToExportAdapter($model);
                         $data[] = $modelToExportAdapter->getData();
                         if (count($headerData) == 0) {
                             $headerData = $modelToExportAdapter->getHeaderData();
                         }
                     }
                 }
             }
             // Output data
             if (count($data)) {
                 if ($exportFileName == null) {
                     $fileName = $this->getModule()->getName() . ".csv";
                 } else {
                     $fileName = $exportFileName . ".csv";
                 }
                 $output = ExportItemToCsvFileUtil::export($data, $headerData, $fileName, true);
             } else {
                 Yii::app()->user->setFlash('notification', Zurmo::t('ZurmoModule', 'There is no data to export.'));
             }
         } else {
             if ($dataProvider) {
                 $serializedData = ExportUtil::getSerializedDataForExport($dataProvider);
             } else {
                 $serializedData = serialize($idsToExport);
             }
             // Create background job
             $exportItem = new ExportItem();
             $exportItem->isCompleted = false;
             $exportItem->exportFileType = 'csv';
             $exportItem->exportFileName = $this->getModule()->getName();
             $exportItem->modelClassName = $modelClassName;
             $exportItem->serializedData = $serializedData;
             $exportItem->isJobRunning = false;
             $exportItem->cancelExport = false;
             $exportItem->save();
             $exportItem->forget();
             Yii::app()->user->setFlash('notification', Zurmo::t('ZurmoModule', 'A large amount of data has been requested for export.  You will receive ' . 'a notification with the download link when the export is complete.'));
         }
     } else {
         Yii::app()->user->setFlash('notification', Zurmo::t('ZurmoModule', 'There is no data to export.'));
     }
     $this->redirect(array($this->getId() . '/index'));
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:87,代码来源:ZurmoModuleController.php

示例5: resolveAccessCanCurrentUserWriteModule

 /**
  * If a current user cannot write the module, then render a AccessFailurePageView
  * and end the application.
  * @param $model - RedBeanModel
  * @return null;
  */
 public static function resolveAccessCanCurrentUserWriteModule($moduleClassName, $fromAjax = false)
 {
     assert('is_string($moduleClassName)');
     $item = NamedSecurableItem::getByName($moduleClassName);
     if (ControllerSecurityUtil::doesCurrentUserHavePermissionOnSecurableItem($item, Permission::WRITE)) {
         return;
     }
     static::processAccessFailure($fromAjax);
     Yii::app()->end(0, false);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:16,代码来源:ControllerSecurityUtil.php

示例6: resolvePersonOrAccountFromGet

 protected function resolvePersonOrAccountFromGet($relatedId = null, $relatedModelClassName = null)
 {
     $personOrAccount = null;
     if ($relatedId != null && $relatedModelClassName != null) {
         $personOrAccount = $relatedModelClassName::getById((int) $relatedId);
         //Only attempt to populate email if the user has write permissions
         if ($relatedModelClassName == 'Contact' && $personOrAccount->primaryEmail->emailAddress == null && ControllerSecurityUtil::doesCurrentUserHavePermissionOnSecurableItem($personOrAccount, Permission::WRITE)) {
             $this->redirect(array($this->getId() . '/populateContactEmailBeforeCreating', 'id' => $personOrAccount->id));
             Yii::app()->end(false);
         }
     }
     return $personOrAccount;
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:13,代码来源:DefaultController.php

示例7: processModelsForMassActionWithoutScoring

 protected static function processModelsForMassActionWithoutScoring($modelClassName, $selectedRecordCount, $dataProvider, $page, $pageSize, $insufficientPermissionSkipSavingUtil, $actionId)
 {
     // TODO: @Shoaibi/@Jason: Low: Candidate for MassActionController
     $returnValue = false;
     static::toggleMuteScoringModelValueByMassActionId($actionId, true);
     $modelsToProcess = static::getModelsToUpdate($modelClassName, $dataProvider, $selectedRecordCount, $page, $pageSize);
     $modelPermission = static::resolvePermissionOnSecurableItemByMassActionId($actionId);
     foreach ($modelsToProcess as $modelToProcess) {
         if (ControllerSecurityUtil::doesCurrentUserHavePermissionOnSecurableItem($modelToProcess, $modelPermission)) {
             $function = 'processModelFor' . static::resolveMassActionId($actionId, true);
             $returnValue = static::$function($modelToProcess);
         } else {
             $insufficientPermissionSkipSavingUtil::setByModelIdAndName($modelClassName, $modelToProcess->id, $modelToProcess->name);
         }
     }
     static::toggleMuteScoringModelValueByMassActionId($actionId, false);
     return $returnValue;
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:18,代码来源:ZurmoBaseController.php

示例8: processExportModels

 /**
  * @param array $models
  * @param array $headerData
  * @param array $data
  * @param bool $resolveForHeader
  */
 protected function processExportModels(array $models, &$headerData, &$data, $resolveForHeader = true)
 {
     foreach ($models as $model) {
         $canRead = ControllerSecurityUtil::doesCurrentUserHavePermissionOnSecurableItem($model, Permission::READ);
         if ($canRead) {
             $modelToExportAdapter = new ModelToExportAdapter($model);
             if (count($headerData) == 0 && $resolveForHeader) {
                 $headerData = $modelToExportAdapter->getHeaderData();
             }
             $data[] = $modelToExportAdapter->getData();
             unset($modelToExportAdapter);
         }
         $this->runGarbageCollection($model);
     }
     unset($models);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:22,代码来源:ExportJob.php

示例9: run

 public function run()
 {
     $exportItems = ExportItem::getUncompletedItems();
     if (count($exportItems) > 0) {
         foreach ($exportItems as $exportItem) {
             if (isset($exportItem->exportFileModel)) {
                 //continue;
             }
             $unserializedData = unserialize($exportItem->serializedData);
             if ($unserializedData instanceof RedBeanModelDataProvider) {
                 $formattedData = $unserializedData->getData();
             } else {
                 $formattedData = array();
                 foreach ($unserializedData as $idToExport) {
                     $model = call_user_func(array($exportItem->modelClassName, 'getById'), intval($idToExport));
                     $formattedData[] = $model;
                 }
             }
             if ($exportItem->exportFileType == 'csv') {
                 $headerData = array();
                 foreach ($formattedData as $model) {
                     if (ControllerSecurityUtil::doesCurrentUserHavePermissionOnSecurableItem($model, Permission::READ)) {
                         $modelToExportAdapter = new ModelToExportAdapter($model);
                         if (count($headerData) == 0) {
                             $headerData = $modelToExportAdapter->getHeaderData();
                         }
                         $data[] = $modelToExportAdapter->getData();
                     }
                 }
                 $output = ExportItemToCsvFileUtil::export($data, $headerData);
                 $fileContent = new FileContent();
                 $fileContent->content = $output;
                 $exportFileModel = new ExportFileModel();
                 $exportFileModel->fileContent = $fileContent;
                 $exportFileModel->name = $exportItem->exportFileName . ".csv";
                 $exportFileModel->type = 'application/octet-stream';
                 $exportFileModel->size = strlen($output);
                 $saved = $exportFileModel->save();
                 if ($saved) {
                     $exportItem->isCompleted = 1;
                     $exportItem->exportFileModel = $exportFileModel;
                     $exportItem->save();
                     $message = new NotificationMessage();
                     $message->htmlContent = Zurmo::t('ExportModule', 'Export of {fileName} requested on {dateTime} is completed. <a href="{url}">Click here</a> to download file!', array('{fileName}' => $exportItem->exportFileName, '{url}' => Yii::app()->createUrl('export/default/download', array('id' => $exportItem->id)), '{dateTime}' => DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($exportItem->createdDateTime, 'long')));
                     $rules = new ExportProcessCompletedNotificationRules();
                     NotificationsUtil::submit($message, $rules);
                 }
             }
         }
     } else {
         return true;
     }
     return true;
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:54,代码来源:ExportJob.php

示例10: resolveSavedReportAndWarningData

 private function resolveSavedReportAndWarningData()
 {
     try {
         $savedReport = SavedReport::getById((int) $this->getSavedReportId());
         if (!ControllerSecurityUtil::doesCurrentUserHavePermissionOnSecurableItem($savedReport, Permission::READ)) {
             $this->warningMessage = Zurmo::t('ReportsModule', 'You have tried to access a report you do not have access to');
         } else {
             $report = SavedReportToReportAdapter::makeReportBySavedReport($savedReport);
             if ($report->getChart()->type == null) {
                 $this->warningMessage = Zurmo::t('ReportsModule', 'This report does not have a chart to display');
             } else {
                 $this->savedReport = $savedReport;
             }
         }
     } catch (NotFoundException $e) {
         $this->warningMessage = Zurmo::t('ReportsModule', 'You have tried to access a report that is no longer available');
     } catch (AccessDeniedSecurityException $e) {
         $this->warningMessage = Zurmo::t('ReportsModule', 'You have tried to access a report you do not have access to');
     }
     $this->savedReportHasBeenResolved = true;
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:21,代码来源:DashboardReportChartForPortletView.php


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