From: Johnnie Lamar Odom II Date: Thu, 17 May 2018 02:35:16 +0000 (-0500) Subject: Saving current source state before making major send changes. X-Git-Url: https://git.planwatch.world/gitweb/?a=commitdiff_plain;h=5c8de2a0b5253e5886469e7d0a23489898c8c1f1;p=planworld_public.git Saving current source state before making major send changes. --- diff --git a/code/lib/Planworld.php b/code/lib/Planworld.php index 3534145..0b14445 100644 --- a/code/lib/Planworld.php +++ b/code/lib/Planworld.php @@ -453,7 +453,9 @@ public static function isUser ($uid, $force=false) { 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){ diff --git a/code/lib/Send.php b/code/lib/Send.php index 8422254..124846f 100644 --- a/code/lib/Send.php +++ b/code/lib/Send.php @@ -124,13 +124,14 @@ class Send { if($planworldForGetSendList->isUser($uid)){ $dbh = Planworld::_connect(); try{ - $query = $dbh->prepare('SELECT name, isinbound, MAX(SENDDATE) AS senddate, seen FROM - (SELECT U.Username AS name, "TRUE" AS isinbound, MAX(S.SENT) AS senddate, seen FROM SEND S, USERS U - WHERE U.ID=S.UID AND s.to_uid=:uid GROUP BY S.UID + $query = $dbh->prepare('SELECT name, isinbound, senddate, seen FROM + (SELECT U.username AS name, "TRUE" AS isinbound, MAX(S.SENT) AS senddate, MAX(S.SEEN) as seen FROM send S, users U + WHERE U.id=S.uid AND S.to_uid=:uid GROUP BY S.uid UNION - SELECT U.Username AS name, "FALSE" AS isinbound, MAX(S.SENT) AS senddate, seen FROM SEND S, USERS U - WHERE U.ID=S.TO_UID AND s.uid=:uid GROUP BY S.TO_UID) SUB - GROUP BY NAME ORDER BY name'); + SELECT U.username AS name, "FALSE" AS isinbound, MAX(S.sent) AS senddate, MAX(S.SEEN) as seen FROM send S, users U + WHERE U.id=S.to_uid AND S.uid=:uid GROUP BY S.to_uid + ORDER BY name, senddate DESC) SUB + GROUP BY name ORDER BY name'); $queryArray = array('uid' => $uid); $query->execute($queryArray); $result = $query->fetchAll(); diff --git a/code/lib/User.php b/code/lib/User.php index a5bd7b2..7bb3bb3 100755 --- a/code/lib/User.php +++ b/code/lib/User.php @@ -988,6 +988,72 @@ class User { } + /* 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 */ } diff --git a/code/scaffolding/getusers.php b/code/scaffolding/getusers.php index 04c036a..d94ce98 100644 --- a/code/scaffolding/getusers.php +++ b/code/scaffolding/getusers.php @@ -1,41 +1,43 @@ 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 '
' . $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 diff --git a/code/scaffolding/ttpdisplay_tools.php b/code/scaffolding/ttpdisplay_tools.php index 53e43cd..b6fd44d 100644 --- a/code/scaffolding/ttpdisplay_tools.php +++ b/code/scaffolding/ttpdisplay_tools.php @@ -126,4 +126,18 @@ function PrintSimpleUserTable($printUserIdArray, $lookupTable, $title){ } +function PrintEvenSimplerUserTable($printUserIdArray, $title){ + echo '' . CR . '' . CR; + echo '' . CR; + $rowCount = 1; + foreach($printUserIdArray as $printUserId){ + echo ''; + echo ''; + echo '' . CR; + $rowCount++; + } + echo '
' . $title . '
RowUsername
' . $rowCount . '' . $printUserId . '
' . CR; +} + + ?> \ No newline at end of file diff --git a/setup/readme.md b/setup/readme.md index d039c4c..8c28dec 100644 --- a/setup/readme.md +++ b/setup/readme.md @@ -1,10 +1,12 @@ **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.