Ejemplo n.º 1
0
    if (isset($_REQUEST['action'])) {
        $savedSearch->setSearchName($_REQUEST['searchName']);
        if ('create' === $_REQUEST['action']) {
            $saveResult = $savedSearch->setId(null)->setCriterias($_REQUEST)->save();
        } elseif ('update' === $_REQUEST['action']) {
            $saveResult = $savedSearch->setCriterias($_REQUEST)->save();
        } elseif ('delete' === $_REQUEST['action']) {
            $deleteResult = $savedSearch->delete();
            //After deletion, reset search.
            $savedSearch = new SavedSearches($GLOBALS);
            $savedSearch->setUsername($GLOBALS['cfg']['Server']['user'])->setDbname($_REQUEST['db']);
            $_REQUEST = array();
        } elseif ('load' === $_REQUEST['action']) {
            if (empty($_REQUEST['searchId'])) {
                //when not loading a search, reset the object.
                $savedSearch = new SavedSearches($GLOBALS);
                $savedSearch->setUsername($GLOBALS['cfg']['Server']['user'])->setDbname($_REQUEST['db']);
                $_REQUEST = array();
            } else {
                $loadResult = $savedSearch->load();
            }
        }
        //Else, it's an "update query"
    }
    $savedSearchList = $savedSearch->getList();
    $currentSearchId = $savedSearch->getId();
}
/**
 * A query has been submitted -> (maybe) execute it
 */
$message_to_display = false;
Ejemplo n.º 2
0
 /**
  * Initialize criterias
  *
  * @return static
  */
 private function _loadCriterias()
 {
     if (null === $this->_currentSearch || null === $this->_currentSearch->getCriterias()) {
         return $this;
     }
     $criterias = $this->_currentSearch->getCriterias();
     $_REQUEST = $criterias + $_REQUEST;
     return $this;
 }