Example #1
0
 /**
  * Returns all gallery_id's where a specific action is permitted
  * @param integer Action we want to check
  * @return array Array with selected gallery_id's
  */
 function actionPermitted($action)
 {
     $database =& JFactory::getDBO();
     $my =& JFactory::getUser();
     //Check usertype of the logged in user
     $type = rsgAccess::returnUserType();
     //Get action based on that usertype
     $type = $this->levelMaping[$type];
     if ($type == 'admin') {
         // all actions permitted for admin users
         $sql = "SELECT id FROM #__rsgallery2_galleries ";
         $database->setQuery($sql);
         $galleries = $database->loadResultArray();
     } else {
         // get galleries where action is permitted for the user group
         $type = $type . "_" . $action;
         $sql = "SELECT gallery_id FROM {$this->_table} WHERE " . $type . " = 1";
         $database->setQuery($sql);
         $galleries = $database->loadResultArray();
         // check if user is logged in
         if ($my->id) {
             // if so add galleries owned by users to list
             $sql = "SELECT id FROM #__rsgallery2_galleries WHERE uid = '{$my->id}'";
             $database->setQuery($sql);
             $galleries = array_merge($galleries, $database->loadResultArray());
         }
     }
     return $galleries;
 }