Exemple #1
0
 function remove()
 {
     $id = $this->get_id();
     $response_data[] = $this->req->data_array;
     $db = Database::instance();
     $db->query('begin');
     $policy_orm = ORM::factory('policy')->where(array('id' => $id, 'deleted' => 0))->find();
     if ($policy_orm->loaded) {
         $policy_orm->deleted = 1;
         $oldname = $policy_orm->name;
         $name = $policy_orm->name . "@" . sprintf("%x", time());
         $policy_orm->name = $name;
         $policy_orm->save();
         if ($policy_orm->saved) {
             if ($policy_orm->saved) {
                 $pb = new Protobuf();
                 $result = $pb->sendconfig($db);
                 if ($result['status'] === 0) {
                     $db->query('commit');
                     $result = 0;
                     $this->respOk($response_data);
                 } else {
                     $db->query('rollback');
                     $result = -1;
                     if ($result['message']) {
                         $message = "规则下发失败,失败原因:" . $result['message'];
                     } else {
                         $message = "规则下发失败";
                     }
                     $this->respFailed($message);
                 }
             } else {
                 $db->query('commit');
                 $result = 0;
                 $this->respOk($response_data);
             }
         } else {
             $result = -1;
             $message = '删除策略失败,未知的错误';
             $this->respFailed($message);
         }
         $this->operationlog_remove($result, $id, $oldname);
     } else {
         $message = '删除策略失败,未知的策略ID';
         $this->respFailed($message);
     }
     return;
 }
Exemple #2
0
 function update()
 {
     $id = $this->get_id();
     $response_data = $this->get_data_array();
     if (isset($this->req->data->name)) {
         $responseemail_orm = ORM::factory('responseemail')->where('name', $this->req->data->name)->find();
         if ($responseemail_orm->loaded) {
             $this->respNameError();
             exit;
         }
     }
     $db = Database::instance();
     $db->query('begin');
     $responseemail_orm = ORM::factory('responseemail', $id);
     if ($responseemail_orm->loaded) {
         $using = $this->is_using("responseemail", $id);
         foreach ($this->req->data as $key => $value) {
             $responseemail_orm->{$key} = $value;
         }
         $responseemail_orm->save();
         if ($responseemail_orm->saved) {
             if ($using) {
                 $pb = new Protobuf();
                 $result = $pb->sendconfig($db);
                 if ($result['status'] === 0) {
                     $db->query('commit');
                     $result = 0;
                     $this->respOk($response_data);
                 } else {
                     $db->query('rollback');
                     $result = -1;
                     if ($result['message']) {
                         $message = "规则下发失败,失败原因:" . $result['message'];
                     } else {
                         $message = "规则下发失败";
                     }
                     $this->respFailed($message);
                 }
             } else {
                 $db->query('commit');
                 $result = 0;
                 $this->respOk($response_data);
             }
         } else {
             $result = -1;
             $message = '修改email响应失败,未知的错误';
             $this->respFailed($message);
         }
         $diff_data = $this->update_data_diff($this->req->data_array, $this->req->oldValues_array);
         $this->operationlog_update($result, $id, $this->req->oldValues->name, $diff_data);
     } else {
         $message = '修改email响应失败,未知的email响应ID';
         $this->respFailed($message);
     }
     return;
 }
Exemple #3
0
 function remove()
 {
     $id = $this->get_id();
     $response_data[] = $this->req->data_array;
     $db = Database::instance();
     $db->query('begin');
     $dbservice_orm = ORM::factory('auditservice')->where('id', $id)->find();
     if ($dbservice_orm->loaded) {
         $using = $this->is_using("dbservice", $id);
         if ($using) {
             $message = "当前应用配置了审计策略,现在不能删除";
             $this->respFailed($message);
         } else {
             $dbservice_orm->deleted = 1;
             $oldname = $dbservice_orm->name;
             $name = $dbservice_orm->name . "@" . sprintf("%x", time());
             $dbservice_orm->name = $name;
             $dbservice_orm->save();
             if ($dbservice_orm->saved) {
                 if ($using) {
                     $pb = new Protobuf();
                     $result = $pb->sendconfig($db);
                     if ($result['status'] === 0) {
                         $db->query('commit');
                         $result = 0;
                         $this->respOk($response_data);
                     } else {
                         $db->query('rollback');
                         $result = -1;
                         if ($result['message']) {
                             $message = "规则下发失败,失败原因:" . $result['message'];
                         } else {
                             $message = "规则下发失败";
                         }
                         $this->respFailed($message);
                     }
                 } else {
                     $db->query('commit');
                     $result = 0;
                     $this->respOk($response_data);
                 }
             } else {
                 $result = -1;
                 $message = '删除服务失败,未知的错误';
                 $this->respFailed($message);
             }
             $this->operationlog_remove($result, $id, $oldname);
         }
     } else {
         $message = '删除服务失败,未知的数据库服务ID';
         $this->respFailed($message);
     }
     return;
 }