当前位置: 首页>>代码示例>>PHP>>正文


PHP CTemplate::update方法代码示例

本文整理汇总了PHP中CTemplate::update方法的典型用法代码示例。如果您正苦于以下问题:PHP CTemplate::update方法的具体用法?PHP CTemplate::update怎么用?PHP CTemplate::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CTemplate的用法示例。


在下文中一共展示了CTemplate::update方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: template

 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;
     }
 }
开发者ID:phedders,项目名称:zabbix,代码行数:45,代码来源:class.czbxrpc.php

示例2: zbx_toObject

 $templates = zbx_toObject($templates, 'templateid');
 $templates_clear = zbx_toObject($templates_clear, 'templateid');
 $hosts = zbx_toObject($hosts, 'hostid');
 $macros = get_request('macros', array());
 foreach ($macros as $mnum => $macro) {
     if (zbx_empty($macro['value'])) {
         unset($macros[$mnum]);
     }
 }
 $template = array('host' => $template_name, 'groups' => $groups, 'templates' => $templates, 'hosts' => $hosts, 'macros' => $macros);
 // CREATE/UPDATE TEMPLATE {{{
 if ($templateid) {
     $created = 0;
     $template['templateid'] = $templateid;
     $template['templates_clear'] = $templates_clear;
     $result = CTemplate::update($template);
     if (!$result) {
         error(CTemplate::resetErrors());
         $result = false;
     }
     $msg_ok = S_TEMPLATE_UPDATED;
     $msg_fail = S_CANNOT_UPDATE_TEMPLATE;
 } else {
     $created = 1;
     $result = CTemplate::create($template);
     if ($result) {
         $templateid = reset($result['templateids']);
     } else {
         error(CTemplate::resetErrors());
         $result = false;
     }
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:31,代码来源:templates.php

示例3: parseMain


//.........这里部分代码省略.........
                         $host_db['macros'][] = self::mapXML2arr($macro, XML_TAG_MACRO);
                     }
                 }
                 // }}} MACROS
                 // TEMPLATES {{{
                 if (isset($rules['template']['exist'])) {
                     $templates = $xpath->query('templates/template', $host);
                     $host_db['templates'] = array();
                     foreach ($templates as $tnum => $template) {
                         $options = array('filter' => array('host' => $template->nodeValue), 'output' => API_OUTPUT_EXTEND, 'editable' => 1);
                         $current_template = CTemplate::get($options);
                         if (empty($current_template)) {
                             throw new APIException(1, 'No permission for Template [' . $template->nodeValue . ']');
                         }
                         $current_template = reset($current_template);
                         if (!$current_template && !isset($rules['template']['missed'])) {
                             info('Template [' . $template->nodeValue . '] skipped - user rule');
                             continue;
                             // break if update nonexist
                         }
                         if ($current_template && !isset($rules['template']['exist'])) {
                             info('Template [' . $template->nodeValue . '] skipped - user rule');
                             continue;
                             // break if not update exist
                         }
                         $host_db['templates'][] = $current_template;
                     }
                 }
                 // }}} TEMPLATES
                 // HOSTS
                 if ($current_host && isset($rules['host']['exist'])) {
                     if ($host_db['status'] == HOST_STATUS_TEMPLATE) {
                         $host_db['templateid'] = $current_host['hostid'];
                         $result = CTemplate::update($host_db);
                         if (!$result) {
                             throw new APIException(1, CTemplate::resetErrors());
                         }
                         $options = array('templateids' => $result['templateids'], 'output' => API_OUTPUT_EXTEND);
                         $current_host = CTemplate::get($options);
                     } else {
                         $host_db['hostid'] = $current_host['hostid'];
                         $result = CHost::update($host_db);
                         if (!$result) {
                             throw new APIException(1, CHost::resetErrors());
                         }
                         $options = array('hostids' => $result['hostids'], 'output' => API_OUTPUT_EXTEND);
                         $current_host = CHost::get($options);
                     }
                     if ($current_host === false) {
                         throw new APIException(1, $host_db['status'] == HOST_STATUS_TEMPLATE ? CTemplate::resetErrors() : CHost::resetErrors());
                     }
                 }
                 if (!$current_host && isset($rules['host']['missed'])) {
                     if ($host_db['status'] == HOST_STATUS_TEMPLATE) {
                         $result = CTemplate::create($host_db);
                         if (!$result) {
                             throw new APIException(1, CTemplate::resetErrors());
                         }
                         $options = array('templateids' => $result['templateids'], 'output' => API_OUTPUT_EXTEND);
                         $current_host = CTemplate::get($options);
                     } else {
                         $result = CHost::create($host_db);
                         if (!$result) {
                             throw new APIException(1, CHost::resetErrors());
                         }
                         $options = array('hostids' => $result['hostids'], 'output' => API_OUTPUT_EXTEND);
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:67,代码来源:export.inc.php

示例4: foreach

 // CREATE NEW GROUP
 if (!empty($newgroup)) {
     if ($groupid = CHostGroup::add(array($newgroup))) {
         $groups += $groupid;
     } else {
         $result = false;
     }
 }
 // <<<--- CREATE|UPDATE TEMPLATE WITH GROUPS ANT LINKED TEMPLATES --->>>
 if ($templateid) {
     if (isset($_REQUEST['clear_templates'])) {
         foreach ($_REQUEST['clear_templates'] as $id) {
             $result &= unlink_template($_REQUEST['templateid'], $id, false);
         }
     }
     $result = CTemplate::update(array(array('hostid' => $templateid, 'host' => $template_name)));
     $result &= CHostGroup::updateGroupsToHost(array('hostid' => $templateid, 'groupids' => $groups));
     $msg_ok = S_TEMPLATE_UPDATED;
     $msg_fail = S_CANNOT_UPDATE_TEMPLATE;
 } else {
     if ($result = CTemplate::add(array(array('host' => $template_name, 'groupids' => $groups)))) {
         $templateid = reset($result);
     } else {
         $result = false;
     }
     $msg_ok = S_TEMPLATE_ADDED;
     $msg_fail = S_CANNOT_ADD_TEMPLATE;
 }
 if ($result) {
     $original_templates = get_templates_by_hostid($templateid);
     $original_templates = array_keys($original_templates);
开发者ID:phedders,项目名称:zabbix,代码行数:31,代码来源:templates.php


注:本文中的CTemplate::update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。