function approve_cats($cat_id, $publish = 0, $option) { global $mainframe; $database =& JFactory::getDBO(); $mtCats = new mtCats($database); if (!is_array($cat_id) || count($cat_id) < 1) { echo "<script> alert('" . JText::_('Select an item to approve') . "'); window.history.go(-1);</script>\n"; exit; } if (count($cat_id)) { foreach ($cat_id as $cid) { $mtCats->load($cid); $mtCats->approveCat(); $mtCats->publishCat($publish); if ($mtCats->lft == 0 && $mtCats->rgt == 0) { $mtCats->updateLftRgt(); } $mtCats->updateCatCount(1); } } $mainframe->redirect("index2.php?option={$option}&task=listpending_cats", sprintf(JText::_('Cats have been aprroved'), count($cat_id))); }
function addcategory2($option) { global $Itemid, $mtconf, $mainframe; // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); $database =& JFactory::getDBO(); $my =& JFactory::getUser(); $jdate = JFactory::getDate(); $now = $jdate->toMySQL(); # Get cat_parent $cat_parent = JRequest::getInt('cat_parent', 0); # Check if any malicious user is trying to submit link if ($mtconf->get('user_addcategory') == 1 && $my->id <= 0) { echo _NOT_EXIST; } else { # Allowed $post = JRequest::get('post'); $row = new mtCats($database); if (!$row->bind($post)) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } $isNew = $row->cat_id < 1; # Assignment for new record if ($isNew) { $jdate = JFactory::getDate(); $row->cat_created = $now; // Required approval if ($mtconf->get('needapproval_addcategory')) { $row->cat_approved = '0'; } else { $row->cat_approved = 1; $row->cat_published = 1; $cache =& JFactory::getCache('com_mtree'); $cache->clean(); } } else { # Assignment for exsiting record $row->cat_modified = $now; } # OK. Store new category into database if (!$row->store()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } if ($isNew && !$mtconf->get('needapproval_addcategory')) { $row->updateLftRgt(); $row->updateCatCount(1); } $mainframe->redirect(JRoute::_("index.php?option={$option}&task=listcats&cat_id={$cat_parent}&Itemid={$Itemid}"), $mtconf->get('needapproval_addcategory') ? JText::_('Category will be reviewed') : JText::_('Category have been added')); } }
function addcategory2( $option ) { global $Itemid, $mtconf; $app = JFactory::getApplication('site'); // Check for request forgeries JRequest::checkToken() or jexit( 'Invalid Token' ); $database =& JFactory::getDBO(); $my =& JFactory::getUser(); $jdate = JFactory::getDate(); $now = $jdate->toMySQL(); # Get cat_parent $cat_parent = JRequest::getInt('cat_parent', 0); # Check if any malicious user is trying to submit link if ( $mtconf->get('user_addcategory') == 1 && $my->id <= 0 ) { echo JText::_( 'NOT_EXIST' ); } elseif( $mtconf->get('user_addcategory') == '-1' ) { # Add category is disabled JError::raiseError(404, JText::_('Resource Not Found')); } else { # Allowed $post = JRequest::get( 'post' ); $row = new mtCats( $database ); if (!$row->bind( $post )) { echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; exit(); } $isNew = $row->cat_id < 1; # Assignment for new record if ($isNew) { $jdate = JFactory::getDate(); $row->cat_created = $now; $row->alias = JFilterOutput::stringURLSafe($row->cat_name); // Required approval if ( $mtconf->get('needapproval_addcategory') ) { $row->cat_approved = '0'; } else { $row->cat_approved = 1; $row->cat_published = 1; $cache = &JFactory::getCache('com_mtree'); $cache->clean(); } } else { # Assignment for exsiting record $row->cat_modified = $now; } # OK. Store new category into database if (!$row->store()) { echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; exit(); } if ( $isNew && !$mtconf->get('needapproval_addcategory')) { $row->updateLftRgt(); $row->updateCatCount( 1 ); } $app->redirect( JRoute::_("index.php?option=$option&task=listcats&cat_id=$cat_parent&Itemid=$Itemid"), ( ($mtconf->get('needapproval_addcategory')) ? JText::_( 'Category will be reviewed' ) : JText::_( 'Category have been added' )) ); } }