"id", "sName" => "name", "sNamespace" => "namespace", "bIsCondition" => "is_condition", "bIsComplete" => "is_complete", "iUserId" => "user_id", "aSearch" => "search", ); var $_bUsePearError = true; function _table () { global $default; return $default->saved_searches_table; } function _fieldValues () { $aRet = parent::_fieldValues(); $aRet['search'] = base64_encode(serialize($aRet['search'])); return $aRet; } function load($iId) { $res = parent::load($iId); if (PEAR::isError($res)) { return $res; } $this->aSearch = unserialize(base64_decode($this->aSearch)); return $res; } function _cachedGroups() { return array('getList', 'getSearches', 'getConditions', 'getSystemSearches'); } // }}} // {{{ getters/setters function getId() { return $this->iId; } function getName() { return sanitizeForSQLtoHTML($this->sName); } function getNamespace() { return $this->sNamespace; } function getIsCondition() { return $this->bIsCondition; } function getIsComplete() { return $this->bIsComplete; } function getUserId() { return $this->iUserId; } function getSearch() { return $this->aSearch; } function setId($iId) { $this->iId = $iId; } function setName($sName) { $this->sName = sanitizeForSQL($sName); } function setNamespace($sNamespace) { $this->sNamespace = $sNamespace; } function setIsCondition($bIsCondition) { $this->bIsCondition = $bIsCondition; } function setIsComplete($bIsComplete) { $this->bIsComplete = $bIsComplete; } function setUserId($iUserId) { $this->iUserId = $iUserId; } function setSearch($aSearch) { $this->aSearch = $aSearch; } // }}} function &createFromArray($aValues) { return KTEntityUtil::createFromArray('KTSavedSearch', $aValues); } function &getByNamespace($sNamespace) { return KTEntityUtil::getBy('KTSavedSearch', 'namespace', $sNamespace); } function &get($iId) { return KTEntityUtil::get('KTSavedSearch', $iId); } function &getList($sWhereClause = null) { return KTEntityUtil::getList2('KTSavedSearch', $sWhereClause); } function &getSearches() { return KTEntityUtil::getByDict('KTSavedSearch', array( 'is_condition' => false, ), array( 'multi' => true, )); } function &getUserSearches($iUserId, $bNoSystem = false) { $sQuery = sprintf('(user_id = %d AND is_condition = 0) ', $iUserId); if(!$bNoSystem) { $sQuery .= ' OR (user_id IS NULL AND is_condition = 0)'; } return KTEntityUtil::getList2('KTSavedSearch', $sQuery, array('orderby' => 'user_id, name')); } function &getConditions() { return KTEntityUtil::getByDict('KTSavedSearch', array( 'is_condition' => true, ), array( 'multi' => true, )); } function &getSystemSearches($sWhereClause = null) { return KTEntityUtil::getByDict('KTSavedSearch', array( 'is_condition' => false, 'user_id' => null, ), array( 'multi' => true, 'noneok' => true, )); } }