예제 #1
0
}
$check_id = -1;
$section = null;
$old_parent = null;
if (isset($_POST['id'])) {
    // Saving an existing content page.  Read it from the database.
    $section = $db->selectObject('section', 'id=' . intval($_POST['id']));
    if ($section) {
        $old_parent = $section->parent;
        $check_id = $section->id;
    }
} else {
    $check_id = $_POST['parent'];
}
// Update the section from the _POST data.
$section = section::updateExternalAlias($_POST, $section);
if ($check_id != -1 && expPermissions::check('manage', expCore::makeLocation('navigationmodule', '', $check_id))) {
    if (isset($section->id)) {
        if ($section->parent != $old_parent) {
            // Old_parent id was different than the new parent id.  Need to decrement the ranks
            // of the old children (after ours), and then add
            $section = section::changeParent($section, $old_parent, $section->parent);
        }
        // Existing section.  Update the database record.
        // The 'id=x' where clause is implicit with an updateObject
        expSession::clearAllUsersSessionCache('navigationmodule');
        $db->updateObject($section, 'section');
    } else {
        // Since this is new, we need to increment ranks, in case the user
        // added it in the middle of the level.
        $db->increment('section', 'rank', 1, 'rank >= ' . $section->rank . ' AND parent=' . $section->parent);