/** * Constructs the content item. * The id passed will usually be the primary key of the model data in the * database but as this is model specific it can be interpreted in other ways. * * @param mixed $itemid - The id of the item * @param int $load_flags - Any required info prenotification */ public function __construct($itemid = false, $load_flags = false) { if (!$this->package or !$this->class) { throw new vB_Exception_Content('No package or contenttype class defined for content item '); } parent::__construct($itemid, $load_flags); }
/** * Applies the result of the load query. * Child classes should extend or override to determine what was loaded based * on $required_query and $required_info. * * This method should only ever be used directly after performing the queries so * that $this->required_info accurately reflects the query result. * * @param resource $result - The db result resource * @param int $load_query - The query that the result is from */ protected function applyLoad($result, $load_query) { return parent::applyLoad($result, $load_query); }
/** * Applies the result of the load query. * * @param resource $result - The db result resource * @param int $load_query - The query that the result is from */ protected function applyLoad($result, $load_query) { if (self::QUERY_WIDGETS == $load_query) { $widgets = $locations = array(); while ($widget = vB::$db->fetch_array($result)) { $widgets[] = $widget['widgetid']; $locations[$widget['column']][$widget['index']] = $widget['widgetid']; } $this->setWidgets($widgets); $this->setLocations($locations); // mark widget info as loaded $this->loaded_info |= self::INFO_WIDGETS; return true; } return parent::applyLoad($result, $load_query); }
/** * Ensures the existing item is instantiated and valid. */ protected function assertItem() { if (isset($this->item)) { return true; } if (!isset($this->item_id)) { throw new vB_Exception_DM('No item id specified for creating an existing item in ' . get_class($this)); } $this->item = new $this->item_class($this->item_id); if (!$this->item->isValid()) { throw new vB_Exception_DM('The existing item assigned to the DM is not valid (class: ' . $this->item_class . ' id: ' . print_r($this->item_id, 1) . ')'); } }
/** * Fetches the SQL for loading. * * @param int $required_query - The required query * @param bool $force_rebuild - Whether to rebuild the string * * @return string */ protected function getLoadQuery($required_query = self::QUERY_BASIC, $force_rebuild = false) { // Hooks should check the required query before populating the hook vars $hook_query_fields = $hook_query_joins = $hook_query_where = ''; ($hook = vBulletinHook::fetch_hook($this->query_hook)) ? eval($hook) : false; if (self::QUERY_BASIC == $required_query) { return "SELECT widget.title, widget.description, widget.varname, widget.widgettypeid $hook_query_fields FROM " . TABLE_PREFIX . "cms_widget AS widget $hook_query_joins WHERE widget.widgetid = " . intval($this->itemid) . " $hook_query_where"; } if (self::QUERY_CONFIG == $required_query) { return "SELECT config.name, config.value, (nodeid = 0) instance, config.serialized $hook_query_fields FROM " . TABLE_PREFIX . "cms_widgetconfig AS config $hook_query_joins WHERE widgetid = " . intval($this->itemid) . " AND nodeid = 0 " . ($this->nodeid ? "OR nodeid = " . intval($this->nodeid) : '') . " $hook_query_where"; } parent::getLoadQuery($required_query, $force_rebuild); }
/** * Fetches the SQL for loading. * * @param int $required_query - The required query * @return string */ protected function getLoadQuery($required_query) { // Hooks should check the required query before populating the hook vars $hook_query_fields = $hook_query_joins = $hook_query_where = ''; ($hook = vBulletinHook::fetch_hook($this->query_hook)) ? eval($hook) : false; if (self::QUERY_BASIC == $required_query) { $sql = "SELECT rate.rateid, rate.nodeid, rate.userid, rate.vote, rate.ipaddress $hook_query_fields FROM " . TABLE_PREFIX . "cms_rate AS rate $hook_query_joins WHERE"; if (is_numeric($this->itemid)) { $sql .= ' rate.rateid = ' . intval($this->itemid); } else if (is_numeric($this->nodeid)) { $sql .= ' rate.rateid = ' . intval($this->rate.rateid); } $sql .= ' ' . $hook_query_where; return $sql; } return parent::getLoadQuery($required_query); }