Changeset 22


Ignore:
Timestamp:
Nov 23, 2005 9:29:33 PM (18 years ago)
Author:
scdev
Message:

More bugs and shifting things about.

Location:
trunk
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/module_maker/form_template.cli.php

    r21 r22  
    6464    <tr>
    6565        <td class="right"><label for="$field"<\x3fphp \$fv->err('$field', ' class="error"') \x3f>><\x3fphp echo _("$title"); \x3f></label></td>
    66         <td valign="top">
     66        <td>
    6767            <select name="$field" class="small">
    68             <\x3fphp printSelectForm('<##>_tbl', "CONCAT(<##>_id, '&mdash;', <##>)", '$field', \$frm['$field'], true, 'ORDER BY $field DESC'); \x3f>
     68            <\x3fphp printSelectForm('<##>_tbl', "CONCAT(<##>_id, '&mdash;', <##>)", '$field', \$frm['$field'], true, 'ORDER BY $field ASC'); \x3f>
    6969            </select>
     70            <span class="commandtext">
     71                <span class="commanditem"><a href="<\x3fphp echo App::oHREF('<##>.php?op=add&boomerang=true'); \x3f>" onClick="javascript:return confirm('<\x3fphp echo _("Notice: You are about to leave this form page and any changes you may have made without saving will be lost."); \x3f>')"><\x3fphp echo _("Add <##>") \x3f></a></span>
     72                <\x3fphp if ('' != \$frm['<##>_id']) { \x3f>
     73                    <span class="commanditem"><a href="<\x3fphp echo App::oHREF('<##>.php?op=edit&boomerang=true&<##>_id=' . \$frm['<##>_id']); \x3f>" onClick="javascript:return confirm('<\x3fphp echo _("Notice: You are about to leave this form page and any changes you may have made without saving will be lost."); \x3f>')"><\x3fphp echo sprintf(_("Edit <##> <em>%s</em>"), \$frm['<##>']) \x3f></a></span>
     74                <\x3fphp } \x3f>
     75            </span>
    7076        </td>
    7177    </tr>
     
    7985    <tr>
    8086        <td class="right"><label for="$field"<\x3fphp \$fv->err('$field', ' class="error"') \x3f>><\x3fphp echo _("$title"); \x3f></label></td>
    81         <td valign="top">
     87        <td>
    8288            <input type="file" name="$field" />
    8389            <\x3fphp if ('' != \$upload->getFilenameGlob(getFormData('$primary_key_field') . '_*') && getFormData('op') == 'edit' || getFormData('op') == 'update') { \x3f>
    84             <div class="help"><\x3fphp printf(_("The current file <a href=\"%s/%2\$s\"><strong>%2\$s</strong></a> will be deleted if a new file is selected for upload."), '/_db_files/<##>', \$upload->getFilenameGlob(getFormData('$primary_key_field') . '_*')) \x3f></div>
     90            <div class="help"><\x3fphp printf(_("The current file <a href=\"%s/%2\\\$s\"><strong>%2\\\$s</strong></a> will be deleted if a new file is selected for upload."), '/_db_files/<##>', \$upload->getFilenameGlob(getFormData('$primary_key_field') . '_*')) \x3f></div>
    8591            <\x3fphp } \x3f>
    8692            <div class="help"><\x3fphp printf(_("File to upload must have one of the following file-name extensions: %s."), join(', ', \$upload->getParam('valid_file_extensions'))) \x3f></div>
     
    96102    <tr>
    97103        <td class="right"><label for="$field"<\x3fphp \$fv->err('$field', ' class="error"') \x3f>><\x3fphp echo _("$title"); \x3f></label></td>
    98         <td valign="top">
     104        <td>
    99105            <input type="password" class="medium" size="50" name="$field" value="<\x3fphp echo oTxt(\$frm['$field']); \x3f>" />
    100106        </td>
     
    111117    <tr>
    112118        <td class="right"><label for="$field"<\x3fphp \$fv->err('$field', ' class="error"') \x3f>><\x3fphp echo _("$title"); \x3f></label></td>
    113         <td valign="top">
     119        <td>
    114120            <select name="$field">
    115121            <\x3fphp printSetSelectForm('$db_tbl', '$field', \$frm['$field'], true); \x3f>
     
    125131    <tr>
    126132        <td class="right"><label for="$field"<\x3fphp \$fv->err('$field', ' class="error"') \x3f>><\x3fphp echo _("$title"); \x3f></label></td>
    127         <td valign="top">
     133        <td>
    128134            <\x3fphp printSetCheckboxes('$db_tbl', '$field', \$frm['$field'], 1) \x3f>
    129135        </td>
     
    156162    <tr>
    157163        <td class="right"><label for="$field"<\x3fphp \$fv->err('$field', ' class="error"') \x3f>><\x3fphp echo _("$title"); \x3f></label></td>
    158         <td valign="top">
     164        <td>
    159165            <textarea class="large" cols="75" rows="4" name="$field"><\x3fphp echo oTxt(\$frm['$field']); \x3f></textarea>
    160166        </td>
     
    195201    <tr>
    196202        <td class="right"><label for="$field"<\x3fphp \$fv->err('$field', ' class="error"') \x3f>><\x3fphp echo _("$title"); \x3f></label></td>
    197         <td valign="top">
     203        <td>
    198204            <input type="text" class="medium" size="50" name="$field" value="<\x3fphp echo oTxt(\$frm['$field']); \x3f>" />
    199205        </td>
  • trunk/bin/module_maker/module.cli.php

    r21 r22  
    207207$search['admin_upload_insert'] = '/%ADMIN_UPLOAD_INSERT%/';
    208208$replace['admin_upload_insert'] = '';
    209 $search['admin_upload_insert2'] = '/%ADMIN_UPLOAD_INSERT2%/';
    210 $replace['admin_upload_insert2'] = '';
    211209$search['admin_upload_update'] = '/%ADMIN_UPLOAD_UPDATE%/';
    212210$replace['admin_upload_update'] = '';
    213211
    214212if ($upload_file_capability) {
     213    // Form arguments
    215214    $replace['admin_form_tag_init'] = "<form enctype=\"multipart/form-data\" method=\"post\" action=\"<\x3fphp echo \$_SERVER['PHP_SELF']; \x3f>\">\n<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"<##>\" />";
    216 
     215   
     216    // Include statement.
    217217    $replace['admin_upload_include'] = "require_once 'codebase/lib/Upload.inc.php';\n";
    218218
     219    // Config
    219220    $replace['admin_upload_config'] = <<<E_O_F
    220221
     
    230231E_O_F;
    231232
     233    // Main init.
    232234    $replace['admin_upload_init'] = <<<E_O_F
    233235
     
    238240E_O_F;
    239241
     242    // Delete.
    240243    $replace['admin_upload_del'] = <<<E_O_F
    241244
     
    246249E_O_F;
    247250
     251    // Insert 1.
    248252    $replace['admin_upload_insert'] = <<<E_O_F
    249253
    250         // Upload file.
    251         if (!\$new_files = \$upload->process('<##>')) {
    252             // Upload failed. Reload form, displaying errors.
    253             \$frm =& addRecordForm();
    254             \$frm = array_merge(\$frm, getFormData());
    255             \$nav->addPage(_("Add %ITEM_TITLE%"));
    256             \$main_template = '%ADMIN_FORM_TEMPLATE%';
    257             break;
     254        // Upload files with prepended primary key.
     255        \$new_file = \$upload->process('<##>',  \$%PRIMARY_KEY% . '_' . getFormData('<##>'));
     256
     257        // If file upload errors, redirect to edit operation for the inserted record.
     258        if (\$upload->anyErrors() || false === \$new_file) {
     259            App::dieURL(\$_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . \$%PRIMARY_KEY%);
    258260        }
    259261E_O_F;
    260262
    261     $replace['admin_upload_insert2'] = <<<E_O_F
    262 
    263         // Record inserted successfuly. Now we know the primary key, prepend to filename.
    264         \$upload->moveFile(\$new_files[0]['name'], \$%PRIMARY_KEY% . '_' . \$new_files[0]['name']);
    265 E_O_F;
    266 
     263    // Update.
    267264    $replace['admin_upload_update'] = <<<E_O_F
    268265
    269         // Upload new file.
     266        // Upload new files.
    270267        if (getFormData('<##>')) {
    271             if (\$upload->process('<##>',  getFormData('%PRIMARY_KEY%') . '_' . getFormData('<##>'))) {
    272                 // Upload success. Delete old file.
    273                 if ('' != \$upload->getFilenameGlob(getFormData('%PRIMARY_KEY%') . '_*')) {
    274                     \$upload->deleteFile(\$upload->getFilenameGlob(getFormData('%PRIMARY_KEY%') . '_*'));
    275                 }
    276             } else {
    277                 // Upload failed. Reload form, displaying errors.
     268            // Get old file names for deletion.
     269            \$old_file = \$upload->getFilenameGlob(getFormData('%PRIMARY_KEY%') . '_*');
     270            // Process new file upload with prepended primary key.
     271            \$new_file = \$upload->process('<##>',  getFormData('%PRIMARY_KEY%') . '_' . getFormData('<##>'));
     272            if (false === \$new_file || \$upload->anyErrors()) {
     273                // Upload failed. Reload form. Display errors.
    278274                \$frm =& editRecordForm(getFormData('%PRIMARY_KEY%'));
    279275                \$frm = array_merge(\$frm, getFormData());
     
    281277                \$main_template = '%ADMIN_FORM_TEMPLATE%';
    282278                break;
    283             }           
     279            } else {
     280                // Upload succeeded. Delete old files.
     281                if ('' != \$old_file && \$old_file != \$new_file[0]['name']) {
     282                    \$upload->deleteFile(\$old_file);
     283                }
     284            }
    284285        }
    285286E_O_F;
    286 } // End if.
     287} // End upload_file_capability.
    287288
    288289
  • trunk/bin/module_maker/skel/adm_form.ihtml

    r21 r22  
    99    <tr>
    1010        <td>&nbsp;</td>
    11         <td valign="top"><?php printSubmitButtons($frm['submit_buttons']); ?></td>
     11        <td><?php printSubmitButtons($frm['submit_buttons']); ?></td>
    1212    </tr>
    1313%ADM_FORM_TABLE_ROWS%
    1414    <tr>
    1515        <td>&nbsp;</td>
    16         <td valign="top"><?php printSubmitButtons($frm['submit_buttons']); ?></td>
     16        <td><?php printSubmitButtons($frm['submit_buttons']); ?></td>
    1717    </tr>
    1818</table>
  • trunk/bin/module_maker/skel/admin.php

    r21 r22  
    9292//     $auth->requireAccessClearance(ZONE_ADMIN_%NAME_UPPER%_FUNC_ADD);
    9393    if (getFormdata('cancel', false)) {
     94        if (App::validBoomerangURL('%NAME_PLURAL%')) {
     95            // Display boomerang page.
     96            App::dieBoomerangURL('%NAME_PLURAL%');
     97        }
     98        // Display default page.
    9499        App::dieURL($_SERVER['PHP_SELF']);
    95100    }
     
    100105        $nav->addPage(_("Add %ITEM_TITLE%"));
    101106        $main_template = '%ADMIN_FORM_TEMPLATE%';
    102     } else {%ADMIN_UPLOAD_INSERT%
    103         $%PRIMARY_KEY% = insertRecord(getFormData());%ADMIN_UPLOAD_INSERT2%
     107    } else {
     108        $%PRIMARY_KEY% = insertRecord(getFormData());%ADMIN_UPLOAD_INSERT%
    104109        if (getFormdata('repeat', false)) {
    105110            // Display function again.
     
    122127    if (getFormdata('cancel', false)) {
    123128        // Remove lock
    124         $lock =& RecordLock::getInstance($GLOBALS['auth']);
    125129        $lock->select('%DB_TBL%', '%PRIMARY_KEY%', getFormData('%PRIMARY_KEY%'));
    126130        $lock->remove();
     
    202206function &editRecordForm($id)
    203207{
    204     $lock =& RecordLock::getInstance($GLOBALS['auth']);
     208    global $lock;
     209
    205210    $lock->select('%DB_TBL%', '%PRIMARY_KEY%', $id);
    206211    if ($lock->isLocked() && !$lock->isMine()) {
     
    240245function deleteRecord($id)
    241246{
    242     $lock =& RecordLock::getInstance($GLOBALS['auth']);
     247    global $lock;
     248   
    243249    $lock->select('%DB_TBL%', '%PRIMARY_KEY%', $id);
    244250    if ($lock->isLocked() && !$lock->isMine()) {
     
    291297function updateRecord($frm)
    292298{
    293     global $auth;
    294    
    295     $lock =& RecordLock::getInstance($GLOBALS['auth']);
     299    global $auth, $lock;
     300   
    296301    $lock->select('%DB_TBL%', '%PRIMARY_KEY%', $frm['%PRIMARY_KEY%']);
    297302    if ($lock->isLocked() && !$lock->isMine()) {
  • trunk/css/admin.inc.css

    r21 r22  
    230230{
    231231    vertical-align: top;
    232     padding: 8px 6px 0 0 ;
     232    padding: 8px 6px 0 0;
    233233}
    234234
  • trunk/css/utilities.inc.css

    r21 r22  
    1010
    1111/* BEAU: I format my CSS using BBEdit's Markup->CSS->Format command. Would you like to use that as well so our code looks consistant? */
    12 
    1312/*_____________________ FORMS ____________________*/
    1413input, select, input.submit
    1514{
    16     color: #000;
    17     margin: 0 0.5em 0 0;
    18     padding: 0;
     15    color: #000;
     16    margin: 0 0.5em 0 0;
     17    padding: 0;
    1918}
    2019
     
    2221input.submit
    2322{
    24     font-weight: bold;
    25     margin: 0.5em;
     23    font-weight: bold;
     24    margin: 0.5em;
    2625}
    2726
    2827input
    2928{
    30     margin: 0.5em 0.5em 0 0;
     29    margin: 0.5em 0.5em 0 0;
    3130}
    3231
    3332form table select, form table input
    3433{
    35     margin-top: 0;
     34    margin-top: 0;
    3635}
    3736
     
    3938BEAU: I want more text box widths! I find need for boxes that fit 5em, 10em, 20em, and 40em widths. These should be in EMs so text can resize and still fit. Since it is useful to apply a width to other form elements to have them similar sizes (not always a text box, such as <select multiple>) I propose renaming them to "input.tiny", "input.small", "input.medium", "input.large", and "input.half" (not sure how you would do "half" in EMs however.
    4039*/
    41 input.tiny, textarea.tiny
     40
     41input.tiny, textarea.tiny, select.tiny
    4242{
    4343    width: 4.75em;
    4444}
    4545
    46 input.small, textarea.small
     46input.small, textarea.small, select.small
    4747{
    4848    width: 10em;
    4949}
    5050
    51 input.medium, textarea.medium
     51input.medium, textarea.medium, select.medium
    5252{
    5353    width: 20.5em;
    5454}
    5555
    56 input.large, textarea.large
     56input.large, textarea.large, select.large
    5757{
    5858    width: 41.5em;
    5959}
    6060
    61 textarea
     61textarea.twolines, select.twolines
    6262{
    63     height: 8em;
     63    height: 3em;
    6464}
    6565
    66 textarea.twolines
     66textarea.short, select.short
    6767{
    68     height: 3em;
     68    height: 8em;
    6969}
    7070
    71 textarea.short
     71textarea.tall, select.tall
    7272{
    73     height: 8em;
     73    height: 25em;
    7474}
    7575
    76 textarea.tall
     76textarea.fullscreen, select.fullscreen
    7777{
    78     height: 25em;
    79 }
    80 
    81 textarea.fullscreen
    82 {
    83     height: 40em;
     78    height: 40em;
    8479}
    8580
     
    9792form label
    9893{
    99     padding: 7px 0px 0px 0px;
    100     font-weight: bold;
     94    padding: 7px 0px 0px 0px;
     95    font-weight: bold;
    10196}
    10297
    10398/* BEAU: We need a .formtext substitute...something like a label tag but not bold! */
    104 
    10599/*_____________________ COMMANDS ____________________*/
    106100#commandbox
    107101{
    108     padding: 5px;
    109     margin: 0 0 .5em 0;
    110     border: black 1px dotted;
    111     background-color: #DDD;
     102    padding: 5px;
     103    margin: 0 0 .5em 0;
     104    border: black 1px dotted;
     105    background-color: #DDD;
    112106}
    113107
    114108.commanditem
    115109{
    116     margin: 0 10px 0 0;
    117     white-space: nowrap;
     110    margin: 0 10px 0 0;
     111    white-space: nowrap;
    118112}
    119113
    120114.commandtext
    121115{
    122     padding-right: 1em;
     116    padding-right: 1em;
    123117}
    124118
    125119.command_left
    126120{
    127     float:left; 
    128     white-space: nowrap;
     121    float: left;
     122    white-space: nowrap;
    129123}
    130124
    131125.command_right
    132126{
    133     position: relative;
    134     visibility: visible;
    135     white-space: nowrap;
    136     float:right; 
     127    position: relative;
     128    visibility: visible;
     129    white-space: nowrap;
     130    float: right;
    137131}
    138132
     
    140134.nowrap
    141135{
    142     white-space: nowrap;
     136    white-space: nowrap;
    143137}
    144138
    145139.clearboth
    146140{
    147     clear: both;
     141    clear: both;
    148142}
    149143
    150144.center
    151145{
    152     text-align: center;
     146    text-align: center;
    153147}
    154148
    155149.right
    156150{
    157     text-align: right;
     151    text-align: right;
    158152}
    159153
    160154.padright
    161155{
    162     padding: 0 10px 0 0;
     156    padding: 0 10px 0 0;
    163157}
    164158
    165159.padleft
    166160{
    167     padding: 0 0 0 10px;
     161    padding: 0 0 0 10px;
    168162}
    169163
    170164.help
    171165{
    172     color: #999;
    173     font-weight: normal;
     166    color: #666;
     167    font-weight: normal;
    174168}
    175169
    176170.monospaced
    177171{
    178     font-family: monaco, courier;
    179     font-weight: normal;
     172    font-family: monaco, courier;
     173    font-weight: normal;
    180174}
  • trunk/lib/App.inc.php

    r21 r22  
    152152        }
    153153       
    154         if (!isset($_SESSION[$this->app])) {
    155             $_SESSION[$this->app] = array();
    156         }
    157 
    158154        // Initialize default parameters.
    159155        $this->_params = array_merge($this->_params, $this->_param_defaults);
     
    296292            session_name($this->getParam('session_name'));
    297293           
    298             // Start the session. Access session data using: $_SESSION['...']
     294            // Start the session.
    299295            session_start();
     296           
     297            if (!isset($_SESSION[$this->app])) {
     298                // Access session data using: $_SESSION['...'].
     299                // Initialize here _after_ session has started.
     300                $_SESSION[$this->app] = array(
     301                    'messages' => array(),
     302                    'boomerang' => array('url'),
     303                );
     304            }
    300305        }
    301306       
     
    374379       
    375380        if (!in_array($type, array(MSG_NOTICE, MSG_SUCCESS, MSG_WARNING, MSG_ERR))) {
    376             App::logMsg(sprintf('Invalid MSG_* type: %s', $type), LOG_DEBUG, __FILE__, __LINE__);
     381            $this->logMsg(sprintf('Invalid MSG_* type: %s', $type), LOG_DEBUG, __FILE__, __LINE__);
    377382        }
    378383    }
     
    752757        if (preg_match('!^/!', $url)) {
    753758            // If relative URL is given, prepend correct local hostname.
    754             $my_url = parse_url($_SERVER['SCRIPT_URI']);
    755             $url = sprintf('%s://%s%s', $my_url['scheme'], $my_url['host'], $url);
    756         }
    757    
     759            $scheme = 'on' == getenv('HTTPS') ? 'https' : 'http';
     760            $host = getenv('HTTP_HOST');
     761            $url = sprintf('%s://%s%s', $scheme, $host, $url);
     762        }
     763
    758764        $url = $this->oHREF($url, $carry_args, $always_include_sid);
    759765       
     
    787793            if (isset($id) && isset($_SESSION[$this->app]['boomerang']['url'][$id])) {
    788794                $url = $_SESSION[$this->app]['boomerang']['url'][$id];
     795                $this->logMsg(sprintf('dieBoomerangURL(%s) found: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
    789796            } else {
    790797                $url = end($_SESSION[$this->app]['boomerang']['url']);
    791             }
    792         } else if (!refererIsMe() && !preg_match('/admin_common/', getenv('SCRIPT_NAME'))) {
     798                $this->logMsg(sprintf('dieBoomerangURL(%s) using: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
     799            }
     800            // Delete stored boomerang.
     801            $this->deleteBoomerangURL($id);
     802        } else if (!refererIsMe()) {
    793803            // Ensure that the redirecting page is not also the referrer.
    794             // admin_common is an alias of 'admin', which confuses this function. Just here for local testing.
    795804            $url = getenv('HTTP_REFERER');
     805            $this->logMsg(sprintf('dieBoomerangURL(%s) using referrer: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
    796806        } else {
    797             $url = '';
    798         }
    799    
    800         $this->logMsg(sprintf('dieBoomerangURL: %s', $url), LOG_DEBUG, __FILE__, __LINE__);
    801    
    802         // Delete stored boomerang.
    803         $this->deleteBoomerangURL($id);
     807            // If URL is not specified, use the redirect_home_url.
     808            $url = $this->getParam('redirect_home_url');
     809            $this->logMsg(sprintf('dieBoomerangURL(%s) not found, using redirect_home_url: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
     810        }
     811   
    804812           
    805813        // A redirection will never happen immediatly twice.
     
    825833            return false;
    826834        }
    827        
    828835        // A redirection will never happen immediatly after setting the boomerangURL.
    829836        // Set the time so ensure this doesn't happen. See App::validBoomerangURL for more.
    830837   
    831         if (isset($url) && is_string($url)) {
     838        if ('' != $url && is_string($url)) {
    832839            // Delete any boomerang request keys in the query string.
    833840            $url = preg_replace('/boomerang=[\w]+/', '', $url);
    834841           
    835             if (is_array($_SESSION[$this->app]['boomerang']['url']) && !empty($_SESSION[$this->app]['boomerang']['url'])) {
     842            if (isset($_SESSION[$this->app]['boomerang']['url']) && is_array($_SESSION[$this->app]['boomerang']['url']) && !empty($_SESSION[$this->app]['boomerang']['url'])) {
    836843                // If the URL currently exists in the boomerang array, delete.
    837844                while ($existing_key = array_search($url, $_SESSION[$this->app]['boomerang']['url'])) {
     
    845852                $_SESSION[$this->app]['boomerang']['url'][] = $url;
    846853            }
    847             $this->logMsg(sprintf('setBoomerangURL: %s', $url), LOG_DEBUG, __FILE__, __LINE__);
     854            $this->logMsg(sprintf('setBoomerangURL(%s): %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
    848855            return true;
    849856        } else {
     857            $this->logMsg(sprintf('setBoomerangURL(%s) is empty!', $id, $url), LOG_NOTICE, __FILE__, __LINE__);
    850858            return false;
    851859        }
     
    895903        }
    896904       
     905        $this->logMsg(sprintf('deleteBoomerangURL(%s): %s', $id, $this->getBoomerangURL($id)), LOG_DEBUG, __FILE__, __LINE__);
     906
    897907        if (isset($id) && isset($_SESSION[$this->app]['boomerang']['url'][$id])) {
    898908            unset($_SESSION[$this->app]['boomerang']['url'][$id]);
     
    927937        $boomerang_time = isset($_SESSION[$this->app]['boomerang']['time']) ? $_SESSION[$this->app]['boomerang']['time'] : 0;
    928938       
     939        $url = '';
    929940        if (isset($id) && isset($_SESSION[$this->app]['boomerang']['url'][$id])) {
    930941            $url = $_SESSION[$this->app]['boomerang']['url'][$id];
     
    934945        }
    935946   
    936         $this->logMsg(sprintf('validBoomerangURL testing url: %s', $url), LOG_DEBUG, __FILE__, __LINE__);
    937         if (empty($url)) {
     947        $this->logMsg(sprintf('validBoomerangURL(%s) testing: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
     948
     949        if ('' == $url) {
     950            $this->logMsg(sprintf('validBoomerangURL(%s) not valid, empty!', $id), LOG_NOTICE, __FILE__, __LINE__);
    938951            return false;
    939952        }
    940953        if ($url == absoluteMe()) {
    941954            // The URL we are directing to is the current page.
    942             $this->logMsg(sprintf('Boomerang URL not valid, same as absoluteMe: %s', $url), LOG_WARNING, __FILE__, __LINE__);
     955            $this->logMsg(sprintf('validBoomerangURL(%s) not valid, same as absoluteMe: %s', $id, $url), LOG_NOTICE, __FILE__, __LINE__);
    943956            return false;
    944957        }
    945958        if ($boomerang_time >= (time() - 2)) {
    946959            // Last boomerang direction was more than 2 seconds ago.
    947             $this->logMsg(sprintf('Boomerang URL not valid, boomerang_time too short: %s', time() - $boomerang_time), LOG_WARNING, __FILE__, __LINE__);
    948             return false;
    949         }
    950        
    951         $this->logMsg(sprintf('validBoomerangURL found: %s', $url), LOG_DEBUG, __FILE__, __LINE__);
     960            $this->logMsg(sprintf('validBoomerangURL(%s) not valid, boomerang_time too short: %s', $id, time() - $boomerang_time), LOG_NOTICE, __FILE__, __LINE__);
     961            return false;
     962        }
     963       
     964        $this->logMsg(sprintf('validBoomerangURL(%s) is valid: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
    952965        return true;
    953966    }
  • trunk/lib/FormValidator.inc.php

    r21 r22  
    433433        $phone = getFormData($form_name);
    434434       
    435         $this->checkRegex($form_name, '/^[0-9 +().-]*$/', true, sprintf(_("The phone number <strong>%s</strong> is not valid."), $phone));
    436         $this->stringLength($form_name, 0, 25, sprintf(_("The phone number <strong>%s</strong> is too long"), $phone));
     435        return $this->checkRegex($form_name, '/^[0-9 +().-]*$/', true, sprintf(_("The phone number <strong>%s</strong> is not valid."), $phone))
     436        && $this->stringLength($form_name, 0, 25, sprintf(_("The phone number <strong>%s</strong> is too long"), $phone));
    437437    }
    438438
  • trunk/lib/Nav.inc.php

    r21 r22  
    148148       
    149149        if ($this->getFeature('title', $page_id)) {
    150             return oTxt($this->pages[$page_id]['title'], true);
     150            return oTxt($this->pages[$page_id]['title']);
    151151        } else {
    152152            return false;
  • trunk/lib/PEdit.inc.php

    r21 r22  
    163163                    ?>
    164164                    <tr>
    165                     <td valign="top" nowrap="nowrap"><p><?php echo date('r', $v['unixtime']); ?></p></td>
    166                     <td valign="top" nowrap="nowrap"><p>&nbsp;&nbsp;&nbsp;<?php printf(_("%s bytes"), $v['filesize']); ?></p></td>
    167                     <td valign="top" nowrap="nowrap"><p>&nbsp;&nbsp;&nbsp;[<a href="<?php echo App::oHREF(dirname($_SERVER['PHP_SELF']) . (preg_match('!/$!', dirname($_SERVER['PHP_SELF'])) ? '' : '/') . $v['filename']); ?>" target="_blank"><?php echo _("view"); ?></a>]</p></td>
    168                     <td valign="top" nowrap="nowrap"><p>&nbsp;&nbsp;&nbsp;[<a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=Restore&with_file=' . $v['filename'] . '&file_hash=' . md5('frog_guts' . $this->_filename)); ?>"><?php echo _("restore"); ?></a>]</p></td>
     165                    <td nowrap="nowrap"><p><?php echo date('r', $v['unixtime']); ?></p></td>
     166                    <td nowrap="nowrap"><p>&nbsp;&nbsp;&nbsp;<?php printf(_("%s bytes"), $v['filesize']); ?></p></td>
     167                    <td nowrap="nowrap"><p>&nbsp;&nbsp;&nbsp;[<a href="<?php echo App::oHREF(dirname($_SERVER['PHP_SELF']) . (preg_match('!/$!', dirname($_SERVER['PHP_SELF'])) ? '' : '/') . $v['filename']); ?>" target="_blank"><?php echo _("view"); ?></a>]</p></td>
     168                    <td nowrap="nowrap"><p>&nbsp;&nbsp;&nbsp;[<a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=Restore&with_file=' . $v['filename'] . '&file_hash=' . md5('frog_guts' . $this->_filename)); ?>"><?php echo _("restore"); ?></a>]</p></td>
    169169                    </tr>
    170170                    <?php   
     
    237237                ?>
    238238                <table border="0" cellspacing="0" cellpadding="2"><tr>
    239                 <td valign="top"><input type="hidden" name="data[<?php echo $name; ?>]" value="off" /><input type="checkbox" name="data[<?php echo $name; ?>]" <?php echo $checked; ?>/></td>
    240                 <td valign="top"><?php echo oTxt($this->_data[$name]['corresponding_text']); ?></td>
     239                <td><input type="hidden" name="data[<?php echo $name; ?>]" value="off" /><input type="checkbox" name="data[<?php echo $name; ?>]" <?php echo $checked; ?>/></td>
     240                <td><?php echo oTxt($this->_data[$name]['corresponding_text']); ?></td>
    241241                </tr></table>
    242242                <?php
  • trunk/lib/RecordLock.inc.php

    r21 r22  
    3333    {
    3434        static $instances = array();
    35 
    36         if (!is_a($auth_object, 'Auth_SQL')) {
    37             trigger_error('Constructor not provided a valid Auth_SQL object.', E_USER_ERROR);
    38         }
    3935               
    4036        if (!isset($instances[$auth_object->getVal('auth_name')])) {
     
    5248    function RecordLock($auth_object)
    5349    {
     50        if (!is_a($auth_object, 'Auth_SQL')) {
     51            trigger_error('Constructor not provided a valid Auth_SQL object.', E_USER_ERROR);
     52        }
     53
    5454        $this->_auth = $auth_object;
    5555       
     
    168168        }
    169169        if ($this->data = mysql_fetch_assoc($qid)) {
    170             App::logMsg(sprintf('Found locked record: %s %s %s', $record_table_or_lock_id, $record_key, $record_val), LOG_DEBUG, __FILE__, __LINE__);
     170            App::logMsg(sprintf('Selecting %slocked record: %s %s %s', ($this->data['set_by_admin_id'] == $this->_auth->getVal('user_id') ? 'self-' : ''), $record_table_or_lock_id, $record_key, $record_val), LOG_DEBUG, __FILE__, __LINE__);
     171            /// FIX ME: What if admin set lock, but public user is current lock user?
    171172            $this->data['editor'] = $this->_auth->getUsername($this->data['set_by_admin_id']);
    172173            return true;
     
    275276            WHERE lock_id = '" . addslashes($this->data['lock_id']) . "'
    276277        ");
     278       
     279        App::logMsg(sprintf('Removing lock: %s', $this->data['lock_id']), LOG_DEBUG, __FILE__, __LINE__);
    277280    }
    278281
  • trunk/lib/Upload.inc.php

    r21 r22  
    3030        'dest_file_perms' => 0600,
    3131
    32         // Require file to have one of the following file extentions.
     32        // Require file to have one of the following file name extentions.
    3333        'valid_file_extensions' => array('jpg', 'jpeg', 'gif', 'png', 'pdf', 'txt', 'text', 'html', 'htm'),
    3434    );
     
    3737    var $errors = array();
    3838
    39     // Array of file extensions and corresponding mime-types.
     39    // Array of file name extensions and corresponding mime-types.
    4040    var $mime_extension_map = array(
    4141        'Z'       => 'application/x-compress',
     
    278278        }
    279279       
     280        // Ensure the file form element specified actually exists.
    280281        if (!isset($_FILES[$form_name])) {
    281             App::logMsg(sprintf(_("Form element %s not posted."), $form_name), LOG_ERR, __FILE__, __LINE__);
    282             $this->raiseMsg(_("There was a problem with the file upload. Please try again."), MSG_ERR, __FILE__, __LINE__);
     282            App::logMsg(sprintf(_("Form element %s does not exist."), $form_name), LOG_ERR, __FILE__, __LINE__);
     283            $this->raiseMsg(_("There was a problem with the file upload. Please try again later."), MSG_ERR, __FILE__, __LINE__);
    283284            return false;
    284285        }
     
    314315            }
    315316           
    316             // Check The php upload error messages.
    317             if (UPLOAD_ERR_INI_SIZE === $files['error'][$i]) {
    318                 if ($this->getParam('display_messages')) {
    319                 $this->raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading: it exceeds the maximum allowed upload file size of %s."), $files['name'][$i], ini_get('upload_max_filesize')), MSG_ERR, __FILE__, __LINE__);
    320                 }
    321                 App::logMsg(sprintf(_("The file %s failed uploading with PHP error %s UPLOAD_ERR_INI_SIZE (currently %s)."), $files['error'][$i], $files['name'][$i], ini_get('upload_max_filesize')), LOG_ERR, __FILE__, __LINE__);
    322                 $this->errors[] = $files['name'][$i];
    323                 continue;
    324             }
    325             if (UPLOAD_ERR_FORM_SIZE === $files['error'][$i]) {
    326                 $this->raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading: it exceeds the maximum allowed upload file size of %s."), $files['name'][$i], $_POST['MAX_FILE_SIZE']), MSG_ERR, __FILE__, __LINE__);
    327                 App::logMsg(sprintf(_("The file %s failed uploading with PHP error %s UPLOAD_ERR_FORM_SIZE (currently %s)."), $files['error'][$i], $files['name'][$i], $_POST['MAX_FILE_SIZE']), LOG_ERR, __FILE__, __LINE__);
    328                 $this->errors[] = $files['name'][$i];
    329                 continue;
    330             }
    331             if (UPLOAD_ERR_PARTIAL === $files['error'][$i]) {
    332                 $this->raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading: it was only partially uploaded."), $files['name'][$i]), MSG_ERR, __FILE__, __LINE__);
    333                 App::logMsg(sprintf(_("The file %s failed uploading with PHP error %s UPLOAD_ERR_PARTIAL."), $files['error'][$i], $files['name'][$i]), LOG_ERR, __FILE__, __LINE__);
    334                 $this->errors[] = $files['name'][$i];
    335                 continue;
    336             }
    337             if (UPLOAD_ERR_NO_FILE === $files['error'][$i]) {
    338                 $this->raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading: no file was uploaded."), $files['name'][$i]), MSG_ERR, __FILE__, __LINE__);
    339                 App::logMsg(sprintf(_("The file %s failed uploading with PHP error %s UPLOAD_ERR_NO_FILE."), $files['error'][$i], $files['name'][$i]), LOG_ERR, __FILE__, __LINE__);
    340                 $this->errors[] = $files['name'][$i];
    341                 continue;
    342             }
    343             if (UPLOAD_ERR_NO_TMP_DIR === $files['error'][$i]) {
    344                 $this->raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading: temporary upload directory missing."), $files['name'][$i]), MSG_ERR, __FILE__, __LINE__);
    345                 App::logMsg(sprintf(_("The file %s failed uploading with PHP error %s UPLOAD_ERR_NO_TMP_DIR."), $files['error'][$i], $files['name'][$i]), LOG_ERR, __FILE__, __LINE__);
    346                 $this->errors[] = $files['name'][$i];
    347                 continue;
    348             }
    349            
    350             // Check to be sure it's an uploaded file.
    351             if (!is_uploaded_file($files['tmp_name'][$i])) {
    352                 $this->raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading."), $files['name'][$i]), MSG_ERR, __FILE__, __LINE__);
    353                 App::logMsg(sprintf(_("The file %s failed is_uploaded_file."), $files['name'][$i]), LOG_ERR, __FILE__, __LINE__);
    354                 $this->errors[] = $files['name'][$i];
    355                 continue;
    356             }
    357            
    358             // Check to be sure the file is not empty.
    359             if ($files['size'][$i] < 1) {
    360                 $this->raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading: it contains zero bytes."), $files['name'][$i]), MSG_ERR, __FILE__, __LINE__);
    361                 App::logMsg(sprintf(_("The uploaded file %s contains zero bytes."), $files['name'][$i]), LOG_ERR, __FILE__, __LINE__);
    362                 $this->errors[] = $files['name'][$i];
    363                 continue;
    364             }
    365            
    366             // Check to be sure the file has a valid file extension.
    367             if (!in_array(strtolower($this->getFilenameExtension($files['name'][$i])), $this->getParam('valid_file_extensions'))) {
    368                 $this->raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading: it is an unrecognized type. Files must have one of the following file extensions: %s."), $files['name'][$i], join(', ', $this->getParam('valid_file_extensions'))), MSG_ERR, __FILE__, __LINE__);
    369                 App::logMsg(sprintf(_("The uploaded file %s has an unrecognized file extension."), $files['name'][$i]), LOG_WARNING, __FILE__, __LINE__);
    370                 $this->errors[] = $files['name'][$i];
    371                 continue;
    372             }
    373            
    374             // Check to be sure the file has a unique file name.
    375             if (!$this->getParam('allow_overwriting') && $this->exists($files['name'][$i])) {
    376                 $this->raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading: a file with that name already exists."), $files['name'][$i]), MSG_ERR, __FILE__, __LINE__);
    377                 App::logMsg(sprintf(_("The uploaded file %s doesn't have a unique filename."), $files['name'][$i]), LOG_WARNING, __FILE__, __LINE__);
    378                 $this->errors[] = $files['name'][$i];
    379                 continue;
    380             }
    381            
    382             // Determine file name.
     317            // Determine final file name.
    383318            if ($num == 1) {
    384319                // Single upload.
     
    420355            $file_path_name = $this->getParam('upload_path') . '/' . $file_name;
    421356           
     357           
     358            // Check The php upload error messages.
     359            if (UPLOAD_ERR_INI_SIZE === $files['error'][$i]) {
     360                if ($this->getParam('display_messages')) {
     361                $this->raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading: it exceeds the maximum allowed upload file size of %s."), $file_name, ini_get('upload_max_filesize')), MSG_ERR, __FILE__, __LINE__);
     362                }
     363                App::logMsg(sprintf(_("The file %s failed uploading with PHP error %s UPLOAD_ERR_INI_SIZE (currently %s)."), $files['error'][$i], $file_name, ini_get('upload_max_filesize')), LOG_ERR, __FILE__, __LINE__);
     364                $this->errors[] = $file_name;
     365                continue;
     366            }
     367            if (UPLOAD_ERR_FORM_SIZE === $files['error'][$i]) {
     368                $this->raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading: it exceeds the maximum allowed upload file size of %s."), $file_name, $_POST['MAX_FILE_SIZE']), MSG_ERR, __FILE__, __LINE__);
     369                App::logMsg(sprintf(_("The file %s failed uploading with PHP error %s UPLOAD_ERR_FORM_SIZE (currently %s)."), $files['error'][$i], $file_name, $_POST['MAX_FILE_SIZE']), LOG_ERR, __FILE__, __LINE__);
     370                $this->errors[] = $file_name;
     371                continue;
     372            }
     373            if (UPLOAD_ERR_PARTIAL === $files['error'][$i]) {
     374                $this->raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading: it was only partially uploaded."), $file_name), MSG_ERR, __FILE__, __LINE__);
     375                App::logMsg(sprintf(_("The file %s failed uploading with PHP error %s UPLOAD_ERR_PARTIAL."), $files['error'][$i], $file_name), LOG_ERR, __FILE__, __LINE__);
     376                $this->errors[] = $file_name;
     377                continue;
     378            }
     379            if (UPLOAD_ERR_NO_FILE === $files['error'][$i]) {
     380                $this->raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading: no file was uploaded."), $file_name), MSG_ERR, __FILE__, __LINE__);
     381                App::logMsg(sprintf(_("The file %s failed uploading with PHP error %s UPLOAD_ERR_NO_FILE."), $files['error'][$i], $file_name), LOG_ERR, __FILE__, __LINE__);
     382                $this->errors[] = $file_name;
     383                continue;
     384            }
     385            if (UPLOAD_ERR_NO_TMP_DIR === $files['error'][$i]) {
     386                $this->raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading: temporary upload directory missing."), $file_name), MSG_ERR, __FILE__, __LINE__);
     387                App::logMsg(sprintf(_("The file %s failed uploading with PHP error %s UPLOAD_ERR_NO_TMP_DIR."), $files['error'][$i], $file_name), LOG_ERR, __FILE__, __LINE__);
     388                $this->errors[] = $file_name;
     389                continue;
     390            }
     391           
     392            // Check to be sure it's an uploaded file.
     393            if (!is_uploaded_file($files['tmp_name'][$i])) {
     394                $this->raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading."), $file_name), MSG_ERR, __FILE__, __LINE__);
     395                App::logMsg(sprintf(_("The file %s failed is_uploaded_file."), $file_name), LOG_ERR, __FILE__, __LINE__);
     396                $this->errors[] = $file_name;
     397                continue;
     398            }
     399           
     400            // Check to be sure the file is not empty.
     401            if ($files['size'][$i] < 1) {
     402                $this->raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading: it contains zero bytes."), $file_name), MSG_ERR, __FILE__, __LINE__);
     403                App::logMsg(sprintf(_("The uploaded file %s contains zero bytes."), $file_name), LOG_ERR, __FILE__, __LINE__);
     404                $this->errors[] = $file_name;
     405                continue;
     406            }
     407           
     408            // Check to be sure the file has a valid file name extension.
     409            if (!in_array(strtolower($this->getFilenameExtension($file_name)), $this->getParam('valid_file_extensions'))) {
     410                $this->raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading: it is an unrecognized type. Files must have one of the following file name extensions: %s."), $file_name, join(', ', $this->getParam('valid_file_extensions'))), MSG_ERR, __FILE__, __LINE__);
     411                App::logMsg(sprintf(_("The uploaded file %s has an unrecognized file name extension."), $file_name), LOG_WARNING, __FILE__, __LINE__);
     412                $this->errors[] = $file_name;
     413                continue;
     414            }
     415           
     416            // Check to be sure the file has a unique file name.
     417            if (!$this->getParam('allow_overwriting') && $this->exists($file_name)) {
     418                $this->raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading: a file with that name already exists."), $file_name), MSG_ERR, __FILE__, __LINE__);
     419                App::logMsg(sprintf(_("The uploaded file %s doesn't have a unique filename."), $file_name), LOG_WARNING, __FILE__, __LINE__);
     420                $this->errors[] = $file_name;
     421                continue;
     422            }
     423           
    422424            // Move the file to the final place.
    423425            if (move_uploaded_file($files['tmp_name'][$i], $file_path_name)) {
    424426                chmod($file_path_name, $this->getParam('dest_file_perms'));
    425                 $this->raiseMsg(sprintf(_("The file <strong>%s</strong> uploaded successfully."), $files['name'][$i]), MSG_SUCCESS, __FILE__, __LINE__);
     427                $this->raiseMsg(sprintf(_("The file <strong>%s</strong> uploaded successfully."), $file_name), MSG_SUCCESS, __FILE__, __LINE__);
    426428                if (!isset($custom_file_name) && $files['name'][$i] != $file_name) {
    427429                    // Notify user if uploaded file name was modified (unless a custom file name will be used anyways).
     
    435437                continue;
    436438            } else {
    437                 $this->raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading."), $files['name'][$i]), MSG_ERR, __FILE__, __LINE__);
     439                $this->raiseMsg(sprintf(_("The file <strong>%s</strong> failed uploading."), $file_name), MSG_ERR, __FILE__, __LINE__);
    438440                App::logMsg(sprintf(_("Moving file failed: %s -> %s"), $files['tmp_name'][$i], $file_path_name), LOG_ALERT, __FILE__, __LINE__);
    439                 $this->errors[] = $files['name'][$i];
    440                 continue;
    441             }
    442         }
    443         return (sizeof($new_file_names) > 0) ? $new_file_names : false;
     441                $this->errors[] = $file_name;
     442                continue;
     443            }
     444        }
     445       
     446        // Return names of files uploaded (or empty array when none processed).
     447        return $new_file_names;
    444448    }
    445449   
     
    543547     *
    544548     */
     549    function anyErrors()
     550    {
     551        return sizeof($this->errors) > 0;
     552    }
     553
     554    /**
     555     *
     556     */
    545557    function cleanFileName($file_name)
    546558    {
     
    560572    {
    561573        preg_match('/.*?\.(\w+)$/i', $file_name, $ext);
    562         return $ext[1];
     574        return isset($ext[1]) ? $ext[1] : '';
    563575    }
    564576   
  • trunk/lib/Utilities.inc.php

    r21 r22  
    532532 * @access  public
    533533 * @param   string  $val    The string to sign.
    534  * @param   string  $key    (Optional) A text key to use for computing the signature.
     534 * @param   string  $seed_key   (Optional) A text key to use for computing the signature.
    535535 * @return  string  The original value with a signature appended.
    536536 */
    537 function addSignature($val, $key=null)
     537function addSignature($val, $seed_key=null)
    538538{
    539539    if ('' == $val) {
     
    541541    }
    542542   
    543     if (!isset($key)) {
    544         $key = App::getParam('signing_key');
    545     }
    546 
    547     return $val . '-' . substr(md5($val . $key), 0, 18);
     543    if (!isset($seed_key)) {
     544        $seed_key = App::getParam('signing_key');
     545    }
     546
     547    return $val . '-' . substr(md5($val . $seed_key), 0, 18);
    548548}
    549549
     
    566566 * @access  public
    567567 * @param   string  $signed_val A value with appended signature.
    568  * @param   string  $key        (Optional) A text key to use for computing the signature.
     568 * @param   string  $seed_key       (Optional) A text key to use for computing the signature.
    569569 * @return  bool    True if the signature matches the var.
    570570 */
    571 function verifySignature($signed_val, $key=null)
     571function verifySignature($signed_val, $seed_key=null)
    572572{
    573573    // Strip the value from the signed value.
    574     $val = substr($signed_val, 0, strrpos($signed_val, '-'));
     574    $val = removeSignature($signed_val);
    575575    // If the signed value matches the original signed value we consider the value safe.
    576     if ($signed_val == addSignature($val, $key)) {
     576    if ($signed_val == addSignature($val, $seed_key)) {
    577577        // Signature verified.
    578578        return true;
  • trunk/services/admins.php

    r21 r22  
    101101case 'insert' :
    102102    if (getFormdata('cancel', false)) {
     103        if (App::validBoomerangURL('admins')) {
     104            // Display boomerang page.
     105            App::dieBoomerangURL('admins');
     106        }
     107        // Display default page.
    103108        App::dieURL($_SERVER['PHP_SELF']);
    104109    }
     
    130135    if (getFormdata('cancel', false)) {
    131136        // Remove lock
    132         $lock =& RecordLock::getInstance($GLOBALS['auth']);
    133137        $lock->select('admin_tbl', 'admin_id', getFormData('admin_id'));
    134138        $lock->remove();
     
    252256function &editRecordForm($id)
    253257{
    254     $lock =& RecordLock::getInstance($GLOBALS['auth']);
     258    global $lock;
     259
    255260    $lock->select('admin_tbl', 'admin_id', $id);
    256261    if ($lock->isLocked() && !$lock->isMine()) {
     
    305310function deleteRecord($id)
    306311{
    307     global $auth;
    308    
    309     $lock =& RecordLock::getInstance($GLOBALS['auth']);
     312    global $auth, $lock;
     313   
    310314    $lock->select('admin_tbl', 'admin_id', $id);
    311315    if ($lock->isLocked() && !$lock->isMine()) {
     
    392396function updateRecord($frm)
    393397{
    394     global $auth;
    395    
    396     $lock =& RecordLock::getInstance($GLOBALS['auth']);
     398    global $auth, $lock;
     399   
    397400    $lock->select('admin_tbl', 'admin_id', $frm['admin_id']);
    398401    if ($lock->isLocked() && !$lock->isMine()) {
  • trunk/services/lock.php

    r21 r22  
    1111App::sslOn();
    1212
    13 if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) {
     13if (getFormData('boomerang', false)) {
    1414    // We remember which page we came from so we can go back there.
    1515    $boom_url = strpos(getFormData('boomerang'), '/') !== false ? getFormData('boomerang') : $_SERVER['HTTP_REFERER'];
    1616    App::setBoomerangURL($boom_url, 'lock');
     17    App::setBoomerangURL($_SERVER['HTTP_REFERER'], 'cancel-lock');
    1718}
    1819
    19 $lock =& RecordLock::getInstance($GLOBALS['auth']);
     20if (!isset($lock) || !is_a($lock, 'RecordLock')) {
     21    $lock =& RecordLock::getInstance($auth);
     22}
    2023$lock->select(getFormData('lock_id'));
    2124
     
    3134    App::dieBoomerangURL('lock');
    3235} else if (getFormData('cancel', false)) {
    33     App::dieBoomerangURL('lock');
     36    // Since the boomerang URL will go back to the locked record, and the record was not unlocked, we must delete the boomerang URL otherwise we'll come back here.
     37    App::deleteBoomerangURL('lock');
     38    App::dieBoomerangURL('cancel-lock');
    3439}
    3540
  • trunk/services/logout.php

    r21 r22  
    88
    99// Delete this admin's record locks.
    10 $lock =& RecordLock::getInstance($GLOBALS['auth']);
     10if (!isset($lock) || !is_a($lock, 'RecordLock')) {
     11    $lock =& RecordLock::getInstance($auth);
     12}
    1113$lock->removeAll($auth->getVal('user_id'));
    1214
  • trunk/services/logs.php

    r21 r22  
    88
    99$auth->requireLogin();
    10 $auth->requireAccessClearance(ZONE_ADMIN_APPLOG);
     10// $auth->requireAccessClearance(ZONE_ADMIN_APPLOG);
    1111App::sslOn();
    1212
     
    5555switch (getFormData('op')) {
    5656case 'delete' :
    57     $auth->requireAccessClearance(ZONE_ADMIN_APPLOG_FUNC_RESET);
     57//     $auth->requireAccessClearance(ZONE_ADMIN_APPLOG_FUNC_RESET);
    5858    deleteLog(Prefs::getValue('log_file', 'logs_module'));
    5959    Prefs::setValue('log_file', App::getParam('log_filename'), 'logs_module');
     
    6767   
    6868case 'clear' :
    69     $auth->requireAccessClearance(ZONE_ADMIN_APPLOG_FUNC_RESET);
     69//     $auth->requireAccessClearance(ZONE_ADMIN_APPLOG_FUNC_RESET);
    7070    clearLog(Prefs::getValue('log_file', 'logs_module'));
    7171    if (App::validBoomerangURL('app_log')) {
     
    7878   
    7979case 'archive' :
    80     $auth->requireAccessClearance(ZONE_ADMIN_APPLOG_FUNC_RESET);
     80//     $auth->requireAccessClearance(ZONE_ADMIN_APPLOG_FUNC_RESET);
    8181    if (archiveLog(Prefs::getValue('log_file', 'logs_module'))) {
    8282        // Now flush current log.
  • trunk/services/templates/admin_form.ihtml

    r21 r22  
    1010    <tr>
    1111        <td>&nbsp;</td>
    12         <td valign="top"><?php printSubmitButtons($frm['submit_buttons']); ?></td>
     12        <td><?php printSubmitButtons($frm['submit_buttons']); ?></td>
    1313    </tr>
    1414    <tr>
    1515        <td class="right"><label for="username"<?php $fv->err('username', ' class="error"') ?>><?php echo _("Username"); ?></label></td>
    16         <td valign="top">
     16        <td>
    1717            <input type="text" class="small" size="50" name="username" value="<?php echo oTxt($frm['username']); ?>" />
    1818        </td>
     
    2020    <tr>
    2121        <td class="right"><label for="userpass"<?php $fv->err('userpass', ' class="error"') ?>><?php echo _("Password"); ?></label></td>
    22         <td valign="top">
     22        <td>
    2323            <input type="password" class="small" size="50" name="userpass" value="<?php echo oTxt($frm['userpass']); ?>" />
    2424        </td>
     
    2626    <tr>
    2727        <td class="right"><label for="first_name"<?php $fv->err('first_name', ' class="error"') ?>><?php echo _("First name"); ?></label></td>
    28         <td valign="top">
     28        <td>
    2929            <input type="text" class="small" size="50" name="first_name" value="<?php echo oTxt($frm['first_name']); ?>" />
    3030        </td>
     
    3232    <tr>
    3333        <td class="right"><label for="last_name"<?php $fv->err('last_name', ' class="error"') ?>><?php echo _("Last name"); ?></label></td>
    34         <td valign="top">
     34        <td>
    3535            <input type="text" class="small" size="50" name="last_name" value="<?php echo oTxt($frm['last_name']); ?>" />
    3636        </td>
     
    3838    <tr>
    3939        <td class="right"><label for="email"<?php $fv->err('email', ' class="error"') ?>><?php echo _("Email"); ?></label></td>
    40         <td valign="top">
     40        <td>
    4141            <input type="text" class="medium" size="50" name="email" value="<?php echo oTxt($frm['email']); ?>" />
    4242        </td>
     
    4444    <tr>
    4545        <td class="right"><label for="user_type"<?php $fv->err('user_type', ' class="error"') ?>><?php echo _("User type"); ?></label></td>
    46         <td valign="top">
     46        <td>
    4747            <select name="user_type" class="small">
    4848            <?php printSetSelectForm('admin_tbl', 'user_type', $frm['user_type'], true); ?>
     
    5252    <tr>
    5353        <td>&nbsp;</td>
    54         <td valign="top"><?php printSubmitButtons($frm['submit_buttons']); ?></td>
     54        <td><?php printSubmitButtons($frm['submit_buttons']); ?></td>
    5555    </tr>
    5656</table>
  • trunk/services/templates/lock.ihtml

    r21 r22  
    11<?php
    2 if (!is_a($lock)) {
     2if (!is_a($lock, 'RecordLock')) {
    33    return null;
    44}
  • trunk/services/templates/login_form.ihtml

    r21 r22  
    44    <tr>
    55        <td class="right"><label for="username"><?php echo _("Username"); ?></label></td>
    6         <td valign="top">
    7             <input type="text" class="medium" size="20" name="username" value="<?php echo oTxt($frm['username']); ?>" />
     6        <td>
     7            <input type="text" class="small" size="20" name="username" value="<?php echo oTxt($frm['username']); ?>" />
    88        </td>
    99    </tr>
    1010    <tr>
    1111        <td class="right"><label for="password"><?php echo _("Password"); ?></label></td>
    12         <td valign="top">
    13             <input type="password" class="medium" size="20" name="password" value="<?php echo oTxt($frm['password']); ?>" />
     12        <td>
     13            <input type="password" class="small" size="20" name="password" value="<?php echo oTxt($frm['password']); ?>" />
    1414        </td>
    1515    </tr>
    1616    <tr>
    1717        <td>&nbsp;</td>
    18         <td valign="top"><input type="submit" value="<?php echo _("Login"); ?>" /></td>
     18        <td><input type="submit" value="<?php echo _("Login"); ?>" /></td>
    1919    </tr>
    2020</table>
  • trunk/services/templates/password.ihtml

    r21 r22  
    77    <tr>
    88        <td class="right"><label for="oldpassword"<?php $fv->err('oldpassword', ' class="error"') ?>><?php echo _("Old password"); ?></label></td>
    9         <td valign="top">
     9        <td>
    1010            <input type="text" class="medium" size="50" name="oldpassword" />
    1111        </td>
     
    1313    <tr>
    1414        <td class="right"><label for="newpassword"<?php $fv->err('newpassword', ' class="error"') ?>><?php echo _("New password"); ?></label></td>
    15         <td valign="top">
     15        <td>
    1616            <input type="password" class="medium" size="50" name="newpassword" />
    1717        </td>
     
    1919    <tr>
    2020        <td class="right"><label for="newpassword2"<?php $fv->err('newpassword2', ' class="error"') ?>><?php echo _("New password again"); ?></label></td>
    21         <td valign="top">
     21        <td>
    2222            <input type="password" class="medium" size="50" name="newpassword2" />
    2323        </td>
     
    2525    <tr>
    2626        <td>&nbsp;</td>
    27         <td valign="top"><input type="submit" value="<?php echo _("Change password"); ?>" /></td>
     27        <td><input type="submit" value="<?php echo _("Change password"); ?>" /></td>
    2828    </tr>
    2929</table>
  • trunk/services/versions.php

    r21 r22  
    7575
    7676case 'restore' :
    77     $lock =& RecordLock::getInstance($GLOBALS['auth']);
     77    if (!isset($lock) || !is_a($lock, 'RecordLock')) {
     78        $lock =& RecordLock::getInstance($auth);
     79    }
    7880    $lock->select($record_table, $record_key, $record_val);
    7981    if ($lock->isLocked() && !$lock->isMine()) {
Note: See TracChangeset for help on using the changeset viewer.