(Resubmit with added files) Sevenoaks Release. Lots of bugfixes from Gordon. Added...
authorJohnnie Lamar Odom II <jlodom00@alumni.amherst.edu>
Sun, 13 Oct 2019 01:47:25 +0000 (20:47 -0500)
committerJohnnie Lamar Odom II <jlodom00@alumni.amherst.edu>
Sun, 13 Oct 2019 01:47:25 +0000 (20:47 -0500)
code/clientlib/3.00/block.php [new file with mode: 0644]
code/clientlib/3.00/debug.php [new file with mode: 0644]
code/clientlib/3.00/watch.php [new file with mode: 0644]

diff --git a/code/clientlib/3.00/block.php b/code/clientlib/3.00/block.php
new file mode 100644 (file)
index 0000000..5467d24
--- /dev/null
@@ -0,0 +1,90 @@
+<?php
+
+function blocklistGet($arrayRestInputs){
+  if((file_exists($arrayRestInputs['enginebasedir'] . '/lib/User.php')) && (file_exists($arrayRestInputs['enginebasedir'] . '/lib/NodeToken.php')) ){
+    require_once($arrayRestInputs['enginebasedir'] . '/lib/User.php');
+    require_once($arrayRestInputs['enginebasedir'] . '/lib/NodeToken.php');
+    $objectToken = new NodeToken ();
+    if($objectToken->retrieveToken($arrayRestInputs['token'])){
+      $thisUserUid = $objectToken->uid;
+      $thisUserObject = new User($thisUserUid);
+      return $thisUserObject->getBlockListNames();
+    }
+    else{
+      return array();
+    }
+  }
+  else{
+    return array();
+  }
+}
+
+
+function blockedbyGet($arrayRestInputs){
+  if((file_exists($arrayRestInputs['enginebasedir'] . '/lib/User.php')) && (file_exists($arrayRestInputs['enginebasedir'] . '/lib/NodeToken.php')) ){
+    require_once($arrayRestInputs['enginebasedir'] . '/lib/User.php');
+    require_once($arrayRestInputs['enginebasedir'] . '/lib/NodeToken.php');
+    $objectToken = new NodeToken ();
+    if($objectToken->retrieveToken($arrayRestInputs['token'])){
+      $thisUserUid = $objectToken->uid;
+      $thisUserObject = new User($thisUserUid);
+      return $thisUserObject->getBlockedByNames();
+    }
+    else{
+      return array();
+    }
+  }
+  else{
+    return array();
+  }
+}
+
+
+
+function addPost($arrayRestInputs){
+  $boolReturn = false;
+  if((file_exists($arrayRestInputs['enginebasedir'] . '/lib/User.php')) && (file_exists($arrayRestInputs['enginebasedir'] . '/lib/NodeToken.php')) ){
+    require_once($arrayRestInputs['enginebasedir'] . '/lib/User.php');
+    require_once($arrayRestInputs['enginebasedir'] . '/lib/NodeToken.php');
+    $objectToken = new NodeToken ();
+    if(($objectToken->retrieveToken($arrayRestInputs['token'])) && (!(empty($arrayRestInputs['post'])))){
+      $stringUserToAdd = $arrayRestInputs['post'];;
+      if((Planworld::isUser($stringUserToAdd))){
+        $thisUserUid = $objectToken->uid;
+        $thisUserObject = new User($thisUserUid);
+        $objectUserToAdd = new User($stringUserToAdd);
+        $boolUserInBlockList = $thisUserObject->isUserIdInBlocklist($objectUserToAdd->userID);
+        if(!$boolUserInPlanwatch){
+          $boolReturn = $thisPlanwatch->add($stringUserToAdd);
+        }
+      }
+    }
+  }
+  return $boolReturn;
+}
+
+
+function removePost($arrayRestInputs){
+  $boolReturn = false;
+  if((file_exists($arrayRestInputs['enginebasedir'] . '/lib/User.php')) && (file_exists($arrayRestInputs['enginebasedir'] . '/lib/NodeToken.php')) ){
+    require_once($arrayRestInputs['enginebasedir'] . '/lib/User.php');
+    require_once($arrayRestInputs['enginebasedir'] . '/lib/NodeToken.php');
+    $objectToken = new NodeToken ();
+    if(($objectToken->retrieveToken($arrayRestInputs['token'])) && (!(empty($arrayRestInputs['post'])))){
+      $stringUserToRemove = $arrayRestInputs['post'];;
+      if((Planworld::isUser($stringUserToAdd))){
+        $thisUserUid = $objectToken->uid;
+        $thisUserObject = new User($thisUserUid);
+        $objectUserToRemove = new User($stringUserToRemove);
+        $boolUserInBlockList = $thisUserObject->isUserIdInBlocklist($objectUserToRemove->userID);
+        if(!$boolUserInPlanwatch){
+          $boolReturn = $thisPlanwatch->remove($stringUserToRemove);
+        }
+      }
+    }
+  }
+  return $boolReturn;
+}
+
+
+?>
\ No newline at end of file
diff --git a/code/clientlib/3.00/debug.php b/code/clientlib/3.00/debug.php
new file mode 100644 (file)
index 0000000..597f13f
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+
+
+/* DEBUG CATEGORY VERBS FOR PLANWORLD CLIENT LAYER.
+
+  __VERY IMPORTANT__
+  1. This file is only active if there is a file called debug.on in the backend directory, which is not created by default in a new installation.
+  2. In production environments both this file and the debug.on file should be entirely removed.
+  These API calls are HIGHLY DANGEROUS and not meant for running in a live environment.
+
+*/
+
+
+
+
+function pseudologinGet($arrayRestInputs){
+  $tokenValue = '0';
+  if((file_exists($arrayRestInputs['enginebasedir'] . '/lib/Planworld.php')) && (file_exists($arrayRestInputs['enginebasedir'] . '/lib/User.php')) && (file_exists($arrayRestInputs['enginebasedir'] . '/lib/NodeToken.php')) && (file_exists($arrayRestInputs['enginebasedir'] . '/backend/debug.on')) ){
+    require_once($arrayRestInputs['enginebasedir'] . '/lib/Planworld.php');
+    require_once($arrayRestInputs['enginebasedir'] . '/lib/User.php');
+    require_once($arrayRestInputs['enginebasedir'] . '/lib/NodeToken.php');
+    if(count($arrayRestInputs['arguments']) > 1){
+      $arguments = $arrayRestInputs['arguments'];
+      $stringLoginUser = $arguments[0];
+      $stringPsuedoPassword = $arguments[1];
+      if(Planworld::isUser($stringLoginUser)){
+        $objectLoginUser = new User($stringLoginUser);
+        $intLoginUser = $objectLoginUser->userID;
+        $comparepass = str_replace('.', '', (str_replace('/', '', crypt($stringLoginUser, ((int)$intLoginUser + 45678)))));
+        if(strcmp($stringPsuedoPassword, $comparepass) == 0){
+          $nodeToken = new NodeToken ();
+          if($nodeToken->createToken($stringLoginUser, 'enginedebug')){
+            $tokenValue = $nodeToken->tokenNumber;
+          }
+        }
+      }
+    }
+  }
+  return $tokenValue;
+}
+
+?>
\ No newline at end of file
diff --git a/code/clientlib/3.00/watch.php b/code/clientlib/3.00/watch.php
new file mode 100644 (file)
index 0000000..051fc7b
--- /dev/null
@@ -0,0 +1,162 @@
+<?php
+
+
+/* WATCHLIST CATEGORY VERBS FOR PLANWORLD CLIENT LAYER. */
+
+
+
+function watchlistGet($arrayRestInputs){
+  if((file_exists($arrayRestInputs['enginebasedir'] . '/lib/Planwatch.php')) && (file_exists($arrayRestInputs['enginebasedir'] . '/lib/NodeToken.php')) ){
+    require_once($arrayRestInputs['enginebasedir'] . '/lib/Planwatch.php');
+    require_once($arrayRestInputs['enginebasedir'] . '/lib/NodeToken.php');
+    $objectToken = new NodeToken ();
+    if($objectToken->retrieveToken($arrayRestInputs['token'])){
+      $thisUserUid = $objectToken->uid;
+      $thisUserObject = new User($thisUserUid);
+      $thisPlanwatch = new Planwatch($thisUserObject);
+      return $thisPlanwatch->getInteroperableWatchlist();
+    }
+    else{
+      return '';
+    }
+  }
+  else{
+    return '';
+  }
+}
+
+
+function watchlistgroupGet($arrayRestInputs){
+  if((file_exists($arrayRestInputs['enginebasedir'] . '/lib/Planwatch.php')) && (file_exists($arrayRestInputs['enginebasedir'] . '/lib/NodeToken.php')) ){
+    require_once($arrayRestInputs['enginebasedir'] . '/lib/Planwatch.php');
+    require_once($arrayRestInputs['enginebasedir'] . '/lib/NodeToken.php');
+    $objectToken = new NodeToken ();
+    if($objectToken->retrieveToken($arrayRestInputs['token'])){
+      $thisUserUid = $objectToken->uid;
+      $thisUserObject = new User($thisUserUid);
+      $thisPlanwatch = new Planwatch($thisUserObject);
+      return $thisPlanwatch->getInteroperableWatchlistGroups();
+    }
+    else{
+      return '';
+    }
+  }
+  else{
+    return '';
+  }
+}
+
+
+function addgroupPost($arrayRestInputs){
+  $boolReturn = false;
+  if((file_exists($arrayRestInputs['enginebasedir'] . '/lib/Planwatch.php')) && (file_exists($arrayRestInputs['enginebasedir'] . '/lib/NodeToken.php')) ){
+    require_once($arrayRestInputs['enginebasedir'] . '/lib/Planwatch.php');
+    require_once($arrayRestInputs['enginebasedir'] . '/lib/NodeToken.php');
+    $objectToken = new NodeToken ();
+    if(($objectToken->retrieveToken($arrayRestInputs['token'])) && (!(empty($arrayRestInputs['post'])))){
+      $stringNewGroupName = $arrayRestInputs['post'];
+      if(Planworld::isValidWatchlistGroupName($stringNewGroupName)){
+        $thisUserUid = $objectToken->uid;
+        $thisUserObject = new User($thisUserUid);
+        $thisPlanwatch = new Planwatch($thisUserObject);
+        $boolNameDoesNotAlreadyExist = true;
+        $arrayOfCurrentGroupNames = $thisPlanwatch->getGroupNames();
+        foreach($arrayOfCurrentGroupNames as $currentGroupName){
+          if(strcasecmp($currentGroupName, $stringNewGroupName) == 0){
+            $boolNameDoesNotAlreadyExist = false;
+          }
+        }
+        if($boolNameDoesNotAlreadyExists){
+          $boolReturn = $thisPlanwatch->addGroup($stringNewGroupName);
+          $thisPlanwatch->save();
+        }
+      }
+    }
+  }
+  return $boolReturn;
+}
+
+
+
+function moveusergroupPost($arrayRestInputs){
+  $boolReturn = false;
+  if((file_exists($arrayRestInputs['enginebasedir'] . '/lib/Planwatch.php')) && (file_exists($arrayRestInputs['enginebasedir'] . '/lib/NodeToken.php')) ){
+    require_once($arrayRestInputs['enginebasedir'] . '/lib/Planwatch.php');
+    require_once($arrayRestInputs['enginebasedir'] . '/lib/NodeToken.php');
+    $objectToken = new NodeToken ();
+    if(($objectToken->retrieveToken($arrayRestInputs['token'])) && (count($arrayRestInputs['arguments']) > 0) && (!(empty($arrayRestInputs['post'])))){
+      $arguments = $arrayRestInputs['arguments'];
+      $stringUserToMove = $arguments[0];
+      $stringGroupToMoveTo = $arrayRestInputs['post'];
+      if((Planworld::isValidWatchlistGroupName($stringGroupToMoveTo)) && (Planworld::isUser($stringUserToMove))){
+        $thisUserUid = $objectToken->uid;
+        $thisUserObject = new User($thisUserUid);
+        $thisPlanwatch = new Planwatch($thisUserObject);
+        $boolGroupExists = false;
+        $boolUserInPlanwatch = $thisPlanwatch->inPlanwatch($stringUserToMove);
+        $matrixGroups = $thisPlanwatch->getGroups();
+        $intGidForGroupMove = -1;
+        foreach($matrixGroups as $nameGroup => $rowGroup){
+          if(strcasecmp($nameGroup, $stringGroupToMoveTo) == 0){
+            $boolGroupExists = true;
+            $intGidForGroupMove = $rowGroup['gid'];
+          }
+        }
+        if($boolGroupExists && $boolUserInPlanwatch){
+          $boolReturn = $thisPlanwatch->move($stringUserToMove, $intGidForGroupMove);
+          $thisPlanwatch->save();
+        }
+      }
+    }
+  }
+  return $boolReturn;
+}
+
+
+function addPost($arrayRestInputs){
+  $boolReturn = false;
+  if((file_exists($arrayRestInputs['enginebasedir'] . '/lib/Planwatch.php')) && (file_exists($arrayRestInputs['enginebasedir'] . '/lib/NodeToken.php')) ){
+    require_once($arrayRestInputs['enginebasedir'] . '/lib/Planwatch.php');
+    require_once($arrayRestInputs['enginebasedir'] . '/lib/NodeToken.php');
+    $objectToken = new NodeToken ();
+    if(($objectToken->retrieveToken($arrayRestInputs['token'])) && (!(empty($arrayRestInputs['post'])))){
+      $stringUserToAdd = $arrayRestInputs['post'];;
+      if((Planworld::isUser($stringUserToAdd))){
+        $thisUserUid = $objectToken->uid;
+        $thisUserObject = new User($thisUserUid);
+        $thisPlanwatch = new Planwatch($thisUserObject);
+        $boolUserInPlanwatch = $thisPlanwatch->inPlanwatch($stringUserToAdd);
+        $boolBlockedRelationshipExists = $thisUserObject->doesBlockRelationshipExist($stringUserToAdd);
+        if((!$boolUserInPlanwatch) && (!$boolBlockedRelationshipExists) ){
+          $boolReturn = $thisPlanwatch->add($stringUserToAdd);
+        }
+      }
+    }
+  }
+  return $boolReturn;
+}
+
+function removePost($arrayRestInputs){
+  $boolReturn = false;
+  if((file_exists($arrayRestInputs['enginebasedir'] . '/lib/Planwatch.php')) && (file_exists($arrayRestInputs['enginebasedir'] . '/lib/NodeToken.php')) ){
+    require_once($arrayRestInputs['enginebasedir'] . '/lib/Planwatch.php');
+    require_once($arrayRestInputs['enginebasedir'] . '/lib/NodeToken.php');
+    $objectToken = new NodeToken ();
+    if(($objectToken->retrieveToken($arrayRestInputs['token'])) && (!(empty($arrayRestInputs['post'])))){
+      $stringUserToRemove = $arrayRestInputs['post'];;
+      if((Planworld::isUser($stringUserToRemove))){
+        $thisUserUid = $objectToken->uid;
+        $thisUserObject = new User($thisUserUid);
+        $thisPlanwatch = new Planwatch($thisUserObject);
+        $boolUserInPlanwatch = $thisPlanwatch->inPlanwatch($stringUserToRemove);
+        if($boolUserInPlanwatch){
+          $boolReturn = $thisPlanwatch->remove($stringUserToRemove);
+        }
+      }
+    }
+  }
+  return $boolReturn;
+}
+
+
+?>
\ No newline at end of file