private static function template($action, $params) { CTemplate::$error = array(); switch ($action) { default: $result = call_user_func(array('CTemplate', $action), $params); } self::$result = $result; }
private static function template($action, $params) { CTemplate::$error = array(); switch ($action) { case 'add': $result = CTemplate::add($params); break; case 'get': $result = CTemplate::get($params); break; case 'getById': $result = CTemplate::getById($params); break; case 'getId': $result = CTemplate::getId($params); break; case 'update': $result = CTemplate::update($params); break; case 'linkHosts': $result = CTemplate::linkHosts($params); break; case 'unlinkHosts': $result = CTemplate::unlinkHosts($params); break; case 'linkTemplates': $result = CTemplate::linkTemplates($params); break; case 'unlinkTemplates': $result = CTemplate::unlinkTemplates($params); break; case 'delete': $result = CTemplate::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 = CTemplate::$error; } }
/** * Unlink Templates from Host * * {@source} * @access public * @static * @since 1.8 * @version 1 * * @param string $data * @param string $data['templateid'] * @param array $data['hostids'] * @param boolean $data['clean'] whether to wipe all info from template elements. * @return boolean */ public static function unlinkTemplates($data) { $templateid = $data['templateid']; $hostids = $data['hostids']; $clean = isset($data['clean']); $result = delete_template_elements($hostid, $templateids, $clean); $result &= DBexecute('DELETE FROM hosts_templates WHERE hostid=' . $hostid . ' AND ' . DBcondition('templateid', $templateids)); if ($result) { return true; } else { self::$error = array('error' => ZBX_API_ERROR_INTERNAL, 'data' => $error); return false; } }