RoleModel::getWithRankPermissions PHP Method

getWithRankPermissions() public method

Get all of the roles including their ranking permissions.
public getWithRankPermissions ( ) : Gdn_DataSet
return Gdn_DataSet Returns all of the roles with the ranking permissions.
    public function getWithRankPermissions()
    {
        $this->SQL->select('r.*')->from('Role r')->leftJoin('Permission p', 'p.RoleID = r.RoleID and p.JunctionID is null')->orderBy('Sort', 'asc');
        foreach ($this->RankPermissions as $Permission) {
            $this->SQL->select("`{$Permission}`", '', $Permission);
        }
        $Result = $this->SQL->get();
        return $Result;
    }

Usage Example

コード例 #1
0
 /**
  * Show list of roles.
  *
  * @since 2.0.0
  * @access public
  */
 public function index($RoleID = null)
 {
     $this->_permission();
     $this->addSideMenu('dashboard/role');
     $this->addJsFile('jquery.tablednd.js');
     $this->addJsFile('jquery-ui.js');
     $this->title(t('Roles & Permissions'));
     if (!$RoleID) {
         $RoleData = $this->RoleModel->getWithRankPermissions()->resultArray();
         // Check to see which roles can be modified.
         foreach ($RoleData as &$Row) {
             $CanModify = true;
             if (!Gdn::session()->checkPermission('Garden.Settings.Manage')) {
                 foreach ($this->RoleModel->RankPermissions as $Permission) {
                     if ($Row[$Permission] && !Gdn::session()->checkPermission($Permission)) {
                         $CanModify = false;
                         break;
                     }
                 }
             }
             $Row['CanModify'] = $CanModify;
         }
     } else {
         $Role = $this->RoleModel->getID($RoleID);
         $RoleData = array($Role);
     }
     $this->setData('Roles', $RoleData);
     $this->render();
 }
All Usage Examples Of RoleModel::getWithRankPermissions