Changeset 1877831
- Timestamp:
- 05/19/2018 10:20:16 PM (8 years ago)
- Location:
- chatwee/trunk
- Files:
-
- 1 deleted
- 5 edited
-
chatwee-admin.php (modified) (3 diffs)
-
chatwee.php (modified) (16 diffs)
-
lib/ChatweeV1_SDK (deleted)
-
lib/ChatweeV2_SDK/Chatwee/SsoUser.php (modified) (1 diff)
-
lib/ChatweeV2_SDK/Chatwee/Utils.php (modified) (1 diff)
-
readme.txt (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
chatwee/trunk/chatwee-admin.php
r1808954 r1877831 31 31 $chatwee_settings = get_option("chatwee_settings"); 32 32 33 $chatwee_settings["chatwee_version"] = $_POST["chatwee_version"];34 33 $chatwee_settings["chatwee_script"] = $_POST["chatwee_script"]; 35 34 $chatwee_settings["disable_offline_users"] = isSet($_POST["disable_offline_users"]) ? true : false; … … 52 51 $chatwee_settings = get_option("chatwee_settings"); 53 52 $keys = array( 54 "chatwee_version",55 53 "chatwee_script", 56 54 "disable_offline_users", … … 131 129 <form method="post"> 132 130 <table class="form-table chatwee-options-table"> 133 <tr>134 <th>135 <label for="chatwee_version">Chatwee version</label>136 </th>137 <td>138 <select id="chatwee_version" name="chatwee_version">139 <option value="v1" <?php if ($chatwee_settings["chatwee_version"] === "v1") echo "selected"; ?>>Chatwee 1.0</option>140 <option value="v2" <?php if ($chatwee_settings["chatwee_version"] === "v2") echo "selected"; ?>>Chatwee 2.0</option>141 </select>142 </td>143 </tr>144 131 <tr> 145 132 <th> -
chatwee/trunk/chatwee.php
r1796149 r1877831 5 5 Plugin URI: https://chatwee.com/ 6 6 Description: WordPress Chat by Chatwee is fully customizable social chat & comment platform for websites and blogs. With Chatwee you can engage your online community and provide real-time communication. 7 Version: 2. 0.57 Version: 2.1.1 8 8 Author: Chatwee Ltd 9 9 Author URI: https://chatwee.com/ … … 18 18 require_once(dirname( __FILE__ ) . "/chatwee-admin.php"); 19 19 20 require_once(dirname( __FILE__ ) . "/lib/ChatweeV1_SDK/Chatwee.php");21 22 20 require_once(dirname( __FILE__ ) . "/lib/ChatweeV2_SDK/Chatwee.php"); 23 21 … … 27 25 function get_default_chatwee_settings() { 28 26 return Array( 29 "chatwee_version" => "v2",30 27 "chatwee_script" => "", 31 28 "disable_offline_users" => false, … … 120 117 } 121 118 122 function initialize_v1() { 123 $chatwee_settings = get_option("chatwee_settings"); 124 125 ChatweeV1_Configuration::setChatId($chatwee_settings["chat_id"]); 126 ChatweeV1_Configuration::setClientKey($chatwee_settings["client_key"]); 127 128 if($chatwee_settings["disable_offline_users"] === true && $chatwee_settings["enable_sso"] === true && is_user_logged_in() === false && ChatweeV1_User::isLogged() === true) { 129 logout_v1(); 130 } 131 132 if($chatwee_settings["enable_sso"] === true && is_user_logged_in() === true && ChatweeV1_User::isLogged() === false) { 133 login_v1(wp_get_current_user()); 134 } 135 } 136 137 function initialize_v2() { 119 function initialize() { 138 120 $chatwee_settings = get_option("chatwee_settings"); 139 121 140 122 ChatweeV2_Configuration::setChatId($chatwee_settings["chat_id"]); 141 123 ChatweeV2_Configuration::setClientKey($chatwee_settings["client_key"]); 142 ChatweeV2_Configuration::setCustomUserAgent("Chatwee Wordpress Plugin 2. 0.4");124 ChatweeV2_Configuration::setCustomUserAgent("Chatwee Wordpress Plugin 2.1.1"); 143 125 144 126 if($chatwee_settings["disable_offline_users"] === true && $chatwee_settings["enable_sso"] === true && is_user_logged_in() === false && ChatweeV2_Session::isSessionSet() === true) { 145 logout_v2();127 sso_logout(); 146 128 } 147 129 … … 149 131 if($chatwee_settings["enable_sso"] === true && is_user_logged_in() === true) { 150 132 if(ChatweeV2_Session::isSessionSet() === false) { 151 login_v2(wp_get_current_user());133 sso_login(wp_get_current_user()); 152 134 } else { 153 135 $sessionId = ChatweeV2_Session::getSessionId(); … … 158 140 159 141 if($isSessionValid === false) { 160 login_v2(wp_get_current_user());142 sso_login(wp_get_current_user()); 161 143 } 162 144 } … … 172 154 } 173 155 174 $chatwee_settings = get_option("chatwee_settings"); 175 176 if($chatwee_settings["chatwee_version"] === "v1") { 177 initialize_v1(); 178 } 179 if($chatwee_settings["chatwee_version"] === "v2") { 180 initialize_v2(); 181 } 156 initialize(); 182 157 } 183 158 184 159 add_action("init", "init_handler"); 185 160 186 function render _v1() {161 function render() { 187 162 $chatwee_settings = get_option("chatwee_settings"); 188 163 … … 191 166 } 192 167 if(is_page_enabled() === true) { 168 $chatwee_settings = get_option("chatwee_settings"); 169 193 170 echo $chatwee_settings["chatwee_script"]; 194 171 } 195 172 } 196 173 197 function render_v2() {198 $chatwee_settings = get_option("chatwee_settings");199 200 if(is_user_logged_in() === false && $chatwee_settings["disable_offline_users"] === true) {201 return false;202 }203 if(is_page_enabled() === true) {204 $chatwee_settings = get_option("chatwee_settings");205 206 echo $chatwee_settings["chatwee_script"];207 }208 }209 210 174 function wp_footer_handler() { 211 175 $chatwee_settings = get_option("chatwee_settings"); 212 176 213 if($chatwee_settings["chatwee_version"] === "v1") { 214 render_v1(); 215 } 216 if($chatwee_settings["chatwee_version"] === "v2") { 217 render_v2(); 218 } 177 render(); 219 178 } 220 179 221 180 add_action("wp_footer", "wp_footer_handler"); 222 181 223 function login_v1($user) { 224 $username = $user->display_name ? $user->display_name : $user->user_login; 225 226 $chatwee_settings = get_option("chatwee_settings"); 227 228 try { 229 $session_id = ChatweeV1_User::login(Array( 230 "login" => $username, 182 function sso_login($user) { 183 $chatwee_user_id = get_user_meta($user->ID, "chatwee_v2_user_id_" . ChatweeV2_Configuration::getChatId(), true); 184 185 if(!$chatwee_user_id) { 186 $chatwee_user_id = sso_register($user); 187 } 188 189 try { 190 ChatweeV2_SsoUser::edit(Array( 191 "userId" => $chatwee_user_id, 192 "login" => $user->display_name ? $user->display_name : $user->user_login, 231 193 "avatar" => get_chatwee_avatar_url($user->ID), 232 194 "isAdmin" => does_user_belong_to_moderator_group($user->ID) || if_user_is_moderator($user->ID) 233 195 )); 234 196 } catch(Exception $exception) { 235 add_log("Error while executing login_v1: " . $exception->getMessage()); 236 } 237 } 238 239 function login_v2($user) { 240 $chatwee_user_id = get_user_meta($user->ID, "chatwee_v2_user_id_" . ChatweeV2_Configuration::getChatId(), true); 241 if(!$chatwee_user_id) { 242 $chatwee_user_id = register_v2($user); 243 } 244 245 $has_been_promoted_as_chatwee_moderator_on_wordpress = does_user_belong_to_moderator_group($user->ID) || if_user_is_moderator($user->ID); 246 $has_been_set_as_moderator_on_chatwee = get_user_meta($user->ID, "has_been_set_as_moderator_on_chatwee", true) == 1 ? 1 : 0; 247 248 if ($has_been_promoted_as_chatwee_moderator_on_wordpress == true && $has_been_set_as_moderator_on_chatwee == 0) { 249 try { 250 ChatweeV2_SsoUser::edit(Array( 251 "userId" => $chatwee_user_id, 252 "login" => $user->display_name ? $user->display_name : $user->user_login, 253 "avatar" => get_chatwee_avatar_url($user->ID), 254 "isAdmin" => true 255 )); 256 update_user_meta($user->ID, "has_been_set_as_moderator_on_chatwee", 1); 257 } catch(Exception $exception) { 258 add_log("Error: " . $exception->getMessage()); 259 } 260 } elseif ($has_been_promoted_as_chatwee_moderator_on_wordpress == false && $has_been_set_as_moderator_on_chatwee == 1) { 261 try { 262 ChatweeV2_SsoUser::edit(Array( 263 "userId" => $chatwee_user_id, 264 "login" => $user->display_name ? $user->display_name : $user->user_login, 265 "avatar" => get_chatwee_avatar_url($user->ID), 266 "isAdmin" => false 267 )); 268 update_user_meta($user->ID, "has_been_set_as_moderator_on_chatwee", 0); 269 } catch(Exception $exception) { 270 add_log("Error: " . $exception->getMessage()); 197 if(strpos($exception->getMessage(), "User does not exist") !== false) { 198 $chatwee_user_id = sso_register($user); 199 } else { 200 add_log("Error while executing sso_login: " . $exception->getMessage()); 271 201 } 272 202 } … … 277 207 )); 278 208 } catch(Exception $exception) { 279 add_log("Error while executing login_v2: " . $exception->getMessage());209 add_log("Error while executing sso_login: " . $exception->getMessage()); 280 210 } 281 211 } … … 284 214 $chatwee_settings = get_option("chatwee_settings"); 285 215 286 if($chatwee_settings["chatwee_version"] === "v1") { 287 login_v1($user); 288 } 289 if($chatwee_settings["chatwee_version"] === "v2") { 290 login_v2($user); 291 } 216 sso_login($user); 292 217 } 293 218 … … 296 221 } 297 222 298 function logout_v1() { 299 $chatwee_settings = get_option("chatwee_settings"); 300 301 try { 302 ChatweeV1_User::logout(); 303 } catch(Exception $exception) { 304 add_log("Error while executing logout_v1: " . $exception->getMessage()); 305 } 306 } 307 308 function logout_v2() { 223 function sso_logout() { 309 224 $chatwee_settings = get_option("chatwee_settings"); 310 225 … … 312 227 ChatweeV2_SsoManager::logoutUser(); 313 228 } catch(Exception $exception) { 314 add_log("Error while executing logout_v2: " . $exception->getMessage());229 add_log("Error while executing sso_logout: " . $exception->getMessage()); 315 230 } 316 231 } … … 319 234 $chatwee_settings = get_option("chatwee_settings"); 320 235 321 if($chatwee_settings["chatwee_version"] === "v1") { 322 logout_v1(); 323 } 324 if($chatwee_settings["chatwee_version"] === "v2") { 325 logout_v2(); 326 } 236 sso_logout(); 327 237 } 328 238 … … 331 241 } 332 242 333 function register_v2($user) {243 function sso_register($user) { 334 244 335 245 $username = $user->display_name ? $user->display_name : $user->user_login; … … 345 255 346 256 update_user_meta($user->ID, "chatwee_v2_user_id_" . ChatweeV2_Configuration::getChatId(), $user_id); 347 update_user_meta($user->ID, "has_been_set_as_moderator_on_chatwee", does_user_belong_to_moderator_group($user->ID) || if_user_is_moderator($user->ID));348 257 349 258 return $user_id; 350 259 } catch(Exception $exception) { 351 add_log("Error while executing register_v2: " . $exception->getMessage());260 add_log("Error while executing sso_register: " . $exception->getMessage()); 352 261 return null; 353 262 } … … 357 266 $user = get_user_by("id", $user_id); 358 267 359 register_v2($user);268 sso_register($user); 360 269 } 361 270 362 271 if($chatwee_settings["enable_sso"] === true) { 363 272 add_action("user_register", "user_register_handler", 10, 1); 364 }365 366 function edit_v2($user) {367 368 $chatwee_settings = get_option("chatwee_settings");369 370 $chatwee_user_id = get_user_meta($user->ID, "chatwee_v2_user_id_" . ChatweeV2_Configuration::getChatId(), true);371 372 if(!$chatwee_user_id) {373 $chatwee_user_id = register_v2($user);374 }375 376 try {377 ChatweeV2_SsoManager::editUser(Array(378 "userId" => $chatwee_user_id,379 "login" => $user->display_name ? $user->display_name : $user->user_login,380 "avatar" => get_chatwee_avatar_url($user->ID),381 "isAdmin" => does_user_belong_to_moderator_group($user->ID) || if_user_is_moderator($user->ID)382 ));383 update_user_meta($user->ID, "has_been_set_as_moderator_on_chatwee", does_user_belong_to_moderator_group($user->ID) || if_user_is_moderator($user->ID));384 } catch(Exception $exception) {385 add_log("Error while executing edit_v2: " . $exception->getMessage());386 }387 }388 389 function user_edit_handler($user_id) {390 $user = get_user_by("id", $user_id);391 392 edit_v2($user);393 }394 395 if($chatwee_settings["enable_sso"] === true) {396 add_action("profile_update", 'user_edit_handler', 10, 2);397 273 } 398 274 -
chatwee/trunk/lib/ChatweeV2_SDK/Chatwee/SsoUser.php
r1711815 r1877831 22 22 "userId" => $parameters["userId"] 23 23 ); 24 25 if(isSet($parameters["userIp"])) 26 { 27 if(filter_var($parameters["userIp"], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false) 28 { 29 $requestParameters["userIp"] = $parameters["userIp"]; 30 } 31 } 24 32 25 33 $httpClient = new ChatweeV2_HttpClient(); -
chatwee/trunk/lib/ChatweeV2_SDK/Chatwee/Utils.php
r1564521 r1877831 13 13 return $ip; 14 14 } 15 16 public static function isMobileDevice() {17 $user_agent = strtolower ( $_SERVER['HTTP_USER_AGENT'] );18 19 if (preg_match("/phone|iphone|itouch|ipod|symbian|android|htc_|htc-|palmos|blackberry|opera mini|iemobile|windows ce|nokia|fennec|hiptop|kindle|mot |mot-|webos\/|samsung|sonyericsson|^sie-|nintendo/", $user_agent)) {20 return true;21 } else if (preg_match("/mobile|pda;|avantgo|eudoraweb|minimo|netfront|brew|teleca|lg;|lge |wap;| wap /", $user_agent)) {22 return true;23 }24 return false;25 }26 15 } -
chatwee/trunk/readme.txt
r1712683 r1877831 1 1 === WordPress Chat by Chatwee === 2 2 Plugin Name: WordPress Chat by Chatwee 3 Contributors: paulq3 Contributors: Wojciech Majerski 4 4 Tags: live chat, chat, chat plugin, chat widget, group chat, chat room, free chat, social chat, chat box, shout box, online community, community, engage, contact us, customer support, support, live support, live help, wordpress chat, wordpress live chat, chat system, website chat, comments system, user experience 5 5 Requires at least: 3.0.1 6 Tested up to: 4. 7.26 Tested up to: 4.9.6 7 7 Stable tag: 4.3 8 8 License: GPLv2 or later … … 25 25 Chatwee can become your site’s social hub, a place where community members come together to interact, or serve as an add-on supporting comments section or a forum. 26 26 27 Importantly, with our plugin, you actually gain access to two independent widgets, both of which you can test absolutely for free.28 29 27 Sign up with no commitments whatsoever and add a new, dynamic element to spark up your site. As proven by numerous sites using Chatwee, we’re among the leaders in providing solutions supporting online community growth. 30 28 31 29 [See Chatwee 2.0 live](https://chatwee.com) 32 30 33 [See Chatwee 1.0 live](https://v1.chatwee.com)34 35 31 = Key benefits of the Chatwee WordPress plugin: = 36 * two distinct products in one package - decide which one suits you best and go with it, or easily switch anytime37 32 * extensive customization options 38 33 * user-friendly installation, including enabling Single Sign-on utilizing your WordPress user database … … 42 37 * To use the plugin, please [sign up](https://client.chatwee.com/v2/dashboard) with us first. It’s free and you’ll need access to the installation code, in order to get this plugin to work. 43 38 * [WordPress chat plugin installation instruction](https://chatwee.com/wordpress-chat-plugin-installation) 44 * [Chatwee 2.0features](https://chatwee.com/full-features) / [Chatwee 1.0 features](https://v1.chatwee.com/features)45 * [Chatwee 2.0support center](https://chatwee.com/support) / [Chatwee 1.0 support center](https://support.chatwee.com)39 * [Chatwee features](https://chatwee.com/full-features) / [Chatwee 1.0 features](https://v1.chatwee.com/features) 40 * [Chatwee support center](https://chatwee.com/support) / [Chatwee 1.0 support center](https://support.chatwee.com) 46 41 * Follow us on [Facebook](https://facebook.com/chatwee), [Twitter](https://twitter.com/Chatwee) and [Pinterest](https://pl.pinterest.com/chatwee/) for the latest updates 47 42 * Visit our [blog](http://blog.chatwee.com) for inspirational posts. … … 50 45 == Installation == 51 46 52 By installing the Chatwee WordPress Chat plugin you gain access to two independent widgets. Once you’re done with the setup, you’ll be able to choose the one you wish to actually use from a dropdown menu.Follow the steps below to get the chat going in no time.47 Follow the steps below to get the chat going in no time. 53 48 54 49 Please note that in order to use the plugin, you have to [sign up](https://chatwee.com/) with us first. Don’t worry, the account is free and comes with absolutely no commitments. … … 57 52 2. Type Chatwee WordPress Chat into the search bar. 58 53 3. Once WordPress Directory shows you the search result, install the plugin and activate it. 59 4. Next, log in to your [Chatwee Dashboard](https://client.chatwee.com/v2/dashboard) and copy the relevant installation code (1.0 or 2.0)into a box in the plugin settings page (the plugin will be listed in the left column of your WordPress admin panel). Save changes.54 4. Next, log in to your [Chatwee Dashboard](https://client.chatwee.com/v2/dashboard) and copy the relevant installation code into a box in the plugin settings page (the plugin will be listed in the left column of your WordPress admin panel). Save changes. 60 55 5. That’s it! Now go ahead and explore customization options in your [Chatwee Dashboard](https://client.chatwee.com/v2/customize) and the plugin settings page. 61 56 … … 135 130 * Plugin GUI improved 136 131 132 = 2.1.1 = 133 134 * No longer supporting Chatwee 1.0 135 * SSO user re-registered if no corresponding Chatwee user found 136 137 137 == Frequently Asked Questions == 138 138 … … 147 147 = How much customization can I do? = 148 148 149 Chatwee WordPress Chat plugin gives you access to two individual widgets. With Chatwee 1.0, you can customize things like the color of the background, border and text, choose font and its size, as well as select one of the three display modes available. 150 Using Chatwee 2.0, you can click and drag the chat window to adjust its size to the one that fits you best. It also offers the option to set up multiple chat rooms with paid plans. 149 Using Chatwee you can click and drag the chat window to adjust its size to the one that fits you best. It also offers the option to set up multiple chat rooms with paid plans. 151 150 There’s plenty more, though, and the best way to learn about Chatwee is to install it and explore it on your own. Essentially, these are two different products, and comparing them isn’t really fair, as they both offer unique features to their users. 152 151 … … 157 156 = Is Chatwee available in my language? = 158 157 159 Chatwee 1.0 is currently available in: English, Spanish, Chinese, Arabic, Persian, Kurdish, Hebrew, Bengali, Telugu, Turkish, Portuguese, Russian, German, French, Danish, Finnish, Polish, Czech, Hungarian, Slovenian, Slovak, Thai, Dutch, Italian, Korean, Greek, Swedish, Norwegian, Hindi, Serbian, Croatian, Japanese, Romanian and Vietnamese. 160 Chatwee 2.0 is still a relatively new product and is currently only available in English. 158 Chatwee is currently available in: English, Portuguese, Polish, Spanish, French, Bulgarian, Hebrew, Finnish, Czech, Indonesian, Turkish, Ukrainian, Russian, Norwegian, Japanese and German. 161 159 Would you like to help us translate Chatwee? If so, [let us know](https://chatwee.com/contact) and we'll send you the array of phrases to translate from English. In exchange, we'll offer you a free, one-time upgrade to your current plan. 162 160 … … 171 169 = What types of media can Chatwee users share? = 172 170 173 Our chat widget is all about rich, real time interaction. With Chatwee 1.0, you can upload files up to 2 MB that become available for download, as well as post videos and images, with previews generated based on their original URLs. 174 Using Chatwee 2.0, you can upload files as well, and on top of that, you can easily share images and animated gifs simply by selecting the file from your phone or hard drive. 171 Using Chatwee you can upload files as well, and on top of that, you can easily share images and animated gifs simply by selecting the file from your phone or hard drive. 175 172 176 173 = What payment methods do you accept? =
Note: See TracChangeset
for help on using the changeset viewer.