コード例 #1
0
ファイル: panoptes.php プロジェクト: redsox38/panoptes
 /**
  * delete monitor entries
  *
  * @param args json params converted into an array
  *             id key contains an array of ids to remove
  * @throws none
  * @return array containing result and possible error messages
  */
 public function ajax_deleteMonitorEntry($args)
 {
     try {
         // table is based on type argument
         if ($args['type'] == 'port_monitors') {
             require_once 'portMonitorEntry.php';
             foreach ($args['id'] as $v) {
                 $ent = new portMonitorEntry($this->db);
                 $ent->id = $v;
                 $ent->delete();
             }
         } elseif ($args['type'] == 'certificate_monitors') {
             require_once 'certificateMonitorEntry.php';
             foreach ($args['id'] as $v) {
                 $ent = new certificateMonitorEntry($this->db);
                 $ent->id = $v;
                 $ent->delete();
             }
         } elseif ($args['type'] == 'snmp_monitors') {
             foreach ($args['id'] as $v) {
                 require_once 'SNMPMonitorEntry.php';
                 $ent = new SNMPMonitorEntry($this->db);
                 $ent->id = $v;
                 $ent->delete();
             }
         } elseif ($args['type'] == 'shell_monitors') {
             foreach ($args['id'] as $v) {
                 require_once 'shellMonitorEntry.php';
                 $ent = new shellMonitorEntry($this->db);
                 $ent->id = $v;
                 $ent->delete();
             }
         } elseif ($args['type'] == 'url_monitors') {
             foreach ($args['id'] as $v) {
                 require_once 'urlMonitorEntry.php';
                 $ent = new urlMonitorEntry($this->db);
                 $ent->id = $v;
                 $ent->delete();
             }
         } else {
             return array('result' => 'failure', 'error' => 'unknown type: ' . $args['type']);
         }
     } catch (Exception $e) {
         return array('result' => 'failure', 'error' => $e->getMessage());
     }
     return array('result' => 'success');
 }