Exemple #1
0
 /**
  * Retrieve row field value
  *
  * @param  	string 	The column name.
  * @return 	string 	The corresponding column value.
  */
 public function __get($column)
 {
     if (strpos($column, '_permissions') === false) {
         return parent::__get($column);
     }
     $object = str_replace('_permissions', '', $column);
     if (!isset($this->_permissions[$object])) {
         $table = KFactory::get('admin::com.ninjaboard.database.table.assets');
         $query = KFactory::tmp('lib.koowa.database.query');
         $me = KFactory::get('admin::com.ninjaboard.model.people')->getMe();
         $gids = explode('|', $me->ninjaboard_usergroup_id);
         //If super admin, then the permission level is always 3
         if ($me->gid == 25) {
             return $this->_permissions[$object] = 3;
         }
         $query->select('IFNULL(tbl.level, ' . (int) $me->{$object . '_permissions'} . ') AS level')->from('ninjaboard_assets AS tbl')->order('tbl.level', 'DESC')->limit(1);
         $where = array();
         foreach ($gids as $gid) {
             $where[] = 'com_ninjaboard.forum.' . (int) $this->id . '.' . $gid . '.' . $object;
         }
         if ($where) {
             $query->where('tbl.name', 'in', $where);
         }
         $result = $table->getDatabase()->select($query, KDatabase::FETCH_FIELD);
         $this->_permissions[$object] = is_numeric($result) ? $result : $me->{$object . '_permissions'};
     }
     return $this->_permissions[$object];
 }
Exemple #2
0
 /**
  * Specialized in order to dynamically get the usergroups list when needed
  *
  * @TODO performance optimize this
  *
  * @param  	string 	The column name.
  */
 public function __get($column)
 {
     if ($column == 'usergroups') {
         if (!isset($this->_usergroups)) {
             $user = KFactory::tmp('admin::com.ninjaboard.model.users')->id($this->created_by)->getItem();
             $this->_usergroups = $user->usergroups;
         }
         return $this->_usergroups;
     }
     return parent::__get($column);
 }