Changeset 128 for branches/2.0singleton/lib/RecordLock.inc.php
- Timestamp:
- May 26, 2006 9:29:19 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.0singleton/lib/RecordLock.inc.php
r111 r128 48 48 function RecordLock($auth_object) 49 49 { 50 $app =& App::getInstance(); 51 50 52 if (!is_a($auth_object, 'Auth_SQL')) { 51 53 trigger_error('Constructor not provided a valid Auth_SQL object.', E_USER_ERROR); … … 55 57 56 58 // 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'))); 59 61 } 60 62 } … … 69 71 function initDB($recreate_db=false) 70 72 { 73 $app =& App::getInstance(); 74 71 75 static $_db_tested = false; 72 76 … … 74 78 if ($recreate_db) { 75 79 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__); 77 81 } 78 82 DB::query("CREATE TABLE IF NOT EXISTS " . $this->getParam('db_table') . " ( … … 99 103 'lock_datetime', 100 104 ), 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__); 102 106 trigger_error(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), E_USER_ERROR); 103 107 } … … 128 132 function getParam($param) 129 133 { 134 $app =& App::getInstance(); 135 130 136 if (isset($this->_params[$param])) { 131 137 return $this->_params[$param]; 132 138 } 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__); 134 140 return null; 135 141 } … … 147 153 function select($record_table_or_lock_id, $record_key=null, $record_val=null) 148 154 { 155 $app =& App::getInstance(); 156 149 157 $this->initDB(); 150 158 … … 168 176 } 169 177 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__); 171 179 /// FIX ME: What if admin set lock, but public user is current lock user? 172 180 $this->data['editor'] = $this->_auth->getUsername($this->data['set_by_admin_id']); 173 181 return true; 174 182 } 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__); 176 184 return false; 177 185 } … … 266 274 function remove() 267 275 { 276 $app =& App::getInstance(); 277 268 278 $this->initDB(); 269 279 … … 277 287 "); 278 288 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__); 280 290 } 281 291 … … 285 295 function removeAll($user_id=null) 286 296 { 297 $app =& App::getInstance(); 298 287 299 $this->initDB(); 288 300 … … 293 305 // Delete specific user's locks. 294 306 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__); 296 308 } else { 297 309 // Delete ALL locks. 298 310 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__); 300 312 } 301 313 } … … 325 337 function dieErrorPage() 326 338 { 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()))); 328 342 } 329 343 … … 333 347 function printErrorHTML() 334 348 { 349 $app =& App::getInstance(); 350 335 351 ?> 336 352 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> 337 <?php App::printHiddenSession() ?>353 <?php $app->printHiddenSession() ?> 338 354 <input type="hidden" name="lock_id" value="<?php echo $this->getID(); ?>" /> 339 355
Note: See TracChangeset
for help on using the changeset viewer.