本文整理汇总了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;
}
示例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;
}