Пример #1
0
 /**
  * Saves the permissions from the form into the database
  * @param array Array with permissions
  * @return boolean True if succesfull, false if otherwise
  */
 function savePermissions($perms, $gallery_id)
 {
     $database =& JFactory::getDBO();
     //Check if permissions are set, if not, create them
     if (rsgAccess::arePermissionsSet($gallery_id)) {
         $parent_id = galleryUtils::getParentId($gallery_id);
         $sql = "UPDATE {$this->_table} SET ";
         // assemble actions and add them to sql query
         foreach ($this->levels as $level) {
             foreach ($this->actions as $action) {
                 $sql .= $level . '_' . $action . " = '" . $perms[$level . '_' . $action] . "', ";
             }
         }
         $sql = substr($sql, 0, -2);
         $sql .= " WHERE gallery_id = '{$gallery_id}'";
         $database->setQuery($sql);
         if ($database->query()) {
             return true;
         } else {
             return false;
         }
     } else {
         //
         if (rsgAccess::createDefaultPermissions($gallery_id)) {
             return true;
         } else {
             return false;
         }
     }
 }