/** * Mass update hosts * * @param _array $hosts multidimensional array with Hosts data * @param array $hosts['hosts'] Array of Host objects to update * @param string $hosts['fields']['host'] Host name. * @param array $hosts['fields']['groupids'] HostGroup IDs add Host to. * @param int $hosts['fields']['port'] Port. OPTIONAL * @param int $hosts['fields']['status'] Host Status. OPTIONAL * @param int $hosts['fields']['useip'] Use IP. OPTIONAL * @param string $hosts['fields']['dns'] DNS. OPTIONAL * @param string $hosts['fields']['ip'] IP. OPTIONAL * @param int $hosts['fields']['proxy_hostid'] Proxy Host ID. OPTIONAL * @param int $hosts['fields']['useipmi'] Use IPMI. OPTIONAL * @param string $hosts['fields']['ipmi_ip'] IPMAI IP. OPTIONAL * @param int $hosts['fields']['ipmi_port'] IPMI port. OPTIONAL * @param int $hosts['fields']['ipmi_authtype'] IPMI authentication type. OPTIONAL * @param int $hosts['fields']['ipmi_privilege'] IPMI privilege. OPTIONAL * @param string $hosts['fields']['ipmi_username'] IPMI username. OPTIONAL * @param string $hosts['fields']['ipmi_password'] IPMI password. OPTIONAL * @return boolean */ public static function massUpdate($data) { $hosts = zbx_toArray($data['hosts']); $hostids = zbx_objectValues($hosts, 'hostid'); try { self::BeginTransaction(__METHOD__); $options = array('hostids' => $hostids, 'editable' => 1, 'output' => API_OUTPUT_EXTEND, 'preservekeys' => 1); $upd_hosts = self::get($options); foreach ($hosts as $hnum => $host) { if (!isset($upd_hosts[$host['hostid']])) { self::exception(ZBX_API_ERROR_PERMISSIONS, S_NO_PERMISSION); } } // CHECK IF HOSTS HAVE AT LEAST 1 GROUP {{{ if (isset($data['groups']) && empty($data['groups'])) { self::exception(ZBX_API_ERROR_PARAMETERS, 'No groups for hosts'); } // }}} CHECK IF HOSTS HAVE AT LEAST 1 GROUP // UPDATE HOSTS PROPERTIES {{{ if (isset($data['host'])) { if (count($hosts) > 1) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Cannot mass update host name'); } $cur_host = reset($hosts); $options = array('filter' => array('host' => $cur_host['host']), 'output' => API_OUTPUT_SHORTEN, 'editable' => 1, 'nopermissions' => 1); $host_exists = self::get($options); $host_exist = reset($host_exists); if ($host_exist && $host_exist['hostid'] != $cur_host['hostid']) { self::exception(ZBX_API_ERROR_PARAMETERS, S_HOST . ' [ ' . $data['host'] . ' ] ' . S_ALREADY_EXISTS_SMALL); } //can't add host with the same name as existing template if (CTemplate::exists(array('host' => $cur_host['host']))) { self::exception(ZBX_API_ERROR_PARAMETERS, S_TEMPLATE . ' [ ' . $cur_host['host'] . ' ] ' . S_ALREADY_EXISTS_SMALL); } } if (isset($data['host']) && !preg_match('/^' . ZBX_PREG_HOST_FORMAT . '$/i', $data['host'])) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Incorrect characters used for Hostname [ ' . $data['host'] . ' ]'); } if (isset($data['dns']) && !empty($data['dns']) && !preg_match('/^' . ZBX_PREG_DNS_FORMAT . '$/i', $data['dns'])) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Incorrect characters used for DNS [ ' . $data['dns'] . ' ]'); } $sql_set = array(); if (isset($data['proxy_hostid'])) { $sql_set[] = 'proxy_hostid=' . $data['proxy_hostid']; } if (isset($data['host'])) { $sql_set[] = 'host=' . zbx_dbstr($data['host']); } if (isset($data['port'])) { $sql_set[] = 'port=' . $data['port']; } if (isset($data['status'])) { $sql_set[] = 'status=' . $data['status']; } if (isset($data['useip'])) { $sql_set[] = 'useip=' . $data['useip']; } if (isset($data['dns'])) { $sql_set[] = 'dns=' . zbx_dbstr($data['dns']); } if (isset($data['ip'])) { $sql_set[] = 'ip=' . zbx_dbstr($data['ip']); } if (isset($data['useipmi'])) { $sql_set[] = 'useipmi=' . $data['useipmi']; } if (isset($data['ipmi_port'])) { $sql_set[] = 'ipmi_port=' . $data['ipmi_port']; } if (isset($data['ipmi_authtype'])) { $sql_set[] = 'ipmi_authtype=' . $data['ipmi_authtype']; } if (isset($data['ipmi_privilege'])) { $sql_set[] = 'ipmi_privilege=' . $data['ipmi_privilege']; } if (isset($data['ipmi_username'])) { $sql_set[] = 'ipmi_username='******'ipmi_username']); } if (isset($data['ipmi_password'])) { $sql_set[] = 'ipmi_password='******'ipmi_password']); } if (isset($data['ipmi_ip'])) { $sql_set[] = 'ipmi_ip=' . zbx_dbstr($data['ipmi_ip']); } if (!empty($sql_set)) { $sql = 'UPDATE hosts SET ' . implode(', ', $sql_set) . ' WHERE ' . DBcondition('hostid', $hostids); $result = DBexecute($sql); if (isset($data['status'])) { update_host_status($hostids, $data['status']); } } // }}} UPDATE HOSTS PROPERTIES // UPDATE HOSTGROUPS LINKAGE {{{ if (isset($data['groups']) && !is_null($data['groups'])) { $data['groups'] = zbx_toArray($data['groups']); $host_groups = CHostGroup::get(array('hostids' => $hostids)); $host_groupids = zbx_objectValues($host_groups, 'groupid'); $new_groupids = zbx_objectValues($data['groups'], 'groupid'); $groups_to_add = array_diff($new_groupids, $host_groupids); if (!empty($groups_to_add)) { $result = self::massAdd(array('hosts' => $hosts, 'groups' => zbx_toObject($groups_to_add, 'groupid'))); if (!$result) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Can\'t add group'); } } $groupids_to_del = array_diff($host_groupids, $new_groupids); if (!empty($groupids_to_del)) { $result = self::massRemove(array('hostids' => $hostids, 'groupids' => $groupids_to_del)); if (!$result) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Can\'t remove group'); } } } // }}} UPDATE HOSTGROUPS LINKAGE $data['templates_clear'] = isset($data['templates_clear']) ? zbx_toArray($data['templates_clear']) : array(); $cleared_templateids = array(); foreach ($hostids as $hostid) { foreach ($data['templates_clear'] as $tpl) { $result = unlink_template($hostid, $tpl['templateid'], false); if (!$result) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Cannot unlink template [ ' . $tpl['templateid'] . ' ]'); } $cleared_templateids[] = $tpl['templateid']; } } // UPDATE TEMPLATE LINKAGE {{{ if (isset($data['templates']) && !is_null($data['templates'])) { $opt = array('hostids' => $hostids, 'output' => API_OUTPUT_SHORTEN, 'preservekeys' => true); $host_templates = CTemplate::get($opt); $host_templateids = array_keys($host_templates); $new_templateids = zbx_objectValues($data['templates'], 'templateid'); $templates_to_del = array_diff($host_templateids, $new_templateids); $templates_to_del = array_diff($templates_to_del, $cleared_templateids); if (!empty($templates_to_del)) { $result = self::massRemove(array('hostids' => $hostids, 'templateids' => $templates_to_del)); if (!$result) { self::exception(ZBX_API_ERROR_PARAMETERS, S_CANNOT_UNLINK_TEMPLATE); } } $result = self::massAdd(array('hosts' => $hosts, 'templates' => $data['templates'])); if (!$result) { self::exception(ZBX_API_ERROR_PARAMETERS, S_CANNOT_LINK_TEMPLATE); } } // }}} UPDATE TEMPLATE LINKAGE // UPDATE MACROS {{{ if (isset($data['macros']) && !is_null($data['macros'])) { $macrosToAdd = zbx_toHash($data['macros'], 'macro'); $hostMacros = CUserMacro::get(array('hostids' => $hostids, 'output' => API_OUTPUT_EXTEND)); $hostMacros = zbx_toHash($hostMacros, 'macro'); // Delete $macrosToDelete = array(); foreach ($hostMacros as $hmnum => $hmacro) { if (!isset($macrosToAdd[$hmacro['macro']])) { $macrosToDelete[] = $hmacro['macro']; } } // Update $macrosToUpdate = array(); foreach ($macrosToAdd as $nhmnum => $nhmacro) { if (isset($hostMacros[$nhmacro['macro']])) { $macrosToUpdate[] = $nhmacro; unset($macrosToAdd[$nhmnum]); } } //---- if (!empty($macrosToDelete)) { $result = self::massRemove(array('hostids' => $hostids, 'macros' => $macrosToDelete)); if (!$result) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Can\'t remove macro'); } } if (!empty($macrosToUpdate)) { $result = CUsermacro::massUpdate(array('hosts' => $hosts, 'macros' => $macrosToUpdate)); if (!$result) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Cannot update macro'); } } if (!empty($macrosToAdd)) { $result = self::massAdd(array('hosts' => $hosts, 'macros' => $macrosToAdd)); if (!$result) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Cannot add macro'); } } } // }}} UPDATE MACROS // PROFILE {{{ if (isset($data['profile']) && !is_null($data['profile'])) { if (empty($data['profile'])) { $sql = 'DELETE FROM hosts_profiles WHERE ' . DBcondition('hostid', $hostids); if (!DBexecute($sql)) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Cannot delete profile'); } } else { $existing_profiles = array(); $existing_profiles_db = DBselect('SELECT hostid FROM hosts_profiles WHERE ' . DBcondition('hostid', $hostids)); while ($existing_profile = DBfetch($existing_profiles_db)) { $existing_profiles[] = $existing_profile['hostid']; } $hostids_without_profile = array_diff($hostids, $existing_profiles); $fields = array_keys($data['profile']); $fields = implode(', ', $fields); $values = array_map('zbx_dbstr', $data['profile']); $values = implode(', ', $values); foreach ($hostids_without_profile as $hostid) { $sql = 'INSERT INTO hosts_profiles (hostid, ' . $fields . ') VALUES (' . $hostid . ', ' . $values . ')'; if (!DBexecute($sql)) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Cannot create profile'); } } if (!empty($existing_profiles)) { $host_profile_fields = array('devicetype', 'name', 'os', 'serialno', 'tag', 'macaddress', 'hardware', 'software', 'contact', 'location', 'notes'); $sql_set = array(); foreach ($host_profile_fields as $field) { if (isset($data['profile'][$field])) { $sql_set[] = $field . '=' . zbx_dbstr($data['profile'][$field]); } } $sql = 'UPDATE hosts_profiles SET ' . implode(', ', $sql_set) . ' WHERE ' . DBcondition('hostid', $existing_profiles); if (!DBexecute($sql)) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Cannot update profile'); } } } } // }}} PROFILE // EXTENDED PROFILE {{{ if (isset($data['extendedProfile']) && !is_null($data['extendedProfile'])) { if (empty($data['extendedProfile'])) { $sql = 'DELETE FROM hosts_profiles_ext WHERE ' . DBcondition('hostid', $hostids); if (!DBexecute($sql)) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Cannot delete extended profile'); } } else { $existing_profiles = array(); $existing_profiles_db = DBselect('SELECT hostid FROM hosts_profiles_ext WHERE ' . DBcondition('hostid', $hostids)); while ($existing_profile = DBfetch($existing_profiles_db)) { $existing_profiles[] = $existing_profile['hostid']; } $hostids_without_profile = array_diff($hostids, $existing_profiles); $fields = array_keys($data['extendedProfile']); $fields = implode(', ', $fields); $values = array_map('zbx_dbstr', $data['extendedProfile']); $values = implode(', ', $values); foreach ($hostids_without_profile as $hostid) { $sql = 'INSERT INTO hosts_profiles_ext (hostid, ' . $fields . ') VALUES (' . $hostid . ', ' . $values . ')'; if (!DBexecute($sql)) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Cannot create extended profile'); } } if (!empty($existing_profiles)) { $host_profile_ext_fields = array('device_alias', 'device_type', 'device_chassis', 'device_os', 'device_os_short', 'device_hw_arch', 'device_serial', 'device_model', 'device_tag', 'device_vendor', 'device_contract', 'device_who', 'device_status', 'device_app_01', 'device_app_02', 'device_app_03', 'device_app_04', 'device_app_05', 'device_url_1', 'device_url_2', 'device_url_3', 'device_networks', 'device_notes', 'device_hardware', 'device_software', 'ip_subnet_mask', 'ip_router', 'ip_macaddress', 'oob_ip', 'oob_subnet_mask', 'oob_router', 'date_hw_buy', 'date_hw_install', 'date_hw_expiry', 'date_hw_decomm', 'site_street_1', 'site_street_2', 'site_street_3', 'site_city', 'site_state', 'site_country', 'site_zip', 'site_rack', 'site_notes', 'poc_1_name', 'poc_1_email', 'poc_1_phone_1', 'poc_1_phone_2', 'poc_1_cell', 'poc_1_screen', 'poc_1_notes', 'poc_2_name', 'poc_2_email', 'poc_2_phone_1', 'poc_2_phone_2', 'poc_2_cell', 'poc_2_screen', 'poc_2_notes'); $sql_set = array(); foreach ($host_profile_ext_fields as $field) { if (isset($data['extendedProfile'][$field])) { $sql_set[] = $field . '=' . zbx_dbstr($data['extendedProfile'][$field]); } } $sql = 'UPDATE hosts_profiles_ext SET ' . implode(', ', $sql_set) . ' WHERE ' . DBcondition('hostid', $existing_profiles); if (!DBexecute($sql)) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Cannot update extended profile'); } } } } // }}} EXTENDED PROFILE self::EndTransaction(true, __METHOD__); return array('hostids' => $hostids); } catch (APIException $e) { self::EndTransaction(false, __METHOD__); $error = $e->getErrors(); $error = reset($error); self::setError(__METHOD__, $e->getCode(), $error); return false; } }
/* if we are only allowed to use an snmp check and this host does not support snnp, we must assume that this host is up */ if (($ping_availability == AVAIL_SNMP) && ($item["snmp_community"] == "")) { $host_down = false; update_host_status(HOST_UP, $host_id, $hosts, $ping, $ping_availability, $print_data_to_stdout); if (read_config_option("log_verbosity") >= POLLER_VERBOSITY_MEDIUM) { cacti_log("Host[$host_id] No host availability check possible for '" . $item["hostname"] . "'.", $print_data_to_stdout); } }else{ if ($ping->ping($ping_availability, read_config_option("ping_method"), read_config_option("ping_timeout"), read_config_option("ping_retries"))) { $host_down = false; update_host_status(HOST_UP, $host_id, $hosts, $ping, $ping_availability, $print_data_to_stdout); }else{ $host_down = true; update_host_status(HOST_DOWN, $host_id, $hosts, $ping, $ping_availability, $print_data_to_stdout); } } if (!$host_down) { /* do the reindex check for this host */ $reindex = db_fetch_assoc("select poller_reindex.data_query_id, poller_reindex.action, poller_reindex.op, poller_reindex.assert_value, poller_reindex.arg1 from poller_reindex where poller_reindex.host_id=" . $item["host_id"]); if ((sizeof($reindex) > 0) && (!$host_down)) {
} $result = DBend($result); show_messages(true, S_GROUP_DELETED, S_CANNOT_DELETE_GROUP); } else { if (str_in_array($_REQUEST['go'], array('activate', 'disable'))) { $result = true; $status = $_REQUEST['go'] == 'activate' ? HOST_STATUS_MONITORED : HOST_STATUS_NOT_MONITORED; $groups = get_request('groups', array()); $db_hosts = DBselect('select h.hostid, hg.groupid ' . ' from hosts_groups hg, hosts h' . ' where h.hostid=hg.hostid ' . ' and h.status in (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ')' . ' and ' . DBin_node('h.hostid')); DBstart(); while ($db_host = DBfetch($db_hosts)) { if (!uint_in_array($db_host['groupid'], $groups)) { continue; } $host = get_host_by_hostid($db_host['hostid']); $result &= update_host_status($db_host['hostid'], $status); /* add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_HOST, 'Old status ['.$host['status'].'] '.'New status ['.$status.']');*/ } $result = DBend($result); show_messages($result, S_HOST_STATUS_UPDATED, S_CANNOT_UPDATE_HOST); unset($_REQUEST['activate']); } } } } } /*** --->>> ACTIONS <<<--- ***/ $frmForm = new CForm(); $frmForm->setMethod('get'); if (!isset($_REQUEST['form'])) {
/* assume we don't have to spike prevent */ $set_spike_kill = false; $host_update_time = date("Y-m-d H:i:s"); // for poller update time } $host_id = $item["host_id"]; if ($new_host && !empty($host_id)) { $ping->host = $item; $ping->port = $hosts[$host_id]["ping_port"]; /* perform the appropriate ping check of the host */ if ($ping->ping($hosts[$host_id]["availability_method"], $hosts[$host_id]["ping_method"], $hosts[$host_id]["ping_timeout"], $hosts[$host_id]["ping_retries"])) { $host_down = false; update_host_status(HOST_UP, $host_id, $hosts, $ping, $hosts[$host_id]["availability_method"], $print_data_to_stdout); } else { $host_down = true; update_host_status(HOST_DOWN, $host_id, $hosts, $ping, $hosts[$host_id]["availability_method"], $print_data_to_stdout); } if (!$host_down) { /* do the reindex check for this host */ $reindex = db_fetch_assoc("select\n\t\t\t\t\tpoller_reindex.data_query_id,\n\t\t\t\t\tpoller_reindex.action,\n\t\t\t\t\tpoller_reindex.op,\n\t\t\t\t\tpoller_reindex.assert_value,\n\t\t\t\t\tpoller_reindex.arg1\n\t\t\t\t\tfrom poller_reindex\n\t\t\t\t\twhere poller_reindex.host_id=" . $item["host_id"]); if (sizeof($reindex) > 0 && !$host_down) { if (read_config_option("log_verbosity") == POLLER_VERBOSITY_DEBUG) { cacti_log("Host[{$host_id}] RECACHE: Processing " . sizeof($reindex) . " items in the auto reindex cache for '" . $item["hostname"] . "'.", $print_data_to_stdout); } foreach ($reindex as $index_item) { $assert_fail = false; /* do the check */ switch ($index_item["action"]) { case POLLER_ACTION_SNMP: /* snmp */ $output = cacti_snmp_get($item["hostname"], $item["snmp_community"], $index_item["arg1"], $item["snmp_version"], $item["snmp_username"], $item["snmp_password"], $item["snmp_auth_protocol"], $item["snmp_priv_passphrase"], $item["snmp_priv_protocol"], $item["snmp_context"], $item["snmp_port"], $item["snmp_timeout"], read_config_option("snmp_retries"), SNMP_CMDPHP);
function db_save_host($host, $port, $status, $useip, $dns, $ip, $proxy_hostid, $templates, $useipmi, $ipmi_ip, $ipmi_port, $ipmi_authtype, $ipmi_privilege, $ipmi_username, $ipmi_password, $hostid = null) { if (!eregi('^' . ZBX_EREG_HOST_FORMAT . '$', $host)) { error("Incorrect characters used for Hostname"); return false; } if (!empty($dns) && !eregi('^' . ZBX_EREG_DNS_FORMAT . '$', $dns)) { error("Incorrect characters used for DNS"); return false; } if (DBfetch(DBselect('SELECT h.host ' . ' FROM hosts h ' . ' WHERE h.host=' . zbx_dbstr($host) . ' AND ' . DBin_node('h.hostid', get_current_nodeid(false)) . ' AND status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ',' . HOST_STATUS_TEMPLATE . ')' . (isset($hostid) ? ' AND h.hostid<>' . $hostid : '')))) { error("Host '{$host}' already exists"); return false; } if (is_null($hostid)) { $hostid = get_dbid('hosts', 'hostid'); $result = DBexecute('INSERT INTO hosts ' . ' (hostid,proxy_hostid,host,port,status,useip,dns,ip,disable_until,available,useipmi,ipmi_port,ipmi_authtype,ipmi_privilege,ipmi_username,ipmi_password,ipmi_ip) ' . ' VALUES (' . $hostid . ',' . $proxy_hostid . ',' . zbx_dbstr($host) . ',' . $port . ',' . $status . ',' . $useip . ',' . zbx_dbstr($dns) . ',' . zbx_dbstr($ip) . ',0,' . HOST_AVAILABLE_UNKNOWN . ',' . ($useipmi == 'yes' ? 1 : 0) . ',' . $ipmi_port . ',' . $ipmi_authtype . ',' . $ipmi_privilege . ',' . zbx_dbstr($ipmi_username) . ',' . zbx_dbstr($ipmi_password) . ',' . zbx_dbstr($ipmi_ip) . ')'); if ($result) { add_audit_ext(AUDIT_ACTION_ADD, AUDIT_RESOURCE_HOST, $hostid, $host, 'hosts', NULL, NULL); } } else { if (check_circle_host_link($hostid, $templates)) { error("Circle link can't be created"); return false; } $host_old = get_host_by_hostid($hostid); $result = DBexecute('UPDATE hosts SET proxy_hostid=' . $proxy_hostid . ',host=' . zbx_dbstr($host) . ',port=' . $port . ',useip=' . $useip . ',dns=' . zbx_dbstr($dns) . ',ip=' . zbx_dbstr($ip) . ',useipmi=' . ($useipmi == 'yes' ? 1 : 0) . ',ipmi_port=' . $ipmi_port . ',ipmi_authtype=' . $ipmi_authtype . ',ipmi_privilege=' . $ipmi_privilege . ',ipmi_username='******',ipmi_password='******',ipmi_ip=' . zbx_dbstr($ipmi_ip) . ' WHERE hostid=' . $hostid); if ($result) { $host_new = get_host_by_hostid($hostid); add_audit_ext(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_HOST, $hostid, $host_old['host'], 'hosts', $host_old, $host_new); } update_host_status($hostid, $status); } foreach ($templates as $id => $name) { $hosttemplateid = get_dbid('hosts_templates', 'hosttemplateid'); if (!($result = DBexecute('INSERT INTO hosts_templates VALUES (' . $hosttemplateid . ',' . $hostid . ',' . $id . ')'))) { break; } } if ($result) { $result = $hostid; } return $result; }
$result = delete_host($del_hosts, $unlink_mode); $result = DBend($result); show_messages($result, S_HOST_DELETED, S_CANNOT_DELETE_HOST); } else { if (str_in_array($_REQUEST['go'], array('activate', 'disable'))) { $result = true; $status = $_REQUEST['go'] == 'activate' ? HOST_STATUS_MONITORED : HOST_STATUS_NOT_MONITORED; $hosts = get_request('hosts', array()); $act_hosts = array(); $sql = 'SELECT host,hostid,status ' . ' FROM hosts ' . ' WHERE ' . DBin_node('hostid') . ' AND ' . DBcondition('hostid', $hosts) . ' AND ' . DBcondition('hostid', $available_hosts); $db_hosts = DBselect($sql); DBstart(); while ($db_host = DBfetch($db_hosts)) { $act_hosts[$db_host['hostid']] = $db_host['hostid']; } $result = update_host_status($act_hosts, $status); $result = DBend($result); show_messages($result, S_HOST_STATUS_UPDATED, S_CANNOT_UPDATE_HOST); } } } } } } } } } $params = array(); $options = array('only_current_node'); if (isset($_REQUEST['form']) || isset($_REQUEST['massupdate'])) { array_push($options, 'do_not_select_if_empty');