Beispiel #1
0
 function FindColumns(LOGGROUP $grp, MASK $mask = NULL)
 {
     $sql_filters = false;
     if (!$this->time_column || !$this->time_column[$grp->gid]) {
         $time_column_base = $this->columns['time'];
         if ($this->time_module) {
             $time_column = $this->db->col_quote . $time_column_base . $this->db->col_quote;
         } else {
             // This will never work. We always create time_module in the constructor. Why we have it here?
             $time_column = $this->db->GetTimeRequest($time_column_base);
         }
         if ($this->time_module && !$this->use_db_slicer) {
             $slicer_column = $this->db->col_quote . $time_column_base . $this->db->col_quote;
         } else {
             $slicer_column = $this->db->GetSlicerRequest($time_column_base);
         }
         $sql_filters = $this->req->GetGroupOption("sql_filters", $grp, array());
         $data_columns = array();
         $msk = $this->CreateMask($grp, $info = array());
         //        if ($msk->IsFull()) $flags = 0;
         //        else $flags = REQUEST::LIST_CUSTOM;
         $items = $this->GetItemList($grp, $msk);
         foreach ($items as $item) {
             $col = $this->db->col_quote . $item['column'] . $this->db->col_quote;
             foreach ($sql_filters as $re => $sqlflt) {
                 if (preg_match($re, $item['column'])) {
                     $col = $this->ApplySqlFilters($col, $sqlflt);
                     break;
                 }
             }
             array_push($data_columns, $col);
         }
         $this->data_columns[$grp->gid] = $data_columns;
         $this->time_column[$grp->gid] = $time_column;
         $this->slicer_column[$grp->gid] = $slicer_column;
     }
     if ($mask && is_array($ids = $mask->GetIDs())) {
         if (!isset($time_column)) {
             $data_columns =& $this->data_columns[$grp->gid];
             $time_column = $this->time_column[$grp->gid];
         }
         $data_request = "";
         $custom_columns = false;
         foreach ($ids as $id) {
             if (isset($data_columns[$id])) {
                 $data_request .= "{$data_columns[$id]}, ";
             } else {
                 if ($custom_columns === false) {
                     if ($sql_filters === false) {
                         $sql_filters = $this->req->GetGroupOption("sql_filters", $grp, array());
                     }
                     if (isset($this->custom_columns[$grp->gid])) {
                         $custom_columns =& $this->custom_columns[$grp->gid];
                     } else {
                         $items = $this->GetItemList($grp, $msk = $this->CreateMask($grp, $minfo = array()), REQUEST::LIST_CUSTOM);
                         $custom_columns = array();
                         $i = 0;
                         foreach ($items as $item) {
                             if ($item['custom']) {
                                 $col = $this->db->col_quote . $item['column'] . $this->db->col_quote;
                                 foreach ($sql_filters as $re => $sqlflt) {
                                     if (preg_match($re, $item['column'])) {
                                         $col = $this->ApplySqlFilters($col, $sqlflt);
                                         break;
                                     }
                                 }
                                 $custom_columns["c" . $i++] = $col;
                             }
                         }
                         $this->custom_columns[$grp->gid] = $custom_columns;
                     }
                 }
                 if (isset($custom_columns[$id])) {
                     $data_request .= "{$custom_columns[$id]}, ";
                 } else {
                     throw new ADEIException(translate("Invalid item mask is supplied. The ID:%s refers non-existing item.", $id));
                 }
             }
         }
         return "{$data_request}{$time_column}";
     } elseif ($this->data_request[$grp->gid]) {
         return $this->data_request[$grp->gid];
     } else {
         $this->data_request[$grp->gid] = implode(", ", $this->data_columns[$grp->gid]) . ", " . $this->time_column[$grp->gid];
         return $this->data_request[$grp->gid];
     }
 }
Beispiel #2
0
 function GetAlarmList(LOGGROUP $grp = NULL, MASK $mask = NULL, $flags = 0)
 {
     $masktest = "";
     if ($mask) {
         $ids = $mask->GetIDs();
         if ($ids) {
             $lastid = array_pop($ids);
             foreach ($ids as $id) {
                 $masktest .= "(messageid = {$id}) OR ";
             }
             $masktest .= "(messageid = {$lastid})";
         }
     }
     $columns = "messageid AS id, mtype AS severity, name";
     $selopts = array();
     if ($masktest) {
         $selopts['condition'] = $masktest;
     }
     $query = $this->db->SelectRequest("messages", $columns, $selopts);
     $resp = $this->db->Query($query);
     $res = array();
     if ($resp) {
         foreach ($resp as $row) {
             $res[$row['id']] = $row;
         }
     }
     return $res;
 }