/** * 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; }
/** * Returns a property of the object or the default value if the property is not set. * * @param string $property The name of the property * @param mixed $default The default value if property not found * @return mixed The value of the property */ public function get($property, $default = null) { if (isset($this->_tbl->{$property})) { return $this->_tbl->{$property}; } else { if (isset($this->_tbl->{'__' . $property})) { return $this->_tbl->{'__' . $property}; } else { if (in_array($property, self::$_section_keys)) { $tbl = new Tables\SectionDate($this->_db); $tbl->load($this->get('id'), 'asset', $this->get('section_id')); $this->set('publish_up', $tbl->get('publish_up', '')); $this->set('publish_down', $tbl->get('publish_down', '')); return $tbl->get($property, $default); } else { if (strpos($property, '.') !== false) { $parts = explode('.', $property); if (isset($parts[0]) && array_key_exists($parts[0], self::$_aux_tablekeys)) { $key = str_replace('_', ' ', $parts[0]); $key = ucwords($key); $key = str_replace(' ', '', $key); $tbl = "Components\\Courses\\Tables\\{$key}"; $tbl = new $tbl($this->_db); $aux = array(); foreach (self::$_aux_tablekeys[$parts[0]] as $item) { $k = $item; if ($item == 'id') { $k = $this->_scope . '_' . $item; } $aux[$k] = $this->get((string) $item); } $tbl->load($aux); return $tbl->get($parts[1], $default); } } } } } return $default; }