Ejemplo n.º 1
0
function addUserGroup($location, $type, $profile, $redirect = true)
{
    $mainframe = JFactory::getApplication();
    $database = JFactory::getDBO();
    $error_num = 0;
    $count = 0;
    cleanMessageQueue();
    if (!isset($_POST[$type]) || !isset($_POST[$profile])) {
        if ($redirect) {
            $mainframe->redirect("index.php?option=com_jfuploader&act=user", JText::_('MES_MAP_NOSEL'));
        } else {
            return;
        }
    }
    foreach ($_POST[$type] as $jgroup) {
        $count++;
        $database->setQuery('SELECT * FROM #__joomla_flash_uploader_user u where u.jgroup=' . $jgroup . ' and u.profile=' . $_POST[$profile]);
        if (count($database->loadObjectList()) == 0) {
            $row = new joomla_flash_uploader_user($database);
            $row->profile = $_POST[$profile];
            $row->jgroup = $jgroup;
            $row->location = $location;
            if (!$row->store()) {
                $error_num++;
            }
        } else {
            $error_num++;
        }
    }
    // $row->bind($_POST);
    $_SESSION['LAST_PROFILE'] = $row->profile;
    if ($redirect) {
        if ($error_num > 0) {
            $mainframe->redirect("index.php?option=com_jfuploader&act=user", $error_num . JText::_('MES_EXISTS'));
        } else {
            $mainframe->redirect("index.php?option=com_jfuploader&act=user", JText::_('MES_MAP_SAVED'));
        }
    }
}
function addUser()
{
    global $mainframe;
    $database =& JFactory::getDBO();
    $error_num = 0;
    cleanMessageQueue();
    if (!isset($_POST['user']) || !isset($_POST['profile'])) {
        $mainframe->redirect("index2.php?option=com_joomla_flash_uploader&act=user", JText::_('MES_MAP_NOSEL'));
    }
    foreach ($_POST['user'] as $singleuser) {
        $row = new joomla_flash_uploader_user($database);
        $row->profile = $_POST['profile'];
        $row->user = $singleuser;
        if (!$row->store()) {
            $error_num++;
        }
    }
    $row->bind($_POST);
    $_SESSION['LAST_PROFILE'] = $row->profile;
    if ($error_num > 0) {
        $mainframe->redirect("index2.php?option=com_joomla_flash_uploader&act=user", $error_num . JText::_('MES_EXISTS'));
    } else {
        $mainframe->redirect("index2.php?option=com_joomla_flash_uploader&act=user", JText::_('MES_MAP_SAVED'));
    }
}