| 1 |
<?php
|
| 2 |
// $Id: phpfreechat.inc,v 1.4.2.14 2007/12/07 19:35:55 owahab Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Define data folders
|
| 6 |
*/
|
| 7 |
define('PHPFREECHAT_DATA_DIR', 'files/phpfreechat');
|
| 8 |
define('PHPFREECHAT_PUBLIC_DIR', 'files/phpfreechat/public');
|
| 9 |
define('PHPFREECHAT_PRIVATE_DIR', 'files/phpfreechat/private');
|
| 10 |
|
| 11 |
/**
|
| 12 |
* Private hook_help function, to reduce module overhead
|
| 13 |
*/
|
| 14 |
function _phpfreechat_help($section) {
|
| 15 |
switch ($section) {
|
| 16 |
case 'admin/help#phpfreechat':
|
| 17 |
return t('<p>Enables the creation of phpFreeChat channels on any page on the site. ' .
|
| 18 |
'You will need to enable phpFreeChat for any content types you would like a ' .
|
| 19 |
'chat page on by going to: ' .
|
| 20 |
l('/admin/content/types', 'admin/content/types') .
|
| 21 |
'.</p><p>phpFreeChat has the concept of chat channels. You can have as many channels ' .
|
| 22 |
'as you want, and any chat box can connect to one or more channels on startup. ' .
|
| 23 |
'By default a new channel will be created for each page, based on the page title. ' .
|
| 24 |
'If you set the \'Default Channels\' setting below you can have each page join the ' .
|
| 25 |
'same channel, creating a sitewide chatroom. ' .
|
| 26 |
'In addition you can override the channel at the content-type or ' .
|
| 27 |
'node level, which allows you to create a content-type channel or channels and/or ' .
|
| 28 |
'set several pages to share the same channel or channels.</p>');
|
| 29 |
case 'admin/settings/phpfreechat':
|
| 30 |
return t('<p>Enables the creation of phpFreeChat channels on any page on the site.<br />' .
|
| 31 |
'You will need to enable phpFreeChat for any content types you would like a ' .
|
| 32 |
'chat page on by going to: ' .
|
| 33 |
l('/admin/content/types', 'admin/content/types') .
|
| 34 |
'.</p><p>Please read the ' . l('phpFreeChat help pages', 'admin/help/phpfreechat') .
|
| 35 |
' to understand how to configure phpFreeChat channels.</p>' .
|
| 36 |
'<p>Leaving any textbox blank will cause that setting to use the default value. ' .
|
| 37 |
'Please note that some settings may not take effect until you clear your cookies.</p>');
|
| 38 |
}
|
| 39 |
}
|
| 40 |
|
| 41 |
/**
|
| 42 |
* Make sure that third party files exist.
|
| 43 |
*/
|
| 44 |
function _phpfreechat_check_install() {
|
| 45 |
$install_path = drupal_get_path('module', 'phpfreechat').'/phpfreechat';
|
| 46 |
if (file_exists($install_path .'/src/phpfreechat.class.php') &&
|
| 47 |
file_exists($install_path .'/src/pfcinfo.class.php')) {
|
| 48 |
return true;
|
| 49 |
}
|
| 50 |
return false;
|
| 51 |
}
|
| 52 |
|
| 53 |
/**
|
| 54 |
* Make sure data directories are created.
|
| 55 |
*/
|
| 56 |
function _phpfreechat_check_files() {
|
| 57 |
// Create data folders:
|
| 58 |
// PS: I had to pass first parameter as a variable since file_check_directory
|
| 59 |
// accepts only variables since it references the first parameter
|
| 60 |
return (
|
| 61 |
file_check_directory(file_directory_path(), FILE_CREATE_DIRECTORY, 'op')
|
| 62 |
&& file_check_directory($f = PHPFREECHAT_DATA_DIR, FILE_CREATE_DIRECTORY, 'op')
|
| 63 |
&& file_check_directory($f = PHPFREECHAT_PRIVATE_DIR, FILE_CREATE_DIRECTORY, 'op')
|
| 64 |
&& file_check_directory($f = PHPFREECHAT_PUBLIC_DIR, FILE_CREATE_DIRECTORY, 'op'));
|
| 65 |
}
|
| 66 |
|
| 67 |
/**
|
| 68 |
* Clears cached data from cookies
|
| 69 |
*/
|
| 70 |
function _phpfreechat_clear_cookies() {
|
| 71 |
setcookie('phpfreechat', '', time() - 3600);
|
| 72 |
setcookie('pfc_nickmarker', '', time() - 3600);
|
| 73 |
setcookie('pfc_clock', '', time() - 3600);
|
| 74 |
setcookie('pfc_minmax_status', '', time() - 3600);
|
| 75 |
setcookie('pfc_current_text_color', '', time() - 3600);
|
| 76 |
setcookie('pfc_showsmileys', '', time() - 3600);
|
| 77 |
setcookie('pfc_showwhosonline', '', time() - 3600);
|
| 78 |
}
|
| 79 |
|
| 80 |
/**
|
| 81 |
* Clears cached data from the configuration cache
|
| 82 |
*/
|
| 83 |
function _phpfreechat_clear_cache() {
|
| 84 |
$params = phpfreechat_load_params();
|
| 85 |
_phpfreechat_rm($params['data_private_path'] .'/chat');
|
| 86 |
_phpfreechat_rm($params['data_public_path']);
|
| 87 |
drupal_set_message('phpFreeChat settings cache cleared.');
|
| 88 |
}
|
| 89 |
|
| 90 |
/**
|
| 91 |
* Delete logs of a chat room.
|
| 92 |
* @params $rid
|
| 93 |
* Room Id
|
| 94 |
*/
|
| 95 |
function _phpfreechat_nuke($rid) {
|
| 96 |
$params = phpfreechat_load_params();
|
| 97 |
$data = $params['data_private_path'] .'/chat/'. $rid .'/messages.data';
|
| 98 |
$index = $params['data_private_path'] .'/chat/'. $rid .'/messages.index';
|
| 99 |
file_delete($data);
|
| 100 |
file_create_path($data);
|
| 101 |
file_delete($indes);
|
| 102 |
file_create_path($index);
|
| 103 |
drupal_set_message('Chat room contents cleared.');
|
| 104 |
drupal_goto('');
|
| 105 |
}
|
| 106 |
|
| 107 |
/**
|
| 108 |
* Private hook_settings function, to reduce module overhead
|
| 109 |
*/
|
| 110 |
function _phpfreechat_settings() {
|
| 111 |
if (!empty($_POST['op'])) {
|
| 112 |
_phpfreechat_clear_cache();
|
| 113 |
_phpfreechat_clear_cookies();
|
| 114 |
}
|
| 115 |
if (!_phpfreechat_check_install()) {
|
| 116 |
form_set_error('op', _phpfreechat_not_found());
|
| 117 |
}
|
| 118 |
if (!_phpfreechat_check_files()) {
|
| 119 |
form_set_error('op', t('Unable to create data folders for phpfreechat.'));
|
| 120 |
}
|
| 121 |
$params = phpfreechat_load_params();
|
| 122 |
|
| 123 |
$form['module'] = array(
|
| 124 |
'#type' => 'fieldset',
|
| 125 |
'#title' => t('phpFreeChat Module Settings'),
|
| 126 |
);
|
| 127 |
|
| 128 |
$form['module']['phpfreechat_title'] = array(
|
| 129 |
'#type' => 'textfield',
|
| 130 |
'#title' => t('Default Title'),
|
| 131 |
'#default_value' => variable_get('phpfreechat_title', ''),
|
| 132 |
'#size' => 70,
|
| 133 |
'#maxlength' => 128,
|
| 134 |
'#description' => t('This is the default title (shown at the top of the chat box), which can be overriden at the content type or node level. If all of these are empty the node title will be used.'),
|
| 135 |
);
|
| 136 |
|
| 137 |
$form['module']['phpfreechat_channels'] = array(
|
| 138 |
'#type' => 'textfield',
|
| 139 |
'#title' => t('Default Channels'),
|
| 140 |
'#default_value' => variable_get('phpfreechat_channels', ''),
|
| 141 |
'#size' => 70,
|
| 142 |
'#maxlength' => 128,
|
| 143 |
'#description' => t('These are the default channels, which can be overriden at the content type or node level. ' .
|
| 144 |
'You can enter multiple rooms to be joined separated by commas. ' .
|
| 145 |
'Leaving this blank will auto-generate a string based on the title parameter.'),
|
| 146 |
);
|
| 147 |
|
| 148 |
$form['chat'] = array(
|
| 149 |
'#type' => 'fieldset',
|
| 150 |
'#title' => t('Chat Room Settings'),
|
| 151 |
'#collapsible' => TRUE,
|
| 152 |
'#collapsed' => TRUE,
|
| 153 |
);
|
| 154 |
|
| 155 |
$form['chat']['phpfreechat_theme'] = array(
|
| 156 |
'#type' => 'select',
|
| 157 |
'#title' => t('Theme'),
|
| 158 |
'#options' => _phpfreechat_ls($params['theme_path']),
|
| 159 |
'#default_value' => variable_get('phpfreechat_theme', 'default'),
|
| 160 |
'#description' => t('This parameter specifies which theme this chat will use.'),
|
| 161 |
);
|
| 162 |
|
| 163 |
$form['chat']['phpfreechat_language'] = array(
|
| 164 |
'#type' => 'select',
|
| 165 |
'#title' => t('Language'),
|
| 166 |
'#options' => _phpfreechat_ls(drupal_get_path('module', 'phpfreechat') . '/phpfreechat/i18n'),
|
| 167 |
'#default_value' => variable_get('phpfreechat_language', 'en_US'),
|
| 168 |
'#description' => t('Used to specify the chat labels language. ' .
|
| 169 |
'Accepted values are i18n/* sub directories names. ' .
|
| 170 |
'(by default this is the local server language)'),
|
| 171 |
);
|
| 172 |
|
| 173 |
$form['chat']['phpfreechat_auto_nick'] = array(
|
| 174 |
'#type' => 'select',
|
| 175 |
'#title' => t('Auto Nick'),
|
| 176 |
'#default_value' => variable_get('phpfreechat_auto_nick', 'true'),
|
| 177 |
'#options' => array('true' => 'true', 'false' => 'false'),
|
| 178 |
'#description' => t('Use site username as nick, rather than prompting the ' .
|
| 179 |
'user to enter their own nick. (true value by default)'),
|
| 180 |
);
|
| 181 |
|
| 182 |
$form['chat']['phpfreechat_frozen_nick'] = array(
|
| 183 |
'#type' => 'select',
|
| 184 |
'#title' => t('Frozen Nick'),
|
| 185 |
'#default_value' => variable_get('phpfreechat_frozen_nick', 'true'),
|
| 186 |
'#options' => array('true' => 'true', 'false' => 'false'),
|
| 187 |
'#description' => t('Setting this to true will forbid the user from ' .
|
| 188 |
'changing their nickname later. (false value by default)'),
|
| 189 |
);
|
| 190 |
|
| 191 |
$form['chat']['phpfreechat_max_nick_len'] = array(
|
| 192 |
'#type' => 'textfield',
|
| 193 |
'#title' => t('Maximum Nick Length'),
|
| 194 |
'#default_value' => variable_get('phpfreechat_max_nick_len', ''),
|
| 195 |
'#description' => t('This is the maximum nickname length, a longer nickname ' .
|
| 196 |
'is forbidden. (15 characters by default)'),
|
| 197 |
);
|
| 198 |
|
| 199 |
$form['chat']['phpfreechat_max_text_len'] = array(
|
| 200 |
'#type' => 'textfield',
|
| 201 |
'#title' => t('Maximum Message Length'),
|
| 202 |
'#default_value' => variable_get('phpfreechat_max_text_len', ''),
|
| 203 |
'#description' => t('This is the maximum message length, a longer message ' .
|
| 204 |
'is forbidden. (250 characters by default)'),
|
| 205 |
);
|
| 206 |
|
| 207 |
$form['chat']['phpfreechat_max_msg'] = array(
|
| 208 |
'#type' => 'textfield',
|
| 209 |
'#title' => t('Message History Length'),
|
| 210 |
'#default_value' => variable_get('phpfreechat_max_msg', ''),
|
| 211 |
'#description' => t('This is the message history length. When a user ' .
|
| 212 |
'connects, he can see the history. The number of messages s/he can ' .
|
| 213 |
'see is defined by this (20 lines by default)'),
|
| 214 |
);
|
| 215 |
|
| 216 |
$form['chat']['phpfreechat_start_minimized'] = array(
|
| 217 |
'#type' => 'select',
|
| 218 |
'#title' => t('Start Minimized'),
|
| 219 |
'#default_value' => variable_get('phpfreechat_start_minimized', 'false'),
|
| 220 |
'#options' => array('true' => 'true', 'false' => 'false'),
|
| 221 |
'#description' => t('Setting it to true will start the chat minimized. ' .
|
| 222 |
'(false value by default)'),
|
| 223 |
);
|
| 224 |
|
| 225 |
$form['chat']['phpfreechat_height'] = array(
|
| 226 |
'#type' => 'textfield',
|
| 227 |
'#title' => t('Chat Height'),
|
| 228 |
'#default_value' => variable_get('phpfreechat_height', ''),
|
| 229 |
'#description' => t('Height of the chat area. (440px by default)'),
|
| 230 |
);
|
| 231 |
|
| 232 |
$form['chat']['phpfreechat_width'] = array(
|
| 233 |
'#type' => 'textfield',
|
| 234 |
'#title' => t('Chat Width'),
|
| 235 |
'#default_value' => variable_get('phpfreechat_width', ''),
|
| 236 |
'#description' => t('Width of the chat area. ' .
|
| 237 |
'(empty by default, which means it\'s given by the CSS)'),
|
| 238 |
);
|
| 239 |
|
| 240 |
$form['chat']['phpfreechat_shownotice'] = array(
|
| 241 |
'#type' => 'textfield',
|
| 242 |
'#title' => t('Show Notice'),
|
| 243 |
'#default_value' => variable_get('phpfreechat_shownotice', ''),
|
| 244 |
'#description' => t('Setting this to 0 will disable all notices. ' .
|
| 245 |
'Setting it to 1 will show nicknames changes. ' .
|
| 246 |
'Setting it to 2 will show connect/disconnect notifications.' .
|
| 247 |
'Setting it to 3 (1+2) will show nicknames and connect/disconnect notifications.' .
|
| 248 |
'(3 by default)'),
|
| 249 |
);
|
| 250 |
|
| 251 |
$form['chat']['phpfreechat_nickmarker'] = array(
|
| 252 |
'#type' => 'select',
|
| 253 |
'#title' => t('Nick Marker'),
|
| 254 |
'#default_value' => variable_get('phpfreechat_nickmarker', ''),
|
| 255 |
'#options' => array('true' => 'true', 'false' => 'false'),
|
| 256 |
'#description' => t('Setting this to false will disable nickname ' .
|
| 257 |
'colorization. (true value by default)'),
|
| 258 |
);
|
| 259 |
|
| 260 |
$form['chat']['phpfreechat_clock'] = array(
|
| 261 |
'#type' => 'select',
|
| 262 |
'#title' => t('Clock'),
|
| 263 |
'#default_value' => variable_get('phpfreechat_clock', ''),
|
| 264 |
'#options' => array('true' => 'true', 'false' => 'false'),
|
| 265 |
'#description' => t('Setting this to false will hide the date/hour column. ' .
|
| 266 |
'(true value by default)'),
|
| 267 |
);
|
| 268 |
|
| 269 |
$form['chat']['phpfreechat_openlinknewwindow'] = array(
|
| 270 |
'#type' => 'select',
|
| 271 |
'#title' => t('Open Links in New Window'),
|
| 272 |
'#default_value' => variable_get('phpfreechat_openlinknewwindow', ''),
|
| 273 |
'#options' => array('true' => 'true', 'false' => 'false'),
|
| 274 |
'#description' => t('Setting this to true will add target="_blank" into ' .
|
| 275 |
'parsed links. This attribute is used to open the followed link in a ' .
|
| 276 |
'new window. (true value by default)'),
|
| 277 |
);
|
| 278 |
|
| 279 |
$form['chat']['phpfreechat_showwhosonline'] = array(
|
| 280 |
'#type' => 'select',
|
| 281 |
'#title' => t('Show Who\'s Online'),
|
| 282 |
'#default_value' => variable_get('phpfreechat_showwhosonline', ''),
|
| 283 |
'#options' => array('true' => 'true', 'false' => 'false'),
|
| 284 |
'#description' => t('Used to show/hide online users at startup. ' .
|
| 285 |
'(true value by default)'),
|
| 286 |
);
|
| 287 |
|
| 288 |
$form['chat']['phpfreechat_showsmileys'] = array(
|
| 289 |
'#type' => 'select',
|
| 290 |
'#title' => t('Show Smileys'),
|
| 291 |
'#default_value' => variable_get('phpfreechat_showsmileys', ''),
|
| 292 |
'#options' => array('true' => 'true', 'false' => 'false'),
|
| 293 |
'#description' => t('Used to show/hide the smiley list at startup. ' .
|
| 294 |
'(true value by default)'),
|
| 295 |
);
|
| 296 |
|
| 297 |
$form['chat']['phpfreechat_btn_sh_whosonline'] = array(
|
| 298 |
'#type' => 'select',
|
| 299 |
'#title' => t('Show Who\'s Online Button'),
|
| 300 |
'#default_value' => variable_get('phpfreechat_btn_sh_whosonline', ''),
|
| 301 |
'#options' => array('true' => 'true', 'false' => 'false'),
|
| 302 |
'#description' => t('Used to display or not the showwhosonline button. ' .
|
| 303 |
'(true value by default)'),
|
| 304 |
);
|
| 305 |
|
| 306 |
$form['chat']['phpfreechat_btn_sh_smileys'] = array(
|
| 307 |
'#type' => 'select',
|
| 308 |
'#title' => t('Show Smileys Button'),
|
| 309 |
'#default_value' => variable_get('phpfreechat_btn_sh_smileys', ''),
|
| 310 |
'#options' => array('true' => 'true', 'false' => 'false'),
|
| 311 |
'#description' => t('Used to display or not the showsmileys button. ' .
|
| 312 |
'(true value by default)'),
|
| 313 |
);
|
| 314 |
|
| 315 |
$form['system'] = array(
|
| 316 |
'#type' => 'fieldset',
|
| 317 |
'#title' => t('Performance & Output Settings'),
|
| 318 |
'#collapsible' => TRUE,
|
| 319 |
'#collapsed' => TRUE,
|
| 320 |
);
|
| 321 |
|
| 322 |
$form['system']['phpfreechat_container_type'] = array(
|
| 323 |
'#type' => 'textfield',
|
| 324 |
'#title' => t('Container Type'),
|
| 325 |
'#default_value' => variable_get('phpfreechat_container_type', ''),
|
| 326 |
'#description' => t('Used to specify the used container. For the moment, ' .
|
| 327 |
'the file container is the best supported. A \'Memory\' ' .
|
| 328 |
'container, which offers much greater performance has also been ' .
|
| 329 |
'written, but is less well tested. In the future several ' .
|
| 330 |
'containers (IRC, MSN, Jabber...) will surely be available. ' .
|
| 331 |
'(\'File\' by default)'),
|
| 332 |
);
|
| 333 |
|
| 334 |
$form['system']['phpfreechat_container_cfg_sm_type'] = array(
|
| 335 |
'#type' => 'textfield',
|
| 336 |
'#title' => t('Container Storage Method'),
|
| 337 |
'#default_value' => variable_get('phpfreechat_container_cfg_sm_type', ''),
|
| 338 |
'#description' => t('Sets the storage method for the selected container ' .
|
| 339 |
'type. Currently this only applies for the \'Memory\' container - ' .
|
| 340 |
'possible values are: Eaccelerator, File, Shmop, Sharedance (tested), ' .
|
| 341 |
'Systemv, Mmcache, Memcache, Apc, Apachenote, Sqlite (not tested) .' .
|
| 342 |
'(\'auto\' by default)'),
|
| 343 |
);
|
| 344 |
|
| 345 |
$form['system']['phpfreechat_refresh_delay'] = array(
|
| 346 |
'#type' => 'textfield',
|
| 347 |
'#title' => t('Refresh Delay'),
|
| 348 |
'#default_value' => variable_get('phpfreechat_refresh_delay', ''),
|
| 349 |
'#description' => t('This is the time to wait (in milliseconds) between' .
|
| 350 |
' two refreshes. A refresh is a HTTP request which asks the server ' .
|
| 351 |
'if there are new messages to display. If there are no new messages, ' .
|
| 352 |
'then a empty HTTP response is returned. (5000 by default)'),
|
| 353 |
);
|
| 354 |
|
| 355 |
$form['system']['phpfreechat_timeout'] = array(
|
| 356 |
'#type' => 'textfield',
|
| 357 |
'#title' => t('Timeout'),
|
| 358 |
'#default_value' => variable_get('phpfreechat_timeout', ''),
|
| 359 |
'#description' => t('This is the time of inactivity (in milliseconds)' .
|
| 360 |
'to wait before disconnecting the user. (20000 by default)'),
|
| 361 |
);
|
| 362 |
|
| 363 |
$form['system']['phpfreechat_connect_at_startup'] = array(
|
| 364 |
'#type' => 'select',
|
| 365 |
'#title' => t('Connect At Startup'),
|
| 366 |
'#default_value' => variable_get('phpfreechat_connect_at_startup', ''),
|
| 367 |
'#options' => array('true' => 'true', 'false' => 'false'),
|
| 368 |
'#description' => t('Setting this to false will oblige user to click ' .
|
| 369 |
'on the connect button if s/he wants to chat. (true value by ' .
|
| 370 |
'default, which means when the chat web page is open, a connection ' .
|
| 371 |
'to the chat is automaticaly performed)'),
|
| 372 |
);
|
| 373 |
|
| 374 |
$form['system']['phpfreechat_output_encoding'] = array(
|
| 375 |
'#type' => 'textfield',
|
| 376 |
'#title' => t('Output Encoding'),
|
| 377 |
'#default_value' => variable_get('phpfreechat_output_encoding', ''),
|
| 378 |
'#description' => t('Useful to set a specific encoding for chat labels. ' .
|
| 379 |
'This is really useful when the Web page embedding the chat is ' .
|
| 380 |
'not UTF-8 encoded. This parameter should be the same as the chat ' .
|
| 381 |
'web page. (UTF-8 by default)'),
|
| 382 |
);
|
| 383 |
|
| 384 |
$form['system']['phpfreechat_prefix'] = array(
|
| 385 |
'#type' => 'textfield',
|
| 386 |
'#title' => t('Prefix'),
|
| 387 |
'#default_value' => variable_get('phpfreechat_prefix', ''),
|
| 388 |
'#description' => t('Used to prefix all javascript functions, CSS ' .
|
| 389 |
'id\'s and classes in order to avoid namespace clashes. ' .
|
| 390 |
'("pfc_" by default)'),
|
| 391 |
);
|
| 392 |
|
| 393 |
$form['advanced'] = array(
|
| 394 |
'#type' => 'fieldset',
|
| 395 |
'#title' => t('Advanced Settings'),
|
| 396 |
'#collapsible' => TRUE,
|
| 397 |
'#collapsed' => TRUE,
|
| 398 |
);
|
| 399 |
|
| 400 |
$form['advanced']['phpfreechat_params'] = array(
|
| 401 |
'#type' => 'select',
|
| 402 |
'#title' => t('Debug Parameters'),
|
| 403 |
'#default_value' => variable_get('phpfreechat_params', 'false'),
|
| 404 |
'#options' => array('true' => 'true', 'false' => 'false'),
|
| 405 |
'#description' => t('For developers, setting this to true will list ' .
|
| 406 |
'the chat parameters, session and cookies. (false value by default)'),
|
| 407 |
);
|
| 408 |
|
| 409 |
$form['advanced']['phpfreechat_debug'] = array(
|
| 410 |
'#type' => 'select',
|
| 411 |
'#title' => t('Debug Console'),
|
| 412 |
'#default_value' => variable_get('phpfreechat_debug', 'false'),
|
| 413 |
'#options' => array('true' => 'true', 'false' => 'false'),
|
| 414 |
'#description' => t('For developers, setting this to true will activate ' .
|
| 415 |
'logging and debuging console. (false value by default)'),
|
| 416 |
);
|
| 417 |
|
| 418 |
$form['advanced']['phpfreechat_server_script_path'] = array(
|
| 419 |
'#type' => 'textfield',
|
| 420 |
'#title' => t('Server Script Path'),
|
| 421 |
'#default_value' => variable_get('phpfreechat_server_script_path', ''),
|
| 422 |
'#description' => t('Used to specify the script which will handle ' .
|
| 423 |
'asynchronous requests. (by default this parameter is auto-detected)'),
|
| 424 |
);
|
| 425 |
|
| 426 |
$form['advanced']['phpfreechat_server_script_url'] = array(
|
| 427 |
'#type' => 'textfield',
|
| 428 |
'#title' => t('Server Script URL'),
|
| 429 |
'#default_value' => variable_get('phpfreechat_server_script_url', ''),
|
| 430 |
'#description' => t('Used to specify the script which will handle ' .
|
| 431 |
'asynchronous requests. (by default this parameter is auto-detected)'),
|
| 432 |
);
|
| 433 |
|
| 434 |
$form['advanced']['phpfreechat_client_script_path'] = array(
|
| 435 |
'#type' => 'textfield',
|
| 436 |
'#title' => t('Client Script Path'),
|
| 437 |
'#default_value' => variable_get('phpfreechat_client_script_path', ''),
|
| 438 |
'#description' => t('Used to specify the script path which display the ' .
|
| 439 |
'chat and load every JavaScript libraries (the client side). ' .
|
| 440 |
'Useful when the php configuration is uncommon, this option can ' .
|
| 441 |
'be used to force the automatic detection process. client_script_url ' .
|
| 442 |
'must point to the client script browable url (useful when using URL ' .
|
| 443 |
'rewriting). (by default this parameter is auto-detected)'),
|
| 444 |
);
|
| 445 |
|
| 446 |
$form['advanced']['phpfreechat_client_script_url'] = array(
|
| 447 |
'#type' => 'textfield',
|
| 448 |
'#title' => t('Client Script URL'),
|
| 449 |
'#default_value' => variable_get('phpfreechat_client_script_url', ''),
|
| 450 |
'#description' => t('Used to specify the script path which display the ' .
|
| 451 |
'chat and load every JavaScript libraries (the client side). ' .
|
| 452 |
'Useful when the php configuration is uncommon, this option can be ' .
|
| 453 |
'used to force the automatic detection process. client_script_url ' .
|
| 454 |
'must point to the client script browable URL (useful when using URL ' .
|
| 455 |
'rewriting). (by default this parameter is auto-detected)'),
|
| 456 |
);
|
| 457 |
|
| 458 |
$form['advanced']['phpfreechat_cmd_path'] = array(
|
| 459 |
'#type' => 'textfield',
|
| 460 |
'#title' => t('Commands Directory'),
|
| 461 |
'#default_value' => variable_get('phpfreechat_cmd_path', ''),
|
| 462 |
'#description' => t('The absolute commands directory path. To create a new command, ' .
|
| 463 |
'you have to write it and indicate in this parameter where it is located. ' .
|
| 464 |
'(dirname(__FILE__)."/../themes" by default)'),
|
| 465 |
);
|
| 466 |
|
| 467 |
$form['advanced']['phpfreechat_theme_path'] = array(
|
| 468 |
'#type' => 'textfield',
|
| 469 |
'#title' => t('Theme Path'),
|
| 470 |
'#default_value' => variable_get('phpfreechat_theme_path', ''),
|
| 471 |
'#description' => t('The absolute theme directory path. Sub directories ' .
|
| 472 |
'must contains themes directories. ' .
|
| 473 |
'(dirname(__FILE__)."/../themes" by default)'),
|
| 474 |
);
|
| 475 |
|
| 476 |
$form['advanced']['phpfreechat_jspath'] = array(
|
| 477 |
'#type' => 'textfield',
|
| 478 |
'#title' => t('Jspath'),
|
| 479 |
'#default_value' => variable_get('phpfreechat_jspath', ''),
|
| 480 |
'#description' => t('Specify the javascript libraries path (md5, ' .
|
| 481 |
'cookie ...). (dirname(__FILE__)."/../lib/javascript" by default)'),
|
| 482 |
);
|
| 483 |
|
| 484 |
$form['advanced']['phpfreechat_xajaxpath'] = array(
|
| 485 |
'#type' => 'textfield',
|
| 486 |
'#title' => t('Xajaxpath'),
|
| 487 |
'#default_value' => variable_get('phpfreechat_xajaxpath', ''),
|
| 488 |
'#description' => t('Specify the xajax path. It\'s useful if you already ' .
|
| 489 |
'have an xajax library installed and you want to save bytes on your ' .
|
| 490 |
'server. (dirname(__FILE__)."/../lib/xajax_x.x" by default);'),
|
| 491 |
);
|
| 492 |
|
| 493 |
$form['advanced']['phpfreechat_data_private_path'] = array(
|
| 494 |
'#type' => 'textfield',
|
| 495 |
'#title' => t('Data Private Path'),
|
| 496 |
'#default_value' => variable_get('phpfreechat_data_private_path', ''),
|
| 497 |
'#description' => t('Used by the filesystem container to store chat ' .
|
| 498 |
'data. Used by smarty to store compiled templates. ' .
|
| 499 |
'Tip: you can optimize your chat performance, by pointing this to' .
|
| 500 |
'a RAM filesystem mount. ' .
|
| 501 |
'(by default this parameter is auto-detected)'),
|
| 502 |
);
|
| 503 |
|
| 504 |
$form['advanced']['phpfreechat_data_public_path'] = array(
|
| 505 |
'#type' => 'textfield',
|
| 506 |
'#title' => t('Data Public Path'),
|
| 507 |
'#default_value' => variable_get('phpfreechat_data_public_path', ''),
|
| 508 |
'#description' => t('This path must be reachable by your web server. ' .
|
| 509 |
'JS compiled scripts will be stored here. data_public_url parameter ' .
|
| 510 |
'can be specified to help when URL rewriting is used. ' .
|
| 511 |
'(by default this parameter is auto-detected)'),
|
| 512 |
);
|
| 513 |
|
| 514 |
$form['advanced']['phpfreechat_data_public_url'] = array(
|
| 515 |
'#type' => 'textfield',
|
| 516 |
'#title' => t('Data Public URL'),
|
| 517 |
'#default_value' => variable_get('phpfreechat_data_public_url', ''),
|
| 518 |
'#description' => t('This path must be reachable by your web server. ' .
|
| 519 |
'JS compiled scripts will be stored here. data_public_url parameter ' .
|
| 520 |
'can be specified to help when URL rewriting is used. ' .
|
| 521 |
'(by default this parameter is auto-detected)'),
|
| 522 |
);
|
| 523 |
|
| 524 |
$form['advanced']['phpfreechat_serverid'] = array(
|
| 525 |
'#type' => 'textfield',
|
| 526 |
'#title' => t('Serverid'),
|
| 527 |
'#default_value' => variable_get('phpfreechat_serverid', ''),
|
| 528 |
'#description' => t('This is the chat server id, ' .
|
| 529 |
'(comparable to the server host in IRC) used to identify the server. ' .
|
| 530 |
'Is you want to share channels between different sites you can use this ' .
|
| 531 |
'to force an identical serverid. ' .
|
| 532 |
'(by default this parameter is auto-detected)'),
|
| 533 |
);
|
| 534 |
|
| 535 |
return $form;
|
| 536 |
}
|
| 537 |
|
| 538 |
/**
|
| 539 |
* Return a 'not found' message
|
| 540 |
*/
|
| 541 |
function _phpfreechat_not_found() {
|
| 542 |
$message = t('phpFreeChat script is not found.<br />Before you can use this module ' .
|
| 543 |
'you must download the script from <a href="http://www.phpfreechat.net/">' .
|
| 544 |
'http://www.phpfreechat.net/</a> and extract in to the /%directory ' .
|
| 545 |
'directory on your web server.<br />See INSTALL.txt for more details.',
|
| 546 |
array('%directory' => drupal_get_path('module', 'phpfreechat').'/phpfreechat'));
|
| 547 |
watchdog('phpfreechat', $message, 'WATCHDOG_ERROR');
|
| 548 |
return $message;
|
| 549 |
}
|
| 550 |
|
| 551 |
/**
|
| 552 |
* Returns a list of files/folders in a path.
|
| 553 |
*
|
| 554 |
*/
|
| 555 |
function _phpfreechat_ls($dir){
|
| 556 |
// scan the path
|
| 557 |
$list = file_scan_directory($dir, '.*', array('.', '..', 'CVS'), 0, FALSE, 'basename');
|
| 558 |
// get only filenames
|
| 559 |
$list = array_keys($list);
|
| 560 |
// order according to file names descendingly
|
| 561 |
sort($list);
|
| 562 |
// convert a an associative array and return it
|
| 563 |
return drupal_map_assoc($list);
|
| 564 |
}
|
| 565 |
|
| 566 |
/**
|
| 567 |
* Deletes a folder recursively
|
| 568 |
*/
|
| 569 |
function _phpfreechat_rm($dir) {
|
| 570 |
if (!$dh = @opendir($dir)) {
|
| 571 |
return;
|
| 572 |
}
|
| 573 |
while (($obj = @readdir($dh))) {
|
| 574 |
if ($obj=='.' || $obj=='..') {
|
| 575 |
continue;
|
| 576 |
}
|
| 577 |
if (!@unlink($dir.'/'.$obj)) {
|
| 578 |
_phpfreechat_rm($dir.'/'.$obj);
|
| 579 |
}
|
| 580 |
}
|
| 581 |
@closedir($dh);
|
| 582 |
@rmdir($dir);
|
| 583 |
}
|