Source for file permissions.inc.php
Documentation is available at permissions.inc.php
* @author Matthias Reuter ($LastChangedBy: matthias $)
* @version $LastChangedDate: 2008-10-31 15:33:34 +0000 (Fr, 31 Okt 2008) $
* @copyright 2007-2010 IPBWI development team
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License
* @desc Loads and checks different vars when class is initiating
* @author Matthias Reuter
public function __construct($ipbwi){
* @desc Finds out if a user has permission to do something...
* @param string $perm the permission to be worked out
* @param int $user the user to have permissions checked. If left blank, currently logged in user used.
* @return bool true if user has perm, otherwise false
* @author Matthias Reuter
* $ipbwi->permissions->has('g_access_cp',55);
public function has($perm,$user= false){
if(substr($perm,0,2) != "g_"){
$this->ipbwi->addSystemMessage('Error',$this->ipbwi->getLibLang('badPermID'),'Located in file <strong>'.__FILE__. '</strong> at class <strong>'.__CLASS__. '</strong> in function <strong>'.__FUNCTION__. '</strong> on line #<strong>'.__LINE__. '</strong>');
$info = $this->ipbwi->member->info($user);
$this->ipbwi->addSystemMessage('Error',$this->ipbwi->getLibLang('badMemID'),'Located in file <strong>'.__FILE__. '</strong> at class <strong>'.__CLASS__. '</strong> in function <strong>'.__FUNCTION__. '</strong> on line #<strong>'.__LINE__. '</strong>');
// Take a look at secondary groups
}elseif(isset ($info['mgroup_others'])){
$info['mgroup_others'] = substr($info['mgroup_others'],1,strlen($info['mgroup_others'])- 2);
if($info['mgroup_others'] != ''){
$this->ipbwi->ips_wrapper->DB->query('SELECT '. $perm. ' FROM '. $this->ipbwi->board['sql_tbl_prefix']. 'groups WHERE g_id IN('. $info['mgroup_others']. ')');
while($row = $this->ipbwi->ips_wrapper->DB->fetch()){
* @desc Attempts to sort out the weird permissions array.
* @param string $permArray the permission array to be sorted
* @return array sorted permissions
* @author Matthias Reuter
* $ipbwi->permissions->sort(array('show' => '*','read' => '*','start' => '*','reply' => '*','upload' => '*','download' => '*'));
public function sort($permArray){
$fr['read_perms'] = $perms['read_perms'];
$fr['reply_perms'] = $perms['reply_perms'];
$fr['start_perms'] = $perms['start_perms'];
$fr['upload_perms'] = $perms['upload_perms'];
$fr['show_perms'] = $perms['show_perms'];
* @desc Returns the best perms a user has for something...
* @param string $perm the permission to be worked out
* @param int $user the user to have permissions checked. if left blank, currently logged in user used.
* @param bool $zero if true, zero is best
* @return array best permissions
* @author Matthias Reuter
* $ipbwi->permissions->best(array('g_max_messages');
public function best($perm,$user= false,$zero= true){
if(substr($perm,0,2) != 'g_'){
$this->ipbwi->addSystemMessage('Error',$this->ipbwi->getLibLang('badPermID'),'Located in file <strong>'.__FILE__. '</strong> at class <strong>'.__CLASS__. '</strong> in function <strong>'.__FUNCTION__. '</strong> on line #<strong>'.__LINE__. '</strong>');
$info = $this->ipbwi->member->info($user);
$this->ipbwi->addSystemMessage('Error',$this->ipbwi->getLibLang('badMemID'),'Located in file <strong>'.__FILE__. '</strong> at class <strong>'.__CLASS__. '</strong> in function <strong>'.__FUNCTION__. '</strong> on line #<strong>'.__LINE__. '</strong>');
if(intval($init) == 0 && $zero){
// Take a look at secondary groups
$info['mgroup_others'] = substr($info['mgroup_others'],1,strlen($info['mgroup_others'])- 2);
if($info['mgroup_others'] != ''){
$this->ipbwi->ips_wrapper->DB->query('SELECT '. $perm. ' FROM '. $this->ipbwi->board['sql_tbl_prefix']. 'groups WHERE g_id IN('. $info['mgroup_others']. ')');
while($row = $this->ipbwi->ips_wrapper->DB->fetch()){
if(intval($init) == 0 && $zero){
|