function set_borrowship_first_level() { $borrows_rel_id = get_borrows_relationship_id($this->admin_page->type_id); if (!empty($this->admin_page->request['unborrow'])) { //do query removing borrowship delete_borrowed_relationship($this->admin_page->site_id, $this->admin_page->id, $borrows_rel_id); } else { //do query creating borrowship create_relationship($this->admin_page->site_id, $this->admin_page->id, $borrows_rel_id); } }
function process_editor_submission() { if (!$this->course->get_value('sourced_id')) { $this->course->set_value('org_id', $this->form->get_value('subject')); $this->course->set_value('course_number', $this->form->get_value('course_number')); } $this->course->set_value('list_of_prerequisites', $this->form->get_value('prerequisites')); $this->course->set_value('credits', $this->form->get_value('credits')); $this->course->set_value('title', $this->form->get_value('title')); $this->course->set_value('long_description', $this->form->get_value('description')); reason_update_entity($this->course->id(), get_user_id(reason_check_authentication()), $this->course->get_values(), true); // Apply title and description changes to selected sections if ($sections = $this->course->get_sections()) { var_dump($sections); foreach ($this->form->get_value('sections') as $id) { if (isset($sections[$id])) { $sections[$id]->set_value('title', $this->form->get_value('title')); $sections[$id]->set_value('long_description', $this->form->get_value('description')); reason_update_entity($id, get_user_id(reason_check_authentication()), $sections[$id]->get_values(), true); } } } if ($this->form->get_value('display_in_catalog') && !$this->course->owned_or_borrowed_by($this->site_id)) { create_relationship($this->site_id, $this->course->id(), get_borrows_relationship_id(id_of('course_template_type'))); } else { if (!$this->form->get_value('display_in_catalog') && $this->course->owned_or_borrowed_by($this->site_id)) { delete_borrowed_relationship($this->site_id, $this->course->id(), get_borrows_relationship_id(id_of('course_template_type'))); } } }