drupalchat.admin.inc in DrupalChat 6
Administrative functions to configure DrupalChat.
File
includes/drupalchat.admin.incView source
<?php
/**
* @file
* Administrative functions to configure DrupalChat.
*/
/**
* Callback for admin/settings/drupalchat.
*/
function drupalchat_settings_form() {
// Alert the administrator to still required items for basic functionality.
if (!variable_get('drupalchat_ur_name', NULL) && variable_get('drupalchat_ur_activate', FALSE)) {
drupal_set_message(t("You must provide the user relationship name in the %info section.", array(
'%info' => t('User Relationship Name to integrate with'),
)), 'error');
}
$form = array();
$form['drupalchat'] = array(
'#type' => 'fieldset',
'#title' => t('DrupalChat Settings'),
'#collapsible' => TRUE,
);
$form['drupalchat']['drupalchat_refresh_rate'] = array(
'#type' => 'textfield',
'#title' => t('Refesh Rate'),
'#description' => t('It is the time interval after which DrupalChat checks for new messages. The value is in seconds.'),
'#default_value' => variable_get('drupalchat_refresh_rate', 2),
);
$form['drupalchat']['drupalchat_send_rate'] = array(
'#type' => 'textfield',
'#title' => t('Delay in sending messages'),
'#description' => t('It is the delay in sending messages to the server. The value is in seconds.'),
'#default_value' => variable_get('drupalchat_send_rate', 2),
);
$form['drupalchat']['drupalchat_polling_method'] = array(
'#type' => 'radios',
'#title' => t('Choose Polling Method'),
'#default_value' => variable_get('drupalchat_polling_method', 0),
'#options' => array(
0 => t('Normal AJAX'),
1 => t('Long Polling'),
),
'#description' => t('Set the polling method to be used. If unsure don\'t change the default value.'),
'#weight' => -1,
);
$form['drupalchat_ur'] = array(
'#type' => 'fieldset',
'#title' => t('DrupalChat UR Settings'),
'#collapsible' => TRUE,
);
$form['drupalchat_ur']['drupalchat_ur_activate'] = array(
'#type' => 'checkbox',
'#title' => t('Enable integration with User Relationships module'),
'#default_value' => variable_get('drupalchat_ur_activate', FALSE),
'#description' => t("If checked, only the users sharing the relationship listed below will be able to chat among themselves."),
);
$form['drupalchat_ur']['drupalchat_ur_name'] = array(
'#type' => 'textfield',
'#title' => t('User Relationships Role Name to integrate with'),
'#description' => t('It should be the singular form of User Relationships Role Name. Example: buddy, friend, coworker, spouse.'),
'#default_value' => variable_get('drupalchat_ur_name', NULL),
);
if (!module_exists('drupalchat_ur')) {
$form['drupalchat_ur']['drupalchat_ur_activate']['#disabled'] = TRUE;
$form['drupalchat_ur']['drupalchat_ur_name']['#disabled'] = TRUE;
$form['drupalchat_ur']['drupalchat_ur_activate']['#default_value'] = FALSE;
}
return system_settings_form($form);
}
/**
* Autodiscover a system path containing a library.
*
* This will attempt to automatically discover the system path to the folder
* containing the desired library. It will first search in sites/example.com/libraries, then
* sites/all/libraries.
*
* @param string $match
* The regex pattern to search for.
* @return string
* The path to the system folder containing that library.
*/
function _drupalchat_autodiscover_path($match, $filename) {
$path = '';
$files = drupal_system_listing($match, 'libraries', 'basename', 0);
if (isset($files[$filename])) {
$path = dirname($files[$filename]->filename);
}
return $path;
}
Functions
Name | Description |
---|---|
drupalchat_settings_form | Callback for admin/settings/drupalchat. |
_drupalchat_autodiscover_path | Autodiscover a system path containing a library. |