diff --git a/module/search/control.php b/module/search/control.php
index 88e8e77450..ab95db6333 100644
--- a/module/search/control.php
+++ b/module/search/control.php
@@ -60,7 +60,7 @@ class search extends control
$this->view->searchFields = $fields;
$this->view->actionURL = $actionURL;
$this->view->fieldParams = $this->search->setDefaultParams($fields, $params);
- $this->view->queries = $this->search->getQueryPairs($module);
+ $this->view->queries = $this->search->getQueryList($module);
$this->view->queryID = $queryID;
$this->view->style = empty($style) ? 'full' : $style;
$this->view->onMenuBar = empty($onMenuBar) ? 'no' : $onMenuBar;
@@ -148,14 +148,13 @@ class search extends control
{
$query = $queryID ? $queryID : '';
$module = empty($module) ? $this->session->searchParams['module'] : $module;
- $queries = $this->search->getQueryPairs($module);
+ $queries = $this->search->getQueryList($module);
$html = '';
- foreach($queries as $queryID => $queryName)
+ foreach($queries as $query)
{
- if(empty($queryID)) continue;
- $query = $this->search->getByID($queryID);
+ if(empty($query->id)) continue;
- $html .= '
' . html::a("javascript:executeQuery({$queryID})", $queryName . ((common::hasPriv('search', 'deleteQuery') and $this->app->user->account == $query->account) ? '' : ''), '', "class='label user-query' data-query-id='$queryID' title='{$queryName}'") . '';
+ $html .= '' . html::a("javascript:executeQuery({$query->id})", $query->title . ((common::hasPriv('search', 'deleteQuery') and $this->app->user->account == $query->account) ? '' : ''), '', "class='label user-query' data-query-id='$query->id' title='{$query->title}'") . '';
}
echo $html;
}
diff --git a/module/search/model.php b/module/search/model.php
index eb39f7832f..7896fc839b 100644
--- a/module/search/model.php
+++ b/module/search/model.php
@@ -439,6 +439,30 @@ class searchModel extends model
return $queries;
}
+ /**
+ * Get query list.
+ *
+ * @param string $module
+ * @access public
+ * @return array
+ */
+ public function getQueryList($module)
+ {
+ $queries = $this->dao->select('id, account, title')
+ ->from(TABLE_USERQUERY)
+ ->where()
+ ->markLeft(1)
+ ->where('account')->eq($this->app->user->account)
+ ->orWhere('common')->eq(1)
+ ->markRight(1)
+ ->andWhere('module')->eq($module)
+ ->orderBy('id_desc')
+ ->fetchAll();
+ if(!$queries) return array('' => $this->lang->search->myQuery);
+ $queries = array('' => $this->lang->search->myQuery) + $queries;
+ return $queries;
+ }
+
/**
* Get records by the condition.
*
diff --git a/module/search/view/buildform.html.php b/module/search/view/buildform.html.php
index f8b92d3422..4010442081 100644
--- a/module/search/view/buildform.html.php
+++ b/module/search/view/buildform.html.php
@@ -227,10 +227,9 @@ foreach($fieldParams as $fieldName => $param)
search->savedQuery;?>
- $queryName):?>
-
- search->getByID($queryID);?>
- - app->user->account == $query->account) ? '' : ''), '', "class='label user-query' data-query-id='$queryID' title='{$queryName}'");?>
+
+ id)) continue;?>
+ - id)", $query->title . ((common::hasPriv('search', 'deleteQuery') and $this->app->user->account == $query->account) ? '' : ''), '', "class='label user-query' data-query-id='$query->id' title='{$query->title}'");?>
|