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

finished /lib folder

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0singleton/lib/RecordLock.inc.php

    r111 r128  
    4848    function RecordLock($auth_object)
    4949    {
     50        $app =& App::getInstance();
     51
    5052        if (!is_a($auth_object, 'Auth_SQL')) {
    5153            trigger_error('Constructor not provided a valid Auth_SQL object.', E_USER_ERROR);
     
    5557
    5658        // Get create tables config from global context.
    57         if (!is_null(App::getParam('db_create_tables'))) {
    58             $this->setParam(array('create_table' => App::getParam('db_create_tables')));
     59        if (!is_null($app->getParam('db_create_tables'))) {
     60            $this->setParam(array('create_table' => $app->getParam('db_create_tables')));
    5961        }
    6062    }
     
    6971    function initDB($recreate_db=false)
    7072    {
     73        $app =& App::getInstance();
     74
    7175        static $_db_tested = false;
    7276
     
    7478            if ($recreate_db) {
    7579                DB::query("DROP TABLE IF EXISTS " . $this->getParam('db_table'));
    76                 App::logMsg(sprintf('Dropping and recreating table %s.', $this->getParam('db_table')), LOG_DEBUG, __FILE__, __LINE__);
     80                $app->logMsg(sprintf('Dropping and recreating table %s.', $this->getParam('db_table')), LOG_DEBUG, __FILE__, __LINE__);
    7781            }
    7882            DB::query("CREATE TABLE IF NOT EXISTS " . $this->getParam('db_table') . " (
     
    99103                'lock_datetime',
    100104            ), false, false)) {
    101                 App::logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), LOG_ALERT, __FILE__, __LINE__);
     105                $app->logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), LOG_ALERT, __FILE__, __LINE__);
    102106                trigger_error(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), E_USER_ERROR);
    103107            }
     
    128132    function getParam($param)
    129133    {
     134        $app =& App::getInstance();
     135
    130136        if (isset($this->_params[$param])) {
    131137            return $this->_params[$param];
    132138        } else {
    133             App::logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);
     139            $app->logMsg(sprintf('Parameter is not set: %s', $param), LOG_DEBUG, __FILE__, __LINE__);
    134140            return null;
    135141        }
     
    147153    function select($record_table_or_lock_id, $record_key=null, $record_val=null)
    148154    {
     155        $app =& App::getInstance();
     156
    149157        $this->initDB();
    150158
     
    168176        }
    169177        if ($this->data = mysql_fetch_assoc($qid)) {
    170             App::logMsg(sprintf('Selecting %slocked record: %s %s %s', ($this->data['set_by_admin_id'] == $this->_auth->getVal('user_id') ? 'self-' : ''), $record_table_or_lock_id, $record_key, $record_val), LOG_DEBUG, __FILE__, __LINE__);
     178            $app->logMsg(sprintf('Selecting %slocked record: %s %s %s', ($this->data['set_by_admin_id'] == $this->_auth->getVal('user_id') ? 'self-' : ''), $record_table_or_lock_id, $record_key, $record_val), LOG_DEBUG, __FILE__, __LINE__);
    171179            /// FIX ME: What if admin set lock, but public user is current lock user?
    172180            $this->data['editor'] = $this->_auth->getUsername($this->data['set_by_admin_id']);
    173181            return true;
    174182        } else {
    175             App::logMsg(sprintf('No locked record: %s %s %s', $record_table_or_lock_id, $record_key, $record_val), LOG_DEBUG, __FILE__, __LINE__);
     183            $app->logMsg(sprintf('No locked record: %s %s %s', $record_table_or_lock_id, $record_key, $record_val), LOG_DEBUG, __FILE__, __LINE__);
    176184            return false;
    177185        }
     
    266274    function remove()
    267275    {
     276        $app =& App::getInstance();
     277
    268278        $this->initDB();
    269279
     
    277287        ");
    278288
    279         App::logMsg(sprintf('Removing lock: %s', $this->data['lock_id']), LOG_DEBUG, __FILE__, __LINE__);
     289        $app->logMsg(sprintf('Removing lock: %s', $this->data['lock_id']), LOG_DEBUG, __FILE__, __LINE__);
    280290    }
    281291
     
    285295    function removeAll($user_id=null)
    286296    {
     297        $app =& App::getInstance();
     298
    287299        $this->initDB();
    288300
     
    293305            // Delete specific user's locks.
    294306            DB::query("DELETE FROM " . $this->getParam('db_table') . " WHERE set_by_admin_id = '" . DB::escapeString($user_id) . "'");
    295             App::logMsg(sprintf('Record locks owned by %s %s have been deleted', $this->_auth->getVal('auth_name'), $this->_auth->getUsername($user_id)), LOG_DEBUG, __FILE__, __LINE__);
     307            $app->logMsg(sprintf('Record locks owned by %s %s have been deleted', $this->_auth->getVal('auth_name'), $this->_auth->getUsername($user_id)), LOG_DEBUG, __FILE__, __LINE__);
    296308        } else {
    297309            // Delete ALL locks.
    298310            DB::query("DELETE FROM " . $this->getParam('db_table') . "");
    299             App::logMsg(sprintf('All record locks deleted by %s %s', $this->_auth->getVal('auth_name'), $this->_auth->getVal('username')), LOG_DEBUG, __FILE__, __LINE__);
     311            $app->logMsg(sprintf('All record locks deleted by %s %s', $this->_auth->getVal('auth_name'), $this->_auth->getVal('username')), LOG_DEBUG, __FILE__, __LINE__);
    300312        }
    301313    }
     
    325337    function dieErrorPage()
    326338    {
    327         App::dieURL(sprintf('%s?lock_id=%s&boomerang=%s', $this->getParam('error_url'), $this->data['lock_id'], urlencode(absoluteMe())));
     339        $app =& App::getInstance();
     340
     341        $app->dieURL(sprintf('%s?lock_id=%s&boomerang=%s', $this->getParam('error_url'), $this->data['lock_id'], urlencode(absoluteMe())));
    328342    }
    329343
     
    333347    function printErrorHTML()
    334348    {
     349        $app =& App::getInstance();
     350
    335351        ?>
    336352        <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    337         <?php App::printHiddenSession() ?>
     353        <?php $app->printHiddenSession() ?>
    338354        <input type="hidden" name="lock_id" value="<?php echo $this->getID(); ?>" />
    339355
Note: See TracChangeset for help on using the changeset viewer.