Beispiel #1
0
 public function edit($id)
 {
     $permission = Permission::name('Faxbox\\Repositories\\Phone\\PhoneInterface', 'view', $id);
     $groups = $this->groups->allWithChecked($permission);
     $phone = $this->phones->byId($id);
     $this->view('phones.edit', compact('phone', 'groups'));
 }
Beispiel #2
0
 /**
  * Registers a new permission with the system directly in the database.
  * @param  Permission $perm
  * @return boolean    Whether the permission was successfully added.
  */
 public static function register($perm)
 {
     $db =& self::$db;
     $db->pushState()->select('sys_perms')->fields('name, display, description, type')->append($perm->name(), $perm->display(), $perm->description(), $perm->type());
     $result = $db->found();
     $db->popState();
     if (!$result) {
         logMsg('Permissions: failed to register a new permission', 3, 5);
     }
     return $result;
 }
 public function update($data)
 {
     $phone = $this->phones->findOrFail($data['id']);
     $phone->fill($data);
     $permission = \Permission::name('Faxbox\\Repositories\\Phone\\PhoneInterface', 'view', $data['id']);
     if (isset($data['groups'])) {
         foreach ($data['groups'] as $id => $access) {
             $group = $this->groups->byId($id);
             $group->permissions = [$permission => $access];
             $group->save();
         }
     }
     if ($phone->save()) {
         $result['success'] = true;
         $result['message'] = trans('phones.updated');
     } else {
         $result['success'] = false;
         $result['message'] = trans('phones.updateproblem');
     }
     return $result;
 }
Beispiel #4
0
             $send = !$fax['sent'];
             break;
         case 'never':
             break;
     }
     $template = $fax['sent'] ? 'emails.fax.sent.success' : 'emails.fax.sent.failed';
     if ($send) {
         Mail::send($template, compact('fax'), function ($message) use($fax) {
             $status = $fax['sent'] ? 'successfully sent' : 'sending failed';
             $message->to($fax['user']['email'])->subject('Fax ' . $status);
         });
     }
 }
 if ($fax['direction'] == 'received') {
     $phoneViewer = Permission::name('Faxbox\\Repositories\\Phone\\PhoneInterface', 'view', $fax['phone']['id']);
     $phoneAdmin = Permission::name('Faxbox\\Repositories\\Phone\\PhoneInterface', 'admin', $fax['phone']['id']);
     $users = Sentry::findAllUsersWithAccess([$phoneViewer, $phoneAdmin]);
     foreach ($users as $user) {
         $send = false;
         switch ($user->received_notification) {
             case 'always':
                 $send = true;
                 break;
             case 'mine':
                 $send = $user->hasAccess($phoneAdmin);
                 break;
             case 'groups':
                 // todo check groups
                 break;
             case 'never':
                 break;