Changeset 127


Ignore:
Timestamp:
May 25, 2006 10:21:07 PM (18 years ago)
Author:
scdev
Message:

Updated App.inc.php thru Hierarchy.inc.php

Location:
branches/2.0singleton
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0singleton/bin/file_importer.php

    r111 r127  
    77
    88require realpath(dirname(__FILE__) . '/..') . '/config/cli_config.inc.php';
     9
     10$app =& App::getInstance();
    911
    1012// Test arguments.
     
    5658
    5759        } else {
    58             App::logMsg('Could not open file: ' . $file, LOG_INFO, __FILE__, __LINE__);
     60            $app->logMsg('Could not open file: ' . $file, LOG_INFO, __FILE__, __LINE__);
    5961        }
    6062    }
    61     App::logMsg('Proccessing complete: ' . $file_count . ' files total.', LOG_INFO, __FILE__, __LINE__);
     63    $app->logMsg('Proccessing complete: ' . $file_count . ' files total.', LOG_INFO, __FILE__, __LINE__);
    6264} else {
    63     App::logMsg('No files available in that directory.', LOG_INFO, __FILE__, __LINE__);
     65    $app->logMsg('No files available in that directory.', LOG_INFO, __FILE__, __LINE__);
    6466}
    6567
  • branches/2.0singleton/bin/module_maker/form_template.cli.php

    r121 r127  
    2424// Make sure requested table is in database.
    2525if (!in_array($db_tbl, $tables)) {
    26     die(sprintf("%s Warning: %s does not exist in database %s. Please select one of: \n\n%s\n\n", basename($_SERVER['argv'][0]), $db_tbl, App::getParam('db_name'), join("\n", $tables)));
     26    die(sprintf("%s Warning: %s does not exist in database %s. Please select one of: \n\n%s\n\n", basename($_SERVER['argv'][0]), $db_tbl, $app->getParam('db_name'), join("\n", $tables)));
    2727}
    2828
     
    6565<label for="$field"<\x3fphp \$fv->err('$field') \x3f>><\x3fphp echo _("$title"); \x3f></label>
    6666<select name="$field" id="$field" class="sc-small"><\x3fphp printSelectForm('<##>_tbl', "CONCAT(<##>_id, '&mdash;', <##>)", '$field', \$frm['$field'], true, 'ORDER BY $field ASC'); \x3f></select>
    67     <span class="commanditem commandtext"><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>
     67    <span class="commanditem commandtext"><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>
    6868    <\x3fphp if ('' != \$frm['<##>_id']) { \x3f>
    69     <span class="commanditem commandtext"><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>
     69    <span class="commanditem commandtext"><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>
    7070    <\x3fphp } \x3f>
    7171E_O_F;
  • branches/2.0singleton/bin/module_maker/list_template.cli.php

    r121 r127  
    3737// Make sure requested table is in database.
    3838if (!in_array($db_tbl, $tables)) {
    39     die(sprintf("%s Warning: %s does not exist in database %s. Please select one of: \n\n%s\n\n", basename($_SERVER['argv'][0]), $db_tbl, App::getParam('db_name'), join("\n", $tables)));
     39    die(sprintf("%s Warning: %s does not exist in database %s. Please select one of: \n\n%s\n\n", basename($_SERVER['argv'][0]), $db_tbl, $app->getParam('db_name'), join("\n", $tables)));
    4040}
    4141
     
    8080            $listrows[] = "<\x3fphp echo strlen(\$list[\$i]['$field'])<50 \x3f oTxt(\$list[\$i]['$field'], true) : oTxt(trim(substr(\$list[\$i]['$field'], 0, 50)) . '...'); \x3f>";
    8181        } else if (preg_match('/.*(begin|start).*date.*/i', $field)) {
    82             $listrows[] = "<\x3fphp echo '0000-00-00' == \$list[\$i]['$field'] ? '' : date(App::getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>";
     82            $listrows[] = "<\x3fphp echo '0000-00-00' == \$list[\$i]['$field'] ? '' : date(\$app->getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>";
    8383        } else if (preg_match('/.*(end|expire).*date.*/i', $field)) {
    84             $listrows[] = "<\x3fphp echo '9999-12-31' == \$list[\$i]['$field'] ? '' : date(App::getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>";
     84            $listrows[] = "<\x3fphp echo '9999-12-31' == \$list[\$i]['$field'] ? '' : date(\$app->getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>";
    8585        } else if (preg_match('/datetime/i', $type)) {
    86             $listrows[] = "<\x3fphp echo '0000-00-00 00:00:00' == \$list[\$i]['$field'] ? '' : date(App::getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>";
     86            $listrows[] = "<\x3fphp echo '0000-00-00 00:00:00' == \$list[\$i]['$field'] ? '' : date(\$app->getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>";
    8787        } else if (preg_match('/date/i', $type)) {
    88             $listrows[] = "<\x3fphp echo '0000-00-00' == \$list[\$i]['$field'] ? '' : date(App::getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>";
     88            $listrows[] = "<\x3fphp echo '0000-00-00' == \$list[\$i]['$field'] ? '' : date(\$app->getParam('date_format'), strtotime(\$list[\$i]['$field'])); \x3f>";
    8989        } else if (preg_match('/(amount|_rate)/i', $field)) {
    9090            $listrows[] = "<\x3fphp printf('$%01.2f', \$list[\$i]['$field']); \x3f>";
     
    110110<div id="commandbox">
    111111<form action="<\x3fphp echo \$_SERVER['PHP_SELF']; \x3f>" method="get">
    112 <\x3fphp App::printHiddenSession(false); \x3f>
    113     <span class="sc-nowrap commandtext"><a href="<\x3fphp echo App::oHREF(\$_SERVER['PHP_SELF'] . '?op=add'); \x3f>"><\x3fphp echo _("Add <##>"); \x3f></a></span>
     112<\x3fphp \$app->printHiddenSession(false); \x3f>
     113    <span class="sc-nowrap commandtext"><a href="<\x3fphp echo \$app->oHREF(\$_SERVER['PHP_SELF'] . '?op=add'); \x3f>"><\x3fphp echo _("Add <##>"); \x3f></a></span>
    114114    <br />
    115115
     
    149149    <\x3fphp for (\$i = 0; \$i <= \$page->last_item - \$page->first_item && \$page->total_items > 0; \$i++) { \x3f>
    150150    <tr>
    151         <td class="sc-nowrap"><a title="<\x3fphp printf(_("Edit %s"), oTxt(\$list[\$i]['<##>'])) \x3f>" href="<\x3fphp echo App::oHREF(\$_SERVER['PHP_SELF'] . '?op=edit&$primary_key=' . \$list[\$i]['$primary_key']); \x3f>"><img src="/admin/_widgets/edit.gif" alt="Edit" width="14" height="18" border="0"></a> &nbsp;</td>
    152         <td class="sc-nowrap"><a title="<\x3fphp printf(_("Versions of %s"), oTxt(\$list[\$i]['<##>'])) \x3f>" href="<\x3fphp echo App::oHREF("/admin/versions.php?record_table=$db_tbl&record_key=$primary_key&boomerang=true&record_val=" . \$list[\$i]['$primary_key']); \x3f>"><img src="/admin/_widgets/subcategory.gif" alt="" width="18" height="14" border="0" /></a> &nbsp;</td>
     151        <td class="sc-nowrap"><a title="<\x3fphp printf(_("Edit %s"), oTxt(\$list[\$i]['<##>'])) \x3f>" href="<\x3fphp echo \$app->oHREF(\$_SERVER['PHP_SELF'] . '?op=edit&$primary_key=' . \$list[\$i]['$primary_key']); \x3f>"><img src="/admin/_widgets/edit.gif" alt="Edit" width="14" height="18" border="0"></a> &nbsp;</td>
     152        <td class="sc-nowrap"><a title="<\x3fphp printf(_("Versions of %s"), oTxt(\$list[\$i]['<##>'])) \x3f>" href="<\x3fphp echo \$app->oHREF("/admin/versions.php?record_table=$db_tbl&record_key=$primary_key&boomerang=true&record_val=" . \$list[\$i]['$primary_key']); \x3f>"><img src="/admin/_widgets/subcategory.gif" alt="" width="18" height="14" border="0" /></a> &nbsp;</td>
    153153
    154154E_O_F;
     
    164164
    165165echo isset($op) ? '' : <<<E_O_F
    166         <td class="sc-nowrap" align="right"><a title="<\x3fphp printf(_("Delete %s"), oTxt(\$list[\$i]['<##>'])) \x3f>" href="<\x3fphp echo App::oHREF(\$_SERVER['PHP_SELF'] . "?op=del&$primary_key=" . \$list[\$i]['$primary_key']); \x3f>" onClick="javascript:return confirm('<\x3fphp printf(_("Are you sure you want to delete the record %s? This action is permanent and cannot be undone."), oTxt(\$list[\$i]['<##>'])) \x3f>')"><img src="/admin/_widgets/delete.gif" alt="Delete" width="16" height="17" border="0"></a> &nbsp;</td>
     166        <td class="sc-nowrap" align="right"><a title="<\x3fphp printf(_("Delete %s"), oTxt(\$list[\$i]['<##>'])) \x3f>" href="<\x3fphp echo \$app->oHREF(\$_SERVER['PHP_SELF'] . "?op=del&$primary_key=" . \$list[\$i]['$primary_key']); \x3f>" onClick="javascript:return confirm('<\x3fphp printf(_("Are you sure you want to delete the record %s? This action is permanent and cannot be undone."), oTxt(\$list[\$i]['<##>'])) \x3f>')"><img src="/admin/_widgets/delete.gif" alt="Delete" width="16" height="17" border="0"></a> &nbsp;</td>
    167167    </tr>
    168168    <\x3fphp } \x3f>
  • branches/2.0singleton/bin/module_maker/module.cli.php

    r119 r127  
    136136// Make sure requested table is in database.
    137137if (!in_array($db_tbl, $tables)) {
    138     die(sprintf("%s Warning: %s does not exist in database %s. Please select one of: \n\n%s\n\n", basename($_SERVER['argv'][0]), $db_tbl, App::getParam('db_name'), join("\n", $tables)));
     138    die(sprintf("%s Warning: %s does not exist in database %s. Please select one of: \n\n%s\n\n", basename($_SERVER['argv'][0]), $db_tbl, $app->getParam('db_name'), join("\n", $tables)));
    139139}
    140140
     
    266266        // If file upload errors, redirect to edit operation for the inserted record.
    267267        if (\$upload->anyErrors() || false === \$new_file) {
    268             App::dieURL(\$_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . \$%PRIMARY_KEY%);
     268            \$app->dieURL(\$_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . \$%PRIMARY_KEY%);
    269269        }
    270270E_O_F;
     
    300300
    301301$search['date'] = '/%DATE%/';
    302 $replace['date'] = date(App::getParam('date_format'));
     302$replace['date'] = date($app->getParam('date_format'));
    303303
    304304$search['name_plural'] = '/%NAME_PLURAL%/';
  • branches/2.0singleton/bin/module_maker/skel/admin.php

    r111 r127  
    1111$auth->requireLogin();
    1212// $auth->requireAccessClearance(ZONE_ADMIN_%NAME_UPPER%);
    13 App::sslOn();
     13$app->sslOn();
    1414
    1515require_once 'codebase/lib/PageNumbers.inc.php';
     
    4141
    4242// Search limiters retain their values between page requests.
    43 App::carryQuery('search_query');
    44 App::carryQuery('filter_<##>');
     43$app->carryQuery('search_query');
     44$app->carryQuery('filter_<##>');
    4545%ADMIN_UPLOAD_CONFIG%
    4646/******************************************************************************
     
    5151// allows us to remember which page we came from so we can go back there.
    5252if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) {
    53     App::setBoomerangURL($_SERVER['HTTP_REFERER'], '%NAME_PLURAL%');
     53    $app->setBoomerangURL($_SERVER['HTTP_REFERER'], '%NAME_PLURAL%');
    5454}
    5555
     
    8181//     $auth->requireAccessClearance(ZONE_ADMIN_%NAME_UPPER%_FUNC_DELETE);
    8282    deleteRecord(getFormData('%PRIMARY_KEY%'));%ADMIN_UPLOAD_DEL%
    83     if (App::validBoomerangURL('%NAME_PLURAL%')) {
     83    if ($app->validBoomerangURL('%NAME_PLURAL%')) {
    8484        // Display boomerang page.
    85         App::dieBoomerangURL('%NAME_PLURAL%');
     85        $app->dieBoomerangURL('%NAME_PLURAL%');
    8686    }
    8787    // Display default page.
    88     App::dieURL($_SERVER['PHP_SELF']);
     88    $app->dieURL($_SERVER['PHP_SELF']);
    8989    break;
    9090
     
    9292//     $auth->requireAccessClearance(ZONE_ADMIN_%NAME_UPPER%_FUNC_ADD);
    9393    if (getFormdata('cancel', false)) {
    94         if (App::validBoomerangURL('%NAME_PLURAL%')) {
     94        if ($app->validBoomerangURL('%NAME_PLURAL%')) {
    9595            // Display boomerang page.
    96             App::dieBoomerangURL('%NAME_PLURAL%');
     96            $app->dieBoomerangURL('%NAME_PLURAL%');
    9797        }
    9898        // Display default page.
    99         App::dieURL($_SERVER['PHP_SELF']);
     99        $app->dieURL($_SERVER['PHP_SELF']);
    100100    }
    101101    validateInput();
     
    109109        if (getFormdata('repeat', false)) {
    110110            // Display function again.
    111             App::dieURL($_SERVER['PHP_SELF'] . '?op=add');
    112         } else if (App::validBoomerangURL('%NAME_PLURAL%')) {
     111            $app->dieURL($_SERVER['PHP_SELF'] . '?op=add');
     112        } else if ($app->validBoomerangURL('%NAME_PLURAL%')) {
    113113            // Display boomerang page.
    114             App::dieBoomerangURL('%NAME_PLURAL%');
     114            $app->dieBoomerangURL('%NAME_PLURAL%');
    115115        }
    116116        // Display default page.
    117         App::dieURL($_SERVER['PHP_SELF']);
     117        $app->dieURL($_SERVER['PHP_SELF']);
    118118    }
    119119    break;
     
    122122//     $auth->requireAccessClearance(ZONE_ADMIN_%NAME_UPPER%_FUNC_EDIT);
    123123    if (getFormdata('reset', false)) {
    124         App::raiseMsg(_("Saved values have been reloaded."), MSG_NOTICE, __FILE__, __LINE__);
    125         App::dieURL($_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . getFormData('%PRIMARY_KEY%'));
     124        $app->raiseMsg(_("Saved values have been reloaded."), MSG_NOTICE, __FILE__, __LINE__);
     125        $app->dieURL($_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . getFormData('%PRIMARY_KEY%'));
    126126    }
    127127    if (getFormdata('cancel', false)) {
     
    129129        $lock->select('%DB_TBL%', '%PRIMARY_KEY%', getFormData('%PRIMARY_KEY%'));
    130130        $lock->remove();
    131         if (App::validBoomerangURL('%NAME_PLURAL%')) {
     131        if ($app->validBoomerangURL('%NAME_PLURAL%')) {
    132132            // Display boomerang page.
    133             App::dieBoomerangURL('%NAME_PLURAL%');
     133            $app->dieBoomerangURL('%NAME_PLURAL%');
    134134        }
    135135        // Display default page.
    136         App::dieURL($_SERVER['PHP_SELF']);
     136        $app->dieURL($_SERVER['PHP_SELF']);
    137137    }
    138138    validateInput();
     
    148148            $qid = DB::query("SELECT %PRIMARY_KEY% FROM %DB_TBL% WHERE %PRIMARY_KEY% > '" . DB::escapeString(getFormData('%PRIMARY_KEY%')) . "' ORDER BY %PRIMARY_KEY% ASC LIMIT 1");
    149149            if (list($next_id) = mysql_fetch_row($qid)) {
    150                 App::dieURL($_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . $next_id);
     150                $app->dieURL($_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . $next_id);
    151151            } else {
    152                 App::raiseMsg(_("Cannot edit next, the end of the list was reached"), MSG_NOTICE, __FILE__, __LINE__);
     152                $app->raiseMsg(_("Cannot edit next, the end of the list was reached"), MSG_NOTICE, __FILE__, __LINE__);
    153153            }
    154         } else if (App::validBoomerangURL('%NAME_PLURAL%')) {
     154        } else if ($app->validBoomerangURL('%NAME_PLURAL%')) {
    155155            // Display boomerang page.
    156             App::dieBoomerangURL('%NAME_PLURAL%');
     156            $app->dieBoomerangURL('%NAME_PLURAL%');
    157157        }
    158158        // Display default page.
    159         App::dieURL($_SERVER['PHP_SELF']);
     159        $app->dieURL($_SERVER['PHP_SELF']);
    160160    }
    161161    break;
     
    164164//     $auth->requireAccessClearance(ZONE_ADMIN_PROGRAMS_FUNC_REORDER);
    165165    updateRank(getFormData('rank'));
    166     App::dieURL($_SERVER['PHP_SELF']);
     166    $app->dieURL($_SERVER['PHP_SELF']);
    167167    break;
    168168
     
    220220    ");
    221221    if (!$frm = mysql_fetch_assoc($qid)) {
    222         App::logMsg('Could not find record with %PRIMARY_KEY%: ' . $id, LOG_WARNING, __FILE__, __LINE__);
    223         App::raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__);
    224         App::dieBoomerangURL();
     222        $app->logMsg('Could not find record with %PRIMARY_KEY%: ' . $id, LOG_WARNING, __FILE__, __LINE__);
     223        $app->raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__);
     224        $app->dieBoomerangURL();
    225225    }
    226226
     
    262262    ");
    263263    if (! list($name) = mysql_fetch_row($qid)) {
    264         App::logMsg('Could not find record with %PRIMARY_KEY%: ' . $id, LOG_WARNING, __FILE__, __LINE__);
    265         App::raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__);
    266         App::dieBoomerangURL();
     264        $app->logMsg('Could not find record with %PRIMARY_KEY%: ' . $id, LOG_WARNING, __FILE__, __LINE__);
     265        $app->raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__);
     266        $app->dieBoomerangURL();
    267267    }
    268268
     
    270270    DB::query("DELETE FROM %DB_TBL% WHERE %PRIMARY_KEY% = '" . DB::escapeString($id) . "'");
    271271
    272     App::raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been deleted."), $name), MSG_SUCCESS, __FILE__, __LINE__);
     272    $app->raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been deleted."), $name), MSG_SUCCESS, __FILE__, __LINE__);
    273273
    274274    // Unlock record.
     
    290290    $version->create('%DB_TBL%', '%PRIMARY_KEY%', $last_insert_id, $frm['<##>']);
    291291
    292     App::raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been added."), $frm['<##>']), MSG_SUCCESS, __FILE__, __LINE__);
     292    $app->raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been added."), $frm['<##>']), MSG_SUCCESS, __FILE__, __LINE__);
    293293
    294294    return $last_insert_id;
     
    313313    $version->create('%DB_TBL%', '%PRIMARY_KEY%', $frm['%PRIMARY_KEY%'], $frm['<##>']);
    314314
    315     App::raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been updated."), $frm['<##>']), MSG_SUCCESS, __FILE__, __LINE__);
     315    $app->raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been updated."), $frm['<##>']), MSG_SUCCESS, __FILE__, __LINE__);
    316316
    317317    // Unlock record.
     
    399399{
    400400    if (!is_array($ranks)) {
    401         App::logMsg('Saving rank failed, data posted is not an array: ' . $ranks, LOG_ERR, __FILE__, __LINE__);
     401        $app->logMsg('Saving rank failed, data posted is not an array: ' . $ranks, LOG_ERR, __FILE__, __LINE__);
    402402        return false;
    403403    }
     
    423423    }
    424424
    425     App::raiseMsg(_("Records have been reordered with the new rank."), MSG_SUCCESS, __FILE__, __LINE__);
     425    $app->raiseMsg(_("Records have been reordered with the new rank."), MSG_SUCCESS, __FILE__, __LINE__);
    426426    if ($unspecified_counter > 0) {
    427         App::raiseMsg(sprintf(_("%s items with unspecified ranks were automatically assigned a rank of 10000."), $unspecified_counter), MSG_NOTICE, __FILE__, __LINE__);
     427        $app->raiseMsg(sprintf(_("%s items with unspecified ranks were automatically assigned a rank of 10000."), $unspecified_counter), MSG_NOTICE, __FILE__, __LINE__);
    428428    }
    429429}
  • branches/2.0singleton/bin/module_maker/skel/public.php

    r111 r127  
    4242    ");
    4343    if (!$item = mysql_fetch_assoc($qid)) {
    44         App::raiseMsg(_("Sorry that %ITEM_TITLE% could not be found"), MSG_WARNING, __FILE__, __LINE__);
    45         App::dieBoomerangURL();
     44        $app->raiseMsg(_("Sorry that %ITEM_TITLE% could not be found"), MSG_WARNING, __FILE__, __LINE__);
     45        $app->dieBoomerangURL();
    4646    }
    4747
  • branches/2.0singleton/bin/module_maker/sql.cli.php

    r111 r127  
    3737// Make sure requested table is in database.
    3838if (!in_array($db_tbl, $tables)) {
    39     die(sprintf("%s Warning: %s does not exist in database %s. Please select one of: \n\n%s\n\n", basename($_SERVER['argv'][0]), $db_tbl, App::getParam('db_name'), join("\n", $tables)));
     39    die(sprintf("%s Warning: %s does not exist in database %s. Please select one of: \n\n%s\n\n", basename($_SERVER['argv'][0]), $db_tbl, $app->getParam('db_name'), join("\n", $tables)));
    4040}
    4141
  • branches/2.0singleton/bin/module_maker/validation.cli.php

    r111 r127  
    2424// Make sure requested table is in database.
    2525if (!in_array($db_tbl, $tables)) {
    26     die(sprintf("%s Warning: %s does not exist in database %s. Please select one of: \n\n%s\n\n", basename($_SERVER['argv'][0]), $db_tbl, App::getParam('db_name'), join("\n", $tables)));
     26    die(sprintf("%s Warning: %s does not exist in database %s. Please select one of: \n\n%s\n\n", basename($_SERVER['argv'][0]), $db_tbl, $app->getParam('db_name'), join("\n", $tables)));
    2727}
    2828
  • branches/2.0singleton/docs/coding_standards.txt

    r121 r127  
    183183        ?>
    184184        <div align="right" class="sc-tiny">
    185         [&nbsp;<a href="<?php echo App::oHREF('contact.php') ?>">Contact us</a>&nbsp;]
     185        [&nbsp;<a href="<?php echo $app->oHREF('contact.php') ?>">Contact us</a>&nbsp;]
    186186        </div>
    187187        <?php
  • branches/2.0singleton/docs/example_config.inc.php

    r101 r127  
    7070// DB credentials for command line scripts stored in a file with read rights
    7171// given only to the user who will be executing the scripts: -rw-------
    72 // This file includes App:: method calls so must be included after App.
     72// This file includes $app-> method calls so must be included after App.
    7373require_once 'global/db_auth.inc.php';
    7474
  • branches/2.0singleton/docs/example_script_template.php

    r21 r127  
    1111
    1212$auth->requireLogin();
    13 App::sslOn();
     13$app->sslOn();
    1414
    1515require_once 'codebase/lib/FormValidator.inc.php';
  • branches/2.0singleton/lib/App.inc.php

    r123 r127  
    2525    var $app = '_app_';
    2626
    27     // If App::start has run successfully.
     27    // If $app->start has run successfully.
    2828    var $running = false;
    2929
     
    4848        'redirect_home_url' => '/',
    4949
    50         // SSL URL used when redirecting with App::sslOn().
     50        // SSL URL used when redirecting with $app->sslOn().
    5151        'ssl_domain' => null,
    5252        'ssl_enabled' => false,
     
    514514        if (!$_this->getParam('log_directory') || !$_this->getParam('log_filename') || !is_dir($_this->getParam('log_directory')) || !is_writable($_this->getParam('log_directory'))) {
    515515            $_this->setParam(array('log_file_priority' => false));
    516             // We must use trigger_error to report this problem rather than calling App::logMsg, which might lead to an infinite loop.
     516            // We must use trigger_error to report this problem rather than calling $app->logMsg, which might lead to an infinite loop.
    517517            trigger_error(sprintf('Codebase error: log directory (%s) not found or writable.', $_this->getParam('log_directory')), E_USER_NOTICE);
    518518        }
     
    610610    /**
    611611     * Sets which query arguments will be carried persistently between requests.
    612      * Values in the _carry_queries array will be copied to URLs (via App::url()) and
     612     * Values in the _carry_queries array will be copied to URLs (via $app->url()) and
    613613     * to hidden input values (via printHiddenSession()).
    614614     *
     
    738738
    739739    /**
    740      * Returns a HTML-friendly URL processed with App::url and & replaced with &amp;
     740     * Returns a HTML-friendly URL processed with $app->url and & replaced with &amp;
    741741     *
    742742     * @access  public
    743743     * @param   string  $url    Input URL to parse.
    744      * @return  string          URL with App::url() and htmlentities() applied.
     744     * @return  string          URL with $app->url() and htmlentities() applied.
    745745     * @author  Quinn Comendant <quinn@strangecode.com>
    746746     * @since   09 Dec 2005 17:58:45
     
    868868
    869869    /*
    870     * Redirects a user by calling App::dieURL(). It will use:
     870    * Redirects a user by calling $app->dieURL(). It will use:
    871871    * 1. the stored boomerang URL, it it exists
    872872    * 2. a specified $default_url, it it exists
     
    876876    * @access   public
    877877    * @param    string  $id             Identifier for this script.
    878     * @param    mixed   $carry_args     Additional arguments to carry in the URL automatically (see App::oHREF()).
     878    * @param    mixed   $carry_args     Additional arguments to carry in the URL automatically (see $app->oHREF()).
    879879    * @param    string  $default_url    A default URL if there is not a valid specified boomerang URL.
    880880    * @return   bool                    False if the session is not running. No return otherwise.
     
    923923
    924924    /**
    925      * Set the URL to return to when App::dieBoomerangURL() is called.
     925     * Set the URL to return to when $app->dieBoomerangURL() is called.
    926926     *
    927927     * @param string  $url  A fully validated URL.
     
    940940        }
    941941        // A redirection will never happen immediately after setting the boomerangURL.
    942         // Set the time so ensure this doesn't happen. See App::validBoomerangURL for more.
     942        // Set the time so ensure this doesn't happen. See $app->validBoomerangURL for more.
    943943
    944944        if ('' != $url && is_string($url)) {
  • branches/2.0singleton/lib/Auth_File.inc.php

    r103 r127  
    9595    function getParam($param)
    9696    {
     97        $app =& App::getInstance();
     98   
    9799        if (isset($this->_params[$param])) {
    98100            return $this->_params[$param];
    99101        } else {
    100             App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);
     102            $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);
    101103            return null;
    102104        }
     
    160162    function authenticate($username, $password)
    161163    {
     164        $app =& App::getInstance();
     165   
    162166        if ('' == trim($password)) {
    163             App::logMsg(_("No password provided for authentication."), LOG_INFO, __FILE__, __LINE__);
     167            $app->logMsg(_("No password provided for authentication."), LOG_INFO, __FILE__, __LINE__);
    164168            return false;
    165169        }
     
    169173
    170174        if (!isset($this->_users[$username])) {
    171             App::logMsg(_("User ID provided does not exist."), LOG_INFO, __FILE__, __LINE__);
     175            $app->logMsg(_("User ID provided does not exist."), LOG_INFO, __FILE__, __LINE__);
    172176            return false;
    173177        }
    174178
    175179        if ($this->_encrypt($password, $this->_users[$username]) != $this->_users[$username]) {
    176             App::logMsg(sprintf('Authentication failed for user %s', $username), LOG_INFO, __FILE__, __LINE__);
     180            $app->logMsg(sprintf('Authentication failed for user %s', $username), LOG_INFO, __FILE__, __LINE__);
    177181            return false;
    178182        }
     
    227231    function isLoggedIn()
    228232    {
     233        $app =& App::getInstance();
     234   
    229235        // Some users will access from networks with a changing IP number (i.e. behind a proxy server). These users must be allowed entry by adding their IP to the list of trusted_networks.
    230236        if ($trusted_net = ipInRange(getRemoteAddr(), $this->_params['trusted_networks'])) {
    231237            $user_in_trusted_network = true;
    232             App::logMsg(sprintf('User %s accessing from trusted network %s', $_SESSION[$this->_sess]['username'], $trusted_net), LOG_DEBUG, __FILE__, __LINE__);
     238            $app->logMsg(sprintf('User %s accessing from trusted network %s', $_SESSION[$this->_sess]['username'], $trusted_net), LOG_DEBUG, __FILE__, __LINE__);
    233239        } else if (preg_match('/proxy.aol.com$/i', getRemoteAddr(true))) {
    234240            $user_in_trusted_network = true;
    235             App::logMsg(sprintf('User %s accessing from trusted network proxy.aol.com', $_SESSION[$this->_sess]['username']), LOG_DEBUG, __FILE__, __LINE__);
     241            $app->logMsg(sprintf('User %s accessing from trusted network proxy.aol.com', $_SESSION[$this->_sess]['username']), LOG_DEBUG, __FILE__, __LINE__);
    236242        } else {
    237243            $user_in_trusted_network = false;
     
    252258            if (strtotime($_SESSION[$this->_sess]['last_access_datetime']) > time() - 43200) {
    253259                // Only raise message if last session is less than 12 hours old.
    254                 App::raiseMsg(_("Your session has closed. You need to log-in again."), MSG_NOTICE, __FILE__, __LINE__);
     260                $app->raiseMsg(_("Your session has closed. You need to log-in again."), MSG_NOTICE, __FILE__, __LINE__);
    255261            }
    256262
     
    269275                $expire_reasons[] = sprintf('remote_ip not matched (%s != %s)', $_SESSION[$this->_sess]['remote_ip'], getRemoteAddr());
    270276            }
    271             App::logMsg(sprintf('User %s session expired: %s', $_SESSION[$this->_sess]['username'], join(', ', $expire_reasons)), LOG_INFO, __FILE__, __LINE__);
     277            $app->logMsg(sprintf('User %s session expired: %s', $_SESSION[$this->_sess]['username'], join(', ', $expire_reasons)), LOG_INFO, __FILE__, __LINE__);
    272278        }
    273279
     
    287293    function requireLogin($message='', $type=MSG_NOTICE, $file=null, $line=null)
    288294    {
     295        $app =& App::getInstance();
     296   
    289297        if (!$this->isLoggedIn()) {
    290298            // Display message for requiring login. (RaiseMsg will ignore empty strings.)
    291             App::raiseMsg($message, $type, $file, $line);
     299            $app->raiseMsg($message, $type, $file, $line);
    292300
    293301            // Login scripts must have the same 'login' tag for boomerangURL verification/manipulation.
    294             App::setBoomerangURL(absoluteMe(), 'login');
    295             App::dieURL($this->_params['login_url']);
     302            $app->setBoomerangURL(absoluteMe(), 'login');
     303            $app->dieURL($this->_params['login_url']);
    296304        }
    297305    }
     
    308316    function _loadHTPasswdFile()
    309317    {
     318        $app =& App::getInstance();
     319   
    310320        static $users = null;
    311321       
    312322        if (!file_exists($this->_params['htpasswd_file'])) {
    313             App::logMsg(sprintf('htpasswd file missing or not specified: %s', $this->_params['htpasswd_file']), LOG_ERR, __FILE__, __LINE__);
     323            $app->logMsg(sprintf('htpasswd file missing or not specified: %s', $this->_params['htpasswd_file']), LOG_ERR, __FILE__, __LINE__);
    314324            return false;
    315325        }
     
    317327        if (!isset($users)) {
    318328            if (false === ($users = file($this->_params['htpasswd_file']))) {
    319                 App::logMsg(sprintf(_("Could not read htpasswd file: %s"), $this->_params['htpasswd_file']), LOG_ERR, __FILE__, __LINE__);
     329                $app->logMsg(sprintf(_("Could not read htpasswd file: %s"), $this->_params['htpasswd_file']), LOG_ERR, __FILE__, __LINE__);
    320330                return false;
    321331            }
  • branches/2.0singleton/lib/Auth_SQL.inc.php

    r121 r127  
    9292    function Auth_SQL($auth_name=null)
    9393    {
     94        $app =& App::getInstance();
     95   
    9496        if (isset($auth_name)) {
    9597            $this->_auth = $auth_name;
     
    101103
    102104        // Get create tables config from global context.
    103         if (!is_null(App::getParam('db_create_tables'))) {
    104             $this->setParam(array('create_table' => App::getParam('db_create_tables')));
     105        if (!is_null($app->getParam('db_create_tables'))) {
     106            $this->setParam(array('create_table' => $app->getParam('db_create_tables')));
    105107        }
    106108    }
     
    115117    function initDB($recreate_db=false)
    116118    {
     119        $app =& App::getInstance();
     120   
    117121        static $_db_tested = false;
    118122
     
    122126            if ($recreate_db) {
    123127                DB::query("DROP TABLE IF EXISTS " . $this->getParam('db_table'));
    124                 App::logMsg(sprintf('Dropping and recreating table %s.', $this->getParam('db_table')), LOG_DEBUG, __FILE__, __LINE__);
     128                $app->logMsg(sprintf('Dropping and recreating table %s.', $this->getParam('db_table')), LOG_DEBUG, __FILE__, __LINE__);
    125129            }
    126130
     
    173177                'modified_datetime',
    174178            ), false, false)) {
    175                 App::logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), LOG_ALERT, __FILE__, __LINE__);
     179                $app->logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), LOG_ALERT, __FILE__, __LINE__);
    176180                trigger_error(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), E_USER_ERROR);
    177181            }
     
    181185                if ($recreate_db) {
    182186                    DB::query("DROP TABLE IF EXISTS " . $this->getParam('db_login_table'));
    183                     App::logMsg(sprintf('Dropping and recreating table %s.', $this->getParam('db_login_table')), LOG_DEBUG, __FILE__, __LINE__);
     187                    $app->logMsg(sprintf('Dropping and recreating table %s.', $this->getParam('db_login_table')), LOG_DEBUG, __FILE__, __LINE__);
    184188                }
    185189                DB::query("CREATE TABLE IF NOT EXISTS " . $this->getParam('db_login_table') . " (
     
    197201                    'remote_ip_binary',
    198202                ), false, false)) {
    199                     App::logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_login_table')), LOG_ALERT, __FILE__, __LINE__);
     203                    $app->logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_login_table')), LOG_ALERT, __FILE__, __LINE__);
    200204                    trigger_error(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_login_table')), E_USER_ERROR);
    201205                }
     
    228232    function getParam($param)
    229233    {
     234        $app =& App::getInstance();
     235   
    230236        if (isset($this->_params[$param])) {
    231237            return $this->_params[$param];
    232238        } else {
    233             App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);
     239            $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);
    234240            return null;
    235241        }
     
    298304    function authenticate($username, $password)
    299305    {
     306        $app =& App::getInstance();
     307   
    300308        $this->initDB();
    301309
     
    311319        // Return user data if found.
    312320        if ($user_data = mysql_fetch_assoc($qid)) {
    313             App::logMsg(sprintf('Authentication successful for %s %s (%s)', $this->_auth, $user_data['user_id'], $username), LOG_INFO, __FILE__, __LINE__);
     321            $app->logMsg(sprintf('Authentication successful for %s %s (%s)', $this->_auth, $user_data['user_id'], $username), LOG_INFO, __FILE__, __LINE__);
    314322            return $user_data;
    315323        } else {
    316             App::logMsg(sprintf('Authentication failed for %s %s (encrypted attempted password: %s)', $this->_auth, $username, $this->encryptPassword($password)), LOG_NOTICE, __FILE__, __LINE__);
     324            $app->logMsg(sprintf('Authentication failed for %s %s (encrypted attempted password: %s)', $this->_auth, $username, $this->encryptPassword($password)), LOG_NOTICE, __FILE__, __LINE__);
    317325            return false;
    318326        }
     
    329337    function login($username, $password)
    330338    {
     339        $app =& App::getInstance();
     340   
    331341        $this->initDB();
    332342
     
    357367            if (!empty($user_data['blocked'])) {
    358368
    359                 App::logMsg(sprintf('%s %s (%s) login failed due to blocked account: %s', ucfirst($this->_auth), $this->getVal('user_id'), $this->getVal('username'), $this->getVal('blocked_reason')), LOG_NOTICE, __FILE__, __LINE__);
     369                $app->logMsg(sprintf('%s %s (%s) login failed due to blocked account: %s', ucfirst($this->_auth), $this->getVal('user_id'), $this->getVal('username'), $this->getVal('blocked_reason')), LOG_NOTICE, __FILE__, __LINE__);
    360370
    361371                switch ($user_data['blocked_reason']) {
    362372                    case 'account abuse' :
    363                         App::raiseMsg(sprintf(_("This account has been blocked due to possible account abuse. Please contact us to reactivate."), null), MSG_WARNING, __FILE__, __LINE__);
     373                        $app->raiseMsg(sprintf(_("This account has been blocked due to possible account abuse. Please contact us to reactivate."), null), MSG_WARNING, __FILE__, __LINE__);
    364374                        break;
    365375                    default :
    366                         App::raiseMsg(sprintf(_("This account is currently not active. %s"), $user_data['blocked_reason']), MSG_WARNING, __FILE__, __LINE__);
     376                        $app->raiseMsg(sprintf(_("This account is currently not active. %s"), $user_data['blocked_reason']), MSG_WARNING, __FILE__, __LINE__);
    367377                        break;
    368378                }
     
    391401                    // Warn the user with a password reset.
    392402                    $this->resetPassword(null, _("This is a security precaution. We have detected this account has been accessed from multiple computers simultaneously. It is against policy to share login information with others. If further account abuse is detected this account will be blocked."));
    393                     App::raiseMsg(_("Your password has been reset as a security precaution. Please check your email for more information."), MSG_NOTICE, __FILE__, __LINE__);
    394                     App::logMsg(sprintf('Account abuse detected for %s %s (%s) from IP %s', $this->_auth, $this->getVal('user_id'), $this->getVal('username'), $this->getVal('remote_ip')), LOG_WARNING, __FILE__, __LINE__);
     403                    $app->raiseMsg(_("Your password has been reset as a security precaution. Please check your email for more information."), MSG_NOTICE, __FILE__, __LINE__);
     404                    $app->logMsg(sprintf('Account abuse detected for %s %s (%s) from IP %s', $this->_auth, $this->getVal('user_id'), $this->getVal('username'), $this->getVal('remote_ip')), LOG_WARNING, __FILE__, __LINE__);
    395405                } else {
    396406                    // Block the account with the reason of account abuse.
    397407                    $this->blockAccount(null, 'account abuse');
    398                     App::raiseMsg(_("Your account has been blocked as a security precaution. Please contact us for more information."), MSG_NOTICE, __FILE__, __LINE__);
    399                     App::logMsg(sprintf('Account blocked for %s %s (%s) from IP %s', $this->_auth, $this->getVal('user_id'), $this->getVal('username'), $this->getVal('remote_ip')), LOG_ALERT, __FILE__, __LINE__);
     408                    $app->raiseMsg(_("Your account has been blocked as a security precaution. Please contact us for more information."), MSG_NOTICE, __FILE__, __LINE__);
     409                    $app->logMsg(sprintf('Account blocked for %s %s (%s) from IP %s', $this->_auth, $this->getVal('user_id'), $this->getVal('username'), $this->getVal('remote_ip')), LOG_ALERT, __FILE__, __LINE__);
    400410                }
    401411                // Increment user's warning level.
     
    447457    function isLoggedIn($user_id=null)
    448458    {
     459        $app =& App::getInstance();
     460   
    449461        $this->initDB();
    450462
     
    471483        if ($trusted_net = ipInRange(getRemoteAddr(), $this->_params['trusted_networks'])) {
    472484            $user_in_trusted_network = true;
    473             App::logMsg(sprintf('%s%s accessing from trusted network %s',
     485            $app->logMsg(sprintf('%s%s accessing from trusted network %s',
    474486                ucfirst($this->_auth),
    475487                ($this->getVal('user_id') ? ' ' . $this->getVal('user_id') . ' (' .  $this->getVal('username') . ')' : ''),
     
    478490        } else if (preg_match('/proxy.aol.com$/i', getRemoteAddr(true))) {
    479491            $user_in_trusted_network = true;
    480             App::logMsg(sprintf('%s%s accessing from trusted network proxy.aol.com',
     492            $app->logMsg(sprintf('%s%s accessing from trusted network proxy.aol.com',
    481493                ucfirst($this->_auth),
    482494                ($this->getVal('user_id') ? ' ' . $this->getVal('user_id') . ' (' .  $this->getVal('username') . ')' : '')
     
    508520                return true;
    509521            } else {
    510                 App::logMsg(sprintf('User update failed. Record not found for %s %s (%s).', $this->_auth, $this->getVal('user_id'), $this->getVal('username')), LOG_NOTICE, __FILE__, __LINE__);
     522                $app->logMsg(sprintf('User update failed. Record not found for %s %s (%s).', $this->_auth, $this->getVal('user_id'), $this->getVal('username')), LOG_NOTICE, __FILE__, __LINE__);
    511523            }
    512524        } else if (isset($_SESSION[$this->_sess]) && true === $_SESSION[$this->_sess]['authenticated']) {
     
    514526            if (strtotime($_SESSION[$this->_sess]['last_access_datetime']) > time() - 43200) {
    515527                // Only raise message if last session is less than 12 hours old.
    516                 App::raiseMsg(sprintf(_("Your %s session has closed. You need to log-in again."), strtolower($this->_auth)), MSG_NOTICE, __FILE__, __LINE__);
     528                $app->raiseMsg(sprintf(_("Your %s session has closed. You need to log-in again."), strtolower($this->_auth)), MSG_NOTICE, __FILE__, __LINE__);
    517529            }
    518530
     
    531543                $expire_reasons[] = sprintf('remote_ip not matched (%s != %s)', $_SESSION[$this->_sess]['remote_ip'], getRemoteAddr());
    532544            }
    533             App::logMsg(sprintf('%s %s (%s) session expired: %s', ucfirst($this->_auth), $this->getVal('user_id'), $this->getVal('username'), join(', ', $expire_reasons)), LOG_INFO, __FILE__, __LINE__);
     545            $app->logMsg(sprintf('%s %s (%s) session expired: %s', ucfirst($this->_auth), $this->getVal('user_id'), $this->getVal('username'), join(', ', $expire_reasons)), LOG_INFO, __FILE__, __LINE__);
    534546        }
    535547
     
    551563    function requireLogin($message='', $type=MSG_NOTICE, $file=null, $line=null)
    552564    {
     565        $app =& App::getInstance();
     566   
    553567        if (!$this->isLoggedIn()) {
    554568            // Display message for requiring login. (RaiseMsg will ignore empty strings.)
    555             App::raiseMsg($message, $type, $file, $line);
     569            $app->raiseMsg($message, $type, $file, $line);
    556570
    557571            // Login scripts must have the same 'login' tag for boomerangURL verification/manipulation.
    558             App::setBoomerangURL(absoluteMe(), 'login');
    559             App::dieURL($this->_params['login_url']);
     572            $app->setBoomerangURL(absoluteMe(), 'login');
     573            $app->dieURL($this->_params['login_url']);
    560574        }
    561575    }
     
    569583    function blockAccount($user_id=null, $reason='')
    570584    {
     585        $app =& App::getInstance();
     586   
    571587        $this->initDB();
    572588
     
    574590            if (strlen(DB::escapeString($reason)) > 255) {
    575591                // blocked_reason field is varchar(255).
    576                 App::logMsg(sprintf('Blocked reason provided is greater than 255 characters: %s', $reason), LOG_WARNING, __FILE__, __LINE__);
     592                $app->logMsg(sprintf('Blocked reason provided is greater than 255 characters: %s', $reason), LOG_WARNING, __FILE__, __LINE__);
    577593            }
    578594
     
    709725    function setPassword($user_id=null, $password)
    710726    {
     727        $app =& App::getInstance();
     728   
    711729        $this->initDB();
    712730
     
    722740       
    723741        if (mysql_affected_rows(DB::getDBH()) != 1) {
    724             App::logMsg(sprintf('setPassword failed to update password for user %s', $user_id), LOG_NOTICE, __FILE__, __LINE__);
     742            $app->logMsg(sprintf('setPassword failed to update password for user %s', $user_id), LOG_NOTICE, __FILE__, __LINE__);
    725743        }
    726744    }
     
    735753    function resetPassword($user_id=null, $reason='')
    736754    {
     755        $app =& App::getInstance();
     756   
    737757        $this->initDB();
    738758
     
    746766        ");
    747767        if (!$user_data = mysql_fetch_assoc($qid)) {
    748             App::logMsg(sprintf('Reset password failed. %s %s not found.', ucfirst($this->_auth), $user_id), LOG_NOTICE, __FILE__, __LINE__);
     768            $app->logMsg(sprintf('Reset password failed. %s %s not found.', ucfirst($this->_auth), $user_id), LOG_NOTICE, __FILE__, __LINE__);
    749769            return false;
    750770        }
     
    758778        // Make sure user has an email on record before continuing.
    759779        if (!isset($user_data['email']) || '' == trim($user_data['email'])) {
    760             App::logMsg(sprintf('Password reset but notification failed, no email address for %s %s (%s).', $this->_auth, $user_data[$this->_params['db_primary_key']], $user_data[$this->_params['db_username_column']]), LOG_NOTICE, __FILE__, __LINE__);
     780            $app->logMsg(sprintf('Password reset but notification failed, no email address for %s %s (%s).', $this->_auth, $user_data[$this->_params['db_primary_key']], $user_data[$this->_params['db_username_column']]), LOG_NOTICE, __FILE__, __LINE__);
    761781        } else {
    762782            // Body for email.
     
    779799            $email = new Email(array(
    780800                'to' => $user_data['email'],
    781                 'from' => sprintf('%s <%s>', App::getParam('site_name'), App::getParam('site_email')),
    782                 'subject' => sprintf('%s password change', App::getParam('site_name'))
     801                'from' => sprintf('%s <%s>', $app->getParam('site_name'), $app->getParam('site_email')),
     802                'subject' => sprintf('%s password change', $app->getParam('site_name'))
    783803            ));
    784804            $email->setString($email_body);
    785805            $email->replace(array(
    786                 'site_name' => App::getParam('site_name'),
    787                 'site_url' => App::getParam('site_url'),
     806                'site_name' => $app->getParam('site_name'),
     807                'site_url' => $app->getParam('site_url'),
    788808                'name' => ('' != $user_data['first_name'] . $user_data['last_name'] ? $user_data['first_name'] . ' ' . $user_data['last_name'] : $user_data[$this->_params['db_username_column']]),
    789809                'username' => $user_data[$this->_params['db_username_column']],
     
    831851    function requireAccessClearance($security_zone, $message='')
    832852    {
     853        $app =& App::getInstance();
     854   
    833855        return true;
    834856        $zone_members = preg_split('/,\s*/', $security_zone);
     
    838860        if (!in_array($this->getVal('priv'), $zone_members) || !$this->getVal('priv')) {
    839861            $message = empty($message) ? _("You have insufficient privileges to view that page.") : $message;
    840             App::raiseMsg($message, MSG_NOTICE, __FILE__, __LINE__);
    841             App::dieBoomerangURL();
     862            $app->raiseMsg($message, MSG_NOTICE, __FILE__, __LINE__);
     863            $app->dieBoomerangURL();
    842864        }
    843865    }
  • branches/2.0singleton/lib/AuthorizeNet.inc.php

    r42 r127  
    132132    function setParam($params)
    133133    {
     134        $app =& App::getInstance();
     135   
    134136        if (isset($params) && is_array($params)) {
    135137            // Merge new parameters with old overriding only those passed.
    136138            $this->_params = array_merge($this->_params, $params);
    137139        } else {
    138             App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
     140            $app->logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
    139141        }
    140142    }
     
    149151    function getParam($param)
    150152    {
     153        $app =& App::getInstance();
     154   
    151155        if (isset($this->_params[$param])) {
    152156            return $this->_params[$param];
    153157        } else {
    154             App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);
     158            $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);
    155159            return null;
    156160        }
     
    167171    function process()
    168172    {
     173        $app =& App::getInstance();
     174   
    169175        if (empty($this->_params['x_login'])) {
    170176            $this->_results['x_response_reason_text'] = _("Transaction gateway temporarily not available. Please try again later.");
    171             App::logMsg(sprintf('x_login not specified.', null), LOG_ERROR, __FILE__, __LINE__);
     177            $app->logMsg(sprintf('x_login not specified.', null), LOG_ERROR, __FILE__, __LINE__);
    172178            return false;
    173179        }
    174180        if (empty($this->_params['x_card_num'])) {
    175181            $this->_results['x_response_reason_text'] = _("Transaction gateway temporarily not available. Please try again later.");
    176             App::logMsg(sprintf('x_card_num not specified.', null), LOG_ERROR, __FILE__, __LINE__);
     182            $app->logMsg(sprintf('x_card_num not specified.', null), LOG_ERROR, __FILE__, __LINE__);
    177183            return false;
    178184        }
  • branches/2.0singleton/lib/CSS.inc.php

    r92 r127  
    2828    function setParam($params)
    2929    {
     30        $app =& App::getInstance();
     31   
    3032        if (isset($params) && is_array($params)) {
    3133            // Merge new parameters with old overriding only those passed.
    3234            $this->_params = array_merge($this->_params, $params);
    3335        } else {
    34             App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
     36            $app->logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
    3537        }
    3638    }
     
    4547    function getParam($param)
    4648    {
     49        $app =& App::getInstance();
     50   
    4751        if (isset($this->_params[$param])) {
    4852            return $this->_params[$param];
    4953        } else {
    50             App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);
     54            $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);
    5155            return null;
    5256        }
     
    5862     * @access  public
    5963     * @param   string  $file   Include path to css files.
    60      * @param   mixed   $apps   App name string or array of app names.
     64     * @param   mixed   $realms   Realm name string or array of realm names.
    6165     * @return  bool    True on success, false on failure.
    6266     */
    63     function setFile($file, $apps='')
     67    function setFile($file, $realms='')
    6468    {
    65         if (!is_array($apps)) {
    66             $apps = array($apps);
     69        $app =& App::getInstance();
     70   
     71        if (!is_array($realms)) {
     72            $realms = array($realms);
    6773        }
    6874
    6975        if ($fp = fopen($file, 'r', true)) {
    70             foreach ($apps as $app) {
    71                 $app = '' == $app ? 'default' : $app;
    72                 $this->_css_files[$app][] = $file;
     76            foreach ($realms as $realm) {
     77                $realm = '' == $realm ? 'default' : $realm;
     78                $this->_css_files[$realm][] = $file;
    7379            }
    7480            fclose($fp);
    7581            return true;
    7682        } else {
    77             App::logMsg(sprintf('CSS file non-existent: %s', $file), LOG_ERR, __FILE__, __LINE__);
     83            $app->logMsg(sprintf('CSS file non-existent: %s', $file), LOG_ERR, __FILE__, __LINE__);
    7884            return false;
    7985        }
     
    8793     * @return  bool    False if no files have been set.
    8894     */
    89     function headers($app='')
     95    function headers($realm='')
    9096    {
    91         $app = '' == $app ? 'default' : $app;
     97        $app =& App::getInstance();
     98   
     99        $realm = '' == $realm ? 'default' : $realm;
    92100
    93         if (empty($this->_css_files[$app])) {
    94             App::logMsg(sprintf('CSS::headers called without specifying any files.', null), LOG_WARNING, __FILE__, __LINE__);
     101        if (empty($this->_css_files[$realm])) {
     102            $app->logMsg(sprintf('CSS::headers called without specifying any files.', null), LOG_WARNING, __FILE__, __LINE__);
    95103            return false;
    96104        }
     
    98106        // Get time of latest modified file, including this class file.
    99107        $files_mtime = array();
    100         foreach (array_merge($this->_css_files[$app], array(__FILE__)) as $file) {
     108        foreach (array_merge($this->_css_files[$realm], array(__FILE__)) as $file) {
    101109            $files_mtime[] = statIncludePath($file, 'mtime');
    102110        }
     
    122130     * @return  bool    False if no files have been set.
    123131     */
    124     function output($app='')
     132    function output($realm='')
    125133    {
    126         $app = '' == $app ? 'default' : $app;
     134        $realm = '' == $realm ? 'default' : $realm;
    127135
    128         if (empty($this->_css_files[$app])) {
    129             App::logMsg(sprintf('CSS::output called without specifying any files.', null), LOG_WARNING, __FILE__, __LINE__);
     136        if (empty($this->_css_files[$realm])) {
     137            $app->logMsg(sprintf('CSS::output called without specifying any files.', null), LOG_WARNING, __FILE__, __LINE__);
    130138            return false;
    131139        }
    132140
    133         foreach ($this->_css_files[$app] as $file) {
     141        foreach ($this->_css_files[$realm] as $file) {
    134142            include $file;
    135143        }
  • branches/2.0singleton/lib/Captcha.inc.php

    r121 r127  
    118118    function Captcha()
    119119    {
    120         $this->secret_key = App::getParam('signing_key');
     120        $app =& App::getInstance();
     121   
     122        $this->secret_key = $app->getParam('signing_key');
    121123        $this->random_number = $this->_getRandomNumber();
    122124    }
     
    133135    function getAsciiNumber($num=null)
    134136    {
     137        $app =& App::getInstance();
     138   
    135139        if (!isset($num)) {
    136140            $num = $this->random_number;
     
    138142
    139143        if (preg_match('/[^\d]/', $num)) {
    140             App::logMsg(sprintf('Bad number: %s', $num), LOG_ERR, __FILE__, __LINE__);
     144            $app->logMsg(sprintf('Bad number: %s', $num), LOG_ERR, __FILE__, __LINE__);
    141145            return false;
    142146        }
  • branches/2.0singleton/lib/DB.inc.php

    r119 r127  
    8585    function setParam($params)
    8686    {
     87        $app =& App::getInstance();
     88   
    8789        if (!isset($_this) || !is_a($_this, 'DB') && !is_subclass_of($_this, 'DB')) {
    8890            $_this =& DB::getInstance();
     
    9395            $_this->_params = array_merge($_this->_params, $params);
    9496        } else {
    95             App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
     97            $app->logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
    9698        }
    9799    }
     
    108110    function getParam($param)
    109111    {
     112        $app =& App::getInstance();
     113   
    110114        if (!isset($_this) || !is_a($_this, 'DB') && !is_subclass_of($_this, 'DB')) {
    111115            $_this =& DB::getInstance();
     
    115119            return $_this->_params[$param];
    116120        } else {
    117             App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);
     121            $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);
    118122            return null;
    119123        }
     
    129133    function connect()
    130134    {
     135        $app =& App::getInstance();
     136   
    131137        if (!isset($_this) || !is_a($_this, 'DB') && !is_subclass_of($_this, 'DB')) {
    132138            $_this =& DB::getInstance();
     
    134140
    135141        if (!$_this->getParam('db_name') || !$_this->getParam('db_user') || !$_this->getParam('db_pass')) {
    136             App::logMsg('Database credentials missing.', LOG_EMERG, __FILE__, __LINE__);
     142            $app->logMsg('Database credentials missing.', LOG_EMERG, __FILE__, __LINE__);
    137143            return false;
    138144        }
     
    147153        if (!$_this->dbh || mysql_error($_this->dbh)) {
    148154            $mysql_error_msg = $_this->dbh ? 'Codebase MySQL error: (' . mysql_errno($_this->dbh) . ') ' . mysql_error($_this->dbh) : 'Codebase MySQL error: Could not connect to server.';
    149             App::logMsg($mysql_error_msg, LOG_EMERG, __FILE__, __LINE__);
     155            $app->logMsg($mysql_error_msg, LOG_EMERG, __FILE__, __LINE__);
    150156
    151157            // Print helpful or pretty error?
     
    169175
    170176        // Tell MySQL what character set we're useing. Available only on MySQL verions > 4.01.01.
    171         $_this->query("/*!40101 SET NAMES '" . $_this->mysql_character_sets[strtolower(App::getParam('character_set'))] . "' */");
     177        $_this->query("/*!40101 SET NAMES '" . $_this->mysql_character_sets[strtolower($app->getParam('character_set'))] . "' */");
    172178
    173179        return true;
     
    254260    function query($query, $debug=false)
    255261    {
     262        $app =& App::getInstance();
     263   
    256264        static $_query_count = 0;
    257265
     
    280288                echo _("This page is temporarily unavailable. It should be back up in a few minutes.");
    281289            }
    282             App::logMsg(sprintf('MySQL error %s: %s in query: %s', mysql_errno($_this->dbh), mysql_error($_this->dbh), $debugqry), LOG_EMERG, __FILE__, __LINE__);
     290            $app->logMsg(sprintf('MySQL error %s: %s in query: %s', mysql_errno($_this->dbh), mysql_error($_this->dbh), $debugqry), LOG_EMERG, __FILE__, __LINE__);
    283291            if ($_this->getParam('db_die_on_failure')) {
    284292                echo "\n\n<!-- Script execution stopped out of embarrassment. -->";
     
    302310    function tableExists($table, $use_cached_results=true)
    303311    {
     312        $app =& App::getInstance();
     313   
    304314        if (!isset($_this) || !is_a($_this, 'DB') && !is_subclass_of($_this, 'DB')) {
    305315            $_this =& DB::getInstance();
     
    320330            return true;
    321331        } else {
    322             App::logMsg(sprintf('nonexistent DB table: %s.%s', $_this->getParam('db_name'), $table), LOG_ALERT, __FILE__, __LINE__);
     332            $app->logMsg(sprintf('nonexistent DB table: %s.%s', $_this->getParam('db_name'), $table), LOG_ALERT, __FILE__, __LINE__);
    323333            return false;
    324334        }
  • branches/2.0singleton/lib/DBSessionHandler.inc.php

    r110 r127  
    3232    function DBSessionHandler($db=null, $params=array())
    3333    {
     34        $app =& App::getInstance();
     35   
    3436        $this->_params = array_merge($this->_params, $params);
    3537
     
    4042                    $this->db =& $db;
    4143                } else {
    42                     App::logMsg(sprintf('Provided DB object is not connected. %s', mysql_error($db->dbh)), LOG_ERR, __FILE__, __LINE__);
     44                    $app->logMsg(sprintf('Provided DB object is not connected. %s', mysql_error($db->dbh)), LOG_ERR, __FILE__, __LINE__);
    4345                }
    4446            } else {
    45                 App::logMsg(sprintf('Provided DB object is not valid. %s', gettype($db)), LOG_ERR, __FILE__, __LINE__);
     47                $app->logMsg(sprintf('Provided DB object is not valid. %s', gettype($db)), LOG_ERR, __FILE__, __LINE__);
    4648            }
    4749        } else {
     
    6971
    7072        // Get create tables config from global context.
    71         if (!is_null(App::getParam('db_create_tables'))) {
    72             $this->_params['create_table'] = App::getParam('db_create_tables');
     73        if (!is_null($app->getParam('db_create_tables'))) {
     74            $this->_params['create_table'] = $app->getParam('db_create_tables');
    7375        }
    7476
     
    9698    function initDB($recreate_db=false)
    9799    {
     100        $app =& App::getInstance();
     101   
    98102        static $_db_tested = false;
    99103
     
    101105            if ($recreate_db) {
    102106                $this->db->query("DROP TABLE IF EXISTS " . $this->_params['db_table']);
    103                 App::logMsg(sprintf('Dropping and recreating table %s.', $this->_params['db_table']), LOG_DEBUG, __FILE__, __LINE__);
     107                $app->logMsg(sprintf('Dropping and recreating table %s.', $this->_params['db_table']), LOG_DEBUG, __FILE__, __LINE__);
    104108            }
    105109            $this->db->query("CREATE TABLE IF NOT EXISTS " . $this->_params['db_table'] . " (
     
    112116
    113117            if (!$this->db->columnExists($this->_params['db_table'], array('session_id', 'session_data', 'last_access'))) {
    114                 App::logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->_params['db_table']), LOG_ALERT, __FILE__, __LINE__);
     118                $app->logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->_params['db_table']), LOG_ALERT, __FILE__, __LINE__);
    115119                trigger_error(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->_params['db_table']), E_USER_ERROR);
    116120            }
  • branches/2.0singleton/lib/Email.inc.php

    r119 r127  
    1212$email = new Email(array(
    1313    'to' => array($frm['email'], 'q@lovemachine.local'),
    14     'from' => sprintf('%s <%s>', App::getParam('site_name'), App::getParam('site_email')),
     14    'from' => sprintf('%s <%s>', $app->getParam('site_name'), $app->getParam('site_email')),
    1515    'subject' => 'Your account has been activated',
    1616));
     
    1818// $email->setString('Or you can pass your message body as a string, also with {VARIABLES}.');
    1919$email->replace(array(
    20     'site_name' => App::getParam('site_name'),
    21     'site_url' => App::getParam('site_url'),
     20    'site_name' => $app->getParam('site_name'),
     21    'site_url' => $app->getParam('site_url'),
    2222    'username' => $frm['username'],
    2323    'password' => $frm['password1'],
    2424));
    2525if ($email->send()) {
    26     App::raiseMsg(sprintf(_("A confirmation email has been sent to %s."), $frm['email']), MSG_SUCCESS, __FILE__, __LINE__);
     26    $app->raiseMsg(sprintf(_("A confirmation email has been sent to %s."), $frm['email']), MSG_SUCCESS, __FILE__, __LINE__);
    2727} else {
    28     App::logMsg(sprintf('Error sending confirmation email to address %s', $frm['email']), LOG_NOTICE, __FILE__, __LINE__);
     28    $app->logMsg(sprintf('Error sending confirmation email to address %s', $frm['email']), LOG_NOTICE, __FILE__, __LINE__);
    2929}
    3030-------------------------------------------------------------------------------------
     
    8888    function setParam($params)
    8989    {
     90        $app =& App::getInstance();
     91   
    9092        if (isset($params) && is_array($params)) {
    9193            // Enforce valid email addresses.
     
    100102            $this->_params = array_merge($this->_params, $params);
    101103        } else {
    102             App::logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
     104            $app->logMsg(sprintf('Parameters are not an array: %s', $params), LOG_ERR, __FILE__, __LINE__);
    103105        }
    104106    }
     
    113115    function getParam($param)
    114116    {
     117        $app =& App::getInstance();
     118   
    115119        if (isset($this->_params[$param])) {
    116120            return $this->_params[$param];
    117121        } else {
    118             App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__);
     122            $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_NOTICE, __FILE__, __LINE__);
    119123            return null;
    120124        }
     
    131135    function setTemplate($template)
    132136    {
     137        $app =& App::getInstance();
     138   
    133139        // Load file, using include_path.
    134140        if (!$this->_template = file_get_contents($template, true)) {
    135             App::logMsg(sprintf('Email template file does not exist: %s', $template), LOG_ERR, __FILE__, __LINE__);
     141            $app->logMsg(sprintf('Email template file does not exist: %s', $template), LOG_ERR, __FILE__, __LINE__);
    136142            $this->_template = null;
    137143            $this->_template_replaced = null;
     
    153159    function setString($string)
    154160    {
     161        $app =& App::getInstance();
     162   
    155163        // Load file, using include_path.
    156164        if ('' == trim($string)) {
    157             App::logMsg(sprintf('Empty string provided.', null), LOG_ERR, __FILE__, __LINE__);
     165            $app->logMsg(sprintf('Empty string provided.', null), LOG_ERR, __FILE__, __LINE__);
    158166            $this->_template_replaced = null;
    159167            return false;
     
    176184    function replace($replacements)
    177185    {
     186        $app =& App::getInstance();
     187   
    178188        // Ensure template exists.
    179189        if (!isset($this->_template)) {
    180             App::logMsg(sprintf('Cannot replace variables, no template defined.', null), LOG_ERR, __FILE__, __LINE__);
     190            $app->logMsg(sprintf('Cannot replace variables, no template defined.', null), LOG_ERR, __FILE__, __LINE__);
    181191            return false;
    182192        }
     
    184194        // Ensure replacements argument is an array.
    185195        if (!is_array($replacements)) {
    186             App::logMsg(sprintf('Cannot replace variables, invalid replacements.', null), LOG_ERR, __FILE__, __LINE__);
     196            $app->logMsg(sprintf('Cannot replace variables, invalid replacements.', null), LOG_ERR, __FILE__, __LINE__);
    187197            return false;
    188198        }
     
    211221    function send($to=null, $from=null, $subject=null, $headers=null)
    212222    {
     223        $app =& App::getInstance();
     224   
    213225        // Use arguments if provided.
    214226        if (isset($to)) {
     
    227239        // Ensure required values exist.
    228240        if (!isset($this->_params['subject'])) {
    229             App::logMsg(sprintf('Cannot send email to %s. SUBJECT not defined.', $this->_params['to']), LOG_ERR, __FILE__, __LINE__);
     241            $app->logMsg(sprintf('Cannot send email to %s. SUBJECT not defined.', $this->_params['to']), LOG_ERR, __FILE__, __LINE__);
    230242            return false;
    231243        } else if (!isset($this->_template)) {
    232             App::logMsg(sprintf('Cannot send email: "%s". Template not set.', $this->_params['subject']), LOG_ERR, __FILE__, __LINE__);
     244            $app->logMsg(sprintf('Cannot send email: "%s". Template not set.', $this->_params['subject']), LOG_ERR, __FILE__, __LINE__);
    233245            return false;
    234246        } else if (!isset($this->_params['to'])) {
    235             App::logMsg(sprintf('Cannot send email: "%s". TO not defined.', $this->_params['subject']), LOG_NOTICE, __FILE__, __LINE__);
     247            $app->logMsg(sprintf('Cannot send email: "%s". TO not defined.', $this->_params['subject']), LOG_NOTICE, __FILE__, __LINE__);
    236248            return false;
    237249        } else if (!isset($this->_params['from'])) {
    238             App::logMsg(sprintf('Cannot send email: "%s". FROM not defined.', $this->_params['subject']), LOG_ERR, __FILE__, __LINE__);
     250            $app->logMsg(sprintf('Cannot send email: "%s". FROM not defined.', $this->_params['subject']), LOG_ERR, __FILE__, __LINE__);
    239251            return false;
    240252        }
     
    245257        // Ensure all placeholders have been replaced. Find anything with {...} characters.
    246258        if (preg_match('/({[^}]+})/', $final_body, $unreplaced_match)) {
    247             App::logMsg(sprintf('Cannot send email. Variables left unreplaced in template: %s', (isset($unreplaced_match[1]) ? $unreplaced_match[1] : '')), LOG_ERR, __FILE__, __LINE__);
     259            $app->logMsg(sprintf('Cannot send email. Variables left unreplaced in template: %s', (isset($unreplaced_match[1]) ? $unreplaced_match[1] : '')), LOG_ERR, __FILE__, __LINE__);
    248260            return false;
    249261        }
     
    273285        $full_mail_content = join("\n", array($final_to, $this->_params['subject'], $final_body, $final_headers, $envelope_sender_header));
    274286        if (preg_match("/(Content-Type:|MIME-Version:|Content-Transfer-Encoding:|[\n\r]Bcc:|[\n\r]Cc:)/i", $full_mail_content)) {
    275             App::logMsg(sprintf('Mail header injection attack in content: %s', $full_mail_content), LOG_WARNING, __FILE__, __LINE__);
     287            $app->logMsg(sprintf('Mail header injection attack in content: %s', $full_mail_content), LOG_WARNING, __FILE__, __LINE__);
    276288            sleep(3);
    277289            return false;
     
    280292        // Ensure message was successfully accepted for delivery.
    281293        if (mail($final_to, $this->_params['subject'], $final_body, $final_headers, $envelope_sender_header)) {
    282             App::logMsg(sprintf('Email successfully sent to %s', $final_to), LOG_DEBUG, __FILE__, __LINE__);
     294            $app->logMsg(sprintf('Email successfully sent to %s', $final_to), LOG_DEBUG, __FILE__, __LINE__);
    283295            return true;
    284296        } else {
    285             App::logMsg(sprintf('Email failure with parameters: %s, %s, %s, %s', $final_to, $this->_params['subject'], str_replace("\r\n", '\r\n', $final_headers), $envelope_sender_header), LOG_NOTICE, __FILE__, __LINE__);
     297            $app->logMsg(sprintf('Email failure with parameters: %s, %s, %s, %s', $final_to, $this->_params['subject'], str_replace("\r\n", '\r\n', $final_headers), $envelope_sender_header), LOG_NOTICE, __FILE__, __LINE__);
    286298            return false;
    287299        }
     
    305317    function validEmail($email)
    306318    {
     319        $app =& App::getInstance();
     320   
    307321        // If an array, check values recursively.
    308322        if (is_array($email)) {
     
    318332                return true;
    319333            } else {
    320                 App::logMsg(sprintf('Invalid email: %s', $email), LOG_INFO, __FILE__, __LINE__);
     334                $app->logMsg(sprintf('Invalid email: %s', $email), LOG_INFO, __FILE__, __LINE__);
    321335                return false;
    322336            }
  • branches/2.0singleton/lib/FormValidator.inc.php

    r121 r127  
    389389    function validateEmail($form_name)
    390390    {
     391        $app =& App::getInstance();
     392   
    391393        $email = getFormData($form_name);
    392394        if ('' == trim($email)) {
     
    400402        if (!preg_match($e->getParam('regex'), $email, $e_parts)) {
    401403            $this->addError($form_name, sprintf(_("<strong>%s</strong> is not a valid email address."), oTxt($email)));
    402             App::logMsg(sprintf('The email address %s is not valid.', getFormData($form_name)), LOG_DEBUG, __FILE__, __LINE__);
     404            $app->logMsg(sprintf('The email address %s is not valid.', getFormData($form_name)), LOG_DEBUG, __FILE__, __LINE__);
    403405            return false;
    404406        }
     
    412414        if (strlen($local) > 64 || strlen($domain) > 191) {
    413415            $this->addError($form_name, sprintf(_("<strong>Email address</strong> must contain less than 256 characters."), oTxt($email)));
    414             App::logMsg(sprintf('The email address %s must contain less than 256 characters.', getFormData($form_name)), LOG_DEBUG, __FILE__, __LINE__);
     416            $app->logMsg(sprintf('The email address %s must contain less than 256 characters.', getFormData($form_name)), LOG_DEBUG, __FILE__, __LINE__);
    415417            return false;
    416418        }
     
    420422        if ((ip2long($domain) == '-1' || ip2long($domain) === false) && function_exists('checkdnsrr') && !checkdnsrr($domain . '.', 'MX') && gethostbyname($domain) == $domain) {
    421423            $this->addError($form_name, sprintf(_("<strong>%s</strong> is not a valid email domain name"), oTxt($domain)));
    422             App::logMsg(sprintf('The email address %s contains an invalid email domain name (%s).', getFormData($form_name), $domain), LOG_INFO, __FILE__, __LINE__);
     424            $app->logMsg(sprintf('The email address %s contains an invalid email domain name (%s).', getFormData($form_name), $domain), LOG_INFO, __FILE__, __LINE__);
    423425            return false;
    424426        }
     
    454456    function validateStrDate($form_name, $msg='')
    455457    {
     458        $app =& App::getInstance();
     459   
    456460        if (($timestamp = strtotime(getFormData($form_name, '0'))) === -1) {
    457461            $this->addError($form_name, $msg);
    458             App::logMsg(sprintf('The string date %s is not valid.', getFormData($form_name)), LOG_DEBUG, __FILE__, __LINE__);
     462            $app->logMsg(sprintf('The string date %s is not valid.', getFormData($form_name)), LOG_DEBUG, __FILE__, __LINE__);
    459463            return false;
    460464        } else {
  • branches/2.0singleton/lib/Hierarchy.inc.php

    r111 r127  
    9797    function toStringID($child_type=null, $child_id=null)
    9898    {
    99         if (!isset($child_type) || !isset($child_id)) {
    100             if ($this->node_init) {
    101                 $child_type =& $this->child_type;
    102                 $child_id =& $this->child_id;
    103             } else {
    104                 App::logMsg(_("toStringID failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
     99            $app =& App::getInstance();
     100   
     101            if (!isset($child_type) || !isset($child_id)) {
     102            if ($this->node_init) {
     103                $child_type =& $this->child_type;
     104                $child_id =& $this->child_id;
     105            } else {
     106                $app->logMsg(_("toStringID failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
    105107                return false;
    106108            }
     
    129131    function toArrayID(&$node)
    130132    {
    131         if (preg_match('/^([[:alnum:]]+)__-?([[:digit:]]+)$/', $node, $node_parts)) {
     133            $app =& App::getInstance();
     134   
     135            if (preg_match('/^([[:alnum:]]+)__-?([[:digit:]]+)$/', $node, $node_parts)) {
    132136            return array('node_type' => $node_parts[1], 'node_id' => $node_parts[2]);
    133137        } else {
    134             App::logMsg(_("Cannot parse node identifier, not formated correctly."), LOG_ERR, __FILE__, __LINE__);
     138            $app->logMsg(_("Cannot parse node identifier, not formated correctly."), LOG_ERR, __FILE__, __LINE__);
    135139            return false;
    136140        }
     
    147151    function insertNode($parents, $child_type=null, $child_id=null, $relationship_type=null, $title='')
    148152    {
     153        $app =& App::getInstance();
     154   
    149155        if (!isset($child_type) || !isset($child_id)) {
    150156            if ($this->node_init) {
     
    152158                $child_id =& $this->child_id;
    153159            } else {
    154                 App::logMsg(_("insertNode failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
     160                $app->logMsg(_("insertNode failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
    155161                return false;
    156162            }
     
    159165        // Make sure this is not empty and an array, even if it has only one value.
    160166        if ('' == $parents) {
    161             App::raiseMsg(sprintf(_("Cannot add node <strong>%s %s</strong>, no parent was specified."), $child_type, $child_id), MSG_ERR, __FILE__, __LINE__);
    162             App::logMsg(sprintf(_("Cannot add node <strong>%s %s</strong>, no parent was specified."), $child_type, $child_id), LOG_ERR, __FILE__, __LINE__);
     167            $app->raiseMsg(sprintf(_("Cannot add node <strong>%s %s</strong>, no parent was specified."), $child_type, $child_id), MSG_ERR, __FILE__, __LINE__);
     168            $app->logMsg(sprintf(_("Cannot add node <strong>%s %s</strong>, no parent was specified."), $child_type, $child_id), LOG_ERR, __FILE__, __LINE__);
    163169            return false;
    164170        } else if (!is_array($parents)) {
     
    174180            $parent = $this->toArrayID($parent_string);
    175181            if ($this->nodeExists($child_type, $child_id, $parent['node_type'], $parent['node_id'], $relationship_type)) {
    176                 App::raiseMsg(sprintf(_("Cannot add node <strong>%s %s</strong> to parent <strong>%s %s</strong>. It already exists there"), $child_type, $child_id, $parent['node_type'], $parent['node_id']), MSG_ERR, __FILE__, __LINE__);
    177                 App::logMsg(sprintf(_("Cannot add node <strong>%s %s</strong> to parent <strong>%s %s</strong>. It already exists there"), $child_type, $child_id, $parent['node_type'], $parent['node_id']), LOG_ERR, __FILE__, __LINE__);
     182                $app->raiseMsg(sprintf(_("Cannot add node <strong>%s %s</strong> to parent <strong>%s %s</strong>. It already exists there"), $child_type, $child_id, $parent['node_type'], $parent['node_id']), MSG_ERR, __FILE__, __LINE__);
     183                $app->logMsg(sprintf(_("Cannot add node <strong>%s %s</strong> to parent <strong>%s %s</strong>. It already exists there"), $child_type, $child_id, $parent['node_type'], $parent['node_id']), LOG_ERR, __FILE__, __LINE__);
    178184                return false;
    179185            }
    180186            if (!$this->nodeExists($parent['node_type'], $parent['node_id'])) {
    181                 App::raiseMsg(sprintf(_("Cannot add node <strong>%s %s</strong> to nonexistent parent <strong>%s %s</strong>."), $child_type, $child_id, $parent['node_type'], $parent['node_id']), MSG_ERR, __FILE__, __LINE__);
    182                 App::logMsg(sprintf(_("Cannot add node <strong>%s %s</strong> to nonexistent parent <strong>%s %s</strong>."), $child_type, $child_id, $parent['node_type'], $parent['node_id']), LOG_ERR, __FILE__, __LINE__);
     187                $app->raiseMsg(sprintf(_("Cannot add node <strong>%s %s</strong> to nonexistent parent <strong>%s %s</strong>."), $child_type, $child_id, $parent['node_type'], $parent['node_id']), MSG_ERR, __FILE__, __LINE__);
     188                $app->logMsg(sprintf(_("Cannot add node <strong>%s %s</strong> to nonexistent parent <strong>%s %s</strong>."), $child_type, $child_id, $parent['node_type'], $parent['node_id']), LOG_ERR, __FILE__, __LINE__);
    183189                return false;
    184190            }
     
    205211                )
    206212            ");
    207             App::logMsg(sprintf('insertNode: Added node %s %s with parent %s %s.', $child_type, $child_id, $parent['node_type'], $parent['node_id']), LOG_DEBUG, __FILE__, __LINE__);
     213            $app->logMsg(sprintf('insertNode: Added node %s %s with parent %s %s.', $child_type, $child_id, $parent['node_type'], $parent['node_id']), LOG_DEBUG, __FILE__, __LINE__);
    208214        }
    209215        return true;
     
    223229    function deleteNode($child_type=null, $child_id=null)
    224230    {
     231        $app =& App::getInstance();
     232   
    225233        if (!isset($child_type) || !isset($child_id)) {
    226234            if ($this->node_init) {
     
    228236                $child_id =& $this->child_id;
    229237            } else {
    230                 App::logMsg(_("deleteNode failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
     238                $app->logMsg(_("deleteNode failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
    231239                return false;
    232240            }
     
    248256            AND child_id = '" . DB::escapeString($child_id) . "'
    249257        ");
    250         App::logMsg(sprintf('deleteNode: Deleted node %s %s.', $child_type, $child_id), LOG_DEBUG, __FILE__, __LINE__);
     258        $app->logMsg(sprintf('deleteNode: Deleted node %s %s.', $child_type, $child_id), LOG_DEBUG, __FILE__, __LINE__);
    251259
    252260        return true;
     
    270278    function moveNode($new_parents=null, $child_type=null, $child_id=null, $relationship_type=null, $title='')
    271279    {
    272         if (!isset($child_type) || !isset($child_id)) {
    273             if ($this->node_init) {
    274                 $child_type =& $this->child_type;
    275                 $child_id =& $this->child_id;
    276             } else {
    277                 App::logMsg(_("moveNode failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
     280            $app =& App::getInstance();
     281   
     282            if (!isset($child_type) || !isset($child_id)) {
     283            if ($this->node_init) {
     284                $child_type =& $this->child_type;
     285                $child_id =& $this->child_id;
     286            } else {
     287                $app->logMsg(_("moveNode failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
    278288                return false;
    279289            }
     
    282292        // Make sure this is not empty and an array, even if it has only one value.
    283293        if (empty($new_parents)) {
    284             App::raiseMsg(sprintf(_("Cannot move node <strong>%s %s</strong>, no parent was specified."), $child_type, $child_id), MSG_ERR, __FILE__, __LINE__);
    285             App::logMsg(sprintf(_("Cannot move node <strong>%s %s</strong>, no parent was specified."), $child_type, $child_id), LOG_ERR, __FILE__, __LINE__);
     294            $app->raiseMsg(sprintf(_("Cannot move node <strong>%s %s</strong>, no parent was specified."), $child_type, $child_id), MSG_ERR, __FILE__, __LINE__);
     295            $app->logMsg(sprintf(_("Cannot move node <strong>%s %s</strong>, no parent was specified."), $child_type, $child_id), LOG_ERR, __FILE__, __LINE__);
    286296            return false;
    287297        } else if (!is_array($new_parents)) {
     
    296306            $parent = $this->toArrayID($parent_string);
    297307            if (!$this->nodeExists($parent['node_type'], $parent['node_id'])) {
    298                 App::raiseMsg(sprintf(_("Cannot move node <strong>%s %s</strong> to nonexistent parent <strong>%s %s</strong>."), $child_type, $child_id, $parent['node_type'], $parent['node_id']), MSG_ERR, __FILE__, __LINE__);
    299                 App::logMsg(sprintf(_("Cannot move node <strong>%s %s</strong> to nonexistent parent <strong>%s %s</strong>."), $child_type, $child_id, $parent['node_type'], $parent['node_id']), LOG_ERR, __FILE__, __LINE__);
     308                $app->raiseMsg(sprintf(_("Cannot move node <strong>%s %s</strong> to nonexistent parent <strong>%s %s</strong>."), $child_type, $child_id, $parent['node_type'], $parent['node_id']), MSG_ERR, __FILE__, __LINE__);
     309                $app->logMsg(sprintf(_("Cannot move node <strong>%s %s</strong> to nonexistent parent <strong>%s %s</strong>."), $child_type, $child_id, $parent['node_type'], $parent['node_id']), LOG_ERR, __FILE__, __LINE__);
    300310                return false;
    301311            }
    302312            if ($this->isAncestor($child_type, $child_id, $parent['node_type'], $parent['node_id'])) {
    303                 App::raiseMsg(sprintf(_("Cannot move node <strong>%s %s</strong> to parent <strong>%s %s</strong> because a node cannot have itself as a parent."), $child_type, $child_id, $parent['node_type'], $parent['node_id']), MSG_ERR, __FILE__, __LINE__);
    304                 App::logMsg(sprintf(_("Cannot move node <strong>%s %s</strong> to parent <strong>%s %s</strong> because a node cannot have itself as a parent."), $child_type, $child_id, $parent['node_type'], $parent['node_id']), LOG_ERR, __FILE__, __LINE__);
     313                $app->raiseMsg(sprintf(_("Cannot move node <strong>%s %s</strong> to parent <strong>%s %s</strong> because a node cannot have itself as a parent."), $child_type, $child_id, $parent['node_type'], $parent['node_id']), MSG_ERR, __FILE__, __LINE__);
     314                $app->logMsg(sprintf(_("Cannot move node <strong>%s %s</strong> to parent <strong>%s %s</strong> because a node cannot have itself as a parent."), $child_type, $child_id, $parent['node_type'], $parent['node_id']), LOG_ERR, __FILE__, __LINE__);
    305315                return false;
    306316            }
     
    325335            AND relationship_type " . (is_null($relationship_type) ? "IS NULL" : "= '" . DB::escapeString($relationship_type) . "'") . "
    326336        ");
    327         App::logMsg(sprintf('moveNode: Deleted node %s %s.', $child_type, $child_id), LOG_DEBUG, __FILE__, __LINE__);
     337        $app->logMsg(sprintf('moveNode: Deleted node %s %s.', $child_type, $child_id), LOG_DEBUG, __FILE__, __LINE__);
    328338
    329339        // Insert new nodes with the new parents.
     
    344354    function getParents($child_type=null, $child_id=null, $type_constraint=null, $order='')
    345355    {
     356        $app =& App::getInstance();
     357   
    346358        if (!isset($child_type) || !isset($child_id)) {
    347359            if ($this->node_init) {
     
    349361                $child_id =& $this->child_id;
    350362            } else {
    351                 App::logMsg(_("getParents failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
     363                $app->logMsg(_("getParents failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
    352364                return false;
    353365            }
     
    392404    function getNode($child_type=null, $child_id=null)
    393405    {
     406        $app =& App::getInstance();
     407   
    394408        if (!isset($child_type) || !isset($child_id)) {
    395409            if ($this->node_init) {
     
    397411                $child_id =& $this->child_id;
    398412            } else {
    399                 App::logMsg(_("getNode failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
     413                $app->logMsg(_("getNode failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
    400414                return false;
    401415            }
     
    433447    function getChildren($child_type=null, $child_id=null, $type_constraint=null, $order='')
    434448    {
     449        $app =& App::getInstance();
     450   
    435451        if (!isset($child_type) || !isset($child_id)) {
    436452            if ($this->node_init) {
     
    438454                $child_id =& $this->child_id;
    439455            } else {
    440                 App::logMsg(_("getChildren failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
     456                $app->logMsg(_("getChildren failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
    441457                return false;
    442458            }
     
    482498    function getNumberChildren($child_type=null, $child_id=null, $type_constraint=null)
    483499    {
     500        $app =& App::getInstance();
     501   
    484502        if (!isset($child_type) || !isset($child_id)) {
    485503            if ($this->node_init) {
     
    487505                $child_id =& $this->child_id;
    488506            } else {
    489                 App::logMsg(_("getNumberChildren failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
     507                $app->logMsg(_("getNumberChildren failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
    490508                return false;
    491509            }
     
    520538    function isLeaf($child_type=null, $child_id=null)
    521539    {
     540        $app =& App::getInstance();
     541   
    522542        if (!isset($child_type) || !isset($child_id)) {
    523543            if ($this->node_init) {
     
    525545                $child_id =& $this->child_id;
    526546            } else {
    527                 App::logMsg(_("isLeaf failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
     547                $app->logMsg(_("isLeaf failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
    528548                return false;
    529549            }
     
    631651    function nodeExists($child_type=null, $child_id=null, $parent_type=null, $parent_id=null, $relationship_type=null)
    632652    {
     653        $app =& App::getInstance();
     654   
    633655        if (!isset($child_type) || !isset($child_id)) {
    634656            if ($this->node_init) {
     
    636658                $child_id =& $this->child_id;
    637659            } else {
    638                 App::logMsg(_("nodeExists failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
     660                $app->logMsg(_("nodeExists failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
    639661                return false;
    640662            }
     
    680702    function &getNodeList($preselected=null, $child_type=null, $child_id=null, $type_constraint=null, $include_curr=false, $order='', $_indent=0, $_return_flag=true)
    681703    {
     704        $app =& App::getInstance();
     705   
    682706        static $output = array();
    683707        static $is_a_leaf = array();
     
    688712                $child_id =& $this->child_id;
    689713            } else {
    690                 App::logMsg(_("getNodeList failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
     714                $app->logMsg(_("getNodeList failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);
    691715                return false;
    692716            }
     
    709733                // Preventing circular references.
    710734                if ($my_children[$i]['child_type'] == $child_type && $my_children[$i]['child_id'] == $child_id && !($_return_flag && $include_curr)) {
    711                     App::logMsg(sprintf(_("Circular reference detected: %s has itself as a parent."), $this->toStringID($my_children[$i]['child_type'], $my_children[$i]['child_id'])), LOG_ERR, __FILE__, __LINE__);
     735                    $app->logMsg(sprintf(_("Circular reference detected: %s has itself as a parent."), $this->toStringID($my_children[$i]['child_type'], $my_children[$i]['child_id'])), LOG_ERR, __FILE__, __LINE__);
    712736                    continue;
    713737                }
Note: See TracChangeset for help on using the changeset viewer.