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


PHP Dept::getIdByName方法代码示例

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


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

示例1: save

 function save($id, $vars, &$errors)
 {
     global $cfg;
     if ($id && $id != $vars['id']) {
         $errors['err'] = __('Missing or invalid Dept ID (internal error).');
     }
     if (!$vars['name']) {
         $errors['name'] = __('Name required');
     } elseif (strlen($vars['name']) < 4) {
         $errors['name'] = __('Name is too short.');
     } elseif (($did = Dept::getIdByName($vars['name'])) && $did != $id) {
         $errors['name'] = __('Department already exists');
     }
     if (!$vars['ispublic'] && $cfg && $vars['id'] == $cfg->getDefaultDeptId()) {
         $errors['ispublic'] = __('System default department cannot be private');
     }
     if ($errors) {
         return false;
     }
     $sql = 'SET updated=NOW() ' . ' ,ispublic=' . db_input(isset($vars['ispublic']) ? $vars['ispublic'] : 0) . ' ,email_id=' . db_input(isset($vars['email_id']) ? $vars['email_id'] : 0) . ' ,tpl_id=' . db_input(isset($vars['tpl_id']) ? $vars['tpl_id'] : 0) . ' ,sla_id=' . db_input(isset($vars['sla_id']) ? $vars['sla_id'] : 0) . ' ,autoresp_email_id=' . db_input(isset($vars['autoresp_email_id']) ? $vars['autoresp_email_id'] : 0) . ' ,manager_id=' . db_input($vars['manager_id'] ? $vars['manager_id'] : 0) . ' ,dept_name=' . db_input(Format::striptags($vars['name'])) . ' ,dept_signature=' . db_input(Format::sanitize($vars['signature'])) . ' ,group_membership=' . db_input($vars['group_membership']) . ' ,ticket_auto_response=' . db_input(isset($vars['ticket_auto_response']) ? $vars['ticket_auto_response'] : 1) . ' ,message_auto_response=' . db_input(isset($vars['message_auto_response']) ? $vars['message_auto_response'] : 1);
     if ($id) {
         $sql = 'UPDATE ' . DEPT_TABLE . ' ' . $sql . ' WHERE dept_id=' . db_input($id);
         if (db_query($sql) && db_affected_rows()) {
             return true;
         }
         $errors['err'] = sprintf(__('Unable to update %s.'), __('this department')) . ' ' . __('Internal error occurred');
     } else {
         if (isset($vars['id'])) {
             $sql .= ', dept_id=' . db_input($vars['id']);
         }
         $sql = 'INSERT INTO ' . DEPT_TABLE . ' ' . $sql . ',created=NOW()';
         if (db_query($sql) && ($id = db_insert_id())) {
             return $id;
         }
         $errors['err'] = sprintf(__('Unable to create %s.'), __('this department')) . ' ' . __('Internal error occurred');
     }
     return false;
 }
开发者ID:dmiguel92,项目名称:osTicket-1.8,代码行数:38,代码来源:class.dept.php

示例2: save

 function save($id, $vars, &$errors)
 {
     global $cfg;
     if ($id && $id != $vars['id']) {
         $errors['err'] = 'Missing or invalid Dept ID (internal error).';
     }
     if (!$vars['email_id'] || !is_numeric($vars['email_id'])) {
         $errors['email_id'] = 'Email selection required';
     }
     if (!is_numeric($vars['tpl_id'])) {
         $errors['tpl_id'] = 'Template selection required';
     }
     if (!$vars['name']) {
         $errors['name'] = 'Name required';
     } elseif (strlen($vars['name']) < 4) {
         $errors['name'] = 'Name is too short.';
     } elseif (($did = Dept::getIdByName($vars['name'])) && $did != $id) {
         $errors['name'] = 'Department already exist';
     }
     if (!$vars['ispublic'] && $vars['id'] == $cfg->getDefaultDeptId()) {
         $errors['ispublic'] = 'System default department can not be private';
     }
     if ($errors) {
         return false;
     }
     $sql = 'SET updated=NOW() ' . ' ,ispublic=' . db_input($vars['ispublic']) . ' ,email_id=' . db_input($vars['email_id']) . ' ,tpl_id=' . db_input($vars['tpl_id']) . ' ,sla_id=' . db_input($vars['sla_id']) . ' ,autoresp_email_id=' . db_input($vars['autoresp_email_id']) . ' ,manager_id=' . db_input($vars['manager_id'] ? $vars['manager_id'] : 0) . ' ,dept_name=' . db_input(Format::striptags($vars['name'])) . ' ,dept_signature=' . db_input(Format::striptags($vars['signature'])) . ' ,ticket_auto_response=' . db_input(isset($vars['ticket_auto_response']) ? $vars['ticket_auto_response'] : 1) . ' ,message_auto_response=' . db_input(isset($vars['message_auto_response']) ? $vars['message_auto_response'] : 1);
     if ($id) {
         $sql = 'UPDATE ' . DEPT_TABLE . ' ' . $sql . ' WHERE dept_id=' . db_input($id);
         if (db_query($sql) && db_affected_rows()) {
             return true;
         }
         $errors['err'] = 'Unable to update ' . Format::htmlchars($vars['name']) . ' Dept. Error occurred';
     } else {
         $sql = 'INSERT INTO ' . DEPT_TABLE . ' ' . $sql . ',created=NOW()';
         if (db_query($sql) && ($id = db_insert_id())) {
             return $id;
         }
         $errors['err'] = 'Unable to create department. Internal error';
     }
     return false;
 }
开发者ID:nicolap,项目名称:osTicket-1.7,代码行数:41,代码来源:class.dept.php


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