/** * Mark this section as the default for this offering * * @return boolean */ public function makeDefault() { if (!$this->exists() || !$this->get('offering_id')) { return true; } $sections = $this->_tbl->find(array('offering_id' => $this->get('offering_id'))); foreach ($sections as $section) { $section = new Section($section); $section->set('is_default', 0); $section->store(false); } $this->set('is_default', 1); return $this->store(false); }
/** * Create a section linked to this offering * * @param boolean $validate Validate data? * @return boolean True on success, False on error */ public function makeSection($alias = '__default', $is_default = 1) { $section = new Section(); $section->set('offering_id', $this->get('id')); $section->set('alias', $alias); $section->set('title', Lang::txt('Default')); $section->set('state', 1); $section->set('is_default', $is_default); $section->set('enrollment', $this->config('default_enrollment', 0)); $section->set('start_date', $this->get('start_date')); $section->set('end_date', $this->get('end_date')); $section->set('publish_up', $this->get('publish_up')); $section->set('publish_down', $this->get('publish_down')); if (!$section->store()) { $this->setError($section->getError()); return false; } $this->_sections = null; return true; }