Changeset 129


Ignore:
Timestamp:
May 26, 2006 9:40:35 PM (18 years ago)
Author:
scdev
Message:

finished updating to 2.0singleton

Location:
branches/2.0singleton
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0singleton/services/admins.php

    r111 r129  
    88
    99$auth->requireLogin();
    10 App::sslOn();
     10$app->sslOn();
    1111
    1212require_once 'codebase/lib/PageNumbers.inc.php';
     
    5454
    5555// Search limiters retain their values between page requests.
    56 App::carryQuery('search_query');
     56$app->carryQuery('search_query');
    5757
    5858
     
    6464// allows us to remember which page we came from so we can go back there.
    6565if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) {
    66     App::setBoomerangURL($_SERVER['HTTP_REFERER'], 'admins');
     66    $app->setBoomerangURL($_SERVER['HTTP_REFERER'], 'admins');
    6767}
    6868
     
    9191case 'del' :
    9292    deleteRecord(getFormData('admin_id'));
    93     if (App::validBoomerangURL('admins')) {
     93    if ($app->validBoomerangURL('admins')) {
    9494        // Display boomerang page.
    95         App::dieBoomerangURL('admins');
     95        $app->dieBoomerangURL('admins');
    9696    }
    9797    // Display default page.
    98     App::dieURL($_SERVER['PHP_SELF']);
     98    $app->dieURL($_SERVER['PHP_SELF']);
    9999    break;
    100100
    101101case 'insert' :
    102102    if (getFormdata('cancel', false)) {
    103         if (App::validBoomerangURL('admins')) {
     103        if ($app->validBoomerangURL('admins')) {
    104104            // Display boomerang page.
    105             App::dieBoomerangURL('admins');
     105            $app->dieBoomerangURL('admins');
    106106        }
    107107        // Display default page.
    108         App::dieURL($_SERVER['PHP_SELF']);
     108        $app->dieURL($_SERVER['PHP_SELF']);
    109109    }
    110110    validateInput();
     
    118118        if (getFormdata('repeat', false)) {
    119119            // Display function again.
    120             App::dieURL($_SERVER['PHP_SELF'] . '?op=add');
    121         } else if (App::validBoomerangURL('admins')) {
     120            $app->dieURL($_SERVER['PHP_SELF'] . '?op=add');
     121        } else if ($app->validBoomerangURL('admins')) {
    122122            // Display boomerang page.
    123             App::dieBoomerangURL('admins');
     123            $app->dieBoomerangURL('admins');
    124124        }
    125125        // Display default page.
    126         App::dieURL($_SERVER['PHP_SELF']);
     126        $app->dieURL($_SERVER['PHP_SELF']);
    127127    }
    128128    break;
     
    130130case 'update' :
    131131    if (getFormdata('reset', false)) {
    132         App::raiseMsg(_("Saved values have been reloaded."), MSG_NOTICE, __FILE__, __LINE__);
    133         App::dieURL($_SERVER['PHP_SELF'] . '?op=edit&admin_id=' . getFormData('admin_id'));
     132        $app->raiseMsg(_("Saved values have been reloaded."), MSG_NOTICE, __FILE__, __LINE__);
     133        $app->dieURL($_SERVER['PHP_SELF'] . '?op=edit&admin_id=' . getFormData('admin_id'));
    134134    }
    135135    if (getFormdata('cancel', false)) {
     
    137137        $lock->select('admin_tbl', 'admin_id', getFormData('admin_id'));
    138138        $lock->remove();
    139         if (App::validBoomerangURL('admins')) {
     139        if ($app->validBoomerangURL('admins')) {
    140140            // Display boomerang page.
    141             App::dieBoomerangURL('admins');
     141            $app->dieBoomerangURL('admins');
    142142        }
    143143        // Display default page.
    144         App::dieURL($_SERVER['PHP_SELF']);
     144        $app->dieURL($_SERVER['PHP_SELF']);
    145145    }
    146146    validateInput();
     
    156156            $qid = DB::query("SELECT admin_id FROM admin_tbl WHERE admin_id > '" . DB::escapeString(getFormData('admin_id')) . "' ORDER BY admin_id ASC LIMIT 1");
    157157            if (list($next_id) = mysql_fetch_row($qid)) {
    158                 App::dieURL($_SERVER['PHP_SELF'] . '?op=edit&admin_id=' . $next_id);
     158                $app->dieURL($_SERVER['PHP_SELF'] . '?op=edit&admin_id=' . $next_id);
    159159            } else {
    160                 App::raiseMsg(_("Cannot edit next, the end of the list was reached"), MSG_NOTICE, __FILE__, __LINE__);
     160                $app->raiseMsg(_("Cannot edit next, the end of the list was reached"), MSG_NOTICE, __FILE__, __LINE__);
    161161            }
    162         } else if (App::validBoomerangURL('admins')) {
     162        } else if ($app->validBoomerangURL('admins')) {
    163163            // Display boomerang page.
    164             App::dieBoomerangURL('admins');
     164            $app->dieBoomerangURL('admins');
    165165        }
    166166        // Display default page.
    167         App::dieURL($_SERVER['PHP_SELF']);
     167        $app->dieURL($_SERVER['PHP_SELF']);
    168168    }
    169169    break;
     
    258258{
    259259    global $lock;
     260    $app =& App::getInstance();
    260261
    261262    $lock->select('admin_tbl', 'admin_id', $id);
     
    271272    ");
    272273    if (!$frm = mysql_fetch_assoc($qid)) {
    273         App::logMsg('Could not find record with admin_id: ' . $id, LOG_WARNING, __FILE__, __LINE__);
    274         App::raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__);
    275         App::dieBoomerangURL();
     274        $app->logMsg('Could not find record with admin_id: ' . $id, LOG_WARNING, __FILE__, __LINE__);
     275        $app->raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__);
     276        $app->dieBoomerangURL();
    276277    }
    277278
     
    313314{
    314315    global $auth, $lock;
     316    $app =& App::getInstance();
    315317
    316318    $lock->select('admin_tbl', 'admin_id', $id);
     
    328330    ");
    329331    if (! list($name, $user_type) = mysql_fetch_row($qid)) {
    330         App::logMsg('Could not find record with admin_id: ' . $id, LOG_WARNING, __FILE__, __LINE__);
    331         App::raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__);
    332         App::dieBoomerangURL();
     332        $app->logMsg('Could not find record with admin_id: ' . $id, LOG_WARNING, __FILE__, __LINE__);
     333        $app->raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__);
     334        $app->dieBoomerangURL();
    333335    }
    334336
     
    338340    if ('root' == $user_type && 'root' != $auth->getVal('user_type')) {
    339341        // Only root users can delete root users!
    340         App::raiseMsg(_("You do not have clearance to delete a root administrator."), MSG_NOTICE, __FILE__, __LINE__);
     342        $app->raiseMsg(_("You do not have clearance to delete a root administrator."), MSG_NOTICE, __FILE__, __LINE__);
    341343    } else if ($num_admins <= 1) {
    342344        // There must always be at least one admnistrator!
    343         App::raiseMsg(_("You cannot delete the only administrator in the database. There must be at least one to log in and create other users."), MSG_NOTICE, __FILE__, __LINE__);
     345        $app->raiseMsg(_("You cannot delete the only administrator in the database. There must be at least one to log in and create other users."), MSG_NOTICE, __FILE__, __LINE__);
    344346    } else if ($auth->getVal('user_id') == $id) {
    345347        // Do not delete yourself!
    346         App::raiseMsg(_("You cannot delete yourself."), MSG_NOTICE, __FILE__, __LINE__);
     348        $app->raiseMsg(_("You cannot delete yourself."), MSG_NOTICE, __FILE__, __LINE__);
    347349    } else {
    348350        // Delete the record.
    349351        DB::query("DELETE FROM admin_tbl WHERE admin_id = '" . DB::escapeString($id) . "'");
    350         App::raiseMsg(sprintf(_("The admin <strong>%s</strong> has been deleted."), $name), MSG_SUCCESS, __FILE__, __LINE__);
     352        $app->raiseMsg(sprintf(_("The admin <strong>%s</strong> has been deleted."), $name), MSG_SUCCESS, __FILE__, __LINE__);
    351353    }
    352354
     
    358360{
    359361    global $auth;
     362    $app =& App::getInstance();
    360363
    361364    // Break the cache because we are changing the list data.
     
    391394    $version->create('admin_tbl', 'admin_id', $last_insert_id, $frm['username']);
    392395
    393     App::raiseMsg(sprintf(_("The Admin <strong>%s</strong> has been added."), $frm['username']), MSG_SUCCESS, __FILE__, __LINE__);
     396    $app->raiseMsg(sprintf(_("The Admin <strong>%s</strong> has been added."), $frm['username']), MSG_SUCCESS, __FILE__, __LINE__);
    394397
    395398    return $last_insert_id;
     
    399402{
    400403    global $auth, $lock;
     404    $app =& App::getInstance();
    401405
    402406    $lock->select('admin_tbl', 'admin_id', $frm['admin_id']);
     
    431435    $version->create('admin_tbl', 'admin_id', $frm['admin_id'], $frm['username']);
    432436
    433     App::raiseMsg(sprintf(_("The Admin <strong>%s</strong> has been updated."), $frm['username']), MSG_SUCCESS, __FILE__, __LINE__);
     437    $app->raiseMsg(sprintf(_("The Admin <strong>%s</strong> has been updated."), $frm['username']), MSG_SUCCESS, __FILE__, __LINE__);
    434438
    435439    // Unlock record.
  • branches/2.0singleton/services/lock.php

    r53 r129  
    99
    1010$auth->requireLogin();
    11 App::sslOn();
     11$app->sslOn();
    1212
    1313if (getFormData('boomerang', false)) {
    1414    // We remember which page we came from so we can go back there.
    1515    $boom_url = strpos(getFormData('boomerang'), '/') !== false ? getFormData('boomerang') : $_SERVER['HTTP_REFERER'];
    16     App::setBoomerangURL($boom_url, 'lock');
     16    $app->setBoomerangURL($boom_url, 'lock');
    1717    if (isset($_SERVER['HTTP_REFERER'])) {
    18         App::setBoomerangURL($_SERVER['HTTP_REFERER'], 'cancel-lock');
     18        $app->setBoomerangURL($_SERVER['HTTP_REFERER'], 'cancel-lock');
    1919    }
    2020}
     
    2626
    2727if (!$lock->isLocked()) {
    28     App::logMsg('Lock not found with lock_id: ' . getFormData('lock_id') . ', from referrer: ' . $_SERVER['HTTP_REFERER'], LOG_WARNING, __FILE__, __LINE__);
    29     App::dieBoomerangURL('lock');
     28    $app->logMsg('Lock not found with lock_id: ' . getFormData('lock_id') . ', from referrer: ' . $_SERVER['HTTP_REFERER'], LOG_WARNING, __FILE__, __LINE__);
     29    $app->dieBoomerangURL('lock');
    3030}
    3131
     
    3333if (getFormData('unlock', false)) {
    3434    $lock->remove();
    35     App::raiseMsg(sprintf(_("The record <strong>%s</strong> has been unlocked, and can now be modified."), $lock->getTitle('title')), MSG_NOTICE, __FILE__, __LINE__);
    36     App::dieBoomerangURL('lock');
     35    $app->raiseMsg(sprintf(_("The record <strong>%s</strong> has been unlocked, and can now be modified."), $lock->getTitle('title')), MSG_NOTICE, __FILE__, __LINE__);
     36    $app->dieBoomerangURL('lock');
    3737} else if (getFormData('cancel', false)) {
    3838    // Since the boomerang URL will go back to the locked record, and the record was not unlocked, we must delete the boomerang URL otherwise we'll come back here.
    39     App::deleteBoomerangURL('lock');
    40     App::dieBoomerangURL('cancel-lock');
     39    $app->deleteBoomerangURL('lock');
     40    $app->dieBoomerangURL('cancel-lock');
    4141}
    4242
  • branches/2.0singleton/services/login.php

    r103 r129  
    88// allows us to remember which page we came from so we can go back there.
    99if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) {
    10     App::setBoomerangURL($_SERVER['HTTP_REFERER'], 'login');
     10    $app->setBoomerangURL($_SERVER['HTTP_REFERER'], 'login');
    1111}
    12 App::sslOn();
     12$app->sslOn();
    1313
    1414$frm['username'] = getFormdata('username');
     
    1919
    2020    if ($auth->login($frm['username'], $frm['password'])) {
    21         App::raiseMsg(_("You are now logged in."), MSG_SUCCESS, __FILE__, __LINE__);
    22         App::dieBoomerangURL('login');
    23         App::logMsg(sprintf('%s %s successfully logged-in.', $auth->getVal('auth_name'), $frm['username']), LOG_INFO, __FILE__, __LINE__);
     21        $app->raiseMsg(_("You are now logged in."), MSG_SUCCESS, __FILE__, __LINE__);
     22        $app->dieBoomerangURL('login');
     23        $app->logMsg(sprintf('%s %s successfully logged-in.', $auth->getVal('auth_name'), $frm['username']), LOG_INFO, __FILE__, __LINE__);
    2424    } else {
    25         App::raiseMsg(_("Login failed, please try again."), MSG_NOTICE, __FILE__, __LINE__);
    26         App::logMsg(sprintf('%s %s failed login using (MD5ed) password: %s', ucfirst($auth->getVal('auth_name')), $frm['username'], md5($frm['password'])), LOG_NOTICE, __FILE__, __LINE__);
     25        $app->raiseMsg(_("Login failed, please try again."), MSG_NOTICE, __FILE__, __LINE__);
     26        $app->logMsg(sprintf('%s %s failed login using (MD5ed) password: %s', ucfirst($auth->getVal('auth_name')), $frm['username'], md5($frm['password'])), LOG_NOTICE, __FILE__, __LINE__);
    2727    }
    2828}
  • branches/2.0singleton/services/logout.php

    r108 r129  
    1515$auth->clearAuth();
    1616
    17 App::raiseMsg(sprintf(_("Your session has been logged-out."), null), MSG_SUCCESS, __FILE__, __LINE__);
    18 App::dieURL(App::getParam('redirect_home_url'));
     17$app->raiseMsg(sprintf(_("Your session has been logged-out."), null), MSG_SUCCESS, __FILE__, __LINE__);
     18$app->dieURL($app->getParam('redirect_home_url'));
    1919
    2020?>
  • branches/2.0singleton/services/logs.php

    r42 r129  
    99$auth->requireLogin();
    1010// $auth->requireAccessClearance(ZONE_ADMIN_APPLOG);
    11 App::sslOn();
     11$app->sslOn();
    1212
    1313require_once 'codebase/lib/PageNumbers.inc.php';
     
    3939
    4040// Set the defaults and catch incoming settings.
    41 Prefs::setDefault('log_file', App::getParam('log_filename'), 'logs_module');
     41Prefs::setDefault('log_file', $app->getParam('log_filename'), 'logs_module');
    4242Prefs::setValue('log_file', getFormData('log'), 'logs_module');
    4343
     
    5757//     $auth->requireAccessClearance(ZONE_ADMIN_APPLOG_FUNC_RESET);
    5858    deleteLog(Prefs::getValue('log_file', 'logs_module'));
    59     Prefs::setValue('log_file', App::getParam('log_filename'), 'logs_module');
    60     if (App::validBoomerangURL('app_log')) {
     59    Prefs::setValue('log_file', $app->getParam('log_filename'), 'logs_module');
     60    if ($app->validBoomerangURL('app_log')) {
    6161        // Display boomerang page.
    62         App::dieBoomerangURL('app_log');
     62        $app->dieBoomerangURL('app_log');
    6363    }
    6464    // Display default page.
    65     App::dieURL($_SERVER['PHP_SELF']);
     65    $app->dieURL($_SERVER['PHP_SELF']);
    6666    break;
    6767
     
    6969//     $auth->requireAccessClearance(ZONE_ADMIN_APPLOG_FUNC_RESET);
    7070    clearLog(Prefs::getValue('log_file', 'logs_module'));
    71     if (App::validBoomerangURL('app_log')) {
     71    if ($app->validBoomerangURL('app_log')) {
    7272        // Display boomerang page.
    73         App::dieBoomerangURL('app_log');
     73        $app->dieBoomerangURL('app_log');
    7474    }
    7575    // Display default page.
    76     App::dieURL($_SERVER['PHP_SELF']);
     76    $app->dieURL($_SERVER['PHP_SELF']);
    7777    break;
    7878
     
    8181    if (archiveLog(Prefs::getValue('log_file', 'logs_module'))) {
    8282        // Now flush current log.
    83         App::dieURL($_SERVER['PHP_SELF'] . '?op=clear');
    84     }
    85     if (App::validBoomerangURL('app_log')) {
     83        $app->dieURL($_SERVER['PHP_SELF'] . '?op=clear');
     84    }
     85    if ($app->validBoomerangURL('app_log')) {
    8686        // Display boomerang page.
    87         App::dieBoomerangURL('app_log');
     87        $app->dieBoomerangURL('app_log');
    8888    }
    8989    // Display default page.
    90     App::dieURL($_SERVER['PHP_SELF']);
     90    $app->dieURL($_SERVER['PHP_SELF']);
    9191    break;
    9292
     
    138138function deleteLog($log_file)
    139139{
    140     if (!file_exists(App::getParam('log_directory') . '/' . $log_file)) {
    141         App::raiseMsg(sprintf(_("Log file %s does not exist."), $log_file), MSG_NOTICE, __FILE__, __LINE__);
    142         App::logMsg(sprintf('Cannot delete nonexistent log file %s', App::getParam('log_directory') . '/' . $log_file), LOG_INFO, __FILE__, __LINE__);
    143         return false;
    144     }
    145 
    146     if (!is_writable(App::getParam('log_directory') . '/' . $log_file) && !is_writable(App::getParam('log_directory'))) {
    147         App::raiseMsg(sprintf(_("Log file %s could not be deleted."), $log_file), MSG_NOTICE, __FILE__, __LINE__);
    148         App::logMsg(sprintf('Cannot delete log file %s, not writable.', App::getParam('log_directory') . '/' . $log_file), LOG_INFO, __FILE__, __LINE__);
    149         return false;
    150     }
    151 
    152     if (unlink(App::getParam('log_directory') . '/' . $log_file)) {
    153         App::raiseMsg(sprintf(_("Log file %s has been deleted."), $log_file), MSG_NOTICE, __FILE__, __LINE__);
    154         App::logMsg(sprintf('Log file %s has been deleted', $log_file), LOG_INFO, __FILE__, __LINE__);
     140    $app =& App::getInstance();
     141
     142    if (!file_exists($app->getParam('log_directory') . '/' . $log_file)) {
     143        $app->raiseMsg(sprintf(_("Log file %s does not exist."), $log_file), MSG_NOTICE, __FILE__, __LINE__);
     144        $app->logMsg(sprintf('Cannot delete nonexistent log file %s', $app->getParam('log_directory') . '/' . $log_file), LOG_INFO, __FILE__, __LINE__);
     145        return false;
     146    }
     147
     148    if (!is_writable($app->getParam('log_directory') . '/' . $log_file) && !is_writable($app->getParam('log_directory'))) {
     149        $app->raiseMsg(sprintf(_("Log file %s could not be deleted."), $log_file), MSG_NOTICE, __FILE__, __LINE__);
     150        $app->logMsg(sprintf('Cannot delete log file %s, not writable.', $app->getParam('log_directory') . '/' . $log_file), LOG_INFO, __FILE__, __LINE__);
     151        return false;
     152    }
     153
     154    if (unlink($app->getParam('log_directory') . '/' . $log_file)) {
     155        $app->raiseMsg(sprintf(_("Log file %s has been deleted."), $log_file), MSG_NOTICE, __FILE__, __LINE__);
     156        $app->logMsg(sprintf('Log file %s has been deleted', $log_file), LOG_INFO, __FILE__, __LINE__);
    155157        return true;
    156158    } else {
    157         App::raiseMsg(sprintf(_("Log file %s could not be deleted."), $log_file), MSG_WARNING, __FILE__, __LINE__);
    158         App::logMsg(sprintf('unlink failed on log file %s', App::getParam('log_directory') . '/' . $log_file), LOG_WARNING, __FILE__, __LINE__);
     159        $app->raiseMsg(sprintf(_("Log file %s could not be deleted."), $log_file), MSG_WARNING, __FILE__, __LINE__);
     160        $app->logMsg(sprintf('unlink failed on log file %s', $app->getParam('log_directory') . '/' . $log_file), LOG_WARNING, __FILE__, __LINE__);
    159161        return false;
    160162    }
     
    163165function clearLog($log_file)
    164166{
    165     if (!$fp = fopen(App::getParam('log_directory') . '/' . $log_file, 'r+')) {
    166         App::raiseMsg(sprintf(_("Log file %s could not be opened."), $log_file), MSG_NOTICE, __FILE__, __LINE__);
    167         App::logMsg(sprintf('fopen failed on log file %s', App::getParam('log_directory') . '/' . $log_file), LOG_INFO, __FILE__, __LINE__);
     167    $app =& App::getInstance();
     168
     169    if (!$fp = fopen($app->getParam('log_directory') . '/' . $log_file, 'r+')) {
     170        $app->raiseMsg(sprintf(_("Log file %s could not be opened."), $log_file), MSG_NOTICE, __FILE__, __LINE__);
     171        $app->logMsg(sprintf('fopen failed on log file %s', $app->getParam('log_directory') . '/' . $log_file), LOG_INFO, __FILE__, __LINE__);
    168172        return false;
    169173    }
     
    174178    fclose($fp);
    175179    if (!$ftruncate_return) {
    176         App::raiseMsg(sprintf(_("Log file %s could not be cleared."), $log_file), MSG_WARNING, __FILE__, __LINE__);
    177         App::logMsg(sprintf('ftruncate failed on log file %s', App::getParam('log_directory') . '/' . $log_file), LOG_WARNING, __FILE__, __LINE__);
     180        $app->raiseMsg(sprintf(_("Log file %s could not be cleared."), $log_file), MSG_WARNING, __FILE__, __LINE__);
     181        $app->logMsg(sprintf('ftruncate failed on log file %s', $app->getParam('log_directory') . '/' . $log_file), LOG_WARNING, __FILE__, __LINE__);
    178182        return false;
    179183    } else {
    180         App::raiseMsg(sprintf(_("Log file %s has been cleared."), $log_file), MSG_NOTICE, __FILE__, __LINE__);
    181         App::logMsg(sprintf('Log file %s has been cleared', $log_file), LOG_INFO, __FILE__, __LINE__);
     184        $app->raiseMsg(sprintf(_("Log file %s has been cleared."), $log_file), MSG_NOTICE, __FILE__, __LINE__);
     185        $app->logMsg(sprintf('Log file %s has been cleared', $log_file), LOG_INFO, __FILE__, __LINE__);
    182186        return true;
    183187    }
     
    186190function archiveLog($log_file)
    187191{
     192    $app =& App::getInstance();
     193
    188194    $old_file_name = $log_file;
    189195    $new_file_name = $log_file . '__' . date('Y-m-d');
    190     If (!is_writable(App::getParam('log_directory') . '')) {
    191         App::raiseMsg(sprintf('Cannot archive log, log directory not writable: %s', App::getParam('log_directory')), MSG_WARNING, __FILE__, __LINE__);
    192         App::logMsg(sprintf('Cannot archive log, log directory not writable: %s', App::getParam('log_directory')), LOG_WARNING, __FILE__, __LINE__);
    193         return false;
    194     }
    195     If (!copy(App::getParam('log_directory') . '/' . $old_file_name, App::getParam('log_directory') . '/' . $new_file_name)) {
    196         App::raiseMsg(sprintf(_("Cannot archive log, copying old log file failed."), null), MSG_WARNING, __FILE__, __LINE__);
    197         App::logMsg(sprintf('Cannot archive log, copying old log file failed.', null), LOG_WARNING, __FILE__, __LINE__);
    198         return false;
    199     }
    200 
    201     App::raiseMsg(sprintf(_("Log file %s has been archived to %s."), $old_file_name, $new_file_name), MSG_NOTICE, __FILE__, __LINE__);
    202     App::logMsg(sprintf('Log file %s has been archived to %s.', $old_file_name, $new_file_name), LOG_NOTICE, __FILE__, __LINE__);
     196    If (!is_writable($app->getParam('log_directory') . '')) {
     197        $app->raiseMsg(sprintf('Cannot archive log, log directory not writable: %s', $app->getParam('log_directory')), MSG_WARNING, __FILE__, __LINE__);
     198        $app->logMsg(sprintf('Cannot archive log, log directory not writable: %s', $app->getParam('log_directory')), LOG_WARNING, __FILE__, __LINE__);
     199        return false;
     200    }
     201    If (!copy($app->getParam('log_directory') . '/' . $old_file_name, $app->getParam('log_directory') . '/' . $new_file_name)) {
     202        $app->raiseMsg(sprintf(_("Cannot archive log, copying old log file failed."), null), MSG_WARNING, __FILE__, __LINE__);
     203        $app->logMsg(sprintf('Cannot archive log, copying old log file failed.', null), LOG_WARNING, __FILE__, __LINE__);
     204        return false;
     205    }
     206
     207    $app->raiseMsg(sprintf(_("Log file %s has been archived to %s."), $old_file_name, $new_file_name), MSG_NOTICE, __FILE__, __LINE__);
     208    $app->logMsg(sprintf('Log file %s has been archived to %s.', $old_file_name, $new_file_name), LOG_NOTICE, __FILE__, __LINE__);
    203209    return true;
    204210}
     
    206212function printLog($log_file)
    207213{
    208     if (!is_file(App::getParam('log_directory') . '/' . $log_file)) {
    209         App::raiseMsg(sprintf(_("Log file %s not found."), $log_file), MSG_WARNING, __FILE__, __LINE__);
    210         App::logMsg(sprintf('Log file %s not found.', App::getParam('log_directory') . '/' . $log_file), LOG_WARNING, __FILE__, __LINE__);
    211         return false;
    212     }
    213 
    214     readfile(App::getParam('log_directory') . '/' . $log_file);
     214    $app =& App::getInstance();
     215
     216    if (!is_file($app->getParam('log_directory') . '/' . $log_file)) {
     217        $app->raiseMsg(sprintf(_("Log file %s not found."), $log_file), MSG_WARNING, __FILE__, __LINE__);
     218        $app->logMsg(sprintf('Log file %s not found.', $app->getParam('log_directory') . '/' . $log_file), LOG_WARNING, __FILE__, __LINE__);
     219        return false;
     220    }
     221
     222    readfile($app->getParam('log_directory') . '/' . $log_file);
    215223}
    216224
    217225function &getLog($log_file, $search_query='')
    218226{
    219     if (!is_file(App::getParam('log_directory') . '/' . $log_file)) {
    220         App::raiseMsg(sprintf(_("Log file %s not found."), $log_file), MSG_WARNING, __FILE__, __LINE__);
    221         App::logMsg(sprintf('Log file %s not found.', App::getParam('log_directory') . '/' . $log_file), LOG_WARNING, __FILE__, __LINE__);
    222         return false;
    223     }
    224     $log = file(App::getParam('log_directory') . '/' . $log_file);
     227    $app =& App::getInstance();
     228
     229    if (!is_file($app->getParam('log_directory') . '/' . $log_file)) {
     230        $app->raiseMsg(sprintf(_("Log file %s not found."), $log_file), MSG_WARNING, __FILE__, __LINE__);
     231        $app->logMsg(sprintf('Log file %s not found.', $app->getParam('log_directory') . '/' . $log_file), LOG_WARNING, __FILE__, __LINE__);
     232        return false;
     233    }
     234    $log = file($app->getParam('log_directory') . '/' . $log_file);
    225235
    226236    if ('' != trim($search_query)) {
     
    237247{
    238248    global $valid_file_extensions;
     249    $app =& App::getInstance();
    239250
    240251    // Get a list of all files in the log directory.
    241     $dir_handle = opendir(App::getParam('log_directory'));
     252    $dir_handle = opendir($app->getParam('log_directory'));
    242253    $list = array();
    243254    while ($dir_handle && ($file = readdir($dir_handle)) !== false) {
    244         if (!preg_match('/^\./', $file) && is_file(App::getParam('log_directory') . '/' . $file) && in_array(strtolower(Upload::getFilenameExtension($file)), $valid_file_extensions)) {
     255        if (!preg_match('/^\./', $file) && is_file($app->getParam('log_directory') . '/' . $file) && in_array(strtolower(Upload::getFilenameExtension($file)), $valid_file_extensions)) {
    245256            $list[] = array(
    246257                'filename' => $file,
    247                 'filesize' => filesize(App::getParam('log_directory') . '/' . $file),
    248                 'modified' => filemtime(App::getParam('log_directory') . '/' . $file),
     258                'filesize' => filesize($app->getParam('log_directory') . '/' . $file),
     259                'modified' => filemtime($app->getParam('log_directory') . '/' . $file),
    249260            );
    250261        }
  • branches/2.0singleton/services/password.php

    r42 r129  
    2727if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) {
    2828    // We remember which page we came from so we can go back there.
    29     App::setBoomerangURL($_SERVER['HTTP_REFERER'], 'admin_password');
     29    $app->setBoomerangURL($_SERVER['HTTP_REFERER'], 'admin_password');
    3030}
    31 App::sslOn();
     31$app->sslOn();
    3232
    3333switch (getFormData('op')) {
     
    5050    if (!$fv->anyErrors() && false === $auth->authenticate($auth->getVal('username'), $frm['oldpassword'])) {
    5151        $fv->addError('oldpassword', _("Your <strong>Old password</strong> failed authentication."));
    52         App::logMsg(sprintf(_("Password change failed for %s, using (md5ed) password: %s"), $auth->getVal('username'), md5($frm['oldpassword'])), LOG_NOTICE, __FILE__, __LINE__);
     52        $app->logMsg(sprintf(_("Password change failed for %s, using (md5ed) password: %s"), $auth->getVal('username'), md5($frm['oldpassword'])), LOG_NOTICE, __FILE__, __LINE__);
    5353    }
    5454
    5555    if (!$fv->anyErrors()) {
    5656        $auth->setPassword(null, $frm['newpassword']);
    57         App::logMsg(sprintf(_("Password change successful for %s"), $auth->getVal('username')), LOG_INFO, __FILE__, __LINE__);
    58         App::raiseMsg(sprintf(_("Password change successful for %s"), $auth->getVal('username')), MSG_SUCCESS, __FILE__, __LINE__);
    59         App::dieBoomerangURL('admin_password');
     57        $app->logMsg(sprintf(_("Password change successful for %s"), $auth->getVal('username')), LOG_INFO, __FILE__, __LINE__);
     58        $app->raiseMsg(sprintf(_("Password change successful for %s"), $auth->getVal('username')), MSG_SUCCESS, __FILE__, __LINE__);
     59        $app->dieBoomerangURL('admin_password');
    6060    }
    6161    break;
  • branches/2.0singleton/services/versions.php

    r42 r129  
    88
    99$auth->requireLogin();
    10 App::sslOn();
     10$app->sslOn();
    1111
    1212require_once 'codebase/lib/RecordVersion.inc.php';
     
    2020
    2121// Query arguments to retain their values between page requests.
    22 App::carryQuery('record_table');
    23 App::carryQuery('record_key');
    24 App::carryQuery('record_val');
    25 App::carryQuery('version_title');
     22$app->carryQuery('record_table');
     23$app->carryQuery('record_key');
     24$app->carryQuery('record_val');
     25$app->carryQuery('version_title');
    2626
    2727// Titles and navigation header.
     
    3939
    4040if ('' == $version_id && ('' == $record_table || '' == $record_key || '' == $record_val)) {
    41     App::raiseMsg(_("Record not specified for versioning."), MSG_WARNING, __FILE__, __LINE__);
    42     App::logMsg('Record not specified for versioning.', LOG_WARNING, __FILE__, __LINE__);
    43     App::dieBoomerangURL();
     41    $app->raiseMsg(_("Record not specified for versioning."), MSG_WARNING, __FILE__, __LINE__);
     42    $app->logMsg('Record not specified for versioning.', LOG_WARNING, __FILE__, __LINE__);
     43    $app->dieBoomerangURL();
    4444}
    4545
    4646if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) {
    4747    // We remember which page we came from so we can go back there.
    48     App::setBoomerangURL($_SERVER['HTTP_REFERER'], 'versions');
     48    $app->setBoomerangURL($_SERVER['HTTP_REFERER'], 'versions');
    4949}
    5050
     
    5353
    5454case _("Cancel") :
    55     App::dieBoomerangURL('versions', false);
     55    $app->dieBoomerangURL('versions', false);
    5656    break;
    5757
     
    6868    $current = $version->getCurrent($record_table, $record_key, $record_val);
    6969    if (serialize($data) == serialize($current)) {
    70         App::raiseMsg(sprintf(_("Version <strong>%s</strong> is identical to the current record"), $version_id), MSG_NOTICE, __FILE__, __LINE__);
     70        $app->raiseMsg(sprintf(_("Version <strong>%s</strong> is identical to the current record"), $version_id), MSG_NOTICE, __FILE__, __LINE__);
    7171    }
    7272    $nav->addPage(sprintf(_("Difference between version %s (%s) and current record."), $version_id, $versionrecord['version_datetime']));
     
    8686        // Create version of this restored record as the "current" version.
    8787        $version->create($record_table, $record_key, $record_val, $v['version_title']);
    88         App::raiseMsg(sprintf(_("The record <strong>%s</strong> has been replaced with <strong>%s</strong> version <strong>%s</strong> from <strong>%s</strong>."), getFormData('version_title'), $v['version_title'], $version_id, $v['version_datetime']), MSG_SUCCESS, __FILE__, __LINE__);
    89         App::dieBoomerangURL('versions', array('break_list_cache'=>'true', false));
     88        $app->raiseMsg(sprintf(_("The record <strong>%s</strong> has been replaced with <strong>%s</strong> version <strong>%s</strong> from <strong>%s</strong>."), getFormData('version_title'), $v['version_title'], $version_id, $v['version_datetime']), MSG_SUCCESS, __FILE__, __LINE__);
     89        $app->dieBoomerangURL('versions', array('break_list_cache'=>'true', false));
    9090    } else {
    91         App::raiseMsg(_("Version restoration failed."), MSG_ERR, __FILE__, __LINE__);
    92         App::dieURL($_SERVER['PHP_SELF']);
     91        $app->raiseMsg(_("Version restoration failed."), MSG_ERR, __FILE__, __LINE__);
     92        $app->dieURL($_SERVER['PHP_SELF']);
    9393    }
    9494    break;
     
    101101        $main_template = 'versions_list.ihtml';
    102102    } else {
    103         App::raiseMsg(sprintf(_("No saved versions available for this record"), null), MSG_NOTICE, __FILE__, __LINE__);
    104         App::dieBoomerangURL('versions');
     103        $app->raiseMsg(sprintf(_("No saved versions available for this record"), null), MSG_NOTICE, __FILE__, __LINE__);
     104        $app->dieBoomerangURL('versions');
    105105    }
    106106}
  • branches/2.0singleton/tests/AppTest.php

    r42 r129  
    7979    {
    8080        $expected = 'My message';
    81         App::raiseMsg($expected, MSG_NOTICE, __FILE__, __LINE__);
     81        $app->raiseMsg($expected, MSG_NOTICE, __FILE__, __LINE__);
    8282        $msg = current($_SESSION[$this->App->app]['messages']);
    8383        $this->assertEquals($expected, $msg['message']);
     
    8787    {
    8888        ob_start();
    89         App::printraisedmessages();
     89        $app->printraisedmessages();
    9090        $result = ob_get_clean();
    9191        $this->assertContains('My message', $result, 'Raised message not found in output.');
     
    9595    {
    9696        $file = $this->App->getParam('log_directory') . '/' . $this->App->getParam('log_filename');
    97         App::logMsg('Test log message', LOG_DEBUG, __FILE__, __LINE__);
     97        $app->logMsg('Test log message', LOG_DEBUG, __FILE__, __LINE__);
    9898        if ($result = file($file)) {
    9999            $result = end($result);
     
    107107    {
    108108        $_GET['arg1'] = 'A';
    109         $result = App::ohref('/some/url.php', array('arg1'), true);
     109        $result = $app->ohref('/some/url.php', array('arg1'), true);
    110110        $this->assertContains(session_name(), $result, 'SSID not found in URL.');
    111111        $this->assertContains('arg1=A', $result, 'Argument not passed through.');
     
    115115    {
    116116        ob_start();
    117         App::printhiddensession();
     117        $app->printhiddensession();
    118118        $result = ob_get_clean();
    119119        $this->assertContains(session_name(), $result);
     
    122122//     function test_dieurl()
    123123//     {
    124 //         App::dieURL('/die/to/this/url.php');
     124//         $app->dieURL('/die/to/this/url.php');
    125125//     }
    126126//
Note: See TracChangeset for help on using the changeset viewer.