Ignore:
Timestamp:
Dec 18, 2005 12:16:03 AM (18 years ago)
Author:
scdev
Message:

detabbed all files ;P

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/RecordLock.inc.php

    r41 r42  
    3333    {
    3434        static $instances = array();
    35                
     35
    3636        if (!isset($instances[$auth_object->getVal('auth_name')])) {
    3737            $instances[$auth_object->getVal('auth_name')] = new RecordLock($auth_object);
     
    5353
    5454        $this->_auth = $auth_object;
    55        
     55
    5656        // Get create tables config from global context.
    5757        if (!is_null(App::getParam('db_create_tables'))) {
     
    7070    {
    7171        static $_db_tested = false;
    72    
     72
    7373        if ($recreate_db || !$_db_tested && $this->getParam('create_table')) {
    7474            if ($recreate_db) {
     
    8989                KEY record_val (record_val)
    9090            )");
    91            
     91
    9292            if (!DB::columnExists($this->getParam('db_table'), array(
    93                 'lock_id',
    94                 'record_table',
    95                 'record_key',
    96                 'record_val',
    97                 'title',
    98                 'set_by_admin_id',
    99                 'lock_datetime',
     93                'lock_id',
     94                'record_table',
     95                'record_key',
     96                'record_val',
     97                'title',
     98                'set_by_admin_id',
     99                'lock_datetime',
    100100            ), false, false)) {
    101101                App::logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), LOG_ALERT, __FILE__, __LINE__);
    102102                trigger_error(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), E_USER_ERROR);
    103103            }
    104         }   
     104        }
    105105        $_db_tested = true;
    106106    }
     
    151151        // Expire old locks.
    152152        $this->_auto_timeout();
    153        
     153
    154154        if (is_numeric($record_table_or_lock_id) && !isset($record_key) && !isset($record_val)) {
    155155            // Get lock data by lock_id.
    156156            $qid = DB::query("
    157                 SELECT * FROM " . $this->getParam('db_table') . " 
     157                SELECT * FROM " . $this->getParam('db_table') . "
    158158                WHERE lock_id = '" . addslashes($record_table_or_lock_id) . "'
    159159            ");
     
    161161            // Get lock data by record specs
    162162            $qid = DB::query("
    163                 SELECT * FROM " . $this->getParam('db_table') . " 
     163                SELECT * FROM " . $this->getParam('db_table') . "
    164164                WHERE record_table = '" . addslashes($record_table_or_lock_id) . "'
    165165                AND record_key = '" . addslashes($record_key) . "'
     
    189189
    190190    /**
    191      * Returns the status of who set the lock. Use this to ignore locks set by 
     191     * Returns the status of who set the lock. Use this to ignore locks set by
    192192     * the current user.
    193193     *
     
    197197    {
    198198        $this->initDB();
    199        
     199
    200200        if (isset($this->data['lock_id'])) {
    201201            $qid = DB::query("SELECT * FROM " . $this->getParam('db_table') . " WHERE lock_id = '" . addslashes($this->data['lock_id']) . "'");
     
    221221     */
    222222    function set($record_table, $record_key, $record_val, $title='')
    223     {       
     223    {
    224224        $this->initDB();
    225225
    226226        // Expire old locks.
    227227        $this->_auto_timeout();
    228        
     228
    229229        // Remove previous locks if exist. Is this better than using a REPLACE INTO?
    230230        DB::query("
    231             DELETE FROM " . $this->getParam('db_table') . " 
     231            DELETE FROM " . $this->getParam('db_table') . "
    232232            WHERE record_table = '" . addslashes($record_table) . "'
    233233            AND record_key = '" . addslashes($record_key) . "'
    234234            AND record_val = '" . addslashes($record_val) . "'
    235235        ");
    236        
     236
    237237        // Set new lock.
    238238        DB::query("
     
    254254        ");
    255255        $lock_id = mysql_insert_id(DB::getDBH());
    256        
     256
    257257        // Must register this locked record as the current.
    258258        $this->select($lock_id);
    259        
     259
    260260        return $lock_id;
    261261    }
     
    270270        // Expire old locks.
    271271        $this->_auto_timeout();
    272        
     272
    273273        // Delete a specific lock.
    274274        DB::query("
    275             DELETE FROM " . $this->getParam('db_table') . " 
     275            DELETE FROM " . $this->getParam('db_table') . "
    276276            WHERE lock_id = '" . addslashes($this->data['lock_id']) . "'
    277277        ");
    278        
     278
    279279        App::logMsg(sprintf('Removing lock: %s', $this->data['lock_id']), LOG_DEBUG, __FILE__, __LINE__);
    280280    }
     
    284284     */
    285285    function removeAll($user_id=null)
    286     {       
     286    {
    287287        $this->initDB();
    288288
    289289        // Expire old locks.
    290290        $this->_auto_timeout();
    291        
     291
    292292        if (isset($user_id)) {
    293293            // Delete specific user's locks.
     
    309309
    310310        $this->initDB();
    311        
     311
    312312        if (!$_timeout_run) {
    313313            // Delete all old locks.
    314314            DB::query("
    315                 DELETE FROM " . $this->getParam('db_table') . " 
     315                DELETE FROM " . $this->getParam('db_table') . "
    316316                WHERE DATE_ADD(lock_datetime, INTERVAL '" . $this->getParam('auto_timeout') . "' SECOND) < NOW()
    317317            ");
     
    337337        <?php App::printHiddenSession() ?>
    338338        <input type="hidden" name="lock_id" value="<?php echo $this->getID(); ?>" />
    339        
     339
    340340        <p><?php
    341         printf(_("The record <strong>%s</strong> is currently being edited by <strong>%s</strong> (%d minutes elapsed). You cannot modify the record while it is locked by another user."), 
    342             $this->getTitle(), 
    343             $this->getEditor(), 
     341        printf(_("The record <strong>%s</strong> is currently being edited by <strong>%s</strong> (%d minutes elapsed). You cannot modify the record while it is locked by another user."),
     342            $this->getTitle(),
     343            $this->getEditor(),
    344344            date('i', $this->getSecondsElapsed() + 60)
    345345        );
    346346        ?></p>
    347        
     347
    348348        <?php if ($this->getSecondsElapsed() > $this->getParam('timeout')) { ?>
    349349        <p><?php printf(_("You can forcibly unlock the record if you believe the editing session has expired. You might want to confirm with %s before doing this."), $this->getEditor()) ?></p>
    350350        <input type="submit" name="unlock" value="<?php echo _("Unlock"); ?>" />
    351351        <?php } ?>
    352        
     352
    353353        <input type="submit" name="cancel" value="<?php echo _("Cancel"); ?>" />
    354354        </form>
Note: See TracChangeset for help on using the changeset viewer.