@@ -31,8 +31,9 @@ discard block |
||
| 31 | 31 | { |
| 32 | 32 | if ($this->groupingColumn == 'rule_type') |
| 33 | 33 | { |
| 34 | - if ($this->categories == NULL || (! isset($this->categories[$value]))) |
|
| 35 | - return 'Unknown category ('.$value.')'; |
|
| 34 | + if ($this->categories == NULL || (! isset($this->categories[$value]))) { |
|
| 35 | + return 'Unknown category ('.$value.')'; |
|
| 36 | + } |
|
| 36 | 37 | return 'Category : '. $this->categories[$value]; |
| 37 | 38 | } |
| 38 | 39 | $html = "$value"; |
@@ -86,13 +87,11 @@ discard block |
||
| 86 | 87 | if (isset($oidName['name'])) |
| 87 | 88 | { |
| 88 | 89 | $val=$oidName['name']; |
| 89 | - } |
|
| 90 | - else |
|
| 90 | + } else |
|
| 91 | 91 | { |
| 92 | 92 | $val = $row->$rowkey; |
| 93 | 93 | } |
| 94 | - } |
|
| 95 | - else |
|
| 94 | + } else |
|
| 96 | 95 | { |
| 97 | 96 | $val = $row->$rowkey; |
| 98 | 97 | } |
@@ -101,8 +100,7 @@ discard block |
||
| 101 | 100 | if ($row->$rowkey == null) |
| 102 | 101 | { |
| 103 | 102 | $val = $row->host_group_name; |
| 104 | - } |
|
| 105 | - else |
|
| 103 | + } else |
|
| 106 | 104 | { |
| 107 | 105 | $val = $row->$rowkey; |
| 108 | 106 | } |
@@ -20,22 +20,22 @@ discard block |
||
| 20 | 20 | protected $MIB; |
| 21 | 21 | |
| 22 | 22 | // categories |
| 23 | - protected $categories = NULL; |
|
| 23 | + protected $categories=NULL; |
|
| 24 | 24 | |
| 25 | 25 | public function setCategoriesArray(array $categories) |
| 26 | 26 | { |
| 27 | - $this->categories = $categories; |
|
| 27 | + $this->categories=$categories; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - public function groupingPrintData( string $value) |
|
| 30 | + public function groupingPrintData(string $value) |
|
| 31 | 31 | { |
| 32 | 32 | if ($this->groupingColumn == 'rule_type') |
| 33 | 33 | { |
| 34 | - if ($this->categories == NULL || (! isset($this->categories[$value]))) |
|
| 34 | + if ($this->categories == NULL || (!isset($this->categories[$value]))) |
|
| 35 | 35 | return 'Unknown category ('.$value.')'; |
| 36 | - return 'Category : '. $this->categories[$value]; |
|
| 36 | + return 'Category : '.$this->categories[$value]; |
|
| 37 | 37 | } |
| 38 | - $html = "$value"; |
|
| 38 | + $html="$value"; |
|
| 39 | 39 | return $html; |
| 40 | 40 | } |
| 41 | 41 | |
@@ -58,16 +58,16 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | public function getCurrentURL() |
| 60 | 60 | { |
| 61 | - return Url::fromPath($this->urlPath . '/handler'); |
|
| 61 | + return Url::fromPath($this->urlPath.'/handler'); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | public function renderLine($row) |
| 65 | 65 | { |
| 66 | - $html = ''; |
|
| 67 | - $firstCol = true; |
|
| 66 | + $html=''; |
|
| 67 | + $firstCol=true; |
|
| 68 | 68 | |
| 69 | - $titleNames = array_keys($this->titles); |
|
| 70 | - foreach ($titleNames as $rowkey ) |
|
| 69 | + $titleNames=array_keys($this->titles); |
|
| 70 | + foreach ($titleNames as $rowkey) |
|
| 71 | 71 | { |
| 72 | 72 | // Check missing value |
| 73 | 73 | if (property_exists($row, $rowkey)) |
@@ -82,57 +82,57 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | if ($this->doTranslate === true) |
| 84 | 84 | { |
| 85 | - $oidName = $this->MIB->translateOID($row->$rowkey); |
|
| 85 | + $oidName=$this->MIB->translateOID($row->$rowkey); |
|
| 86 | 86 | if (isset($oidName['name'])) |
| 87 | 87 | { |
| 88 | 88 | $val=$oidName['name']; |
| 89 | 89 | } |
| 90 | 90 | else |
| 91 | 91 | { |
| 92 | - $val = $row->$rowkey; |
|
| 92 | + $val=$row->$rowkey; |
|
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | else |
| 96 | 96 | { |
| 97 | - $val = $row->$rowkey; |
|
| 97 | + $val=$row->$rowkey; |
|
| 98 | 98 | } |
| 99 | 99 | break; |
| 100 | 100 | case 'host_name': // switch to hostgroup if name is null |
| 101 | 101 | if ($row->$rowkey == null) |
| 102 | 102 | { |
| 103 | - $val = $row->host_group_name; |
|
| 103 | + $val=$row->host_group_name; |
|
| 104 | 104 | } |
| 105 | 105 | else |
| 106 | 106 | { |
| 107 | - $val = $row->$rowkey; |
|
| 107 | + $val=$row->$rowkey; |
|
| 108 | 108 | } |
| 109 | 109 | break; |
| 110 | 110 | default: |
| 111 | - $val = $row->$rowkey; |
|
| 111 | + $val=$row->$rowkey; |
|
| 112 | 112 | } |
| 113 | - if ($rowkey == 'trap_oid' && $this->doTranslate===true) |
|
| 113 | + if ($rowkey == 'trap_oid' && $this->doTranslate === true) |
|
| 114 | 114 | { |
| 115 | 115 | |
| 116 | 116 | } |
| 117 | 117 | } else { |
| 118 | - $val = '-'; |
|
| 118 | + $val='-'; |
|
| 119 | 119 | } |
| 120 | 120 | if ($firstCol === true) { // Put link in first column for trap detail. |
| 121 | - $html .= '<td class="traphover">' |
|
| 121 | + $html.='<td class="traphover">' |
|
| 122 | 122 | . $this->view->qlink( |
| 123 | 123 | $this->view->escape($val), |
| 124 | 124 | Url::fromPath( |
| 125 | - $this->urlPath . '/handler/add', |
|
| 125 | + $this->urlPath.'/handler/add', |
|
| 126 | 126 | array('ruleid' => $row->id) |
| 127 | 127 | ) |
| 128 | 128 | ); |
| 129 | 129 | if ($row->comment != '') |
| 130 | 130 | { |
| 131 | - $html.= '<span class="tohover">'. $row->comment .'</span></td>'; |
|
| 131 | + $html.='<span class="tohover">'.$row->comment.'</span></td>'; |
|
| 132 | 132 | } |
| 133 | - $html.= '</td>'; |
|
| 133 | + $html.='</td>'; |
|
| 134 | 134 | } else { |
| 135 | - $html .= '<td>' . $this->view->escape($val) . '</td>'; |
|
| 135 | + $html.='<td>'.$this->view->escape($val).'</td>'; |
|
| 136 | 136 | } |
| 137 | 137 | $firstCol=false; |
| 138 | 138 | |
@@ -7,136 +7,136 @@ |
||
| 7 | 7 | class HandlerTable extends TrapDirectorTable |
| 8 | 8 | { |
| 9 | 9 | |
| 10 | - protected $status_display=array( |
|
| 11 | - -2 =>'ignore', |
|
| 12 | - -1 => '-', |
|
| 13 | - 0 => 'OK', |
|
| 14 | - 1 => 'warning', |
|
| 15 | - 2 => 'critical', |
|
| 16 | - 3 => 'unknown',); |
|
| 10 | + protected $status_display=array( |
|
| 11 | + -2 =>'ignore', |
|
| 12 | + -1 => '-', |
|
| 13 | + 0 => 'OK', |
|
| 14 | + 1 => 'warning', |
|
| 15 | + 2 => 'critical', |
|
| 16 | + 3 => 'unknown',); |
|
| 17 | 17 | |
| 18 | - // translate |
|
| 19 | - protected $doTranslate=false; |
|
| 20 | - protected $MIB; |
|
| 18 | + // translate |
|
| 19 | + protected $doTranslate=false; |
|
| 20 | + protected $MIB; |
|
| 21 | 21 | |
| 22 | - // categories |
|
| 23 | - protected $categories = NULL; |
|
| 22 | + // categories |
|
| 23 | + protected $categories = NULL; |
|
| 24 | 24 | |
| 25 | - public function setCategoriesArray(array $categories) |
|
| 26 | - { |
|
| 27 | - $this->categories = $categories; |
|
| 28 | - } |
|
| 25 | + public function setCategoriesArray(array $categories) |
|
| 26 | + { |
|
| 27 | + $this->categories = $categories; |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - public function groupingPrintData( string $value) |
|
| 31 | - { |
|
| 32 | - if ($this->groupingColumn == 'rule_type') |
|
| 33 | - { |
|
| 34 | - if ($this->categories == NULL || (! isset($this->categories[$value]))) |
|
| 35 | - return 'Unknown category ('.$value.')'; |
|
| 36 | - return 'Category : '. $this->categories[$value]; |
|
| 37 | - } |
|
| 38 | - $html = "$value"; |
|
| 39 | - return $html; |
|
| 40 | - } |
|
| 30 | + public function groupingPrintData( string $value) |
|
| 31 | + { |
|
| 32 | + if ($this->groupingColumn == 'rule_type') |
|
| 33 | + { |
|
| 34 | + if ($this->categories == NULL || (! isset($this->categories[$value]))) |
|
| 35 | + return 'Unknown category ('.$value.')'; |
|
| 36 | + return 'Category : '. $this->categories[$value]; |
|
| 37 | + } |
|
| 38 | + $html = "$value"; |
|
| 39 | + return $html; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - public function setMibloader($mibloader) |
|
| 43 | - { |
|
| 44 | - $this->MIB=$mibloader; |
|
| 45 | - $this->doTranslate=true; |
|
| 46 | - } |
|
| 42 | + public function setMibloader($mibloader) |
|
| 43 | + { |
|
| 44 | + $this->MIB=$mibloader; |
|
| 45 | + $this->doTranslate=true; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - public function titleOrder($name) |
|
| 49 | - { |
|
| 50 | - switch ($name) |
|
| 51 | - { |
|
| 52 | - case 'host_name' : return $this->content[$name]; break; |
|
| 53 | - case 'source_ip' : return 'ip4'; break; |
|
| 54 | - default: return $this->content[$name]; |
|
| 55 | - } |
|
| 56 | - } |
|
| 48 | + public function titleOrder($name) |
|
| 49 | + { |
|
| 50 | + switch ($name) |
|
| 51 | + { |
|
| 52 | + case 'host_name' : return $this->content[$name]; break; |
|
| 53 | + case 'source_ip' : return 'ip4'; break; |
|
| 54 | + default: return $this->content[$name]; |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - public function getCurrentURL() |
|
| 59 | - { |
|
| 60 | - return Url::fromPath($this->urlPath . '/handler'); |
|
| 61 | - } |
|
| 58 | + public function getCurrentURL() |
|
| 59 | + { |
|
| 60 | + return Url::fromPath($this->urlPath . '/handler'); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - public function renderLine($row) |
|
| 64 | - { |
|
| 65 | - $html = ''; |
|
| 66 | - $firstCol = true; |
|
| 63 | + public function renderLine($row) |
|
| 64 | + { |
|
| 65 | + $html = ''; |
|
| 66 | + $firstCol = true; |
|
| 67 | 67 | |
| 68 | - $titleNames = array_keys($this->titles); |
|
| 69 | - foreach ($titleNames as $rowkey ) |
|
| 70 | - { |
|
| 71 | - // Check missing value |
|
| 72 | - if (property_exists($row, $rowkey)) |
|
| 73 | - { |
|
| 74 | - switch ($rowkey) |
|
| 75 | - { |
|
| 76 | - case 'action_match': // display text levels |
|
| 77 | - case 'action_nomatch': |
|
| 78 | - $val=$this->status_display[$row->$rowkey]; |
|
| 79 | - break; |
|
| 80 | - case 'trap_oid': // try to traslate oids. |
|
| 68 | + $titleNames = array_keys($this->titles); |
|
| 69 | + foreach ($titleNames as $rowkey ) |
|
| 70 | + { |
|
| 71 | + // Check missing value |
|
| 72 | + if (property_exists($row, $rowkey)) |
|
| 73 | + { |
|
| 74 | + switch ($rowkey) |
|
| 75 | + { |
|
| 76 | + case 'action_match': // display text levels |
|
| 77 | + case 'action_nomatch': |
|
| 78 | + $val=$this->status_display[$row->$rowkey]; |
|
| 79 | + break; |
|
| 80 | + case 'trap_oid': // try to traslate oids. |
|
| 81 | 81 | |
| 82 | - if ($this->doTranslate === true) |
|
| 83 | - { |
|
| 84 | - $oidName = $this->MIB->translateOID($row->$rowkey); |
|
| 85 | - if (isset($oidName['name'])) |
|
| 86 | - { |
|
| 87 | - $val=$oidName['name']; |
|
| 88 | - } |
|
| 89 | - else |
|
| 90 | - { |
|
| 91 | - $val = $row->$rowkey; |
|
| 92 | - } |
|
| 93 | - } |
|
| 94 | - else |
|
| 95 | - { |
|
| 96 | - $val = $row->$rowkey; |
|
| 97 | - } |
|
| 98 | - break; |
|
| 99 | - case 'host_name': // switch to hostgroup if name is null |
|
| 100 | - if ($row->$rowkey == null) |
|
| 101 | - { |
|
| 102 | - $val = $row->host_group_name; |
|
| 103 | - } |
|
| 104 | - else |
|
| 105 | - { |
|
| 106 | - $val = $row->$rowkey; |
|
| 107 | - } |
|
| 108 | - break; |
|
| 109 | - default: |
|
| 110 | - $val = $row->$rowkey; |
|
| 111 | - } |
|
| 112 | - if ($rowkey == 'trap_oid' && $this->doTranslate===true) |
|
| 113 | - { |
|
| 82 | + if ($this->doTranslate === true) |
|
| 83 | + { |
|
| 84 | + $oidName = $this->MIB->translateOID($row->$rowkey); |
|
| 85 | + if (isset($oidName['name'])) |
|
| 86 | + { |
|
| 87 | + $val=$oidName['name']; |
|
| 88 | + } |
|
| 89 | + else |
|
| 90 | + { |
|
| 91 | + $val = $row->$rowkey; |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | + else |
|
| 95 | + { |
|
| 96 | + $val = $row->$rowkey; |
|
| 97 | + } |
|
| 98 | + break; |
|
| 99 | + case 'host_name': // switch to hostgroup if name is null |
|
| 100 | + if ($row->$rowkey == null) |
|
| 101 | + { |
|
| 102 | + $val = $row->host_group_name; |
|
| 103 | + } |
|
| 104 | + else |
|
| 105 | + { |
|
| 106 | + $val = $row->$rowkey; |
|
| 107 | + } |
|
| 108 | + break; |
|
| 109 | + default: |
|
| 110 | + $val = $row->$rowkey; |
|
| 111 | + } |
|
| 112 | + if ($rowkey == 'trap_oid' && $this->doTranslate===true) |
|
| 113 | + { |
|
| 114 | 114 | |
| 115 | - } |
|
| 116 | - } else { |
|
| 117 | - $val = '-'; |
|
| 118 | - } |
|
| 119 | - if ($firstCol === true) { // Put link in first column for trap detail. |
|
| 120 | - $html .= '<td class="traphover">' |
|
| 121 | - . $this->view->qlink( |
|
| 122 | - $this->view->escape($val), |
|
| 123 | - Url::fromPath( |
|
| 124 | - $this->urlPath . '/handler/add', |
|
| 125 | - array('ruleid' => $row->id) |
|
| 126 | - ) |
|
| 127 | - ); |
|
| 128 | - if ($row->comment != '') |
|
| 129 | - { |
|
| 130 | - $html.= '<span class="tohover">'. $row->comment .'</span></td>'; |
|
| 131 | - } |
|
| 132 | - $html.= '</td>'; |
|
| 133 | - } else { |
|
| 134 | - $html .= '<td>' . $this->view->escape($val) . '</td>'; |
|
| 135 | - } |
|
| 136 | - $firstCol=false; |
|
| 115 | + } |
|
| 116 | + } else { |
|
| 117 | + $val = '-'; |
|
| 118 | + } |
|
| 119 | + if ($firstCol === true) { // Put link in first column for trap detail. |
|
| 120 | + $html .= '<td class="traphover">' |
|
| 121 | + . $this->view->qlink( |
|
| 122 | + $this->view->escape($val), |
|
| 123 | + Url::fromPath( |
|
| 124 | + $this->urlPath . '/handler/add', |
|
| 125 | + array('ruleid' => $row->id) |
|
| 126 | + ) |
|
| 127 | + ); |
|
| 128 | + if ($row->comment != '') |
|
| 129 | + { |
|
| 130 | + $html.= '<span class="tohover">'. $row->comment .'</span></td>'; |
|
| 131 | + } |
|
| 132 | + $html.= '</td>'; |
|
| 133 | + } else { |
|
| 134 | + $html .= '<td>' . $this->view->escape($val) . '</td>'; |
|
| 135 | + } |
|
| 136 | + $firstCol=false; |
|
| 137 | 137 | |
| 138 | - } |
|
| 139 | - return $html; |
|
| 140 | - } |
|
| 138 | + } |
|
| 139 | + return $html; |
|
| 140 | + } |
|
| 141 | 141 | |
| 142 | 142 | } |
| 143 | 143 | \ No newline at end of file |
@@ -20,245 +20,245 @@ |
||
| 20 | 20 | trait TrapDBQuery |
| 21 | 21 | { |
| 22 | 22 | |
| 23 | - /** @return TrapsController */ |
|
| 24 | - abstract protected function getTrapCtrl(); |
|
| 23 | + /** @return TrapsController */ |
|
| 24 | + abstract protected function getTrapCtrl(); |
|
| 25 | 25 | |
| 26 | - /** @return Zend_Db_Adapter_Abstract : returns DB connexion or null on error */ |
|
| 27 | - abstract public function getDbConn(); |
|
| 26 | + /** @return Zend_Db_Adapter_Abstract : returns DB connexion or null on error */ |
|
| 27 | + abstract public function getDbConn(); |
|
| 28 | 28 | |
| 29 | - /** Add handler rule in traps DB |
|
| 30 | - * @param array $params : array(<db item>=><value>) |
|
| 31 | - * @return int inserted id |
|
| 32 | - */ |
|
| 33 | - public function addHandlerRule($params) |
|
| 34 | - { |
|
| 35 | - // TODO Check for rule consistency |
|
| 29 | + /** Add handler rule in traps DB |
|
| 30 | + * @param array $params : array(<db item>=><value>) |
|
| 31 | + * @return int inserted id |
|
| 32 | + */ |
|
| 33 | + public function addHandlerRule($params) |
|
| 34 | + { |
|
| 35 | + // TODO Check for rule consistency |
|
| 36 | 36 | |
| 37 | - $dbConn = $this->getDbConn(); |
|
| 38 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 39 | - // Add last modified date = creation date and username |
|
| 40 | - $params['created'] = new Zend_Db_Expr('NOW()'); |
|
| 41 | - $params['modified'] = new Zend_Db_Expr('NOW()'); |
|
| 42 | - $params['modifier'] = $this->getTrapCtrl()->Auth()->getUser()->getUsername(); |
|
| 37 | + $dbConn = $this->getDbConn(); |
|
| 38 | + if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 39 | + // Add last modified date = creation date and username |
|
| 40 | + $params['created'] = new Zend_Db_Expr('NOW()'); |
|
| 41 | + $params['modified'] = new Zend_Db_Expr('NOW()'); |
|
| 42 | + $params['modifier'] = $this->getTrapCtrl()->Auth()->getUser()->getUsername(); |
|
| 43 | 43 | |
| 44 | - $query=$dbConn->insert( |
|
| 45 | - $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(), |
|
| 46 | - $params |
|
| 47 | - ); |
|
| 48 | - if($query==false) |
|
| 49 | - { |
|
| 50 | - return null; |
|
| 51 | - } |
|
| 52 | - return $dbConn->lastInsertId(); |
|
| 53 | - } |
|
| 44 | + $query=$dbConn->insert( |
|
| 45 | + $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(), |
|
| 46 | + $params |
|
| 47 | + ); |
|
| 48 | + if($query==false) |
|
| 49 | + { |
|
| 50 | + return null; |
|
| 51 | + } |
|
| 52 | + return $dbConn->lastInsertId(); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** Update handler rule in traps DB |
|
| 56 | - * @param array $params : (<db item>=><value>) |
|
| 57 | - * @param integer $ruleID : rule id in db |
|
| 58 | - * @return array affected rows |
|
| 59 | - */ |
|
| 60 | - public function updateHandlerRule($params,$ruleID) |
|
| 61 | - { |
|
| 62 | - // TODO Check for rule consistency |
|
| 63 | - $dbConn = $this->getDbConn(); |
|
| 64 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 65 | - // Add last modified date = creation date and username |
|
| 66 | - $params['modified'] = new Zend_Db_Expr('NOW()'); |
|
| 67 | - $params['modifier'] = $this->getTrapCtrl()->Auth()->getUser()->getUsername(); |
|
| 55 | + /** Update handler rule in traps DB |
|
| 56 | + * @param array $params : (<db item>=><value>) |
|
| 57 | + * @param integer $ruleID : rule id in db |
|
| 58 | + * @return array affected rows |
|
| 59 | + */ |
|
| 60 | + public function updateHandlerRule($params,$ruleID) |
|
| 61 | + { |
|
| 62 | + // TODO Check for rule consistency |
|
| 63 | + $dbConn = $this->getDbConn(); |
|
| 64 | + if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 65 | + // Add last modified date = creation date and username |
|
| 66 | + $params['modified'] = new Zend_Db_Expr('NOW()'); |
|
| 67 | + $params['modifier'] = $this->getTrapCtrl()->Auth()->getUser()->getUsername(); |
|
| 68 | 68 | |
| 69 | - $numRows=$dbConn->update( |
|
| 70 | - $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(), |
|
| 71 | - $params, |
|
| 72 | - 'id='.$ruleID |
|
| 73 | - ); |
|
| 74 | - return $numRows; |
|
| 75 | - } |
|
| 69 | + $numRows=$dbConn->update( |
|
| 70 | + $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(), |
|
| 71 | + $params, |
|
| 72 | + 'id='.$ruleID |
|
| 73 | + ); |
|
| 74 | + return $numRows; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * ON category removal, put back cat to 0 on handlers with this category. |
|
| 79 | - * @param int $catIndex |
|
| 80 | - * @throws \ErrorException |
|
| 81 | - * @return number |
|
| 82 | - */ |
|
| 83 | - public function updateHandlersOnCategoryDelete($catIndex) |
|
| 84 | - { |
|
| 85 | - // TODO Check for rule consistency |
|
| 86 | - $dbConn = $this->getDbConn(); |
|
| 87 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 77 | + /** |
|
| 78 | + * ON category removal, put back cat to 0 on handlers with this category. |
|
| 79 | + * @param int $catIndex |
|
| 80 | + * @throws \ErrorException |
|
| 81 | + * @return number |
|
| 82 | + */ |
|
| 83 | + public function updateHandlersOnCategoryDelete($catIndex) |
|
| 84 | + { |
|
| 85 | + // TODO Check for rule consistency |
|
| 86 | + $dbConn = $this->getDbConn(); |
|
| 87 | + if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 88 | 88 | |
| 89 | - $numRows=$dbConn->update( |
|
| 90 | - $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(), |
|
| 91 | - array('rule_type' => 0), |
|
| 92 | - 'rule_type='.$catIndex |
|
| 93 | - ); |
|
| 94 | - return $numRows; |
|
| 95 | - } |
|
| 89 | + $numRows=$dbConn->update( |
|
| 90 | + $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(), |
|
| 91 | + array('rule_type' => 0), |
|
| 92 | + 'rule_type='.$catIndex |
|
| 93 | + ); |
|
| 94 | + return $numRows; |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - /** Delete rule by id |
|
| 98 | - * @param int $ruleID rule id |
|
| 99 | - */ |
|
| 100 | - public function deleteRule($ruleID) |
|
| 101 | - { |
|
| 102 | - if (!preg_match('/^[0-9]+$/',$ruleID)) { throw new Exception('Invalid id'); } |
|
| 97 | + /** Delete rule by id |
|
| 98 | + * @param int $ruleID rule id |
|
| 99 | + */ |
|
| 100 | + public function deleteRule($ruleID) |
|
| 101 | + { |
|
| 102 | + if (!preg_match('/^[0-9]+$/',$ruleID)) { throw new Exception('Invalid id'); } |
|
| 103 | 103 | |
| 104 | - $dbConn = $this->getDbConn(); |
|
| 105 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 104 | + $dbConn = $this->getDbConn(); |
|
| 105 | + if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 106 | 106 | |
| 107 | - $query=$dbConn->delete( |
|
| 108 | - $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(), |
|
| 109 | - 'id='.$ruleID |
|
| 110 | - ); |
|
| 111 | - return $query; |
|
| 112 | - } |
|
| 107 | + $query=$dbConn->delete( |
|
| 108 | + $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(), |
|
| 109 | + 'id='.$ruleID |
|
| 110 | + ); |
|
| 111 | + return $query; |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - /** |
|
| 115 | - * Get last trap rule table modification |
|
| 116 | - * @throws \ErrorException |
|
| 117 | - * @return Zend_Db_Select |
|
| 118 | - */ |
|
| 119 | - public function lastModification() |
|
| 120 | - { |
|
| 121 | - $dbConn = $this->getDbConn(); |
|
| 122 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 114 | + /** |
|
| 115 | + * Get last trap rule table modification |
|
| 116 | + * @throws \ErrorException |
|
| 117 | + * @return Zend_Db_Select |
|
| 118 | + */ |
|
| 119 | + public function lastModification() |
|
| 120 | + { |
|
| 121 | + $dbConn = $this->getDbConn(); |
|
| 122 | + if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 123 | 123 | |
| 124 | - $query = $dbConn->select() |
|
| 125 | - ->from( |
|
| 126 | - $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(), |
|
| 127 | - array('lastModified'=>'UNIX_TIMESTAMP(MAX(modified))')); |
|
| 128 | - $returnRow=$dbConn->fetchRow($query); |
|
| 129 | - return $returnRow->lastmodified; |
|
| 130 | - } |
|
| 124 | + $query = $dbConn->select() |
|
| 125 | + ->from( |
|
| 126 | + $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(), |
|
| 127 | + array('lastModified'=>'UNIX_TIMESTAMP(MAX(modified))')); |
|
| 128 | + $returnRow=$dbConn->fetchRow($query); |
|
| 129 | + return $returnRow->lastmodified; |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - /** Delete trap by ip & oid |
|
| 133 | - * @param $ipAddr string source IP (v4 or v6) |
|
| 134 | - * @param $oid string oid |
|
| 135 | - */ |
|
| 136 | - public function deleteTrap($ipAddr,$oid) |
|
| 137 | - { |
|
| 132 | + /** Delete trap by ip & oid |
|
| 133 | + * @param $ipAddr string source IP (v4 or v6) |
|
| 134 | + * @param $oid string oid |
|
| 135 | + */ |
|
| 136 | + public function deleteTrap($ipAddr,$oid) |
|
| 137 | + { |
|
| 138 | 138 | |
| 139 | - $dbConn = $this->getDbConn(); |
|
| 140 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 141 | - $condition=null; |
|
| 142 | - if ($ipAddr != null) |
|
| 143 | - { |
|
| 144 | - $condition="source_ip='$ipAddr'"; |
|
| 145 | - } |
|
| 146 | - if ($oid != null) |
|
| 147 | - { |
|
| 148 | - $condition=($condition===null)?'':$condition.' AND '; |
|
| 149 | - $condition.="trap_oid='$oid'"; |
|
| 150 | - } |
|
| 151 | - if($condition === null) return null; |
|
| 152 | - $query=$dbConn->delete( |
|
| 153 | - $this->getTrapCtrl()->getModuleConfig()->getTrapTableName(), |
|
| 154 | - $condition |
|
| 155 | - ); |
|
| 156 | - // TODO test ret code etc... |
|
| 157 | - return $query; |
|
| 158 | - } |
|
| 139 | + $dbConn = $this->getDbConn(); |
|
| 140 | + if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 141 | + $condition=null; |
|
| 142 | + if ($ipAddr != null) |
|
| 143 | + { |
|
| 144 | + $condition="source_ip='$ipAddr'"; |
|
| 145 | + } |
|
| 146 | + if ($oid != null) |
|
| 147 | + { |
|
| 148 | + $condition=($condition===null)?'':$condition.' AND '; |
|
| 149 | + $condition.="trap_oid='$oid'"; |
|
| 150 | + } |
|
| 151 | + if($condition === null) return null; |
|
| 152 | + $query=$dbConn->delete( |
|
| 153 | + $this->getTrapCtrl()->getModuleConfig()->getTrapTableName(), |
|
| 154 | + $condition |
|
| 155 | + ); |
|
| 156 | + // TODO test ret code etc... |
|
| 157 | + return $query; |
|
| 158 | + } |
|
| 159 | 159 | |
| 160 | 160 | |
| 161 | - /** count trap by ip & oid |
|
| 162 | - * @param $ipAddr string source IP (v4 or v6) |
|
| 163 | - * @param $oid string oid |
|
| 164 | - */ |
|
| 165 | - public function countTrap($ipAddr,$oid) |
|
| 166 | - { |
|
| 161 | + /** count trap by ip & oid |
|
| 162 | + * @param $ipAddr string source IP (v4 or v6) |
|
| 163 | + * @param $oid string oid |
|
| 164 | + */ |
|
| 165 | + public function countTrap($ipAddr,$oid) |
|
| 166 | + { |
|
| 167 | 167 | |
| 168 | - $dbConn = $this->getDbConn(); |
|
| 169 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 168 | + $dbConn = $this->getDbConn(); |
|
| 169 | + if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 170 | 170 | |
| 171 | - $condition=null; |
|
| 172 | - if ($ipAddr != null) |
|
| 173 | - { |
|
| 174 | - $condition="source_ip='$ipAddr'"; |
|
| 175 | - } |
|
| 176 | - if ($oid != null) |
|
| 177 | - { |
|
| 178 | - $condition=($condition===null)?'':$condition.' AND '; |
|
| 179 | - $condition.="trap_oid='$oid'"; |
|
| 180 | - } |
|
| 181 | - if($condition === null) return 0; |
|
| 182 | - $query=$dbConn->select() |
|
| 183 | - ->from( |
|
| 184 | - $this->getTrapCtrl()->getModuleConfig()->getTrapTableName(), |
|
| 185 | - array('num'=>'count(*)')) |
|
| 186 | - ->where($condition); |
|
| 187 | - $returnRow=$dbConn->fetchRow($query); |
|
| 188 | - return $returnRow->num; |
|
| 189 | - } |
|
| 171 | + $condition=null; |
|
| 172 | + if ($ipAddr != null) |
|
| 173 | + { |
|
| 174 | + $condition="source_ip='$ipAddr'"; |
|
| 175 | + } |
|
| 176 | + if ($oid != null) |
|
| 177 | + { |
|
| 178 | + $condition=($condition===null)?'':$condition.' AND '; |
|
| 179 | + $condition.="trap_oid='$oid'"; |
|
| 180 | + } |
|
| 181 | + if($condition === null) return 0; |
|
| 182 | + $query=$dbConn->select() |
|
| 183 | + ->from( |
|
| 184 | + $this->getTrapCtrl()->getModuleConfig()->getTrapTableName(), |
|
| 185 | + array('num'=>'count(*)')) |
|
| 186 | + ->where($condition); |
|
| 187 | + $returnRow=$dbConn->fetchRow($query); |
|
| 188 | + return $returnRow->num; |
|
| 189 | + } |
|
| 190 | 190 | |
| 191 | - /** get configuration value |
|
| 192 | - * @param string $element : configuration name in db |
|
| 193 | - */ |
|
| 194 | - public function getDBConfigValue($element) |
|
| 195 | - { |
|
| 191 | + /** get configuration value |
|
| 192 | + * @param string $element : configuration name in db |
|
| 193 | + */ |
|
| 194 | + public function getDBConfigValue($element) |
|
| 195 | + { |
|
| 196 | 196 | |
| 197 | - $dbConn = $this->getDbConn(); |
|
| 198 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 197 | + $dbConn = $this->getDbConn(); |
|
| 198 | + if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 199 | 199 | |
| 200 | - $query=$dbConn->select() |
|
| 201 | - ->from( |
|
| 202 | - $this->getTrapCtrl()->getModuleConfig()->getDbConfigTableName(), |
|
| 203 | - array('value'=>'value')) |
|
| 204 | - ->where('name=?',$element); |
|
| 205 | - $returnRow=$dbConn->fetchRow($query); |
|
| 206 | - if ($returnRow==null) // value does not exists |
|
| 207 | - { |
|
| 208 | - $default=$this->getTrapCtrl()->getModuleConfig()->getDBConfigDefaults(); |
|
| 209 | - if ( ! isset($default[$element])) return null; // no default and not value |
|
| 200 | + $query=$dbConn->select() |
|
| 201 | + ->from( |
|
| 202 | + $this->getTrapCtrl()->getModuleConfig()->getDbConfigTableName(), |
|
| 203 | + array('value'=>'value')) |
|
| 204 | + ->where('name=?',$element); |
|
| 205 | + $returnRow=$dbConn->fetchRow($query); |
|
| 206 | + if ($returnRow==null) // value does not exists |
|
| 207 | + { |
|
| 208 | + $default=$this->getTrapCtrl()->getModuleConfig()->getDBConfigDefaults(); |
|
| 209 | + if ( ! isset($default[$element])) return null; // no default and not value |
|
| 210 | 210 | |
| 211 | - $this->addDBConfigValue($element,$default[$element]); |
|
| 212 | - return $default[$element]; |
|
| 213 | - } |
|
| 214 | - if ($returnRow->value == null) // value id empty |
|
| 215 | - { |
|
| 216 | - $default=$this->getTrapCtrl()->getModuleConfig()->getDBConfigDefaults(); |
|
| 217 | - if ( ! isset($default[$element])) return null; // no default and not value |
|
| 218 | - $this->setDBConfigValue($element,$default[$element]); |
|
| 219 | - return $default[$element]; |
|
| 220 | - } |
|
| 221 | - return $returnRow->value; |
|
| 222 | - } |
|
| 211 | + $this->addDBConfigValue($element,$default[$element]); |
|
| 212 | + return $default[$element]; |
|
| 213 | + } |
|
| 214 | + if ($returnRow->value == null) // value id empty |
|
| 215 | + { |
|
| 216 | + $default=$this->getTrapCtrl()->getModuleConfig()->getDBConfigDefaults(); |
|
| 217 | + if ( ! isset($default[$element])) return null; // no default and not value |
|
| 218 | + $this->setDBConfigValue($element,$default[$element]); |
|
| 219 | + return $default[$element]; |
|
| 220 | + } |
|
| 221 | + return $returnRow->value; |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | - /** add configuration value |
|
| 225 | - * @param string $element : name of config element |
|
| 226 | - * @param string $value : value |
|
| 227 | - */ |
|
| 224 | + /** add configuration value |
|
| 225 | + * @param string $element : name of config element |
|
| 226 | + * @param string $value : value |
|
| 227 | + */ |
|
| 228 | 228 | |
| 229 | - public function addDBConfigValue($element,$value) |
|
| 230 | - { |
|
| 229 | + public function addDBConfigValue($element,$value) |
|
| 230 | + { |
|
| 231 | 231 | |
| 232 | - $dbConn = $this->getDbConn(); |
|
| 233 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 232 | + $dbConn = $this->getDbConn(); |
|
| 233 | + if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 234 | 234 | |
| 235 | - $query=$dbConn->insert( |
|
| 236 | - $this->getTrapCtrl()->getModuleConfig()->getDbConfigTableName(), |
|
| 237 | - array( |
|
| 238 | - 'name' => $element, |
|
| 239 | - 'value'=>$value |
|
| 240 | - ) |
|
| 241 | - ); |
|
| 242 | - return $query; |
|
| 243 | - } |
|
| 235 | + $query=$dbConn->insert( |
|
| 236 | + $this->getTrapCtrl()->getModuleConfig()->getDbConfigTableName(), |
|
| 237 | + array( |
|
| 238 | + 'name' => $element, |
|
| 239 | + 'value'=>$value |
|
| 240 | + ) |
|
| 241 | + ); |
|
| 242 | + return $query; |
|
| 243 | + } |
|
| 244 | 244 | |
| 245 | - /** set configuration value |
|
| 246 | - * @param string $element : name of config element |
|
| 247 | - * @param string $value : value |
|
| 248 | - */ |
|
| 249 | - public function setDBConfigValue($element,$value) |
|
| 250 | - { |
|
| 245 | + /** set configuration value |
|
| 246 | + * @param string $element : name of config element |
|
| 247 | + * @param string $value : value |
|
| 248 | + */ |
|
| 249 | + public function setDBConfigValue($element,$value) |
|
| 250 | + { |
|
| 251 | 251 | |
| 252 | - $dbConn = $this->getDbConn(); |
|
| 253 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 252 | + $dbConn = $this->getDbConn(); |
|
| 253 | + if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 254 | 254 | |
| 255 | - $query=$dbConn->update( |
|
| 256 | - $this->getTrapCtrl()->getModuleConfig()->getDbConfigTableName(), |
|
| 257 | - array('value'=>$value), |
|
| 258 | - 'name=\''.$element.'\'' |
|
| 259 | - ); |
|
| 260 | - return $query; |
|
| 261 | - } |
|
| 255 | + $query=$dbConn->update( |
|
| 256 | + $this->getTrapCtrl()->getModuleConfig()->getDbConfigTableName(), |
|
| 257 | + array('value'=>$value), |
|
| 258 | + 'name=\''.$element.'\'' |
|
| 259 | + ); |
|
| 260 | + return $query; |
|
| 261 | + } |
|
| 262 | 262 | |
| 263 | 263 | |
| 264 | 264 | } |
| 265 | 265 | \ No newline at end of file |
@@ -34,18 +34,18 @@ discard block |
||
| 34 | 34 | { |
| 35 | 35 | // TODO Check for rule consistency |
| 36 | 36 | |
| 37 | - $dbConn = $this->getDbConn(); |
|
| 37 | + $dbConn=$this->getDbConn(); |
|
| 38 | 38 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 39 | 39 | // Add last modified date = creation date and username |
| 40 | - $params['created'] = new Zend_Db_Expr('NOW()'); |
|
| 41 | - $params['modified'] = new Zend_Db_Expr('NOW()'); |
|
| 42 | - $params['modifier'] = $this->getTrapCtrl()->Auth()->getUser()->getUsername(); |
|
| 40 | + $params['created']=new Zend_Db_Expr('NOW()'); |
|
| 41 | + $params['modified']=new Zend_Db_Expr('NOW()'); |
|
| 42 | + $params['modifier']=$this->getTrapCtrl()->Auth()->getUser()->getUsername(); |
|
| 43 | 43 | |
| 44 | 44 | $query=$dbConn->insert( |
| 45 | 45 | $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(), |
| 46 | 46 | $params |
| 47 | 47 | ); |
| 48 | - if($query==false) |
|
| 48 | + if ($query == false) |
|
| 49 | 49 | { |
| 50 | 50 | return null; |
| 51 | 51 | } |
@@ -57,14 +57,14 @@ discard block |
||
| 57 | 57 | * @param integer $ruleID : rule id in db |
| 58 | 58 | * @return array affected rows |
| 59 | 59 | */ |
| 60 | - public function updateHandlerRule($params,$ruleID) |
|
| 60 | + public function updateHandlerRule($params, $ruleID) |
|
| 61 | 61 | { |
| 62 | 62 | // TODO Check for rule consistency |
| 63 | - $dbConn = $this->getDbConn(); |
|
| 63 | + $dbConn=$this->getDbConn(); |
|
| 64 | 64 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 65 | 65 | // Add last modified date = creation date and username |
| 66 | - $params['modified'] = new Zend_Db_Expr('NOW()'); |
|
| 67 | - $params['modifier'] = $this->getTrapCtrl()->Auth()->getUser()->getUsername(); |
|
| 66 | + $params['modified']=new Zend_Db_Expr('NOW()'); |
|
| 67 | + $params['modifier']=$this->getTrapCtrl()->Auth()->getUser()->getUsername(); |
|
| 68 | 68 | |
| 69 | 69 | $numRows=$dbConn->update( |
| 70 | 70 | $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(), |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | public function updateHandlersOnCategoryDelete($catIndex) |
| 84 | 84 | { |
| 85 | 85 | // TODO Check for rule consistency |
| 86 | - $dbConn = $this->getDbConn(); |
|
| 86 | + $dbConn=$this->getDbConn(); |
|
| 87 | 87 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 88 | 88 | |
| 89 | 89 | $numRows=$dbConn->update( |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | public function deleteRule($ruleID) |
| 101 | 101 | { |
| 102 | - if (!preg_match('/^[0-9]+$/',$ruleID)) { throw new Exception('Invalid id'); } |
|
| 102 | + if (!preg_match('/^[0-9]+$/', $ruleID)) { throw new Exception('Invalid id'); } |
|
| 103 | 103 | |
| 104 | - $dbConn = $this->getDbConn(); |
|
| 104 | + $dbConn=$this->getDbConn(); |
|
| 105 | 105 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 106 | 106 | |
| 107 | 107 | $query=$dbConn->delete( |
@@ -118,10 +118,10 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | public function lastModification() |
| 120 | 120 | { |
| 121 | - $dbConn = $this->getDbConn(); |
|
| 121 | + $dbConn=$this->getDbConn(); |
|
| 122 | 122 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 123 | 123 | |
| 124 | - $query = $dbConn->select() |
|
| 124 | + $query=$dbConn->select() |
|
| 125 | 125 | ->from( |
| 126 | 126 | $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(), |
| 127 | 127 | array('lastModified'=>'UNIX_TIMESTAMP(MAX(modified))')); |
@@ -133,10 +133,10 @@ discard block |
||
| 133 | 133 | * @param $ipAddr string source IP (v4 or v6) |
| 134 | 134 | * @param $oid string oid |
| 135 | 135 | */ |
| 136 | - public function deleteTrap($ipAddr,$oid) |
|
| 136 | + public function deleteTrap($ipAddr, $oid) |
|
| 137 | 137 | { |
| 138 | 138 | |
| 139 | - $dbConn = $this->getDbConn(); |
|
| 139 | + $dbConn=$this->getDbConn(); |
|
| 140 | 140 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 141 | 141 | $condition=null; |
| 142 | 142 | if ($ipAddr != null) |
@@ -145,10 +145,10 @@ discard block |
||
| 145 | 145 | } |
| 146 | 146 | if ($oid != null) |
| 147 | 147 | { |
| 148 | - $condition=($condition===null)?'':$condition.' AND '; |
|
| 148 | + $condition=($condition === null) ? '' : $condition.' AND '; |
|
| 149 | 149 | $condition.="trap_oid='$oid'"; |
| 150 | 150 | } |
| 151 | - if($condition === null) return null; |
|
| 151 | + if ($condition === null) return null; |
|
| 152 | 152 | $query=$dbConn->delete( |
| 153 | 153 | $this->getTrapCtrl()->getModuleConfig()->getTrapTableName(), |
| 154 | 154 | $condition |
@@ -162,10 +162,10 @@ discard block |
||
| 162 | 162 | * @param $ipAddr string source IP (v4 or v6) |
| 163 | 163 | * @param $oid string oid |
| 164 | 164 | */ |
| 165 | - public function countTrap($ipAddr,$oid) |
|
| 165 | + public function countTrap($ipAddr, $oid) |
|
| 166 | 166 | { |
| 167 | 167 | |
| 168 | - $dbConn = $this->getDbConn(); |
|
| 168 | + $dbConn=$this->getDbConn(); |
|
| 169 | 169 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 170 | 170 | |
| 171 | 171 | $condition=null; |
@@ -175,10 +175,10 @@ discard block |
||
| 175 | 175 | } |
| 176 | 176 | if ($oid != null) |
| 177 | 177 | { |
| 178 | - $condition=($condition===null)?'':$condition.' AND '; |
|
| 178 | + $condition=($condition === null) ? '' : $condition.' AND '; |
|
| 179 | 179 | $condition.="trap_oid='$oid'"; |
| 180 | 180 | } |
| 181 | - if($condition === null) return 0; |
|
| 181 | + if ($condition === null) return 0; |
|
| 182 | 182 | $query=$dbConn->select() |
| 183 | 183 | ->from( |
| 184 | 184 | $this->getTrapCtrl()->getModuleConfig()->getTrapTableName(), |
@@ -194,28 +194,28 @@ discard block |
||
| 194 | 194 | public function getDBConfigValue($element) |
| 195 | 195 | { |
| 196 | 196 | |
| 197 | - $dbConn = $this->getDbConn(); |
|
| 197 | + $dbConn=$this->getDbConn(); |
|
| 198 | 198 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 199 | 199 | |
| 200 | 200 | $query=$dbConn->select() |
| 201 | 201 | ->from( |
| 202 | 202 | $this->getTrapCtrl()->getModuleConfig()->getDbConfigTableName(), |
| 203 | 203 | array('value'=>'value')) |
| 204 | - ->where('name=?',$element); |
|
| 204 | + ->where('name=?', $element); |
|
| 205 | 205 | $returnRow=$dbConn->fetchRow($query); |
| 206 | - if ($returnRow==null) // value does not exists |
|
| 206 | + if ($returnRow == null) // value does not exists |
|
| 207 | 207 | { |
| 208 | 208 | $default=$this->getTrapCtrl()->getModuleConfig()->getDBConfigDefaults(); |
| 209 | - if ( ! isset($default[$element])) return null; // no default and not value |
|
| 209 | + if (!isset($default[$element])) return null; // no default and not value |
|
| 210 | 210 | |
| 211 | - $this->addDBConfigValue($element,$default[$element]); |
|
| 211 | + $this->addDBConfigValue($element, $default[$element]); |
|
| 212 | 212 | return $default[$element]; |
| 213 | 213 | } |
| 214 | 214 | if ($returnRow->value == null) // value id empty |
| 215 | 215 | { |
| 216 | 216 | $default=$this->getTrapCtrl()->getModuleConfig()->getDBConfigDefaults(); |
| 217 | - if ( ! isset($default[$element])) return null; // no default and not value |
|
| 218 | - $this->setDBConfigValue($element,$default[$element]); |
|
| 217 | + if (!isset($default[$element])) return null; // no default and not value |
|
| 218 | + $this->setDBConfigValue($element, $default[$element]); |
|
| 219 | 219 | return $default[$element]; |
| 220 | 220 | } |
| 221 | 221 | return $returnRow->value; |
@@ -226,10 +226,10 @@ discard block |
||
| 226 | 226 | * @param string $value : value |
| 227 | 227 | */ |
| 228 | 228 | |
| 229 | - public function addDBConfigValue($element,$value) |
|
| 229 | + public function addDBConfigValue($element, $value) |
|
| 230 | 230 | { |
| 231 | 231 | |
| 232 | - $dbConn = $this->getDbConn(); |
|
| 232 | + $dbConn=$this->getDbConn(); |
|
| 233 | 233 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 234 | 234 | |
| 235 | 235 | $query=$dbConn->insert( |
@@ -246,10 +246,10 @@ discard block |
||
| 246 | 246 | * @param string $element : name of config element |
| 247 | 247 | * @param string $value : value |
| 248 | 248 | */ |
| 249 | - public function setDBConfigValue($element,$value) |
|
| 249 | + public function setDBConfigValue($element, $value) |
|
| 250 | 250 | { |
| 251 | 251 | |
| 252 | - $dbConn = $this->getDbConn(); |
|
| 252 | + $dbConn=$this->getDbConn(); |
|
| 253 | 253 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 254 | 254 | |
| 255 | 255 | $query=$dbConn->update( |
@@ -35,7 +35,9 @@ discard block |
||
| 35 | 35 | // TODO Check for rule consistency |
| 36 | 36 | |
| 37 | 37 | $dbConn = $this->getDbConn(); |
| 38 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 38 | + if ($dbConn === null) { |
|
| 39 | + throw new \ErrorException('uncatched db error'); |
|
| 40 | + } |
|
| 39 | 41 | // Add last modified date = creation date and username |
| 40 | 42 | $params['created'] = new Zend_Db_Expr('NOW()'); |
| 41 | 43 | $params['modified'] = new Zend_Db_Expr('NOW()'); |
@@ -61,7 +63,9 @@ discard block |
||
| 61 | 63 | { |
| 62 | 64 | // TODO Check for rule consistency |
| 63 | 65 | $dbConn = $this->getDbConn(); |
| 64 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 66 | + if ($dbConn === null) { |
|
| 67 | + throw new \ErrorException('uncatched db error'); |
|
| 68 | + } |
|
| 65 | 69 | // Add last modified date = creation date and username |
| 66 | 70 | $params['modified'] = new Zend_Db_Expr('NOW()'); |
| 67 | 71 | $params['modifier'] = $this->getTrapCtrl()->Auth()->getUser()->getUsername(); |
@@ -84,7 +88,9 @@ discard block |
||
| 84 | 88 | { |
| 85 | 89 | // TODO Check for rule consistency |
| 86 | 90 | $dbConn = $this->getDbConn(); |
| 87 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 91 | + if ($dbConn === null) { |
|
| 92 | + throw new \ErrorException('uncatched db error'); |
|
| 93 | + } |
|
| 88 | 94 | |
| 89 | 95 | $numRows=$dbConn->update( |
| 90 | 96 | $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(), |
@@ -102,7 +108,9 @@ discard block |
||
| 102 | 108 | if (!preg_match('/^[0-9]+$/',$ruleID)) { throw new Exception('Invalid id'); } |
| 103 | 109 | |
| 104 | 110 | $dbConn = $this->getDbConn(); |
| 105 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 111 | + if ($dbConn === null) { |
|
| 112 | + throw new \ErrorException('uncatched db error'); |
|
| 113 | + } |
|
| 106 | 114 | |
| 107 | 115 | $query=$dbConn->delete( |
| 108 | 116 | $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(), |
@@ -119,7 +127,9 @@ discard block |
||
| 119 | 127 | public function lastModification() |
| 120 | 128 | { |
| 121 | 129 | $dbConn = $this->getDbConn(); |
| 122 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 130 | + if ($dbConn === null) { |
|
| 131 | + throw new \ErrorException('uncatched db error'); |
|
| 132 | + } |
|
| 123 | 133 | |
| 124 | 134 | $query = $dbConn->select() |
| 125 | 135 | ->from( |
@@ -137,7 +147,9 @@ discard block |
||
| 137 | 147 | { |
| 138 | 148 | |
| 139 | 149 | $dbConn = $this->getDbConn(); |
| 140 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 150 | + if ($dbConn === null) { |
|
| 151 | + throw new \ErrorException('uncatched db error'); |
|
| 152 | + } |
|
| 141 | 153 | $condition=null; |
| 142 | 154 | if ($ipAddr != null) |
| 143 | 155 | { |
@@ -148,7 +160,9 @@ discard block |
||
| 148 | 160 | $condition=($condition===null)?'':$condition.' AND '; |
| 149 | 161 | $condition.="trap_oid='$oid'"; |
| 150 | 162 | } |
| 151 | - if($condition === null) return null; |
|
| 163 | + if($condition === null) { |
|
| 164 | + return null; |
|
| 165 | + } |
|
| 152 | 166 | $query=$dbConn->delete( |
| 153 | 167 | $this->getTrapCtrl()->getModuleConfig()->getTrapTableName(), |
| 154 | 168 | $condition |
@@ -166,7 +180,9 @@ discard block |
||
| 166 | 180 | { |
| 167 | 181 | |
| 168 | 182 | $dbConn = $this->getDbConn(); |
| 169 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 183 | + if ($dbConn === null) { |
|
| 184 | + throw new \ErrorException('uncatched db error'); |
|
| 185 | + } |
|
| 170 | 186 | |
| 171 | 187 | $condition=null; |
| 172 | 188 | if ($ipAddr != null) |
@@ -178,7 +194,9 @@ discard block |
||
| 178 | 194 | $condition=($condition===null)?'':$condition.' AND '; |
| 179 | 195 | $condition.="trap_oid='$oid'"; |
| 180 | 196 | } |
| 181 | - if($condition === null) return 0; |
|
| 197 | + if($condition === null) { |
|
| 198 | + return 0; |
|
| 199 | + } |
|
| 182 | 200 | $query=$dbConn->select() |
| 183 | 201 | ->from( |
| 184 | 202 | $this->getTrapCtrl()->getModuleConfig()->getTrapTableName(), |
@@ -195,7 +213,9 @@ discard block |
||
| 195 | 213 | { |
| 196 | 214 | |
| 197 | 215 | $dbConn = $this->getDbConn(); |
| 198 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 216 | + if ($dbConn === null) { |
|
| 217 | + throw new \ErrorException('uncatched db error'); |
|
| 218 | + } |
|
| 199 | 219 | |
| 200 | 220 | $query=$dbConn->select() |
| 201 | 221 | ->from( |
@@ -203,18 +223,28 @@ discard block |
||
| 203 | 223 | array('value'=>'value')) |
| 204 | 224 | ->where('name=?',$element); |
| 205 | 225 | $returnRow=$dbConn->fetchRow($query); |
| 206 | - if ($returnRow==null) // value does not exists |
|
| 226 | + if ($returnRow==null) { |
|
| 227 | + // value does not exists |
|
| 207 | 228 | { |
| 208 | 229 | $default=$this->getTrapCtrl()->getModuleConfig()->getDBConfigDefaults(); |
| 209 | - if ( ! isset($default[$element])) return null; // no default and not value |
|
| 230 | + } |
|
| 231 | + if ( ! isset($default[$element])) { |
|
| 232 | + return null; |
|
| 233 | + } |
|
| 234 | + // no default and not value |
|
| 210 | 235 | |
| 211 | 236 | $this->addDBConfigValue($element,$default[$element]); |
| 212 | 237 | return $default[$element]; |
| 213 | 238 | } |
| 214 | - if ($returnRow->value == null) // value id empty |
|
| 239 | + if ($returnRow->value == null) { |
|
| 240 | + // value id empty |
|
| 215 | 241 | { |
| 216 | 242 | $default=$this->getTrapCtrl()->getModuleConfig()->getDBConfigDefaults(); |
| 217 | - if ( ! isset($default[$element])) return null; // no default and not value |
|
| 243 | + } |
|
| 244 | + if ( ! isset($default[$element])) { |
|
| 245 | + return null; |
|
| 246 | + } |
|
| 247 | + // no default and not value |
|
| 218 | 248 | $this->setDBConfigValue($element,$default[$element]); |
| 219 | 249 | return $default[$element]; |
| 220 | 250 | } |
@@ -230,7 +260,9 @@ discard block |
||
| 230 | 260 | { |
| 231 | 261 | |
| 232 | 262 | $dbConn = $this->getDbConn(); |
| 233 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 263 | + if ($dbConn === null) { |
|
| 264 | + throw new \ErrorException('uncatched db error'); |
|
| 265 | + } |
|
| 234 | 266 | |
| 235 | 267 | $query=$dbConn->insert( |
| 236 | 268 | $this->getTrapCtrl()->getModuleConfig()->getDbConfigTableName(), |
@@ -250,7 +282,9 @@ discard block |
||
| 250 | 282 | { |
| 251 | 283 | |
| 252 | 284 | $dbConn = $this->getDbConn(); |
| 253 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 285 | + if ($dbConn === null) { |
|
| 286 | + throw new \ErrorException('uncatched db error'); |
|
| 287 | + } |
|
| 254 | 288 | |
| 255 | 289 | $query=$dbConn->update( |
| 256 | 290 | $this->getTrapCtrl()->getModuleConfig()->getDbConfigTableName(), |
@@ -8,10 +8,10 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | /********* Filter ********/ |
| 10 | 10 | /** @var string $filterString : string filter for db columns */ |
| 11 | - protected $filterString = ''; |
|
| 11 | + protected $filterString=''; |
|
| 12 | 12 | |
| 13 | 13 | /** @var array $filterColumn : columns to apply filter to */ |
| 14 | - protected $filterColumn = array(); |
|
| 14 | + protected $filterColumn=array(); |
|
| 15 | 15 | |
| 16 | 16 | protected $filterQuery=''; |
| 17 | 17 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | { |
| 30 | 30 | if ($filter != "") $filter.=' OR '; |
| 31 | 31 | //$filter .= "'" . $column . "' LIKE '%" . $this->filterString. "%'"; |
| 32 | - $filter .= $column . " LIKE '%" . $this->filterString. "%'"; |
|
| 32 | + $filter.=$column." LIKE '%".$this->filterString."%'"; |
|
| 33 | 33 | } |
| 34 | 34 | //echo $filter; |
| 35 | 35 | |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | public function setFilter(string $filter, array $filterCol) |
| 42 | 42 | { |
| 43 | - $this->filterString = $filter; |
|
| 44 | - $this->filterColumn = $filterCol; |
|
| 43 | + $this->filterString=$filter; |
|
| 44 | + $this->filterColumn=$filterCol; |
|
| 45 | 45 | return $this; |
| 46 | 46 | } |
| 47 | 47 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | { |
| 64 | 64 | if (isset($getVars['f'])) |
| 65 | 65 | { |
| 66 | - $this->filterQuery = $getVars['f']; |
|
| 66 | + $this->filterQuery=$getVars['f']; |
|
| 67 | 67 | $this->setFilter(html_entity_decode($getVars['f']), $this->columnNames); |
| 68 | 68 | } |
| 69 | 69 | } |
@@ -27,7 +27,9 @@ discard block |
||
| 27 | 27 | $filter=''; |
| 28 | 28 | foreach ($this->filterColumn as $column) |
| 29 | 29 | { |
| 30 | - if ($filter != "") $filter.=' OR '; |
|
| 30 | + if ($filter != "") { |
|
| 31 | + $filter.=' OR '; |
|
| 32 | + } |
|
| 31 | 33 | //$filter .= "'" . $column . "' LIKE '%" . $this->filterString. "%'"; |
| 32 | 34 | $filter .= $column . " LIKE '%" . $this->filterString. "%'"; |
| 33 | 35 | } |
@@ -70,7 +72,9 @@ discard block |
||
| 70 | 72 | |
| 71 | 73 | protected function curFilterQuery() |
| 72 | 74 | { |
| 73 | - if ($this->filterQuery == '') return ''; |
|
| 75 | + if ($this->filterQuery == '') { |
|
| 76 | + return ''; |
|
| 77 | + } |
|
| 74 | 78 | return 'f='.$this->filterQuery; |
| 75 | 79 | } |
| 76 | 80 | |
@@ -6,75 +6,75 @@ |
||
| 6 | 6 | trait TrapDirectorTableFilter |
| 7 | 7 | { |
| 8 | 8 | |
| 9 | - /********* Filter ********/ |
|
| 10 | - /** @var string $filterString : string filter for db columns */ |
|
| 11 | - protected $filterString = ''; |
|
| 9 | + /********* Filter ********/ |
|
| 10 | + /** @var string $filterString : string filter for db columns */ |
|
| 11 | + protected $filterString = ''; |
|
| 12 | 12 | |
| 13 | - /** @var array $filterColumn : columns to apply filter to */ |
|
| 14 | - protected $filterColumn = array(); |
|
| 13 | + /** @var array $filterColumn : columns to apply filter to */ |
|
| 14 | + protected $filterColumn = array(); |
|
| 15 | 15 | |
| 16 | - protected $filterQuery=''; |
|
| 16 | + protected $filterQuery=''; |
|
| 17 | 17 | |
| 18 | - /**** var & func of TrapDirectorTable used ***/ |
|
| 19 | - protected $query; |
|
| 20 | - abstract protected function getCurrentURLAndQS(string $caller); |
|
| 18 | + /**** var & func of TrapDirectorTable used ***/ |
|
| 19 | + protected $query; |
|
| 20 | + abstract protected function getCurrentURLAndQS(string $caller); |
|
| 21 | 21 | |
| 22 | - /**************** Filtering ******************/ |
|
| 22 | + /**************** Filtering ******************/ |
|
| 23 | 23 | |
| 24 | - public function applyFilter() |
|
| 25 | - { |
|
| 26 | - if ($this->filterString == '' || count($this->filterColumn) == 0) |
|
| 27 | - { |
|
| 28 | - return $this; |
|
| 29 | - } |
|
| 30 | - $filter=''; |
|
| 31 | - foreach ($this->filterColumn as $column) |
|
| 32 | - { |
|
| 33 | - if ($filter != "") $filter.=' OR '; |
|
| 34 | - //$filter .= "'" . $column . "' LIKE '%" . $this->filterString. "%'"; |
|
| 35 | - $filter .= $column . " LIKE '%" . $this->filterString. "%'"; |
|
| 36 | - } |
|
| 37 | - //echo $filter; |
|
| 24 | + public function applyFilter() |
|
| 25 | + { |
|
| 26 | + if ($this->filterString == '' || count($this->filterColumn) == 0) |
|
| 27 | + { |
|
| 28 | + return $this; |
|
| 29 | + } |
|
| 30 | + $filter=''; |
|
| 31 | + foreach ($this->filterColumn as $column) |
|
| 32 | + { |
|
| 33 | + if ($filter != "") $filter.=' OR '; |
|
| 34 | + //$filter .= "'" . $column . "' LIKE '%" . $this->filterString. "%'"; |
|
| 35 | + $filter .= $column . " LIKE '%" . $this->filterString. "%'"; |
|
| 36 | + } |
|
| 37 | + //echo $filter; |
|
| 38 | 38 | |
| 39 | - $this->query=$this->query->where($filter); |
|
| 39 | + $this->query=$this->query->where($filter); |
|
| 40 | 40 | |
| 41 | - return $this; |
|
| 42 | - } |
|
| 41 | + return $this; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - public function setFilter(string $filter, array $filterCol) |
|
| 45 | - { |
|
| 46 | - $this->filterString = $filter; |
|
| 47 | - $this->filterColumn = $filterCol; |
|
| 48 | - return $this; |
|
| 49 | - } |
|
| 44 | + public function setFilter(string $filter, array $filterCol) |
|
| 45 | + { |
|
| 46 | + $this->filterString = $filter; |
|
| 47 | + $this->filterColumn = $filterCol; |
|
| 48 | + return $this; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - public function renderFilter() |
|
| 52 | - { |
|
| 51 | + public function renderFilter() |
|
| 52 | + { |
|
| 53 | 53 | |
| 54 | - $html=' <form id="genfilter" name="mainFilterGen" |
|
| 54 | + $html=' <form id="genfilter" name="mainFilterGen" |
|
| 55 | 55 | enctype="application/x-www-form-urlencoded" |
| 56 | 56 | action="'.$this->getCurrentURLAndQS('filter').'" |
| 57 | 57 | method="get">'; |
| 58 | - $html.='<input type="text" name="f" title="Search is simple! Try to combine multiple words" |
|
| 58 | + $html.='<input type="text" name="f" title="Search is simple! Try to combine multiple words" |
|
| 59 | 59 | placeholder="Search..." value="'.$this->filterQuery.'">'; |
| 60 | 60 | |
| 61 | - $html.='</form>'; |
|
| 62 | - return $html; |
|
| 63 | - } |
|
| 61 | + $html.='</form>'; |
|
| 62 | + return $html; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - public function getFilterQuery(array $getVars) |
|
| 66 | - { |
|
| 67 | - if (isset($getVars['f'])) |
|
| 68 | - { |
|
| 69 | - $this->filterQuery = $getVars['f']; |
|
| 70 | - $this->setFilter(html_entity_decode($getVars['f']), $this->columnNames); |
|
| 71 | - } |
|
| 72 | - } |
|
| 65 | + public function getFilterQuery(array $getVars) |
|
| 66 | + { |
|
| 67 | + if (isset($getVars['f'])) |
|
| 68 | + { |
|
| 69 | + $this->filterQuery = $getVars['f']; |
|
| 70 | + $this->setFilter(html_entity_decode($getVars['f']), $this->columnNames); |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - protected function curFilterQuery() |
|
| 75 | - { |
|
| 76 | - if ($this->filterQuery == '') return ''; |
|
| 77 | - return 'f='.$this->filterQuery; |
|
| 78 | - } |
|
| 74 | + protected function curFilterQuery() |
|
| 75 | + { |
|
| 76 | + if ($this->filterQuery == '') return ''; |
|
| 77 | + return 'f='.$this->filterQuery; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | 80 | } |
| 81 | 81 | \ No newline at end of file |
@@ -6,195 +6,195 @@ |
||
| 6 | 6 | abstract class TrapDirectorTable |
| 7 | 7 | { |
| 8 | 8 | |
| 9 | - use TrapDirectorTableFilter; |
|
| 10 | - use TrapDirectorTablePaging; |
|
| 11 | - use TrapDirectorTableOrder; |
|
| 12 | - use TrapDirectorTableGrouping; |
|
| 9 | + use TrapDirectorTableFilter; |
|
| 10 | + use TrapDirectorTablePaging; |
|
| 11 | + use TrapDirectorTableOrder; |
|
| 12 | + use TrapDirectorTableGrouping; |
|
| 13 | 13 | |
| 14 | - /** @var array $titles table titles (name, display value) */ |
|
| 15 | - protected $titles = null; |
|
| 14 | + /** @var array $titles table titles (name, display value) */ |
|
| 15 | + protected $titles = null; |
|
| 16 | 16 | |
| 17 | - /** @var array $content table content (name, sb column name). name index must be the same as $titles*/ |
|
| 18 | - protected $content = null; |
|
| 17 | + /** @var array $content table content (name, sb column name). name index must be the same as $titles*/ |
|
| 18 | + protected $content = null; |
|
| 19 | 19 | |
| 20 | - /** @var array $columnNames names of columns for filtering */ |
|
| 21 | - protected $columnNames = array(); |
|
| 20 | + /** @var array $columnNames names of columns for filtering */ |
|
| 21 | + protected $columnNames = array(); |
|
| 22 | 22 | |
| 23 | - /** @var mixed $dbConn connection to database */ |
|
| 24 | - protected $dbConn = null; |
|
| 23 | + /** @var mixed $dbConn connection to database */ |
|
| 24 | + protected $dbConn = null; |
|
| 25 | 25 | |
| 26 | - /** Current view **/ |
|
| 27 | - protected $view; |
|
| 26 | + /** Current view **/ |
|
| 27 | + protected $view; |
|
| 28 | 28 | |
| 29 | - protected $urlPath; |
|
| 29 | + protected $urlPath; |
|
| 30 | 30 | |
| 31 | - // Database stuff |
|
| 31 | + // Database stuff |
|
| 32 | 32 | /** @var array $table (db ref, name) */ |
| 33 | - protected $table = array(); |
|
| 34 | - |
|
| 35 | - /** @var mixed $query Query in database; */ |
|
| 36 | - protected $query = null; |
|
| 37 | - |
|
| 38 | - function __construct(array $table,array $titles, array $columns, array $columnNames, $dbConn , $view, $urlPath) |
|
| 39 | - { |
|
| 40 | - $this->table = $table; |
|
| 41 | - $this->titles = $titles; |
|
| 42 | - $this->content = $columns; |
|
| 43 | - $this->columnNames = $columnNames; |
|
| 44 | - $this->dbConn = $dbConn; |
|
| 33 | + protected $table = array(); |
|
| 34 | + |
|
| 35 | + /** @var mixed $query Query in database; */ |
|
| 36 | + protected $query = null; |
|
| 37 | + |
|
| 38 | + function __construct(array $table,array $titles, array $columns, array $columnNames, $dbConn , $view, $urlPath) |
|
| 39 | + { |
|
| 40 | + $this->table = $table; |
|
| 41 | + $this->titles = $titles; |
|
| 42 | + $this->content = $columns; |
|
| 43 | + $this->columnNames = $columnNames; |
|
| 44 | + $this->dbConn = $dbConn; |
|
| 45 | 45 | |
| 46 | - $this->view = $view; |
|
| 47 | - $this->urlPath = $urlPath; |
|
| 46 | + $this->view = $view; |
|
| 47 | + $this->urlPath = $urlPath; |
|
| 48 | 48 | |
| 49 | - return $this; |
|
| 50 | - } |
|
| 49 | + return $this; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | 52 | |
| 53 | - /************** GET variables and URLs *************/ |
|
| 54 | - public function getParams(array $getVars) |
|
| 55 | - { |
|
| 56 | - $this->getFilterQuery($getVars); |
|
| 57 | - $this->getPagingQuery($getVars); |
|
| 58 | - $this->getOrderQuery($getVars); |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - public function getCurrentURL() |
|
| 62 | - { |
|
| 63 | - return '?'; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - protected function getCurrentURLAndQS(string $caller) |
|
| 67 | - { |
|
| 68 | - $actionURL = $this->getCurrentURL() . '?' ; |
|
| 69 | - $QSList=array(); |
|
| 70 | - if ($caller != 'filter' && $this->curFilterQuery() != '') |
|
| 71 | - array_push($QSList , $this->curFilterQuery()); |
|
| 53 | + /************** GET variables and URLs *************/ |
|
| 54 | + public function getParams(array $getVars) |
|
| 55 | + { |
|
| 56 | + $this->getFilterQuery($getVars); |
|
| 57 | + $this->getPagingQuery($getVars); |
|
| 58 | + $this->getOrderQuery($getVars); |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + public function getCurrentURL() |
|
| 62 | + { |
|
| 63 | + return '?'; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + protected function getCurrentURLAndQS(string $caller) |
|
| 67 | + { |
|
| 68 | + $actionURL = $this->getCurrentURL() . '?' ; |
|
| 69 | + $QSList=array(); |
|
| 70 | + if ($caller != 'filter' && $this->curFilterQuery() != '') |
|
| 71 | + array_push($QSList , $this->curFilterQuery()); |
|
| 72 | 72 | |
| 73 | - if ($caller != 'paging' && $caller != 'filter' && $this->curPagingQuery() != '') |
|
| 74 | - array_push($QSList , $this->curPagingQuery()); |
|
| 73 | + if ($caller != 'paging' && $caller != 'filter' && $this->curPagingQuery() != '') |
|
| 74 | + array_push($QSList , $this->curPagingQuery()); |
|
| 75 | 75 | |
| 76 | - if ($caller != 'order' && $this->curOrderQuery() != '') |
|
| 77 | - array_push($QSList , $this->curOrderQuery()); |
|
| 76 | + if ($caller != 'order' && $this->curOrderQuery() != '') |
|
| 77 | + array_push($QSList , $this->curOrderQuery()); |
|
| 78 | 78 | |
| 79 | - if (count($QSList) != 0) |
|
| 80 | - $actionURL .= implode('&', $QSList) . '&'; |
|
| 79 | + if (count($QSList) != 0) |
|
| 80 | + $actionURL .= implode('&', $QSList) . '&'; |
|
| 81 | 81 | |
| 82 | - return $actionURL; |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - /************* DB queries ******************/ |
|
| 86 | - /** |
|
| 87 | - * Get base query in $this->query |
|
| 88 | - * @return TrapDirectorTable |
|
| 89 | - */ |
|
| 90 | - public function getBaseQuery() |
|
| 91 | - { |
|
| 92 | - $this->query = $this->dbConn->select(); |
|
| 93 | - $this->query = $this->query->from( |
|
| 94 | - $this->table, |
|
| 95 | - $this->content |
|
| 96 | - ); |
|
| 82 | + return $actionURL; |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + /************* DB queries ******************/ |
|
| 86 | + /** |
|
| 87 | + * Get base query in $this->query |
|
| 88 | + * @return TrapDirectorTable |
|
| 89 | + */ |
|
| 90 | + public function getBaseQuery() |
|
| 91 | + { |
|
| 92 | + $this->query = $this->dbConn->select(); |
|
| 93 | + $this->query = $this->query->from( |
|
| 94 | + $this->table, |
|
| 95 | + $this->content |
|
| 96 | + ); |
|
| 97 | 97 | |
| 98 | - return $this; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - public function fullQuery() |
|
| 102 | - { |
|
| 103 | - $this->getBaseQuery() |
|
| 104 | - ->applyFilter() |
|
| 105 | - ->applyPaging() |
|
| 106 | - ->applyOrder(); |
|
| 98 | + return $this; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + public function fullQuery() |
|
| 102 | + { |
|
| 103 | + $this->getBaseQuery() |
|
| 104 | + ->applyFilter() |
|
| 105 | + ->applyPaging() |
|
| 106 | + ->applyOrder(); |
|
| 107 | 107 | |
| 108 | - return $this->dbConn->fetchAll($this->query); |
|
| 109 | - //return $this->query->fetchAll(); |
|
| 110 | - } |
|
| 108 | + return $this->dbConn->fetchAll($this->query); |
|
| 109 | + //return $this->query->fetchAll(); |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - /*************** Rendering *************************/ |
|
| 113 | - |
|
| 114 | - public function titleOrder($name) |
|
| 115 | - { |
|
| 116 | - return $this->content[$name]; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - public function renderTitles() |
|
| 120 | - { |
|
| 121 | - $html = "<thead>\n<tr>\n"; |
|
| 122 | - foreach ($this->titles as $name => $values) |
|
| 123 | - { |
|
| 124 | - $titleOrder = $this->titleOrder($name); // TODO : put this as function of order trait |
|
| 125 | - if ($titleOrder != NULL) |
|
| 126 | - { |
|
| 127 | - if (isset($this->order[$titleOrder])) |
|
| 128 | - { |
|
| 129 | - if ($this->order[$titleOrder] == 'ASC') |
|
| 130 | - { |
|
| 131 | - $titleOrder.='DESC'; |
|
| 132 | - } |
|
| 133 | - else |
|
| 134 | - { |
|
| 135 | - $titleOrder.='ASC'; |
|
| 136 | - } |
|
| 137 | - } |
|
| 138 | - else |
|
| 139 | - { |
|
| 140 | - $titleOrder.='ASC'; |
|
| 141 | - } |
|
| 142 | - $actionURL = $this->getCurrentURLAndQS('order').'o='.$titleOrder; |
|
| 143 | - $html .= '<th><a href="'.$actionURL.'">' . $values . '</a></th>'; |
|
| 144 | - } |
|
| 145 | - else |
|
| 146 | - { |
|
| 147 | - $html .= '<th>' . $values . '</th>'; |
|
| 148 | - } |
|
| 149 | - } |
|
| 150 | - $html .= "</tr>\n</thead>\n"; |
|
| 151 | - return $html; |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - public function renderLine( $value) |
|
| 155 | - { |
|
| 156 | - $html = ''; |
|
| 157 | - $titleNames = array_keys($this->titles); |
|
| 158 | - foreach ($titleNames as $name ) |
|
| 159 | - { |
|
| 160 | - $html .= '<td>'; |
|
| 161 | - $html .= $value->$name; |
|
| 162 | - $html .= "</td>\n"; |
|
| 163 | - } |
|
| 164 | - return $html; |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - public function renderTable(array $values) |
|
| 168 | - { |
|
| 169 | - $html = '<tbody id="obj_table_body">'; |
|
| 170 | - foreach($values as $value) |
|
| 171 | - { |
|
| 172 | - $html .= $this->groupingNextLine($value); |
|
| 112 | + /*************** Rendering *************************/ |
|
| 113 | + |
|
| 114 | + public function titleOrder($name) |
|
| 115 | + { |
|
| 116 | + return $this->content[$name]; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + public function renderTitles() |
|
| 120 | + { |
|
| 121 | + $html = "<thead>\n<tr>\n"; |
|
| 122 | + foreach ($this->titles as $name => $values) |
|
| 123 | + { |
|
| 124 | + $titleOrder = $this->titleOrder($name); // TODO : put this as function of order trait |
|
| 125 | + if ($titleOrder != NULL) |
|
| 126 | + { |
|
| 127 | + if (isset($this->order[$titleOrder])) |
|
| 128 | + { |
|
| 129 | + if ($this->order[$titleOrder] == 'ASC') |
|
| 130 | + { |
|
| 131 | + $titleOrder.='DESC'; |
|
| 132 | + } |
|
| 133 | + else |
|
| 134 | + { |
|
| 135 | + $titleOrder.='ASC'; |
|
| 136 | + } |
|
| 137 | + } |
|
| 138 | + else |
|
| 139 | + { |
|
| 140 | + $titleOrder.='ASC'; |
|
| 141 | + } |
|
| 142 | + $actionURL = $this->getCurrentURLAndQS('order').'o='.$titleOrder; |
|
| 143 | + $html .= '<th><a href="'.$actionURL.'">' . $values . '</a></th>'; |
|
| 144 | + } |
|
| 145 | + else |
|
| 146 | + { |
|
| 147 | + $html .= '<th>' . $values . '</th>'; |
|
| 148 | + } |
|
| 149 | + } |
|
| 150 | + $html .= "</tr>\n</thead>\n"; |
|
| 151 | + return $html; |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + public function renderLine( $value) |
|
| 155 | + { |
|
| 156 | + $html = ''; |
|
| 157 | + $titleNames = array_keys($this->titles); |
|
| 158 | + foreach ($titleNames as $name ) |
|
| 159 | + { |
|
| 160 | + $html .= '<td>'; |
|
| 161 | + $html .= $value->$name; |
|
| 162 | + $html .= "</td>\n"; |
|
| 163 | + } |
|
| 164 | + return $html; |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + public function renderTable(array $values) |
|
| 168 | + { |
|
| 169 | + $html = '<tbody id="obj_table_body">'; |
|
| 170 | + foreach($values as $value) |
|
| 171 | + { |
|
| 172 | + $html .= $this->groupingNextLine($value); |
|
| 173 | 173 | |
| 174 | - $html .= "<tr>\n"; |
|
| 175 | - $html .= $this->renderLine($value); |
|
| 176 | - $html .= "</tr>\n"; |
|
| 177 | - } |
|
| 178 | - $html .= '</tbody>'; |
|
| 179 | - return $html; |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - public function render() |
|
| 183 | - { |
|
| 184 | - $html = ''; |
|
| 174 | + $html .= "<tr>\n"; |
|
| 175 | + $html .= $this->renderLine($value); |
|
| 176 | + $html .= "</tr>\n"; |
|
| 177 | + } |
|
| 178 | + $html .= '</tbody>'; |
|
| 179 | + return $html; |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + public function render() |
|
| 183 | + { |
|
| 184 | + $html = ''; |
|
| 185 | 185 | |
| 186 | 186 | |
| 187 | - $values = $this->fullQuery(); |
|
| 188 | - $this->initGrouping(); |
|
| 187 | + $values = $this->fullQuery(); |
|
| 188 | + $this->initGrouping(); |
|
| 189 | 189 | |
| 190 | - $html.="<table class='simple common-table table-row-selectable'>\n"; |
|
| 190 | + $html.="<table class='simple common-table table-row-selectable'>\n"; |
|
| 191 | 191 | |
| 192 | - $html .= $this->renderTitles(); |
|
| 193 | - $html .= $this->renderTable($values); |
|
| 194 | - $html .= '</table>'; |
|
| 192 | + $html .= $this->renderTitles(); |
|
| 193 | + $html .= $this->renderTable($values); |
|
| 194 | + $html .= '</table>'; |
|
| 195 | 195 | |
| 196 | 196 | |
| 197 | - return $html; |
|
| 198 | - } |
|
| 197 | + return $html; |
|
| 198 | + } |
|
| 199 | 199 | |
| 200 | 200 | } |
| 201 | 201 | \ No newline at end of file |
@@ -12,16 +12,16 @@ discard block |
||
| 12 | 12 | use TrapDirectorTableGrouping; |
| 13 | 13 | |
| 14 | 14 | /** @var array $titles table titles (name, display value) */ |
| 15 | - protected $titles = null; |
|
| 15 | + protected $titles=null; |
|
| 16 | 16 | |
| 17 | 17 | /** @var array $content table content (name, sb column name). name index must be the same as $titles*/ |
| 18 | - protected $content = null; |
|
| 18 | + protected $content=null; |
|
| 19 | 19 | |
| 20 | 20 | /** @var array $columnNames names of columns for filtering */ |
| 21 | - protected $columnNames = array(); |
|
| 21 | + protected $columnNames=array(); |
|
| 22 | 22 | |
| 23 | 23 | /** @var mixed $dbConn connection to database */ |
| 24 | - protected $dbConn = null; |
|
| 24 | + protected $dbConn=null; |
|
| 25 | 25 | |
| 26 | 26 | /** Current view **/ |
| 27 | 27 | protected $view; |
@@ -30,21 +30,21 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | // Database stuff |
| 32 | 32 | /** @var array $table (db ref, name) */ |
| 33 | - protected $table = array(); |
|
| 33 | + protected $table=array(); |
|
| 34 | 34 | |
| 35 | 35 | /** @var mixed $query Query in database; */ |
| 36 | - protected $query = null; |
|
| 36 | + protected $query=null; |
|
| 37 | 37 | |
| 38 | - function __construct(array $table,array $titles, array $columns, array $columnNames, $dbConn , $view, $urlPath) |
|
| 38 | + function __construct(array $table, array $titles, array $columns, array $columnNames, $dbConn, $view, $urlPath) |
|
| 39 | 39 | { |
| 40 | - $this->table = $table; |
|
| 41 | - $this->titles = $titles; |
|
| 42 | - $this->content = $columns; |
|
| 43 | - $this->columnNames = $columnNames; |
|
| 44 | - $this->dbConn = $dbConn; |
|
| 40 | + $this->table=$table; |
|
| 41 | + $this->titles=$titles; |
|
| 42 | + $this->content=$columns; |
|
| 43 | + $this->columnNames=$columnNames; |
|
| 44 | + $this->dbConn=$dbConn; |
|
| 45 | 45 | |
| 46 | - $this->view = $view; |
|
| 47 | - $this->urlPath = $urlPath; |
|
| 46 | + $this->view=$view; |
|
| 47 | + $this->urlPath=$urlPath; |
|
| 48 | 48 | |
| 49 | 49 | return $this; |
| 50 | 50 | } |
@@ -65,19 +65,19 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | protected function getCurrentURLAndQS(string $caller) |
| 67 | 67 | { |
| 68 | - $actionURL = $this->getCurrentURL() . '?' ; |
|
| 68 | + $actionURL=$this->getCurrentURL().'?'; |
|
| 69 | 69 | $QSList=array(); |
| 70 | 70 | if ($caller != 'filter' && $this->curFilterQuery() != '') |
| 71 | - array_push($QSList , $this->curFilterQuery()); |
|
| 71 | + array_push($QSList, $this->curFilterQuery()); |
|
| 72 | 72 | |
| 73 | 73 | if ($caller != 'paging' && $caller != 'filter' && $this->curPagingQuery() != '') |
| 74 | - array_push($QSList , $this->curPagingQuery()); |
|
| 74 | + array_push($QSList, $this->curPagingQuery()); |
|
| 75 | 75 | |
| 76 | 76 | if ($caller != 'order' && $this->curOrderQuery() != '') |
| 77 | - array_push($QSList , $this->curOrderQuery()); |
|
| 77 | + array_push($QSList, $this->curOrderQuery()); |
|
| 78 | 78 | |
| 79 | 79 | if (count($QSList) != 0) |
| 80 | - $actionURL .= implode('&', $QSList) . '&'; |
|
| 80 | + $actionURL.=implode('&', $QSList).'&'; |
|
| 81 | 81 | |
| 82 | 82 | return $actionURL; |
| 83 | 83 | } |
@@ -89,8 +89,8 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | public function getBaseQuery() |
| 91 | 91 | { |
| 92 | - $this->query = $this->dbConn->select(); |
|
| 93 | - $this->query = $this->query->from( |
|
| 92 | + $this->query=$this->dbConn->select(); |
|
| 93 | + $this->query=$this->query->from( |
|
| 94 | 94 | $this->table, |
| 95 | 95 | $this->content |
| 96 | 96 | ); |
@@ -118,10 +118,10 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | public function renderTitles() |
| 120 | 120 | { |
| 121 | - $html = "<thead>\n<tr>\n"; |
|
| 121 | + $html="<thead>\n<tr>\n"; |
|
| 122 | 122 | foreach ($this->titles as $name => $values) |
| 123 | 123 | { |
| 124 | - $titleOrder = $this->titleOrder($name); // TODO : put this as function of order trait |
|
| 124 | + $titleOrder=$this->titleOrder($name); // TODO : put this as function of order trait |
|
| 125 | 125 | if ($titleOrder != NULL) |
| 126 | 126 | { |
| 127 | 127 | if (isset($this->order[$titleOrder])) |
@@ -139,59 +139,59 @@ discard block |
||
| 139 | 139 | { |
| 140 | 140 | $titleOrder.='ASC'; |
| 141 | 141 | } |
| 142 | - $actionURL = $this->getCurrentURLAndQS('order').'o='.$titleOrder; |
|
| 143 | - $html .= '<th><a href="'.$actionURL.'">' . $values . '</a></th>'; |
|
| 142 | + $actionURL=$this->getCurrentURLAndQS('order').'o='.$titleOrder; |
|
| 143 | + $html.='<th><a href="'.$actionURL.'">'.$values.'</a></th>'; |
|
| 144 | 144 | } |
| 145 | 145 | else |
| 146 | 146 | { |
| 147 | - $html .= '<th>' . $values . '</th>'; |
|
| 147 | + $html.='<th>'.$values.'</th>'; |
|
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | - $html .= "</tr>\n</thead>\n"; |
|
| 150 | + $html.="</tr>\n</thead>\n"; |
|
| 151 | 151 | return $html; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - public function renderLine( $value) |
|
| 154 | + public function renderLine($value) |
|
| 155 | 155 | { |
| 156 | - $html = ''; |
|
| 157 | - $titleNames = array_keys($this->titles); |
|
| 158 | - foreach ($titleNames as $name ) |
|
| 156 | + $html=''; |
|
| 157 | + $titleNames=array_keys($this->titles); |
|
| 158 | + foreach ($titleNames as $name) |
|
| 159 | 159 | { |
| 160 | - $html .= '<td>'; |
|
| 161 | - $html .= $value->$name; |
|
| 162 | - $html .= "</td>\n"; |
|
| 160 | + $html.='<td>'; |
|
| 161 | + $html.=$value->$name; |
|
| 162 | + $html.="</td>\n"; |
|
| 163 | 163 | } |
| 164 | 164 | return $html; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | public function renderTable(array $values) |
| 168 | 168 | { |
| 169 | - $html = '<tbody id="obj_table_body">'; |
|
| 170 | - foreach($values as $value) |
|
| 169 | + $html='<tbody id="obj_table_body">'; |
|
| 170 | + foreach ($values as $value) |
|
| 171 | 171 | { |
| 172 | - $html .= $this->groupingNextLine($value); |
|
| 172 | + $html.=$this->groupingNextLine($value); |
|
| 173 | 173 | |
| 174 | - $html .= "<tr>\n"; |
|
| 175 | - $html .= $this->renderLine($value); |
|
| 176 | - $html .= "</tr>\n"; |
|
| 174 | + $html.="<tr>\n"; |
|
| 175 | + $html.=$this->renderLine($value); |
|
| 176 | + $html.="</tr>\n"; |
|
| 177 | 177 | } |
| 178 | - $html .= '</tbody>'; |
|
| 178 | + $html.='</tbody>'; |
|
| 179 | 179 | return $html; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | public function render() |
| 183 | 183 | { |
| 184 | - $html = ''; |
|
| 184 | + $html=''; |
|
| 185 | 185 | |
| 186 | 186 | |
| 187 | - $values = $this->fullQuery(); |
|
| 187 | + $values=$this->fullQuery(); |
|
| 188 | 188 | $this->initGrouping(); |
| 189 | 189 | |
| 190 | 190 | $html.="<table class='simple common-table table-row-selectable'>\n"; |
| 191 | 191 | |
| 192 | - $html .= $this->renderTitles(); |
|
| 193 | - $html .= $this->renderTable($values); |
|
| 194 | - $html .= '</table>'; |
|
| 192 | + $html.=$this->renderTitles(); |
|
| 193 | + $html.=$this->renderTable($values); |
|
| 194 | + $html.='</table>'; |
|
| 195 | 195 | |
| 196 | 196 | |
| 197 | 197 | return $html; |
@@ -67,17 +67,21 @@ discard block |
||
| 67 | 67 | { |
| 68 | 68 | $actionURL = $this->getCurrentURL() . '?' ; |
| 69 | 69 | $QSList=array(); |
| 70 | - if ($caller != 'filter' && $this->curFilterQuery() != '') |
|
| 71 | - array_push($QSList , $this->curFilterQuery()); |
|
| 70 | + if ($caller != 'filter' && $this->curFilterQuery() != '') { |
|
| 71 | + array_push($QSList , $this->curFilterQuery()); |
|
| 72 | + } |
|
| 72 | 73 | |
| 73 | - if ($caller != 'paging' && $caller != 'filter' && $this->curPagingQuery() != '') |
|
| 74 | - array_push($QSList , $this->curPagingQuery()); |
|
| 74 | + if ($caller != 'paging' && $caller != 'filter' && $this->curPagingQuery() != '') { |
|
| 75 | + array_push($QSList , $this->curPagingQuery()); |
|
| 76 | + } |
|
| 75 | 77 | |
| 76 | - if ($caller != 'order' && $this->curOrderQuery() != '') |
|
| 77 | - array_push($QSList , $this->curOrderQuery()); |
|
| 78 | + if ($caller != 'order' && $this->curOrderQuery() != '') { |
|
| 79 | + array_push($QSList , $this->curOrderQuery()); |
|
| 80 | + } |
|
| 78 | 81 | |
| 79 | - if (count($QSList) != 0) |
|
| 80 | - $actionURL .= implode('&', $QSList) . '&'; |
|
| 82 | + if (count($QSList) != 0) { |
|
| 83 | + $actionURL .= implode('&', $QSList) . '&'; |
|
| 84 | + } |
|
| 81 | 85 | |
| 82 | 86 | return $actionURL; |
| 83 | 87 | } |
@@ -129,20 +133,17 @@ discard block |
||
| 129 | 133 | if ($this->order[$titleOrder] == 'ASC') |
| 130 | 134 | { |
| 131 | 135 | $titleOrder.='DESC'; |
| 132 | - } |
|
| 133 | - else |
|
| 136 | + } else |
|
| 134 | 137 | { |
| 135 | 138 | $titleOrder.='ASC'; |
| 136 | 139 | } |
| 137 | - } |
|
| 138 | - else |
|
| 140 | + } else |
|
| 139 | 141 | { |
| 140 | 142 | $titleOrder.='ASC'; |
| 141 | 143 | } |
| 142 | 144 | $actionURL = $this->getCurrentURLAndQS('order').'o='.$titleOrder; |
| 143 | 145 | $html .= '<th><a href="'.$actionURL.'">' . $values . '</a></th>'; |
| 144 | - } |
|
| 145 | - else |
|
| 146 | + } else |
|
| 146 | 147 | { |
| 147 | 148 | $html .= '<th>' . $values . '</th>'; |
| 148 | 149 | } |
@@ -46,7 +46,9 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | protected function curPagingQuery() |
| 48 | 48 | { |
| 49 | - if ($this->currentPage == '') return ''; |
|
| 49 | + if ($this->currentPage == '') { |
|
| 50 | + return ''; |
|
| 51 | + } |
|
| 50 | 52 | return 'page='.$this->currentPage; |
| 51 | 53 | } |
| 52 | 54 | |
@@ -58,10 +60,14 @@ discard block |
||
| 58 | 60 | return 'count : ' . $this->count() . '<br>'; |
| 59 | 61 | } |
| 60 | 62 | |
| 61 | - if ($this->currentPage == 0) $this->currentPage = 1; |
|
| 63 | + if ($this->currentPage == 0) { |
|
| 64 | + $this->currentPage = 1; |
|
| 65 | + } |
|
| 62 | 66 | |
| 63 | 67 | $numPages = intdiv($count , $this->maxPerPage); |
| 64 | - if ($count % $this->maxPerPage != 0 ) $numPages++; |
|
| 68 | + if ($count % $this->maxPerPage != 0 ) { |
|
| 69 | + $numPages++; |
|
| 70 | + } |
|
| 65 | 71 | |
| 66 | 72 | $html = '<div class="pagination-control" role="navigation">'; |
| 67 | 73 | $html .= '<ul class="nav tab-nav">'; |
@@ -75,8 +81,7 @@ discard block |
||
| 75 | 81 | </span> |
| 76 | 82 | </li> |
| 77 | 83 | '; |
| 78 | - } |
|
| 79 | - else |
|
| 84 | + } else |
|
| 80 | 85 | { |
| 81 | 86 | $html .= ' |
| 82 | 87 | <li class="nav-item"> |
@@ -92,7 +97,9 @@ discard block |
||
| 92 | 97 | $active = ($this->currentPage == $i) ? 'active' : ''; |
| 93 | 98 | $first = ($i-1)*$this->maxPerPage+1; |
| 94 | 99 | $last = $i * $this->maxPerPage; |
| 95 | - if ($last > $count) $last = $count; |
|
| 100 | + if ($last > $count) { |
|
| 101 | + $last = $count; |
|
| 102 | + } |
|
| 96 | 103 | $display = 'Show rows '. $first . ' to '. $last .' of '. $count; |
| 97 | 104 | $html .= '<li class="' . $active . ' nav-item"> |
| 98 | 105 | <a href="'. $this->getCurrentURLAndQS('paging') .'&page='. $i .'" title="' . $display . '" aria-label="' . $display . '"> |
@@ -111,8 +118,7 @@ discard block |
||
| 111 | 118 | </span> |
| 112 | 119 | </li> |
| 113 | 120 | '; |
| 114 | - } |
|
| 115 | - else |
|
| 121 | + } else |
|
| 116 | 122 | { |
| 117 | 123 | $html .= ' |
| 118 | 124 | <li class="nav-item"> |
@@ -6,72 +6,72 @@ discard block |
||
| 6 | 6 | trait TrapDirectorTablePaging |
| 7 | 7 | { |
| 8 | 8 | |
| 9 | - /*************** Paging *************/ |
|
| 10 | - protected $maxPerPage = 25; |
|
| 9 | + /*************** Paging *************/ |
|
| 10 | + protected $maxPerPage = 25; |
|
| 11 | 11 | |
| 12 | - protected $currentPage = 0; |
|
| 12 | + protected $currentPage = 0; |
|
| 13 | 13 | |
| 14 | - /**** var & func of TrapDirectorTable used ***/ |
|
| 15 | - protected $query; |
|
| 16 | - abstract protected function getCurrentURLAndQS(string $caller); |
|
| 17 | - abstract public function applyFilter(); |
|
| 14 | + /**** var & func of TrapDirectorTable used ***/ |
|
| 15 | + protected $query; |
|
| 16 | + abstract protected function getCurrentURLAndQS(string $caller); |
|
| 17 | + abstract public function applyFilter(); |
|
| 18 | 18 | |
| 19 | - /***************** Paging and counting *********/ |
|
| 19 | + /***************** Paging and counting *********/ |
|
| 20 | 20 | |
| 21 | - public function countQuery() |
|
| 22 | - { |
|
| 23 | - $this->query = $this->dbConn->select(); |
|
| 24 | - $this->query = $this->query |
|
| 25 | - ->from( |
|
| 26 | - $this->table, |
|
| 27 | - array('COUNT(*)') |
|
| 28 | - ); |
|
| 29 | - $this->applyFilter(); |
|
| 30 | - } |
|
| 21 | + public function countQuery() |
|
| 22 | + { |
|
| 23 | + $this->query = $this->dbConn->select(); |
|
| 24 | + $this->query = $this->query |
|
| 25 | + ->from( |
|
| 26 | + $this->table, |
|
| 27 | + array('COUNT(*)') |
|
| 28 | + ); |
|
| 29 | + $this->applyFilter(); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - public function count() |
|
| 33 | - { |
|
| 34 | - $this->countQuery(); |
|
| 35 | - return $this->dbConn->fetchOne($this->query); |
|
| 36 | - } |
|
| 32 | + public function count() |
|
| 33 | + { |
|
| 34 | + $this->countQuery(); |
|
| 35 | + return $this->dbConn->fetchOne($this->query); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - public function setMaxPerPage(int $max) |
|
| 39 | - { |
|
| 40 | - $this->maxPerPage = $max; |
|
| 41 | - } |
|
| 38 | + public function setMaxPerPage(int $max) |
|
| 39 | + { |
|
| 40 | + $this->maxPerPage = $max; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - protected function getPagingQuery(array $getVars) |
|
| 44 | - { |
|
| 45 | - if (isset($getVars['page'])) |
|
| 46 | - { |
|
| 47 | - $this->currentPage = $getVars['page']; |
|
| 48 | - } |
|
| 49 | - } |
|
| 43 | + protected function getPagingQuery(array $getVars) |
|
| 44 | + { |
|
| 45 | + if (isset($getVars['page'])) |
|
| 46 | + { |
|
| 47 | + $this->currentPage = $getVars['page']; |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - protected function curPagingQuery() |
|
| 52 | - { |
|
| 53 | - if ($this->currentPage == '') return ''; |
|
| 54 | - return 'page='.$this->currentPage; |
|
| 55 | - } |
|
| 51 | + protected function curPagingQuery() |
|
| 52 | + { |
|
| 53 | + if ($this->currentPage == '') return ''; |
|
| 54 | + return 'page='.$this->currentPage; |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - public function renderPagingHeader() |
|
| 58 | - { |
|
| 59 | - $count = $this->count(); |
|
| 60 | - if ($count <= $this->maxPerPage ) |
|
| 61 | - { |
|
| 62 | - return 'count : ' . $this->count() . '<br>'; |
|
| 63 | - } |
|
| 57 | + public function renderPagingHeader() |
|
| 58 | + { |
|
| 59 | + $count = $this->count(); |
|
| 60 | + if ($count <= $this->maxPerPage ) |
|
| 61 | + { |
|
| 62 | + return 'count : ' . $this->count() . '<br>'; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - if ($this->currentPage == 0) $this->currentPage = 1; |
|
| 65 | + if ($this->currentPage == 0) $this->currentPage = 1; |
|
| 66 | 66 | |
| 67 | - $numPages = intdiv($count , $this->maxPerPage); |
|
| 68 | - if ($count % $this->maxPerPage != 0 ) $numPages++; |
|
| 67 | + $numPages = intdiv($count , $this->maxPerPage); |
|
| 68 | + if ($count % $this->maxPerPage != 0 ) $numPages++; |
|
| 69 | 69 | |
| 70 | - $html = '<div class="pagination-control" role="navigation">'; |
|
| 71 | - $html .= '<ul class="nav tab-nav">'; |
|
| 72 | - if ($this->currentPage <=1) |
|
| 73 | - { |
|
| 74 | - $html .= ' |
|
| 70 | + $html = '<div class="pagination-control" role="navigation">'; |
|
| 71 | + $html .= '<ul class="nav tab-nav">'; |
|
| 72 | + if ($this->currentPage <=1) |
|
| 73 | + { |
|
| 74 | + $html .= ' |
|
| 75 | 75 | <li class="nav-item disabled" aria-hidden="true"> |
| 76 | 76 | <span class="previous-page"> |
| 77 | 77 | <span class="sr-only">Previous page</span> |
@@ -79,35 +79,35 @@ discard block |
||
| 79 | 79 | </span> |
| 80 | 80 | </li> |
| 81 | 81 | '; |
| 82 | - } |
|
| 83 | - else |
|
| 84 | - { |
|
| 85 | - $html .= ' |
|
| 82 | + } |
|
| 83 | + else |
|
| 84 | + { |
|
| 85 | + $html .= ' |
|
| 86 | 86 | <li class="nav-item"> |
| 87 | 87 | <a href="'. $this->getCurrentURLAndQS('paging') .'&page='. ($this->currentPage - 1 ).'" class="previous-page" > |
| 88 | 88 | <i aria-hidden="true" class="icon-angle-double-left"></i> |
| 89 | 89 | </a> |
| 90 | 90 | </li> |
| 91 | 91 | '; |
| 92 | - } |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - for ($i=1; $i <= $numPages ; $i++) |
|
| 95 | - { |
|
| 96 | - $active = ($this->currentPage == $i) ? 'active' : ''; |
|
| 97 | - $first = ($i-1)*$this->maxPerPage+1; |
|
| 98 | - $last = $i * $this->maxPerPage; |
|
| 99 | - if ($last > $count) $last = $count; |
|
| 100 | - $display = 'Show rows '. $first . ' to '. $last .' of '. $count; |
|
| 101 | - $html .= '<li class="' . $active . ' nav-item"> |
|
| 94 | + for ($i=1; $i <= $numPages ; $i++) |
|
| 95 | + { |
|
| 96 | + $active = ($this->currentPage == $i) ? 'active' : ''; |
|
| 97 | + $first = ($i-1)*$this->maxPerPage+1; |
|
| 98 | + $last = $i * $this->maxPerPage; |
|
| 99 | + if ($last > $count) $last = $count; |
|
| 100 | + $display = 'Show rows '. $first . ' to '. $last .' of '. $count; |
|
| 101 | + $html .= '<li class="' . $active . ' nav-item"> |
|
| 102 | 102 | <a href="'. $this->getCurrentURLAndQS('paging') .'&page='. $i .'" title="' . $display . '" aria-label="' . $display . '"> |
| 103 | 103 | '.$i.' |
| 104 | 104 | </a> |
| 105 | 105 | </li>'; |
| 106 | - } |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - if ($this->currentPage == $numPages) |
|
| 109 | - { |
|
| 110 | - $html .= ' |
|
| 108 | + if ($this->currentPage == $numPages) |
|
| 109 | + { |
|
| 110 | + $html .= ' |
|
| 111 | 111 | <li class="nav-item disabled" aria-hidden="true"> |
| 112 | 112 | <span class="previous-page"> |
| 113 | 113 | <span class="sr-only">Previous page</span> |
@@ -115,28 +115,28 @@ discard block |
||
| 115 | 115 | </span> |
| 116 | 116 | </li> |
| 117 | 117 | '; |
| 118 | - } |
|
| 119 | - else |
|
| 120 | - { |
|
| 121 | - $html .= ' |
|
| 118 | + } |
|
| 119 | + else |
|
| 120 | + { |
|
| 121 | + $html .= ' |
|
| 122 | 122 | <li class="nav-item"> |
| 123 | 123 | <a href="'. $this->getCurrentURLAndQS('paging') .'&page='. ($this->currentPage + 1 ).'" class="next-page"> |
| 124 | 124 | <i aria-hidden="true" class="icon-angle-double-right"></i> |
| 125 | 125 | </a> |
| 126 | 126 | </li> |
| 127 | 127 | '; |
| 128 | - } |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - $html .= '</ul> </div>'; |
|
| 130 | + $html .= '</ul> </div>'; |
|
| 131 | 131 | |
| 132 | - return $html; |
|
| 133 | - } |
|
| 132 | + return $html; |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - public function applyPaging() |
|
| 136 | - { |
|
| 137 | - $this->query->limitPage($this->currentPage,$this->maxPerPage); |
|
| 138 | - return $this; |
|
| 139 | - } |
|
| 135 | + public function applyPaging() |
|
| 136 | + { |
|
| 137 | + $this->query->limitPage($this->currentPage,$this->maxPerPage); |
|
| 138 | + return $this; |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | 141 | |
| 142 | 142 | } |
| 143 | 143 | \ No newline at end of file |
@@ -7,9 +7,9 @@ discard block |
||
| 7 | 7 | { |
| 8 | 8 | |
| 9 | 9 | /*************** Paging *************/ |
| 10 | - protected $maxPerPage = 25; |
|
| 10 | + protected $maxPerPage=25; |
|
| 11 | 11 | |
| 12 | - protected $currentPage = 0; |
|
| 12 | + protected $currentPage=0; |
|
| 13 | 13 | |
| 14 | 14 | /**** var & func of TrapDirectorTable used ***/ |
| 15 | 15 | protected $query; |
@@ -20,8 +20,8 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | public function countQuery() |
| 22 | 22 | { |
| 23 | - $this->query = $this->dbConn->select(); |
|
| 24 | - $this->query = $this->query |
|
| 23 | + $this->query=$this->dbConn->select(); |
|
| 24 | + $this->query=$this->query |
|
| 25 | 25 | ->from( |
| 26 | 26 | $this->table, |
| 27 | 27 | array('COUNT(*)') |
@@ -37,14 +37,14 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | public function setMaxPerPage(int $max) |
| 39 | 39 | { |
| 40 | - $this->maxPerPage = $max; |
|
| 40 | + $this->maxPerPage=$max; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | protected function getPagingQuery(array $getVars) |
| 44 | 44 | { |
| 45 | 45 | if (isset($getVars['page'])) |
| 46 | 46 | { |
| 47 | - $this->currentPage = $getVars['page']; |
|
| 47 | + $this->currentPage=$getVars['page']; |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
@@ -56,22 +56,22 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | public function renderPagingHeader() |
| 58 | 58 | { |
| 59 | - $count = $this->count(); |
|
| 60 | - if ($count <= $this->maxPerPage ) |
|
| 59 | + $count=$this->count(); |
|
| 60 | + if ($count <= $this->maxPerPage) |
|
| 61 | 61 | { |
| 62 | - return 'count : ' . $this->count() . '<br>'; |
|
| 62 | + return 'count : '.$this->count().'<br>'; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - if ($this->currentPage == 0) $this->currentPage = 1; |
|
| 65 | + if ($this->currentPage == 0) $this->currentPage=1; |
|
| 66 | 66 | |
| 67 | - $numPages = intdiv($count , $this->maxPerPage); |
|
| 68 | - if ($count % $this->maxPerPage != 0 ) $numPages++; |
|
| 67 | + $numPages=intdiv($count, $this->maxPerPage); |
|
| 68 | + if ($count % $this->maxPerPage != 0) $numPages++; |
|
| 69 | 69 | |
| 70 | - $html = '<div class="pagination-control" role="navigation">'; |
|
| 71 | - $html .= '<ul class="nav tab-nav">'; |
|
| 72 | - if ($this->currentPage <=1) |
|
| 70 | + $html='<div class="pagination-control" role="navigation">'; |
|
| 71 | + $html.='<ul class="nav tab-nav">'; |
|
| 72 | + if ($this->currentPage <= 1) |
|
| 73 | 73 | { |
| 74 | - $html .= ' |
|
| 74 | + $html.=' |
|
| 75 | 75 | <li class="nav-item disabled" aria-hidden="true"> |
| 76 | 76 | <span class="previous-page"> |
| 77 | 77 | <span class="sr-only">Previous page</span> |
@@ -82,24 +82,24 @@ discard block |
||
| 82 | 82 | } |
| 83 | 83 | else |
| 84 | 84 | { |
| 85 | - $html .= ' |
|
| 85 | + $html.=' |
|
| 86 | 86 | <li class="nav-item"> |
| 87 | - <a href="'. $this->getCurrentURLAndQS('paging') .'&page='. ($this->currentPage - 1 ).'" class="previous-page" > |
|
| 87 | + <a href="'. $this->getCurrentURLAndQS('paging').'&page='.($this->currentPage - 1).'" class="previous-page" > |
|
| 88 | 88 | <i aria-hidden="true" class="icon-angle-double-left"></i> |
| 89 | 89 | </a> |
| 90 | 90 | </li> |
| 91 | 91 | '; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - for ($i=1; $i <= $numPages ; $i++) |
|
| 94 | + for ($i=1; $i <= $numPages; $i++) |
|
| 95 | 95 | { |
| 96 | - $active = ($this->currentPage == $i) ? 'active' : ''; |
|
| 97 | - $first = ($i-1)*$this->maxPerPage+1; |
|
| 98 | - $last = $i * $this->maxPerPage; |
|
| 99 | - if ($last > $count) $last = $count; |
|
| 100 | - $display = 'Show rows '. $first . ' to '. $last .' of '. $count; |
|
| 101 | - $html .= '<li class="' . $active . ' nav-item"> |
|
| 102 | - <a href="'. $this->getCurrentURLAndQS('paging') .'&page='. $i .'" title="' . $display . '" aria-label="' . $display . '"> |
|
| 96 | + $active=($this->currentPage == $i) ? 'active' : ''; |
|
| 97 | + $first=($i - 1) * $this->maxPerPage + 1; |
|
| 98 | + $last=$i * $this->maxPerPage; |
|
| 99 | + if ($last > $count) $last=$count; |
|
| 100 | + $display='Show rows '.$first.' to '.$last.' of '.$count; |
|
| 101 | + $html.='<li class="'.$active.' nav-item"> |
|
| 102 | + <a href="'. $this->getCurrentURLAndQS('paging').'&page='.$i.'" title="'.$display.'" aria-label="'.$display.'"> |
|
| 103 | 103 | '.$i.' |
| 104 | 104 | </a> |
| 105 | 105 | </li>'; |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | if ($this->currentPage == $numPages) |
| 109 | 109 | { |
| 110 | - $html .= ' |
|
| 110 | + $html.=' |
|
| 111 | 111 | <li class="nav-item disabled" aria-hidden="true"> |
| 112 | 112 | <span class="previous-page"> |
| 113 | 113 | <span class="sr-only">Previous page</span> |
@@ -118,23 +118,23 @@ discard block |
||
| 118 | 118 | } |
| 119 | 119 | else |
| 120 | 120 | { |
| 121 | - $html .= ' |
|
| 121 | + $html.=' |
|
| 122 | 122 | <li class="nav-item"> |
| 123 | - <a href="'. $this->getCurrentURLAndQS('paging') .'&page='. ($this->currentPage + 1 ).'" class="next-page"> |
|
| 123 | + <a href="'. $this->getCurrentURLAndQS('paging').'&page='.($this->currentPage + 1).'" class="next-page"> |
|
| 124 | 124 | <i aria-hidden="true" class="icon-angle-double-right"></i> |
| 125 | 125 | </a> |
| 126 | 126 | </li> |
| 127 | 127 | '; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - $html .= '</ul> </div>'; |
|
| 130 | + $html.='</ul> </div>'; |
|
| 131 | 131 | |
| 132 | 132 | return $html; |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | public function applyPaging() |
| 136 | 136 | { |
| 137 | - $this->query->limitPage($this->currentPage,$this->maxPerPage); |
|
| 137 | + $this->query->limitPage($this->currentPage, $this->maxPerPage); |
|
| 138 | 138 | return $this; |
| 139 | 139 | } |
| 140 | 140 | |
@@ -20,7 +20,9 @@ discard block |
||
| 20 | 20 | $orderSQL=''; |
| 21 | 21 | foreach ($this->order as $column => $direction) |
| 22 | 22 | { |
| 23 | - if ($orderSQL != "") $orderSQL.=','; |
|
| 23 | + if ($orderSQL != "") { |
|
| 24 | + $orderSQL.=','; |
|
| 25 | + } |
|
| 24 | 26 | |
| 25 | 27 | $orderSQL .= $column . ' ' . $direction; |
| 26 | 28 | } |
@@ -37,7 +39,9 @@ discard block |
||
| 37 | 39 | |
| 38 | 40 | public function isOrderSet() |
| 39 | 41 | { |
| 40 | - if (count($this->order) == 0) return FALSE; |
|
| 42 | + if (count($this->order) == 0) { |
|
| 43 | + return FALSE; |
|
| 44 | + } |
|
| 41 | 45 | return TRUE; |
| 42 | 46 | } |
| 43 | 47 | |
@@ -58,7 +62,9 @@ discard block |
||
| 58 | 62 | |
| 59 | 63 | protected function curOrderQuery() |
| 60 | 64 | { |
| 61 | - if ($this->orderQuery == '') return ''; |
|
| 65 | + if ($this->orderQuery == '') { |
|
| 66 | + return ''; |
|
| 67 | + } |
|
| 62 | 68 | return 'o='.$this->orderQuery; |
| 63 | 69 | } |
| 64 | 70 | |
@@ -5,65 +5,65 @@ |
||
| 5 | 5 | |
| 6 | 6 | trait TrapDirectorTableOrder |
| 7 | 7 | { |
| 8 | - /** @var array $order : (db column, 'ASC' | 'DESC') */ |
|
| 9 | - protected $order = array(); |
|
| 10 | - /** @var string $orderQuery passed by GET */ |
|
| 11 | - protected $orderQuery = ''; |
|
| 8 | + /** @var array $order : (db column, 'ASC' | 'DESC') */ |
|
| 9 | + protected $order = array(); |
|
| 10 | + /** @var string $orderQuery passed by GET */ |
|
| 11 | + protected $orderQuery = ''; |
|
| 12 | 12 | |
| 13 | - /** used var & functions of trapDirectorTable **/ |
|
| 14 | - protected $query; |
|
| 13 | + /** used var & functions of trapDirectorTable **/ |
|
| 14 | + protected $query; |
|
| 15 | 15 | |
| 16 | 16 | /***************** Ordering ********************/ |
| 17 | 17 | |
| 18 | - public function applyOrder() |
|
| 19 | - { |
|
| 20 | - if (count($this->order) == 0) |
|
| 21 | - { |
|
| 22 | - return $this; |
|
| 23 | - } |
|
| 24 | - $orderSQL=''; |
|
| 25 | - foreach ($this->order as $column => $direction) |
|
| 26 | - { |
|
| 27 | - if ($orderSQL != "") $orderSQL.=','; |
|
| 18 | + public function applyOrder() |
|
| 19 | + { |
|
| 20 | + if (count($this->order) == 0) |
|
| 21 | + { |
|
| 22 | + return $this; |
|
| 23 | + } |
|
| 24 | + $orderSQL=''; |
|
| 25 | + foreach ($this->order as $column => $direction) |
|
| 26 | + { |
|
| 27 | + if ($orderSQL != "") $orderSQL.=','; |
|
| 28 | 28 | |
| 29 | - $orderSQL .= $column . ' ' . $direction; |
|
| 30 | - } |
|
| 31 | - $this->query = $this->query->order($orderSQL); |
|
| 29 | + $orderSQL .= $column . ' ' . $direction; |
|
| 30 | + } |
|
| 31 | + $this->query = $this->query->order($orderSQL); |
|
| 32 | 32 | |
| 33 | - return $this; |
|
| 34 | - } |
|
| 33 | + return $this; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - public function setOrder(array $order) |
|
| 37 | - { |
|
| 38 | - $this->order = $order; |
|
| 39 | - return $this; |
|
| 40 | - } |
|
| 36 | + public function setOrder(array $order) |
|
| 37 | + { |
|
| 38 | + $this->order = $order; |
|
| 39 | + return $this; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - public function isOrderSet() |
|
| 43 | - { |
|
| 44 | - if (count($this->order) == 0) return FALSE; |
|
| 45 | - return TRUE; |
|
| 46 | - } |
|
| 42 | + public function isOrderSet() |
|
| 43 | + { |
|
| 44 | + if (count($this->order) == 0) return FALSE; |
|
| 45 | + return TRUE; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - public function getOrderQuery(array $getVars) |
|
| 49 | - { |
|
| 50 | - if (isset($getVars['o'])) |
|
| 51 | - { |
|
| 52 | - $this->orderQuery = $getVars['o']; |
|
| 53 | - $match = array(); |
|
| 54 | - if (preg_match('/(.*)(ASC|DESC)$/', $this->orderQuery , $match)) |
|
| 55 | - { |
|
| 56 | - $orderArray=array($match[1] => $match[2]); |
|
| 57 | - echo "$match[1] => $match[2]"; |
|
| 58 | - $this->setOrder($orderArray); |
|
| 59 | - } |
|
| 60 | - } |
|
| 61 | - } |
|
| 48 | + public function getOrderQuery(array $getVars) |
|
| 49 | + { |
|
| 50 | + if (isset($getVars['o'])) |
|
| 51 | + { |
|
| 52 | + $this->orderQuery = $getVars['o']; |
|
| 53 | + $match = array(); |
|
| 54 | + if (preg_match('/(.*)(ASC|DESC)$/', $this->orderQuery , $match)) |
|
| 55 | + { |
|
| 56 | + $orderArray=array($match[1] => $match[2]); |
|
| 57 | + echo "$match[1] => $match[2]"; |
|
| 58 | + $this->setOrder($orderArray); |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - protected function curOrderQuery() |
|
| 64 | - { |
|
| 65 | - if ($this->orderQuery == '') return ''; |
|
| 66 | - return 'o='.$this->orderQuery; |
|
| 67 | - } |
|
| 63 | + protected function curOrderQuery() |
|
| 64 | + { |
|
| 65 | + if ($this->orderQuery == '') return ''; |
|
| 66 | + return 'o='.$this->orderQuery; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | 69 | } |
| 70 | 70 | \ No newline at end of file |
@@ -6,9 +6,9 @@ discard block |
||
| 6 | 6 | trait TrapDirectorTableOrder |
| 7 | 7 | { |
| 8 | 8 | /** @var array $order : (db column, 'ASC' | 'DESC') */ |
| 9 | - protected $order = array(); |
|
| 9 | + protected $order=array(); |
|
| 10 | 10 | /** @var string $orderQuery passed by GET */ |
| 11 | - protected $orderQuery = ''; |
|
| 11 | + protected $orderQuery=''; |
|
| 12 | 12 | |
| 13 | 13 | /** used var & functions of trapDirectorTable **/ |
| 14 | 14 | protected $query; |
@@ -26,16 +26,16 @@ discard block |
||
| 26 | 26 | { |
| 27 | 27 | if ($orderSQL != "") $orderSQL.=','; |
| 28 | 28 | |
| 29 | - $orderSQL .= $column . ' ' . $direction; |
|
| 29 | + $orderSQL.=$column.' '.$direction; |
|
| 30 | 30 | } |
| 31 | - $this->query = $this->query->order($orderSQL); |
|
| 31 | + $this->query=$this->query->order($orderSQL); |
|
| 32 | 32 | |
| 33 | 33 | return $this; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | public function setOrder(array $order) |
| 37 | 37 | { |
| 38 | - $this->order = $order; |
|
| 38 | + $this->order=$order; |
|
| 39 | 39 | return $this; |
| 40 | 40 | } |
| 41 | 41 | |
@@ -49,9 +49,9 @@ discard block |
||
| 49 | 49 | { |
| 50 | 50 | if (isset($getVars['o'])) |
| 51 | 51 | { |
| 52 | - $this->orderQuery = $getVars['o']; |
|
| 53 | - $match = array(); |
|
| 54 | - if (preg_match('/(.*)(ASC|DESC)$/', $this->orderQuery , $match)) |
|
| 52 | + $this->orderQuery=$getVars['o']; |
|
| 53 | + $match=array(); |
|
| 54 | + if (preg_match('/(.*)(ASC|DESC)$/', $this->orderQuery, $match)) |
|
| 55 | 55 | { |
| 56 | 56 | $orderArray=array($match[1] => $match[2]); |
| 57 | 57 | echo "$match[1] => $match[2]"; |
@@ -4,18 +4,18 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | class TrapModuleConfig |
| 6 | 6 | { |
| 7 | - /********** Database configuration ***********************/ |
|
| 7 | + /********** Database configuration ***********************/ |
|
| 8 | 8 | // Database prefix for tables |
| 9 | - protected $table_prefix; //< Database prefix for tables |
|
| 9 | + protected $table_prefix; //< Database prefix for tables |
|
| 10 | 10 | protected $DBConfigDefaults=array( |
| 11 | 11 | 'db_remove_days' => 60, // number of days before removing traps |
| 12 | 12 | 'log_destination' => 'syslog', // Log destination for trap handler |
| 13 | 13 | 'log_file' => '/tmp/trapdirector.log', // Log file |
| 14 | 14 | 'log_level' => 2, // log level |
| 15 | 15 | 'use_SnmpTrapAddess' => 1, // use SnmpTrapAddress by default |
| 16 | - 'SnmpTrapAddess_oid' => '.1.3.6.1.6.3.18.1.3', // default snmpTrapAdress OID |
|
| 17 | - 'max_rows_in_list' => 25, // Max rows displayed in table before paging |
|
| 18 | - 'handler_categories' => '0:Not categorized' // handlers categories : <index>:<name>!<index>:<name> .... |
|
| 16 | + 'SnmpTrapAddess_oid' => '.1.3.6.1.6.3.18.1.3', // default snmpTrapAdress OID |
|
| 17 | + 'max_rows_in_list' => 25, // Max rows displayed in table before paging |
|
| 18 | + 'handler_categories' => '0:Not categorized' // handlers categories : <index>:<name>!<index>:<name> .... |
|
| 19 | 19 | ); |
| 20 | 20 | // get default values for dbconfig |
| 21 | 21 | public function getDBConfigDefaults() { return $this->DBConfigDefaults;} |
@@ -122,27 +122,27 @@ discard block |
||
| 122 | 122 | // Note : must have 'source_ip' and 'last_sent' |
| 123 | 123 | public function getTrapHostListDisplayColumns() |
| 124 | 124 | { |
| 125 | - return array( |
|
| 126 | - 'source_name' => 't.source_name', |
|
| 127 | - 'source_ip' => 't.source_ip', |
|
| 128 | - 'trap_oid' => 't.trap_oid', |
|
| 129 | - 'count' => 'count(*)', |
|
| 130 | - 'last_sent' => 'UNIX_TIMESTAMP(max(t.date_received))' |
|
| 131 | - ); |
|
| 125 | + return array( |
|
| 126 | + 'source_name' => 't.source_name', |
|
| 127 | + 'source_ip' => 't.source_ip', |
|
| 128 | + 'trap_oid' => 't.trap_oid', |
|
| 129 | + 'count' => 'count(*)', |
|
| 130 | + 'last_sent' => 'UNIX_TIMESTAMP(max(t.date_received))' |
|
| 131 | + ); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | public function getTrapHostListSearchColumns() |
| 135 | 135 | { |
| 136 | - return array(); // No search needed on this table |
|
| 136 | + return array(); // No search needed on this table |
|
| 137 | 137 | } |
| 138 | 138 | // Titles display in Trap List table |
| 139 | 139 | public function getTrapHostListTitles() |
| 140 | 140 | { |
| 141 | - return array( |
|
| 142 | - 'trap_oid' => 'Trap OID', |
|
| 143 | - 'count' => 'Number of traps received', |
|
| 144 | - 'last_sent' => 'Last trap received' |
|
| 145 | - ); |
|
| 141 | + return array( |
|
| 142 | + 'trap_oid' => 'Trap OID', |
|
| 143 | + 'count' => 'Number of traps received', |
|
| 144 | + 'last_sent' => 'Last trap received' |
|
| 145 | + ); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | |
@@ -157,13 +157,13 @@ discard block |
||
| 157 | 157 | 'source_ip' => "CASE WHEN r.ip4 IS NULL THEN r.ip6 ELSE r.ip4 END", |
| 158 | 158 | 'trap_oid' => 'r.trap_oid', |
| 159 | 159 | 'rule' => 'r.rule', |
| 160 | - 'comment' => 'r.comment', |
|
| 161 | - 'category' => 'r.rule_type', |
|
| 160 | + 'comment' => 'r.comment', |
|
| 161 | + 'category' => 'r.rule_type', |
|
| 162 | 162 | 'action_match' => 'r.action_match', |
| 163 | 163 | 'action_nomatch'=> 'r.action_nomatch', |
| 164 | 164 | 'service_name' => 'r.service_name', |
| 165 | 165 | 'num_match' => 'r.num_match', |
| 166 | - 'rule_type' => 'r.rule_type', |
|
| 166 | + 'rule_type' => 'r.rule_type', |
|
| 167 | 167 | 'id' => 'r.id' |
| 168 | 168 | ); |
| 169 | 169 | } |
@@ -184,17 +184,17 @@ discard block |
||
| 184 | 184 | } |
| 185 | 185 | public function getHandlerColumns() |
| 186 | 186 | { |
| 187 | - return array( |
|
| 188 | - 'r.host_name', 'r.host_group_name', |
|
| 189 | - 'r.ip4', 'r.ip6', |
|
| 190 | - 'r.trap_oid', |
|
| 191 | - 'r.rule', |
|
| 192 | - 'r.action_match', |
|
| 193 | - 'r.action_nomatch', |
|
| 194 | - 'r.service_name', |
|
| 195 | - 'r.num_match', |
|
| 196 | - 'r.id' |
|
| 197 | - ); |
|
| 187 | + return array( |
|
| 188 | + 'r.host_name', 'r.host_group_name', |
|
| 189 | + 'r.ip4', 'r.ip6', |
|
| 190 | + 'r.trap_oid', |
|
| 191 | + 'r.rule', |
|
| 192 | + 'r.action_match', |
|
| 193 | + 'r.action_nomatch', |
|
| 194 | + 'r.service_name', |
|
| 195 | + 'r.num_match', |
|
| 196 | + 'r.id' |
|
| 197 | + ); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | // handler update (<key> => <sql select>) |
@@ -214,9 +214,9 @@ discard block |
||
| 214 | 214 | 'revert_ok' => 'r.revert_ok', |
| 215 | 215 | 'display' => 'r.display', |
| 216 | 216 | 'modified' => 'UNIX_TIMESTAMP(r.modified)', |
| 217 | - 'modifier' => 'r.modifier', |
|
| 218 | - 'comment' => 'r.comment', |
|
| 219 | - 'category' => 'r.rule_type' |
|
| 217 | + 'modifier' => 'r.modifier', |
|
| 218 | + 'comment' => 'r.comment', |
|
| 219 | + 'category' => 'r.rule_type' |
|
| 220 | 220 | ); |
| 221 | 221 | } |
| 222 | 222 | |
@@ -18,27 +18,27 @@ discard block |
||
| 18 | 18 | 'handler_categories' => '0:Not categorized' // handlers categories : <index>:<name>!<index>:<name> .... |
| 19 | 19 | ); |
| 20 | 20 | // get default values for dbconfig |
| 21 | - public function getDBConfigDefaults() { return $this->DBConfigDefaults;} |
|
| 21 | + public function getDBConfigDefaults() { return $this->DBConfigDefaults; } |
|
| 22 | 22 | /** Minimum DB version |
| 23 | 23 | * @return number |
| 24 | 24 | */ |
| 25 | - static public function getDbMinVersion() { return 2;} |
|
| 25 | + static public function getDbMinVersion() { return 2; } |
|
| 26 | 26 | /** Current DB version |
| 27 | 27 | * @return number |
| 28 | 28 | */ |
| 29 | - static public function getDbCurVersion() { return 2;} |
|
| 29 | + static public function getDbCurVersion() { return 2; } |
|
| 30 | 30 | |
| 31 | 31 | /************ Module configuration **********************/ |
| 32 | 32 | // Module base path |
| 33 | 33 | static public function urlPath() { return 'trapdirector'; } |
| 34 | - static public function getapiUserPermissions() { return array("status", "objects/query/Host", "objects/query/hostgroup", "objects/query/Service" , "actions/process-check-result"); } //< api user permissions required |
|
| 34 | + static public function getapiUserPermissions() { return array("status", "objects/query/Host", "objects/query/hostgroup", "objects/query/Service", "actions/process-check-result"); } //< api user permissions required |
|
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | /*********** Log configuration *************************/ |
| 38 | 38 | protected $logLevels=array(0=>'No output', 1=>'critical', 2=>'warning', 3=>'trace', 4=>'ALL'); |
| 39 | - public function getlogLevels() { return $this->logLevels;} |
|
| 40 | - protected $logDestinations=array('syslog'=>'syslog','file'=>'file','display'=>'display'); |
|
| 41 | - public function getLogDestinations() { return $this->logDestinations;} |
|
| 39 | + public function getlogLevels() { return $this->logLevels; } |
|
| 40 | + protected $logDestinations=array('syslog'=>'syslog', 'file'=>'file', 'display'=>'display'); |
|
| 41 | + public function getLogDestinations() { return $this->logDestinations; } |
|
| 42 | 42 | |
| 43 | 43 | function __construct($prefix) |
| 44 | 44 | { |
@@ -49,29 +49,29 @@ discard block |
||
| 49 | 49 | // DB table name of trap received list : prefix 't' |
| 50 | 50 | public function getTrapTableName() |
| 51 | 51 | { |
| 52 | - return array('t' => $this->table_prefix . 'received'); |
|
| 52 | + return array('t' => $this->table_prefix.'received'); |
|
| 53 | 53 | } |
| 54 | 54 | // DB table name of trap data list : prefix 'd' |
| 55 | 55 | public function getTrapDataTableName() |
| 56 | 56 | { |
| 57 | - return array('d' => $this->table_prefix . 'received_data'); |
|
| 57 | + return array('d' => $this->table_prefix.'received_data'); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | // DB table name of rules : prefix 'r' |
| 61 | 61 | public function getTrapRuleName() |
| 62 | 62 | { |
| 63 | - return array('r' => $this->table_prefix . 'rules'); |
|
| 63 | + return array('r' => $this->table_prefix.'rules'); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // DB table name of db config : prefix 'c' |
| 67 | 67 | public function getDbConfigTableName() |
| 68 | 68 | { |
| 69 | - return array('c' => $this->table_prefix . 'db_config'); |
|
| 69 | + return array('c' => $this->table_prefix.'db_config'); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | // Mib cache tables |
| 73 | - public function getMIBCacheTableName() { return $this->table_prefix . 'mib_cache'; } |
|
| 74 | - public function getMIBCacheTableTrapObjName() { return $this->table_prefix . 'mib_cache_trap_object'; } |
|
| 73 | + public function getMIBCacheTableName() { return $this->table_prefix.'mib_cache'; } |
|
| 74 | + public function getMIBCacheTableTrapObjName() { return $this->table_prefix.'mib_cache_trap_object'; } |
|
| 75 | 75 | |
| 76 | 76 | |
| 77 | 77 | /****************** Database queries *******************/ |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | public function getHandlerListDisplayColumns() |
| 153 | 153 | { |
| 154 | 154 | return array( |
| 155 | - 'host_name' => 'r.host_name',//'UNIX_TIMESTAMP(t.date_received)', |
|
| 155 | + 'host_name' => 'r.host_name', //'UNIX_TIMESTAMP(t.date_received)', |
|
| 156 | 156 | 'host_group_name'=> 'r.host_group_name', |
| 157 | 157 | 'source_ip' => "CASE WHEN r.ip4 IS NULL THEN r.ip6 ELSE r.ip4 END", |
| 158 | 158 | 'trap_oid' => 'r.trap_oid', |
@@ -224,32 +224,32 @@ discard block |
||
| 224 | 224 | public function trapDetailQuery() |
| 225 | 225 | { |
| 226 | 226 | return array( |
| 227 | - 'timestamp' => array('Date','UNIX_TIMESTAMP(t.date_received)'), |
|
| 228 | - 'source_ip' => array('Source IP','t.source_ip'), |
|
| 229 | - 'source_name' => array('Source name','t.source_name'), |
|
| 230 | - 'source_port' => array('Source port','t.source_port'), |
|
| 231 | - 'destination_ip' => array('Destination IP','t.destination_ip'), |
|
| 232 | - 'destination_port' => array('Destination port','t.destination_port'), |
|
| 233 | - 'trap_oid' => array('Numeric OID','t.trap_oid'), |
|
| 234 | - 'trap_name' => array('Trap name','t.trap_name'), |
|
| 235 | - 'trap_name_mib' => array('Trap MIB','t.trap_name_mib'), |
|
| 236 | - 'status' => array('Processing status','t.status'), |
|
| 237 | - 'status_detail' => array('Status details','t.status_detail'), |
|
| 238 | - 'process_time' => array('Trap processing time','t.process_time'), |
|
| 227 | + 'timestamp' => array('Date', 'UNIX_TIMESTAMP(t.date_received)'), |
|
| 228 | + 'source_ip' => array('Source IP', 't.source_ip'), |
|
| 229 | + 'source_name' => array('Source name', 't.source_name'), |
|
| 230 | + 'source_port' => array('Source port', 't.source_port'), |
|
| 231 | + 'destination_ip' => array('Destination IP', 't.destination_ip'), |
|
| 232 | + 'destination_port' => array('Destination port', 't.destination_port'), |
|
| 233 | + 'trap_oid' => array('Numeric OID', 't.trap_oid'), |
|
| 234 | + 'trap_name' => array('Trap name', 't.trap_name'), |
|
| 235 | + 'trap_name_mib' => array('Trap MIB', 't.trap_name_mib'), |
|
| 236 | + 'status' => array('Processing status', 't.status'), |
|
| 237 | + 'status_detail' => array('Status details', 't.status_detail'), |
|
| 238 | + 'process_time' => array('Trap processing time', 't.process_time'), |
|
| 239 | 239 | ); |
| 240 | 240 | } |
| 241 | 241 | // Trap detail : additional data (<key> => <title> <sql select>) |
| 242 | 242 | public function trapDataDetailQuery() |
| 243 | 243 | { |
| 244 | 244 | return array( |
| 245 | - 'oid' => array('Numeric OID','d.oid'), |
|
| 246 | - 'oid_name' => array('Text OID','d.oid_name'), |
|
| 247 | - 'oid_name_mib' => array('MIB','d.oid_name_mib'), |
|
| 248 | - 'value' => array('Value','d.value'), |
|
| 245 | + 'oid' => array('Numeric OID', 'd.oid'), |
|
| 246 | + 'oid_name' => array('Text OID', 'd.oid_name'), |
|
| 247 | + 'oid_name_mib' => array('MIB', 'd.oid_name_mib'), |
|
| 248 | + 'value' => array('Value', 'd.value'), |
|
| 249 | 249 | ); |
| 250 | 250 | } |
| 251 | 251 | // foreign key of trap data table |
| 252 | - public function trapDataFK() { return 'trap_id';} |
|
| 252 | + public function trapDataFK() { return 'trap_id'; } |
|
| 253 | 253 | |
| 254 | 254 | // Max items in a list OBSOLETE TODO : remove after all tables moved to trapdirectorTable |
| 255 | 255 | public function itemListDisplay() { return 25; } |
@@ -7,86 +7,86 @@ |
||
| 7 | 7 | { |
| 8 | 8 | |
| 9 | 9 | |
| 10 | - /*************** Grouping ************/ |
|
| 10 | + /*************** Grouping ************/ |
|
| 11 | 11 | |
| 12 | - /** @var boolean $grouppingActive set to true if grouping is active by query or function call */ |
|
| 13 | - protected $grouppingActive=false; |
|
| 12 | + /** @var boolean $grouppingActive set to true if grouping is active by query or function call */ |
|
| 13 | + protected $grouppingActive=false; |
|
| 14 | 14 | |
| 15 | - /** @var string $groupingColumn Name of column (can be hidden) for grouping */ |
|
| 16 | - protected $groupingColumn=''; |
|
| 15 | + /** @var string $groupingColumn Name of column (can be hidden) for grouping */ |
|
| 16 | + protected $groupingColumn=''; |
|
| 17 | 17 | |
| 18 | - /**@var string $groupingVal Current value of grouping column in row (used while rendering) */ |
|
| 19 | - protected $groupingVal=''; |
|
| 18 | + /**@var string $groupingVal Current value of grouping column in row (used while rendering) */ |
|
| 19 | + protected $groupingVal=''; |
|
| 20 | 20 | |
| 21 | - /** @var integer $groupingColSpan colspan of grouping line : set to table titles in init */ |
|
| 22 | - protected $groupingColSpan=1; |
|
| 21 | + /** @var integer $groupingColSpan colspan of grouping line : set to table titles in init */ |
|
| 22 | + protected $groupingColSpan=1; |
|
| 23 | 23 | |
| 24 | - /***************** Grouping ****************/ |
|
| 24 | + /***************** Grouping ****************/ |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Set grouping. column must be DB name |
|
| 28 | - * @param string $columnDBName |
|
| 29 | - */ |
|
| 30 | - public function setGrouping(string $columnDBName) |
|
| 31 | - { |
|
| 32 | - $this->groupingColumn = $columnDBName; |
|
| 33 | - $this->grouppingActive = TRUE; |
|
| 34 | - } |
|
| 26 | + /** |
|
| 27 | + * Set grouping. column must be DB name |
|
| 28 | + * @param string $columnDBName |
|
| 29 | + */ |
|
| 30 | + public function setGrouping(string $columnDBName) |
|
| 31 | + { |
|
| 32 | + $this->groupingColumn = $columnDBName; |
|
| 33 | + $this->grouppingActive = TRUE; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Init of grouping before rendering |
|
| 38 | - */ |
|
| 39 | - public function initGrouping() |
|
| 40 | - { |
|
| 41 | - $this->groupingVal = ''; |
|
| 42 | - $this->groupingColSpan = count($this->titles); |
|
| 43 | - } |
|
| 36 | + /** |
|
| 37 | + * Init of grouping before rendering |
|
| 38 | + */ |
|
| 39 | + public function initGrouping() |
|
| 40 | + { |
|
| 41 | + $this->groupingVal = ''; |
|
| 42 | + $this->groupingColSpan = count($this->titles); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Function to print grouping value (for ovveride in specific tables) |
|
| 47 | - * @param string $value |
|
| 48 | - * @return string |
|
| 49 | - */ |
|
| 50 | - public function groupingPrintData( string $value ) |
|
| 51 | - { |
|
| 52 | - $html = "$value"; |
|
| 53 | - return $html; |
|
| 54 | - } |
|
| 45 | + /** |
|
| 46 | + * Function to print grouping value (for ovveride in specific tables) |
|
| 47 | + * @param string $value |
|
| 48 | + * @return string |
|
| 49 | + */ |
|
| 50 | + public function groupingPrintData( string $value ) |
|
| 51 | + { |
|
| 52 | + $html = "$value"; |
|
| 53 | + return $html; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * When to display new grouping line (for ovveride in specific tables) |
|
| 58 | - * @param string $val1 Current value in grouping |
|
| 59 | - * @param string $val2 Value of current line |
|
| 60 | - * @return boolean TRUE if a new grouping line is needed. |
|
| 61 | - */ |
|
| 62 | - public function groupingEvalNext(string $val1, string $val2) |
|
| 63 | - { |
|
| 64 | - if ($val1 != $val2) |
|
| 65 | - return TRUE; |
|
| 66 | - else |
|
| 67 | - return FALSE; |
|
| 68 | - } |
|
| 56 | + /** |
|
| 57 | + * When to display new grouping line (for ovveride in specific tables) |
|
| 58 | + * @param string $val1 Current value in grouping |
|
| 59 | + * @param string $val2 Value of current line |
|
| 60 | + * @return boolean TRUE if a new grouping line is needed. |
|
| 61 | + */ |
|
| 62 | + public function groupingEvalNext(string $val1, string $val2) |
|
| 63 | + { |
|
| 64 | + if ($val1 != $val2) |
|
| 65 | + return TRUE; |
|
| 66 | + else |
|
| 67 | + return FALSE; |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * Called before each line to check if grouping line is needed. |
|
| 72 | - * @param mixed $values |
|
| 73 | - * @return string with line or empty. |
|
| 74 | - */ |
|
| 75 | - public function groupingNextLine( $values) |
|
| 76 | - { |
|
| 77 | - if ($this->grouppingActive === FALSE) return ''; |
|
| 70 | + /** |
|
| 71 | + * Called before each line to check if grouping line is needed. |
|
| 72 | + * @param mixed $values |
|
| 73 | + * @return string with line or empty. |
|
| 74 | + */ |
|
| 75 | + public function groupingNextLine( $values) |
|
| 76 | + { |
|
| 77 | + if ($this->grouppingActive === FALSE) return ''; |
|
| 78 | 78 | |
| 79 | - $dbcol = $this->groupingColumn; |
|
| 80 | - $dbVal = $values->$dbcol; |
|
| 81 | - if ( $dbVal === NULL ) $dbVal = '0'; // Set default to 0 |
|
| 82 | - if ($this->groupingVal == '' || $this->groupingEvalNext($this->groupingVal ,$dbVal) === TRUE ) |
|
| 83 | - { |
|
| 84 | - $this->groupingVal = $dbVal; |
|
| 85 | - $html = '<tr><th colspan="'. $this->groupingColSpan .'">'. $this->groupingPrintData($this->groupingVal) .'</th></tr>'; |
|
| 86 | - return $html; |
|
| 87 | - } |
|
| 88 | - return ''; |
|
| 79 | + $dbcol = $this->groupingColumn; |
|
| 80 | + $dbVal = $values->$dbcol; |
|
| 81 | + if ( $dbVal === NULL ) $dbVal = '0'; // Set default to 0 |
|
| 82 | + if ($this->groupingVal == '' || $this->groupingEvalNext($this->groupingVal ,$dbVal) === TRUE ) |
|
| 83 | + { |
|
| 84 | + $this->groupingVal = $dbVal; |
|
| 85 | + $html = '<tr><th colspan="'. $this->groupingColSpan .'">'. $this->groupingPrintData($this->groupingVal) .'</th></tr>'; |
|
| 86 | + return $html; |
|
| 87 | + } |
|
| 88 | + return ''; |
|
| 89 | 89 | |
| 90 | - } |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | 92 | } |
@@ -29,8 +29,8 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | public function setGrouping(string $columnDBName) |
| 31 | 31 | { |
| 32 | - $this->groupingColumn = $columnDBName; |
|
| 33 | - $this->grouppingActive = TRUE; |
|
| 32 | + $this->groupingColumn=$columnDBName; |
|
| 33 | + $this->grouppingActive=TRUE; |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -38,8 +38,8 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public function initGrouping() |
| 40 | 40 | { |
| 41 | - $this->groupingVal = ''; |
|
| 42 | - $this->groupingColSpan = count($this->titles); |
|
| 41 | + $this->groupingVal=''; |
|
| 42 | + $this->groupingColSpan=count($this->titles); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -47,9 +47,9 @@ discard block |
||
| 47 | 47 | * @param string $value |
| 48 | 48 | * @return string |
| 49 | 49 | */ |
| 50 | - public function groupingPrintData( string $value ) |
|
| 50 | + public function groupingPrintData(string $value) |
|
| 51 | 51 | { |
| 52 | - $html = "$value"; |
|
| 52 | + $html="$value"; |
|
| 53 | 53 | return $html; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -72,17 +72,17 @@ discard block |
||
| 72 | 72 | * @param mixed $values |
| 73 | 73 | * @return string with line or empty. |
| 74 | 74 | */ |
| 75 | - public function groupingNextLine( $values) |
|
| 75 | + public function groupingNextLine($values) |
|
| 76 | 76 | { |
| 77 | 77 | if ($this->grouppingActive === FALSE) return ''; |
| 78 | 78 | |
| 79 | - $dbcol = $this->groupingColumn; |
|
| 80 | - $dbVal = $values->$dbcol; |
|
| 81 | - if ( $dbVal === NULL ) $dbVal = '0'; // Set default to 0 |
|
| 82 | - if ($this->groupingVal == '' || $this->groupingEvalNext($this->groupingVal ,$dbVal) === TRUE ) |
|
| 79 | + $dbcol=$this->groupingColumn; |
|
| 80 | + $dbVal=$values->$dbcol; |
|
| 81 | + if ($dbVal === NULL) $dbVal='0'; // Set default to 0 |
|
| 82 | + if ($this->groupingVal == '' || $this->groupingEvalNext($this->groupingVal, $dbVal) === TRUE) |
|
| 83 | 83 | { |
| 84 | - $this->groupingVal = $dbVal; |
|
| 85 | - $html = '<tr><th colspan="'. $this->groupingColSpan .'">'. $this->groupingPrintData($this->groupingVal) .'</th></tr>'; |
|
| 84 | + $this->groupingVal=$dbVal; |
|
| 85 | + $html='<tr><th colspan="'.$this->groupingColSpan.'">'.$this->groupingPrintData($this->groupingVal).'</th></tr>'; |
|
| 86 | 86 | return $html; |
| 87 | 87 | } |
| 88 | 88 | return ''; |
@@ -61,10 +61,11 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | public function groupingEvalNext(string $val1, string $val2) |
| 63 | 63 | { |
| 64 | - if ($val1 != $val2) |
|
| 65 | - return TRUE; |
|
| 66 | - else |
|
| 67 | - return FALSE; |
|
| 64 | + if ($val1 != $val2) { |
|
| 65 | + return TRUE; |
|
| 66 | + } else { |
|
| 67 | + return FALSE; |
|
| 68 | + } |
|
| 68 | 69 | } |
| 69 | 70 | |
| 70 | 71 | /** |
@@ -74,11 +75,16 @@ discard block |
||
| 74 | 75 | */ |
| 75 | 76 | public function groupingNextLine( $values) |
| 76 | 77 | { |
| 77 | - if ($this->grouppingActive === FALSE) return ''; |
|
| 78 | + if ($this->grouppingActive === FALSE) { |
|
| 79 | + return ''; |
|
| 80 | + } |
|
| 78 | 81 | |
| 79 | 82 | $dbcol = $this->groupingColumn; |
| 80 | 83 | $dbVal = $values->$dbcol; |
| 81 | - if ( $dbVal === NULL ) $dbVal = '0'; // Set default to 0 |
|
| 84 | + if ( $dbVal === NULL ) { |
|
| 85 | + $dbVal = '0'; |
|
| 86 | + } |
|
| 87 | + // Set default to 0 |
|
| 82 | 88 | if ($this->groupingVal == '' || $this->groupingEvalNext($this->groupingVal ,$dbVal) === TRUE ) |
| 83 | 89 | { |
| 84 | 90 | $this->groupingVal = $dbVal; |
@@ -22,7 +22,9 @@ discard block |
||
| 22 | 22 | try |
| 23 | 23 | { |
| 24 | 24 | $dbConn = $this->getUIDatabase()->getDbConn(); |
| 25 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 25 | + if ($dbConn === null) { |
|
| 26 | + throw new \ErrorException('uncatched db error'); |
|
| 27 | + } |
|
| 26 | 28 | $query = $dbConn->select()->from( |
| 27 | 29 | $this->getModuleConfig()->getTrapTableName(), |
| 28 | 30 | array('COUNT(*)') |
@@ -41,8 +43,7 @@ discard block |
||
| 41 | 43 | |
| 42 | 44 | $this->view->trap_days_delete=$this->getUIDatabase()->getDBConfigValue('db_remove_days'); |
| 43 | 45 | |
| 44 | - } |
|
| 45 | - catch (Exception $e) |
|
| 46 | + } catch (Exception $e) |
|
| 46 | 47 | { |
| 47 | 48 | $this->displayExitError('status',$e->getMessage()); |
| 48 | 49 | } |
@@ -56,8 +57,7 @@ discard block |
||
| 56 | 57 | $this->view->currentLogFile=$this->getUIDatabase()->getDBConfigValue('log_file'); |
| 57 | 58 | $this->view->logLevels=$this->getModuleConfig()->getlogLevels(); |
| 58 | 59 | $this->view->currentLogLevel=$this->getUIDatabase()->getDBConfigValue('log_level'); |
| 59 | - } |
|
| 60 | - catch (Exception $e) |
|
| 60 | + } catch (Exception $e) |
|
| 61 | 61 | { |
| 62 | 62 | $this->displayExitError('status',$e->getMessage()); |
| 63 | 63 | } |
@@ -69,8 +69,7 @@ discard block |
||
| 69 | 69 | $this->view->SnmpTrapAddressOID=$this->getUIDatabase()->getDBConfigValue('SnmpTrapAddess_oid'); |
| 70 | 70 | $this->view->SnmpTrapAddressOIDDefault = ($this->view->SnmpTrapAddressOID == $this->getModuleConfig()->getDBConfigDefaults()['SnmpTrapAddess_oid'] ) ? TRUE : FALSE; |
| 71 | 71 | |
| 72 | - } |
|
| 73 | - catch (Exception $e) |
|
| 72 | + } catch (Exception $e) |
|
| 74 | 73 | { |
| 75 | 74 | $this->displayExitError('status',$e->getMessage()); |
| 76 | 75 | } |
@@ -120,8 +119,7 @@ discard block |
||
| 120 | 119 | if ($retVal == 0) |
| 121 | 120 | { // process is alive |
| 122 | 121 | $this->_helper->json(array('status'=>'Alive and kicking')); |
| 123 | - } |
|
| 124 | - else |
|
| 122 | + } else |
|
| 125 | 123 | { // process is dead |
| 126 | 124 | $this->_helper->json(array('status'=>'tu quoque fili','err'=>'no proc'.$pid)); |
| 127 | 125 | } |
@@ -137,22 +135,19 @@ discard block |
||
| 137 | 135 | if (!is_dir($destDir)) |
| 138 | 136 | { |
| 139 | 137 | $this->view->uploadStatus="ERROR : no $destDir directory, check module configuration"; |
| 140 | - } |
|
| 141 | - else |
|
| 138 | + } else |
|
| 142 | 139 | { |
| 143 | 140 | if (!is_writable($destDir)) |
| 144 | 141 | { |
| 145 | 142 | $this->view->uploadStatus="ERROR : $destDir directory is not writable"; |
| 146 | - } |
|
| 147 | - else |
|
| 143 | + } else |
|
| 148 | 144 | { |
| 149 | 145 | $destination = $destDir .'/'.$name; //$this->Module()->getBaseDir() . "/mibs/$name"; |
| 150 | 146 | $sourceTmpNam=filter_var($_FILES['mibfile']['tmp_name'],FILTER_SANITIZE_STRING); |
| 151 | 147 | if (move_uploaded_file($sourceTmpNam,$destination)===false) |
| 152 | 148 | { |
| 153 | 149 | $this->view->uploadStatus="ERROR, file $destination not loaded. Check file and path name or selinux violations"; |
| 154 | - } |
|
| 155 | - else |
|
| 150 | + } else |
|
| 156 | 151 | { |
| 157 | 152 | $this->view->uploadStatus="File $name uploaded in $destDir"; |
| 158 | 153 | } |
@@ -177,18 +172,15 @@ discard block |
||
| 177 | 172 | { |
| 178 | 173 | $this->view->snmptranslate='works fine'; |
| 179 | 174 | $this->view->snmptranslate_state='ok'; |
| 180 | - } |
|
| 181 | - else |
|
| 175 | + } else |
|
| 182 | 176 | { |
| 183 | 177 | $this->view->snmptranslate='works fine but missing basic MIBs'; |
| 184 | 178 | } |
| 185 | - } |
|
| 186 | - else |
|
| 179 | + } else |
|
| 187 | 180 | { |
| 188 | 181 | $this->view->snmptranslate='Can execute but no OID to name resolution'; |
| 189 | 182 | } |
| 190 | - } |
|
| 191 | - else |
|
| 183 | + } else |
|
| 192 | 184 | { |
| 193 | 185 | $this->view->snmptranslate='Cannot execute'; |
| 194 | 186 | } |
@@ -209,15 +201,13 @@ discard block |
||
| 209 | 201 | if ($retVal==0) |
| 210 | 202 | { |
| 211 | 203 | $dirArray=array_merge($dirArray,explode(':',$sysDirs)); |
| 212 | - } |
|
| 213 | - else |
|
| 204 | + } else |
|
| 214 | 205 | { |
| 215 | 206 | $translateOut=exec($this->Config()->get('config', 'snmptranslate') . ' -Dinit_mib .1.3 2>&1 | grep MIBDIRS'); |
| 216 | 207 | if (preg_match('/MIBDIRS.*\'([^\']+)\'/',$translateOut,$matches)) |
| 217 | 208 | { |
| 218 | 209 | $dirArray=array_merge($dirArray,explode(':',$matches[1])); |
| 219 | - } |
|
| 220 | - else |
|
| 210 | + } else |
|
| 221 | 211 | { |
| 222 | 212 | array_push($dirArray,'Install net-snmp-config to see system directories'); |
| 223 | 213 | } |
@@ -256,8 +246,7 @@ discard block |
||
| 256 | 246 | if (!preg_match('/^[0-9]+$/', $maxRows) || $maxRows < 1) |
| 257 | 247 | { |
| 258 | 248 | $this->view->setError='Max rows must be a number'; |
| 259 | - } |
|
| 260 | - else |
|
| 249 | + } else |
|
| 261 | 250 | { |
| 262 | 251 | $this->setitemListDisplay($maxRows); |
| 263 | 252 | $this->view->setOKMsg='Set max rows to ' . $maxRows; |
@@ -276,8 +265,9 @@ discard block |
||
| 276 | 265 | $index = $this->getRequest()->getPost('index',NULL); |
| 277 | 266 | $newname = $this->getRequest()->getPost('newname',NULL); |
| 278 | 267 | |
| 279 | - if (!preg_match('/^[0-9]+$/', $index) || $index < 1) |
|
| 280 | - $this->_helper->json(array('status'=>'Bad index')); |
|
| 268 | + if (!preg_match('/^[0-9]+$/', $index) || $index < 1) { |
|
| 269 | + $this->_helper->json(array('status'=>'Bad index')); |
|
| 270 | + } |
|
| 281 | 271 | |
| 282 | 272 | switch ($type) |
| 283 | 273 | { |
@@ -21,8 +21,8 @@ discard block |
||
| 21 | 21 | /************ Trapdb ***********/ |
| 22 | 22 | try |
| 23 | 23 | { |
| 24 | - $dbConn = $this->getUIDatabase()->getDbConn(); |
|
| 25 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 24 | + $dbConn = $this->getUIDatabase()->getDbConn(); |
|
| 25 | + if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 26 | 26 | $query = $dbConn->select()->from( |
| 27 | 27 | $this->getModuleConfig()->getTrapTableName(), |
| 28 | 28 | array('COUNT(*)') |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | try |
| 53 | 53 | { |
| 54 | - $this->view->currentLogDestination=$this->getUIDatabase()->getDBConfigValue('log_destination'); |
|
| 54 | + $this->view->currentLogDestination=$this->getUIDatabase()->getDBConfigValue('log_destination'); |
|
| 55 | 55 | $this->view->logDestinations=$this->getModuleConfig()->getLogDestinations(); |
| 56 | 56 | $this->view->currentLogFile=$this->getUIDatabase()->getDBConfigValue('log_file'); |
| 57 | 57 | $this->view->logLevels=$this->getModuleConfig()->getlogLevels(); |
@@ -65,23 +65,23 @@ discard block |
||
| 65 | 65 | /*************** SNMP configuration ****************/ |
| 66 | 66 | try |
| 67 | 67 | { |
| 68 | - $this->view->useSnmpTrapAddess= ( $this->getUIDatabase()->getDBConfigValue('use_SnmpTrapAddess') == 1 ) ? TRUE : FALSE; |
|
| 69 | - $this->view->SnmpTrapAddressOID=$this->getUIDatabase()->getDBConfigValue('SnmpTrapAddess_oid'); |
|
| 70 | - $this->view->SnmpTrapAddressOIDDefault = ($this->view->SnmpTrapAddressOID == $this->getModuleConfig()->getDBConfigDefaults()['SnmpTrapAddess_oid'] ) ? TRUE : FALSE; |
|
| 68 | + $this->view->useSnmpTrapAddess= ( $this->getUIDatabase()->getDBConfigValue('use_SnmpTrapAddess') == 1 ) ? TRUE : FALSE; |
|
| 69 | + $this->view->SnmpTrapAddressOID=$this->getUIDatabase()->getDBConfigValue('SnmpTrapAddess_oid'); |
|
| 70 | + $this->view->SnmpTrapAddressOIDDefault = ($this->view->SnmpTrapAddressOID == $this->getModuleConfig()->getDBConfigDefaults()['SnmpTrapAddess_oid'] ) ? TRUE : FALSE; |
|
| 71 | 71 | |
| 72 | 72 | } |
| 73 | 73 | catch (Exception $e) |
| 74 | 74 | { |
| 75 | - $this->displayExitError('status',$e->getMessage()); |
|
| 75 | + $this->displayExitError('status',$e->getMessage()); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** Mib management |
| 81 | - * Post param : action=update_mib_db : update mib database |
|
| 82 | - * Post param : ation=check_update : check if mib update is finished |
|
| 83 | - * File post : mibfile -> save mib file |
|
| 84 | - */ |
|
| 81 | + * Post param : action=update_mib_db : update mib database |
|
| 82 | + * Post param : ation=check_update : check if mib update is finished |
|
| 83 | + * File post : mibfile -> save mib file |
|
| 84 | + */ |
|
| 85 | 85 | public function mibAction() |
| 86 | 86 | { |
| 87 | 87 | $this->prepareTabs()->activate('mib'); |
@@ -100,22 +100,22 @@ discard block |
||
| 100 | 100 | $return=exec('icingacli trapdirector mib update --pid /tmp/trapdirector_update.pid'); |
| 101 | 101 | if (preg_match('/OK/',$return)) |
| 102 | 102 | { |
| 103 | - $this->_helper->json(array('status'=>'OK')); |
|
| 103 | + $this->_helper->json(array('status'=>'OK')); |
|
| 104 | 104 | } |
| 105 | 105 | // Error |
| 106 | 106 | $this->_helper->json(array('status'=>$return)); |
| 107 | 107 | } |
| 108 | 108 | if ($action == 'check_update') |
| 109 | 109 | { |
| 110 | - $file=@fopen('/tmp/trapdirector_update.pid','r'); |
|
| 111 | - if ($file == false) |
|
| 112 | - { // process is dead |
|
| 113 | - $this->_helper->json(array('status'=>'tu quoque fili','err'=>'Cannot open file')); |
|
| 114 | - return; |
|
| 115 | - } |
|
| 116 | - $pid=fgets($file); |
|
| 117 | - $output=array(); |
|
| 118 | - $retVal=0; |
|
| 110 | + $file=@fopen('/tmp/trapdirector_update.pid','r'); |
|
| 111 | + if ($file == false) |
|
| 112 | + { // process is dead |
|
| 113 | + $this->_helper->json(array('status'=>'tu quoque fili','err'=>'Cannot open file')); |
|
| 114 | + return; |
|
| 115 | + } |
|
| 116 | + $pid=fgets($file); |
|
| 117 | + $output=array(); |
|
| 118 | + $retVal=0; |
|
| 119 | 119 | exec('ps '.$pid,$output,$retVal); |
| 120 | 120 | if ($retVal == 0) |
| 121 | 121 | { // process is alive |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | else |
| 125 | 125 | { // process is dead |
| 126 | - $this->_helper->json(array('status'=>'tu quoque fili','err'=>'no proc'.$pid)); |
|
| 126 | + $this->_helper->json(array('status'=>'tu quoque fili','err'=>'no proc'.$pid)); |
|
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | $this->_helper->json(array('status'=>'ERR : no '.$action.' action possible' )); |
@@ -131,32 +131,32 @@ discard block |
||
| 131 | 131 | /** Check for mib file UPLOAD */ |
| 132 | 132 | if (isset($_FILES['mibfile'])) |
| 133 | 133 | { |
| 134 | - $name=filter_var($_FILES['mibfile']['name'],FILTER_SANITIZE_STRING); |
|
| 134 | + $name=filter_var($_FILES['mibfile']['name'],FILTER_SANITIZE_STRING); |
|
| 135 | 135 | $DirConf=explode(':',$this->Config()->get('config', 'snmptranslate_dirs')); |
| 136 | 136 | $destDir=array_shift($DirConf); |
| 137 | 137 | if (!is_dir($destDir)) |
| 138 | 138 | { |
| 139 | - $this->view->uploadStatus="ERROR : no $destDir directory, check module configuration"; |
|
| 139 | + $this->view->uploadStatus="ERROR : no $destDir directory, check module configuration"; |
|
| 140 | 140 | } |
| 141 | 141 | else |
| 142 | 142 | { |
| 143 | - if (!is_writable($destDir)) |
|
| 144 | - { |
|
| 145 | - $this->view->uploadStatus="ERROR : $destDir directory is not writable"; |
|
| 146 | - } |
|
| 147 | - else |
|
| 148 | - { |
|
| 149 | - $destination = $destDir .'/'.$name; //$this->Module()->getBaseDir() . "/mibs/$name"; |
|
| 150 | - $sourceTmpNam=filter_var($_FILES['mibfile']['tmp_name'],FILTER_SANITIZE_STRING); |
|
| 151 | - if (move_uploaded_file($sourceTmpNam,$destination)===false) |
|
| 152 | - { |
|
| 153 | - $this->view->uploadStatus="ERROR, file $destination not loaded. Check file and path name or selinux violations"; |
|
| 154 | - } |
|
| 155 | - else |
|
| 156 | - { |
|
| 157 | - $this->view->uploadStatus="File $name uploaded in $destDir"; |
|
| 158 | - } |
|
| 159 | - } |
|
| 143 | + if (!is_writable($destDir)) |
|
| 144 | + { |
|
| 145 | + $this->view->uploadStatus="ERROR : $destDir directory is not writable"; |
|
| 146 | + } |
|
| 147 | + else |
|
| 148 | + { |
|
| 149 | + $destination = $destDir .'/'.$name; //$this->Module()->getBaseDir() . "/mibs/$name"; |
|
| 150 | + $sourceTmpNam=filter_var($_FILES['mibfile']['tmp_name'],FILTER_SANITIZE_STRING); |
|
| 151 | + if (move_uploaded_file($sourceTmpNam,$destination)===false) |
|
| 152 | + { |
|
| 153 | + $this->view->uploadStatus="ERROR, file $destination not loaded. Check file and path name or selinux violations"; |
|
| 154 | + } |
|
| 155 | + else |
|
| 156 | + { |
|
| 157 | + $this->view->uploadStatus="File $name uploaded in $destDir"; |
|
| 158 | + } |
|
| 159 | + } |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | } |
@@ -172,16 +172,16 @@ discard block |
||
| 172 | 172 | $translate=exec($snmptranslate . ' 1'); |
| 173 | 173 | if (preg_match('/iso/',$translate)) |
| 174 | 174 | { |
| 175 | - $translate=exec($snmptranslate . ' 1.3.6.1.4'); |
|
| 176 | - if (preg_match('/private/',$translate)) |
|
| 177 | - { |
|
| 178 | - $this->view->snmptranslate='works fine'; |
|
| 179 | - $this->view->snmptranslate_state='ok'; |
|
| 180 | - } |
|
| 181 | - else |
|
| 182 | - { |
|
| 183 | - $this->view->snmptranslate='works fine but missing basic MIBs'; |
|
| 184 | - } |
|
| 175 | + $translate=exec($snmptranslate . ' 1.3.6.1.4'); |
|
| 176 | + if (preg_match('/private/',$translate)) |
|
| 177 | + { |
|
| 178 | + $this->view->snmptranslate='works fine'; |
|
| 179 | + $this->view->snmptranslate_state='ok'; |
|
| 180 | + } |
|
| 181 | + else |
|
| 182 | + { |
|
| 183 | + $this->view->snmptranslate='works fine but missing basic MIBs'; |
|
| 184 | + } |
|
| 185 | 185 | } |
| 186 | 186 | else |
| 187 | 187 | { |
@@ -244,63 +244,63 @@ discard block |
||
| 244 | 244 | /** UI options */ |
| 245 | 245 | public function uimgtAction() |
| 246 | 246 | { |
| 247 | - $this->prepareTabs()->activate('uimgt'); |
|
| 247 | + $this->prepareTabs()->activate('uimgt'); |
|
| 248 | 248 | |
| 249 | - $this->view->setError=''; |
|
| 250 | - $this->view->setOKMsg=''; |
|
| 249 | + $this->view->setError=''; |
|
| 250 | + $this->view->setOKMsg=''; |
|
| 251 | 251 | |
| 252 | - //max_rows=25&row_update=update |
|
| 253 | - if ( $this->getRequest()->getParam('max_rows',NULL) !== NULL ) |
|
| 254 | - { |
|
| 255 | - $maxRows = $this->getRequest()->getParam('max_rows'); |
|
| 256 | - if (!preg_match('/^[0-9]+$/', $maxRows) || $maxRows < 1) |
|
| 257 | - { |
|
| 258 | - $this->view->setError='Max rows must be a number'; |
|
| 259 | - } |
|
| 260 | - else |
|
| 261 | - { |
|
| 262 | - $this->setitemListDisplay($maxRows); |
|
| 263 | - $this->view->setOKMsg='Set max rows to ' . $maxRows; |
|
| 264 | - } |
|
| 265 | - } |
|
| 252 | + //max_rows=25&row_update=update |
|
| 253 | + if ( $this->getRequest()->getParam('max_rows',NULL) !== NULL ) |
|
| 254 | + { |
|
| 255 | + $maxRows = $this->getRequest()->getParam('max_rows'); |
|
| 256 | + if (!preg_match('/^[0-9]+$/', $maxRows) || $maxRows < 1) |
|
| 257 | + { |
|
| 258 | + $this->view->setError='Max rows must be a number'; |
|
| 259 | + } |
|
| 260 | + else |
|
| 261 | + { |
|
| 262 | + $this->setitemListDisplay($maxRows); |
|
| 263 | + $this->view->setOKMsg='Set max rows to ' . $maxRows; |
|
| 264 | + } |
|
| 265 | + } |
|
| 266 | 266 | |
| 267 | - if ( $this->getRequest()->getParam('add_category',NULL) !== NULL ) |
|
| 268 | - { |
|
| 269 | - $addCat = $this->getRequest()->getParam('add_category'); |
|
| 270 | - $this->addHandlersCategory($addCat); |
|
| 271 | - } |
|
| 267 | + if ( $this->getRequest()->getParam('add_category',NULL) !== NULL ) |
|
| 268 | + { |
|
| 269 | + $addCat = $this->getRequest()->getParam('add_category'); |
|
| 270 | + $this->addHandlersCategory($addCat); |
|
| 271 | + } |
|
| 272 | 272 | |
| 273 | - if ( $this->getRequest()->getPost('type',NULL) !== NULL ) |
|
| 274 | - { |
|
| 275 | - $type = $this->getRequest()->getPost('type',NULL); |
|
| 276 | - $index = $this->getRequest()->getPost('index',NULL); |
|
| 277 | - $newname = $this->getRequest()->getPost('newname',NULL); |
|
| 273 | + if ( $this->getRequest()->getPost('type',NULL) !== NULL ) |
|
| 274 | + { |
|
| 275 | + $type = $this->getRequest()->getPost('type',NULL); |
|
| 276 | + $index = $this->getRequest()->getPost('index',NULL); |
|
| 277 | + $newname = $this->getRequest()->getPost('newname',NULL); |
|
| 278 | 278 | |
| 279 | - if (!preg_match('/^[0-9]+$/', $index) || $index < 1) |
|
| 280 | - $this->_helper->json(array('status'=>'Bad index')); |
|
| 279 | + if (!preg_match('/^[0-9]+$/', $index) || $index < 1) |
|
| 280 | + $this->_helper->json(array('status'=>'Bad index')); |
|
| 281 | 281 | |
| 282 | - switch ($type) |
|
| 283 | - { |
|
| 284 | - case 'delete': |
|
| 285 | - $this->delHandlersCategory($index); |
|
| 286 | - $this->_helper->json(array('status'=>'OK')); |
|
| 287 | - return; |
|
| 288 | - break; |
|
| 289 | - case 'rename': |
|
| 290 | - $this->renameHandlersCategory($index, $newname); |
|
| 291 | - $this->_helper->json(array('status'=>'OK')); |
|
| 292 | - return; |
|
| 293 | - break; |
|
| 294 | - default: |
|
| 295 | - $this->_helper->json(array('status'=>'Unknwon command')); |
|
| 296 | - return; |
|
| 297 | - break; |
|
| 298 | - } |
|
| 299 | - } |
|
| 282 | + switch ($type) |
|
| 283 | + { |
|
| 284 | + case 'delete': |
|
| 285 | + $this->delHandlersCategory($index); |
|
| 286 | + $this->_helper->json(array('status'=>'OK')); |
|
| 287 | + return; |
|
| 288 | + break; |
|
| 289 | + case 'rename': |
|
| 290 | + $this->renameHandlersCategory($index, $newname); |
|
| 291 | + $this->_helper->json(array('status'=>'OK')); |
|
| 292 | + return; |
|
| 293 | + break; |
|
| 294 | + default: |
|
| 295 | + $this->_helper->json(array('status'=>'Unknwon command')); |
|
| 296 | + return; |
|
| 297 | + break; |
|
| 298 | + } |
|
| 299 | + } |
|
| 300 | 300 | |
| 301 | - $this->view->maxRows = $this->itemListDisplay(); |
|
| 301 | + $this->view->maxRows = $this->itemListDisplay(); |
|
| 302 | 302 | |
| 303 | - $this->view->categories = $this->getHandlersCategory(); |
|
| 303 | + $this->view->categories = $this->getHandlersCategory(); |
|
| 304 | 304 | |
| 305 | 305 | |
| 306 | 306 | |
@@ -349,47 +349,47 @@ discard block |
||
| 349 | 349 | */ |
| 350 | 350 | public function pluginsAction() |
| 351 | 351 | { |
| 352 | - $this->prepareTabs()->activate('plugins'); |
|
| 352 | + $this->prepareTabs()->activate('plugins'); |
|
| 353 | 353 | |
| 354 | - require_once($this->Module()->getBaseDir() .'/bin/trap_class.php'); |
|
| 355 | - $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc'); |
|
| 356 | - $Trap = new Trap($icingaweb2_etc,4); |
|
| 354 | + require_once($this->Module()->getBaseDir() .'/bin/trap_class.php'); |
|
| 355 | + $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc'); |
|
| 356 | + $Trap = new Trap($icingaweb2_etc,4); |
|
| 357 | 357 | |
| 358 | - $this->view->pluginLoaded = htmlentities($Trap->pluginClass->registerAllPlugins(false)); |
|
| 358 | + $this->view->pluginLoaded = htmlentities($Trap->pluginClass->registerAllPlugins(false)); |
|
| 359 | 359 | |
| 360 | - $enabledPlugins = $Trap->pluginClass->getEnabledPlugins(); |
|
| 360 | + $enabledPlugins = $Trap->pluginClass->getEnabledPlugins(); |
|
| 361 | 361 | |
| 362 | - $pluginList = $Trap->pluginClass->pluginList(); |
|
| 362 | + $pluginList = $Trap->pluginClass->pluginList(); |
|
| 363 | 363 | |
| 364 | - // Plugin list and fill function name list |
|
| 365 | - $functionList=array(); |
|
| 366 | - $this->view->pluginArray=array(); |
|
| 367 | - foreach ($pluginList as $plugin) |
|
| 368 | - { |
|
| 369 | - $pluginDetails=$Trap->pluginClass->pluginDetails($plugin); |
|
| 370 | - $pluginDetails->enabled = (in_array($plugin, $enabledPlugins)) ? true : false; |
|
| 371 | - $pluginDetails->catchAllTraps = ($pluginDetails->catchAllTraps === true )? 'Yes' : 'No'; |
|
| 372 | - $pluginDetails->processTraps = ($pluginDetails->processTraps === true )? 'Yes' : 'No'; |
|
| 373 | - $pluginDetails->description = htmlentities($pluginDetails->description); |
|
| 374 | - $pluginDetails->description = preg_replace('/\n/','<br>',$pluginDetails->description); |
|
| 375 | - array_push($this->view->pluginArray, $pluginDetails); |
|
| 376 | - // Get functions for function details |
|
| 377 | - foreach ($pluginDetails->funcArray as $function) |
|
| 378 | - { |
|
| 379 | - array_push($functionList,$function); |
|
| 380 | - } |
|
| 381 | - } |
|
| 364 | + // Plugin list and fill function name list |
|
| 365 | + $functionList=array(); |
|
| 366 | + $this->view->pluginArray=array(); |
|
| 367 | + foreach ($pluginList as $plugin) |
|
| 368 | + { |
|
| 369 | + $pluginDetails=$Trap->pluginClass->pluginDetails($plugin); |
|
| 370 | + $pluginDetails->enabled = (in_array($plugin, $enabledPlugins)) ? true : false; |
|
| 371 | + $pluginDetails->catchAllTraps = ($pluginDetails->catchAllTraps === true )? 'Yes' : 'No'; |
|
| 372 | + $pluginDetails->processTraps = ($pluginDetails->processTraps === true )? 'Yes' : 'No'; |
|
| 373 | + $pluginDetails->description = htmlentities($pluginDetails->description); |
|
| 374 | + $pluginDetails->description = preg_replace('/\n/','<br>',$pluginDetails->description); |
|
| 375 | + array_push($this->view->pluginArray, $pluginDetails); |
|
| 376 | + // Get functions for function details |
|
| 377 | + foreach ($pluginDetails->funcArray as $function) |
|
| 378 | + { |
|
| 379 | + array_push($functionList,$function); |
|
| 380 | + } |
|
| 381 | + } |
|
| 382 | 382 | |
| 383 | - // Function list with details |
|
| 384 | - $this->view->functionList=array(); |
|
| 385 | - foreach ($functionList as $function) |
|
| 386 | - { |
|
| 387 | - $functionDetail = $Trap->pluginClass->getFunctionDetails($function); |
|
| 388 | - $functionDetail->params = htmlentities($functionDetail->params); |
|
| 389 | - $functionDetail->description = htmlentities($functionDetail->description); |
|
| 390 | - $functionDetail->description = preg_replace('/\n/','<br>',$functionDetail->description); |
|
| 391 | - array_push($this->view->functionList, $functionDetail); |
|
| 392 | - } |
|
| 383 | + // Function list with details |
|
| 384 | + $this->view->functionList=array(); |
|
| 385 | + foreach ($functionList as $function) |
|
| 386 | + { |
|
| 387 | + $functionDetail = $Trap->pluginClass->getFunctionDetails($function); |
|
| 388 | + $functionDetail->params = htmlentities($functionDetail->params); |
|
| 389 | + $functionDetail->description = htmlentities($functionDetail->description); |
|
| 390 | + $functionDetail->description = preg_replace('/\n/','<br>',$functionDetail->description); |
|
| 391 | + array_push($this->view->functionList, $functionDetail); |
|
| 392 | + } |
|
| 393 | 393 | |
| 394 | 394 | } |
| 395 | 395 | |
@@ -398,47 +398,47 @@ discard block |
||
| 398 | 398 | */ |
| 399 | 399 | public function debugAction() |
| 400 | 400 | { |
| 401 | - $this->view->answer='No answer'; |
|
| 402 | - $this->view->input1 = ''; |
|
| 401 | + $this->view->answer='No answer'; |
|
| 402 | + $this->view->input1 = ''; |
|
| 403 | 403 | |
| 404 | - $postData=$this->getRequest()->getPost(); |
|
| 405 | - if (isset($postData['input1'])) |
|
| 406 | - { |
|
| 407 | - $input1 = $postData['input1']; |
|
| 408 | - $input2 = $postData['input2']; |
|
| 409 | - $input3 = $postData['input3']; |
|
| 410 | - $this->view->input1 = $input1; |
|
| 411 | - //$this->view->answer=$input1 . '/' . $input2 . '/' . $input3; |
|
| 412 | - try { |
|
| 413 | - $this->view->answer = 'Answer : '; |
|
| 414 | - $API = $this->getIdoConn(); |
|
| 415 | - $DB = $this->getUIDatabase(); |
|
| 404 | + $postData=$this->getRequest()->getPost(); |
|
| 405 | + if (isset($postData['input1'])) |
|
| 406 | + { |
|
| 407 | + $input1 = $postData['input1']; |
|
| 408 | + $input2 = $postData['input2']; |
|
| 409 | + $input3 = $postData['input3']; |
|
| 410 | + $this->view->input1 = $input1; |
|
| 411 | + //$this->view->answer=$input1 . '/' . $input2 . '/' . $input3; |
|
| 412 | + try { |
|
| 413 | + $this->view->answer = 'Answer : '; |
|
| 414 | + $API = $this->getIdoConn(); |
|
| 415 | + $DB = $this->getUIDatabase(); |
|
| 416 | 416 | |
| 417 | - //$hosts = $DB->getServicesByHostGroupid($input1); |
|
| 418 | - //$this->view->answer .= 'services : '.print_r($hosts,true); |
|
| 417 | + //$hosts = $DB->getServicesByHostGroupid($input1); |
|
| 418 | + //$this->view->answer .= 'services : '.print_r($hosts,true); |
|
| 419 | 419 | |
| 420 | - $hosts = $API->getServicesByHostGroupid($input1); |
|
| 421 | - $this->view->answer .= 'services : '.print_r($hosts,true); |
|
| 420 | + $hosts = $API->getServicesByHostGroupid($input1); |
|
| 421 | + $this->view->answer .= 'services : '.print_r($hosts,true); |
|
| 422 | 422 | |
| 423 | 423 | |
| 424 | 424 | |
| 425 | - return; |
|
| 426 | - $hosts = $API->getHostByIP($input1); |
|
| 427 | - $this->view->answer .= 'Host : '. print_r($hosts,true); |
|
| 428 | - $hosts = $API->getHostGroupByName($input1); |
|
| 429 | - $this->view->answer .= 'Group : '.print_r($hosts,true); |
|
| 430 | - $hosts = $API->getServicesByHostid($input1); |
|
| 431 | - $this->view->answer .= 'service : '.print_r($hosts,true); |
|
| 425 | + return; |
|
| 426 | + $hosts = $API->getHostByIP($input1); |
|
| 427 | + $this->view->answer .= 'Host : '. print_r($hosts,true); |
|
| 428 | + $hosts = $API->getHostGroupByName($input1); |
|
| 429 | + $this->view->answer .= 'Group : '.print_r($hosts,true); |
|
| 430 | + $hosts = $API->getServicesByHostid($input1); |
|
| 431 | + $this->view->answer .= 'service : '.print_r($hosts,true); |
|
| 432 | 432 | |
| 433 | - /* $hosts = $API->getHostsIPByHostGroup($input1); |
|
| 433 | + /* $hosts = $API->getHostsIPByHostGroup($input1); |
|
| 434 | 434 | $this->view->answer .= "\n Hostgrp : " . print_r($hosts,true); */ |
| 435 | 435 | |
| 436 | - } catch (Exception $e) |
|
| 437 | - { |
|
| 438 | - $this->view->answer = "Exception : " . print_r($e); |
|
| 439 | - } |
|
| 436 | + } catch (Exception $e) |
|
| 437 | + { |
|
| 438 | + $this->view->answer = "Exception : " . print_r($e); |
|
| 439 | + } |
|
| 440 | 440 | |
| 441 | - } |
|
| 441 | + } |
|
| 442 | 442 | |
| 443 | 443 | } |
| 444 | 444 | |
@@ -450,36 +450,36 @@ discard block |
||
| 450 | 450 | )->add('mib', array( |
| 451 | 451 | 'label' => $this->translate('MIB Management'), |
| 452 | 452 | 'url' => $this->getModuleConfig()->urlPath() . '/status/mib') |
| 453 | - )->add('uimgt', array( |
|
| 454 | - 'label' => $this->translate('UI Configuration'), |
|
| 455 | - 'url' => $this->getModuleConfig()->urlPath() . '/status/uimgt') |
|
| 456 | - )->add('services', array( |
|
| 453 | + )->add('uimgt', array( |
|
| 454 | + 'label' => $this->translate('UI Configuration'), |
|
| 455 | + 'url' => $this->getModuleConfig()->urlPath() . '/status/uimgt') |
|
| 456 | + )->add('services', array( |
|
| 457 | 457 | 'label' => $this->translate('Services management'), |
| 458 | 458 | 'url' => $this->getModuleConfig()->urlPath() . '/status/services') |
| 459 | - )->add('plugins', array( |
|
| 460 | - 'label' => $this->translate('Plugins management'), |
|
| 461 | - 'url' => $this->getModuleConfig()->urlPath() . '/status/plugins') |
|
| 462 | - ); |
|
| 459 | + )->add('plugins', array( |
|
| 460 | + 'label' => $this->translate('Plugins management'), |
|
| 461 | + 'url' => $this->getModuleConfig()->urlPath() . '/status/plugins') |
|
| 462 | + ); |
|
| 463 | 463 | } |
| 464 | 464 | } |
| 465 | 465 | |
| 466 | 466 | // TODO : see if useless |
| 467 | 467 | class UploadForm extends Form |
| 468 | 468 | { |
| 469 | - public function __construct($options = null) |
|
| 470 | - { |
|
| 471 | - parent::__construct($options); |
|
| 472 | - $this->addElements2(); |
|
| 473 | - } |
|
| 469 | + public function __construct($options = null) |
|
| 470 | + { |
|
| 471 | + parent::__construct($options); |
|
| 472 | + $this->addElements2(); |
|
| 473 | + } |
|
| 474 | 474 | |
| 475 | - public function addElements2() |
|
| 476 | - { |
|
| 477 | - // File Input |
|
| 478 | - $file = new File('mib-file'); |
|
| 479 | - $file->setLabel('Mib upload'); |
|
| 480 | - //->setAttrib('multiple', null); |
|
| 481 | - $this->addElement($file); |
|
| 475 | + public function addElements2() |
|
| 476 | + { |
|
| 477 | + // File Input |
|
| 478 | + $file = new File('mib-file'); |
|
| 479 | + $file->setLabel('Mib upload'); |
|
| 480 | + //->setAttrib('multiple', null); |
|
| 481 | + $this->addElement($file); |
|
| 482 | 482 | $button = new Submit("upload",array('ignore'=>false)); |
| 483 | 483 | $this->addElement($button);//->setIgnore(false); |
| 484 | - } |
|
| 484 | + } |
|
| 485 | 485 | } |
@@ -21,19 +21,19 @@ discard block |
||
| 21 | 21 | /************ Trapdb ***********/ |
| 22 | 22 | try |
| 23 | 23 | { |
| 24 | - $dbConn = $this->getUIDatabase()->getDbConn(); |
|
| 24 | + $dbConn=$this->getUIDatabase()->getDbConn(); |
|
| 25 | 25 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 26 | - $query = $dbConn->select()->from( |
|
| 26 | + $query=$dbConn->select()->from( |
|
| 27 | 27 | $this->getModuleConfig()->getTrapTableName(), |
| 28 | 28 | array('COUNT(*)') |
| 29 | 29 | ); |
| 30 | 30 | $this->view->trap_count=$dbConn->fetchOne($query); |
| 31 | - $query = $dbConn->select()->from( |
|
| 31 | + $query=$dbConn->select()->from( |
|
| 32 | 32 | $this->getModuleConfig()->getTrapDataTableName(), |
| 33 | 33 | array('COUNT(*)') |
| 34 | 34 | ); |
| 35 | 35 | $this->view->trap_object_count=$dbConn->fetchOne($query); |
| 36 | - $query = $dbConn->select()->from( |
|
| 36 | + $query=$dbConn->select()->from( |
|
| 37 | 37 | $this->getModuleConfig()->getTrapRuleName(), |
| 38 | 38 | array('COUNT(*)') |
| 39 | 39 | ); |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | } |
| 45 | 45 | catch (Exception $e) |
| 46 | 46 | { |
| 47 | - $this->displayExitError('status',$e->getMessage()); |
|
| 47 | + $this->displayExitError('status', $e->getMessage()); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /*************** Log destination *******************/ |
@@ -59,20 +59,20 @@ discard block |
||
| 59 | 59 | } |
| 60 | 60 | catch (Exception $e) |
| 61 | 61 | { |
| 62 | - $this->displayExitError('status',$e->getMessage()); |
|
| 62 | + $this->displayExitError('status', $e->getMessage()); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /*************** SNMP configuration ****************/ |
| 66 | 66 | try |
| 67 | 67 | { |
| 68 | - $this->view->useSnmpTrapAddess= ( $this->getUIDatabase()->getDBConfigValue('use_SnmpTrapAddess') == 1 ) ? TRUE : FALSE; |
|
| 68 | + $this->view->useSnmpTrapAddess=($this->getUIDatabase()->getDBConfigValue('use_SnmpTrapAddess') == 1) ? TRUE : FALSE; |
|
| 69 | 69 | $this->view->SnmpTrapAddressOID=$this->getUIDatabase()->getDBConfigValue('SnmpTrapAddess_oid'); |
| 70 | - $this->view->SnmpTrapAddressOIDDefault = ($this->view->SnmpTrapAddressOID == $this->getModuleConfig()->getDBConfigDefaults()['SnmpTrapAddess_oid'] ) ? TRUE : FALSE; |
|
| 70 | + $this->view->SnmpTrapAddressOIDDefault=($this->view->SnmpTrapAddressOID == $this->getModuleConfig()->getDBConfigDefaults()['SnmpTrapAddess_oid']) ? TRUE : FALSE; |
|
| 71 | 71 | |
| 72 | 72 | } |
| 73 | 73 | catch (Exception $e) |
| 74 | 74 | { |
| 75 | - $this->displayExitError('status',$e->getMessage()); |
|
| 75 | + $this->displayExitError('status', $e->getMessage()); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | if ($action == 'update_mib_db') |
| 99 | 99 | { // Do the update in background |
| 100 | 100 | $return=exec('icingacli trapdirector mib update --pid /tmp/trapdirector_update.pid'); |
| 101 | - if (preg_match('/OK/',$return)) |
|
| 101 | + if (preg_match('/OK/', $return)) |
|
| 102 | 102 | { |
| 103 | 103 | $this->_helper->json(array('status'=>'OK')); |
| 104 | 104 | } |
@@ -107,32 +107,32 @@ discard block |
||
| 107 | 107 | } |
| 108 | 108 | if ($action == 'check_update') |
| 109 | 109 | { |
| 110 | - $file=@fopen('/tmp/trapdirector_update.pid','r'); |
|
| 110 | + $file=@fopen('/tmp/trapdirector_update.pid', 'r'); |
|
| 111 | 111 | if ($file == false) |
| 112 | 112 | { // process is dead |
| 113 | - $this->_helper->json(array('status'=>'tu quoque fili','err'=>'Cannot open file')); |
|
| 113 | + $this->_helper->json(array('status'=>'tu quoque fili', 'err'=>'Cannot open file')); |
|
| 114 | 114 | return; |
| 115 | 115 | } |
| 116 | 116 | $pid=fgets($file); |
| 117 | 117 | $output=array(); |
| 118 | 118 | $retVal=0; |
| 119 | - exec('ps '.$pid,$output,$retVal); |
|
| 119 | + exec('ps '.$pid, $output, $retVal); |
|
| 120 | 120 | if ($retVal == 0) |
| 121 | 121 | { // process is alive |
| 122 | 122 | $this->_helper->json(array('status'=>'Alive and kicking')); |
| 123 | 123 | } |
| 124 | 124 | else |
| 125 | 125 | { // process is dead |
| 126 | - $this->_helper->json(array('status'=>'tu quoque fili','err'=>'no proc'.$pid)); |
|
| 126 | + $this->_helper->json(array('status'=>'tu quoque fili', 'err'=>'no proc'.$pid)); |
|
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | - $this->_helper->json(array('status'=>'ERR : no '.$action.' action possible' )); |
|
| 129 | + $this->_helper->json(array('status'=>'ERR : no '.$action.' action possible')); |
|
| 130 | 130 | } |
| 131 | 131 | /** Check for mib file UPLOAD */ |
| 132 | 132 | if (isset($_FILES['mibfile'])) |
| 133 | 133 | { |
| 134 | - $name=filter_var($_FILES['mibfile']['name'],FILTER_SANITIZE_STRING); |
|
| 135 | - $DirConf=explode(':',$this->Config()->get('config', 'snmptranslate_dirs')); |
|
| 134 | + $name=filter_var($_FILES['mibfile']['name'], FILTER_SANITIZE_STRING); |
|
| 135 | + $DirConf=explode(':', $this->Config()->get('config', 'snmptranslate_dirs')); |
|
| 136 | 136 | $destDir=array_shift($DirConf); |
| 137 | 137 | if (!is_dir($destDir)) |
| 138 | 138 | { |
@@ -146,9 +146,9 @@ discard block |
||
| 146 | 146 | } |
| 147 | 147 | else |
| 148 | 148 | { |
| 149 | - $destination = $destDir .'/'.$name; //$this->Module()->getBaseDir() . "/mibs/$name"; |
|
| 150 | - $sourceTmpNam=filter_var($_FILES['mibfile']['tmp_name'],FILTER_SANITIZE_STRING); |
|
| 151 | - if (move_uploaded_file($sourceTmpNam,$destination)===false) |
|
| 149 | + $destination=$destDir.'/'.$name; //$this->Module()->getBaseDir() . "/mibs/$name"; |
|
| 150 | + $sourceTmpNam=filter_var($_FILES['mibfile']['tmp_name'], FILTER_SANITIZE_STRING); |
|
| 151 | + if (move_uploaded_file($sourceTmpNam, $destination) === false) |
|
| 152 | 152 | { |
| 153 | 153 | $this->view->uploadStatus="ERROR, file $destination not loaded. Check file and path name or selinux violations"; |
| 154 | 154 | } |
@@ -164,16 +164,16 @@ discard block |
||
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | // snmptranslate tests |
| 167 | - $snmptranslate = $this->Config()->get('config', 'snmptranslate'); |
|
| 167 | + $snmptranslate=$this->Config()->get('config', 'snmptranslate'); |
|
| 168 | 168 | $this->view->snmptranslate_bin=$snmptranslate; |
| 169 | 169 | $this->view->snmptranslate_state='warn'; |
| 170 | - if (is_executable ( $snmptranslate )) |
|
| 170 | + if (is_executable($snmptranslate)) |
|
| 171 | 171 | { |
| 172 | - $translate=exec($snmptranslate . ' 1'); |
|
| 173 | - if (preg_match('/iso/',$translate)) |
|
| 172 | + $translate=exec($snmptranslate.' 1'); |
|
| 173 | + if (preg_match('/iso/', $translate)) |
|
| 174 | 174 | { |
| 175 | - $translate=exec($snmptranslate . ' 1.3.6.1.4'); |
|
| 176 | - if (preg_match('/private/',$translate)) |
|
| 175 | + $translate=exec($snmptranslate.' 1.3.6.1.4'); |
|
| 176 | + if (preg_match('/private/', $translate)) |
|
| 177 | 177 | { |
| 178 | 178 | $this->view->snmptranslate='works fine'; |
| 179 | 179 | $this->view->snmptranslate_state='ok'; |
@@ -196,46 +196,46 @@ discard block |
||
| 196 | 196 | // mib database |
| 197 | 197 | |
| 198 | 198 | $this->view->mibDbCount=$this->getMIB()->countObjects(); |
| 199 | - $this->view->mibDbCountTrap=$this->getMIB()->countObjects(null,21); |
|
| 199 | + $this->view->mibDbCountTrap=$this->getMIB()->countObjects(null, 21); |
|
| 200 | 200 | |
| 201 | 201 | // mib dirs |
| 202 | 202 | $DirConf=$this->Config()->get('config', 'snmptranslate_dirs'); |
| 203 | - $dirArray=explode(':',$DirConf); |
|
| 203 | + $dirArray=explode(':', $DirConf); |
|
| 204 | 204 | |
| 205 | 205 | // Get base directories from net-snmp-config |
| 206 | 206 | $output=$matches=array(); |
| 207 | 207 | $retVal=0; |
| 208 | - $sysDirs=exec('net-snmp-config --default-mibdirs',$output,$retVal); |
|
| 209 | - if ($retVal==0) |
|
| 208 | + $sysDirs=exec('net-snmp-config --default-mibdirs', $output, $retVal); |
|
| 209 | + if ($retVal == 0) |
|
| 210 | 210 | { |
| 211 | - $dirArray=array_merge($dirArray,explode(':',$sysDirs)); |
|
| 211 | + $dirArray=array_merge($dirArray, explode(':', $sysDirs)); |
|
| 212 | 212 | } |
| 213 | 213 | else |
| 214 | 214 | { |
| 215 | - $translateOut=exec($this->Config()->get('config', 'snmptranslate') . ' -Dinit_mib .1.3 2>&1 | grep MIBDIRS'); |
|
| 216 | - if (preg_match('/MIBDIRS.*\'([^\']+)\'/',$translateOut,$matches)) |
|
| 215 | + $translateOut=exec($this->Config()->get('config', 'snmptranslate').' -Dinit_mib .1.3 2>&1 | grep MIBDIRS'); |
|
| 216 | + if (preg_match('/MIBDIRS.*\'([^\']+)\'/', $translateOut, $matches)) |
|
| 217 | 217 | { |
| 218 | - $dirArray=array_merge($dirArray,explode(':',$matches[1])); |
|
| 218 | + $dirArray=array_merge($dirArray, explode(':', $matches[1])); |
|
| 219 | 219 | } |
| 220 | 220 | else |
| 221 | 221 | { |
| 222 | - array_push($dirArray,'Install net-snmp-config to see system directories'); |
|
| 222 | + array_push($dirArray, 'Install net-snmp-config to see system directories'); |
|
| 223 | 223 | } |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | $this->view->dirArray=$dirArray; |
| 227 | 227 | |
| 228 | 228 | $output=null; |
| 229 | - foreach (explode(':',$DirConf) as $mibdir) |
|
| 229 | + foreach (explode(':', $DirConf) as $mibdir) |
|
| 230 | 230 | { |
| 231 | - exec('ls '.$mibdir.' | grep -v traplist.txt',$output); |
|
| 231 | + exec('ls '.$mibdir.' | grep -v traplist.txt', $output); |
|
| 232 | 232 | } |
| 233 | 233 | //$i=0;$listFiles='';while (isset($output[$i])) $listFiles.=$output[$i++]; |
| 234 | 234 | //$this->view->fileList=explode(' ',$listFiles); |
| 235 | 235 | $this->view->fileList=$output; |
| 236 | 236 | |
| 237 | 237 | // Zend form |
| 238 | - $this->view->form= new UploadForm(); |
|
| 238 | + $this->view->form=new UploadForm(); |
|
| 239 | 239 | //$this->view->form= new Form('upload-form'); |
| 240 | 240 | |
| 241 | 241 | |
@@ -250,9 +250,9 @@ discard block |
||
| 250 | 250 | $this->view->setOKMsg=''; |
| 251 | 251 | |
| 252 | 252 | //max_rows=25&row_update=update |
| 253 | - if ( $this->getRequest()->getParam('max_rows',NULL) !== NULL ) |
|
| 253 | + if ($this->getRequest()->getParam('max_rows', NULL) !== NULL) |
|
| 254 | 254 | { |
| 255 | - $maxRows = $this->getRequest()->getParam('max_rows'); |
|
| 255 | + $maxRows=$this->getRequest()->getParam('max_rows'); |
|
| 256 | 256 | if (!preg_match('/^[0-9]+$/', $maxRows) || $maxRows < 1) |
| 257 | 257 | { |
| 258 | 258 | $this->view->setError='Max rows must be a number'; |
@@ -260,21 +260,21 @@ discard block |
||
| 260 | 260 | else |
| 261 | 261 | { |
| 262 | 262 | $this->setitemListDisplay($maxRows); |
| 263 | - $this->view->setOKMsg='Set max rows to ' . $maxRows; |
|
| 263 | + $this->view->setOKMsg='Set max rows to '.$maxRows; |
|
| 264 | 264 | } |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - if ( $this->getRequest()->getParam('add_category',NULL) !== NULL ) |
|
| 267 | + if ($this->getRequest()->getParam('add_category', NULL) !== NULL) |
|
| 268 | 268 | { |
| 269 | - $addCat = $this->getRequest()->getParam('add_category'); |
|
| 269 | + $addCat=$this->getRequest()->getParam('add_category'); |
|
| 270 | 270 | $this->addHandlersCategory($addCat); |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | - if ( $this->getRequest()->getPost('type',NULL) !== NULL ) |
|
| 273 | + if ($this->getRequest()->getPost('type', NULL) !== NULL) |
|
| 274 | 274 | { |
| 275 | - $type = $this->getRequest()->getPost('type',NULL); |
|
| 276 | - $index = $this->getRequest()->getPost('index',NULL); |
|
| 277 | - $newname = $this->getRequest()->getPost('newname',NULL); |
|
| 275 | + $type=$this->getRequest()->getPost('type', NULL); |
|
| 276 | + $index=$this->getRequest()->getPost('index', NULL); |
|
| 277 | + $newname=$this->getRequest()->getPost('newname', NULL); |
|
| 278 | 278 | |
| 279 | 279 | if (!preg_match('/^[0-9]+$/', $index) || $index < 1) |
| 280 | 280 | $this->_helper->json(array('status'=>'Bad index')); |
@@ -298,9 +298,9 @@ discard block |
||
| 298 | 298 | } |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - $this->view->maxRows = $this->itemListDisplay(); |
|
| 301 | + $this->view->maxRows=$this->itemListDisplay(); |
|
| 302 | 302 | |
| 303 | - $this->view->categories = $this->getHandlersCategory(); |
|
| 303 | + $this->view->categories=$this->getHandlersCategory(); |
|
| 304 | 304 | |
| 305 | 305 | |
| 306 | 306 | |
@@ -324,18 +324,18 @@ discard block |
||
| 324 | 324 | $this->view->templateForm_output=''; |
| 325 | 325 | if (isset($postData['template_name']) && isset($postData['template_revert_time'])) |
| 326 | 326 | { |
| 327 | - $template_create = 'icingacli director service create --json \'{ "check_command": "dummy", '; |
|
| 328 | - $template_create .= '"check_interval": "' .$postData['template_revert_time']. '", "check_timeout": "20", "disabled": false, "enable_active_checks": true, "enable_event_handler": true, "enable_notifications": true, "enable_passive_checks": true, "enable_perfdata": true, "max_check_attempts": "1", '; |
|
| 329 | - $template_create .= '"object_name": "'.$postData['template_name'].'", "object_type": "template", "retry_interval": "'.$postData['template_revert_time'].'"}\''; |
|
| 327 | + $template_create='icingacli director service create --json \'{ "check_command": "dummy", '; |
|
| 328 | + $template_create.='"check_interval": "'.$postData['template_revert_time'].'", "check_timeout": "20", "disabled": false, "enable_active_checks": true, "enable_event_handler": true, "enable_notifications": true, "enable_passive_checks": true, "enable_perfdata": true, "max_check_attempts": "1", '; |
|
| 329 | + $template_create.='"object_name": "'.$postData['template_name'].'", "object_type": "template", "retry_interval": "'.$postData['template_revert_time'].'"}\''; |
|
| 330 | 330 | $output=array(); |
| 331 | 331 | $ret_code=0; |
| 332 | - exec($template_create,$output,$ret_code); |
|
| 332 | + exec($template_create, $output, $ret_code); |
|
| 333 | 333 | if ($ret_code != 0) |
| 334 | 334 | { |
| 335 | - $this->displayExitError("Status -> Services","Error creating template : ".$output[0].'<br>Command was : '.$template_create); |
|
| 335 | + $this->displayExitError("Status -> Services", "Error creating template : ".$output[0].'<br>Command was : '.$template_create); |
|
| 336 | 336 | } |
| 337 | - exec('icingacli director config deploy',$output,$ret_code); |
|
| 338 | - $this->view->templateForm_output='Template '.$postData['template_name']. ' created'; |
|
| 337 | + exec('icingacli director config deploy', $output, $ret_code); |
|
| 338 | + $this->view->templateForm_output='Template '.$postData['template_name'].' created'; |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | // template creation form |
@@ -351,15 +351,15 @@ discard block |
||
| 351 | 351 | { |
| 352 | 352 | $this->prepareTabs()->activate('plugins'); |
| 353 | 353 | |
| 354 | - require_once($this->Module()->getBaseDir() .'/bin/trap_class.php'); |
|
| 354 | + require_once($this->Module()->getBaseDir().'/bin/trap_class.php'); |
|
| 355 | 355 | $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc'); |
| 356 | - $Trap = new Trap($icingaweb2_etc,4); |
|
| 356 | + $Trap=new Trap($icingaweb2_etc, 4); |
|
| 357 | 357 | |
| 358 | - $this->view->pluginLoaded = htmlentities($Trap->pluginClass->registerAllPlugins(false)); |
|
| 358 | + $this->view->pluginLoaded=htmlentities($Trap->pluginClass->registerAllPlugins(false)); |
|
| 359 | 359 | |
| 360 | - $enabledPlugins = $Trap->pluginClass->getEnabledPlugins(); |
|
| 360 | + $enabledPlugins=$Trap->pluginClass->getEnabledPlugins(); |
|
| 361 | 361 | |
| 362 | - $pluginList = $Trap->pluginClass->pluginList(); |
|
| 362 | + $pluginList=$Trap->pluginClass->pluginList(); |
|
| 363 | 363 | |
| 364 | 364 | // Plugin list and fill function name list |
| 365 | 365 | $functionList=array(); |
@@ -367,16 +367,16 @@ discard block |
||
| 367 | 367 | foreach ($pluginList as $plugin) |
| 368 | 368 | { |
| 369 | 369 | $pluginDetails=$Trap->pluginClass->pluginDetails($plugin); |
| 370 | - $pluginDetails->enabled = (in_array($plugin, $enabledPlugins)) ? true : false; |
|
| 371 | - $pluginDetails->catchAllTraps = ($pluginDetails->catchAllTraps === true )? 'Yes' : 'No'; |
|
| 372 | - $pluginDetails->processTraps = ($pluginDetails->processTraps === true )? 'Yes' : 'No'; |
|
| 373 | - $pluginDetails->description = htmlentities($pluginDetails->description); |
|
| 374 | - $pluginDetails->description = preg_replace('/\n/','<br>',$pluginDetails->description); |
|
| 370 | + $pluginDetails->enabled=(in_array($plugin, $enabledPlugins)) ? true : false; |
|
| 371 | + $pluginDetails->catchAllTraps=($pluginDetails->catchAllTraps === true) ? 'Yes' : 'No'; |
|
| 372 | + $pluginDetails->processTraps=($pluginDetails->processTraps === true) ? 'Yes' : 'No'; |
|
| 373 | + $pluginDetails->description=htmlentities($pluginDetails->description); |
|
| 374 | + $pluginDetails->description=preg_replace('/\n/', '<br>', $pluginDetails->description); |
|
| 375 | 375 | array_push($this->view->pluginArray, $pluginDetails); |
| 376 | 376 | // Get functions for function details |
| 377 | 377 | foreach ($pluginDetails->funcArray as $function) |
| 378 | 378 | { |
| 379 | - array_push($functionList,$function); |
|
| 379 | + array_push($functionList, $function); |
|
| 380 | 380 | } |
| 381 | 381 | } |
| 382 | 382 | |
@@ -384,10 +384,10 @@ discard block |
||
| 384 | 384 | $this->view->functionList=array(); |
| 385 | 385 | foreach ($functionList as $function) |
| 386 | 386 | { |
| 387 | - $functionDetail = $Trap->pluginClass->getFunctionDetails($function); |
|
| 388 | - $functionDetail->params = htmlentities($functionDetail->params); |
|
| 389 | - $functionDetail->description = htmlentities($functionDetail->description); |
|
| 390 | - $functionDetail->description = preg_replace('/\n/','<br>',$functionDetail->description); |
|
| 387 | + $functionDetail=$Trap->pluginClass->getFunctionDetails($function); |
|
| 388 | + $functionDetail->params=htmlentities($functionDetail->params); |
|
| 389 | + $functionDetail->description=htmlentities($functionDetail->description); |
|
| 390 | + $functionDetail->description=preg_replace('/\n/', '<br>', $functionDetail->description); |
|
| 391 | 391 | array_push($this->view->functionList, $functionDetail); |
| 392 | 392 | } |
| 393 | 393 | |
@@ -399,43 +399,43 @@ discard block |
||
| 399 | 399 | public function debugAction() |
| 400 | 400 | { |
| 401 | 401 | $this->view->answer='No answer'; |
| 402 | - $this->view->input1 = ''; |
|
| 402 | + $this->view->input1=''; |
|
| 403 | 403 | |
| 404 | 404 | $postData=$this->getRequest()->getPost(); |
| 405 | 405 | if (isset($postData['input1'])) |
| 406 | 406 | { |
| 407 | - $input1 = $postData['input1']; |
|
| 408 | - $input2 = $postData['input2']; |
|
| 409 | - $input3 = $postData['input3']; |
|
| 410 | - $this->view->input1 = $input1; |
|
| 407 | + $input1=$postData['input1']; |
|
| 408 | + $input2=$postData['input2']; |
|
| 409 | + $input3=$postData['input3']; |
|
| 410 | + $this->view->input1=$input1; |
|
| 411 | 411 | //$this->view->answer=$input1 . '/' . $input2 . '/' . $input3; |
| 412 | 412 | try { |
| 413 | - $this->view->answer = 'Answer : '; |
|
| 414 | - $API = $this->getIdoConn(); |
|
| 415 | - $DB = $this->getUIDatabase(); |
|
| 413 | + $this->view->answer='Answer : '; |
|
| 414 | + $API=$this->getIdoConn(); |
|
| 415 | + $DB=$this->getUIDatabase(); |
|
| 416 | 416 | |
| 417 | 417 | //$hosts = $DB->getServicesByHostGroupid($input1); |
| 418 | 418 | //$this->view->answer .= 'services : '.print_r($hosts,true); |
| 419 | 419 | |
| 420 | - $hosts = $API->getServicesByHostGroupid($input1); |
|
| 421 | - $this->view->answer .= 'services : '.print_r($hosts,true); |
|
| 420 | + $hosts=$API->getServicesByHostGroupid($input1); |
|
| 421 | + $this->view->answer.='services : '.print_r($hosts, true); |
|
| 422 | 422 | |
| 423 | 423 | |
| 424 | 424 | |
| 425 | 425 | return; |
| 426 | - $hosts = $API->getHostByIP($input1); |
|
| 427 | - $this->view->answer .= 'Host : '. print_r($hosts,true); |
|
| 428 | - $hosts = $API->getHostGroupByName($input1); |
|
| 429 | - $this->view->answer .= 'Group : '.print_r($hosts,true); |
|
| 430 | - $hosts = $API->getServicesByHostid($input1); |
|
| 431 | - $this->view->answer .= 'service : '.print_r($hosts,true); |
|
| 426 | + $hosts=$API->getHostByIP($input1); |
|
| 427 | + $this->view->answer.='Host : '.print_r($hosts, true); |
|
| 428 | + $hosts=$API->getHostGroupByName($input1); |
|
| 429 | + $this->view->answer.='Group : '.print_r($hosts, true); |
|
| 430 | + $hosts=$API->getServicesByHostid($input1); |
|
| 431 | + $this->view->answer.='service : '.print_r($hosts, true); |
|
| 432 | 432 | |
| 433 | 433 | /* $hosts = $API->getHostsIPByHostGroup($input1); |
| 434 | 434 | $this->view->answer .= "\n Hostgrp : " . print_r($hosts,true); */ |
| 435 | 435 | |
| 436 | 436 | } catch (Exception $e) |
| 437 | 437 | { |
| 438 | - $this->view->answer = "Exception : " . print_r($e); |
|
| 438 | + $this->view->answer="Exception : ".print_r($e); |
|
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | } |
@@ -446,19 +446,19 @@ discard block |
||
| 446 | 446 | { |
| 447 | 447 | return $this->getTabs()->add('status', array( |
| 448 | 448 | 'label' => $this->translate('Status'), |
| 449 | - 'url' => $this->getModuleConfig()->urlPath() . '/status') |
|
| 449 | + 'url' => $this->getModuleConfig()->urlPath().'/status') |
|
| 450 | 450 | )->add('mib', array( |
| 451 | 451 | 'label' => $this->translate('MIB Management'), |
| 452 | - 'url' => $this->getModuleConfig()->urlPath() . '/status/mib') |
|
| 452 | + 'url' => $this->getModuleConfig()->urlPath().'/status/mib') |
|
| 453 | 453 | )->add('uimgt', array( |
| 454 | 454 | 'label' => $this->translate('UI Configuration'), |
| 455 | - 'url' => $this->getModuleConfig()->urlPath() . '/status/uimgt') |
|
| 455 | + 'url' => $this->getModuleConfig()->urlPath().'/status/uimgt') |
|
| 456 | 456 | )->add('services', array( |
| 457 | 457 | 'label' => $this->translate('Services management'), |
| 458 | - 'url' => $this->getModuleConfig()->urlPath() . '/status/services') |
|
| 458 | + 'url' => $this->getModuleConfig()->urlPath().'/status/services') |
|
| 459 | 459 | )->add('plugins', array( |
| 460 | 460 | 'label' => $this->translate('Plugins management'), |
| 461 | - 'url' => $this->getModuleConfig()->urlPath() . '/status/plugins') |
|
| 461 | + 'url' => $this->getModuleConfig()->urlPath().'/status/plugins') |
|
| 462 | 462 | ); |
| 463 | 463 | } |
| 464 | 464 | } |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | // TODO : see if useless |
| 467 | 467 | class UploadForm extends Form |
| 468 | 468 | { |
| 469 | - public function __construct($options = null) |
|
| 469 | + public function __construct($options=null) |
|
| 470 | 470 | { |
| 471 | 471 | parent::__construct($options); |
| 472 | 472 | $this->addElements2(); |
@@ -475,11 +475,11 @@ discard block |
||
| 475 | 475 | public function addElements2() |
| 476 | 476 | { |
| 477 | 477 | // File Input |
| 478 | - $file = new File('mib-file'); |
|
| 478 | + $file=new File('mib-file'); |
|
| 479 | 479 | $file->setLabel('Mib upload'); |
| 480 | 480 | //->setAttrib('multiple', null); |
| 481 | 481 | $this->addElement($file); |
| 482 | - $button = new Submit("upload",array('ignore'=>false)); |
|
| 483 | - $this->addElement($button);//->setIgnore(false); |
|
| 482 | + $button=new Submit("upload", array('ignore'=>false)); |
|
| 483 | + $this->addElement($button); //->setIgnore(false); |
|
| 484 | 484 | } |
| 485 | 485 | } |