/** * Store changes to this entry * * @param boolean $check Perform data validation check? * @return boolean False if error, True on success */ public function store($check = true) { $value = parent::store($check); if ($value && $this->get('section_id')) { $dt = new Tables\SectionDate($this->_db); $dt->load($this->get('id'), $this->_scope, $this->get('section_id')); $dt->set('publish_up', $this->get('publish_up')); $dt->set('publish_down', $this->get('publish_down')); if (!$dt->get('id')) { $dt->set('section_id', $this->get('section_id')); $dt->set('scope', $this->_scope); $dt->set('scope_id', $this->get('id')); $dt->set('created', Date::toSql()); $dt->set('created_by', User::get('id')); } if (!$dt->store()) { $this->setError($dt->getError()); } } if ($value) { $this->importPlugin('courses')->trigger('onUnitSave', array($this)); } return $value; }
/** * Store changes to this entry * * @param boolean $check Perform data validation check? * @return boolean False if error, True on success */ public function store($check = true) { $value = parent::store($check); if ($value && $this->get('section_id')) { $dt = new Tables\SectionDate($this->_db); $dt->load($this->get('id'), $this->_scope, $this->get('section_id')); $dt->set('publish_up', $this->get('publish_up')); $dt->set('publish_down', $this->get('publish_down')); if (!$dt->store()) { $this->setError($dt->getError()); } } $properties = get_object_vars($this->_tbl); foreach ($properties as $k => $v) { $kname = substr($k, 2); if (!empty($kname) && array_key_exists($kname, self::$_aux_tablekeys)) { $key = $kname; $key = str_replace('_', ' ', $key); $key = ucwords($key); $key = str_replace(' ', '', $key); $tbl = "Components\\Courses\\Tables\\{$key}"; $tbl = new $tbl($this->_db); if ($v == 'delete') { $aux = array(); foreach (self::$_aux_tablekeys[$kname] as $item) { $k = $item; if ($item == 'id') { $k = $this->_scope . '_' . $item; } $aux[$k] = $this->get((string) $item); } $tbl->load($aux); $tbl->delete(); } else { $tbl->save($v); } } } return $value; }