/** * Displays details about the logged in user and the privileges he/she has * $param integer User ID from Joomla user table */ function RSGalleryUserInfo($id) { global $rsgConfig; $my = JFactory::getUser(); if ($my->usertype == "Super Administrator" or $my->usertype == "Administrator") { $maxcat = JText::_('COM_RSGALLERY2_UNLIMITED'); $max_images = JText::_('COM_RSGALLERY2_UNLIMITED'); } else { $maxcat = $rsgConfig->get('uu_maxCat'); $max_images = $rsgConfig->get('uu_maxImages'); } ?> <table class="adminform" border="1"> <tr> <th colspan="2"><?php echo JText::_('User information'); ?> </th> </tr> <tr> <td width="250"><?php echo JText::_('Username'); ?> </td> <td><?php echo $my->username; ?> </td> </tr> <tr> <td><?php echo JText::_('User level'); ?> </td> <td><?php echo $my->usertype; ?> </td> </tr> <tr> <td><?php echo JText::_('Maximum usergalleries'); ?> </td> <td><?php echo $maxcat; ?> (<font color="#008000"><strong><?php echo galleryUtils::userCategoryTotal($my->id); ?> </strong></font> <?php echo JText::_('created)'); ?> </td> </tr> <tr> <td><?php echo JText::_('Maximum images allowed'); ?> </td> <td><?php echo $max_images; ?> (<font color="#008000"><strong><?php echo galleryUtils::userImageTotal($my->id); ?> </strong></font> <?php echo JText::_('uploaded)'); ?> </td> </tr> <tr> <th colspan="2"></th> </tr> </table> <br><br> <?php }
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 ); }