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 saveCatOrder(&$cid) { $app = JFactory::getApplication('administrator'); $db = JFactory::getDBO(); $total = count($cid); $order = JRequest::getVar('order', array(0), 'post', 'array'); JArrayHelper::toInteger($order, array(0)); $row = new DatsoCategories($db); for ($i = 0; $i < $total; $i++) { $row->load((int) $cid[$i]); if ($row->ordering != $order[$i]) { $row->ordering = $order[$i]; if (!$row->store()) { JError::raiseError(500, $db->getErrorMsg()); } } } $app->redirect('index.php?option=com_datsogallery&task=showcatg', JText::_('COM_DATSOGALLERY_ORDERING_OK')); }
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()); } } } }