Esempio n. 1
0
 /**
  * constructor
  *
  * @param Doctrine_Query $query
  */
 public function __construct(Doctrine_Query $query, $viewName)
 {
     $this->name = $viewName;
     $this->query = $query;
     $this->query->setView($this);
     $this->conn = $query->getConnection();
 }
Esempio n. 2
0
 /**
  * constructor
  *
  * @param Doctrine_Query $query
  */
 public function __construct(Doctrine_Query $query, $viewName)
 {
     $this->_name = $viewName;
     $this->_query = $query;
     $this->_query->setView($this);
     $this->_conn = $query->getConnection();
     $this->_dql = $query->getDql();
     $this->_sql = $query->getSqlQuery();
 }
Esempio n. 3
0
 private function update($table_name, $d, $id)
 {
     $tid = $id;
     if (!is_array($id)) {
         $tid = array('id' => $id);
     }
     $table = Doctrine::getTable($table_name);
     $dq = new Doctrine_Query();
     $conn = $dq->getConnection();
     return $conn->update($table, $d, $tid);
 }
Esempio n. 4
0
 /**
  * Should return the database server name or source name
  *
  * Ex: mysql, pgsql, array, xml
  *
  * @return string
  */
 public function getSourceName()
 {
     return strtolower($this->_query->getConnection()->getDriverName());
 }
 protected function modifyImpl(Doctrine_Query &$o)
 {
     if (!$this->ignoreIds) {
         $table = $o->getConnection()->getTable($this->getTarget());
         $keys = $table->getIdentifierColumnNames();
         $o->addSelect(implode($keys));
     } else {
         $o->disableAutoIdentifierFields(true);
     }
     foreach ($this->additionalSelects as $alias => $select) {
         $o->addSelect($select . (is_numeric($alias) ? "" : " AS " . $alias));
     }
     $db = $this->getContext()->getDatabaseManager()->getDatabase('icinga');
     // check if retained state must be respected
     if (method_exists($db, "useRetained")) {
         /*
          * the core with idomod dumps 2 different config types
          * idomod.cfg:config_output_options
          * 1 = original config => config_type = 0
          * 2 = retained config => config_type = 1
          * 3 = both, both config_types are available
          */
         if ($this->retainedAlias) {
             $o->andWhere($this->retainedAlias . ".config_type= ?", $db->useRetained() ? "1" : "0");
         }
     }
     if ($this->getTarget() == "IcingaObjects") {
         $o->andWhere($this->mainAlias . ".is_active = 1");
     }
     foreach ($this->forceGroup as $group) {
         $o->addGroupBy($group);
     }
     parent::modifyImpl($o);
 }
Esempio n. 6
0
    public function executeUpdateFilter(sfWebRequest $request)
    {
        $this->menu = $this->getMenu('index');
        $this->informations = $this->getInformations();
        $id = $request->getParameter('id');
        $sql = <<<ENDSQL
\t\t\tSELECT domain, lists_id, ordre
\t\t\tFROM lists_filter
\t\t\tJOIN lists ON lists_filter.list_id = lists.id
\t\t\tJOIN lists_detail ON lists.id = lists_detail.lists_id
\t\t\tWHERE lists_filter.filter_id = '{$id}'
\t\t\tAND lists.origin = 'SI'
\t\t\tORDER BY ordre
ENDSQL;
        $dq = new Doctrine_Query();
        $conn = $dq->getConnection();
        $filters_private_lists_res = $conn->fetchAll($sql);
        foreach ($filters_private_lists_res as $filter) {
            if ($filter['domain'] != '') {
                switch ($filter['ordre']) {
                    case 0:
                        $globale_whitelist .= $filter['domain'] . "\n";
                        break;
                    case 1:
                        $globale_blacklist .= $filter['domain'] . "\n";
                        break;
                    case 2:
                        $private_whitelist .= $filter['domain'] . "\n";
                        break;
                    case 3:
                        $private_blacklist .= $filter['domain'] . "\n";
                        break;
                    case 4:
                        $other_blacklists[$filter['lists_id']] = $filter['lists_id'];
                        break;
                }
            }
        }
        $this->globale_whitelist = $globale_whitelist;
        $this->globale_blacklist = $globale_blacklist;
        $this->private_whitelist = $private_whitelist;
        $this->private_blacklist = $private_blacklist;
        // @TODO  ////////////////////////////////////////////////////////////
        $sql = <<<SQL
\t\t\tSELECT li.id, li.name, lf.ordre
\t\t\tFROM lists li
\t\t\t\tLEFT JOIN lists_filter lf ON li.id = lf.list_id
\t\t\tWHERE lf.filter_id = '{$id}'
\t\t\t\tAND li.origin != 'SI'
SQL;
        $dq = new Doctrine_Query();
        $conn = $dq->getConnection();
        $filters_to = $conn->fetchAll($sql);
        foreach ($filters_to as $filterT) {
            $aaa = $filterT['id'];
            $other_blacklists[$aaa] = $aaa;
        }
        $this->other_blacklists = $other_blacklists;
        $this->aaa = $filters_to;
        $lists = Doctrine_Query::create()->select('l.name, l.id')->from('Lists l')->where('origin != ?', 'SI')->orderBy('name')->execute();
        $this->lists = $lists;
        $filters = Doctrine_Query::create()->select('name, description, id')->from('Filter')->where('id = ?', $request->getParameter('id'))->execute();
        $this->filters = $filters;
        return;
    }