本文整理汇总了PHP中Whups::formatUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Whups::formatUser方法的具体用法?PHP Whups::formatUser怎么用?PHP Whups::formatUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Whups
的用法示例。
在下文中一共展示了Whups::formatUser方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(&$vars)
{
global $whups_driver, $conf;
parent::__construct($vars, _("Create Ticket - Step 4"));
/* Preserve previously uploaded attachments. */
$this->addHidden('', 'deferred_attachment', 'text', false);
/* Groups. */
$mygroups = $GLOBALS['injector']->getInstance('Horde_Group')->listAll($conf['prefs']['assign_all_groups'] ? null : $GLOBALS['registry']->getAuth());
asort($mygroups);
$users = $whups_driver->getQueueUsers($vars->get('queue'));
$f_users = array();
foreach ($users as $user) {
$f_users['user:' . $user] = Whups::formatUser($user);
}
$f_groups = array();
if (count($mygroups)) {
foreach ($mygroups as $id => $group) {
$f_groups['group:' . $id] = $group;
}
}
if (count($f_users)) {
asort($f_users);
$owners = $this->addVariable(_("Owners"), 'owners', 'multienum', false, false, null, array($f_users));
}
if (count($f_groups)) {
asort($f_groups);
$group_owners = $this->addVariable(_("Group Owners"), 'group_owners', 'multienum', false, false, null, array($f_groups));
}
if (!count($f_users) && !count($f_groups)) {
$owner_params = array(_("There are no users to which this ticket can be assigned."));
$this->addVariable(_("Owners"), 'owners', 'invalid', false, false, null, $owner_params);
}
}
示例2: __construct
public function __construct(&$vars)
{
global $whups_driver, $registry;
parent::__construct($vars);
$queue = $vars->get('queue');
try {
$info = $whups_driver->getQueue($queue);
} catch (Whups_Exception $e) {
$this->addVariable(_("Invalid Queue"), 'invalid', 'invalid', true, false, null, array(_("Invalid Queue")));
return;
}
$this->setTitle(sprintf(_("Edit %s"), $info['name']));
$this->addHidden('', 'queue', 'int', true, true);
$mname = $this->addVariable(_("Queue Name"), 'name', 'text', true, $info['readonly']);
$mname->setDefault($info['name']);
$mdesc = $this->addVariable(_("Queue Description"), 'description', 'text', true, $info['readonly']);
$mdesc->setDefault($info['description']);
$mslug = $this->addVariable(_("Queue Slug"), 'slug', 'text', false, $info['readonly']);
$mslug->setDefault($info['slug']);
$memail = $this->addVariable(_("Queue Email"), 'email', 'email', false, $info['readonly']);
$memail->setDefault($info['email']);
$types = $whups_driver->getAllTypes();
$mtypes = $this->addVariable(_("Ticket Types associated with this Queue"), 'types', 'set', true, false, null, array($types));
$mtypes->setDefault(array_keys($whups_driver->getTypes($queue)));
$mdefaults = $this->addVariable(_("Default Ticket Type"), 'default', 'enum', false, false, null, array($types));
$mdefaults->setDefault($whups_driver->getDefaultType($queue));
/* Versioned and version link. */
$mversioned = $this->addVariable(_("Keep a set of versions for this queue?"), 'versioned', 'boolean', false, $info['readonly']);
$mversioned->setDefault($info['versioned']);
if ($registry->hasMethod('tickets/listVersions') == $registry->getApp()) {
$versionlink = array('text' => _("Edit the versions for this queue"), 'url' => Horde::url('admin/?formname=whups_form_admin_editversionstepone')->add('queue', $queue));
$this->addVariable('', 'link', 'link', false, true, null, array($versionlink));
}
/* Usertype and usertype link. */
$users = $whups_driver->getQueueUsers($queue);
$f_users = array();
foreach ($users as $user) {
$f_users[$user] = Whups::formatUser($user);
}
asort($f_users);
$musers = $this->addVariable(_("Users responsible for this Queue"), 'users', 'set', false, true, null, array($f_users));
$musers->setDefault($whups_driver->getQueueUsers($queue));
$userlink = array('text' => _("Edit the users responsible for this queue"), 'url' => Horde::url('admin/?formname=edituserform')->add('queue', $queue));
$this->addVariable('', 'link', 'link', false, true, null, array($userlink));
/* Permissions link. */
if ($GLOBALS['registry']->isAdmin(array('permission' => 'whups:admin', 'permlevel' => Horde_Perms::EDIT))) {
$permslink = array('text' => _("Edit the permissions on this queue"), 'url' => Horde::url('admin/perms/edit.php', false, array('app' => 'horde'))->add(array('category' => 'whups:queues:' . $queue, 'autocreate' => '1')));
$this->addVariable('', 'link', 'link', false, true, null, array($permslink));
}
}
示例3: getDataSet
/**
* Get the data set
*
* @param string $report The report
*
* @return array The dataset
*/
public function getDataSet($report)
{
$operation = 'inc';
$state = null;
list($type, $field) = explode('|', $report);
if (substr($type, 0, 1) == '@') {
list($type, $operation, $state) = explode(':', substr($type, 1));
}
$tickets = $this->_getTicketSet($type, $field == 'owner');
if (substr($field, 0, 7) == 'user_id' || $field == 'owner') {
$user = true;
} else {
$user = false;
}
$dataset = array();
foreach ($tickets as $info) {
switch ($state) {
case 'open':
$date1 = new Horde_Date($info['date_resolved']);
$newdata = $date1->diff(new Horde_Date($info['timestamp']));
break;
default:
$newdata = 1;
}
if (empty($info[$field])) {
$this->_updateDataSet($dataset, _("None"), $newdata, $operation);
} else {
if ($user) {
$col = Whups::formatUser($info[$field], false);
} else {
$col = $info[$field];
}
$this->_updateDataSet($dataset, $col, $newdata, $operation);
}
}
// Perform any necessary post-processing on the dataset - process
// averages, for example.
switch ($operation) {
case 'avg':
foreach ($dataset as $index => $data) {
$dataset[$index] = number_format(array_sum($data) / count($data), 2);
}
break;
}
// Sort
ksort($dataset);
// Return the final data.
return $dataset;
}
示例4: __construct
public function __construct(&$vars)
{
global $whups_driver;
$this->appendButtons(array(array('class' => 'horde-delete', 'value' => _("Remove User"))));
parent::__construct($vars, _("Responsible Users"));
$queue = $vars->get('queue');
$users = $whups_driver->getQueueUsers($queue);
$f_users = array();
foreach ($users as $user) {
$f_users[$user] = Whups::formatUser($user);
}
if ($f_users) {
asort($f_users);
$usertype = 'enum';
$type_params = array($f_users);
} else {
$usertype = 'invalid';
$type_params = array(_("There are no users responsible for this queue."));
}
$this->addHidden('', 'queue', 'int', true, true);
$this->addVariable(_("Users responsible for this queue"), 'user', $usertype, true, false, null, $type_params);
}
示例5: _open
_open();
$form1->renderActive($renderer, $vars, $adminurl, 'post');
echo '<br />';
$vars = new Horde_Variables(array('queue' => $vars->get('queue')));
$form2 = new Whups_Form_Admin_AddUser($vars);
$form2->renderActive($renderer, $vars, $adminurl, 'post');
break;
case 'whups_form_admin_edituser':
$form = new Whups_Form_Admin_EditUser($vars);
if ($form->validate($vars)) {
$info = $whups_driver->getQueue($vars->get('queue'));
try {
$whups_driver->removeQueueUser($vars->get('queue'), $vars->get('user'));
$notification->push(sprintf(_("\"%s\" is no longer among those responsible for \"%s\""), Whups::formatUser($vars->get('user')), $info['name']), 'horde.success');
} catch (Whups_Exception $e) {
$notification->push(sprintf(_("There was an error removing \"%s\" from the responsible list for \"%s\":"), Whups::formatUser($vars->get('user')), $info['name']) . ' ' . $e->getMessage(), 'horde.error');
}
}
_open();
$vars = new Horde_Variables(array('queue' => $vars->get('queue')));
$form = new Whups_Form_Admin_EditUser($vars);
$form->renderActive($renderer, $vars, $adminurl, 'get');
$form1 = new Whups_Form_Admin_AddUser($vars);
$form1->renderActive($renderer, $vars, $adminurl, 'get');
break;
case 'whups_form_admin_addversion':
$form = new Whups_Form_Admin_AddVersion($vars);
if ($form->validate($vars)) {
try {
$whups_driver->addVersion($vars->get('queue'), $vars->get('name'), $vars->get('description'), $vars->get('active') == 'on');
$queuename = $whups_driver->getQueue($vars->get('queue'));
示例6: getTicketsByProperties
//.........这里部分代码省略.........
// Handle owner properties.
if (isset($info['owner'])) {
$join .= ' INNER JOIN whups_ticket_owners ON whups_tickets.ticket_id = whups_ticket_owners.ticket_id AND ';
if (is_array($info['owner'])) {
$clauses = array();
foreach ($info['owner'] as $owner) {
$clauses[] = 'whups_ticket_owners.ticket_owner = ' . $this->_db->quotestring($owner);
}
$join .= '(' . implode(' OR ', $clauses) . ')';
} else {
$join .= 'whups_ticket_owners.ticket_owner = ' . $this->_db->quotestring($info['owner']);
}
}
if (isset($info['notowner'])) {
if ($info['notowner'] === true) {
// Filter for tickets with no owner.
$join .= ' LEFT JOIN whups_ticket_owners ON whups_tickets.ticket_id = whups_ticket_owners.ticket_id AND whups_ticket_owners.ticket_owner IS NOT NULL';
} else {
$join .= ' LEFT JOIN whups_ticket_owners ON whups_tickets.ticket_id = whups_ticket_owners.ticket_id AND whups_ticket_owners.ticket_owner = ' . $this->_db->quotestring($info['notowner']);
}
$where = $this->_addWhere($where, 1, 'whups_ticket_owners.ticket_id IS NULL');
}
if ($munge) {
$myqueues = $GLOBALS['registry']->hasMethod('tickets/listQueues') == $GLOBALS['registry']->getApp();
$myversions = $GLOBALS['registry']->hasMethod('tickets/listVersions') == $GLOBALS['registry']->getApp();
$fields = "{$fields}, " . 'whups_types.type_name AS type_name, ' . 'whups_states.state_name AS state_name, ' . 'whups_states.state_category AS state_category, ' . 'whups_priorities.priority_name AS priority_name';
$join .= ' INNER JOIN whups_types ON whups_tickets.type_id = whups_types.type_id' . ' INNER JOIN whups_states ON whups_tickets.state_id = whups_states.state_id' . ' INNER JOIN whups_priorities ON whups_tickets.priority_id = whups_priorities.priority_id' . ' INNER JOIN whups_states state2 ON whups_tickets.type_id = state2.type_id';
$groupby .= ', whups_types.type_name, whups_states.state_name, whups_states.state_category';
if ($myversions) {
$versions = array();
$fields .= ', whups_versions.version_name AS version_name' . ', whups_versions.version_description AS version_description' . ', whups_versions.version_active AS version_active';
$join .= ' LEFT JOIN whups_versions ON whups_tickets.version_id = whups_versions.version_id';
$groupby .= ', whups_versions.version_name, whups_versions.version_description, whups_versions.version_active, whups_tickets.version_id';
}
if ($myqueues) {
$queues = array();
$fields .= ', whups_queues.queue_name AS queue_name';
$join .= ' INNER JOIN whups_queues ON whups_tickets.queue_id = whups_queues.queue_id';
$groupby .= ', whups_queues.queue_name';
}
$groupby .= ', whups_priorities.priority_name';
}
if ($perowner) {
$join .= ' LEFT JOIN whups_ticket_owners ON whups_tickets.ticket_id = whups_ticket_owners.ticket_id';
$fields .= ', whups_ticket_owners.ticket_owner AS owner';
$groupby .= ', whups_ticket_owners.ticket_owner';
}
$query = "SELECT {$fields} FROM {$tables}{$join} " . (!empty($where) ? "WHERE {$where} " : '') . 'GROUP BY ' . $groupby;
try {
$info = $this->_db->selectAll($query);
} catch (Horde_Db_Exception $e) {
throw new Whups_Exception($e);
}
if (!count($info)) {
return array();
}
$info = $this->_fromBackend($info);
$tickets = array();
foreach ($info as $ticket) {
if ($munge) {
if (!$myqueues) {
if (!isset($queues[$ticket['queue']])) {
$queues[$ticket['queue']] = $GLOBALS['registry']->call('tickets/getQueueDetails', array($ticket['queue']));
}
$ticket['queue_name'] = $queues[$ticket['queue']]['name'];
if (isset($queues[$ticket['queue']]['link'])) {
$ticket['queue_link'] = $queues[$ticket['queue']]['link'];
}
}
if (!$myversions) {
if (!isset($versions[$ticket['version']])) {
$versions[$ticket['version']] = $GLOBALS['registry']->call('tickets/getVersionDetails', array($ticket['version']));
}
$ticket['version_name'] = $versions[$ticket['version']]['name'];
if (isset($versions[$ticket['version']]['link'])) {
$ticket['version_link'] = $versions[$ticket['version']]['link'];
}
}
$ticket['requester_formatted'] = Whups::formatUser($ticket['user_id_requester'], false, true, true);
}
$tickets[$ticket['id']] = $ticket;
}
foreach ($this->getOwners(array_keys($tickets)) as $id => $owners) {
$tickets[$id]['owners'] = $owners;
foreach ($owners as $owner) {
$tickets[$id]['owners_formatted'][] = Whups::formatUser($owner, false, true, true);
}
}
$attributes = $this->getTicketAttributesWithNames(array_keys($tickets));
foreach ($attributes as $row) {
$attribute_id = 'attribute_' . $row['attribute_id'];
try {
$tickets[$row['id']][$attribute_id] = Horde_Serialize::unserialize($row['attribute_value'], Horde_Serialize::JSON);
} catch (Horde_Serialize_Exception $e) {
$tickets[$row['id']][$attribute_id] = $row['attribute_value'];
}
$tickets[$row['id']][$attribute_id . '_name'] = $row['attribute_name'];
}
return array_values($tickets);
}
示例7: catch
* did not receive this file, see http://www.horde.org/licenses/bsdl.php.
*
* @author Jan Schneider <jan@horde.org>
*/
require_once __DIR__ . '/../lib/Application.php';
Horde_Registry::appInit('whups');
$vars = Horde_Variables::getDefaultVariables();
$ticket = Whups::getCurrentTicket();
$view = $injector->createInstance('Horde_View');
try {
$files = $ticket->listAllAttachments();
} catch (Whups_Exception $e) {
$notification->push($e);
}
if ($files) {
$format = array($prefs->getValue('date_format'), $prefs->getValue('time_format'));
$attachments = Whups::getAttachments($ticket->getId());
$view->attachments = array();
foreach ($files as $file) {
$view->attachments[] = array_merge(array('timestamp' => $file['timestamp'], 'date' => strftime($format[0], $file['timestamp']) . ' ' . strftime($format[1], $file['timestamp']), 'user' => Whups::formatUser(Whups::getUserAttributes($file['user_id']), true, true, true)), Whups::attachmentUrl($ticket->getId(), $attachments[$file['value']], $ticket->get('queue')));
}
}
Whups::addTopbarSearch();
Whups::addFeedLink();
$page_output->addLinkTag($ticket->feedLink());
$page_output->addScriptFile('tables.js', 'horde');
$page_output->header(array('title' => sprintf(_("Attachments for %s"), '[#' . $id . '] ' . $ticket->get('summary'))));
$notification->notify(array('listeners' => 'status'));
echo Whups::getTicketTabs($vars, $ticket->getId())->render('attachments');
echo $view->render('ticket/attachments');
$page_output->footer();
示例8: render
public function render($transaction, &$vars)
{
global $prefs, $conf, $registry;
static $canUpdate, $comment_count = 0;
if (!isset($canUpdate)) {
$canUpdate = $GLOBALS['registry']->getAuth() && Whups::hasPermission($vars->get('queue'), 'queue', 'update');
}
$comment = '';
$private = false;
$changes = array();
$changelist = $vars->get('changes');
if (!$changelist) {
return '';
}
/* Format each change in this history entry, including comments,
* etc. */
foreach ($changelist as $change) {
switch ($change['type']) {
case 'summary':
$changes[] = sprintf(_("Summary ⇒ %s"), htmlspecialchars($change['value']));
break;
case 'message':
$ticket = $vars->get('ticket_id');
try {
if (Whups::hasMessage($ticket, $change['value'])) {
$changes[] = implode(' ', Whups::messageUrls($ticket, $change['value'], $vars->get('queue')));
}
} catch (Whups_Exception $e) {
}
break;
case 'delete-attachment':
$changes[] = _("Deleted Original Message");
break;
case 'attachment':
$ticket = $vars->get('ticket_id');
try {
if ($file = Whups::getAttachments($ticket, $change['value'])) {
$changes[] = sprintf(_("New Attachment: %s"), implode(' ', Whups::attachmentUrl($ticket, $file, $vars->get('queue'))));
} else {
$changes[] = sprintf(_("New Attachment: %s"), htmlspecialchars($change['value']));
}
} catch (Whups_Exception $e) {
$changes[] = sprintf(_("New Attachment: %s"), htmlspecialchars($change['value']));
}
break;
case 'delete-attachment':
$changes[] = sprintf(_("Deleted Attachment: %s"), htmlspecialchars($change['value']));
break;
case 'assign':
$changes[] = sprintf(_("Assigned to %s"), Whups::formatUser($change['value'], false, true, true));
break;
case 'unassign':
$changes[] = sprintf(_("Taken from %s"), Whups::formatUser($change['value'], false, true, true));
break;
case 'comment':
$comment = $change['comment'];
$private = !empty($change['private']);
if ($comment) {
$reply = Horde::link(Horde::url($canUpdate ? 'ticket/update.php' : 'ticket/comment.php')->add(array('id' => $vars->get('ticket_id'), 'transaction' => $transaction))) . _("Reply to this comment") . '</a>';
}
break;
case 'queue':
$changes[] = sprintf(_("Queue ⇒ %s"), htmlspecialchars($change['label']));
break;
case 'version':
$changes[] = sprintf(_("Version ⇒ %s"), htmlspecialchars($change['label']));
break;
case 'type':
$changes[] = sprintf(_("Type ⇒ %s"), htmlspecialchars($change['label']));
break;
case 'state':
$changes[] = sprintf(_("State ⇒ %s"), htmlspecialchars($change['label']));
break;
case 'priority':
$changes[] = sprintf(_("Priority ⇒ %s"), htmlspecialchars($change['label']));
break;
case 'attribute':
$changes[] = sprintf(_("%s ⇒ %s"), htmlspecialchars($change['label']), htmlspecialchars($change['human']));
break;
case 'due':
if ($change['label']) {
$changes[] = sprintf(_("Due ⇒ %s"), strftime($prefs->getValue('date_format'), $change['label']));
}
break;
}
}
if ($comment) {
$flowed = new Horde_Text_Flowed($comment, 'UTF-8');
$flowed->setDelSp(true);
$comment = $flowed->toFlowed(false);
$comment = $GLOBALS['injector']->getInstance('Horde_Core_Factory_TextFilter')->filter($comment, array('text2html', 'simplemarkup', 'highlightquotes'), array(array('parselevel' => Horde_Text_Filter_Text2html::MICRO), array('html' => true), array('hideBlocks' => true)));
if ($prefs->getValue('autolink_tickets') && $conf['prefs']['autolink_terms']) {
// Replace existing links by tokens to avoid double linking.
$comment = preg_replace_callback('/<a.*?<\\/a>/', array($this, '_writeTokens'), $comment);
$comment = preg_replace_callback('/(' . $conf['prefs']['autolink_terms'] . ')\\s*#?(\\d+)/i', array($this, '_autolink'), $comment);
$comment = preg_replace_callback('/\\0/', array($this, '_readTokens'), $comment);
}
$comment_count++;
if ($private) {
$comment_label = Horde::img('locked.png') . sprintf(_("Comment #%d (Private)"), $comment_count);
//.........这里部分代码省略.........
示例9: formatComments
/**
* Converts a changeset array to a plain text comment snippet.
*
* @param array $comments A changeset list.
* @param integer $ticket A ticket ID.
*
* @return string The formatted comment text, if any.
*/
public function formatComments($comments, $ticket)
{
$text = '';
foreach ($comments as $comment) {
if (!empty($comment['comment_text'])) {
$text .= "\n" . sprintf(_("%s (%s) wrote:"), Whups::formatUser($comment['user_id']), strftime('%Y-%m-%d %H:%M', $comment['timestamp'])) . "\n\n" . $comment['comment_text'] . "\n\n\n";
}
/* Add attachment links. */
if (empty($GLOBALS['conf']['mail']['link_attach'])) {
continue;
}
foreach ($comment['changes'] as $change) {
if ($change['type'] != 'attachment') {
continue;
}
$url_params = array('actionID' => 'download_file', 'file' => $change['value'], 'ticket' => $ticket);
$text .= "\n" . sprintf(_("%s (%s) uploaded: %s"), Whups::formatUser($comment['user_id']), strftime('%Y-%m-%d %H:%M', $comment['timestamp']), $change['value']) . "\n\n" . Horde::url($GLOBALS['registry']->downloadUrl($change['value'], $url_params), true) . "\n\n\n";
}
}
return $text;
}
示例10: notify
/**
* Notifies all appropriate people of the creation/update of this ticket.
*
* @param string $author Who created/changed the ticket?
* @param boolean $isNew Is this a new ticket or a change to an existing
* one?
* @param array $listeners The list of listener that should receive the
* notification, with user names as keys and user
* roles as values. If empty, the list will be
* created automatically.
*/
public function notify($author, $isNew, $listeners = array())
{
global $conf, $whups_driver;
/* Get the attributes for this ticket. */
$attributes = $whups_driver->getAttributesForType($this->get('type'));
$fields = array('queue' => _("Queue"), 'version' => _("Version"), 'type' => _("Type"), 'state' => _("State"), 'priority' => _("Priority"), 'due' => _("Due"));
$field_names = array_merge($fields, array(_("Created By"), _("Updated By"), _("Summary"), _("Owners"), _("New Attachment"), _("Deleted Attachment")));
foreach ($attributes as $attribute) {
$field_names[] = $attribute['human_name'];
}
/* Find the longest translated field name. */
$length = 0;
foreach ($field_names as $field_name) {
$length = max($length, Horde_String::length($field_name));
}
$wrap_break = "\n" . str_repeat(' ', $length + 2) . '| ';
$wrap_width = 73 - $length;
/* Ticket URL. */
$url = sprintf(_("Ticket URL: %s"), Whups::urlFor('ticket', $this->_id, true, -1));
/* Ticket properties. */
$table = "------------------------------------------------------------------------------\n" . ' ' . Horde_String::pad(_("Ticket"), $length) . ' | ' . $this->_id . "\n" . ' ' . Horde_String::pad($isNew ? _("Created By") : _("Updated By"), $length) . ' | ' . Whups::formatUser($author) . "\n";
if (isset($this->_changes['summary'])) {
$table .= '-' . Horde_String::pad(_("Summary"), $length) . ' | ' . Horde_String::wrap($this->_changes['summary']['from'], $wrap_width, $wrap_break) . "\n" . '+' . Horde_String::pad(_("Summary"), $length) . ' | ' . Horde_String::wrap($this->get('summary'), $wrap_width, $wrap_break) . "\n";
} else {
$table .= ' ' . Horde_String::pad(_("Summary"), $length) . ' | ' . Horde_String::wrap($this->get('summary'), $wrap_width, $wrap_break) . "\n";
}
foreach ($fields as $field => $label) {
if ($name = $this->get($field . '_name')) {
if (isset($this->_changes[$field])) {
$table .= '-' . Horde_String::pad($label, $length) . ' | ' . Horde_String::wrap($this->_changes[$field]['from_name'], $wrap_width, $wrap_break) . "\n" . '+' . Horde_String::pad($label, $length) . ' | ' . Horde_String::wrap($name, $wrap_width, $wrap_break) . "\n";
} else {
$table .= ' ' . Horde_String::pad($label, $length) . ' | ' . Horde_String::wrap($name, $wrap_width, $wrap_break) . "\n";
}
}
}
/* Attribute changes. */
foreach ($attributes as $id => $attribute) {
$attribute_id = 'attribute_' . $id;
$label = $attribute['human_name'];
if (isset($this->_changes[$attribute_id])) {
$table .= '-' . Horde_String::pad($label, $length) . ' | ' . Horde_String::wrap($this->_changes[$attribute_id]['from'], $wrap_width, $wrap_break) . "\n" . '+' . Horde_String::pad($label, $length) . ' | ' . Horde_String::wrap($this->_changes[$attribute_id]['to'], $wrap_width, $wrap_break) . "\n";
} else {
$table .= ' ' . Horde_String::pad($label, $length) . ' | ' . Horde_String::wrap($this->get($attribute_id), $wrap_width, $wrap_break) . "\n";
}
}
/* Show any change in ticket owners. */
$owners = $oldOwners = Horde_String::wrap(Whups::getOwners($this->_id, false, true), $wrap_width, $wrap_break);
if (isset($this->_changes['oldowners'])) {
$oldOwners = Horde_String::wrap(Whups::getOwners($this->_id, false, true, $this->_changes['oldowners']), $wrap_width, $wrap_break);
}
if ($owners != $oldOwners) {
$table .= '-' . Horde_String::pad(_("Owners"), $length) . ' | ' . $oldOwners . "\n" . '+' . Horde_String::pad(_("Owners"), $length) . ' | ' . $owners . "\n";
} else {
$table .= ' ' . Horde_String::pad(_("Owners"), $length) . ' | ' . $owners . "\n";
}
/* New Attachments. */
if (isset($this->_changes['attachment'])) {
$table .= '+' . Horde_String::pad(_("New Attachment"), $length) . ' | ' . $this->_changes['attachment']['to']['name'] . "\n";
}
if (!empty($this->_changes['attachments'])) {
foreach ($this->_changes['attachments']['to'] as $attachment) {
$table .= '+' . Horde_String::pad(_("New Attachment"), $length) . ' | ' . $attachment['name'] . "\n";
}
}
/* Deleted Attachments. */
if (isset($this->_changes['delete-attachment'])) {
$table .= '+' . Horde_String::pad(_("Deleted Attachment"), $length) . ' | ' . $this->_changes['delete-attachment']['to'] . "\n";
}
$table .= "------------------------------------------------------------------------------";
/* Build message template. */
$view = new Horde_View(array('templatePath' => WHUPS_BASE . '/config'));
$view->ticket_url = $url;
$view->table = $table;
$view->dont_reply = empty($conf['mail']['reply']);
$view->date = strftime($GLOBALS['prefs']->getValue('date_format'));
$view->auth_name = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create()->getValue('fullname');
if (empty($view->auth_name)) {
$view->auth_name = $GLOBALS['registry']->getAuth('bare');
}
/* Get queue specific notification message text, if available. */
$message_file = WHUPS_BASE . '/config/' . ($isNew ? 'create_email.plain' : 'notify_email.plain');
if (file_exists($message_file . '.' . $this->get('queue') . '.php')) {
$message_file .= '.' . $this->get('queue') . '.php';
} elseif (file_exists($message_file . '.local.php')) {
$message_file .= '.local.php';
} else {
$message_file .= '.php';
}
$message_file = basename($message_file);
//.........这里部分代码省略.........
示例11: __construct
public function __construct(&$vars, &$ticket, $title = '')
{
global $whups_driver;
parent::__construct($vars, $title);
$type = $vars->get('type');
$start_year = date('Y');
if (is_numeric($d = $vars->get('due'))) {
$start_year = min($start_year, date('Y', $d));
}
$fields = array('summary');
$qinfo = $whups_driver->getQueue($vars->get('queue'));
if (!empty($qinfo['versioned'])) {
$fields[] = 'version';
}
$fields = array_merge($fields, array('state', 'priority', 'due'));
try {
$attributes = $ticket->addAttributes();
} catch (Whups_Exception $e) {
$attributes = array();
}
foreach ($attributes as $attribute) {
$fields[] = 'attribute_' . $attribute['id'];
}
$fields = array_merge($fields, array('owner', 'attachments', 'comment'));
$grouped_fields = array($fields);
$grouped_hook = false;
try {
$grouped_fields = Horde::callHook('group_fields', array($ticket->get('type'), $fields), 'whups');
$grouped_hook = true;
} catch (Horde_Exception_HookNotSet $e) {
} catch (Horde_Exception $e) {
Horde::log($e, 'ERR');
}
$this->addHidden('', 'id', 'int', true, true);
$this->addHidden('', 'type', 'int', true, true);
foreach ($grouped_fields as $header => $fields) {
if ($grouped_hook) {
$this->addVariable($header, null, 'header', false);
}
foreach ($fields as $field) {
switch ($field) {
case 'summary':
$this->addVariable(_("Summary"), 'summary', 'text', true);
break;
case 'version':
$versions = $whups_driver->getVersions($vars->get('queue'));
if (count($versions) == 0) {
$vtype = 'invalid';
$v_params = array(_("This queue requires that you specify a version, but there are no versions associated with it. Until versions are created for this queue, you will not be able to create tickets."));
} else {
$vtype = 'enum';
$v_params = array($versions);
}
$this->addVariable(_("Queue Version"), 'version', $vtype, true, false, null, $v_params);
break;
case 'state':
$this->addVariable(_("State"), 'state', 'enum', true, false, null, array($whups_driver->getStates($type)));
break;
case 'priority':
$this->addVariable(_("Priority"), 'priority', 'enum', true, false, null, array($whups_driver->getPriorities($type)));
break;
case 'due':
$this->addVariable(_("Due Date"), 'due', 'datetime', false, false, null, array($start_year));
break;
case 'owner':
if (Whups::hasPermission($vars->get('queue'), 'queue', 'assign')) {
$groups = $GLOBALS['injector']->getInstance('Horde_Group');
$mygroups = $groups->listAll($GLOBALS['conf']['prefs']['assign_all_groups'] ? null : $GLOBALS['registry']->getAuth());
asort($mygroups);
$f_users = array();
$users = $whups_driver->getQueueUsers($vars->get('queue'));
foreach ($users as $user) {
$f_users['user:' . $user] = Whups::formatUser($user);
}
$f_groups = array();
if ($mygroups) {
foreach (array_keys($mygroups) as $id) {
$f_groups['group:' . $id] = $groups->getName($id);
}
}
if (count($f_users)) {
asort($f_users);
$this->addVariable(_("Owners"), 'owners', 'multienum', false, false, null, array($f_users));
}
if (count($f_groups)) {
asort($f_groups);
$this->addVariable(_("Group Owners"), 'group_owners', 'multienum', false, false, null, array($f_groups));
}
}
break;
case 'attachments':
$this->addVariable(_("Attachment"), 'newattachment', 'file', false);
break;
case 'comment':
$cvar = $this->addVariable(_("Comment"), 'newcomment', 'longtext', false);
/* Form replies. */
try {
$replies = Whups::permissionsFilter($whups_driver->getReplies($type), 'reply');
} catch (Whups_Exception $e) {
$replies = array();
//.........这里部分代码省略.........