static function update($values, $object, $loc) { global $db; // check if this is a controller or module $iscontroller = expModules::controllerExists($values['i_mod']); if (!isset($values['id'])) { // Only deal with the inc/dec stuff if adding a module. $src = ""; if (empty($values['existing_source'])) { $src = "@random" . uniqid(""); $object->is_existing = 0; $object->is_existing = 0; } else { $src = $values['existing_source']; $object->is_existing = 1; } // set the location data for the new module/controller $newInternal = expCore::makeLocation($values['modcntrol'], $src); // REFERENCES - Section and Location //$sect = $db->selectObject('section','id='.$_POST['current_section']); expCore::incrementLocationReference($newInternal, intval($_POST['current_section'])); // Rank is only updateable from the order action $object->rank = $values['rank']; // if (isset($values['rerank'])) $db->increment("container","rank",1,"external='".serialize($loc)."' AND rank >= " . $values['rank']); if (isset($values['rerank']) && $values['rerank']) { $db->increment("container", "rank", 1, "external='" . serialize($loc) . "' AND rank >= " . $values['rank']); } $object->internal = serialize($newInternal); $object->external = serialize($loc); } $object->is_private = isset($_POST['is_private']) ? 1 : 0; // UPDATE the container $object->action = isset($values['actions']) ? $values['actions'] : null; //$object->view = $iscontroller ? $values['ctlview'] : $values['view']; $object->view = $values['views']; $object->title = $values['title']; return $object; }
function copyContent($oloc, $nloc, $section = 0) { global $db; foreach ($db->selectObjects('container', "external='" . serialize($oloc) . "'") as $c) { unset($c->id); $c->external = serialize($nloc); if (!$c->is_existing == 1) { // Copy over content to a new source $oldinternal = unserialize($c->internal); $iloc = expCore::makeLocation($oldinternal->mod, '@random' . uniqid('')); $c->internal = serialize($iloc); $db->insertObject($c, 'container'); // Now copy over content if (call_user_func(array($oldinternal->mod, 'hasContent')) == true) { call_user_func(array($oldinternal->mod, 'copyContent'), $oldinternal, $iloc); // Incrementors! expCore::incrementLocationReference($iloc, $section); // SECTION } } else { $db->insertObject($c, 'container'); expCore::incrementLocationReference($iloc, $section); // SECTION } } }