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/services/admins.php

    r41 r42  
    11<?php
    22/**
    3  * admins.php 
     3 * admins.php
    44 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information
    55 */
     
    2323 * CONFIG
    2424 *****************************************************************************/
    25  
     25
    2626// Titles and navigation header.
    2727$nav->addPage(_("Administrators"), $_SERVER['PHP_SELF']);
    28    
     28
    2929// The object to validate form input.
    3030$fv = new FormValidator();
     
    6060 * MAIN
    6161 *****************************************************************************/
    62  
     62
    6363// We may want to use the add/edit interface from another script, so this
    6464// allows us to remember which page we came from so we can go back there.
     
    208208    $fv->isEmpty('username', _("<strong>Username</strong> cannot be blank."));
    209209    $fv->stringLength('username', 0, 255, _("<strong>Username</strong> must contain less than 256 characters."));
    210    
     210
    211211    $fv->isEmpty('userpass', _("<strong>Passwords</strong> cannot be blank."));
    212212    $fv->stringLength('userpass', 6, 36, _("<strong>Passwords</strong> must be between 6 and 36 characters long."));
    213    
     213
    214214    $fv->stringLength('first_name', 0, 255, _("<strong>First name</strong> must contain less than 256 characters."));
    215    
     215
    216216    $fv->stringLength('last_name', 0, 255, _("<strong>Last name</strong> must contain less than 256 characters."));
    217217
     
    219219    $fv->stringLength('email', 0, 255, _("<strong>Email</strong> must contain less than 256 characters."));
    220220    $fv->validateEmail('email');
    221    
     221
    222222    $fv->isEmpty('user_type', _("<strong>User type</strong> cannot be blank."));
    223223    $fv->stringLength('user_type', 0, 255, _("<strong>User type</strong> has an invalid selection."));
     
    265265    // Get the information for the form.
    266266    $qid = DB::query("
    267         SELECT * 
     267        SELECT *
    268268        FROM admin_tbl
    269269        WHERE admin_id = '" . addslashes($id) . "'
     
    274274        App::dieBoomerangURL();
    275275    }
    276    
     276
    277277    // Lock this record.
    278278    $lock->set('admin_tbl', 'admin_id', $id, $frm['username']);
    279    
     279
    280280    // Set misc values for the form.
    281281    $frm = array_merge(array(
     
    312312{
    313313    global $auth, $lock;
    314    
     314
    315315    $lock->select('admin_tbl', 'admin_id', $id);
    316316    if ($lock->isLocked() && !$lock->isMine()) {
     
    320320    // Break the cache because we are changing the list data.
    321321    SessionCache::breakCache($_SERVER['PHP_SELF']);
    322    
     322
    323323    // Get the information for this object.
    324324    $qid = DB::query("
     
    331331        App::dieBoomerangURL();
    332332    }
    333    
     333
    334334    // Get the information for this object.
    335335    $qid = DB::query("SELECT COUNT(*) from admin_tbl");
     
    357357{
    358358    global $auth;
    359    
     359
    360360    // Break the cache because we are changing the list data.
    361361    SessionCache::breakCache($_SERVER['PHP_SELF']);
    362    
     362
    363363    // Insert record data.
    364364    DB::query("
     
    382382    ");
    383383    $last_insert_id = mysql_insert_id(DB::getDBH());
    384    
     384
    385385    // Set admin password.
    386386    $auth->setPassword($last_insert_id, $frm['userpass']);
    387    
     387
    388388    // Create version.
    389389    $version = RecordVersion::getInstance($GLOBALS['auth']);
    390390    $version->create('admin_tbl', 'admin_id', $last_insert_id, $frm['username']);
    391    
     391
    392392    App::raiseMsg(sprintf(_("The Admin <strong>%s</strong> has been added."), $frm['username']), MSG_SUCCESS, __FILE__, __LINE__);
    393    
     393
    394394    return $last_insert_id;
    395395}
     
    398398{
    399399    global $auth, $lock;
    400    
     400
    401401    $lock->select('admin_tbl', 'admin_id', $frm['admin_id']);
    402402    if ($lock->isLocked() && !$lock->isMine()) {
     
    406406    // Break the cache because we are changing the list data.
    407407    SessionCache::breakCache($_SERVER['PHP_SELF']);
    408    
     408
    409409    // If the userpass is left blank or with the filler **** characters, we don't want to update it.
    410410    if (!empty($frm['userpass']) && !preg_match('/[\*]{4,}/', $frm['userpass'])) {
     
    412412        $auth->setPassword($frm['admin_id'], $frm['userpass']);
    413413    }
    414    
     414
    415415    // Update record data.
    416416    DB::query("
     
    440440    global $page;
    441441    global $so;
    442    
     442
    443443    $where_clause = '';
    444    
     444
    445445    // Build search query if available.
    446446    if (getFormData('search_query', false)) {
     
    460460    // Count the total number of records so we can do something about the page numbers.
    461461    $qid = DB::query("
    462         SELECT COUNT(*) 
    463         FROM admin_tbl 
     462        SELECT COUNT(*)
     463        FROM admin_tbl
    464464        $where_clause
    465465    ");
    466466    list($num_results) = mysql_fetch_row($qid);
    467    
     467
    468468    // Set page numbers now we know (needed for next step).
    469469    $page->setTotalItems($num_results);
    470470    $page->calculate();
    471    
     471
    472472    // Final SQL, with sort and page limiters.
    473473    $sql = "
    474         SELECT 
    475             admin_tbl.*, 
     474        SELECT
     475            admin_tbl.*,
    476476            a1.username AS added_admin_username,
    477477            a2.username AS modified_admin_username
     
    483483        " . $page->getLimitSQL() . "
    484484    ";
    485    
     485
    486486    // A unique key for this query, with the total_items in case db records
    487487    // were added since the last cache. This identifies a unique set of
     
    494494        Prefs::setValue('cache_hash', $cache_hash, $_SERVER['PHP_SELF']);
    495495    }
    496    
     496
    497497    if (SessionCache::isCached($_SERVER['PHP_SELF']) && false) {
    498498        // Get the cached results.
     
    505505            $list[] = $row;
    506506        }
    507            
     507
    508508        if (isset($list) && !empty($list)) {
    509509            // Cache the results.
Note: See TracChangeset for help on using the changeset viewer.