/** @test */
 public function parse_class_can_set_parameters_based_on_owner_model()
 {
     $this->model->addImage($this->uploaded_file);
     $image = $this->model->getImage();
     $this->assertEquals('/User/1/hadouken', $this->filepathmanager->parseOwnerClass($image, '/:owner_class/:owner_id/hadouken'));
     $this->assertEquals('/1/User/hadouken', $this->filepathmanager->parseOwnerClass($image, '/:owner_id/:owner_class/hadouken'));
     $this->assertEquals('User/1/hadouken', $this->filepathmanager->parseOwnerClass($image, ':owner_class/:owner_id/hadouken'));
     $this->assertEquals('1/User/hadouken', $this->filepathmanager->parseOwnerClass($image, ':owner_id/:owner_class/hadouken'));
     $this->assertEquals('/hadouken/User/1', $this->filepathmanager->parseOwnerClass($image, '/hadouken/:owner_class/:owner_id'));
     $this->assertEquals('/hadouken/1/User', $this->filepathmanager->parseOwnerClass($image, '/hadouken/:owner_id/:owner_class'));
     $this->assertEquals('/hadouken/User/1', $this->filepathmanager->parseOwnerClass($image, '/hadouken/:owner_class/:owner_id'));
     $this->assertEquals('/hadouken/1/User', $this->filepathmanager->parseOwnerClass($image, '/hadouken/:owner_id/:owner_class'));
 }
Example #2
0
 public function image_file_overides_old_files_when_relationship_is_added_again()
 {
     $this->model->addImage($this->uploaded_file);
     $image = $this->model->getImage();
     $firstFilePath = $image->getPath('original_style');
     $wasWrittenFirstTime = $this->filemanager->pathExists($firstFilePath);
     $this->assertTrue($wasWrittenFirstTime);
     $firstFilePathOtherStyle = $image->getPath('original_style2');
     $wasWrittenFirstTimeOtherStyle = $this->filemanager->pathExists($firstFilePathOtherStyle);
     $this->assertTrue($wasWrittenFirstTimeOtherStyle);
     $this->model->addImage($this->uploaded_file_2);
     $image = $this->model->getImage();
     $secondFilePath = $image->getPath('original_style');
     $secondFilePathOtherStyle = $image->getPath('original_style2');
     $wasWrittenSecondTime = $this->filemanager->pathExists($secondFilePath);
     $wasWrittenSecondTimeOtherStyle = $this->filemanager->pathExists($secondFilePathOtherStyle);
     $this->assertNotEquals($firstFilePath, $image->getPath('original_style'));
     $this->assertNotEquals($firstFilePathOtherStyle, $image->getPath('original_style2'));
     $this->assertTrue($wasWrittenSecondTime);
     $this->assertTrue($wasWrittenSecondTimeOtherStyle);
     $this->model->deleteImage();
 }
Example #3
0
" alt="profile_pic"/><br/>
                    <span><p>You Bought this <?php 
echo $product->getName();
?>
 for <span style="color:#2CBB76;font-weight:bold;text-decoration:underline;">$<?php 
echo $amt;
?>
!</span></p></span>
                    <span><p>5% is taken as a Service Charge - <span style="color:red;">$<?php 
echo $amt * 0.05;
?>
</span></p></span>
                </div>
                <div class="col-lg-4" id="seller_info">
                    <img style="margin-right:1em;margin-bottom:1em;" width="200px" height="250px" src="<?php 
echo $seller->getImage();
?>
" alt="profile_pic"/><br/>
                    <span>5% Towards <?php 
echo $charity->getName();
?>
: <span style="color:#2CBB76;font-weight:bold;text-decoration:underline;">$<?php 
echo $amt * 0.05;
?>
!</span></span><br/>
                    <span>85% for Seller <span style="color:#2CBB76;font-weight:bold;text-decoration:underline;">$<?php 
echo $amt * 0.85;
?>
!</span></span>
                    <hr style="margin:0;color:gray;"/>
                    <span>-2.75% for Credit Card Processing: <span style="color:red;">$<?php 
Example #4
0
 /**
  * Finds all users by a search string
  * Intended to be used without instantiating object
  *
  * @param string $string
  * @param int $user_id
  * @return string
  */
 public static function getUsersByName($string, $user_id)
 {
     global $f3, $db;
     if ($string) {
         $sql = "SELECT u.id, CONCAT('@', u.handle) AS handle, u.email, u.first_name, u.last_name, fs.id AS request_sent FROM user u ";
         $sql .= "LEFT JOIN friendship fs ON (fs.friend_id = u.id AND fs.user_id = ?)";
         $sql .= "WHERE handle LIKE ?";
         $sql_params = array($user_id, '%' . $string . '%');
         $query = $db->prepare($sql);
         $query->execute($sql_params);
         if ($users = $query->fetchAll(PDO::FETCH_OBJ)) {
             for ($i = 0; $i < sizeof($users); $i++) {
                 $found_user = new User(null, $users[$i]->id);
                 $users[$i]->image = $found_user->getImage();
                 unset($found_user);
             }
             return $users;
         } else {
             return false;
         }
     } else {
         return false;
         // throw new Exception('No email was provided/in object.');
     }
 }
Example #5
0
} else {
    // Connect to database
    $con = mysql_connect(DB_HOST, DB_USER, DB_PW);
    if (!$con) {
        die('Could not connect: ' . mysql_error());
    }
    mysql_select_db(DB_NAME, $con);
    $userObj = new User();
    // Get list of users for form
    $user_arr = User::getAll();
    // Build login form
    $form_str = "<div id=\"login\">";
    foreach ($user_arr as $user_id) {
        $userObj->setId($user_id);
        $userObj->load();
        $image = file_exists($userObj->getImage()) ? $userObj->getImage() : 'user.png';
        $form_str .= "<form action=" . $_SERVER['PHP_SELF'] . " method='post' class='form-inline'>";
        $form_str .= "<input type='hidden' name='user_id' value='{$user_id}'/>";
        $form_str .= "<input type='submit' value='' class='btn' style='background: url(images/{$image}) no-repeat center center' />";
        $form_str .= "<p>" . $userObj->getName() . "</p>";
        $form_str .= "</form>";
    }
    $form_str .= "</div>";
}
?>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Weather Debt Manager</title>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
Example #6
0
 public function testUser()
 {
     $user = new User(123, 'Admin', '*****@*****.**', 'Colin', 'Rosen', false, UserPermission::ADMINISTRATOR, true, false, true, "MEH");
     $this->assertEquals(123, $user->getID());
     $this->assertEquals('Admin', $user->getUsername());
     $this->assertEquals('*****@*****.**', $user->getEmail());
     $this->assertEquals('Colin', $user->getFirstname());
     $this->assertEquals('Rosen', $user->getSurname());
     $this->assertEquals('Colin Rosen', $user->getName());
     $this->assertEquals(false, $user->ForceOffline());
     $this->assertEquals(UserPermission::ADMINISTRATOR, $user->getPermission());
     $this->assertEquals(true, $user->isActive());
     $this->assertEquals(false, $user->isBlocked());
     $this->assertEquals(true, $user->isOnline());
     $this->assertEquals("MEH", $user->getImage());
 }
 /** @test */
 public function add_image_returns_attacher_image_if_image_added_successfully()
 {
     $this->model->addImage($this->uploaded_file);
     $this->assertTrue($this->model->getImage() instanceof AttacherImage);
     $this->model->deleteImage();
 }