/** * @internal * @param array $config */ public function initialize(array $config) { parent::initialize($config); $this->addBehavior('Timestamp'); $this->belongsTo('Groups'); $this->belongsTo('Users'); }
/** * Table constructor * * @param object Application * @param string Resource name */ public function __construct($app, $resource_name) { $inflector = $app->zoocart; $resource_name = strtolower($resource_name); parent::__construct($app, '#__zoo_zl_zoocart_' . $inflector->toPlural($resource_name), 'id'); $this->app->loader->register(ucfirst($resource_name), 'classes:' . $resource_name . '.php'); $this->class = ucfirst($resource_name); $this->default_order = '`' . $this->key . '`'; }
public function count($application_id = 0, $search = "") { // get database $db = $this->database; $select = 'DISTINCT a.name'; $from = $this->name . " AS a, " . ZOO_TABLE_ITEM . " AS b USE INDEX (ID_APPLICATION_INDEX)"; $conditions = array("a.item_id = b.id AND b.application_id = " . (int) $application_id . (!empty($search) ? " AND LOWER(a.name) LIKE " . $db->Quote('%' . $db->escape($search, true) . '%', false) : "")); $options = compact('select', 'from', 'conditions'); return parent::count($options); }
/** * Get all the results of the query built using the options passed * * @see _select() * * @param array $options The list of conditions for the query * * @return array The list of objects representing the table record */ public function all($options = null) { $profiles = parent::all($options); foreach ($profiles as $profile) { $new = !$profile->id ? true : false; // trigger save event $this->app->event->dispatcher->notify($this->app->event->create($profile, 'userprofile:init', compact('new'))); } return $profiles; }
protected function _initObject($object) { parent::_initObject($object); // add to cache $key_name = $this->key; if ($object->{$key_name} && !key_exists($object->{$key_name}, $this->_objects)) { $this->_objects[$object->{$key_name}] = $object; } // trigger init event $this->app->event->dispatcher->notify($this->app->event->create($object, 'orderdev:init')); return $object; }
public function delete($object) { // get database $db = $this->database; // update childrens parent category $query = "UPDATE " . $this->name . " SET parent=" . $object->parent . " WHERE parent=" . $object->id; $db->query($query); // delete category to item relations $this->app->category->deleteCategoryItemRelations($object->id); $result = parent::delete($object); // trigger deleted event $this->app->event->dispatcher->notify($this->app->event->create($object, 'category:deleted')); return $result; }
/** * Get unique object alias. * * @param string $id The object id * @param string $alias The object alias * * @return string The unique object alias string * * @since 2.0 */ public function getUniqueAlias($id, $alias = '') { if (empty($alias) && $id) { $alias = $this->string->sluggify($this->_table->get($id)->name); } if (!empty($alias)) { $new_alias = $alias; while ($this->checkAliasExists($new_alias, $id)) { $new_alias = JString::increment($new_alias, 'dash'); } return $new_alias; } return $alias; }
public function save($object) { if ($object->name == '') { throw new SubmissionTableException('Invalid name'); } if ($object->alias == '' || $object->alias != $this->app->string->sluggify($object->alias)) { throw new SubmissionTableException('Invalid slug'); } if ($this->app->alias->submission->checkAliasExists($object->alias, $object->id)) { throw new SubmissionTableException('Slug already exists, please choose a unique slug'); } // sanatize trusted mode if ($object->access == false) { $object->getParams()->set('trusted_mode', false); } return parent::save($object); }
public function delete($object) { // Check ACL if (!$object->canDelete()) { throw new ItemTableException('Invalid Access Permission'); } // get database $db = $this->database; // delete item to category relations $query = "DELETE FROM " . ZOO_TABLE_CATEGORY_ITEM . " WHERE item_id = " . (int) $object->id; $db->query($query); // delete related comments $query = "DELETE FROM " . ZOO_TABLE_COMMENT . " WHERE item_id = " . (int) $object->id; $db->query($query); // delete related search data rows $query = "DELETE FROM " . ZOO_TABLE_SEARCH . " WHERE item_id = " . (int) $object->id; $db->query($query); // delete related rating data rows $query = "DELETE FROM " . ZOO_TABLE_RATING . " WHERE item_id = " . (int) $object->id; $db->query($query); // delete related tag data rows $query = "DELETE FROM " . ZOO_TABLE_TAG . " WHERE item_id = " . (int) $object->id; $db->query($query); $result = parent::delete($object); // trigger deleted event $this->app->event->dispatcher->notify($this->app->event->create($object, 'item:deleted')); return $result; }
public function find($mode = 'all', $options = null) { $result = parent::find($mode, $options); if ($this->app->system->application->isAdmin()) { if (!$result) { return false; } if (is_array($result)) { foreach ($result as $name => $application) { if (!$application->canManage()) { unset($result[$name]); } } } else { if (!$result->canManage()) { return false; } } } return $result; }
public function __construct($app) { parent::__construct($app, '#__zoo_zl_zootrack_categorytrack', 'id'); $this->app->loader->register('CategoryTrack', 'classes:categorytrack.php'); $this->class = 'CategoryTrack'; }
public function save($object) { $new = !(bool) $object->id; // first save to get id if (empty($object->id)) { parent::save($object); } $result = parent::save($object); return $result; }
public function __construct($app) { parent::__construct($app, '#__zoo_coupon'); }
public function __construct($app) { parent::__construct($app, '#__zoo_zl_zootrack_itemtrack', 'id'); $this->app->loader->register('ItemTrack', 'classes:itemtrack.php'); $this->class = 'ItemTrack'; }
public function delete($object) { // Check ACL if (!$object->canManageCategories()) { throw new CategoryTableException('Invalid Access Permissions'); } // get database $db = $this->database; // update childrens parent category $query = "UPDATE " . $this->name . " SET parent=" . $object->parent . " WHERE parent=" . $object->id; $db->query($query); // delete category to item relations $this->app->category->deleteCategoryItemRelations($object->id); $result = parent::delete($object); // trigger deleted event $this->app->event->dispatcher->notify($this->app->event->create($object, 'categeory:deleted')); return $result; }
/** * Class constructor * * @param $app */ public function __construct($app) { AppTable::__construct($app, '#__zoo_zl_zoocart_user_discount', 'id'); }
public function delete($object) { // delete related categories $table = $this->app->table->category; $categories = $table->all(array('conditions' => array('application_id=?', $object->id))); foreach ($categories as $category) { $table->delete($category); } // delete related items $table = $this->app->table->item; $items = $table->all(array('conditions' => array('application_id=?', $object->id))); foreach ($items as $item) { $table->delete($item); } $result = parent::delete($object); // trigger deleted event $this->app->event->dispatcher->notify($this->app->event->create($object, 'application:deleted')); return $result; }
public function delete($object) { // get database $db = $this->database; $old_parent = $object->id; $new_parent = $object->parent_id; parent::delete($object); $query = "UPDATE " . $this->name . " SET parent_id = " . $new_parent . " WHERE parent_id = " . $old_parent; $result = $db->query($query); // trigger deleted event $this->app->event->dispatcher->notify($this->app->event->create($object, 'comment:deleted')); return $result; }