Пример #1
0
	/**
	 * 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);
	}
Пример #2
0
	/**
	 * 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);
	}