當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。