function saveCatg() { require JPATH_COMPONENT_ADMINISTRATOR . DS . 'config.datsogallery.php'; $is_admin = array(7, 8); $db = JFactory::getDBO(); $user = JFactory::getUser(); $userGroups = JAccess::getGroupsByUser($user->id, true); $post = JRequest::get('post'); //$post['description'] = JRequest::getVar('description', '', 'post', 'string', JREQUEST_ALLOWRAW); $row = new DatsoCategories($db); if (!array_intersect($is_admin, $userGroups)) { $category = explode(',', $ad_category); $getfirst = array_shift($category); $db->setQuery('SELECT cid' . ' FROM #__datsogallery_catg' . ' WHERE user_id = ' . (int) $user->id . ' AND parent = ' . $ad_category); $result = $db->loadResult(); $row->parent = $result ? $result : $ad_category; $row->ordering = $row->getNextOrder('parent = ' . $row->parent); } else { $row->ordering = $row->getNextOrder('parent = 0'); } $row->user_id = $user->id; $row->approved = !$user_categories_approval || array_intersect($is_admin, $userGroups) ? 1 : 0; $row->published = 1; jimport('joomla.utilities.date'); $dtz = new DateTimeZone(JFactory::getApplication()->getCfg('offset')); $date = new JDate($row->date); $date->setTimezone($dtz); $row->date = $date->toMySQL(true); if (!$row->bind($post)) { JError::raiseError(500, $row->getError()); } if (!$row->check()) { JError::raiseError(500, $row->getError()); } if (!$row->store()) { JError::raiseError(500, $row->getError()); } if ($ad_category_notify && !array_intersect($is_admin, $userGroups)) { categoryNotify($user->username, $post['name']); } }
function orderCatg($uid, $inc) { $app = JFactory::getApplication('administrator'); JRequest::checkToken() or jexit('Invalid Token'); $db =& JFactory::getDBO(); $row = new DatsoCategories($db); $row->load($uid); if (!$row->move($inc, 'parent = ' . $db->Quote($row->parent))) { $this->setError($row->getError()); return false; } $app->redirect('index.php?option=com_datsogallery&task=showcatg'); }
function createNewMemberAlbum() { require JPATH_COMPONENT_ADMINISTRATOR . DS . 'config.datsogallery.php'; $is_admin = array(7, 8); $db = JFactory::getDBO(); $user = JFactory::getUser(); $userGroups = JAccess::getGroupsByUser($user->id, true); $row = new DatsoCategories($db); if (!array_intersect($is_admin, $userGroups) && $user_categories) { $db->setQuery('SELECT cid' . ' FROM #__datsogallery_catg' . ' WHERE user_id = ' . $user->id . ' AND parent = ' . $ad_category); $result = $db->loadResult(); if (!$result) { $row->name = $user->name; $row->description = JText::sprintf('COM_DATSOGALLERY_NEW_ALBUM_DESC', $user->name); $row->parent = $ad_category; $row->ordering = $row->getNextOrder('parent = ' . $row->parent); $row->user_id = $user->id; $row->approved = 1; $row->published = 1; jimport('joomla.utilities.date'); $dtz = new DateTimeZone(JFactory::getApplication()->getCfg('offset')); $date = new JDate($row->date); $date->setTimezone($dtz); $row->date = $date->toMySQL(true); if (!$row->check()) { JError::raiseError(500, $row->getError()); } if (!$row->store()) { JError::raiseError(500, $row->getError()); } } } }