Skip to content
Snippets Groups Projects
Commit aa29e51e authored by Raghav Gupta's avatar Raghav Gupta
Browse files

by iflylabs: New iFlyChat Engine-V2 for Drupal 6.

parent bd2dc2a5
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,30 @@
* Administrative functions to configure DrupalChat.
*/
function drupalchat_app_settings(){
global $user;
if(isset($_SESSION['token']) && !empty($_SESSION['token'])){
$token = $_SESSION['token'];
}else{
$user_name = _drupalchat_get_username($user->uid);
$json = (array)_drupalchat_get_auth($user_name, array());
$token = $json['key'];
}
$drupalchat_host = DRUPALCHAT_EXTERNAL_A_HOST;
$host = explode("/", $drupalchat_host);
$host_name = $host[2];
$dashboardUrl = "//cdn.iflychat.com/apps/dashboard/#/app-settings?sessid=". $token ."&hostName=". $host_name ."&hostPort=".DRUPALCHAT_EXTERNAL_A_PORT;
return '<iframe id = "app_settings" style = "width:100%; height:600px; border:none;" src = "'.$dashboardUrl.'"></iframe>';
}
/**
* Callback for admin/settings/drupalchat.
*/
......@@ -53,7 +77,7 @@ function drupalchat_settings_form() {
$form['drupalchat_general'] = array(
'#type' => 'fieldset',
'#title' => t('DRUPALCHAT GENERAL SETTINGS'),
'#title' => t('DrupalChat General Settings'),
'#collapsible' => TRUE,
);
$form['drupalchat_general']['drupalchat_polling_method'] = array(
......@@ -63,19 +87,20 @@ function drupalchat_settings_form() {
'#options' => array(DRUPALCHAT_COMMERCIAL => t('iFlyChat server'), DRUPALCHAT_AJAX => t('Normal AJAX'), DRUPALCHAT_LONGPOLL => t('Long Polling'), DRUPALCHAT_NODEJS => t('Node.js (currently under development)'),),
'#description' => t('Decide the server backend for Drupal Chat.'),
);
$form['drupalchat_general']['drupalchat_app_id'] = array(
'#type' => 'textfield',
'#title' => t('iFlyChat APP ID'),
'#description' => t("Please enter the APP ID by registering at !elink.", array('!elink' => l(t('iFlyChat.com'), 'https://iflychat.com', array('attributes' => array('target' => '_blank'))))),
'#default_value' => variable_get('drupalchat_app_id', NULL),
);
$form['drupalchat_general']['drupalchat_external_api_key'] = array(
'#type' => 'textfield',
'#title' => t('iFlyChat API Key'),
'#description' => t("Please enter the API key by registering at !elink.", array('!elink' => l(t('iFlyChat.com'), 'https://iflychat.com', array('attributes' => array('target' => '_blank'))))),
'#default_value' => variable_get('drupalchat_external_api_key', NULL),
);
$form['drupalchat_general']['drupalchat_show_admin_list'] = array(
'#type' => 'select',
'#title' => t('Select which chat software to use'),
'#description' => t('Community chat is suitable for forums, blogs and social networking websites where you would like to users to be able to chat with each other both in rooms and one-to-one. Whereas Support chat is suitable for sites which need to attend to queries of their visitors. Please select which one to use. In Community chat, users with administer_drupalchat permission are considered as chat moderators/administrators. And, in Support chat, users with administer_drupalchat permission are considered as support staff.'),
'#options' => array(2 => 'Community Chat', 1 => 'Support Chat',),
'#default_value' => variable_get('drupalchat_show_admin_list', 2),
);
$form['drupalchat_general']['drupalchat_theme'] = array(
'#type' => 'select',
'#title' => t('Theme'),
......@@ -105,13 +130,7 @@ function drupalchat_settings_form() {
'#options' => array(1 => 'Yes', 2 => 'No'),
'#default_value' => variable_get('drupalchat_enable_smiley', 1),
);
$form['drupalchat_general']['drupalchat_enable_mobile_browser_app'] = array(
'#type' => 'select',
'#title' => t('Enable Mobile App'),
'#description' => t('Select whether to enable browser based mobile app.'),
'#options' => array('1' => 'Yes', '2' => 'No'),
'#default_value' => variable_get('drupalchat_enable_mobile_browser_app', '1'),
);
$form['drupalchat_general']['drupalchat_log_messages'] = array(
'#type' => 'select',
'#title' => t('Log chat messages'),
......@@ -127,35 +146,12 @@ function drupalchat_settings_form() {
);
$form['drupalchat_general']['drupalchat_anon_use_name'] = array(
'#type' => 'select',
'#title' => t('Use random name or number for anonymous user'),
'#description' => t('Select whether to use random generated name or number to assign to a new anonymous user'),
'#options' => array(1 => 'Name', 2 => 'Number'),
'#default_value' => variable_get('drupalchat_anon_use_name', 1),
'#title' => t('Use random name or number for anonymous user'),
'#description' => t('Select whether to use random generated name or number to assign to a new anonymous user'),
'#options' => array(1 => 'Name', 2 => 'Number'),
'#default_value' => variable_get('drupalchat_anon_use_name', 1),
);
$form['drupalchat_general']['drupalchat_anon_change_name'] = array(
'#type' => 'select',
'#title' => t('Allow anonymous user to set his/her name'),
'#description' => t('Select whether to allow anonymous user to be able to change his/her name'),
'#options' => array(1 => 'Yes', 2 => 'No'),
'#default_value' => variable_get('drupalchat_anon_change_name', 1),
);
// $form['drupalchat_anon_name_set'] = array(
// '#type' => 'select',
// '#title' => t('Select country to use for generating names of anonymous users'),
// '#options' => array('usa' => 'United States'),
// '#default_value' => variable_get('drupalchat_anon_name_set', 'usa'),
// '#wysiwyg' => false,
// );
// $result = drupal_http_request(DRUPALCHAT_EXTERNAL_A_HOST . ':' . DRUPALCHAT_EXTERNAL_A_PORT . '/anam/c', array('Content-Type' => 'application/json'));
// if($result->code == 200) {
// $result = json_decode($result->data);
// foreach($result as $k=>$v) {
// if($k != 'usa') {
// $form['drupalchat_anon_name_set']['#options'][$k] = $v;
// }
// }
// }
$form['drupalchat_general']['drupalchat_user_latency'] = array(
'#type' => 'select',
'#title' => t('Chat List Latency'),
......@@ -179,14 +175,7 @@ function drupalchat_settings_form() {
'#default_value' => variable_get('drupalchat_send_rate', 2),
'#disabled' => variable_get('drupalchat_polling_method', DRUPALCHAT_AJAX) == DRUPALCHAT_LONGPOLL ? TRUE : FALSE,
);
$form['drupalchat_general']['drupalchat_load_chat_async'] = array(
'#type' => 'select',
'#title' => t('Load chat asynchronously'),
'#description' => t('Select whether to load chat asynchronously or not.'),
'#options' => array(1 => 'Yes (Recommended)', 2 => 'No'),
'#default_value' => variable_get('drupalchat_load_chat_async', 1),
);
$form['drupalchat_pc'] = array(
'#type' => 'fieldset',
'#title' => t('Chat Moderation'),
......@@ -198,75 +187,19 @@ function drupalchat_settings_form() {
'#default_value' => variable_get('drupalchat_enable_chatroom', 1),
'#options' => array(1 => 'Yes', 2 => 'No'),
);
$form['drupalchat_pc']['drupalchat_stop_word_list'] = array(
'#type' => 'textarea',
'#title' => t('Stop Words (separated by comma)'),
'#default_value' => variable_get('drupalchat_stop_word_list', 'asshole,assholes,bastard,beastial,beastiality,beastility,bestial,bestiality,bitch,bitcher,bitchers,bitches,bitchin,bitching,blowjob,blowjobs,bullshit,clit,cock,cocks,cocksuck,cocksucked,cocksucker,cocksucking,cocksucks,cum,cummer,cumming,cums,cumshot,cunillingus,cunnilingus,cunt,cuntlick,cuntlicker,cuntlicking,cunts,cyberfuc,cyberfuck,cyberfucked,cyberfucker,cyberfuckers,cyberfucking,damn,dildo,dildos,dick,dink,dinks,ejaculate,ejaculated,ejaculates,ejaculating,ejaculatings,ejaculation,fag,fagging,faggot,faggs,fagot,fagots,fags,fart,farted,farting,fartings,farts,farty,felatio,fellatio,fingerfuck,fingerfucked,fingerfucker,fingerfuckers,fingerfucking,fingerfucks,fistfuck,fistfucked,fistfucker,fistfuckers,fistfucking,fistfuckings,fistfucks,fuck,fucked,fucker,fuckers,fuckin,fucking,fuckings,fuckme,fucks,fuk,fuks,gangbang,gangbanged,gangbangs,gaysex,goddamn,hardcoresex,horniest,horny,hotsex,jism,jiz,jizm,kock,kondum,kondums,kum,kumer,kummer,kumming,kums,kunilingus,lust,lusting,mothafuck,mothafucka,mothafuckas,mothafuckaz,mothafucked,mothafucker,mothafuckers,mothafuckin,mothafucking,mothafuckings,mothafucks,motherfuck,motherfucked,motherfucker,motherfuckers,motherfuckin,motherfucking,motherfuckings,motherfucks,niger,nigger,niggers,orgasim,orgasims,orgasm,orgasms,phonesex,phuk,phuked,phuking,phukked,phukking,phuks,phuq,pis,piss,pisser,pissed,pisser,pissers,pises,pisses,pisin,pissin,pising,pissing,pisof,pissoff,porn,porno,pornography,pornos,prick,pricks,pussies,pusies,pussy,pusy,pussys,pusys,slut,sluts,smut,spunk'),
'#wysiwyg' => false,
);
$form['drupalchat_pc']['drupalchat_use_stop_word_list'] = array(
'#type' => 'select',
'#title' => t('Use Stop Words to filter chat'),
'#description' => t('Select whether to use stop words(entered above) for filtering'),
'#options' => array('1' => t('Don\'t filter'), '2' => t('Filter in public chatroom'), '3' => t('Filter in private chats'), '4' => t('Filter in all rooms')),
'#default_value' => variable_get('drupalchat_use_stop_word_list', '1'),
);
$form['drupalchat_pc']['drupalchat_stop_links'] = array(
'#type' => 'select',
'#title' => t('Block hyperlinks'),
'#description' => t('Select whether to block hyperlinks posted in chats'),
'#options' => array('1' => t('Don\'t block'), '2' => t('Block in public chatroom'), '3' => t('Block in private chats'), '4' => t('Block in all rooms')),
'#default_value' => variable_get('drupalchat_stop_links', '1'),
);
$form['drupalchat_pc']['drupalchat_allow_anon_links'] = array(
'#type' => 'select',
'#title' => t('Apply above defined block hyperlinks settings only to anonymous users'),
'#description' => t('Select whether to apply above defined block hyperlinks setting only to anonymous users.'),
'#options' => array('1' => t('Yes, apply only to anonymous users'), '2' => t('No, apply to all users'),),
'#default_value' => variable_get('drupalchat_allow_anon_links', '1'),
);
$form['drupalchat_pc']['drupalchat_allow_render_images'] = array(
'#type' => 'select',
'#title' => t('Render image and video hyperlinks inline'),
'#description' => t('Select whether to render image and video hyperlinks inline in chat.'),
'#options' => array('1' => 'Yes', '2' => 'No'),
'#default_value' => variable_get('drupalchat_allow_render_images', '1'),
);
$form['drupalchat_pc']['drupalchat_enable_file_attachment'] = array(
'#type' => 'select',
'#title' => t('Enable File Attachment'),
'#description' => t('Enable File Attachment'),
'#options' => array('1' => 'Yes', '2' => 'No'),
'#default_value' => variable_get('drupalchat_enable_file_attachment', '1'),
);
$form['drupalchat_pc']['drupalchat_allow_single_message_delete'] = array(
'#type' => 'select',
'#title' => t('Allow users to delete messages selectively when in private conversation'),
'#description' => t('Select whether to apply above defined block hyperlinks setting only to anonymous users.'),
'#options' => array('1' => t('Allow all users'), '2' => t('Allow only moderators'), '3' => t('Disable'),),
'#default_value' => variable_get('drupalchat_allow_single_message_delete', '1'),
);
$form['drupalchat_pc']['drupalchat_allow_clear_room_history'] = array(
'#type' => 'select',
'#title' => t('Allow users to clear all messages in a room'),
'#description' => t('Select whether to allow users to clear all messages in a room'),
'#options' => array('1' => t('Allow all users'), '2' => t('Allow only moderators'), '3' => t('Disable'),),
'#default_value' => variable_get('drupalchat_allow_clear_room_history', '1'),
);
$form['drupalchat_pc']['drupalchat_allow_user_font_color'] = array(
'#type' => 'select',
'#title' => t('Allow users to set color of their name in a room'),
'#description' => t('Select whether to allow users to set color of their name in a room.'),
'#options' => array('1' => 'Yes', '2' => 'No'),
'#default_value' => variable_get('drupalchat_allow_user_font_color', '1'),
);
$form['drupalchat_path'] = array(
'#type' => 'fieldset',
'#title' => t('DrupalChat Visibility'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#collapsed' => FALSE,
);
$form['drupalchat_path']['drupalchat_show_embed_chat'] = array(
'#type' => 'item',
'#title' => t("Show Embed Chat"),
'#description' => t("Click on the !elink to view the tutorial of embedding the chat onto a page.", array('!elink' => l(t('link'), 'https://iflychat.com/embedded-chatroom-example-public-chatroom', array('attributes' => array('target' => '_blank'))))),
);
$access = user_access('use PHP for settings');
$options = array(
......@@ -296,129 +229,6 @@ function drupalchat_settings_form() {
'#description' => $description,
);
$form['drupalchat_css'] = array(
'#type' => 'fieldset',
'#title' => t('Theme Customization'),
'#collapsible' => TRUE,
);
$form['drupalchat_css']['drupalchat_chat_topbar_color'] = array(
'#type' => 'textfield',
'#title' => t('Chat Top Bar Color'),
'#description' => t("Choose the color of the top bar in the chat."),
'#default_value' => variable_get('drupalchat_chat_topbar_color', '#222222'),
'#suffix' => '<div id="drupalchat-colorpicker1"></div>',
);
$form['drupalchat_css']['drupalchat_chat_topbar_text_color'] = array(
'#type' => 'textfield',
'#title' => t('Chat Top Bar Text Color'),
'#description' => t("Choose the color of the text in top bar in the chat."),
'#default_value' => variable_get('drupalchat_chat_topbar_text_color', '#FFFFFF'),
'#suffix' => '<div id="drupalchat-colorpicker2"></div>',
);
$form['drupalchat_css']['drupalchat_font_color'] = array(
'#type' => 'textfield',
'#title' => t('Chat Font Color'),
'#description' => t("Choose the color of the text in the chat."),
'#default_value' => variable_get('drupalchat_font_color', '#222222'),
'#suffix' => '<div id="drupalchat-colorpicker3"></div>',
);
$form['drupalchat_css']['drupalchat_public_chatroom_header'] = array(
'#type' => 'textfield',
'#title' => t('Public Chatroom Header'),
'#description' => t("This is the text that will appear in header of public chatroom."),
'#default_value' => variable_get('drupalchat_public_chatroom_header', 'Public Chatroom'),
);
$form['drupalchat_css']['drupalchat_chat_list_header'] = array(
'#type' => 'textfield',
'#title' => t('Chat List Header'),
'#description' => t("This is the text that will appear in header of chat list."),
'#default_value' => variable_get('drupalchat_chat_list_header', 'Chat'),
);
$form['drupalchat_support'] = array(
'#type' => 'fieldset',
'#title' => t('Support Chat Customization'),
'#collapsible' => TRUE,
);
$form['drupalchat_support']['drupalchat_support_chat_init_label'] = array(
'#type' => 'textfield',
'#title' => t('Support Chat - Start Button Label'),
'#description' => t("The label for <i>Start Chat</i> button, which when clicked upon will launch chat."),
'#default_value' => variable_get('drupalchat_support_chat_init_label', 'Chat with us'),
);
$form['drupalchat_support']['drupalchat_support_chat_box_header'] = array(
'#type' => 'textfield',
'#title' => t('Support Chat Box Header'),
'#description' => t("This is the text that will appear as header of chat box."),
'#default_value' => variable_get('drupalchat_support_chat_box_header', 'Support'),
);
$form['drupalchat_support']['drupalchat_support']['drupalchat_support_chat_box_company_name'] = array(
'#type' => 'textfield',
'#title' => t('Support Team/Company Name'),
'#description' => t("Name of your team or company which the visitors will see in the chat box."),
'#default_value' => variable_get('drupalchat_support_chat_box_company_name', 'Support Team'),
);
$form['drupalchat_support']['drupalchat_support_chat_box_company_tagline'] = array(
'#type' => 'textfield',
'#title' => t('Support Tagline Label'),
'#description' => t("Your team/company tagline."),
'#default_value' => variable_get('drupalchat_support_chat_box_company_tagline', 'Ask us anything...'),
);
$form['drupalchat_support']['drupalchat_support_chat_auto_greet_enable'] = array(
'#type' => 'radios',
'#title' => t('Support Chat - Enable Auto Greeting Message'),
'#default_value' => variable_get('drupalchat_support_chat_auto_greet_enable', 1),
'#options' => array(1 => 'Yes', 2 => 'No'),
);
$form['drupalchat_support']['drupalchat_support_chat_auto_greet_message'] = array(
'#type' => 'textarea',
'#title' => t('Support Chat - Auto Greeting Message'),
'#description' => t("This is the text of an auto greeting message which will be displayed to visitors."),
'#default_value' => variable_get('drupalchat_support_chat_auto_greet_message', 'Hi there! Welcome to our website. Let us know if you have any query!'),
);
$form['drupalchat_support']['drupalchat_support_chat_auto_greet_time'] = array(
'#type' => 'select',
'#title' => t('Support Chat - Auto Greet Message Time Delay'),
'#description' => t('The delay, in seconds, after which the first time visitors will be shown auto greeting message.'),
'#options' => $seconds,
'#default_value' => variable_get('drupalchat_support_chat_auto_greet_time', 1),
);
$form['drupalchat_support']['drupalchat_support_chat_init_label_off'] = array(
'#type' => 'textfield',
'#title' => t('Support Chat - Leave Message Button Label'),
'#description' => t("The label for <i>Leave Message</i> button, which when clicked upon will offline form."),
'#default_value' => variable_get('drupalchat_support_chat_init_label_off', 'Leave Message'),
);
$form['drupalchat_support']['drupalchat_support_chat_offline_message_desc'] = array(
'#type' => 'textarea',
'#title' => t('Support Chat - Offline Message Description'),
'#description' => t("This is the description shown in Support Chat Offline window."),
'#default_value' => variable_get('drupalchat_support_chat_offline_message_desc', 'Hello there. We are currently offline. Please leave us a message. Thanks.'),
);
$form['drupalchat_support']['drupalchat_support_chat_offline_message_label'] = array(
'#type' => 'textfield',
'#title' => t('Support Chat - Offline Message Label'),
'#description' => t("This is the label for the <i>Message</i> textarea in Support Chat Offline window."),
'#default_value' => variable_get('drupalchat_support_chat_offline_message_label', 'Message'),
);
$form['drupalchat_support']['drupalchat_support_chat_offline_message_contact'] = array(
'#type' => 'textfield',
'#title' => t('Support Chat - Offline Contact Details Label'),
'#description' => t("This is the label for the <i>Contact Details</i> textarea in Support Chat Offline window."),
'#default_value' => variable_get('drupalchat_support_chat_offline_message_contact', 'Contact Details'),
);
$form['drupalchat_support']['drupalchat_support_chat_offline_message_send_button'] = array(
'#type' => 'textfield',
'#title' => t('Support Chat - Offline Send Button Label'),
'#description' => t("This is the label for the <i>Send Button</i> textarea in Support Chat Offline window"),
'#default_value' => variable_get('drupalchat_support_chat_offline_message_send_button', 'Send Message'),
);
$form['drupalchat_support']['drupalchat_support_chat_offline_message_email'] = array(
'#type' => 'textfield',
'#title' => t('Support Chat - Email(s) to which mail offline messages should be sent'),
'#description' => t("Enter all email ids (separated by comma) to which notification should be sent when a user leaves a message via Offline Form"),
'#default_value' => variable_get('drupalchat_support_chat_offline_message_email', variable_get('site_mail', '')),
);
$form['drupalchat_chatlist_cont'] = array(
'#type' => 'fieldset',
......@@ -426,20 +236,7 @@ function drupalchat_settings_form() {
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['drupalchat_chatlist_cont']['drupalchat_minimize_chat_user_list'] = array(
'#type' => 'select',
'#title' => t('Minimize online user list by default'),
'#description' => t('Select whether to minimize online user list in chat by default.'),
'#options' => array(1 => 'Yes', 2 => 'No'),
'#default_value' => variable_get('drupalchat_minimize_chat_user_list', 2),
);
$form['drupalchat_chatlist_cont']['drupalchat_enable_search_bar'] = array(
'#type' => 'select',
'#title' => t('Show search bar in online user list'),
'#description' => t('Select whether to show search bar in online user list.'),
'#options' => array(1 => 'Yes', 2 => 'No'),
'#default_value' => variable_get('drupalchat_enable_search_bar', 2),
);
$form['drupalchat_chatlist_cont']['drupalchat_rel'] = array(
'#type' => 'radios',
'#title' => t('Relationship method'),
......@@ -463,11 +260,43 @@ function drupalchat_settings_form() {
'#autocomplete_path' => 'drupalchat/ur-autocomplete',
//'#disabled' => variable_get('drupalchat_rel', DRUPALCHAT_REL_AUTH) == DRUPALCHAT_REL_UR ? FALSE : TRUE,
);
return system_settings_form($form);
}
function drupalchat_settings_form_validate($form, &$form_state) {
global $user;
if($form_state['values']['drupalchat_polling_method'] == DRUPALCHAT_COMMERCIAL){
$form_state['values']['drupalchat_app_id'] = trim($form_state['values']['drupalchat_app_id']);
$form_state['values']['drupalchat_external_api_key'] = trim($form_state['values']['drupalchat_external_api_key']);
$app_id = $form_state['values']['drupalchat_app_id'];
if(!(strlen($app_id) == 36 && $app_id[14] == '4')){
form_set_error('drupalchat_app_id', "Invalid APP ID.");
}
if(!$form_state['values']['drupalchat_app_id']) {
form_set_error('drupalchat_app_id', t('Please enter APP ID.'));
}
if(!$form_state['values']['drupalchat_external_api_key']) {
form_set_error('drupalchat_external_api_key', t('Please enter API key.'));
}
$formValues = array(
'api_key' => $form_state['values']['drupalchat_external_api_key'],
'app_id' => $form_state['values']['drupalchat_app_id']
);
$result = (array)_drupalchat_get_auth($user->name, $formValues);
if(!array_key_exists('key', $result)){
form_set_error('drupalchat_external_api_key', "Unable to connect to iFlyChat server. Error code - " . $result['code'] . ". Error message - " . $result['error'] . ".");
}
}
if ($form_state['values']['drupalchat_rel'] == DRUPALCHAT_REL_UR) {
if (!$form_state['values']['drupalchat_ur_name']) {
form_set_error('drupalchat_ur_name', t('You must provide the user relationship name in the Drupal UR Settings section.'));
......@@ -486,55 +315,7 @@ function drupalchat_settings_form_validate($form, &$form_state) {
form_set_error('drupalchat_ur_name', t('User Relationship type %type was not found.', array('%type' => drupal_implode_tags($error))));
}
}
if(($form_state['values']['drupalchat_polling_method'] == DRUPALCHAT_COMMERCIAL) && (!$form_state['values']['drupalchat_external_api_key'])) {
form_set_error('drupalchat_external_api_key', t('Please enter API key.'));
}
if(($form_state['values']['drupalchat_polling_method'] == DRUPALCHAT_COMMERCIAL) && ($form_state['values']['drupalchat_external_api_key'])) {
$data = array(
'api_key' => $form_state['values']['drupalchat_external_api_key'],
'enable_chatroom' => $form_state['values']['drupalchat_enable_chatroom'],
'theme' => $form_state['values']['drupalchat_theme'],
'notify_sound' => $form_state['values']['drupalchat_notification_sound'],
'smileys' => $form_state['values']['drupalchat_enable_smiley'],
'log_chat' => $form_state['values']['drupalchat_log_messages'],
'chat_topbar_color' => $form_state['values']['drupalchat_chat_topbar_color'],
'chat_topbar_text_color' => $form_state['values']['drupalchat_chat_topbar_text_color'],
'font_color' => $form_state['values']['drupalchat_font_color'],
'chat_list_header' => $form_state['values']['drupalchat_chat_list_header'],
'public_chatroom_header' => $form_state['values']['drupalchat_public_chatroom_header'],
'rel' => $form_state['values']['drupalchat_rel'],
'version' => '6.x-2.0-beta29',
'show_admin_list' => $form_state['values']['drupalchat_show_admin_list'],
'clear' => $form_state['values']['drupalchat_allow_single_message_delete'],
'delmessage' => $form_state['values']['drupalchat_allow_clear_room_history'],
'ufc' => $form_state['values']['drupalchat_allow_user_font_color'],
'guest_prefix' => ($form_state['values']['drupalchat_anon_prefix'] . " "),
'enable_guest_change_name' => $form_state['values']['drupalchat_anon_change_name'],
'use_stop_word_list' => $form_state['values']['drupalchat_use_stop_word_list'],
'stop_word_list' => $form_state['values']['drupalchat_stop_word_list'],
'file_attachment' => $form_state['values']['drupalchat_enable_file_attachment'],
'mobile_browser_app' => $form_state['values']['drupalchat_enable_mobile_browser_app'],
);
if($form_state['values']['drupalchat_rel'] > DRUPALCHAT_REL_AUTH) {
$new_valid_uids = _drupalchat_get_buddylist($user->uid, $form_state['values']['drupalchat_ur_name']);
if(!isset($_SESSION['drupalchat_valid_uids']) || ($_SESSION['drupalchat_valid_uids'] != $new_valid_uids)) {
$data['valid_uids'] = $new_valid_uids;
$_SESSION['drupalchat_valid_uids'] = $new_valid_uids;
}
else {
$data['valid_uids'] = $new_valid_uids;
}
}
$data = json_encode($data);
$result = drupal_http_request(DRUPALCHAT_EXTERNAL_A_HOST . ':' . DRUPALCHAT_EXTERNAL_A_PORT . '/z/', array('Content-Type' => 'application/json'), 'POST', $data, 15);
if($result->code == 200) {
$result = json_decode($result->data);
}
else {
form_set_error('drupalchat_external_api_key', "Unable to connect to iFlyChat server. Error code - " . $result->code . ". Error message - " . $result->error . ".");
}
}
}
function _drupalchat_load_themes($outerDir, $x) {
......
drupalchat.module 100644 → 100755
This diff is collapsed.
// $(document).ready(function() {
// $('#drupalchat-colorpicker1').farbtastic('#edit-drupalchat-chat-topbar-color');
// $('#drupalchat-colorpicker2').farbtastic('#edit-drupalchat-chat-topbar-text-color');
// $('#drupalchat-colorpicker3').farbtastic('#edit-drupalchat-font-color');
// $("fieldset > legend:contains('Theme Customization')").parent().hide();
// $("input[name=drupalchat_polling_method]").change(function() {
// $('#edit-drupalchat-external-api-key').attr('disabled', 'disabled');
// $('#edit-drupalchat-external-api-key-wrapper').hide();
// $("fieldset > legend:contains('Theme Customization')").parent().hide();
// $('#edit-drupalchat-stop-word-list-wrapper').hide();
// $('#edit-drupalchat-use-stop-word-list-wrapper').hide();
// $('#edit-drupalchat-stop-links-wrapper').hide();
// $('#edit-drupalchat-allow-anon-links-wrapper').hide();
// $('#edit-drupalchat-allow-single-message-delete-wrapper').hide();
// $('#edit-drupalchat-allow-clear-room-history-wrapper').hide();
// $('#edit-drupalchat-show-admin-list-wrapper').hide();
// $('#edit-drupalchat-enable-mobile-browser-app-wrapper').hide();
// $('#edit-drupalchat-anon-name-set-wrapper').hide();
// $('#edit-drupalchat-anon-change-name-wrapper').hide();
// $('#edit-drupalchat-load-chat-async-wrapper').hide();
// $('#edit-drupalchat-enable-file-attachment-wrapper').hide();
// $('#edit-drupalchat-minimize-chat-user-list-wrapper').hide();
// $('#edit-drupalchat-enable-search-bar-wrapper').hide();
// $('#edit-drupalchat-allow-render-images-wrapper').hide();
// $('#edit-drupalchat-allow-user-font-color-wrapper').hide();
// $('#edit-drupalchat-user-latency-wrapper').show();
// $('#edit-drupalchat-refresh-rate-wrapper').show();
// $('#edit-drupalchat-send-rate-wrapper').show();
// $('#edit-drupalchat-rel-wrapper').show();
// $('#edit-drupalchat-ur-name-wrapper').show();
// if ($("input[name=drupalchat_polling_method]:checked").val() == '0') {
// $('#edit-drupalchat-refresh-rate').removeAttr('disabled');
// $('#edit-drupalchat-send-rate').removeAttr('disabled');
// $('#edit-drupalchat-refresh-rate-wrapper').fadeIn();
// $('#edit-drupalchat-send-rate-wrapper').fadeIn();
// }
// else if ($("input[@name=drupalchat_polling_method]:checked").val() == '1') {
// $('#edit-drupalchat-refresh-rate').attr('disabled', 'disabled');
// $('#edit-drupalchat-send-rate').attr('disabled', 'disabled');
// $('#edit-drupalchat-refresh-rate-wrapper').hide();
// $('#edit-drupalchat-send-rate-wrapper').hide();
// }
// else if($("input[@name=drupalchat_polling_method]:checked").val() == '3') {
// $('#edit-drupalchat-external-api-key').removeAttr('disabled');
// $('#edit-drupalchat-external-api-key-wrapper').fadeIn();
// $("fieldset > legend:contains('Theme Customization')").parent().fadeIn();
// $('#edit-drupalchat-user-latency-wrapper').hide();
// $('#edit-drupalchat-refresh-rate-wrapper').hide();
// $('#edit-drupalchat-send-rate-wrapper').hide();
// $('#edit-drupalchat-rel-wrapper').hide();
// $('#edit-drupalchat-ur-name-wrapper').hide();
// $('#edit-drupalchat-stop-word-list-wrapper').show();
// $('#edit-drupalchat-use-stop-word-list-wrapper').show();
// $('#edit-drupalchat-stop-links-wrapper').show();
// $('#edit-drupalchat-allow-anon-links-wrapper').show();
// $('#edit-drupalchat-allow-single-message-delete-wrapper').show();
// $('#edit-drupalchat-allow-clear-room-history-wrapper').show();
// $('#edit-drupalchat-show-admin-list-wrapper').show();
// $('#edit-drupalchat-user-picture-wrapper').show();
// $('#edit-drupalchat-enable-mobile-browser-app-wrapper').show();
// $('#edit-drupalchat-anon-name-set-wrapper').show();
// $('#edit-drupalchat-anon-use-name-wrapper').show();
// $('#edit-drupalchat-anon-change-name-wrapper').show();
// $('#edit-drupalchat-load-chat-async-wrapper').show();
// $('#edit-drupalchat-allow-render-images-wrapper').show();
// $('#edit-drupalchat-allow-user-font-color-wrapper').show();
// $('#edit-drupalchat-enable-file-attachment-wrapper').show();
// $('#edit-drupalchat-minimize-chat-user-list-wrapper').show();
// $('#edit-drupalchat-enable-search-bar-wrapper').show();
// }
// });
// $("input[name=drupalchat_rel]").change(function() {
// if ($("input[name=drupalchat_rel]:checked").val() == '1') {
// $('#edit-drupalchat-ur-name').removeAttr('disabled');
// $('#edit-drupalchat-ur-name-wrapper').fadeIn();
// }
// else {
// $('#edit-drupalchat-ur-name').attr('disabled', 'disabled');
// $('#edit-drupalchat-ur-name-wrapper').hide();
// }
// });
// $("#edit-drupalchat-show-admin-list").change(function() {
// if ($("#edit-drupalchat-show-admin-list").val() == '1') {
// $("fieldset > legend:contains('Support Chat Customization')").parent().fadeIn();
// }
// else {
// $("fieldset > legend:contains('Support Chat Customization')").parent().hide();
// }
// });
// $("input[name=drupalchat_polling_method]").change();
// $("input[name=drupalchat_rel]").change();
// $("#edit-drupalchat-show-admin-list").change();
// });
$(document).ready(function() {
$('#drupalchat-colorpicker1').farbtastic('#edit-drupalchat-chat-topbar-color');
$('#drupalchat-colorpicker2').farbtastic('#edit-drupalchat-chat-topbar-text-color');
$('#drupalchat-colorpicker3').farbtastic('#edit-drupalchat-font-color');
$("fieldset > legend:contains('Theme Customization')").parent().hide();
$("input[name=drupalchat_polling_method]").change(function() {
$('#edit-drupalchat-external-api-key').attr('disabled', 'disabled');
$('#edit-drupalchat-external-api-key-wrapper').hide();
$("fieldset > legend:contains('Theme Customization')").parent().hide();
$('#edit-drupalchat-stop-word-list-wrapper').hide();
$('#edit-drupalchat-use-stop-word-list-wrapper').hide();
$('#edit-drupalchat-stop-links-wrapper').hide();
$('#edit-drupalchat-allow-anon-links-wrapper').hide();
$('#edit-drupalchat-allow-single-message-delete-wrapper').hide();
$('#edit-drupalchat-allow-clear-room-history-wrapper').hide();
$('#edit-drupalchat-show-admin-list-wrapper').hide();
$('#edit-drupalchat-enable-mobile-browser-app-wrapper').hide();
$('#edit-drupalchat-anon-name-set-wrapper').hide();
$('#edit-drupalchat-anon-change-name-wrapper').hide();
$('#edit-drupalchat-load-chat-async-wrapper').hide();
$('#edit-drupalchat-enable-file-attachment-wrapper').hide();
$('#edit-drupalchat-minimize-chat-user-list-wrapper').hide();
$('#edit-drupalchat-enable-search-bar-wrapper').hide();
$('#edit-drupalchat-allow-render-images-wrapper').hide();
$('#edit-drupalchat-allow-user-font-color-wrapper').hide();
$('#edit-drupalchat-user-latency-wrapper').show();
$('#edit-drupalchat-refresh-rate-wrapper').show();
$('#edit-drupalchat-send-rate-wrapper').show();
$('#edit-drupalchat-rel-wrapper').show();
$('#edit-drupalchat-ur-name-wrapper').show();
if ($("input[name=drupalchat_polling_method]:checked").val() == '0') {
$('#edit-drupalchat-refresh-rate').removeAttr('disabled');
$('#edit-drupalchat-send-rate').removeAttr('disabled');
$('#edit-drupalchat-refresh-rate-wrapper').fadeIn();
$('#edit-drupalchat-send-rate-wrapper').fadeIn();
}
else if ($("input[@name=drupalchat_polling_method]:checked").val() == '1') {
$('#edit-drupalchat-refresh-rate').attr('disabled', 'disabled');
$('#edit-drupalchat-send-rate').attr('disabled', 'disabled');
if($("input[name=drupalchat_polling_method]:checked").val() != '3'){
$('#edit-drupalchat-app-id-wrapper').hide();
$('#edit-drupalchat-external-api-key-wrapper').hide();
$('#edit-drupalchat-notification-sound-wrapper').show();
$('#edit-drupalchat-theme-wrapper').show();
$('#edit-drupalchat-user-picture-wrapper').show();
$('#edit-drupalchat-enable-smiley-wrapper').show();
$('#edit-drupalchat-log-messages-wrapper').show();
$('#edit-drupalchat-anon-prefix-wrapper').show();
$('#edit-drupalchat-anon-use-name-wrapper').show();
$('#edit-drupalchat-user-latency-wrapper').show();
$('#edit-drupalchat-refresh-rate-wrapper').show();
$('#edit-drupalchat-send-rate-wrapper').show();
$("fieldset > legend:contains('Chat Moderation')").parent().fadeIn();
//$('#edit-drupalchat-enable-chatroom-wrapper').show();
$("div > label:contains('Show Embed Chat: ')").parent().fadeOut();
}else{
$('#edit-drupalchat-app-id-wrapper').show();
$('#edit-drupalchat-external-api-key-wrapper').show();
$('#edit-drupalchat-notification-sound-wrapper').hide();
$('#edit-drupalchat-theme-wrapper').hide();
$('#edit-drupalchat-user-picture-wrapper').hide();
$('#edit-drupalchat-enable-smiley-wrapper').hide();
$('#edit-drupalchat-log-messages-wrapper').hide();
$('#edit-drupalchat-anon-prefix-wrapper').hide();
$('#edit-drupalchat-anon-use-name-wrapper').hide();
$('#edit-drupalchat-user-latency-wrapper').hide();
$('#edit-drupalchat-refresh-rate-wrapper').hide();
$('#edit-drupalchat-send-rate-wrapper').hide();
}
else if($("input[@name=drupalchat_polling_method]:checked").val() == '3') {
$('#edit-drupalchat-external-api-key').removeAttr('disabled');
$('#edit-drupalchat-external-api-key-wrapper').fadeIn();
$("fieldset > legend:contains('Theme Customization')").parent().fadeIn();
$('#edit-drupalchat-user-latency-wrapper').hide();
$('#edit-drupalchat-refresh-rate-wrapper').hide();
$('#edit-drupalchat-send-rate-wrapper').hide();
$('#edit-drupalchat-rel-wrapper').hide();
$('#edit-drupalchat-ur-name-wrapper').hide();
$('#edit-drupalchat-stop-word-list-wrapper').show();
$('#edit-drupalchat-use-stop-word-list-wrapper').show();
$('#edit-drupalchat-stop-links-wrapper').show();
$('#edit-drupalchat-allow-anon-links-wrapper').show();
$('#edit-drupalchat-allow-single-message-delete-wrapper').show();
$('#edit-drupalchat-allow-clear-room-history-wrapper').show();
$('#edit-drupalchat-show-admin-list-wrapper').show();
$('#edit-drupalchat-user-picture-wrapper').show();
$('#edit-drupalchat-enable-mobile-browser-app-wrapper').show();
$('#edit-drupalchat-anon-name-set-wrapper').show();
$('#edit-drupalchat-anon-use-name-wrapper').show();
$('#edit-drupalchat-anon-change-name-wrapper').show();
$('#edit-drupalchat-load-chat-async-wrapper').show();
$('#edit-drupalchat-allow-render-images-wrapper').show();
$('#edit-drupalchat-allow-user-font-color-wrapper').show();
$('#edit-drupalchat-enable-file-attachment-wrapper').show();
$('#edit-drupalchat-minimize-chat-user-list-wrapper').show();
$('#edit-drupalchat-enable-search-bar-wrapper').show();
}
$("fieldset > legend:contains('Chat Moderation')").parent().fadeOut();
//$('#edit-drupalchat-enable-chatroom-wrapper').hide();
$("div > label:contains('Show Embed Chat: ')").parent().fadeIn();
}
});
$("input[name=drupalchat_rel]").change(function() {
if ($("input[name=drupalchat_rel]:checked").val() == '1') {
$('#edit-drupalchat-ur-name').removeAttr('disabled');
$('#edit-drupalchat-ur-name').attr('required', 'true');
$('#edit-drupalchat-ur-name-wrapper').fadeIn();
}
else {
$('#edit-drupalchat-ur-name').attr('disabled', 'disabled');
$('#edit-drupalchat-ur-name-wrapper').hide();
$('#edit-drupalchat-ur-name').removeAttr('required');
$('#edit-drupalchat-ur-name-wrapper').hide();
}
});
});
$("#edit-drupalchat-show-admin-list").change(function() {
if ($("#edit-drupalchat-show-admin-list").val() == '1') {
$("fieldset > legend:contains('Support Chat Customization')").parent().fadeIn();
}
else {
$("fieldset > legend:contains('Support Chat Customization')").parent().hide();
}
});
$("input[name=drupalchat_polling_method]").change();
$("input[name=drupalchat_rel]").change();
$("#edit-drupalchat-show-admin-list").change();
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment