if(!$dbh){
throw new PDOException('Database connection not initialized.');
}
- $query = $dbh->prepare('SELECT username FROM users WHERE last_login!=0 AND remote="N" ORDER BY username');
+ /* 20180410 JLO2 - Until login code is implemented in the scaffolding system, a simpler version of this query should be used.
+ $query = $dbh->prepare('SELECT username FROM users WHERE last_login!=0 AND remote="N" ORDER BY username'); */
+ $query = $dbh->prepare('SELECT username FROM users WHERE remote="N" ORDER BY username');
$query->execute();
$result = $query->fetchAll();
if (!$result){
if($planworldForGetSendList->isUser($uid)){\r
$dbh = Planworld::_connect();\r
try{\r
- $query = $dbh->prepare('SELECT name, isinbound, MAX(SENDDATE) AS senddate, seen FROM\r
- (SELECT U.Username AS name, "TRUE" AS isinbound, MAX(S.SENT) AS senddate, seen FROM SEND S, USERS U\r
- WHERE U.ID=S.UID AND s.to_uid=:uid GROUP BY S.UID\r
+ $query = $dbh->prepare('SELECT name, isinbound, senddate, seen FROM\r
+ (SELECT U.username AS name, "TRUE" AS isinbound, MAX(S.SENT) AS senddate, MAX(S.SEEN) as seen FROM send S, users U\r
+ WHERE U.id=S.uid AND S.to_uid=:uid GROUP BY S.uid\r
UNION\r
- SELECT U.Username AS name, "FALSE" AS isinbound, MAX(S.SENT) AS senddate, seen FROM SEND S, USERS U\r
- WHERE U.ID=S.TO_UID AND s.uid=:uid GROUP BY S.TO_UID) SUB\r
- GROUP BY NAME ORDER BY name');\r
+ SELECT U.username AS name, "FALSE" AS isinbound, MAX(S.sent) AS senddate, MAX(S.SEEN) as seen FROM send S, users U\r
+ WHERE U.id=S.to_uid AND S.uid=:uid GROUP BY S.to_uid\r
+ ORDER BY name, senddate DESC) SUB\r
+ GROUP BY name ORDER BY name');\r
$queryArray = array('uid' => $uid);\r
$query->execute($queryArray);\r
$result = $query->fetchAll();\r
}
+ /* The following functions were moved here from the Online library. 20171121 JLO2 */
+
+ function isUserOnline(){
+ try{
+ if(!$this->dbh){
+ throw new PDOException('Database connection not initialized.');
+ }
+ $query = $this->dbh->prepare('SELECT count(last_access) as onlinecount FROM online where uid=:uid');
+ $queryArray = array('uid' => $this->userID);
+ $result = $query->execute($queryArray);
+ if (!$result){
+ return false;
+ }
+ else{
+ $intOnlineCount = (int) $result['onlinecount'];
+ if($intOnlineCount > 0){
+ return true;
+ }
+ else{
+ return false;
+ }
+ }
+ return false;
+ }
+ catch(PDOException $badquery){
+ return false;
+ }
+ }
+
+
+ /* Update the user's online status. If the user is not online, add them. If they are online, update them.
+ Set last login based on the user's current token. This last would need to change if we stop using tokens. */
+ function userOnline($stringWhatUserIsDoing = ''){
+ try{
+ if(!$this->dbh){
+ throw new PDOException('Database connection not initialized.');
+ }
+
+ if($this->isUserOnline()){
+
+ }
+ else{
+
+ }
+ }
+ catch(PDOException $badquery){
+ return false;
+ }
+ }
+
+
+ /* Sets the user to offline (i.e. removes them from the Online table. */
+ function userOffline(){
+ try{
+ if(!$this->dbh){
+ throw new PDOException('Database connection not initialized.');
+ }
+ $query = $this->dbh->prepare('DELETE FROM online WHERE uid=:uid');
+ $queryArray = array('uid' => $this->userID);
+ return $query->execute($queryArray);
+ }
+ catch(PDOException $badquery){
+ return false;
+ }
+ }
+
/* END CLASS */
}
<?php
- /* This file exists to test Planworld functionality as it is being built. */
+/* This file exists to test Planworld functionality as it is being built. */
- $_base = dirname(__FILE__) . '/../';
- require_once($_base . '/lib/Planworld.php');
- require_once($_base . '/lib/User.php');
- require_once('ttpdisplay_tools.php');
+$_base = dirname(__FILE__) . '/../';
+require_once($_base . '/lib/Planworld.php');
+require_once($_base . '/lib/User.php');
+require_once('ttpdisplay_tools.php');
- $message = '';
- $arrayUsers = array();
- if((isset($_POST['loginusername'])) && (isset($_POST['loginpassword']))){
- $username = $_POST['loginusername'];
- $password = $_POST['loginpassword'];
- if(!ctype_alnum($username)){
- $message = "Usernames for this test site must be alphanumeric";
+$message = '';
+$arrayUsers = array();
+if((isset($_POST['loginusername'])) && (isset($_POST['loginpassword']))){
+ $username = $_POST['loginusername'];
+ $password = $_POST['loginpassword'];
+ if(!ctype_alnum($username)){
+ $message = "Usernames for this test site must be alphanumeric";
+ }
+ else{
+ $userExists = new User($username);
+ $userId = $userExists->userID;
+ $comparepass = crypt($username, ((int)$userId + 45678));
+ if(strcmp($password, $comparepass) == 0){
+ $pw = new Planworld();
+ $arrayUsers = $pw->getAllUsers();
}
else{
- $userExists = new User($username);
- $userId = $userExists->userID;
- $comparepass = crypt($username, ((int)$userId + 45678));
- if(strcmp($password, $comparepass) == 0){
- $pw = new Planworld();
- $arrayUsers = $pw->getAllUsers();
- }
- else{
- $message = 'Bad username or password.';
- }
+ $message = 'Bad username or password.';
}
}
+}
- PrintHeader('fullpage.css', 'Test Planworld User Listing');
- PrintLoginForm('getusers.php', 'Enter username and password to print a list of all users on this system.', $message);
- foreach($arrayUsers as $arrayUser){
- echo '<br />' . $arrayUser;
- }
+PrintHeader('fullpage.css', 'Test Planworld User Listing');
+PrintLoginForm('getusers.php', 'Enter username and password to print a list of all users on this system.', $message);
+
+/* Print the user list below the login form. */
+if((is_array($arrayUsers)) && !(empty($arrayUsers))){
+ PrintEvenSimplerUserTable($arrayUsers, 'Usernames On This System');
+}
- PrintFooter();
+PrintFooter();
?>
\ No newline at end of file
}
+function PrintEvenSimplerUserTable($printUserIdArray, $title){
+ echo '<table>' . CR . '<caption>' . $title . '</caption>' . CR;
+ echo '<tr><th>Row</th><th>Username</th></tr>' . CR;
+ $rowCount = 1;
+ foreach($printUserIdArray as $printUserId){
+ echo '<tr><td>' . $rowCount . '</td>';
+ echo '<td>' . $printUserId . '</td>';
+ echo '</tr>' . CR;
+ $rowCount++;
+ }
+ echo '</table>' . CR;
+}
+
+
?>
\ No newline at end of file
**Readme For Planworld Alphas**
--------------------------------------
+_Last Updated 20180409_ by jlodom00
_Last Updated 20170406_ by jlodom00
-
_Releases in V3.00 Alpha Series_
20170406 - "Louisbourg" - Send Only Release Without Clients
+20180409 - "Loudon" - Fixed sendlist db query. Also make a note -- PHP 5.5 or later is required. Need to eliminate old JSON file and depedency.
+MAKE ANOTHER NOTE -- The NOTE Production Database contains invalid usernames. We filter for this in PW->getallusers, but in the future we should have a cleaner process to eliminate them. ALSO getallusers is part of scaffolding and the API userslocalGet call but it doesn't return all users now, just the local ones who are properly formatted.
_License_
This release does not yet include proper attribution for authors (Seth Fitzsimmons, Baker Franke, Johnnie Odom et al) but it is licensed using the GPLv2 as the previous version was. Future releases will more properly note this.