Plugin Directory

Changeset 834602


Ignore:
Timestamp:
01/07/2014 10:27:00 PM (12 years ago)
Author:
VanillaForums
Message:

Added the full role names to the list of roles sent with sso.

Location:
vanilla-forums/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • vanilla-forums/trunk/functions.php

    r621730 r834602  
    3636    if (!is_array($options))
    3737        $options = array();
    38        
     38
    3939    $options[$option_name] = $option_value;
    4040    $return = update_option(VF_OPTIONS_NAME, $options);
     
    5555        $Result = $Collection->$Key;
    5656    }
    57        
     57
    5858    return $Result;
    5959}
     
    6868    if (is_wp_error($Response))
    6969        return $Response->get_error_message();
    70    
     70
    7171    return wp_remote_retrieve_body($Response);
    7272}
     
    8080 * array('/path', 'to', 'vanilla', 'applications', 'dashboard')
    8181 * array('/path/', '/to/', '/vanilla/', '/applications/', '/dashboard')
    82  * 
     82 *
    8383 * @param array $paths The array of paths to concatenate.
    8484 * @param string $delimiter The delimiter to use when concatenating. Defaults to system-defined directory separator.
     
    130130    if (!is_array($alloptions))
    131131        $alloptions = array();
    132        
     132
    133133    switch ($formname) {
    134134        case 'url-form':
     
    170170            break;
    171171    }
    172    
     172
    173173    return $options;
    174174}
     
    216216   if (isset($Activity->Headline))
    217217      return $Activity->Headline;
    218    
     218
    219219    $ProfileUserID = -1;
    220220    $ViewingUserID = -1;
    221221    $GenderSuffixCode = 'First';
    222222    $GenderSuffixGender = $Activity->ActivityGender;
    223    
     223
    224224    if ($ViewingUserID == $Activity->ActivityUserID) {
    225225        $ActivityName = $ActivityNameP = 'You';
     
    286286    $ProfileHeadline = $Activity->ProfileHeadline;
    287287    $MessageFormat = ($ProfileUserID == $Activity->ActivityUserID || $ProfileUserID == '' ? $FullHeadline : $ProfileHeadline);
    288    
     288
    289289    return sprintf($MessageFormat, $ActivityName, $ActivityNameP, $RegardingName, $RegardingNameP, $RegardingWall, $Gender, $Gender2, $Route, $GenderSuffix);
    290290}
     
    317317
    318318function vf_get_user() {
    319    global $current_user;
    320    
     319   global $current_user, $wp_roles;
     320
    321321   if (!function_exists('get_currentuserinfo'))
    322322      require_once ABSPATH . WPINC . '/pluggable.php';
    323323   get_currentuserinfo();
    324    
     324
    325325   $user = array();
    326326   if ($current_user->ID != '') {
     
    330330      $user['photourl'] = ''; //
    331331      $user['wp_nonce'] = wp_create_nonce('log-out');
    332      
     332
    333333      // Do some fudgery to grab the photo url.
    334334      try {
     
    338338      } catch (Exception $Ex) {
    339339      }
    340      
     340
    341341      // Add the user's roles to the SSO.
    342342      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));
    344363      } else {
    345364         $user['roles'] = null;
    346365      }
    347366//      $user['_user'] = $current_user;
    348    }   
    349    
     367   }
     368
    350369   // Allow other plugins to modify the user.
    351370   $user = apply_filters('vf_get_user', $user);
    352    
     371
    353372   return $user;
    354373}
     
    356375function vf_get_sso_string() {
    357376   $user = vf_get_user();
    358    
     377
    359378   if (empty($user))
    360379      return '';
    361    
     380
    362381   $options = get_option(VF_OPTIONS_NAME);
    363382   $clientID = vf_get_value('sso-clientid', $options, '');
     
    365384   if (!$clientID || !$secret)
    366385      return '';
    367    
     386
    368387   $user['client_id'] = $clientID;
    369    
     388
    370389   $string = base64_encode(json_encode($user));
    371390   $timestamp = time();
    372391   $hash = hash_hmac('sha1', "$string $timestamp", $secret);
    373    
     392
    374393   $result = "$string $hash $timestamp hmacsha1";
    375394   return $result;
     
    379398    if ($User->Photo == '')
    380399        $User->Photo = vf_combine_paths(array($Url, 'applications/dashboard/design/images/usericon.gif'), '/');
    381    
     400
    382401    $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://';
    384403    $PhotoUrl = ($IsFullPath) ? $User->Photo : vf_combine_paths(array($Url, 'uploads/'.vf_change_basename($User->Photo, 'n%s')), '/');
    385404    return '<a href="'.vf_combine_paths(array($Url, '/profile/'.$User->UserID.'/'.urlencode($User->Name)), '/').'"'.$CssClass.' style="display: inline-block; margin: 0 2px 2px 0">'
     
    415434}
    416435
    417 /** 
     436/**
    418437 * Place the Vanilla Forum on the external domain redirect whitelist.
    419438 */
     
    423442   if ($ix !== FALSE)
    424443      $path = substr($path, 0, $ix);
    425    
     444
    426445   if (!in_array($path, $allowed_hosts))
    427446        $allowed_hosts[] = $path;
    428    
     447
    429448    return $allowed_hosts;
    430449}
  • vanilla-forums/trunk/plugin.php

    r621730 r834602  
    58581.1.14
    5959- Added a check for forum embedding so that the forum and comments don't get embedded at the same time.
     601.1.15
     61- Added the full role names to the list of roles sent on sso.
    6062
    6163Copyright 2010 Vanilla Forums Inc
     
    7173define('VF_PLUGIN_URL', WP_PLUGIN_URL.'/'.plugin_basename(dirname(__FILE__)));
    7274
    73 include_once(VF_PLUGIN_PATH.'/functions.php'); 
     75include_once(VF_PLUGIN_PATH.'/functions.php');
    7476include_once(VF_PLUGIN_PATH.'/admin.php');
    7577include_once(VF_PLUGIN_PATH.'/embed.php');
Note: See TracChangeset for help on using the changeset viewer.