Changeset 136 for trunk/services


Ignore:
Timestamp:
Jun 3, 2006 7:47:48 PM (18 years ago)
Author:
scdev
Message:

Q - Merged branches/2.0singleton into trunk. Completed updating classes to use singleton methods. Implemented tests. Fixed some bugs. Changed some interfaces.

Location:
trunk/services
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/services/admins.php

    r111 r136  
    88
    99$auth->requireLogin();
    10 App::sslOn();
     10$app->sslOn();
    1111
    1212require_once 'codebase/lib/PageNumbers.inc.php';
    13 require_once 'codebase/lib/SessionCache.inc.php';
     13require_once 'codebase/lib/Cache.inc.php';
    1414require_once 'codebase/lib/FormValidator.inc.php';
    1515require_once 'codebase/lib/SortOrder.inc.php';
     
    2929// The object to validate form input.
    3030$fv = new FormValidator();
     31
     32$cache =& Cache::getInstance();
    3133
    3234// Instantiate a sorting object with the default sort and order. Add SQL for each column.
     
    5456
    5557// Search limiters retain their values between page requests.
    56 App::carryQuery('search_query');
     58$app->carryQuery('search_query');
    5759
    5860
     
    6466// allows us to remember which page we came from so we can go back there.
    6567if (getFormData('boomerang', false) && isset($_SERVER['HTTP_REFERER'])) {
    66     App::setBoomerangURL($_SERVER['HTTP_REFERER'], 'admins');
     68    $app->setBoomerangURL($_SERVER['HTTP_REFERER'], 'admins');
    6769}
    6870
    6971if (getFormData('break_list_cache', false)) {
    7072    // Break the cache because we are changing the list data.
    71     SessionCache::breakCache($_SERVER['PHP_SELF']);
     73    $cache->delete($_SERVER['PHP_SELF']);
    7274}
    7375
     
    9193case 'del' :
    9294    deleteRecord(getFormData('admin_id'));
    93     if (App::validBoomerangURL('admins')) {
     95    if ($app->validBoomerangURL('admins')) {
    9496        // Display boomerang page.
    95         App::dieBoomerangURL('admins');
     97        $app->dieBoomerangURL('admins');
    9698    }
    9799    // Display default page.
    98     App::dieURL($_SERVER['PHP_SELF']);
     100    $app->dieURL($_SERVER['PHP_SELF']);
    99101    break;
    100102
    101103case 'insert' :
    102104    if (getFormdata('cancel', false)) {
    103         if (App::validBoomerangURL('admins')) {
     105        if ($app->validBoomerangURL('admins')) {
    104106            // Display boomerang page.
    105             App::dieBoomerangURL('admins');
     107            $app->dieBoomerangURL('admins');
    106108        }
    107109        // Display default page.
    108         App::dieURL($_SERVER['PHP_SELF']);
     110        $app->dieURL($_SERVER['PHP_SELF']);
    109111    }
    110112    validateInput();
     
    118120        if (getFormdata('repeat', false)) {
    119121            // Display function again.
    120             App::dieURL($_SERVER['PHP_SELF'] . '?op=add');
    121         } else if (App::validBoomerangURL('admins')) {
     122            $app->dieURL($_SERVER['PHP_SELF'] . '?op=add');
     123        } else if ($app->validBoomerangURL('admins')) {
    122124            // Display boomerang page.
    123             App::dieBoomerangURL('admins');
     125            $app->dieBoomerangURL('admins');
    124126        }
    125127        // Display default page.
    126         App::dieURL($_SERVER['PHP_SELF']);
     128        $app->dieURL($_SERVER['PHP_SELF']);
    127129    }
    128130    break;
     
    130132case 'update' :
    131133    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'));
     134        $app->raiseMsg(_("Saved values have been reloaded."), MSG_NOTICE, __FILE__, __LINE__);
     135        $app->dieURL($_SERVER['PHP_SELF'] . '?op=edit&admin_id=' . getFormData('admin_id'));
    134136    }
    135137    if (getFormdata('cancel', false)) {
     
    137139        $lock->select('admin_tbl', 'admin_id', getFormData('admin_id'));
    138140        $lock->remove();
    139         if (App::validBoomerangURL('admins')) {
     141        if ($app->validBoomerangURL('admins')) {
    140142            // Display boomerang page.
    141             App::dieBoomerangURL('admins');
     143            $app->dieBoomerangURL('admins');
    142144        }
    143145        // Display default page.
    144         App::dieURL($_SERVER['PHP_SELF']);
     146        $app->dieURL($_SERVER['PHP_SELF']);
    145147    }
    146148    validateInput();
     
    154156        if (getFormdata('repeat', false)) {
    155157            // Display edit function with next available ID.
    156             $qid = DB::query("SELECT admin_id FROM admin_tbl WHERE admin_id > '" . DB::escapeString(getFormData('admin_id')) . "' ORDER BY admin_id ASC LIMIT 1");
     158            $qid = $db->query("SELECT admin_id FROM admin_tbl WHERE admin_id > '" . $db->escapeString(getFormData('admin_id')) . "' ORDER BY admin_id ASC LIMIT 1");
    157159            if (list($next_id) = mysql_fetch_row($qid)) {
    158                 App::dieURL($_SERVER['PHP_SELF'] . '?op=edit&admin_id=' . $next_id);
     160                $app->dieURL($_SERVER['PHP_SELF'] . '?op=edit&admin_id=' . $next_id);
    159161            } else {
    160                 App::raiseMsg(_("Cannot edit next, the end of the list was reached"), MSG_NOTICE, __FILE__, __LINE__);
     162                $app->raiseMsg(_("Cannot edit next, the end of the list was reached"), MSG_NOTICE, __FILE__, __LINE__);
    161163            }
    162         } else if (App::validBoomerangURL('admins')) {
     164        } else if ($app->validBoomerangURL('admins')) {
    163165            // Display boomerang page.
    164             App::dieBoomerangURL('admins');
     166            $app->dieBoomerangURL('admins');
    165167        }
    166168        // Display default page.
    167         App::dieURL($_SERVER['PHP_SELF']);
     169        $app->dieURL($_SERVER['PHP_SELF']);
    168170    }
    169171    break;
     
    258260{
    259261    global $lock;
    260 
     262    $app =& App::getInstance();
     263    $db =& DB::getInstance();
     264   
    261265    $lock->select('admin_tbl', 'admin_id', $id);
    262266    if ($lock->isLocked() && !$lock->isMine()) {
     
    265269
    266270    // Get the information for the form.
    267     $qid = DB::query("
     271    $qid = $db->query("
    268272        SELECT *
    269273        FROM admin_tbl
    270         WHERE admin_id = '" . DB::escapeString($id) . "'
     274        WHERE admin_id = '" . $db->escapeString($id) . "'
    271275    ");
    272276    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();
     277        $app->logMsg('Could not find record with admin_id: ' . $id, LOG_WARNING, __FILE__, __LINE__);
     278        $app->raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__);
     279        $app->dieBoomerangURL();
    276280    }
    277281
     
    313317{
    314318    global $auth, $lock;
    315 
     319    $app =& App::getInstance();
     320    $db =& DB::getInstance();
     321    $cache =& Cache::getInstance();
     322   
    316323    $lock->select('admin_tbl', 'admin_id', $id);
    317324    if ($lock->isLocked() && !$lock->isMine()) {
     
    320327
    321328    // Break the cache because we are changing the list data.
    322     SessionCache::breakCache($_SERVER['PHP_SELF']);
     329    $cache->delete($_SERVER['PHP_SELF']);
    323330
    324331    // Get the information for this object.
    325     $qid = DB::query("
     332    $qid = $db->query("
    326333        SELECT username, user_type from admin_tbl
    327         WHERE admin_id = '" . DB::escapeString($id) . "'
     334        WHERE admin_id = '" . $db->escapeString($id) . "'
    328335    ");
    329336    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();
     337        $app->logMsg('Could not find record with admin_id: ' . $id, LOG_WARNING, __FILE__, __LINE__);
     338        $app->raiseMsg(sprintf(_("The requested record %s could not be found."), $id), MSG_ERR, __FILE__, __LINE__);
     339        $app->dieBoomerangURL();
    333340    }
    334341
    335342    // Get the information for this object.
    336     $qid = DB::query("SELECT COUNT(*) from admin_tbl");
     343    $qid = $db->query("SELECT COUNT(*) from admin_tbl");
    337344    list($num_admins) = mysql_fetch_row($qid);
    338345    if ('root' == $user_type && 'root' != $auth->getVal('user_type')) {
    339346        // Only root users can delete root users!
    340         App::raiseMsg(_("You do not have clearance to delete a root administrator."), MSG_NOTICE, __FILE__, __LINE__);
     347        $app->raiseMsg(_("You do not have clearance to delete a root administrator."), MSG_NOTICE, __FILE__, __LINE__);
    341348    } else if ($num_admins <= 1) {
    342349        // 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__);
     350        $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__);
    344351    } else if ($auth->getVal('user_id') == $id) {
    345352        // Do not delete yourself!
    346         App::raiseMsg(_("You cannot delete yourself."), MSG_NOTICE, __FILE__, __LINE__);
     353        $app->raiseMsg(_("You cannot delete yourself."), MSG_NOTICE, __FILE__, __LINE__);
    347354    } else {
    348355        // Delete the record.
    349         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__);
     356        $db->query("DELETE FROM admin_tbl WHERE admin_id = '" . $db->escapeString($id) . "'");
     357        $app->raiseMsg(sprintf(_("The admin <strong>%s</strong> has been deleted."), $name), MSG_SUCCESS, __FILE__, __LINE__);
    351358    }
    352359
     
    358365{
    359366    global $auth;
    360 
     367    $app =& App::getInstance();
     368    $db =& DB::getInstance();
     369    $cache =& Cache::getInstance();
     370   
    361371    // Break the cache because we are changing the list data.
    362     SessionCache::breakCache($_SERVER['PHP_SELF']);
     372    $cache->delete($_SERVER['PHP_SELF']);
    363373
    364374    // Insert record data.
    365     DB::query("
     375    $db->query("
    366376        INSERT INTO admin_tbl (
    367377            username,
     
    373383            added_datetime
    374384        ) VALUES (
    375             '" . DB::escapeString($frm['username']) . "',
    376             '" . DB::escapeString($frm['first_name']) . "',
    377             '" . DB::escapeString($frm['last_name']) . "',
    378             '" . DB::escapeString($frm['email']) . "',
    379             '" . DB::escapeString($frm['user_type']) . "',
    380             '" . DB::escapeString($auth->getVal('user_id')) . "',
     385            '" . $db->escapeString($frm['username']) . "',
     386            '" . $db->escapeString($frm['first_name']) . "',
     387            '" . $db->escapeString($frm['last_name']) . "',
     388            '" . $db->escapeString($frm['email']) . "',
     389            '" . $db->escapeString($frm['user_type']) . "',
     390            '" . $db->escapeString($auth->getVal('user_id')) . "',
    381391            NOW()
    382392        )
    383393    ");
    384     $last_insert_id = mysql_insert_id(DB::getDBH());
     394    $last_insert_id = mysql_insert_id($db->getDBH());
    385395
    386396    // Set admin password.
     
    391401    $version->create('admin_tbl', 'admin_id', $last_insert_id, $frm['username']);
    392402
    393     App::raiseMsg(sprintf(_("The Admin <strong>%s</strong> has been added."), $frm['username']), MSG_SUCCESS, __FILE__, __LINE__);
     403    $app->raiseMsg(sprintf(_("The Admin <strong>%s</strong> has been added."), $frm['username']), MSG_SUCCESS, __FILE__, __LINE__);
    394404
    395405    return $last_insert_id;
     
    399409{
    400410    global $auth, $lock;
    401 
     411    $app =& App::getInstance();
     412    $db =& DB::getInstance();
     413    $cache =& Cache::getInstance();
     414   
    402415    $lock->select('admin_tbl', 'admin_id', $frm['admin_id']);
    403416    if ($lock->isLocked() && !$lock->isMine()) {
     
    406419
    407420    // Break the cache because we are changing the list data.
    408     SessionCache::breakCache($_SERVER['PHP_SELF']);
     421    $cache->delete($_SERVER['PHP_SELF']);
    409422
    410423    // If the userpass is left blank or with the filler **** characters, we don't want to update it.
     
    415428
    416429    // Update record data.
    417     DB::query("
     430    $db->query("
    418431        UPDATE admin_tbl SET
    419             username = '" . DB::escapeString($frm['username']) . "',
    420             first_name = '" . DB::escapeString($frm['first_name']) . "',
    421             last_name = '" . DB::escapeString($frm['last_name']) . "',
    422             email = '" . DB::escapeString($frm['email']) . "',
    423             user_type = '" . DB::escapeString($frm['user_type']) . "',
    424             modified_by_user_id = '" . DB::escapeString($auth->getVal('user_id')) . "',
     432            username = '" . $db->escapeString($frm['username']) . "',
     433            first_name = '" . $db->escapeString($frm['first_name']) . "',
     434            last_name = '" . $db->escapeString($frm['last_name']) . "',
     435            email = '" . $db->escapeString($frm['email']) . "',
     436            user_type = '" . $db->escapeString($frm['user_type']) . "',
     437            modified_by_user_id = '" . $db->escapeString($auth->getVal('user_id')) . "',
    425438            modified_datetime = NOW()
    426         WHERE admin_id = '" . DB::escapeString($frm['admin_id']) . "'
     439        WHERE admin_id = '" . $db->escapeString($frm['admin_id']) . "'
    427440    ");
    428441
     
    431444    $version->create('admin_tbl', 'admin_id', $frm['admin_id'], $frm['username']);
    432445
    433     App::raiseMsg(sprintf(_("The Admin <strong>%s</strong> has been updated."), $frm['username']), MSG_SUCCESS, __FILE__, __LINE__);
     446    $app->raiseMsg(sprintf(_("The Admin <strong>%s</strong> has been updated."), $frm['username']), MSG_SUCCESS, __FILE__, __LINE__);
    434447
    435448    // Unlock record.
     
    441454    global $page;
    442455    global $so;
    443 
     456    $db =& DB::getInstance();
     457    $prefs =& Prefs::getInstance();
     458    $cache =& Cache::getInstance();
     459   
    444460    $where_clause = '';
    445461
     
    450466            $where_clause .= (empty($where_clause) ? 'WHERE' : 'AND') . "
    451467                (
    452                     admin_tbl.username LIKE '%" . DB::escapeString($qry_words[$i]) . "%'
    453                     OR admin_tbl.first_name LIKE '%" . DB::escapeString($qry_words[$i]) . "%'
    454                     OR admin_tbl.last_name LIKE '%" . DB::escapeString($qry_words[$i]) . "%'
    455                     OR admin_tbl.email LIKE '%" . DB::escapeString($qry_words[$i]) . "%'
     468                    admin_tbl.username LIKE '%" . $db->escapeString($qry_words[$i]) . "%'
     469                    OR admin_tbl.first_name LIKE '%" . $db->escapeString($qry_words[$i]) . "%'
     470                    OR admin_tbl.last_name LIKE '%" . $db->escapeString($qry_words[$i]) . "%'
     471                    OR admin_tbl.email LIKE '%" . $db->escapeString($qry_words[$i]) . "%'
    456472                )
    457473            ";
     
    460476
    461477    // Count the total number of records so we can do something about the page numbers.
    462     $qid = DB::query("
     478    $qid = $db->query("
    463479        SELECT COUNT(*)
    464480        FROM admin_tbl
     
    491507    // without knowing the hash.
    492508    $cache_hash = md5($sql . '|' . $page->total_items);
    493     if (Prefs::getValue('cache_hash', $_SERVER['PHP_SELF']) != $cache_hash) {
    494         SessionCache::breakCache($_SERVER['PHP_SELF']);
    495         Prefs::setValue('cache_hash', $cache_hash, $_SERVER['PHP_SELF']);
    496     }
    497 
    498     if (SessionCache::isCached($_SERVER['PHP_SELF']) && false) {
     509    if ($prefs->get('cache_hash', $_SERVER['PHP_SELF']) != $cache_hash) {
     510        $cache->delete($_SERVER['PHP_SELF']);
     511        $prefs->set('cache_hash', $cache_hash, $_SERVER['PHP_SELF']);
     512    }
     513
     514    if ($cache->exists($_SERVER['PHP_SELF']) && false) {
    499515        // Get the cached results.
    500         $list = SessionCache::getCache($_SERVER['PHP_SELF']);
     516        $list = $cache->get($_SERVER['PHP_SELF']);
    501517    } else {
    502518        // If the list is not already cached, query now.
    503         $qid = DB::query($sql);
     519        $qid = $db->query($sql);
    504520        // Fill an array with the items for this page.
    505521        while ($row = mysql_fetch_assoc($qid)) {
     
    509525        if (isset($list) && !empty($list)) {
    510526            // Cache the results.
    511             SessionCache::putCache($list, $_SERVER['PHP_SELF']);
     527            $cache->set($list, $_SERVER['PHP_SELF']);
    512528        }
    513529    }
  • trunk/services/lock.php

    r53 r136  
    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
  • trunk/services/login.php

    r103 r136  
    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}
  • trunk/services/logout.php

    r108 r136  
    55 */
    66
    7 if (is_a($auth, 'Auth_SQL')) {
     7if (isset($auth) && method_exists($auth, 'getVal')) {
    88    // Delete the current user's record locks.
    99    require_once 'codebase/lib/RecordLock.inc.php';
     
    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?>
  • trunk/services/logs.php

    r42 r136  
    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');
    42 Prefs::setValue('log_file', getFormData('log'), 'logs_module');
     41$prefs =& Prefs::getInstance();
     42$prefs->setDefault('log_file', $app->getParam('log_filename'), 'logs_module');
     43$prefs->set('log_file', getFormData('log'), 'logs_module');
    4344
    4445// Titles and navigation header.
    45 $nav->addPage(sprintf(_("Viewing log: <em>%s</em>"), Prefs::getValue('log_file', 'logs_module')), '/admin/logs.php');
     46$nav->addPage(sprintf(_("Viewing log: <em>%s</em>"), $prefs->get('log_file', 'logs_module')), '/admin/logs.php');
    4647
    4748/******************************************************************************
     
    5657case 'delete' :
    5758//     $auth->requireAccessClearance(ZONE_ADMIN_APPLOG_FUNC_RESET);
    58     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    deleteLog($prefs->get('log_file', 'logs_module'));
     60    $prefs->set('log_file', $app->getParam('log_filename'), 'logs_module');
     61    if ($app->validBoomerangURL('app_log')) {
    6162        // Display boomerang page.
    62         App::dieBoomerangURL('app_log');
     63        $app->dieBoomerangURL('app_log');
    6364    }
    6465    // Display default page.
    65     App::dieURL($_SERVER['PHP_SELF']);
     66    $app->dieURL($_SERVER['PHP_SELF']);
    6667    break;
    6768
    6869case 'clear' :
    6970//     $auth->requireAccessClearance(ZONE_ADMIN_APPLOG_FUNC_RESET);
    70     clearLog(Prefs::getValue('log_file', 'logs_module'));
    71     if (App::validBoomerangURL('app_log')) {
     71    clearLog($prefs->get('log_file', 'logs_module'));
     72    if ($app->validBoomerangURL('app_log')) {
    7273        // Display boomerang page.
    73         App::dieBoomerangURL('app_log');
     74        $app->dieBoomerangURL('app_log');
    7475    }
    7576    // Display default page.
    76     App::dieURL($_SERVER['PHP_SELF']);
     77    $app->dieURL($_SERVER['PHP_SELF']);
    7778    break;
    7879
    7980case 'archive' :
    8081//     $auth->requireAccessClearance(ZONE_ADMIN_APPLOG_FUNC_RESET);
    81     if (archiveLog(Prefs::getValue('log_file', 'logs_module'))) {
     82    if (archiveLog($prefs->get('log_file', 'logs_module'))) {
    8283        // Now flush current log.
    83         App::dieURL($_SERVER['PHP_SELF'] . '?op=clear');
    84     }
    85     if (App::validBoomerangURL('app_log')) {
     84        $app->dieURL($_SERVER['PHP_SELF'] . '?op=clear');
     85    }
     86    if ($app->validBoomerangURL('app_log')) {
    8687        // Display boomerang page.
    87         App::dieBoomerangURL('app_log');
     88        $app->dieBoomerangURL('app_log');
    8889    }
    8990    // Display default page.
    90     App::dieURL($_SERVER['PHP_SELF']);
     91    $app->dieURL($_SERVER['PHP_SELF']);
    9192    break;
    9293
     
    9798case 'download' :
    9899    header('Content-Type: application/octet-stream');
    99     header(sprintf('Content-Disposition: attachment; filename=%s.txt', Prefs::getValue('log_file', 'logs_module')));
    100     printLog(Prefs::getValue('log_file', 'logs_module'));
     100    header(sprintf('Content-Disposition: attachment; filename=%s.txt', $prefs->get('log_file', 'logs_module')));
     101    printLog($prefs->get('log_file', 'logs_module'));
    101102    die;
    102103    break;
    103104
    104105default :
    105     $list =& getLog(Prefs::getValue('log_file', 'logs_module'), getFormData('search_query'));
     106    $list =& getLog($prefs->get('log_file', 'logs_module'), getFormData('search_query'));
    106107    $main_template = 'log_list.ihtml';
    107108    break;
     
    125126include 'header.ihtml';
    126127if ('output' == $main_template) {
    127     printLog(Prefs::getValue('log_file', 'logs_module'));
     128    printLog($prefs->get('log_file', 'logs_module'));
    128129} else {
    129130    include 'codebase/services/templates/' . $main_template;
     
    138139function deleteLog($log_file)
    139140{
    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__);
     141    $app =& App::getInstance();
     142
     143    if (!file_exists($app->getParam('log_directory') . '/' . $log_file)) {
     144        $app->raiseMsg(sprintf(_("Log file %s does not exist."), $log_file), MSG_NOTICE, __FILE__, __LINE__);
     145        $app->logMsg(sprintf('Cannot delete nonexistent log file %s', $app->getParam('log_directory') . '/' . $log_file), LOG_INFO, __FILE__, __LINE__);
     146        return false;
     147    }
     148
     149    if (!is_writable($app->getParam('log_directory') . '/' . $log_file) && !is_writable($app->getParam('log_directory'))) {
     150        $app->raiseMsg(sprintf(_("Log file %s could not be deleted."), $log_file), MSG_NOTICE, __FILE__, __LINE__);
     151        $app->logMsg(sprintf('Cannot delete log file %s, not writable.', $app->getParam('log_directory') . '/' . $log_file), LOG_INFO, __FILE__, __LINE__);
     152        return false;
     153    }
     154
     155    if (unlink($app->getParam('log_directory') . '/' . $log_file)) {
     156        $app->raiseMsg(sprintf(_("Log file %s has been deleted."), $log_file), MSG_NOTICE, __FILE__, __LINE__);
     157        $app->logMsg(sprintf('Log file %s has been deleted', $log_file), LOG_INFO, __FILE__, __LINE__);
    155158        return true;
    156159    } 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__);
     160        $app->raiseMsg(sprintf(_("Log file %s could not be deleted."), $log_file), MSG_WARNING, __FILE__, __LINE__);
     161        $app->logMsg(sprintf('unlink failed on log file %s', $app->getParam('log_directory') . '/' . $log_file), LOG_WARNING, __FILE__, __LINE__);
    159162        return false;
    160163    }
     
    163166function clearLog($log_file)
    164167{
    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__);
     168    $app =& App::getInstance();
     169
     170    if (!$fp = fopen($app->getParam('log_directory') . '/' . $log_file, 'r+')) {
     171        $app->raiseMsg(sprintf(_("Log file %s could not be opened."), $log_file), MSG_NOTICE, __FILE__, __LINE__);
     172        $app->logMsg(sprintf('fopen failed on log file %s', $app->getParam('log_directory') . '/' . $log_file), LOG_INFO, __FILE__, __LINE__);
    168173        return false;
    169174    }
     
    174179    fclose($fp);
    175180    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__);
     181        $app->raiseMsg(sprintf(_("Log file %s could not be cleared."), $log_file), MSG_WARNING, __FILE__, __LINE__);
     182        $app->logMsg(sprintf('ftruncate failed on log file %s', $app->getParam('log_directory') . '/' . $log_file), LOG_WARNING, __FILE__, __LINE__);
    178183        return false;
    179184    } 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__);
     185        $app->raiseMsg(sprintf(_("Log file %s has been cleared."), $log_file), MSG_NOTICE, __FILE__, __LINE__);
     186        $app->logMsg(sprintf('Log file %s has been cleared', $log_file), LOG_INFO, __FILE__, __LINE__);
    182187        return true;
    183188    }
     
    186191function archiveLog($log_file)
    187192{
     193    $app =& App::getInstance();
     194
    188195    $old_file_name = $log_file;
    189196    $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__);
     197    If (!is_writable($app->getParam('log_directory') . '')) {
     198        $app->raiseMsg(sprintf('Cannot archive log, log directory not writable: %s', $app->getParam('log_directory')), MSG_WARNING, __FILE__, __LINE__);
     199        $app->logMsg(sprintf('Cannot archive log, log directory not writable: %s', $app->getParam('log_directory')), LOG_WARNING, __FILE__, __LINE__);
     200        return false;
     201    }
     202    If (!copy($app->getParam('log_directory') . '/' . $old_file_name, $app->getParam('log_directory') . '/' . $new_file_name)) {
     203        $app->raiseMsg(sprintf(_("Cannot archive log, copying old log file failed."), null), MSG_WARNING, __FILE__, __LINE__);
     204        $app->logMsg(sprintf('Cannot archive log, copying old log file failed.', null), LOG_WARNING, __FILE__, __LINE__);
     205        return false;
     206    }
     207
     208    $app->raiseMsg(sprintf(_("Log file %s has been archived to %s."), $old_file_name, $new_file_name), MSG_NOTICE, __FILE__, __LINE__);
     209    $app->logMsg(sprintf('Log file %s has been archived to %s.', $old_file_name, $new_file_name), LOG_NOTICE, __FILE__, __LINE__);
    203210    return true;
    204211}
     
    206213function printLog($log_file)
    207214{
    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);
     215    $app =& App::getInstance();
     216
     217    if (!is_file($app->getParam('log_directory') . '/' . $log_file)) {
     218        $app->raiseMsg(sprintf(_("Log file %s not found."), $log_file), MSG_WARNING, __FILE__, __LINE__);
     219        $app->logMsg(sprintf('Log file %s not found.', $app->getParam('log_directory') . '/' . $log_file), LOG_WARNING, __FILE__, __LINE__);
     220        return false;
     221    }
     222
     223    readfile($app->getParam('log_directory') . '/' . $log_file);
    215224}
    216225
    217226function &getLog($log_file, $search_query='')
    218227{
    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);
     228    $app =& App::getInstance();
     229
     230    if (!is_file($app->getParam('log_directory') . '/' . $log_file)) {
     231        $app->raiseMsg(sprintf(_("Log file %s not found."), $log_file), MSG_WARNING, __FILE__, __LINE__);
     232        $app->logMsg(sprintf('Log file %s not found.', $app->getParam('log_directory') . '/' . $log_file), LOG_WARNING, __FILE__, __LINE__);
     233        return false;
     234    }
     235    $log = file($app->getParam('log_directory') . '/' . $log_file);
    225236
    226237    if ('' != trim($search_query)) {
     
    237248{
    238249    global $valid_file_extensions;
     250    $app =& App::getInstance();
    239251
    240252    // Get a list of all files in the log directory.
    241     $dir_handle = opendir(App::getParam('log_directory'));
     253    $dir_handle = opendir($app->getParam('log_directory'));
    242254    $list = array();
    243255    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)) {
     256        if (!preg_match('/^\./', $file) && is_file($app->getParam('log_directory') . '/' . $file) && in_array(strtolower(Upload::getFilenameExtension($file)), $valid_file_extensions)) {
    245257            $list[] = array(
    246258                'filename' => $file,
    247                 'filesize' => filesize(App::getParam('log_directory') . '/' . $file),
    248                 'modified' => filemtime(App::getParam('log_directory') . '/' . $file),
     259                'filesize' => filesize($app->getParam('log_directory') . '/' . $file),
     260                'modified' => filemtime($app->getParam('log_directory') . '/' . $file),
    249261            );
    250262        }
  • trunk/services/password.php

    r42 r136  
    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;
  • trunk/services/templates/admin_form.ihtml

    r121 r136  
    22
    33<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    4 <?php App::printHiddenSession(); ?>
     4<?php $app->printHiddenSession(); ?>
    55<input type="hidden" name="op" value="<?php echo $frm['new_op']; ?>" />
    66<input type="hidden" name="admin_id" value="<?php echo $frm['admin_id']; ?>" />
  • trunk/services/templates/admin_list.ihtml

    r124 r136  
    22<?php $fv->printErrorMessages(); ?>
    33<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    4 <?php App::printHiddenSession(false); ?>
     4<?php $app->printHiddenSession(false); ?>
    55<div id="commandbox">
    6     <span class="sc-nowrap commandtext"><a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=add'); ?>"><?php echo _("Add administrator"); ?></a></span>
     6    <span class="sc-nowrap commandtext"><a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?op=add'); ?>"><?php echo _("Add administrator"); ?></a></span>
    77    <br />
    88
     
    3131    <?php for ($i = 0; $i <= $page->last_item - $page->first_item && $page->total_items > 0; $i++) { ?>
    3232    <tr>
    33         <td class="sc-padleft sc-nowrap"><a title="<?php printf(_("Edit %s"), oTxt($list[$i]['username'])) ?>" href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=edit&admin_id=' . $list[$i]['admin_id']); ?>"><img src="/admin/_widgets/edit.gif" alt="Edit" width="14" height="18" border="0"></a> &nbsp;</td>
    34         <td class="sc-padleft sc-nowrap"><a title="<?php printf(_("Versions of %s"), oTxt($list[$i]['username'])) ?>" href="<?php echo App::oHREF('/admin/versions.php?record_table=admin_tbl&record_key=admin_id&boomerang=true&record_val=' . $list[$i]['admin_id']); ?>"><img src="/admin/_widgets/subcategory.gif" alt="" width="18" height="14" border="0" /></a> &nbsp;</td>
     33        <td class="sc-padleft sc-nowrap"><a title="<?php printf(_("Edit %s"), oTxt($list[$i]['username'])) ?>" href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?op=edit&admin_id=' . $list[$i]['admin_id']); ?>"><img src="/admin/_widgets/edit.gif" alt="Edit" width="14" height="18" border="0"></a> &nbsp;</td>
     34        <td class="sc-padleft sc-nowrap"><a title="<?php printf(_("Versions of %s"), oTxt($list[$i]['username'])) ?>" href="<?php echo $app->oHREF('/admin/versions.php?record_table=admin_tbl&record_key=admin_id&boomerang=true&record_val=' . $list[$i]['admin_id']); ?>"><img src="/admin/_widgets/subcategory.gif" alt="" width="18" height="14" border="0" /></a> &nbsp;</td>
    3535        <td class="sc-nowrap"><?php echo oTxt($list[$i]['admin_id'], true); ?> &nbsp;</td>
    3636        <td class="sc-nowrap"><?php echo oTxt($list[$i]['username'], true); ?> &nbsp;</td>
     
    4040        <td class="sc-nowrap"><?php
    4141            if ($auth->isLoggedIn($list[$i]['admin_id'])) {
    42                 ?><strong><?php echo date(App::getParam('date_format'), strtotime($list[$i]['last_login_datetime'])) ?></strong><?php
     42                ?><strong><?php echo date($app->getParam('date_format'), strtotime($list[$i]['last_login_datetime'])) ?></strong><?php
    4343            } else {
    44                 echo '0000-00-00 00:00:00' == $list[$i]['last_login_datetime'] ? '' : date(App::getParam('date_format'), strtotime($list[$i]['last_login_datetime']));
     44                echo '0000-00-00 00:00:00' == $list[$i]['last_login_datetime'] ? '' : date($app->getParam('date_format'), strtotime($list[$i]['last_login_datetime']));
    4545            }
    4646        ?> &nbsp;</td>
    4747        <td class="sc-nowrap"><?php echo gethostbyaddr($list[$i]['last_login_ip']); ?> &nbsp;</td>
    48         <td class="sc-nowrap"><?php echo '0000-00-00 00:00:00' == $list[$i]['added_datetime'] ? '' : date(App::getParam('date_format'), strtotime($list[$i]['added_datetime'])); ?> &nbsp;</td>
     48        <td class="sc-nowrap"><?php echo '0000-00-00 00:00:00' == $list[$i]['added_datetime'] ? '' : date($app->getParam('date_format'), strtotime($list[$i]['added_datetime'])); ?> &nbsp;</td>
    4949        <td class="sc-nowrap"><?php echo oTxt($list[$i]['added_admin_username'], true); ?> &nbsp;</td>
    50         <td class="sc-nowrap"><?php echo '0000-00-00 00:00:00' == $list[$i]['modified_datetime'] ? '' : date(App::getParam('date_format'), strtotime($list[$i]['modified_datetime'])); ?> &nbsp;</td>
    51         <td class="sc-padleft sc-nowrap" align="right"><a title="<?php printf(_("Delete %s"), oTxt($list[$i]['username'])) ?>" href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . "?op=del&admin_id=" . $list[$i]['admin_id']); ?>" onClick="javascript:return confirm('<?php printf(_("Are you sure you want to delete the record %s? This action is permanent and cannot be undone."), oTxt($list[$i]['username'])) ?>')"><img src="/admin/_widgets/delete.gif" alt="Delete" width="16" height="17" border="0"></a> &nbsp;</td>
     50        <td class="sc-nowrap"><?php echo '0000-00-00 00:00:00' == $list[$i]['modified_datetime'] ? '' : date($app->getParam('date_format'), strtotime($list[$i]['modified_datetime'])); ?> &nbsp;</td>
     51        <td class="sc-padleft sc-nowrap" align="right"><a title="<?php printf(_("Delete %s"), oTxt($list[$i]['username'])) ?>" href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . "?op=del&admin_id=" . $list[$i]['admin_id']); ?>" onClick="javascript:return confirm('<?php printf(_("Are you sure you want to delete the record %s? This action is permanent and cannot be undone."), oTxt($list[$i]['username'])) ?>')"><img src="/admin/_widgets/delete.gif" alt="Delete" width="16" height="17" border="0"></a> &nbsp;</td>
    5252    </tr>
    5353    <?php } ?>
  • trunk/services/templates/list_info.ihtml

    r121 r136  
    55    <span class="sc-nowrap commanditem commandtext">
    66        <?php printf(_("Listing <strong>%s-%s</strong> of <strong>%s</strong> results on <strong>%s</strong> pages"), (0==$page->total_items ? 0 : $page->first_item+1), (0==$page->total_items ? 0 : $page->last_item+1), $page->total_items, $page->total_pages) ?>
    7         &nbsp;&nbsp; <a href="<?php echo App::oHREF($_SERVER['PHP_SELF'], false); ?>"><?php echo _("List all"); ?></a>
     7        &nbsp;&nbsp; <a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'], false); ?>"><?php echo _("List all"); ?></a>
    88        &nbsp;&nbsp; <?php echo _("Per page"); ?>:&nbsp;<?php $page->printPerPageLinks() ?>
    99    </span>
  • trunk/services/templates/lock.ihtml

    r42 r136  
    55?>
    66<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    7     <?php App::printHiddenSession() ?>
     7    <?php $app->printHiddenSession() ?>
    88    <input type="hidden" name="lock_id" value="<?php echo $lock->getID(); ?>" />
    99
  • trunk/services/templates/log_list.ihtml

    r121 r136  
    11<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    2 <?php App::printHiddenSession(false); ?>
     2<?php $app->printHiddenSession(false); ?>
    33
    44<div id="commandbox">
     
    1010        <tr class="commandtext">
    1111            <td>
    12                 <?php if ($l['filename'] == Prefs::getValue('log_file', 'logs_module')) { ?>
     12                <?php if ($l['filename'] == $prefs->get('log_file', 'logs_module')) { ?>
    1313                    <span class="commanditem"><strong><?php echo sprintf(_("%s"), $l['filename']); ?></strong></span>
    1414                <?php } else { ?>
    15                     <span class="commanditem"><a href="<?php echo App::oHREF('/admin/logs.php?log=' . $l['filename']); ?>"><strong><?php echo sprintf(_("%s"), $l['filename']); ?></strong></a></span>
     15                    <span class="commanditem"><a href="<?php echo $app->oHREF('/admin/logs.php?log=' . $l['filename']); ?>"><strong><?php echo sprintf(_("%s"), $l['filename']); ?></strong></a></span>
    1616                <?php } ?>
    1717            </td>
    1818            <td>
    19                 <span class="commanditem"><em><?php echo sprintf(_("%01.1f KB, last modified %s"), ($l['filesize']/1024), date(App::getParam('date_format'), $l['modified'])); ?></em></span>
     19                <span class="commanditem"><em><?php echo sprintf(_("%01.1f KB, last modified %s"), ($l['filesize']/1024), date($app->getParam('date_format'), $l['modified'])); ?></em></span>
    2020            </td>
    2121            <td>
    22                 <?php if (!preg_match($no_download_files, $l['filename'])) { ?><span class="commanditem"><a href="<?php echo App::oHREF('/admin/logs.php?op=download&log=' . $l['filename']); ?>"><?php echo _("Download"); ?></a></span><?php } ?>
    23                 <?php if (!preg_match($no_archive_files, $l['filename'])) { ?><span class="commanditem"><a href="<?php echo App::oHREF('/admin/logs.php?op=archive&log=' . $l['filename']); ?>"><?php echo _("Archive"); ?></a></span><?php } ?>
    24                 <?php if (!preg_match($no_clear_files, $l['filename'])) { ?><span class="commanditem"><a href="<?php echo App::oHREF('/admin/logs.php?op=clear&log=' . $l['filename']); ?>" onClick="javascript:return confirm('<?php printf(_("Are you sure you want to clear the log file %s? This will empty this file of its contents. This action is not reversible."), $l['filename'])?>')"><?php echo _("Clear"); ?></a></span><?php } ?>
    25                 <?php if (!preg_match($no_delete_files, $l['filename'])) { ?><span class="commanditem"><a href="<?php echo App::oHREF('/admin/logs.php?op=delete&log=' . $l['filename']); ?>" onClick="javascript:return confirm('<?php printf(_("Are you sure you want to delete the log file %s? This will remove this log file permanently. This action is not reversible."), $l['filename'])?>')"><?php echo _("Delete"); ?></a></span><?php } ?>
     22                <?php if (!preg_match($no_download_files, $l['filename'])) { ?><span class="commanditem"><a href="<?php echo $app->oHREF('/admin/logs.php?op=download&log=' . $l['filename']); ?>"><?php echo _("Download"); ?></a></span><?php } ?>
     23                <?php if (!preg_match($no_archive_files, $l['filename'])) { ?><span class="commanditem"><a href="<?php echo $app->oHREF('/admin/logs.php?op=archive&log=' . $l['filename']); ?>"><?php echo _("Archive"); ?></a></span><?php } ?>
     24                <?php if (!preg_match($no_clear_files, $l['filename'])) { ?><span class="commanditem"><a href="<?php echo $app->oHREF('/admin/logs.php?op=clear&log=' . $l['filename']); ?>" onClick="javascript:return confirm('<?php printf(_("Are you sure you want to clear the log file %s? This will empty this file of its contents. This action is not reversible."), $l['filename'])?>')"><?php echo _("Clear"); ?></a></span><?php } ?>
     25                <?php if (!preg_match($no_delete_files, $l['filename'])) { ?><span class="commanditem"><a href="<?php echo $app->oHREF('/admin/logs.php?op=delete&log=' . $l['filename']); ?>" onClick="javascript:return confirm('<?php printf(_("Are you sure you want to delete the log file %s? This will remove this log file permanently. This action is not reversible."), $l['filename'])?>')"><?php echo _("Delete"); ?></a></span><?php } ?>
    2626            </td>
    2727        </tr><?php
  • trunk/services/templates/login_form.ihtml

    r121 r136  
    11<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    2 <?php App::printHiddenSession() ?>
     2<?php $app->printHiddenSession() ?>
    33<table>
    44    <tr>
  • trunk/services/templates/password.ihtml

    r121 r136  
    22
    33<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    4 <?php App::printHiddenSession() ?>
     4<?php $app->printHiddenSession() ?>
    55<input type="hidden" name="op" value="update_password" />
    66<table>
  • trunk/services/templates/versions_diff.ihtml

    r124 r136  
    11<div id="commandbox">
    22<?php if (!getFormData('current', false)) { ?>
    3     <span class="sc-nowrap commandtext"><a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=restore', array('version_id', 'version_title')); ?>"><?php echo _("Restore this saved version"); ?></a></span>
     3    <span class="sc-nowrap commandtext"><a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?op=restore', array('version_id', 'version_title')); ?>"><?php echo _("Restore this saved version"); ?></a></span>
    44<?php } else { ?>
    55    <span class="sc-nowrap commandtext">&nbsp;</span>
  • trunk/services/templates/versions_list.ihtml

    r124 r136  
    11<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    2 <?php App::printHiddenSession() ?>
     2<?php $app->printHiddenSession() ?>
    33<input type="submit" name="op" value="<?php echo _("Cancel"); ?>" />
    44<table class="list" border="0" cellspacing="0" cellpadding="4">
     
    1414<tr>
    1515    <?php if ($first) { ?>
    16     <td class="sc-padleft sc-nowrap">[<a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=view&current=true&version_id=' . $v['version_id']); ?>">view</a>]</td>
     16    <td class="sc-padleft sc-nowrap">[<a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?op=view&current=true&version_id=' . $v['version_id']); ?>">view</a>]</td>
    1717    <td class="sc-padleft sc-nowrap" colspan="2">(<?php echo _("Current record"); ?>)</td>
    1818    <?php } else { ?>
    19     <td class="sc-padleft sc-nowrap">[<a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=view&version_id=' . $v['version_id']); ?>">view</a>]</td>
    20     <td class="sc-padleft sc-nowrap">[<a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=diff&version_id=' . $v['version_id']); ?>">diff</a>]</td>
    21     <td class="sc-padleft sc-nowrap">[<a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=restore&version_id=' . $v['version_id']); ?>">restore</a>]</td>
     19    <td class="sc-padleft sc-nowrap">[<a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?op=view&version_id=' . $v['version_id']); ?>">view</a>]</td>
     20    <td class="sc-padleft sc-nowrap">[<a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?op=diff&version_id=' . $v['version_id']); ?>">diff</a>]</td>
     21    <td class="sc-padleft sc-nowrap">[<a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?op=restore&version_id=' . $v['version_id']); ?>">restore</a>]</td>
    2222    <?php } ?>
    2323    <td class="sc-padleft sc-nowrap"><?php echo $v['version_id']; ?></td>
  • trunk/services/templates/versions_view.ihtml

    r121 r136  
    11<div id="commandbox">
    22<?php if (!getFormData('current', false)) { ?>
    3     <span class="sc-nowrap commandtext"><a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=restore', array('version_id', 'version_title')); ?>"><?php echo _("Restore this saved version"); ?></a></span>
     3    <span class="sc-nowrap commandtext"><a href="<?php echo $app->oHREF($_SERVER['PHP_SELF'] . '?op=restore', array('version_id', 'version_title')); ?>"><?php echo _("Restore this saved version"); ?></a></span>
    44<?php } else { ?>
    55    <span class="sc-nowrap commandtext">&nbsp;</span>
  • trunk/services/versions.php

    r42 r136  
    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}
Note: See TracChangeset for help on using the changeset viewer.