Exemple #1
0
 function get()
 {
     $graph = array($this);
     $tracked = array();
     $this->add = "{$this->root}/form/promo-add";
     $this->setFilters($_GET);
     $nestingRef = array("brand_" => array("@id" => "{$this->root}/team/{id}", "@type" => "brand"), "relay_" => array("@id" => "{$this->root}/relay/{id}", "@type" => "relay", "edit" => "/form/relay-edit", "by_all_limit" => "{by_all_limit}"));
     $sql = "SELECT promo_id AS id, \n\t\t\t\tbrand_id, \n\t\t\t\tbrands.name AS brand_name, \n\t\t\t\tp.name AS name, \n\t\t\t\tp.description AS description, \n\t\t\t\tamount, \n\t\t\t\timageURL, \n\t\t\t\tinfoURL, \n\t\t\t\tp.created, \n\t\t\t\tp.updated, \n\t\t\t\texpires, \n\t\t\t\trelay_id, \n\t\t\t\tkeyword, \n\t\t\t\tby_all_limit AS relay_by_all_limit, \n\t\t\t\tby_brand_limit AS relay_by_brand_limit, \n\t\t\t\tby_user_limit AS relay_by_user_limit, \n\t\t\t\tby_user_wait AS relay_by_user_wait\n\t\t\tFROM promos p\n\t\t\tJOIN relays r USING (relay_id)\n\t\t\tJOIN brands USING (brand_id)\n\t\t\tWHERE brand_id={$this->brand_id} {$this->filterCond} AND promo_id {$this->ltgt} {$this->limitID}\n\t\t\tORDER BY id ASC\n\t\t\tLIMIT {$this->itemsLimit}";
     $items = DBquery::get($sql, $this->filterValArr);
     foreach ($items as &$r) {
         $this->nestResources($r, $nestingRef, $graph, $tracked);
         $r['@id'] = "{$this->root}/promo/" . $r['id'];
         $r['@type'] = 'promo';
         $r['payURL'] = Requester::$ProtDomain . "/for/{$r['keyword']}-{$r['id']}";
         $r['code'] = "{$r['keyword']}-{$r['id']}";
         $r['promoPage'] = Requester::$ProtDomain . "/ad/{$r['id']}";
         if (!$r['infoURL']) {
             $r['infoURL'] = $r['promoPage'];
         }
         $r['edit'] = '/form/promo-edit';
         $relayHoldings = array();
         if (in_array($r['relay_id'], $relayHoldings) or Requester::isRelayHolder($r['relay_id'])) {
             $relayHoldings[] = $r['relay_id'];
             $r['relay-edit'] = '/form/relay-edit';
             $r['relay-edit-target'] = "/relay/" . $r['relay_id'];
         }
         $r['brand'] = "{$this->root}/brand/{$this->brand_id}";
         $this->{$this->collectionOf}[] = $r['@id'];
         $graph[] = $r;
     }
     $this->paginate('promo_id');
     return $graph;
 }
Exemple #2
0
 function __construct($data = '')
 {
     $this->relay_id = $this->getID();
     if (Router::$resource == 'relay' and !Requester::isRelayHolder($this->relay_id)) {
         Error::http(403, "The user does not have access to this accountholder's information.");
     }
     $this->{"@type"} = "relay";
     $this->{'@id'} = "{$this->root}/relay/{$this->relay_id}";
     $this->table = "relays";
     $this->idkey = 'relay_id';
     $this->init($data);
     $this->okToFilterBy = array('relay_id');
 }