public function save() { parent::save(); /** * FIXME It's not possible to send an empty list to remove all assignees */ if (is_array($this->assignees)) { $table = KFactory::get('admin::com.jedi.table.tasks2members'); $query = $table->getDatabase()->getQuery()->where('jedi_task_id', '=', $this->id); $rowset = $table->select($query); $old = array(); $new = array_map('intval', $this->assignees); foreach ($rowset as $row) { $old[] = (int) $row->jedi_member_id; if (!in_array($row->jedi_member_id, $new)) { $row->delete(); } } $row = KFactory::get('admin::com.jedi.row.tasks2members'); foreach (array_diff($new, $old) as $assignee) { $row->reset(); $row->jedi_member_id = $assignee; $row->jedi_task_id = $this->id; $row->save(); } } return $this; }
public function __get($column) { if ($column == 'data' && is_string($this->_data['data'])) { $this->_data['data'] = json_decode($this->_data['data'], true); } return parent::__get($column); }
public function __get($name) { if ($name == 'relation' && is_null($this->relation)) { $this->relation = $this->getService('com://admin/attachments.database.table.relations')->select(array('attachments_attachment_id' => $this->id), KDatabase::FETCH_ROW); } return parent::__get($name); }
/** * @param $column * @return string */ public function __get($column) { if ($column == 'form_fields') { return $this->getService('com://admin/wufoo.model.api.fields')->id($this->hash)->getItem()->toArray(); } return parent::__get($column); }
/** * Return an associative array of the data. * * @return array */ public function toArray() { $data = parent::toArray(); $data['type'] = $this->type; $data['params'] = $this->params->toArray(); return $data; }
public function save() { if ($this->isNew()) { $this->created_by = null; } return parent::save(); }
public function toArray() { $data = parent::toArray(); unset($data['_thumbnail_size']); unset($data['source']); return $data; }
protected function _initialize(KConfig $config) { $config->append(array( 'table' => 'com://admin/articles.database.table.featured' )); parent::_initialize($config); }
public function delete() { // Remove records in jos_businesses_businesses_tags foreach ($this->getService('com://admin/businesses.model.businesses_tags')->business($this->id)->getList() as $value) { $this->getService('com://admin/businesses.model.businesses_tags')->businesses_business_id($this->id)->businesses_tag_id($value->businesses_tag_id)->getItem()->delete(); } return parent::delete(); }
public function getData($modified = false) { $data = parent::getData($modified); if (isset($data['parameters'])) { $data['parameters'] = $this->parameters->getData(); } return $data; }
public function toArray() { $data = parent::toArray(); $data['path'] = $this->path_value; $data['parameters'] = $this->getParameters()->toArray(); $data['relative_path'] = $this->getRelativePath(); return $data; }
public function __get($key) { if ($key == 'category_title') { return $this->getService('com://admin/carousel.model.category')->id($this->carousel_category_id)->getItem()->title; } else { return parent::__get($key); } }
/** * @return bool|void */ public function save() { if (!$this->load() && !$this->getOriginal()->original) { $this->original = 1; $this->translated = 1; } $this->lang = substr(JFactory::getLanguage()->getTag(), 0, 2); parent::save(); }
/** * Initializes the options for the object * * Called from {@link __construct()} as a first step of object instantiation. * * @param object An optional KConfig object with configuration options. * @return void */ protected function _initialize(KConfig $config) { $config->append(array( 'children' => null, 'parent' => null, )); parent::_initialize($config); }
public function save() { $source = $_FILES["file"]; if ($source["tmp_name"]) { $str = $this->generateThumbnail(); $this->setData(array('thumbnail' => $str)); } return parent::save(); }
/** * Specialized in order to dynamically get the type icon * * @TODO performance optimize this * * @param string The column name. */ public function __get($column) { if ($column == 'type') { if (!isset($this->_type)) { $this->_type = MediaHelper::getTypeIcon($this->name); } return $this->_type; } return parent::__get($column); }
public function delete() { // Before the delete we reset all the items connected to this category. $items = $this->getService('com://admin/carousel.model.items')->carousel_category_id($this->id)->getList(); foreach ($items as $item) { $item->enabled = false; $item->cck_category_id = null; $item->save(); } return parent::delete(); }
/** * Return an associative array of the data. * * @return array */ public function toArray() { $data = parent::toArray(); //Include the manifest fields foreach (self::$_manifest_fields as $field) { $data[$field] = (string) $this->{$field}; } $data['title'] = (string) $this->title; $data['params'] = $this->params->toArray(); return $data; }
public function __get($key) { $value = parent::__get($key); if ($key == 'metadata' && is_string($value)) { // Try to decode it. $metadata = json_decode($value); if ($metadata !== null) { $value = $metadata; } } return $value; }
/** * Retrieve row field value * * @param string The column name. * @return string The corresponding column value. */ public function __get($column) { if ($column == 'usergroups') { if (!$this->_usergroups) { $ids = explode('|', $this->ninjaboard_usergroup_id); $this->_usergroups = KFactory::tmp('admin::com.ninjaboard.model.usergroups')->limit(0)->id($ids)->getList(); } return $this->_usergroups; } if ($column == 'ninjaboard_usergroup_id') { if (!isset($this->_ninjaboard_usergroup_id)) { $original = parent::__get($column); $table = $this->getTable(); $query = $table->getDatabase()->getQuery(); $query->select("joomla_map.ninjaboard_gid AS ninjaboard_usergroup_id")->from('ninjaboard_joomla_user_group_maps AS joomla_map')->where('joomla_map.joomla_gid', '=', (int) $this->gid)->where('joomla_map.ninjaboard_gid', '!=', 0)->limit(1); $ninjaboard_usergroup_id = $table->getDatabase()->select($query, KDatabase::FETCH_FIELD, 'ninjaboard_usergroup_id'); if ($this->id) { $query = $table->getDatabase()->getQuery(); $query->select("ninjaboard_map.ninjaboard_user_group_id AS ninjaboard_usergroup_id")->from('ninjaboard_user_group_maps AS ninjaboard_map')->where('ninjaboard_map.joomla_user_id', '=', $this->id); $groups = $table->getDatabase()->select($query, KDatabase::FETCH_FIELD_LIST); $ninjaboard_usergroup_id = $groups ? implode('|', $groups) : $ninjaboard_usergroup_id; } $this->_ninjaboard_usergroup_id = $ninjaboard_usergroup_id; } return $this->_ninjaboard_usergroup_id; } if (strpos($column, '_permissions') !== false) { $object = str_replace('_permissions', '', $column); if (!isset($this->_permissions[$object])) { $table = KFactory::get('admin::com.ninjaboard.database.table.assets'); $query = KFactory::tmp('lib.koowa.database.query'); $gids = explode('|', $this->ninjaboard_usergroup_id); //If super admin, then the permission level is always 3 if ($this->gid == 25) { return $this->_permissions[$object] = 3; } $query->select('tbl.level')->from('ninjaboard_assets AS tbl')->order('tbl.level', 'DESC')->limit(1); $where = array(); foreach ($gids as $gid) { $where[] = 'com_ninjaboard.usergroup.' . $gid . '.' . $object; } if ($where) { $query->where('tbl.name', 'in', $where); } $this->_permissions[$object] = $table->getDatabase()->select($query, KDatabase::FETCH_FIELD); } return $this->_permissions[$object]; } return parent::__get($column); }
/** * Retrieve row field value * * @param string The column name. * @return string The corresponding column value. */ public function __get($column) { $result = parent::__get($column); if ($column != 'theme' || is_string($this->params) || !isset($this->params->board_details->theme)) { return $result; } if (!isset($this->_theme)) { if (!isset($this->_data['theme']) || !$this->_data['theme']) { $this->_data['theme'] = $this->params->board_details->theme; } $this->_theme = KInflector::humanize($this->_data['theme']); } return $this->_theme; }
public function save() { //Set the introtext and the full text $text = str_replace('<br>', '<br />', $this->text); $pattern = '#<hr\\s+id=("|\')system-readmore("|\')\\s*\\/*>#i'; if (preg_match($pattern, $text)) { list($introtext, $fulltext) = preg_split($pattern, $text, 2); $this->introtext = trim($introtext); $this->fulltext = trim($fulltext); } else { $this->introtext = trim($text); $this->fulltext = ''; } $modified = $this->_modified; $result = parent::save(); return $result; }
/** * Saves the row to the database. * * This performs an update on all children rows when the path changes. * * @return KDatabaseRowAbstract */ public function saves() { if (!empty($this->id)) { $id = $this->id; $table = KFactory::get($this->getTable()); $query = $table->getDatabase()->getQuery(); $query->where('path', 'like', '%' . $id . '%'); $path = $this->path; $path = $path ? $path . '/' . $id : $id; foreach ($table->select($query) as $row) { $parts = explode($id, $row->path); $part = isset($parts[1]) ? $parts[1] : null; $row->path = $path . $part; $row->save(); } } parent::save(); return $this; }
/** * Retrieve row field value * * @param string The column name. * @return string The corresponding column value. */ public function __get($column) { $result = parent::__get($column); if (!in_array($column, array('usergroups', 'inherits'))) { return $result; } if ($column == 'usergroups') { if (!$this->_usergroups) { $ids = explode('|', $this->ninjaboard_usergroup_id); $this->_usergroups = KFactory::tmp('admin::com.ninjaboard.model.usergroups')->id($ids)->visible(KFactory::get('lib.joomla.application')->isSite())->limit(0)->getList(); } return $this->_usergroups; } if ($column == 'inherits') { if (!isset($this->_inherits)) { //@TODO this should be optimized $this->_inherits = KFactory::tmp('admin::com.ninjaboard.model.usergroupmaps')->id($this->id)->getTotal() < 1; } return $this->_inherits; } }
public function __get($column) { if ($column == 'path' && !empty($this->_data['path'])) { $result = $this->_data['path']; // Prepend with site root if it is a relative path if (!preg_match('#^(?:[a-z]\\:|~*/)#i', $result)) { $result = JPATH_FILES . '/' . $result; } $result = rtrim(str_replace('\\', '/', $result), '\\'); return $result; } else { if ($column == 'relative_path') { return $this->getRelativePath(); } else { if ($column == 'path_value') { return $this->_data['path']; } } } return parent::__get($column); }
public function __get($column) { $result = parent::__get($column); if (!empty($this->ancestors) && empty($result)) { $ancestors = json_decode($this->ancestors, true); if (is_array($ancestors) && array_key_exists($column, $ancestors)) { $result = $this->__getRelation('ancestors', $column); $this->setData(array($column => $result)); return $result; } } if (!empty($this->descendants) && empty($result)) { $descendants = json_decode($this->descendants, true); if (is_array($descendants) && array_key_exists($column, $descendants) || isset($this->getRelations()->descendants->{$column}) && $this->getRelations()->descendants->{$column}->fallback == 1) { $result = $this->__getRelation('descendants', $column); $this->setData(array($column => $result)); return $result; } } return $result; }
/** * Retrieve row field value * * @param string The column name. * @return string The corresponding column value. */ public function __get($column) { $result = parent::__get($column); if ($column != 'params') { return $result; } if (!isset($this->_params)) { $identifier = clone $this->getIdentifier(); $identifier->path = array('model'); $identifier->name = 'settings'; $defaults = KFactory::get($identifier)->getParams()->toArray(); $params = is_string($result) ? json_decode($result, true) : $result; if ($params !== null) { $params = new KConfig($params); //@TODO Make this configurable, instead of hardcoding the defaults to only apply when JSite $params->append($defaults); } else { $params = $defaults; } $this->_params = $params; } return $this->_params; }
/** * Saves the row to the database. And saves a Joomla User. * * This performs an intelligent insert/update and reloads the properties * with fresh data from the table on success. * * @return boolean If successfull return TRUE, otherwise FALSE */ public function save() { $user = JUser::getInstance(); if (isset($this->_modified['password'])) { $data = array('id' => $this->id, 'name' => $this->name, 'username' => $this->username, 'email' => $this->email, 'groups' => $this->groups); if ($this->password !== '' && $this->password_verify !== '') { $data['password'] = $this->password; $data['password2'] = $this->password_verify; } $user->id = $this->id; $user->bind($data); if ($this->isNew() && empty($this->password)) { JFactory::getApplication()->redirect(KRequest::referrer(), 'No password.', 'error'); } if (!$user->save()) { JFactory::getApplication()->redirect(KRequest::referrer(), 'Error while saving Joomla user.', 'error'); } } if ($this->isNew()) { $this->setData(array('id' => $user->id, 'profile_user_id' => $user->id)); } parent::save(); }
public function __get($property) { if ($property === 'parent_ids') { $pieces = array_map('intval', explode('/', $this->path)); array_pop($pieces); return $pieces; } if ($property === 'parent_path') { return substr($this->path, 0, strrpos($this->path, '/')); } if ($property === 'parent_slug_path' && empty($this->_data['parent_slug_path'])) { $parts = explode('/', $this->getSlugPath()); array_pop($parts); if (is_array($parts)) { $this->_data['parent_slug_path'] = implode("/", $parts); } } if ($property === 'slug_path' && empty($this->_data['slug_path'])) { $this->_data['slug_path'] = $this->getSlugPath(); } return parent::__get($property); }
public function delete() { return parent::delete(); }