예제 #1
0
/**
* Saves the module after an edit form submit
*/
function saveMambot($option, $client, $task)
{
    global $database;
    $params = mosGetParam($_POST, 'params', '');
    if (is_array($params)) {
        $txt = array();
        foreach ($params as $k => $v) {
            $txt[] = "{$k}={$v}";
        }
        $_POST['params'] = mosParameters::textareaHandling($txt);
    }
    $row = new mosMambot($database);
    if (!$row->bind($_POST)) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    if (!$row->check()) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    if (!$row->store()) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    $row->checkin();
    if ($client == 'admin') {
        $where = "client_id='1'";
    } else {
        $where = "client_id='0'";
    }
    $row->updateOrder("folder='{$row->folder}' AND ordering > -10000 AND ordering < 10000 AND ({$where})");
    switch ($task) {
        case 'apply':
            $msg = sprintf(T_('Successfully Saved changes to Mambot: %s'), $row->name);
            mosRedirect('index2.php?option=' . $option . '&client=' . $client . '&task=editA&hidemainmenu=1&id=' . $row->id, $msg);
        case 'save':
        default:
            $msg = sprintf(T_('Successfully Saved Mambot: %s'), $row->name);
            mosRedirect('index2.php?option=' . $option . '&client=' . $client, $msg);
            break;
    }
}
예제 #2
0
파일: admin.mambots.php 프로젝트: cwcw/cms
/**
* Saves the module after an edit form submit
*/
function saveMambot($option, $client)
{
    global $database;
    $params = mosGetParam($_POST, 'params', '');
    if (is_array($params)) {
        $txt = array();
        foreach ($params as $k => $v) {
            $txt[] = "{$k}={$v}";
        }
        $_POST['params'] = implode("\n", $txt);
    }
    $row = new mosMambot($database);
    if (!$row->bind($_POST)) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    if (!$row->check()) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    if (!$row->store()) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    $row->checkin();
    if ($client == 'admin') {
        $where = "client_id='1'";
    } else {
        $where = "client_id='0'";
    }
    $row->updateOrder("folder='{$row->folder}' AND ordering > -10000 AND ordering < 10000 AND ({$where})");
    mosRedirect('index2.php?option=' . $option . '&client=' . $client);
}
예제 #3
0
function saveOrder(&$cid)
{
    global $database;
    josSpoofCheck();
    $total = count($cid);
    $order = josGetArrayInts('order');
    $row = new mosMambot($database);
    $conditions = array();
    // update ordering values
    for ($i = 0; $i < $total; $i++) {
        $row->load((int) $cid[$i]);
        if ($row->ordering != $order[$i]) {
            $row->ordering = $order[$i];
            if (!$row->store()) {
                echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n";
                exit;
            }
            // if
            // remember to updateOrder this group
            $condition = "folder = " . $database->Quote($row->folder) . " AND ordering > -10000 AND ordering < 10000 AND client_id = " . (int) $row->client_id;
            $found = false;
            foreach ($conditions as $cond) {
                if ($cond[1] == $condition) {
                    $found = true;
                    break;
                }
            }
            // if
            if (!$found) {
                $conditions[] = array($row->id, $condition);
            }
        }
        // if
    }
    // for
    // execute updateOrder for each group
    foreach ($conditions as $cond) {
        $row->load($cond[0]);
        $row->updateOrder($cond[1]);
    }
    // foreach
    $msg = 'Nova ordenação salva';
    mosRedirect('index2.php?option=com_mambots', $msg);
}