コード例 #1
0
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']);
    }
}
コード例 #2
0
function movePicResult($id)
{
    $app = JFactory::getApplication('administrator');
    $db =& JFactory::getDBO();
    $id = JRequest::getVar('id', array(0), '', 'array');
    $movepic = JRequest::getVar('catid', 'post');
    if (!$movepic || $movepic == 0) {
        echo "<script> alert('" . JText::_('COM_DATSOGALLERY_MUST_SELECT_CATEGORY') . "'); window.history.go(-1);</script>\n";
        exit;
    } else {
        $pic = new DatsoImages($db);
        $pic->id = $pic->getNextOrder('catid = ' . $movepic);
        $pic->dgMove($id, $movepic);
        $ids = implode(',', $id);
        $total = count($id);
        $cat = new DatsoCategories($db);
        $cat->load($movepic);
        $msg = $total . JText::_('COM_DATSOGALLERY_TOTAL_PICS_MOVED') . $cat->name;
        $app->redirect('index.php?option=com_datsogallery&task=pictures', $msg);
    }
}
コード例 #3
0
function catNameById($cat)
{
    $db = JFactory::getDBO();
    $row = new DatsoCategories($db);
    $row->load($cat);
    return $row->name;
}