public function buildUsers()
 {
     /**
      * Build a list of users.
      *
      * This builds a list of users with options to perform changes to their account.
      *
      * @author	Mark O'Russa	<*****@*****.**>
      *
      * @return	boolean	Returns a list of users with pagination, otherwise throws a customException.
      */
     global $debug, $message, $Dbc;
     try {
         $output = '';
         //Get the user count.
         $userCountStmt = $Dbc->query("SELECT\n\tcount(userId) AS 'count'\nFROM\n\tusers");
         $row = $userCountStmt->fetch(PDO::FETCH_ASSOC);
         $itemCount = $row['count'];
         //Get the pagination info.
         $pagination = new Adrlist_Pagination('buildUsers', 'buildUsers', $itemCount, 'Search Users');
         list($offset, $limit) = $pagination->offsetLimit();
         //Get the users.
         $usersStmt = $Dbc->prepare("SELECT\n\tuserId AS 'userId',\n\tprimaryEmail AS 'primaryEmail',\n\tsecondaryEmail AS 'secondaryEmail',\n\tfirstName AS 'firstName',\n\tlastName AS 'lastName',\n\tdateAdded AS 'dateAdded'\nFROM\n\tusers\nLIMIT " . $offset . ', ' . $limit);
         $usersStmt->execute();
         $userRows = array();
         while ($row = $usersStmt->fetch(PDO::FETCH_ASSOC)) {
             $userRows[] = array($row['userId'], '<span class="blue bold">P:</span> ' . $row['primaryEmail'] . '<br><span class="blue bold">S:</span> ' . $row['secondaryEmail'], '<span class="blue bold">F:</span> ' . $row['firstName'] . '<br><span class="blue bold">L:</span> ' . $row['lastName'], $row['dateAdded']);
         }
         $pagination->setParameters($itemCount, $offset, $limit, 'buildUsers');
         $titleArray = array('userId', 'Email', 'Name', 'Date Added');
         $cssWidths = array('3em', '18em', '10em', '8em');
         $buildRows = new Adrlist_BuildRows($titleArray, $userRows, $cssWidths);
         $pagination = $pagination->output();
         return $pagination['paginationTop'] . $buildRows->outputTitleRow() . $buildRows->outputRows() . $pagination['paginationBottom'];
     } catch (Adrlist_CustomException $e) {
     } catch (PDOException $e) {
         error(__LINE__, '', '<pre class="red">' . $e . '</pre>');
     }
 }
function buildUsers()
{
    global $debug, $message, $success, $Dbc, $returnThis;
    try {
        $output = '';
        //Get the user count.
        $userCountStmt = $Dbc->query("SELECT\n\tcount(userId) AS 'count'\nFROM\n\tusers");
        $row = $userCountStmt->fetch(PDO::FETCH_ASSOC);
        $itemCount = $row['count'];
        //Get the pagination info.
        $pagination = new Adrlist_Pagination();
        $offsetLimit = $pagination->getOffsetLimit($_SESSION['userId'], $_SERVER['SCRIPT_NAME'], 'buildUsers');
        if (isset($_POST['offset'])) {
            $offset = $_POST['offset'];
            $pagination->setOffset($_SESSION['userId'], $_SERVER['SCRIPT_NAME'], 'buildUsers', $offset);
        } else {
            $offset = $offsetLimit[0];
        }
        $offset = $offset > $itemCount ? 0 : $offset;
        //When changing list viewing options the offset may be larger than the count.
        if (isset($_POST['limit'])) {
            $limit = $_POST['limit'];
            $pagination->setLimit($_SESSION['userId'], $_SERVER['SCRIPT_NAME'], 'buildUsers', $limit);
            $offset = 0;
            //We must reset the offset when changing the limit.
        } else {
            $limit = $offsetLimit[1];
        }
        //Get the users.
        $usersStmt = $Dbc->prepare("SELECT\n\tuserId AS 'userId',\n\tprimaryEmail AS 'primaryEmail',\n\tsecondaryEmail AS 'secondaryEmail',\n\tfirstName AS 'firstName',\n\tlastName AS 'lastName',\n\tdateAdded AS 'dateAdded'\nFROM\n\tusers\nLIMIT " . $offset . ', ' . $limit);
        $usersStmt->execute();
        $userRows = array();
        while ($row = $usersStmt->fetch(PDO::FETCH_ASSOC)) {
            $userRows[] = array($row['userId'], '<span class="blue bold">P:</span> ' . $row['primaryEmail'] . '<br><span class="blue bold">S:</span> ' . $row['secondaryEmail'], '<span class="blue bold">F:</span> ' . $row['firstName'] . '<br><span class="blue bold">L:</span> ' . $row['lastName'], $row['dateAdded']);
        }
        $pagination->setParameters($itemCount, $offset, $limit, 'buildUsers');
        $titleArray = array('userId', 'Email', 'Name', 'Date Added');
        $cssWidths = array('3em', '18em', '10em', '8em');
        $buildRows = new Adrlist_BuildRows($titleArray, $userRows, $cssWidths);
        $pagination = $pagination->output();
        $output .= $pagination['paginationTop'] . $buildRows->outputTitleRow() . $buildRows->outputRows() . $pagination['paginationBottom'];
    } catch (Adrlist_CustomException $e) {
    } catch (PDOException $e) {
        error(__LINE__, '', $debug->printArray($e) . '<pre class="red">' . $e . '</pre>');
    }
    if (MODE == 'buildUsers') {
        $success = true;
        $returnThis['output'] = $output;
        $returnThis['container'] = 'buildUsersHolder';
        returnData();
    } else {
        return $output;
    }
}