Skip to content

Commit

Permalink
Dev: Add user method to fetch all superadmins
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Aug 4, 2016
1 parent 2dd0572 commit 837e21e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions application/models/User.php
Expand Up @@ -292,4 +292,17 @@ public function relations()
'permissions' => array(self::HAS_MANY, 'Permission', 'uid')
);
}

/**
* Return all super admins in the system
* @return User[]
*/
public function getSuperAdmins()
{
$criteria = new CDbCriteria();
$criteria->join = ' JOIN {{permissions}} AS p ON p.uid = t.uid';
$criteria->addCondition('p.permission = \'superadmin\'');
$users = $this->findAll($criteria);
return $users;
}
}

0 comments on commit 837e21e

Please sign in to comment.