Ejemplo n.º 1
0
                    				}
                    //*/
                }
                $go_result = DBend($go_result);
                show_messages($go_result, S_GROUP_DELETED, S_CANNOT_DELETE_GROUP);
            } else {
                if (str_in_array($_REQUEST['go'], array('activate', 'disable'))) {
                    $status = $_REQUEST['go'] == 'activate' ? HOST_STATUS_MONITORED : HOST_STATUS_NOT_MONITORED;
                    $groups = get_request('groups', array());
                    if (!empty($groups)) {
                        DBstart();
                        $hosts = CHost::get(array('groupids' => $groups, 'editable' => 1, 'output' => API_OUTPUT_EXTEND));
                        if (empty($hosts)) {
                            $go_result = true;
                        } else {
                            $go_result = CHost::massUpdate(array('hosts' => $hosts, 'status' => $status));
                            if ($go_result) {
                                foreach ($hosts as $host) {
                                    add_audit_ext(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_HOST, $host['hostid'], $host['host'], 'hosts', array('status' => $host['status']), array('status' => $status));
                                }
                            }
                        }
                        $go_result = DBend($go_result);
                        show_messages($go_result, S_HOST_STATUS_UPDATED, S_CANNOT_UPDATE_HOST);
                    }
                }
            }
        }
    }
}
if ($_REQUEST['go'] != 'none' && isset($go_result) && $go_result) {
Ejemplo n.º 2
0
 private static function host($action, $params)
 {
     CHost::$error = array();
     switch ($action) {
         case 'add':
             $result = CHost::add($params);
             break;
         case 'get':
             $result = CHost::get($params);
             break;
         case 'getById':
             $result = CHost::getById($params);
             break;
         case 'getId':
             $result = CHost::getId($params);
             break;
         case 'update':
             $result = CHost::update($params);
             break;
         case 'massUpdate':
             $result = CHost::massUpdate($params);
             break;
         case 'delete':
             $result = CHost::delete($params);
             break;
         default:
             self::$result = array('error' => ZBX_API_ERROR_NO_METHOD, 'data' => 'Method: "' . $action . '" doesn\'t exist.');
             return;
             //exit function
     }
     if ($result !== false) {
         self::$result = array('result' => $result);
     } else {
         self::$result = CHost::$error;
     }
 }
Ejemplo n.º 3
0
 if (isset($visible['groups'])) {
     $hosts['groups'] = CHostGroup::get(array('groupids' => get_request('groups', array()), 'editable' => 1, 'output' => API_OUTPUT_SHORTEN));
     if (!empty($newgroup)) {
         $hosts['groups'][] = $newgroup;
     }
 }
 if (isset($visible['template_table_r'])) {
     if (isset($_REQUEST['mass_clear_tpls'])) {
         $host_templates = CTemplate::get(array('hostids' => $hostids));
         $host_templateids = zbx_objectValues($host_templates, 'templateid');
         $templates_to_del = array_diff($host_templateids, $tplids);
         $hosts['templates_clear'] = zbx_toObject($templates_to_del, 'templateid');
     }
     $hosts['templates'] = $templates;
 }
 $result = CHost::massUpdate(array_merge($hosts, $new_values));
 if ($result === false) {
     throw new Exception();
 }
 $add = array();
 if (!empty($templates) && isset($visible['template_table'])) {
     $add['templates'] = $templates;
 }
 if (!empty($newgroup) && !isset($visible['groups'])) {
     $add['groups'][] = $newgroup;
 }
 if (!empty($add)) {
     $add['hosts'] = $hosts['hosts'];
     $result = CHost::massAdd($add);
     if ($result === false) {
         throw new Exception();