Changeset 834602
- Timestamp:
- 01/07/2014 10:27:00 PM (12 years ago)
- Location:
- vanilla-forums/trunk
- Files:
-
- 2 edited
-
functions.php (modified) (16 diffs)
-
plugin.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
vanilla-forums/trunk/functions.php
r621730 r834602 36 36 if (!is_array($options)) 37 37 $options = array(); 38 38 39 39 $options[$option_name] = $option_value; 40 40 $return = update_option(VF_OPTIONS_NAME, $options); … … 55 55 $Result = $Collection->$Key; 56 56 } 57 57 58 58 return $Result; 59 59 } … … 68 68 if (is_wp_error($Response)) 69 69 return $Response->get_error_message(); 70 70 71 71 return wp_remote_retrieve_body($Response); 72 72 } … … 80 80 * array('/path', 'to', 'vanilla', 'applications', 'dashboard') 81 81 * array('/path/', '/to/', '/vanilla/', '/applications/', '/dashboard') 82 * 82 * 83 83 * @param array $paths The array of paths to concatenate. 84 84 * @param string $delimiter The delimiter to use when concatenating. Defaults to system-defined directory separator. … … 130 130 if (!is_array($alloptions)) 131 131 $alloptions = array(); 132 132 133 133 switch ($formname) { 134 134 case 'url-form': … … 170 170 break; 171 171 } 172 172 173 173 return $options; 174 174 } … … 216 216 if (isset($Activity->Headline)) 217 217 return $Activity->Headline; 218 218 219 219 $ProfileUserID = -1; 220 220 $ViewingUserID = -1; 221 221 $GenderSuffixCode = 'First'; 222 222 $GenderSuffixGender = $Activity->ActivityGender; 223 223 224 224 if ($ViewingUserID == $Activity->ActivityUserID) { 225 225 $ActivityName = $ActivityNameP = 'You'; … … 286 286 $ProfileHeadline = $Activity->ProfileHeadline; 287 287 $MessageFormat = ($ProfileUserID == $Activity->ActivityUserID || $ProfileUserID == '' ? $FullHeadline : $ProfileHeadline); 288 288 289 289 return sprintf($MessageFormat, $ActivityName, $ActivityNameP, $RegardingName, $RegardingNameP, $RegardingWall, $Gender, $Gender2, $Route, $GenderSuffix); 290 290 } … … 317 317 318 318 function vf_get_user() { 319 global $current_user ;320 319 global $current_user, $wp_roles; 320 321 321 if (!function_exists('get_currentuserinfo')) 322 322 require_once ABSPATH . WPINC . '/pluggable.php'; 323 323 get_currentuserinfo(); 324 324 325 325 $user = array(); 326 326 if ($current_user->ID != '') { … … 330 330 $user['photourl'] = ''; // 331 331 $user['wp_nonce'] = wp_create_nonce('log-out'); 332 332 333 333 // Do some fudgery to grab the photo url. 334 334 try { … … 338 338 } catch (Exception $Ex) { 339 339 } 340 340 341 341 // Add the user's roles to the SSO. 342 342 if (isset($current_user->roles)) { 343 $user['roles'] = implode(',', $current_user->roles); 343 if (!isset( $wp_roles ) ) 344 $wp_roles = new WP_Roles(); 345 346 $role_names = $wp_roles->role_names; 347 348 $roles = array(); 349 foreach ((array)$current_user->roles as $role_slug) { 350 // Add the role slug. 351 $roles[] = $role_slug; 352 353 // Add the role name if it's different from the slug. 354 if (isset($role_names[$role_slug])) { 355 $role_name = $role_names[$role_slug]; 356 if (strcasecmp($role_name, $role_slug) !== 0) { 357 $roles[] = str_replace(',', ' ', $role_name); 358 } 359 } 360 } 361 362 $user['roles'] = implode(',', array_unique($roles)); 344 363 } else { 345 364 $user['roles'] = null; 346 365 } 347 366 // $user['_user'] = $current_user; 348 } 349 367 } 368 350 369 // Allow other plugins to modify the user. 351 370 $user = apply_filters('vf_get_user', $user); 352 371 353 372 return $user; 354 373 } … … 356 375 function vf_get_sso_string() { 357 376 $user = vf_get_user(); 358 377 359 378 if (empty($user)) 360 379 return ''; 361 380 362 381 $options = get_option(VF_OPTIONS_NAME); 363 382 $clientID = vf_get_value('sso-clientid', $options, ''); … … 365 384 if (!$clientID || !$secret) 366 385 return ''; 367 386 368 387 $user['client_id'] = $clientID; 369 388 370 389 $string = base64_encode(json_encode($user)); 371 390 $timestamp = time(); 372 391 $hash = hash_hmac('sha1', "$string $timestamp", $secret); 373 392 374 393 $result = "$string $hash $timestamp hmacsha1"; 375 394 return $result; … … 379 398 if ($User->Photo == '') 380 399 $User->Photo = vf_combine_paths(array($Url, 'applications/dashboard/design/images/usericon.gif'), '/'); 381 400 382 401 $CssClass = $CssClass == '' ? '' : ' class="'.$CssClass.'"'; 383 $IsFullPath = strtolower(substr($User->Photo, 0, 7)) == 'http://' || strtolower(substr($User->Photo, 0, 8)) == 'https://'; 402 $IsFullPath = strtolower(substr($User->Photo, 0, 7)) == 'http://' || strtolower(substr($User->Photo, 0, 8)) == 'https://'; 384 403 $PhotoUrl = ($IsFullPath) ? $User->Photo : vf_combine_paths(array($Url, 'uploads/'.vf_change_basename($User->Photo, 'n%s')), '/'); 385 404 return '<a href="'.vf_combine_paths(array($Url, '/profile/'.$User->UserID.'/'.urlencode($User->Name)), '/').'"'.$CssClass.' style="display: inline-block; margin: 0 2px 2px 0">' … … 415 434 } 416 435 417 /** 436 /** 418 437 * Place the Vanilla Forum on the external domain redirect whitelist. 419 438 */ … … 423 442 if ($ix !== FALSE) 424 443 $path = substr($path, 0, $ix); 425 444 426 445 if (!in_array($path, $allowed_hosts)) 427 446 $allowed_hosts[] = $path; 428 447 429 448 return $allowed_hosts; 430 449 } -
vanilla-forums/trunk/plugin.php
r621730 r834602 58 58 1.1.14 59 59 - Added a check for forum embedding so that the forum and comments don't get embedded at the same time. 60 1.1.15 61 - Added the full role names to the list of roles sent on sso. 60 62 61 63 Copyright 2010 Vanilla Forums Inc … … 71 73 define('VF_PLUGIN_URL', WP_PLUGIN_URL.'/'.plugin_basename(dirname(__FILE__))); 72 74 73 include_once(VF_PLUGIN_PATH.'/functions.php'); 75 include_once(VF_PLUGIN_PATH.'/functions.php'); 74 76 include_once(VF_PLUGIN_PATH.'/admin.php'); 75 77 include_once(VF_PLUGIN_PATH.'/embed.php');
Note: See TracChangeset
for help on using the changeset viewer.