function updateTables($version)
{
    Auth::updateTables($version);
    Comment::updateTables($version);
    Feedback::updateTables($version);
    Journal::updateTables($version);
    Media::updateTables($version);
    Setting::updateTables($version);
    Trip::updateTables($version);
    TripAttribute::updateTables($version);
    TripUser::updateTables($version);
    User::updateTables($version);
    print "Tables have been updated. ";
}
 public function testUpdateDatabase()
 {
     $version = Setting::getDataVersion();
     $this->assertTrue(Auth::updateTables($version, ''));
     $this->assertTrue(Comment::updateTables($version, ''));
     $this->assertTrue(Feedback::updateTables($version, ''));
     $this->assertTrue(Journal::updateTables($version, ''));
     $this->assertTrue(Media::updateTables($version, ''));
     $this->assertTrue(Trip::updateTables($version, ''));
     $this->assertTrue(TripAttribute::updateTables($version, ''));
     $this->assertTrue(TripUser::updateTables($version, ''));
     $this->assertTrue(User::updateTables($version, ''));
     // Note: make sure the Settings::updateTables is last: when any of the
     // above fail, the data version in the database should NOT be updated!
     $this->assertTrue(Setting::updateTables($version, ''));
 }
 /**
  * Extra test
  * Make sure that a long text is saved in the comment, one that has
  * at least more than 256 characters.
  * @depends testSaveEmptyObject
  * @depends testSetAttributes
  */
 public function testLongText()
 {
     global $testTripId1, $testUserId1;
     $longText = "This is a long text. This is a very long text. This is a ver, very long text. In fact, this text will just go on and on and on, for up to 400 characters. So when we set and retrieve this text, we will know for sure that the system supports these long texts. Of course, if this fails, we won't know any such thing for sure. Would that be to happen, we will have to go and spend some quality debugging time with the system.";
     $object = new TripUser($testTripId1, $testUserId1);
     $object->setMessage($longText);
     $this->assertTrue($object->save());
     $object = new TripUser($testTripId1, $testUserId1);
     $this->assertEquals($longText, $object->getMessage());
 }
                 $response['role'] = $object->getRole();
                 $response['message'] = $object->getMessage();
                 $response['deleted'] = $object->getDeleted();
                 $response['hash'] = $object->getHash();
             }
         }
     } else {
         $response = errorResponse(RESPONSE_BAD_REQUEST);
     }
 } else {
     if (isPutMethod()) {
         $data = getPostData();
         if (isset($data['tripId']) && isset($data['userId']) && $data['tripId'] !== '' && $data['userId'] !== '') {
             $tripId = $data['tripId'];
             $userId = $data['userId'];
             $object = new TripUser($tripId, $userId);
             if (isset($data['created'])) {
                 $object->setCreated($data['created']);
             }
             if (isset($data['updated'])) {
                 $object->setUpdated($data['updated']);
             }
             if (isset($data['role'])) {
                 $object->setRole($data['role']);
             }
             if (isset($data['message'])) {
                 $object->setMessage($data['message']);
             }
             if (isset($data['deleted'])) {
                 $object->setDeleted($data['deleted']);
             }
Exemple #5
0
 /**
  * Create an instance by the hash value. This function is in support
  * of the synchronization functionality. It takes a hash value and
  * it will return an instance of the object for that hash value
  * if the hash exists. If the hash does not exist, null will be
  * returned, indicating that the object should be created using the
  * normal constructor.
  */
 public static function findByHash($hash = '')
 {
     if (!isset($hash) || $hash === '') {
         return null;
     }
     $hashValue = db_sql_encode($hash);
     $query = "SELECT * FROM blogTripUser " . "WHERE hash={$hashValue} " . "ORDER BY updated DESC " . "LIMIT 1";
     $result = mysql_query($query);
     if (!$result) {
         // Error executing the query
         print $query . "<br/>";
         print " --> error: " . mysql_error() . "<br/>\n";
         return null;
     }
     if (mysql_num_rows($result) <= 0) {
         // Object does not exist
         return null;
     }
     // Create an instance with a special ID '-' to bypass the
     // checks on empty ID. The ID value will be overwritten by the
     // value coming back from the database anyway.
     $object = new TripUser('-', '-');
     if ($object->loadFromResult($result)) {
         return $object;
     }
     return null;
 }
Exemple #6
0
    $response = errorResponse(RESPONSE_UNAUTHORIZED);
} else {
    if (isPutMethod()) {
        $data = getPostData();
        $tripId = '';
        if (isset($data['tripId'])) {
            $tripId = $data['tripId'];
        }
        $userId = '';
        if (isset($data['userId'])) {
            $userId = $data['userId'];
        }
        if ($tripId === '' || $userId === '') {
            $response = errorResponse(RESPONSE_BAD_REQUEST);
        } else {
            $object = new TripUser($tripId, $userId);
            if (isset($data['role'])) {
                $object->setRole($data['role']);
            }
            if (isset($data['message'])) {
                $object->setMessage($data['message']);
            }
            if (isset($data['deleted'])) {
                $object->setDeleted($data['deleted']);
            }
            if ($object->save()) {
                $response = successResponse();
            } else {
                $response = errorResponse(RESPONSE_INTERNAL_ERROR);
            }
        }
 /**
  * Test #13. SYNCH request write new object.
  */
 public function testSynchPut()
 {
     global $testTripId1, $testUserId1;
     global $synchAuthToken;
     $this->assertEquals(0, $this->countTestRows());
     $data = array('tripId' => $testTripId1, 'userId' => $testUserId1, 'created' => '2015-10-01', 'updated' => '2015-10-02', 'role' => 'maintainer', 'message' => 'Message TripUser 1', 'deleted' => 'Y', 'hash' => 'forced hash');
     $result = putApi('synchTripUser.php', $data, $synchAuthToken);
     $this->assertEquals(RESPONSE_SUCCESS, $result['resultCode']);
     $this->assertEquals(1, $this->countTestRows());
     $object = new TripUser($testTripId1, $testUserId1);
     $this->assertEquals('2015-10-01 00:00:00.000000', $object->getCreated());
     $this->assertEquals('2015-10-02 00:00:00.000000', $object->getUpdated());
     $this->assertEquals('maintainer', $object->getRole());
     $this->assertEquals('Message TripUser 1', $object->getMessage());
     $this->assertEquals("Y", $object->getDeleted());
     $this->assertEquals('forced hash', $object->getHash());
 }
Exemple #8
0
$auth = new AuthB();
if (!$auth->canGetMedia()) {
    $response = errorResponse(RESPONSE_UNAUTHORIZED);
} else {
    $tripId = '';
    if (isset($_GET['tripId'])) {
        $tripId = $_GET['tripId'];
    }
    $userId = '';
    if (isset($_GET['userId'])) {
        $userId = $_GET['userId'];
    }
    if ($tripId === '' || $userId === '') {
        $response = errorResponse(RESPONSE_BAD_REQUEST);
    } else {
        $object = new TripUser($tripId, $userId);
        if ($object->getCreated() === null) {
            $response = errorResponse(RESPONSE_NOT_FOUND);
        } else {
            $response = successResponse();
            $response['tripId'] = $object->getTripId();
            $response['userId'] = $object->getUserId();
            $response['created'] = $object->getCreated();
            $response['updated'] = $object->getUpdated();
            $response['role'] = $object->getRole();
            $response['message'] = $object->getMessage();
            $response['deleted'] = $object->getDeleted();
        }
    }
}
echo json_encode($response);