Ejemplo n.º 1
0
 function GetFilteredMaskList(LOGGROUP $grp = NULL, $maskid = false, $flags = 0)
 {
     $grp = $this->CheckGroup($grp, $flags);
     $info = $this->req->GetGroupOption("mask_table", $grp);
     //    $info = $this->opts->Get("mask_table");
     if (!$info) {
         return parent::GetMaskList($grp, $flags);
     }
     if (!is_array($info)) {
         throw new ADEIException(translate("Invalid mask table specified in the reader configuration, the array with information should be provided"));
     }
     if (!$info['table']) {
         throw new ADEIException(translate("The mask table is not specified in the reader configuration"));
     }
     if (!$info['id']) {
         throw new ADEIException(translate("The id column for mask table is not specified in the reader configuration"));
     }
     $query = "";
     if (is_array($info['properties'])) {
         foreach ($info['properties'] as $prop => $col) {
             $query .= ", {$this->db->col_quote}{$col}{$this->db->col_quote} AS {$prop}";
         }
     }
     if ($maskid) {
         $cond = " WHERE {$this->db->col_quote}{$info['id']}{$this->db->col_quote} = {$this->db->text_quote}{$maskid}{$this->db->text_quote}";
     } elseif ($info['gid']) {
         $table = $this->db->FixTableName($grp->table);
         $cond = " WHERE {$this->db->col_quote}{$info['gid']}{$this->db->col_quote} = {$this->db->text_quote}{$table}{$this->db->text_quote}";
     } else {
         $cond = "";
     }
     $query = "SELECT {$this->db->col_quote}{$info['id']}{$this->db->col_quote} AS id{$query} FROM {$this->db->tbl_quote}{$info['table']}{$this->db->tbl_quote}" . $cond;
     $masks = $this->db->Query($query);
     if ($masks->rowCount()) {
         $items = $this->GetItemList($grp, $mask = new MASK(), $flags);
         $hash = array();
         foreach ($items as $item) {
             $hash[$item['name']] = $item;
             if ($item['column']) {
                 //$hash[$item['id']] = $item;
                 $hash[$item['column']] = $item;
             }
         }
     } else {
         if ($maskid) {
             throw new ADEIException(translate("Mask \"%s\" is not found for group \"%s\"", $maskid, $grp->gid));
         }
     }
     $list = array();
     foreach ($masks as $mask) {
         $items = explode(",", $mask['mask']);
         foreach ($items as &$item) {
             if (!is_numeric($item)) {
                 if (isset($hash[$item])) {
                     $item = $hash[$item]['id'];
                 } else {
                     throw new ADEIException(translate("Item \"%s\" specified in the mask \"%s\" is not available in the group \"%s\"", $item, $mask['id'], $grp->gid));
                 }
             }
         }
         $mask['mask'] = implode(",", $items);
         $mask['id'] = "maskid" . $mask['id'];
         $list[$mask['id']] = $mask;
     }
     return array_merge(parent::GetMaskList($grp, $flags), $list);
 }
Ejemplo n.º 2
0
 function GetMaskList(LOGGROUP $grp = NULL, $flags = 0)
 {
     $grp = $this->CheckGroup($grp, $flags);
     if (strcmp($grp->gid, VIRTUALReader::SRCTREE_ID)) {
         return parent::GetMaskList($grp, $flags);
     }
     return array_merge(parent::GetMaskList($grp, $flags), array("all" => array('id' => "all", 'name' => _("All"), 'mask' => "all")));
 }
Ejemplo n.º 3
0
 function GetMaskList(LOGGROUP $grp = NULL, $flags = 0)
 {
     $grp = $this->CheckGroup($grp, $flags);
     $list = array();
     $resp = $this->db->Query("SELECT maskid, name, mask FROM masks WHERE gid=" . $grp->gid);
     foreach ($resp as $row) {
         if (!preg_match("/[\\w\\d]/", $row['name'])) {
             $row['name'] = _("No name");
         }
         $id = "maskid" . $row['maskid'];
         $list[$id] = array('id' => $id, 'name' => $this->db->RecodeMessage($row['name']));
         if ($flags & REQUEST::NEED_INFO) {
             $list[$id]['mask'] = implode(",", $this->ParseMask($row['mask']));
         }
     }
     $timestamps = $this->req->GetGroupOption("timestamp_channels", $grp);
     if ($timestamps) {
         if ($timestamps === true) {
             $timestamps = 2;
         }
         $items = sizeof($this->GetItemList($grp, NULL, $flags));
         if ($items > $timestamps) {
             for ($i = $timestamps; $i < $items; $i++) {
                 if ($i == $timestamps) {
                     $all = $i;
                 } else {
                     $all .= "," . $i;
                 }
             }
         }
         $list["all"] = array('id' => "all", 'name' => _("All"), 'mask' => $all);
     }
     return array_merge(parent::GetMaskList($grp, $flags), $list);
 }