Esempio n. 1
0
 /**
  * fetches an array from Database and returns an array of User objects
  * located in memory.
  *
  * @return array
  */
 public function findAll()
 {
     $resultSet = $this->adapter->findAll();
     $entries = array();
     foreach ($resultSet as $row) {
         $entries[] = $this->mapObject($row);
     }
     return $entries;
 }
Esempio n. 2
0
 public static function getInstance()
 {
     if (!self::$__instance) {
         self::$__instance = new DBAL();
     }
     return self::$__instance;
 }
Esempio n. 3
0
 public static function validateUser($email, $password)
 {
     $user = DBAL::getInstance()->getUserByEmail($email);
     if (count($user) == 0) {
         // Throw UserNotFoundException
         return false;
     } else {
         if (sha1($user['salt'] . $password) == $user['password']) {
             Authentication::setSession($user['id']);
             return true;
         } else {
             return false;
         }
     }
 }
Esempio n. 4
0
 public static function excludeTipo($id)
 {
     $db = new DBAL();
     return $db->delete("tipo", "idTipo", $id);
 }
Esempio n. 5
0
 public static function getDistinctDates()
 {
     $db = new DBAL();
     return $db->select("SELECT DISTINCT dtEntrega FROM entrega");
 }
Esempio n. 6
0
 /**
  * @method GET
  */
 function getTags()
 {
     return json_encode(DBAL::getInstance()->getTopTags());
 }
Esempio n. 7
0
 public function findOne($conditions = null, $fields = '*')
 {
     return parent::findOneBy($this->dbtable, $fields, $conditions);
 }
Esempio n. 8
0
 public static function excludePedido($id)
 {
     $db = new DBAL();
     return $db->delete("pedido", "idPedido", $id);
 }
Esempio n. 9
0
 public static function excludeQuimica($id)
 {
     $db = new DBAL();
     return $db->delete("quimica", "idQuimica", $id);
 }
Esempio n. 10
0
 public static function excludeMaterial($id)
 {
     $db = new DBAL();
     return $db->delete("material", "idMaterial", $id);
 }
Esempio n. 11
0
 public static function excludeUsuario($id)
 {
     $db = new DBAL();
     return $db->delete("usuario", "idUsuario", $id);
 }
Esempio n. 12
0
 /**
  * @method GET
  */
 function getUsers()
 {
     return json_encode(DBAL::getInstance()->getUsers());
 }
Esempio n. 13
0
 public static function getDistinctDates()
 {
     $db = new DBAL();
     return $db->select("SELECT DISTINCT dtPagamento FROM pagamento");
 }
Esempio n. 14
0
 public static function excludeProduto($id)
 {
     $db = new DBAL();
     return $db->delete("produto", "idProduto", $id);
 }
 /**
  * @expectedException InvalidArgumentException
  * @expectedExceptionMessage User #404 not found
  */
 public function testNotFound()
 {
     $this->dbal->expects($this->once())->method('find')->with(404)->will($this->returnValue(array()));
     $user = $this->mapper->findById(404);
 }
Esempio n. 16
0
 public static function excludeMedida($id)
 {
     $db = new DBAL();
     return $db->delete("medida", "idMedida", $id);
 }
Esempio n. 17
0
<?php

require_once '../class/DBAL.php';
require_once '../class/ImageInfo.php';
$db = DBAL::getInstance();
$user_id = 1;
// This should be replaced with some sort of authentication service
if (isset($_FILES) && !empty($_FILES) && isset($_GET) && !empty($_GET)) {
    $thumbnails = array();
    $filename = $user_id . "_" . rand(0, 10000);
    $phy_path = dirname(__FILE__) . "\\..\\upload\\";
    $uri_path = 'http://' . $_SERVER['SERVER_NAME'] . dirname($_SERVER["REQUEST_URI"]) . '/../upload/';
    $tmp_file = $_FILES["file"]["tmp_name"];
    $org_file = $phy_path . $filename . ".jpg";
    move_uploaded_file($tmp_file, $org_file);
    $info = ImageInfo::getImageInfo($org_file);
    $latitude = $info['lat'];
    $longitude = $info['lng'];
    $photo_shot = $info['photo_shot'];
    $description = $_GET['description'];
    $tags = explode(',', $_GET['tags']);
    if (!empty($latitude)) {
        // Create three pictures, 2 thumbnails and one main
        // Dimensions
        // Small: 160x120
        // Medium: 260x180
        // Large: 640x480
        array_push($thumbnails, array('phy_path' => create_thumb($org_file, $phy_path . $filename . "_small.jpg", 160, 120), 'uri_path' => $uri_path . $filename . "_small.jpg", 'type' => 0));
        array_push($thumbnails, array('phy_path' => create_thumb($org_file, $phy_path . $filename . "_medium.jpg", 260, 180), 'uri_path' => $uri_path . $filename . "_medium.jpg", 'type' => 1));
        array_push($thumbnails, array('phy_path' => create_thumb($org_file, $phy_path . $filename . "_large.jpg", 640, 480), 'uri_path' => $uri_path . $filename . "_large.jpg", 'type' => 2));
        $db->insertPicture($user_id, $phy_path . $filename . ".jpg", $uri_path . $filename . ".jpg", $latitude, $longitude, $photo_shot, $description, $tags, $thumbnails);
Esempio n. 18
0
 /**
  * @method GET
  * @param int $user_id
  */
 function listPictures($tags)
 {
     return json_encode(DBAL::getInstance()->getPicturesByTags($tags));
 }