Changeset 468 for trunk/lib/Version.inc.php
- Timestamp:
- Feb 20, 2014 3:03:59 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property
svn:mergeinfo
set to
/branches/eli_branch merged eligible
-
Property
svn:mergeinfo
set to
-
trunk/lib/Version.inc.php
r396 r468 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 39 39 class Version { 40 40 41 // A place to keep an object instance for the singleton pattern. 42 private static $instance = null; 43 41 44 // Configuration of this object. 42 var$_params = array(45 private $_params = array( 43 46 'max_qty' => 100, // Never have more than this many versions of each record. 44 47 'min_qty' => 25, // Keep at least this many versions of each record. 45 48 'min_days' => 7, // Keep ALL versions within this many days, even if MORE than min_qty. 46 49 'db_table' => 'version_tbl', 47 50 48 51 // Automatically create table and verify columns. Better set to false after site launch. 49 52 // This value is overwritten by the $app->getParam('db_create_tables') setting if it is available. … … 54 57 55 58 // Auth_SQL object from which to access a current user_id. 56 var$_auth;59 private $_auth; 57 60 58 61 /** … … 63 66 * @static 64 67 */ 65 static function &getInstance($auth_object) 66 { 67 static $instance = null; 68 69 if ($instance === null) { 70 $instance = new Version($auth_object); 71 } 72 73 return $instance; 68 public static function &getInstance($auth_object) 69 { 70 if (self::$instance === null) { 71 self::$instance = new self($auth_object); 72 } 73 74 return self::$instance; 74 75 } 75 76 … … 79 80 * @param mixed $auth_object An Auth_SQL object. 80 81 */ 81 function Version($auth_object)82 public function __construct($auth_object) 82 83 { 83 84 $app =& App::getInstance(); … … 102 103 * @since 26 Aug 2005 17:09:36 103 104 */ 104 function initDB($recreate_db=false)105 public function initDB($recreate_db=false) 105 106 { 106 107 $app =& App::getInstance(); … … 155 156 * @param array $params Array of param keys and values to set. 156 157 */ 157 function setParam($params=null)158 public function setParam($params=null) 158 159 { 159 160 if (isset($params) && is_array($params)) { … … 170 171 * @return mixed Configured parameter value. 171 172 */ 172 function getParam($param)173 public function getParam($param) 173 174 { 174 175 $app =& App::getInstance(); 175 176 176 177 if (isset($this->_params[$param])) { 177 178 return $this->_params[$param]; … … 192 193 * @return int The id for the version (mysql last insert id). 193 194 */ 194 function create($record_table, $record_key, $record_val, $title='', $notes='')195 public function create($record_table, $record_key, $record_val, $title='', $notes='') 195 196 { 196 197 $app =& App::getInstance(); … … 204 205 return false; 205 206 } 206 207 207 208 // Get previous version_number. 208 209 $qid = $db->query(" … … 253 254 * @return int The id for the version (mysql last insert id). 254 255 */ 255 function restore($version_id)256 public function restore($version_id) 256 257 { 257 258 $app =& App::getInstance(); … … 314 315 * @return mixed Array of versions, or false if none. 315 316 */ 316 function deleteOld($record_table, $record_key, $record_val)317 { 318 $db =& DB::getInstance(); 319 317 public function deleteOld($record_table, $record_key, $record_val) 318 { 319 $db =& DB::getInstance(); 320 320 321 $this->initDB(); 321 322 … … 381 382 * @return mixed Array of versions, or false if none. 382 383 */ 383 function getList($record_table, $record_key, $record_val)384 { 385 $db =& DB::getInstance(); 386 384 public function getList($record_table, $record_key, $record_val) 385 { 386 $db =& DB::getInstance(); 387 387 388 $this->initDB(); 388 389 389 390 // Get versions of this record. 390 391 $qid = $db->query(" 391 SELECT 392 SELECT 392 393 version_id, 393 394 saved_by_user_id, … … 418 419 * @return mixed Array of data saved in version, or false if none. 419 420 */ 420 function getVerson($version_id)421 { 422 $db =& DB::getInstance(); 423 421 public function getVerson($version_id) 422 { 423 $db =& DB::getInstance(); 424 424 425 $this->initDB(); 425 426 … … 439 440 * @return mixed Array of data saved in version, or false if none. 440 441 */ 441 function getData($version_id)442 { 443 $db =& DB::getInstance(); 444 442 public function getData($version_id) 443 { 444 $db =& DB::getInstance(); 445 445 446 $this->initDB(); 446 447 … … 465 466 * @return mixed Array of data saved in version, or false if none. 466 467 */ 467 function getCurrent($record_table, $record_key, $record_val)468 { 469 $db =& DB::getInstance(); 470 468 public function getCurrent($record_table, $record_key, $record_val) 469 { 470 $db =& DB::getInstance(); 471 471 472 $this->initDB(); 472 473 … … 484 485 485 486 } // End of class. 486 ?>
Note: See TracChangeset
for help on using the changeset viewer.