Hawk - PHP documentation
  • Namespace
  • Class
  • Tree

Namespaces

  • Hawk
    • View
      • Plugins

Classes

  • Hawk\App
  • Hawk\ButtonInput
  • Hawk\Cache
  • Hawk\CheckboxInput
  • Hawk\ColorInput
  • Hawk\Conf
  • Hawk\Controller
  • Hawk\Crypto
  • Hawk\DatabaseSessionHandler
  • Hawk\DatetimeInput
  • Hawk\DB
  • Hawk\DBExample
  • Hawk\DeleteInput
  • Hawk\Dialogbox
  • Hawk\EmailInput
  • Hawk\ErrorHandler
  • Hawk\Event
  • Hawk\FileInput
  • Hawk\FileSystem
  • Hawk\FloatInput
  • Hawk\Form
  • Hawk\FormFieldset
  • Hawk\FormInput
  • Hawk\GenericModel
  • Hawk\GifImage
  • Hawk\HawkApi
  • Hawk\HawkUpdater
  • Hawk\HiddenInput
  • Hawk\HtmlInput
  • Hawk\HTTPRequest
  • Hawk\Icon
  • Hawk\Image
  • Hawk\IntegerInput
  • Hawk\ItemList
  • Hawk\ItemListField
  • Hawk\JpegImage
  • Hawk\Lang
  • Hawk\Language
  • Hawk\LeftSidebarTab
  • Hawk\Less
  • Hawk\Logger
  • Hawk\Mail
  • Hawk\MenuItem
  • Hawk\Model
  • Hawk\NoSidebarTab
  • Hawk\NumberInput
  • Hawk\ObjectInput
  • Hawk\Option
  • Hawk\Panel
  • Hawk\PasswordInput
  • Hawk\Permission
  • Hawk\Plugin
  • Hawk\PluginInstaller
  • Hawk\PngImage
  • Hawk\ProfileQuestion
  • Hawk\ProfileQuestionValue
  • Hawk\RadioInput
  • Hawk\Request
  • Hawk\Response
  • Hawk\RightSidebarTab
  • Hawk\Role
  • Hawk\RolePermission
  • Hawk\Route
  • Hawk\Router
  • Hawk\SelectInput
  • Hawk\Session
  • Hawk\Singleton
  • Hawk\SubmitInput
  • Hawk\Tabs
  • Hawk\TextareaInput
  • Hawk\TextInput
  • Hawk\Theme
  • Hawk\TimeInput
  • Hawk\Upload
  • Hawk\User
  • Hawk\View
  • Hawk\View\Plugins\Accordion
  • Hawk\View\Plugins\Button
  • Hawk\View\Plugins\Form
  • Hawk\View\Plugins\Icon
  • Hawk\View\Plugins\Import
  • Hawk\View\Plugins\Panel
  • Hawk\View\Plugins\Tabs
  • Hawk\View\Plugins\Text
  • Hawk\View\Plugins\Uri
  • Hawk\View\Plugins\Widget
  • Hawk\ViewPlugin
  • Hawk\Widget
  • Hawk\WysiwygInput

Traits

  • Hawk\Utils

Exceptions

  • Hawk\AppStopException
  • Hawk\DBExampleException
  • Hawk\DBException
  • Hawk\FileSystemException
  • Hawk\HawkApiException
  • Hawk\ImageException
  • Hawk\MailException
  • Hawk\UploadException
  • Hawk\ViewException
 1 <?php
 2 /**
 3  * Role.php
 4  *
 5  * @author  Elvyrra SAS
 6  * @license http://rem.mit-license.org/ MIT
 7  */
 8 namespace Hawk;
 9 
10 /**
11  * This model describes the roles that can be affected to the users
12  *
13  * @package BaseModels
14  */
15 class Role extends Model{
16     /**
17      * The associated table
18      *
19      * @var string
20      */
21     public static $tablename = "Role";
22 
23     /**
24      * The id corresponding to the 'Guest' role
25      */
26     const GUEST_ROLE_ID = 0;
27 
28     /**
29      * The id corresponding to the 'Admin' role
30      */
31     const ADMIN_ROLE_ID = 1;
32 
33     /**
34      * Get all roles
35      *
36      * @param string $index        The field to use as key in the returned array
37      * @param array  $fields       The fields to get for each role. If not set, all table fields are got
38      * @param array  $order        The order instructions for the returned array
39      * @param bool   $includeGuest If set to true, then include 'Guest' role to the result
40      *
41      * @return array The roles list
42      */
43     public static function getAll($index = null, $fields = array(), $order = array(), $includeGuest= false){
44         if($includeGuest) {
45             return parent::getAll($index, $fields, $order);
46         }
47         else{
48             $example = array('id' => array('$ne' => self::GUEST_ROLE_ID));
49             return self::getListByExample(new DBExample($example), $index, $fields, $order);
50         }
51     }
52 
53     /**
54      * Check if the role is removable. A role is removable if it's not 'Guest' or 'Admin', and not the default role
55      *
56      * @return boolean
57      */
58     public function isRemovable(){
59         return $this->removable && Option::get('roles.default-role') != $this->id;
60     }
61 
62     /**
63      * Get the label of the role in the current language
64      *
65      * @return string
66      */
67     public function getLabel(){
68         return Lang::get('roles.role-' . $this->id . '-label');
69     }
70 }
Hawk - PHP documentation API documentation generated by ApiGen