$HeightUnit = trim($params->get('heightunit', 'px')); $PicsNum = intval($params->get('PicsNum', '5')); $PickMethod = trim($params->get('PickMethod', 'Rand()')); $ScrollDirection = trim($params->get('ScrollDirection', 'up')); $ScrollAmount = intval($params->get('ScrollAmount', '2')); $ScrollDelay = intval($params->get('ScrollDelay', '50')); $ScrollSpace = intval($params->get('ScrollSpace', '2')); $BugSpace = intval($params->get('BugSpace', '10')); $usecss = $params->get('usecss', '1'); $css = $params->get('css'); //determine which gallery id's to use //use ACL if ($useACL) { global $rsgAccess; //check if acl is activated if (rsgAccess::aclActivated()) { //make list of allowed gallery_ids $gal_ids = $rsgAccess->actionPermitted('view'); if ($usegalselect) { if (in_array($galselect, $gal_ids)) { $list = "WHERE #__rsgallery2_files.gallery_id IN(" . $galselect . ")"; } else { echo "One or more gallery id limits is not viewable for the current usertype"; exit; } } else { $list = "WHERE #__rsgallery2_files.gallery_id IN(" . implode(",", $gal_ids) . ")"; } } else { echo "ACL not enabled in RSGallery2 config<br>Enable it, or also disable it for this module"; exit;
/** * function will create initial permissions for all existing galleries * Is called only once from install script on upgrade. */ function initializePermissions() { $database =& JFactory::getDBO(); $i = 0; $sql = "SELECT id FROM #__rsgallery2_galleries"; $database->setQuery($sql); $row = $database->loadResultArray(); if (count($row) < 1) { return false; } else { foreach ($row as $id) { if (!rsgAccess::createDefaultPermissions($id)) { $i++; } } } if ($i > 0) { return true; } else { return false; } }
function saveCat() { global $rsgConfig, $mainframe; $my = JFactory::getUser(); $database = JFactory::getDBO(); //If gallery creation is disabled, unauthorized attempts die here. if (!$rsgConfig->get('uu_createCat')) { die("User category creation is disabled by administrator."); } //Set redirect URL $redirect = JRoute::_("index.php?option=com_rsgallery2&rsgOption=myGalleries", false); $parent = rsgInstance::getVar('parent', 0); $id = rsgInstance::getInt('catid', null); $catname1 = rsgInstance::getstring('catname1', null); $description = rsgInstance::getVar('description', null, 'post', 'string', JREQUEST_ALLOWRAW); $published = rsgInstance::getInt('published', 0); $ordering = rsgInstance::getInt('ordering', null); $maxcats = $rsgConfig->get('uu_maxCat'); //escape strings for sql query $alias = $database->getEscaped(JFilterOutput::stringURLSafe($catname1)); $catname1 = $database->getEscaped($catname1); $description = $database->getEscaped($description); if ($id) { $database->setQuery("UPDATE #__rsgallery2_galleries SET " . "name = '{$catname1}', " . "description = '{$description}', " . "published = '{$published}', " . "parent = '{$parent}' " . "WHERE id = '{$id}' "); if ($database->query()) { $mainframe->redirect($redirect, JText::_('Gallery details updated!')); } else { $mainframe->redirect($redirect, JText::_('Could not update gallery details!')); } } else { //New category $userCatTotal = galleryUtils::userCategoryTotal($my->id); if (!isset($parent)) { $parent = 0; } if ($userCatTotal >= $maxcats) { ?> <script type="text/javascript"> //<![CDATA[ alert('<?php echo JText::_('MAX_USERCAT_ALERT'); ?> '); location = '<?php echo JRoute::_("index.php?option=com_rsgallery2&page=my_galleries", false); ?> '; //]]> </script> <?php //$mainframe->redirect( $redirect ,JText::_('MAX_USERCAT_ALERT')); } else { //Create ordering, start at last position $database->setQuery("SELECT MAX(ordering) FROM #__rsgallery2_galleries WHERE uid = '{$my->id}'"); $ordering = $database->loadResult() + 1; //Insert into database $database->setQuery("INSERT INTO #__rsgallery2_galleries " . "(name, description, alias, ordering, parent, published, user, uid, date) VALUES " . "('{$catname1}','{$description}','{$alias}','{$ordering}','{$parent}','{$published}','1' ,'{$my->id}', now())"); if ($database->query()) { //Create initial permissions for this gallery $database->setQuery("SELECT id FROM #__rsgallery2_galleries WHERE name = '{$catname1}' LIMIT 1"); $gallery_id = $database->loadResult(); $acl = new rsgAccess(); if ($acl->createDefaultPermissions($gallery_id)) { $mainframe->redirect($redirect, JText::_('New gallery created!')); } } else { $mainframe->redirect($redirect, JText::_('ALERT_NONEWCAT')); } } } //$mainframe->redirect( $redirect ); }