Changeset 507062
- Timestamp:
- 02/18/2012 07:02:04 PM (14 years ago)
- Location:
- ssi-sumilux/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (2 diffs)
-
ssi.php (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ssi-sumilux/trunk/readme.txt
r506263 r507062 5 5 Requires at least: 1.0 6 6 Tested up to: 3.3.1 7 Stable tag: 0.7 7 Stable tag: 0.7.2 8 8 9 9 This plugin is currently in the experimental stage, we plan to launch it for beta testing in early February, please use with caution. … … 30 30 == Changelog == 31 31 32 =0.7.2= 33 Fixed some bugs 34 Cleaning code 35 32 36 =0.7= 33 37 Quick app settings from admin -
ssi-sumilux/trunk/ssi.php
r506263 r507062 4 4 Plugin URI: http://ssi.sumilux.com 5 5 Description: Plugin for Social Sign-In from <a href="http://demo.sumilux.com/ssi">Sumilux</a> 6 Version: 0.7 6 Version: 0.7.2 7 7 Author: Serhiy Martynenko 8 8 Author URI: [email protected] … … 14 14 define('SSI_TEMPLATES_DIR', SSI_DIR . 'templates/'); 15 15 define("SSI_PLUGIN_URL",WP_PLUGIN_URL.'/'.basename(dirname(__FILE__))); 16 define("SSI_VERSION", "0.7 ");16 define("SSI_VERSION", "0.7.2"); 17 17 18 18 … … 22 22 //define('APPKEY', get_option('ssi_debug_app_key')); 23 23 define('APPSECRET', get_option('ssi_debug_app_secret')); 24 define('APPNAME', get_option('ssi_debug_widget_name'));25 24 define('WIDGETNAME', get_option('ssi_debug_widget_name')); 26 25 } else { 27 26 // define('APPKEY', get_option('ssi_app_key')); 28 27 define('APPSECRET', get_option('ssi_app_secret')); 29 define('APPNAME', get_option('ssi_widget_name'));30 28 define('WIDGETNAME', get_option('ssi_widget_name')); 31 29 } … … 56 54 function my_plugin_init() { 57 55 if (!session_id()){ 58 59 56 session_start(); 60 } 57 } 58 61 59 if (isset($_POST['ssi_token'])) { 62 60 ssi_work_with_token(); 63 64 61 } 65 62 } … … 70 67 $links[] = '<a href="options-general.php?page=ssi-identifier">'.__('Settings').'</a>'; 71 68 } 72 73 69 return $links; 74 70 } … … 82 78 //add_action('init', 'session'); 83 79 add_action('admin_menu', 'my_plugin_menu'); 84 if ((APPSECRET == "") || (APPNAME=="")){ 85 80 81 if ((APPSECRET == "") || (WIDGETNAME=="")){ 86 82 add_action('admin_notices', 'ssi_admin_warnings'); 87 83 } else { … … 91 87 92 88 93 //add_action('wp_footer', 'ssi_ui_comment_form');94 95 96 89 97 90 function ssi_work_with_token(){ 98 91 99 //session_start();100 92 $token = $_POST['ssi_token']; 101 102 $ssi = new Services_Sumilux_SSI(APPNAME, APPSECRET); 103 93 $ssi = new Services_Sumilux_SSI(WIDGETNAME, APPSECRET); 104 94 105 95 $ssi->setToken($token); 106 107 108 96 $jo = $ssi->getUserProfile('current'); 109 97 110 111 98 global $wpdb; 112 113 114 99 $WpUser = wp_get_current_user(); 100 115 101 if (empty($jo->primaryEmail)) { 116 102 $profile_email = $jo->user->userID . '@' . parse_url(get_option('siteurl'), PHP_URL_HOST); … … 130 116 } 131 117 132 133 //$result = $wpdb->get_results( "SELECT COUNT(*) as cnt FROM $wpdb->users WHERE user_email = '". $profile_email."' " );134 135 136 118 if ($WpUser->ID) { 137 138 139 140 119 if (!$wpuid) { 141 142 143 120 SsiUser::setIdentity($WpUser->ID, $profile); 144 145 146 121 $update_data = array(); 147 122 $update_data['ID'] = $WpUser->ID; 148 149 123 150 124 if ($profile->name->full_name) { 151 125 $update_data['display_name'] = $profile->name->full_name; 152 126 $name_parts = explode(" ", $profile->name->full_name); 153 154 127 $update_data['first_name'] = $name_parts[0]; 155 128 $update_data['last_name'] = $name_parts[1]; … … 175 148 } elseif (!$WpUser->ID) { 176 149 177 178 150 if (!$wpuid) { 179 151 if (!email_exists($profile_email)) { 180 181 152 $wpuid = SsiUser::create($profile_email, $jo); 182 153 } 183 154 } 184 185 186 155 wp_safe_redirect($redirectURL); 187 188 189 156 } 190 157 191 158 if ($wpuid) { 192 193 159 wp_set_auth_cookie($wpuid, true, false); 194 160 wp_set_current_user($wpuid); 195 196 161 wp_safe_redirect($redirectURL); 197 162 } … … 205 170 206 171 function ssi_admin_warnings() { 207 echo " 208 <div id='ssi-warning' class='updated fade'><p>You should set Widget name and App secret of <strong> \"SSI plugin\"</strong> <a href='/wp-admin/options-general.php?page=ssi-identifier'>here</a></p></div> 209 "; 210 211 return true; 212 172 echo "<div id='ssi-warning' class='updated fade'><p>You should set Widget name and App secret of <strong> \"SSI plugin\"</strong> <a href='/wp-admin/options-general.php?page=ssi-identifier'>here</a></p></div>"; 173 return true; 213 174 } 214 175 … … 220 181 } 221 182 $plugname = "Ssi plugin for WordPress"; 222 223 183 $shortname = "ssi"; 224 225 184 $plugoptions = array( 226 227 185 array("name" => "SSI main options", 228 186 "type" => "title"), 229 230 187 array("name" => "Widget name", 231 188 "desc" => "Put widget name here", … … 233 190 "std" => "", 234 191 "type" => "text"), 235 236 192 array("name" => "App secret", 237 193 "desc" => "Put app secret here", … … 259 215 "id" => $shortname . "_debug_app_secret", 260 216 "std" => "", 261 "type" => "text"), 262 263 array("name" => "Language", 264 "desc" => "Choose plugin language", 265 "id" => $shortname . "_lang", 266 "std" => "", 267 "type" => "select"), 268 /*array("name" => "App name", 269 "desc" => "Put app name here", 270 "id" => $shortname . "_app_name", 271 "std" => "", 272 "type" => "text"), */ 217 "type" => "text"), */ 273 218 ); 274 219 … … 289 234 } 290 235 291 /*Modifications to login at comments form*/ 292 /*function ssi_ui_comment_form() 236 function ssi_ui_login_form($type_show) 293 237 { 294 238 $WpUser = wp_get_current_user(); 295 // if user is logged already296 if ($WpUser->ID) return;297 echo ssi_show_template('html_comment_login_form.tpl');298 }*/299 300 function ssi_ui_login_form($type_show)301 {302 $WpUser = wp_get_current_user();303 239 304 240 $return_to = get_option('siteurl'); 305 if ($WpUser->ID) { 306 307 } 308 309 310 //get user from SSI server 311 // session_start(); 241 312 242 313 243 $returnURL = "http://".$_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; 314 315 316 244 $authURL = getAuthURL($returnURL); 317 245 318 319 320 /*if (isset($_POST['token'])) {321 ssi_work_with_token();322 323 }*/324 325 326 246 $site_url = site_url() . '/wp-login.php'; 327 247 328 248 if (DEBUG){ 329 330 249 Services_Sumilux_SSI::setEndpoint("http://idmedemo.sumilux.com/smx/rpcService/xmlRpcService"); 331 250 } … … 334 253 $html_block = Services_Sumilux_SSI::generateCode( 335 254 WIDGETNAME, // widget name 336 337 255 APPSECRET, // app secret 338 256 'medium-icon', … … 347 265 var respond_div = document.getElementById('loginform'); 348 266 349 350 267 if (!respond_div) { 351 268 respond_div = document.getElementById(\"respond\"); … … 360 277 </script>"; 361 278 if ($type_show!=""){ 362 363 279 $javacript_for_login = ""; 364 280 } 365 366 367 368 281 // prepare data for template 369 282 $tpl_data = array( … … 374 287 ); 375 288 376 377 378 289 if ($type_show==""){ 379 290 include(SSI_TEMPLATES_DIR."login.php"); … … 381 292 echo ssi_show_template('html_login_form.tpl', $tpl_data); 382 293 } 383 384 385 386 294 } 387 295 … … 406 314 $exitURL = "http://" . $exitURL; 407 315 $sig = md5($exitURL . APPSECRET); // signature 408 409 $authURL = ENDPOINT . "/owa?exitURL=" . urlencode($exitURL) . "&sig=$sig&appName=" . APPNAME; 316 $authURL = ENDPOINT . "/owa?exitURL=" . urlencode($exitURL) . "&sig=$sig&WIDGETNAME=" . WIDGETNAME; 410 317 return $authURL; 411 318 } … … 429 336 430 337 foreach ($plugoptions as $value) { 431 432 338 update_option($value['id'], $_REQUEST[$value['id']]); 433 434 339 } 435 340 … … 451 356 } 452 357 453 454 358 } 455 359 … … 459 363 460 364 $returnURL = "http://".$_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; 461 if (isset($_REQUEST[" appName"]) && isset($_REQUEST["appSecret"]) ){365 if (isset($_REQUEST["WIDGETNAME"]) && isset($_REQUEST["appSecret"]) ){ 462 366 463 367 $ssi_recieved['ssi_app_secret'] = $_REQUEST["appSecret"]; 464 $ssi_recieved['ssi_widget_name'] = $_REQUEST[" appName"];368 $ssi_recieved['ssi_widget_name'] = $_REQUEST["WIDGETNAME"]; 465 369 } 466 370 include(SSI_TEMPLATES_DIR."options.php");
Note: See TracChangeset
for help on using the changeset viewer.