function support_admin_client in Support Ticketing System 6
Administratively add/update a client.
1 string reference to 'support_admin_client'
- support_menu in ./
support.module - Implementation of hook_menu().
File
- ./
support.admin.inc, line 53 - support.admin.inc
Code
function support_admin_client(&$form_state, $client = NULL) {
$form = array();
$form['name'] = array(
'#title' => t('Client name'),
'#type' => 'textfield',
'#required' => TRUE,
'#default_value' => isset($client->name) ? $client->name : '',
'#description' => t('The full name of your client. This name will be used when building menus, sending emails, and anywhere else the name of your client is visibly displayed.'),
);
$form['path'] = array(
'#title' => t('Path'),
'#type' => 'textfield',
'#required' => TRUE,
'#default_value' => isset($client->path) ? $client->path : '',
'#description' => t("Used to build the path to this client's tickets. The path should only be comprised of alphanumeric characters, dashes, and underscores."),
);
$form['status'] = array(
'#title' => t('Status'),
'#type' => 'radios',
'#options' => array(
1 => t('Enabled'),
2 => t('Disabled'),
),
'#default_value' => isset($client->status) ? $client->status : 1,
'#description' => t('Tickets will only be displayed for enabled clients.'),
);
$result = db_query('SELECT clid, name FROM {support_client} WHERE status = 1 AND parent = 0');
$clients = array(
'0' => t('<no parent>'),
);
while ($cl = db_fetch_object($result)) {
$clients[$cl->clid] = $cl->name;
}
$form['parent'] = array(
'#title' => t('Parent'),
'#type' => 'select',
'#options' => $clients,
'#default_value' => isset($client->parent) ? $client->parent : 0,
'#description' => t('Optionally nest a client under another client.'),
);
$form['mail'] = array(
'#title' => t('Inbound email integration'),
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => isset($client->integrate_email) && $client->integrate_email == TRUE ? FALSE : TRUE,
);
$form['mail']['integrate_email'] = array(
'#title' => t('Integrate inbound email'),
'#type' => 'checkbox',
'#default_value' => isset($client->integrate_email) && $client->integrate_email == TRUE ? 1 : 0,
'#description' => t('Check this box if you would like to fully integrate this client with an email server. This will allow users to create and update tickets by email, but it requires a more complex configuration as you need to create a unique mailbox for each integrated client. If you do not check this box, email notifications will still be mailed out as tickets are created and updated, but replies to these tickets will be ignored.') . ' <em>' . t('Inbound email integration requires that your version of PHP was !compiled.', array(
'!compiled' => l(t('compiled with the IMAP extension'), 'http://php.net/imap'),
)) . '</em>',
);
$form['mail']['server_name'] = array(
'#title' => t('Server name'),
'#type' => 'textfield',
'#description' => t('Hostname or IP address.'),
'#default_value' => isset($client->server_name) ? $client->server_name : '',
'#description' => t("The hostname or IP address of the mail server where your client's dedicated email address is hosted. For example, client %foo may receive email at %email, and so the server name may be %hostname. The server name may also be an IP address, such as %ip.", array(
'%foo' => 'foo',
'%email' => 'foo@support.sample.com',
'%hostname' => 'support.sample.com',
'%ip' => '192.168.1.1',
)),
);
$form['mail']['server_username'] = array(
'#title' => t('Server username'),
'#type' => 'textfield',
'#default_value' => isset($client->server_username) ? $client->server_username : '',
'#description' => t("The client's email username. If a client receives email at %email, the server username is often simply %user. The support module uses this username to log into the mail server to download messages.", array(
'%email' => 'foo@support.sample.com',
'%user' => 'foo',
)),
);
$form['mail']['server_password'] = array(
'#title' => t('Server password'),
'#type' => 'textfield',
'#default_value' => isset($client->server_password) ? $client->server_password : '',
'#description' => t("The client's email password. The support module uses this password to log into the mail server to download messages. %notice", array(
'%notice' => t('Note: this is not a password you request from your client. This is a password you configure on your mail server for managing support tickets for a client.'),
)),
);
$form['mail']['mailbox'] = array(
'#title' => t('Mailbox'),
'#type' => 'textfield',
'#default_value' => isset($client->mailbox) ? $client->mailbox : 'INBOX',
'#description' => t("The mailbox path on your mail server. You generally do not need to modify this setting."),
);
$form['mail']['mailfrom'] = array(
'#title' => t('From address'),
'#type' => 'textfield',
'#default_value' => isset($client->mailfrom) ? $client->mailfrom : '',
'#description' => t('The email address support should use when sending notification emails. This must be the same client-specific email address users will send messages to when creating and updating tickets via email. This will often be comprised of your server username and your server name, such as %email.', array(
'%email' => 'foo@support.sample.com',
)),
);
$form['mail']['port'] = array(
'#title' => t('Port'),
'#type' => 'textfield',
'#default_value' => isset($client->port) ? $client->port : '',
'#description' => t('Specify the TCP port to connect to when downloading email messages. If using pop3, this port is normally 110. If using secure pop3, this port is normally 995. If using imap, this port is normally 143. If using secure imap this port is normally 993.'),
);
$form['mail']['protocol'] = array(
'#type' => 'radios',
'#title' => t('Protocol'),
'#default_value' => 0,
'#options' => array(
'pop3',
'secure pop3',
'imap',
'secure imap',
'local file',
),
'#description' => t('Select the protocol used to obtain messages from your mail server.'),
'#default_value' => isset($client->protocol) ? $client->protocol : 0,
);
$form['mail']['extra'] = array(
'#title' => t('Optional extra flags'),
'#type' => 'textfield',
'#default_value' => isset($client->extra) ? $client->extra : '/novalidate-cert',
'#description' => t('The %pop3, %imap and %ssl flags will be automatically set for you depending on your configuration above. Additional flags can be manually specified here. If you are having trouble downloading messages, you may need to change these extra flags as !defined. These flags are ignored when using the %local protocol.', array(
'!defined' => l(t('defined here'), 'http://php.net/imap_open#function.imap-open.parameters'),
'%local' => t('local file'),
'%pop3' => t('/pop3'),
'%imap' => t('/imap'),
'%ssl' => t('/ssl'),
)),
);
$form['mail']['thread_subject'] = array(
'#type' => 'select',
'#title' => t('Thread emails using subject'),
'#options' => array(
0 => 'Use global setting',
1 => 'Disabled',
2 => 'Match against new tickets',
3 => 'Match against open tickets',
4 => 'Match against all tickets',
),
'#description' => t('When enabled, the entire message subject will be used to match replies with the original tickets. By default the !settings configuration will be used, however, you can override this global configuration here.', array(
'!settings' => l(t('general support settings'), 'admin/support/settings'),
)),
'#default_value' => isset($client->thread_subject) ? $client->thread_subject : 0,
);
$form['mail']['domains'] = array(
'#type' => 'textfield',
'#title' => t('Valid email domains'),
'#default_value' => isset($client->domains) ? $client->domains : '*',
'#description' => t('Enter one or more comma-seperated domains which are allowed to automatically generate new tickets. If you enter "*" tickets will be allowed from all domains.'),
);
$form['mail']['user_creation'] = array(
'#type' => 'select',
'#title' => t('Automatic creation of user'),
'#options' => array(
'Use global setting',
'Enable',
'Disable',
),
'#description' => t('You can override the global setting for autocreating users by selecting an option in this list. If enabled, new user accounts will be automatically created if emails are received from unnknown email addresses. If disabled, notification emails will be sent when emails are discarded notifying the sender that they have to register to be able to create or update support tickets via email.'),
'#default_value' => isset($client->user_creation) ? $client->user_creation : 0,
);
$id = isset($client->clid) ? $client->clid : 0;
$path = 'support/autocomplete/autosubscribe/' . $id;
$form['autosubscribe'] = array(
'#type' => 'textfield',
'#title' => t('Auto-subscribe'),
'#autocomplete_path' => $path,
'#maxlength' => 2048,
'#default_value' => !empty($client->autosubscribe) ? $client->autosubscribe : '',
'#description' => t('Enter one or more comma-seperated usernames to auto-subscribe to !client issues. These users will receive email notifications for all new tickets and ticket updates for this client.', array(
'!client' => isset($client->name) ? $client->name : 'client',
)),
);
$form['autoassign'] = array(
'#type' => 'textfield',
'#title' => t('Auto-assign'),
'#autocomplete_path' => 'support/autocomplete/assigned/' . $id,
'#default_value' => !empty($client->autoassign) ? $client->autoassign : '',
'#description' => t('Optionally enter a username to auto-assign all new tickets for this client to. If left blank, new tickets will be assigned based on your !settings. Enter %nobody to cause new tickets for this client to be assigned to nobody. Enter %creator to cause new tickets for this client to be assigned to the person creating the ticket.', array(
'!settings' => l(t('general support settings'), 'admin/support/settings'),
'%nobody' => '<nobody>',
'%creator' => '<creator>',
)),
);
$form['notes'] = array(
'#title' => t('Notes'),
'#type' => 'textarea',
'#default_value' => isset($client->notes) ? $client->notes : '',
'#description' => t('Notes are only displayed on this page when editing clients. They are optional and are provided for administrative purposes.'),
);
$form['clid'] = array(
'#type' => 'hidden',
'#value' => isset($client->clid) ? $client->clid : 0,
);
$form['submit'] = array(
'#value' => isset($client->clid) ? t('Update client') : t('Add client'),
'#type' => 'submit',
);
if (isset($client->clid)) {
$form['delete'] = array(
'#value' => t('Delete client'),
'#type' => 'submit',
);
$form['cancel'] = array(
'#value' => l(t('Cancel'), 'admin/support/clients'),
);
}
return $form;
}