Ejemplo n.º 1
0
/**
* Saves the record from an edit form submit
* @param string The current GET/POST option
*/
function saveContact($option)
{
    global $database;
    $row = new mosContact($database);
    if (!$row->bind($_POST)) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    // save params
    $params = mosGetParam($_POST, 'params', '');
    if (is_array($params)) {
        $txt = array();
        foreach ($params as $k => $v) {
            $txt[] = "{$k}={$v}";
        }
        $row->params = implode("\n", $txt);
    }
    // pre-save checks
    if (!$row->check()) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    // save the changes
    if (!$row->store()) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    $row->checkin();
    $row->updateOrder();
    if ($row->default_con) {
        $database->setQuery("UPDATE #__contact_details SET default_con='0' WHERE id <> {$row->id} AND default_con='1'");
        $database->query();
    }
    mosRedirect("index2.php?option={$option}");
}
Ejemplo n.º 2
0
/** JJC
* Moves the order of a record
* @param integer The increment to reorder by
*/
function orderContacts($uid, $inc, $option)
{
    global $database;
    $row = new mosContact($database);
    $row->load((int) $uid);
    $row->updateOrder();
    $row->move($inc, "published >= 0");
    $row->updateOrder();
    mosRedirect("index2.php?option={$option}");
}