Changeset 170

Show
Ignore:
Timestamp:
09/14/08 20:26:02 (4 months ago)
Author:
pdingle
Message:

updates: Utils: showClaimList
Utils: matchLinkProtocol --- ISSUES?
Processing: mapFormElements
Processing: addCard
Processing: updateIdentityLastUsed
Admin: checkFrameworkRegistrationSetting
Admin: cardManagementUrl

UserData?: updateUserInfoFromEmail --- DEPRECATED
UserData?: evaluateIncomingUser -- DEPRECATED
Userdata: updateCardInfoFromAccountID -- DEPRECATED
pwlib_userdata::getAuthenticatedUserRecord --- ISSUES?
pwlib_userdata::loginIDisUnique
pwlib_userdata::emailIsUnique

cardforms.pw.php -- added
triggerobject.pw.php -- added

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/RB-0.91/wp-infocard/pw-config.php

    r161 r170  
    88define ('PW_PLUGINPATH', '/wp-content/plugins/wp-infocard'); 
    99define ('PW_VERSION', 'v0.91'); 
    10 define ('PW_VERSION_DATE', '03/09/08'); 
     10define ('PW_VERSION_DATE', '09/13/08'); 
    1111define ('PW_DB_VERSION', 'DB v3'); 
    1212define ('PW_USECAPTCHAS', false ); 
  • branches/RB-0.91/wp-infocard/wp-infocard.php

    r154 r170  
    33Plugin Name: PamelaWare Information Card Login 
    44Plugin URI: http://code.pamelaproject.com/wiki 
    5 Description: This plugin adds functionality to register and login with "information cards", part of the Identity Metasystem web services framework.  Once it is activated, go to the "Options" menu and click on "Information Cards" to see what to do next
     5Description: This plugin adds functionality to register and login with "information cards", part of the Identity Metasystem web services framework.  Once it is activated, go to the "Settings" menu and click on "Information Cards" to see what to do next. We strongly recommend that you use this plugin with Wordpress version 2.6.1 or later
    66Version: v0.91 
    77Author: K. Cameron, P. Dingle, and more 
  • branches/RB-0.91/wp-infocard/wp/admin.pw.php

    r162 r170  
    330330 
    331331        } 
     332 
     333        function checkFrameworkRegistrationSetting() 
     334        { 
     335                $comment_reg = get_settings('comment_registration'); 
     336                if ((bool)$comment_reg) 
     337                        return "Wordpress basic user registration is: enabled"; 
     338                else 
     339                        return "Wordpress basic user registration is: disabled"; 
     340        } //end function checkFrameworkRegistrationSetting 
    332341         
    333342        function pwAdminScreen() 
     
    336345                $opts = pw_admin::updateAdminOptions(); 
    337346                // write submitted changes if this page reload shows a submit 
    338                 if (pw_utils::databaseUpToDate()) 
    339                 { 
    340                         echo "<p>Plugin Version: ". PW_VERSION . " " . PW_VERSION_DATE  
    341                         . " (" . $opts['pw_db_version'] . ")</p>"; 
    342                 } 
    343                 else             
     347                if (!pw_utils::databaseUpToDate()) 
    344348                { 
    345349?> 
     
    359363                        <table border="0"><tr><th valign="bottom" colspan="2" align="left"> 
    360364                        <tr><td colspan="4">&nbsp</td></tr> 
    361  
    362                         <tr><th colspan="4" align="left">Information Card Configuration</td></tr> 
    363                         <tr><td valign="top"> 
    364                         <label for="securesiteurl" title="Secure Site URL"> 
    365                         <?php pw_utils::screenPrint('Secure Site URL'); ?> 
    366                         </label> 
    367                         </td><td colspan="3"> 
    368                         <input type="text" name="pw_securesiteurl" id="pw_securesiteurl" size="50" value="<?php print $opts['pw_securesiteurl']; ?>" /> 
    369                         </td></tr> 
    370  
    371                         <tr><td valign="top"> 
    372                         <label for="pw_infocard_key" title="SSL Private Key"> 
    373                         <?php pw_utils::screenPrint('SSL Private Key'); ?> 
    374                         </label> 
    375                         </td><td colspan="3"> 
    376                         <textarea cols="60" rows="4" name="pw_infocard_key" id="pw_infocard_key"><?php print $opts['pw_infocard_key']; ?></textarea> 
    377                         </td></tr> 
    378                         <tr><td> 
    379                         <label for="pw_infocard_opener" title="SSL Passphrase"> 
    380                         <?php pw_utils::screenPrint('SSL Passphrase'); ?> 
    381                         </label> 
    382                         </td><td colspan="3"> 
    383                         <input type="text" name="pw_infocard_opener" id="pw_infocard_opener" size="50" value="<?php print $opts['pw_infocard_opener']; ?>" /> 
    384 <?php /* 
    385                         </td></tr> 
    386  <tr><td colspan="2"> 
    387                                 <input name="pw_enable_pass" type="checkbox" id="pw_enable_pass" value="1" <?php checked('1', ($opts['pw_enable_pass'])); ?> /> 
    388                                 <?php pw_utils::screenPrint('Use Username/Password in addition to Information Cards'); ?> 
    389                         </td></tr> 
    390 */ ?> 
     365<?php                   echo pw_admin::getPWAdminConfigurationSettings( $opts ); 
     366?> 
    391367                        <tr><td colspan="4">&nbsp;</td></tr> 
    392                         <tr><th colspan="4" align="left">To Enable Information Card User Login</td></tr> 
    393                         <tr><td colspan="4"><?php pw_utils::screenPrint('The following changes will result in a login form with the option "Use an Information Card". Please make a copy of the wp-login.php file before you begin, so that you can revert to that original file in case of difficulties.'); ?></td></tr>                        <tr><td colspan="2" id="code"> 
    394368<?php 
    395369                        pw_admin::printInstallData(); 
     
    571545 
    572546        /* 
     547                Function:       cardManagementUrl 
     548                Description:    returns out the URL to manage cards 
     549                Input:          none 
     550                Output:         URL 
     551                Side-Effects:   none 
     552        */ 
     553        function cardManagementUrl() 
     554        { 
     555                return PW_SECURESITEURL 
     556                        . "/wp-admin/profile.php"; 
     557        }//end function cardManagementUrl 
     558 
     559        /* 
    573560                Function:       getCurrentUserCardProfile 
    574561                Description:    Returns a string with code for maintaining 
  • branches/RB-0.91/wp-infocard/wp/login/login.pw.php

    r158 r170  
    77class pw_login extends pwlib_login  
    88{ 
     9 
     10        function getRegistrationUrl() 
     11        { 
     12                return PW_SECURESITEURL 
     13                        . "/index.php?option=com_pwjos"; 
     14        } 
     15 
     16        function getAttachmentUrl() 
     17        { 
     18                return PW_SECURESITEURL 
     19                        . "/index.php?option=com_pwjos"; 
     20        } 
    921 
    1022        function printPostLoginRedirect() 
  • branches/RB-0.91/wp-infocard/wp/processing.pw.php

    r163 r170  
    170170        } //addIdentityRecord 
    171171 
     172        /* 
     173                Function:       updateIdentityLastUsed 
     174                Description:    updates the identity table with a new lastused date 
     175                Input:          none 
     176                Output:         none 
     177                Side-Effect:    updates infocard_identities table 
     178        */ 
     179        function updateIdentityLastUsed($cardhash, $cardhandle, $accountid) 
     180        { 
     181                if (!$cardhash || !$cardhandle || !$accountid) 
     182                        return FALSE; 
     183                $today = date('c'); 
     184                global $wpdb; 
     185 
     186                $query = "UPDATE `" . PW_TABLE_PREFIX . "infocard_identities` SET " 
     187                . "lastused = '$today' WHERE accountid = '$accountid' AND cardhash = '$cardhash'"; 
     188                $wpdb->query( $query ); 
     189                //pw_utils::printDebug( '&nbsp; Updated Last Used Date to ' . $today . ' for account ' . $accountid . ', card ' . $cardhandle . '<br/>' ); 
     190        }//end function updateIdentityLastUsed 
     191 
    172192        /* 
    173193                Function:       deleteIdentityRecords 
     
    185205                return $wpdb->query( $query ); 
    186206        } //end function deleteIdentityRecords 
     207 
     208        /* 
     209                Function:       addCard 
     210                Description:    adds a single card 
     211                Input:          datamap 
     212                Output:         returns an error if an error was encountered 
     213                Side-Effect:    updates infocard_identities table 
     214        */ 
     215        function addCard($datamap) 
     216        { 
     217                if (!$datamap['ID']->new_value) 
     218                { 
     219                        pw_utils::printDebug('ERROR: no ID value in datamap for updateIdentityData<br />'); 
     220                        return 'INTERNALERROR'; 
     221                } 
     222                global $wpdb; 
     223                $acct       = $datamap['ID']->new_value; 
     224                $cardhash   = $datamap['cardhash']->new_value; 
     225                $cardhandle =  $datamap['cardhandle']->new_value; 
     226                $today = date('c'); 
     227 
     228                $query = "SELECT * FROM " . PW_TABLE_PREFIX 
     229                        . "infocard_identities WHERE cardHash = " 
     230                        . "'$cardhash'"; 
     231 
     232                $results = $wpdb->get_results( $query, OBJECT ); 
     233 
     234                switch ( count($results) ) 
     235                { 
     236                        case 0: 
     237                                pw_processing::addIdentityRecord($datamap['cardhash']->new_value, $datamap['cardhandle']->new_value, $datamap['ID']->new_value); 
     238                        break; 
     239                        case 1: 
     240                                if (!pw_utils::dataCompare($results[0]->accountid, $acct, 'Account ID')) 
     241                                { 
     242                                        pw_utils::printDebug( '&nbsp; Card used for another account<br/>' ); 
     243                                        return 'CARDINUSE'; 
     244 
     245                                } 
     246                        break; 
     247 
     248                        default: 
     249                                // should never happen 
     250                                return 'MULTIPLECARDERROR'; 
     251                } 
     252 
     253                return FALSE;  // no error, life is good 
     254        }//end function addCard 
    187255 
    188256        /* 
     
    203271        }//end function deleteCard 
    204272 
     273        function mapFormElements($datamap, $postdetails) 
     274        { 
     275                $user_login = pw_utils::sanitizeData($postdetails['pwchosenloginid']); 
     276                $user_pwd  = pw_utils::sanitizeData($postdetails['pwchosenpwd']); 
     277                $user_pwdconfirm  = pw_utils::sanitizeData($postdetails['pwchosenpwdconfirm']); 
     278                if ($user_login) 
     279                { 
     280                        pw_utils::printDebug("User Chosen Login: " . $user_login . "<br/>", 3); 
     281                        $datamap['loginid']->new_value == $user_login; 
     282                } 
     283                if (($user_pwd) && ($user_pwd == $user_pwdconfirm)) 
     284                { 
     285                        pw_utils::printDebug("User Chosen Password: " . $user_pwd . "<br/>", 3); 
     286                        $datamap['pwd']->new_value == $user_pwd; 
     287                } 
     288        } //end function mapFormElements 
    205289} // end class pw_processing 
    206290?> 
  • branches/RB-0.91/wp-infocard/wp/userdata.pw.php

    r163 r170  
    253253        } // end function updateIdentityData 
    254254 
     255        /* 
     256                Function:       getAuthenticatedUserRecord 
     257                Description:    returns a user entry in a standardized format 
     258                                which may not match the database name 
     259                Input:          none 
     260                Output:         - accountid:    the user accountid 
     261                                - loginid:      the user login name 
     262                                - name:         the display name 
     263                Side-Effects:   none 
     264        */ 
     265        function getAuthenticatedUserRecord() 
     266        { 
     267                        $user = wp_get_current_user(); 
     268                        if ( $user->ID ) 
     269                        { 
     270                                $returnuser->accountid  =  $user->ID; 
     271                                $returnuser->name       =  $user->display_name; 
     272                                $returnuser->loginid    =  $user->username; 
     273                                $returnuser->email      =  $user->email; 
     274 
     275                                return $returnuser; 
     276                        } 
     277                        else 
     278                        { 
     279                                return false; 
     280                        } 
     281        } //end getAuthenticatedUserRecord 
     282 
    255283        // Function:    Perform user login functions 
    256284        // Description: set whatever cookie &/or session information needed 
     
    444472                return $results; 
    445473        } 
    446          
     474 
     475/* DEPRECATED AS OF V0.91        
    447476        function updateUserInfoFromEmail($email) 
    448477        { 
     
    490519                return $results; 
    491520        } 
    492  
     521*/ 
     522// DEPRECATED 
     523/* 
    493524        function updateCardInfoFromAccountID($accountID) 
    494525        { 
     
    528559                return $results; 
    529560        }//end function updateCardInfoFromAccountID 
    530  
     561*/ 
    531562        function checkEmailAddress($claimslist, $datamap) 
    532563        { 
     
    584615        } //end function updateLegacyCardHash 
    585616 
     617        /* 
     618                Function:       loginIDisUnique 
     619                Description:    returns TRUE if loginID is unique, FALSE otherwise 
     620        */ 
     621        function loginIDisUnique($loginid) 
     622        { 
     623                global $wpdb; 
     624                $query = "SELECT COUNT(*) FROM `" . PW_TABLE_PREFIX 
     625                        . "users` WHERE user_login = '" 
     626                        . $loginid . "'"; 
     627 
     628                if ($wpdb->get_results( $query, OBJECT )) 
     629                        return FALSE; 
     630                else 
     631                        return TRUE; 
     632        } 
     633 
     634        /* 
     635                Function:       emailIsUnique 
     636                Description:    returns TRUE if email is unique 
     637                                returns TRUE if uniqueness doesn't matter 
     638                                returns FALSE otherwise 
     639        */ 
     640        function emailIsUnique($email) 
     641        { 
     642                $email_unique = pw_admin::getOption('pw_email_unique'); 
     643                if (!$email_unique) 
     644                        return TRUE; 
     645 
     646                global $wpdb; 
     647                $query = "SELECT COUNT(*) FROM `" . PW_TABLE_PREFIX 
     648                        . "users` WHERE user_email = '" . $email . "'"; 
     649 
     650                if ($wpdb->get_results( $query, OBJECT )) 
     651                        return FALSE; 
     652                else 
     653                        return TRUE; 
     654        } 
    586655} // end class pw_userdata 
    587656?> 
  • branches/RB-0.91/wp-infocard/wp/utils.pw.php

    r158 r170  
    250250        } 
    251251 
    252         function showClaimList($claimslist) 
    253         { 
    254                 pw_utils::printDebug('<br/>Requested Claims:<br/>'); 
     252        /* 
     253                Function:       showClaimList 
     254                Description:    Returns html describing claims in the claimslist 
     255                                Note: items in the claims list with no schemaURI 
     256                                        are not shown (eg: modulus) 
     257        */ 
     258        function showClaimList() 
     259        { 
     260                $claimslist =& PWClaimInfo::getInstance()->claimslist; 
     261                $output = '<br/>Requested Claims:<br/>'; 
    255262                foreach ($claimslist as $claim) 
    256263                { 
    257264                        if ($claim->schemaURI) 
    258265                        { 
    259                                 pw_utils::printDebug( '&nbsp;' . $claim->displayname . (($claim->required)?'  (required)':'  (optional)') . '<br/>'); 
    260                                 //pw_utils::printDebug($claim->displayname); 
    261                         } 
    262                 } 
    263                 pw_utils::printDebug('<br/>'); 
    264         } 
     266                                $output .= '&nbsp;' . $claim->displayname 
     267                                . (($claim->required)?'  (required)':'  (optional)') . '<br/>'; 
     268                                // $output .= $claim->displayname; 
     269                        } 
     270                } 
     271                $output .= '<br/>'; 
     272 
     273                return $output; 
     274        }//end function showClaimList 
    265275 
    266276        function showDataMap($datamap) 
     
    332342        } 
    333343 
     344        function matchLinkProtocol($string) 
     345        { 
     346                if (strpos(get_settings('siteurl'), "https")) 
     347                { 
     348                        return PW_PLUGINURL . $string; 
     349                } 
     350                else 
     351                { 
     352                        return PW_SECUREPLUGINURL . $string; 
     353                } 
     354        }// end function matchLinkProtocol 
    334355} // end class pw_utils 
    335356?>