Changeset 42 for trunk/services/admins.php
- Timestamp:
- Dec 18, 2005 12:16:03 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/services/admins.php
r41 r42 1 1 <?php 2 2 /** 3 * admins.php 3 * admins.php 4 4 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information 5 5 */ … … 23 23 * CONFIG 24 24 *****************************************************************************/ 25 25 26 26 // Titles and navigation header. 27 27 $nav->addPage(_("Administrators"), $_SERVER['PHP_SELF']); 28 28 29 29 // The object to validate form input. 30 30 $fv = new FormValidator(); … … 60 60 * MAIN 61 61 *****************************************************************************/ 62 62 63 63 // We may want to use the add/edit interface from another script, so this 64 64 // allows us to remember which page we came from so we can go back there. … … 208 208 $fv->isEmpty('username', _("<strong>Username</strong> cannot be blank.")); 209 209 $fv->stringLength('username', 0, 255, _("<strong>Username</strong> must contain less than 256 characters.")); 210 210 211 211 $fv->isEmpty('userpass', _("<strong>Passwords</strong> cannot be blank.")); 212 212 $fv->stringLength('userpass', 6, 36, _("<strong>Passwords</strong> must be between 6 and 36 characters long.")); 213 213 214 214 $fv->stringLength('first_name', 0, 255, _("<strong>First name</strong> must contain less than 256 characters.")); 215 215 216 216 $fv->stringLength('last_name', 0, 255, _("<strong>Last name</strong> must contain less than 256 characters.")); 217 217 … … 219 219 $fv->stringLength('email', 0, 255, _("<strong>Email</strong> must contain less than 256 characters.")); 220 220 $fv->validateEmail('email'); 221 221 222 222 $fv->isEmpty('user_type', _("<strong>User type</strong> cannot be blank.")); 223 223 $fv->stringLength('user_type', 0, 255, _("<strong>User type</strong> has an invalid selection.")); … … 265 265 // Get the information for the form. 266 266 $qid = DB::query(" 267 SELECT * 267 SELECT * 268 268 FROM admin_tbl 269 269 WHERE admin_id = '" . addslashes($id) . "' … … 274 274 App::dieBoomerangURL(); 275 275 } 276 276 277 277 // Lock this record. 278 278 $lock->set('admin_tbl', 'admin_id', $id, $frm['username']); 279 279 280 280 // Set misc values for the form. 281 281 $frm = array_merge(array( … … 312 312 { 313 313 global $auth, $lock; 314 314 315 315 $lock->select('admin_tbl', 'admin_id', $id); 316 316 if ($lock->isLocked() && !$lock->isMine()) { … … 320 320 // Break the cache because we are changing the list data. 321 321 SessionCache::breakCache($_SERVER['PHP_SELF']); 322 322 323 323 // Get the information for this object. 324 324 $qid = DB::query(" … … 331 331 App::dieBoomerangURL(); 332 332 } 333 333 334 334 // Get the information for this object. 335 335 $qid = DB::query("SELECT COUNT(*) from admin_tbl"); … … 357 357 { 358 358 global $auth; 359 359 360 360 // Break the cache because we are changing the list data. 361 361 SessionCache::breakCache($_SERVER['PHP_SELF']); 362 362 363 363 // Insert record data. 364 364 DB::query(" … … 382 382 "); 383 383 $last_insert_id = mysql_insert_id(DB::getDBH()); 384 384 385 385 // Set admin password. 386 386 $auth->setPassword($last_insert_id, $frm['userpass']); 387 387 388 388 // Create version. 389 389 $version = RecordVersion::getInstance($GLOBALS['auth']); 390 390 $version->create('admin_tbl', 'admin_id', $last_insert_id, $frm['username']); 391 391 392 392 App::raiseMsg(sprintf(_("The Admin <strong>%s</strong> has been added."), $frm['username']), MSG_SUCCESS, __FILE__, __LINE__); 393 393 394 394 return $last_insert_id; 395 395 } … … 398 398 { 399 399 global $auth, $lock; 400 400 401 401 $lock->select('admin_tbl', 'admin_id', $frm['admin_id']); 402 402 if ($lock->isLocked() && !$lock->isMine()) { … … 406 406 // Break the cache because we are changing the list data. 407 407 SessionCache::breakCache($_SERVER['PHP_SELF']); 408 408 409 409 // If the userpass is left blank or with the filler **** characters, we don't want to update it. 410 410 if (!empty($frm['userpass']) && !preg_match('/[\*]{4,}/', $frm['userpass'])) { … … 412 412 $auth->setPassword($frm['admin_id'], $frm['userpass']); 413 413 } 414 414 415 415 // Update record data. 416 416 DB::query(" … … 440 440 global $page; 441 441 global $so; 442 442 443 443 $where_clause = ''; 444 444 445 445 // Build search query if available. 446 446 if (getFormData('search_query', false)) { … … 460 460 // Count the total number of records so we can do something about the page numbers. 461 461 $qid = DB::query(" 462 SELECT COUNT(*) 463 FROM admin_tbl 462 SELECT COUNT(*) 463 FROM admin_tbl 464 464 $where_clause 465 465 "); 466 466 list($num_results) = mysql_fetch_row($qid); 467 467 468 468 // Set page numbers now we know (needed for next step). 469 469 $page->setTotalItems($num_results); 470 470 $page->calculate(); 471 471 472 472 // Final SQL, with sort and page limiters. 473 473 $sql = " 474 SELECT 475 admin_tbl.*, 474 SELECT 475 admin_tbl.*, 476 476 a1.username AS added_admin_username, 477 477 a2.username AS modified_admin_username … … 483 483 " . $page->getLimitSQL() . " 484 484 "; 485 485 486 486 // A unique key for this query, with the total_items in case db records 487 487 // were added since the last cache. This identifies a unique set of … … 494 494 Prefs::setValue('cache_hash', $cache_hash, $_SERVER['PHP_SELF']); 495 495 } 496 496 497 497 if (SessionCache::isCached($_SERVER['PHP_SELF']) && false) { 498 498 // Get the cached results. … … 505 505 $list[] = $row; 506 506 } 507 507 508 508 if (isset($list) && !empty($list)) { 509 509 // Cache the results.
Note: See TracChangeset
for help on using the changeset viewer.