Changeset 101

Show
Ignore:
Timestamp:
08/10/07 13:15:44 (1 year ago)
Author:
pdingle
Message:

updated pwAdminScreen to use the updateAdminOptions function

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-infocard/wp/admin.pw.php

    r100 r101  
    335335        { 
    336336                // get initial option values  
    337                 $ic_opener = $new_opener = pw_admin::getOption('pw_infocard_opener'); 
    338                 $ic_key = $new_key = pw_admin::getOption('pw_infocard_key'); 
    339                 $secureurl = $new_secureurl = pw_admin::getOption('pw_securesiteurl'); 
    340                 $ic_secret = pw_admin::getOption('secret'); 
    341                 $ic_debug = $new_debug = pw_admin::getOption('pw_debug_on'); 
    342                 $ic_pass = $new_pass = pw_admin::getOption('pw_enable_pass'); 
    343                 $ic_trigger = $new_trigger = pw_admin::getOption('pw_selector_trigger'); 
    344                 $ic_customdata = $new_customdata = pw_admin::getOption('pw_custom_data'); 
    345                 $ic_timeval = $new_timeval = pw_admin::getOption('pw_time_validation'); 
    346                 $ic_managed = $new_managed = pw_admin::getOption('pw_trust_managed_cards'); 
    347                 $ic_idplist = $new_idplist = pw_admin::getOption('pw_trusted_idp_list'); 
    348  
     337                $opts = pw_admin::updateAdminOptions(); 
    349338                // write submitted changes if this page reload shows a submit 
    350                 if ( $_POST["infocard_admin_submit"] ) 
    351                 { 
    352                         $new_opener = $_POST['pw_infocard_opener']; 
    353                         $new_key = $_POST['pw_infocard_key']; 
    354                         $new_secureurl = $_POST['pw_securesiteurl']; 
    355                         $new_debug = $_POST['pw_debug_on']; 
    356                         $new_pass = $_POST['pw_enable_pass']; 
    357                         $new_trigger = $_POST['pw_selector_trigger']; 
    358                         $new_customdata = $_POST['pw_custom_data']; 
    359                         $new_timeval = $_POST['pw_time_validation']; 
    360                         $new_managed = $_POST['pw_trust_managed_cards']; 
    361                         $new_idplist = $_POST['pw_trusted_idp_list']; 
    362                 } 
    363  
    364                 if ( $ic_opener != $new_opener ){ 
    365                         update_option('pw_infocard_opener', $new_opener); 
    366                 } 
    367  
    368                 if ( $ic_key != $new_key ){ 
    369                         update_option('pw_infocard_key', $new_key); 
    370                 } 
    371  
    372                 if ( $secureurl != $new_secureurl ){ 
    373                         update_option('pw_securesiteurl', $new_secureurl ); 
    374                 } 
    375  
    376                 if ( $ic_debug != $new_debug ){ 
    377                         update_option('pw_debug_on', $new_debug ); 
    378                 } 
    379                  
    380                 if ( $ic_pass != $new_pass ){ 
    381                         update_option('pw_enable_pass', $new_pass ); 
    382                 } 
    383                  
    384                 if ( $ic_trigger != $new_trigger ){ 
    385                         update_option('pw_selector_trigger', $new_trigger ); 
    386                 } 
    387  
    388                 if ( $ic_customdata != $new_customdata ){ 
    389                         update_option('pw_custom_data', $new_customdata ); 
    390                 } 
    391  
    392                 if ( $ic_timeval != $new_timeval ){ 
    393                         update_option('pw_time_validation', $new_timeval ); 
    394                 } 
    395  
    396                 if ( $ic_managed != $new_managed ){ 
    397                         update_option('pw_trust_managed_cards', $new_managed ); 
    398                 } 
    399  
    400                 if ( $ic_idplist != $new_idplist ){ 
    401                         update_option('pw_trusted_idp_list', $new_idplist ); 
    402                 } 
    403  
    404                 pw_admin::printSystemCheck($new_secureurl); 
    405 ?> 
    406                                         <form  action="" method="post"> 
     339 
     340                 pw_admin::printSystemCheck($opts['pw_securesiteurl']); 
     341?> 
     342                <form  action="" method="post"> 
    407343                        <table border="0"><tr><th valign="bottom" colspan="2" align="left"> 
    408344                        <tr><td>&nbsp</td><td/></tr> 
     
    414350                        </label> 
    415351                        </td><td> 
    416                         <input type="text" name="pw_securesiteurl" id="pw_securesiteurl" size="50" value="<?php print $new_secureurl; ?>" /> 
     352                        <input type="text" name="pw_securesiteurl" id="pw_securesiteurl" size="50" value="<?php print $opts['pw_securesiteurl']; ?>" /> 
    417353                        </td></tr> 
    418354 
     
    422358                        </label> 
    423359                        </td><td> 
    424                         <textarea cols="60" rows="4" name="pw_infocard_key" id="pw_infocard_key"><?php print $new_key; ?></textarea> 
     360                        <textarea cols="60" rows="4" name="pw_infocard_key" id="pw_infocard_key"><?php print $opts['pw_infocard_key']; ?></textarea> 
    425361                        </td></tr> 
    426362                        <tr><td> 
     
    429365                        </label> 
    430366                        </td><td> 
    431                         <input type="text" name="pw_infocard_opener" id="pw_infocard_opener" size="50" value="<?php print $new_opener; ?>" /> 
     367                        <input type="text" name="pw_infocard_opener" id="pw_infocard_opener" size="50" value="<?php print $opts['pw_infocard_opener']; ?>" /> 
     368<?php /* 
    432369                        </td></tr> 
    433370 <tr><td colspan="2"> 
    434                                 <input name="pw_enable_pass" type="checkbox" id="pw_enable_pass" value="1" <?php checked('1', ($new_pass)); ?> /> 
     371                                <input name="pw_enable_pass" type="checkbox" id="pw_enable_pass" value="1" <?php checked('1', ($opts['pw_enable_pass'])); ?> /> 
    435372                                <?php pw_utils::screenPrint('Use Username/Password in addition to Information Cards'); ?> 
    436373                        </td></tr> 
     374*/ ?> 
    437375                        <tr><td>&nbsp;</td><td/></tr> 
    438                         <tr><td>&nbsp; 
    439 <?php 
    440                                 if (!$ic_secret) { 
    441                                 pw_utils::screenPrint('There is no 32-bit secret generated for this blog - the secret is needed for security purposes. Do not use this plugin until a secret has been generated & placed into the database'); 
    442                         } 
    443 ?> 
     376                        <tr><th colspan="2" align="left">To Enable Information Card User Login</td></tr> 
     377                        <tr><td colspan="2"><?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"> 
     378<?php 
     379                        pw_admin::printInstallData(); 
     380?>       
    444381                        </td></tr> 
    445                         <tr><th colspan="2" align="left">To Enable Information Card User Login</td></tr> 
    446                         <tr><td colspan="2"><?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> 
    447                         <tr><td colspan="2" id="code"> 
    448 <?php 
    449                         pw_admin::printInstallData(); 
    450 ?> 
    451                         </td></tr> 
    452                         <tr><td>&nbsp</td><td/></tr> 
    453                         <tr><th colspan="2" align="left"> 
    454                                 <?php pw_utils::ScreenPrint('Advanced Settings'); ?> 
    455                         </td></tr> 
     382                        <tr><td>&nbsp</td><td/></tr> 
     383                        <tr><th colspan="2" align="left"> 
     384                                <?php pw_utils::ScreenPrint('Advanced Settings'); ?> 
     385                        </td></tr> 
    456386                        <tr><td colspan="2"> 
    457                                 <?php pw_utils::screenPrint('Don\'t mess with these unless you understand and accept the consequences. Security breaches or errors could occur if you change these settings under the wrong circumstances.'); ?> 
    458                         </td></tr> 
    459                         <tr><td colspan="2">&nbsp;</td></tr> 
     387                                <?php pw_utils::screenPrint('Don\'t mess with these unless you understand and accept the consequences. Security breaches or errors could occur if you change these settings under the wrong circumstances.'); ?> 
     388                        </td></tr> 
     389                        <tr><td colspan="2">&nbsp;</td></tr> 
     390                        <tr><td> 
     391                                <?php pw_utils::screenPrint('Debug Mode'); ?> 
     392                        </td><td> 
     393                                <input name="pw_debug_on" type="radio" id="pw_debug_on" value="1" <?php echo ($opts['pw_debug_on'])?"checked":""; ?> /> 
     394                                <?php pw_utils::screenPrint('On'); ?> 
     395 
     396                                <input name="pw_debug_on" type="radio" id="pw_debug_on" value="0" <?php echo ($opts['pw_debug_on'])?"":"checked"; ?> /> 
     397                                <?php pw_utils::screenPrint('Off'); ?> 
     398                        </td></tr> 
     399                        <tr><td> 
     400                                <?php pw_utils::screenPrint('Time Validation'); ?> 
     401                        </td><td> 
     402                                <input name="pw_time_validation" type="radio" id="pw_time_validation" value="1" <?php echo ($opts['pw_time_validation'])?"checked":""; ?> /> 
     403                                <?php pw_utils::screenPrint('On'); ?> 
     404                                <input name="pw_time_validation" type="radio" id="pw_time_validation" value="0" <?php  echo ($opts['pw_time_validation'])?"":"checked"; ?> /> 
     405                                <?php pw_utils::screenPrint('Off'); ?> 
     406                        <tr><td> 
     407                                <?php pw_utils::screenPrint('Use Custom Data'); ?> 
     408                        </td><td> 
     409                                <input name="pw_custom_data" type="radio" id="pw_custom_data" value="1" <?php echo ($opts['pw_custom_data'])?"checked":""; ?> /> 
     410                                <?php pw_utils::screenPrint('On'); ?> 
     411                                <input name="pw_custom_data" type="radio" id="pw_custom_data" value="0" <?php  echo ($opts['pw_custom_data'])?"":"checked"; ?> /> 
     412                                <?php pw_utils::screenPrint('Off'); ?> 
     413                        </td></tr> 
     414                        <tr><td> 
     415                                <?php pw_utils::screenPrint('Selector Trigger'); ?> 
     416                        </td><td> 
     417                                <input name="pw_selector_trigger" type="radio" id="pw_selector_trigger" value="html" <?php echo ($opts['pw_selector_trigger'] === 'html')?"checked":""; ?> /> 
     418                                <?php pw_utils::screenPrint('HTML'); ?> 
     419                                <input name="pw_selector_trigger" type="radio" id="pw_selector_trigger" value="xhtml" <?php echo ($opts['pw_selector_trigger'] === 'xhtml')?"checked":""; ?> /> 
     420                                <?php pw_utils::screenPrint('XHTML'); ?> 
     421                        </td></tr> 
    460422                        <tr><td> 
    461                                 <?php pw_utils::screenPrint('Debug Mode'); ?> 
    462                         </td><td> 
    463                                 <input name="pw_debug_on" type="radio" id="pw_debug_on" value="1" <?php checked('1', ($new_debug)); ?> /> 
    464                                 <?php pw_utils::screenPrint('On'); ?> 
    465  
    466                                 <input name="pw_debug_on" type="radio" id="pw_debug_on" value="0" <?php checked('0', ($new_debug)); ?> /> 
    467                                 <?php pw_utils::screenPrint('Off'); ?> 
    468                         </td></tr> 
    469                         <tr><td> 
    470                                 <?php pw_utils::screenPrint('Time Validation'); ?> 
    471                         </td><td> 
    472                                 <input name="pw_time_validation" type="radio" id="pw_time_validation" value="1" <?php checked('1', ($new_timeval)); ?> /> 
    473                                 <?php pw_utils::screenPrint('On'); ?> 
    474  
    475                                 <input name="pw_time_validation" type="radio" id="pw_time_validation" value="0" <?php checked('0', ($new_timeval)); ?> /> 
    476                                 <?php pw_utils::screenPrint('Off'); ?> 
    477                         <tr><td> 
    478                                 <?php pw_utils::screenPrint('Use Custom Data'); ?> 
    479                         </td><td> 
    480                                 <input name="pw_custom_data" type="radio" id="pw_custom_data" value="1" <?php checked('1', ($new_customdata)); ?> /> 
    481                                 <?php pw_utils::screenPrint('On'); ?> 
    482  
    483                                 <input name="pw_custom_data" type="radio" id="pw_custom_data" value="0" <?php checked('0', ($new_customdata)); ?> /> 
    484                                 <?php pw_utils::screenPrint('Off'); ?> 
    485                         </td></tr> 
    486                         <tr><td> 
    487                                 <?php pw_utils::screenPrint('Trust Managed Cards'); ?> 
    488                         </td><td> 
    489                                 <input name="pw_trust_managed_cards" type="radio" id="pw_trust_managed_cards" value="0" <?php checked('0', ($new_managed)); ?> /> 
    490                                 <?php pw_utils::screenPrint('No'); ?> 
    491  
    492                                 <input name="pw_trust_managed_cards" type="radio" id="pw_trust_managed_cards" value="1" <?php checked('1', ($new_managed)); ?> /> 
    493                                 <?php pw_utils::screenPrint('Yes'); ?> 
    494                         </td></tr> 
    495 <?php 
    496                         if ( $new_managed ) 
    497                         { 
    498 ?> 
    499                         <tr><td/><td> 
    500                                 <?php pw_utils::screenPrint('Managed Card Trust List (values must be full sts URLs, each value is separated by a "|")'); ?> 
    501                                 <textarea cols="60" rows="3" name="pw_trusted_idp_list" id="pw_trusted_idp_list"><?php print $new_idplist; ?></textarea> 
    502                         </td><tr> 
    503  
    504 <?php 
    505                                  
    506                         } 
    507 ?> 
    508  
    509                         <tr><td> 
    510                                 <?php pw_utils::screenPrint('Selector Trigger'); ?> 
    511                         </td><td> 
    512                                 <input name="pw_selector_trigger" type="radio" id="pw_selector_trigger" value="html" <?php checked('html', ($new_trigger)); ?> />        
    513                                 <?php pw_utils::screenPrint('HTML'); ?> 
    514                                 <input name="pw_selector_trigger" type="radio" id="pw_selector_trigger" value="xhtml" <?php checked('xhtml', ($new_trigger)); ?> /> 
    515                                 <?php pw_utils::screenPrint('XHTML'); ?> 
    516                         </td></tr> 
    517                         <tr><td>&nbsp;</td><td/></tr> 
    518                         <tr><td colspan="2"><?php pw_utils::screenPrint('This test requires that changes be made to the Apache configuration files.  You only need to run this test if everything is green above, but things are still broken.'); ?></td></tr> 
    519  <tr><td> 
    520                                 <?php pw_utils::screenPrint('Advanced Certificate Check'); ?> 
    521                         </td><td valign="bottom">&nbsp; 
    522                                 <?php //pw_admin::advancedCertTest(IC_IMGURL); ?> 
    523                                 <br/>&nbsp;<a href="help/help.php?topic=advancedcerttest"><?php pw_utils::screenPrint('More Information');?></a> 
    524                         </td></tr> 
     423                                <?php pw_utils::screenPrint('Trust Managed Cards'); ?> 
     424                        </td><td> 
     425                                <input name="pw_trust_managed_cards" type="radio" id="pw_trust_managed_cards" value="0" <?php echo ($opts['pw_trust_managed_cards'])?"":"checked"; ?> /> 
     426                                <?php pw_utils::screenPrint('No'); ?> 
     427                                <input name="pw_trust_managed_cards" type="radio" id="pw_trust_managed_cards" value="1" <?php  echo ($opts['pw_trust_managed_cards'])?"checked":""; ?> /> 
     428                                <?php pw_utils::screenPrint('Yes'); ?> 
     429                        </td></tr> 
     430<?php 
     431                        if ( $opts['pw_trust_managed_cards'] ) 
     432                        { 
     433?> 
     434                        <tr><td/><td> 
     435                                <?php pw_utils::screenPrint('Managed Card Trust List (values must be full sts URLs, each value is separated by a "|")'); ?> 
     436                                <textarea cols="60" rows="3" name="pw_trusted_idp_list" id="pw_trusted_idp_list"><?php print $opts['pw_trusted_idp_list']; ?></textarea> 
     437                        </td></tr> 
     438<?php 
     439 
     440                        } 
     441?> 
    525442 
    526443                        </table> 
     
    547464                return; 
    548465        } 
     466 
     467        /* 
     468                Function:       setOption 
     469                Description:    updates an option in the infocard_options table 
     470                Input:          option_name:  the name of the option 
     471                                option_val:  the new value 
     472                Output:         the value set 
     473                Side Effects:   writes to the database 
     474        */ 
     475        function setOption( $option_name, $option_val ) 
     476        { 
     477                update_option($option_name, $option_val); 
     478                return $option_val; 
     479        } 
    549480} // end class pw_admin 
    550481?>