$section->sef_name = $router->encode($section->name); } if (!section::isValidName($section->sef_name)) { expValidator::failAndReturnToForm('You have invalid characters in the SEF Name field.'); } if (section::isDuplicateName($section)) { expValidator::failAndReturnToForm(gt('The name specified in the SEF Name field is a duplicate of an existing page.')); } 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 $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); // New section. Insert a new database record. $section->id = $db->insertObject($section, 'section'); } expSession::clearAllUsersSessionCache('navigationmodule'); navigationmodule::checkForSectionalAdmins($section->id); // Go back to where we came from. Probably the navigation manager. expHistory::back(); } else { echo SITE_403_HTML; }
foreach ($moveNextSiblings as $value) { $value->rank = $value->rank + 1; eDebug($value); $db->updateObject($value, 'section'); } $db->updateObject($moveSec, 'section'); //handle re-ranking of previous parent $oldSiblings = $db->selectObjects("section", "parent=" . $oldParent . " AND rank>" . $oldRank . " ORDER BY rank"); $rerank = 0; foreach ($oldSiblings as $value) { if ($value->id != $moveSec->id) { $value->rank = $rerank; $db->updateObject($value, 'section'); $rerank++; } } if ($oldParent != $moveSec->parent) { //we need to re-rank the children of the parent that the miving section has just left $chilOfLastMove = $db->selectObjects("section", "parent=" . $oldParent . " ORDER BY rank"); for ($i = 0; $i < count($chilOfLastMove); $i++) { $chilOfLastMove[$i]->rank = $i; $db->updateObject($chilOfLastMove[$i], 'section'); } } } } navigationmodule::checkForSectionalAdmins($move); expSession::clearAllUsersSessionCache('navigationmodule'); } else { echo SITE_403_HTML; }