hasAccessPermissions() public method

See also: AccessPermissionsInterface::hasAccessPermissions()
public hasAccessPermissions ( $user, $environment = null, $modify = null )
コード例 #1
0
ファイル: NotificationTrait.php プロジェクト: scalr/scalr
 /**
  * Saves/modifies/deletes notifications
  *
  * @param int   $subjectType Notification subject type
  * @param array $settings    Array of notifications to create/modify
  * @param string $projectId  optional Projects id.
  * @throws \Scalr\Exception\ModelException
  */
 protected function saveNotifications($subjectType, $settings, $projectId = null)
 {
     $uuids = [];
     foreach ($settings['items'] as $item) {
         $notification = new NotificationEntity();
         if ($item['uuid']) {
             $notification->findPk($item['uuid']);
             if (!$notification->hasAccessPermissions($this->getUser())) {
                 continue;
             }
         }
         $notification->subjectType = $subjectType;
         $notification->subjectId = $item['subjectId'] ? $item['subjectId'] : null;
         $notification->notificationType = $item['notificationType'];
         $notification->threshold = $item['threshold'];
         $notification->recipientType = $item['recipientType'];
         $notification->emails = $item['emails'];
         $notification->status = $item['status'];
         $notification->save();
         $uuids[] = $notification->uuid;
     }
     $criteria = [['subjectType' => $subjectType], ['accountId' => null]];
     if ($projectId) {
         $criteria[] = ['subjectId' => $projectId];
     }
     foreach (NotificationEntity::find($criteria) as $notification) {
         /* @var $notification NotificationEntity */
         if (!in_array($notification->uuid, $uuids) && $notification->hasAccessPermissions($this->getUser())) {
             $notification->delete();
         }
     }
 }