/** * Save the given entries in the profile specified by id. * @param string $id The id of the layout to query. 0 to add a new layout. * @param string $name The new name of the layout. * @param array $entries A numeric array of {@link SloodleLayoutEntry} objects to store * @param bool $add (Default: false) If true, then the entries will be added to the layout instead of replacing existing entries * @return bool True if successful, or false otherwise */ function save_layout_by_id($id, $name, $entries, $add = false) { // Attempt to find the relevant layout if ($id > 0) { /* // Delete all existing entries if necessary // This will happen when we save // TODO: make add-only functionality for backwards compatibility if (!$add) { delete_records('sloodle_layout_entry', 'layout', $layout->id); } */ $layout = $this->get_layout($id); $layout->name = $name; $layout->timeupdated = time(); $layout->entries = $entries; $layout->populate_entries_from_active_objects(); // where the records have objectuuids set, copy their settings if (!$layout->update()) { return false; } $this->layout = $layout; } else { $layout = new SloodleLayout(); $layout->name = $name; $layout->course = $this->course_object->id; $layout->timeupdated = time(); $layout->entries = $entries; $layout->populate_entries_from_active_objects(); $layout->id = $layout->insert(); #insert_record('sloodle_layout', $layout); if (!$layout->id) { return false; } $this->layout = $layout; } /* // This should have been done by the layout // Insert each new entry $success = true; foreach ($entries as $e) { $rec = new stdClass(); $rec->layout = $layout->id; $rec->name = $e->name; $rec->position = $e->position; $rec->rotation = $e->rotation; // TODO EDE: If there's an objectuuid for the entry, copy the entries from the active object table to the layout config table if ($objectuuid != '') { $rec->copy_active_object_with_uuid($e->objectuuid); } $entry_id = insert_record('sloodle_layout_entry', $rec); } */ return $layout->id; }
} else { // show the add page even if the url didn't specify layoutid=0 $layoutid = 0; } */ //------------------------------------------------------ // Fetch current layout $currentlayoutentries = array(); $recommendedon = true; // Whether by default we turn on modules that aren't already in the layout we're looking at $layoutname = 'Layout ' . date('Y-m-d H:i:s'); if ($layoutid > 0) { $layout = new SloodleLayout(); $layout->load($layoutid); $currentlayoutentries = $sloodle_course->get_layout_entries_for_layout_id($layoutid); $recommendedon = false; // The user got a chance to use our recommended defaults when they added. Now we'll only turn on things that they did. $layoutname = $layout_names[$layoutid]; } //------------------------------------------------------ // Fetch possible options // if ($layoutid >= 0) { // add or edit layout $modinfo =& get_fast_modinfo($COURSE); $cmsmodules = $modinfo->cms; $instancemodulearrays = $modinfo->instances; $instancemodules = array();
function get_layout() { if ($this->layout != null) { $layout = new SloodleLayout(); if ($layout->load($this->layout)) { return $layout; } } return null; }