function get() { $sql = "SELECT promo_id, brand_id, b.name AS brand_name,\n\t\t\t\tp.name, p.description, amount, imageURL, infoURL, \n\t\t\t\tp.created, p.updated, expires,\n\t\t\t\trelay_id, keyword,\n\t\t\t\tby_all_limit, by_brand_limit, by_user_limit, by_user_wait\n\t\t\tFROM promos p\n\t\t\tJOIN relays USING (relay_id)\n\t\t\tJOIN brands b USING (brand_id)\n\t\t\tWHERE promo_id=?"; $rows = DBquery::get($sql, array($this->promo_id)); if (!$rows) { return array(new stdClass()); } $r = $rows[0]; /*if (!Requester::isMember($rows[0]['brand_id'])) { $this->setForms(); }*/ foreach ($r as $k => $v) { $this->{$k} = $v; } if (!$this->imageURL) { $this->imageURL = Requester::$ProtDomain . "/ui/css/logo5.png"; } //."/ui/logo.php?brand=". $rows[0]['brand_name']; $this->code = "{$r['keyword']}-{$r['promo_id']}"; $this->payURL = Requester::$ProtDomain . "/for/{$this->code}"; $this->promoPage = "/ad/{$r['amount']}"; if (!$this->expires) { $this->expires = "2019-12-31 11:59:59"; } if (Requester::isMember($rows[0]['brand_id'])) { $this->edit = "/form/promo-edit"; } return array($this); }
function __construct($data = '') { $this->brand_id = $this->getID(); if (!Requester::isMember($this->brand_id)) { Error::http(403, "The '/team/{$this->brand_id}' resource is only viewable by members of brand #{$this->brand_id}."); } $this->{"@type"} = 'brand'; $this->{"@id"} = "{$this->root}/team/{$this->brand_id}"; $this->table = "members"; $this->init($data); $this->okToFilterBy = array("brand_id", "member_id"); $this->okToSet = array("joined", "revoked"); }
function __construct($data = '') { $this->{"@type"} = "teamOrders"; $this->brand_id = $this->getID(); if (!Requester::isMember($this->brand_id)) { Error::http(403, "Only members or admins of brand #{$this->brand_id} can view its orders."); } $this->{'@id'} = "{$this->root}/team/{$this->brand_id}/orders"; $this->table = "records"; $this->collectionOf = "order"; $this->init($data); $this->okToFilterBy = array("record_id"); }
function __construct($data = '') { $this->brand_id = $this->getID(); if (!Requester::isMember($this->brand_id)) { Error::http(403, "The requester is not a member of brand #{$this->brand_id}."); } $this->{"@type"} = 'accounts'; $this->{"@id"} = "{$this->root}/team/{$this->brand_id}/accounts"; $this->table = "accounts"; $this->idkey = 'account_id'; $this->collectionOf = "account"; $this->init($data); $this->okToGet = array("brand_id", "account_id", "name", "balance", "unit", "authcode"); }
function __construct($data = '') { $this->brand_id = $this->getID(); if (!Requester::isMember($this->brand_id)) { Error::http(403, "The '/team/{$this->brand_id}/members' resource is only viewable by members of brand #{$this->brand_id}."); } $this->{"@type"} = 'members'; $this->{"@id"} = "{$this->root}/team/{$this->brand_id}/members"; $this->table = "members"; $this->idkey = 'member_id'; $this->collectionOf = "member"; $this->init($data); $this->okToSet = array("role", 'hours', 'ended'); $this->okToFilterBy = array("member_id", "user_id"); }
function __construct($data = '') { //if (!isset($_GET['txntype'])) Error::http(400, "The request must have a value for the URL query parameter 'txntype'."); if (isset($_GET['txntype']) and !in_array($_GET['txntype'], array('np', 'nn', 'pp', 'pn'))) { Error::http(400, "The URL query parameter 'txntype' value must be 'np', 'nn', 'pp, OR 'pn'."); } $this->txntype = $_GET['txntype']; $this->subtype = (isset($_GET['subtype']) and $_GET['subtype']) ? $_GET['subtype'] : ''; $this->{"@type"} = "budgetRecords"; $this->brand_id = $this->getID(); if (!Requester::isMember($this->brand_id)) { Error::http(403, "Only members or admins of brand #{$this->brand_id} can view details of its budget activity."); } $this->{'@id'} = "{$this->root}/budget/{$this->brand_id}/records"; $this->table = "records"; $this->init($data); }
function get() { if (!Requester::isMember($this->brand_id)) { Error::http(403, "Only brand #{$this->brand_id} members have access to this brandThrottles view."); } $sql = "SELECT * FROM {$this->table} WHERE brand_id=? AND ended IS NULL"; $items = DBquery::get($sql, array($this->brand_id)); foreach ($items as &$t) { $t['id'] = $t['throttle_id']; unset($t['throttle_id']); $t['@id'] = "{$this->root}/throttle/" . $t['id']; $t['brand'] = "{$this->root}/team/{$this->brand_id}"; unset($t['brand_id']); $this->{$this->collectionOf}[] = $t; } $this->setForms(); return array($this); }
function get() { $this->setAddlCond(); //if (!$this->cond) $this->setForms(); $graph = array($this); $tracked = array(); $nestingRef = array("brand_" => array("@id" => "{$this->root}/brand/{id}/about", "@type" => "brand")); $sql = "SELECT promo_id, \n\t\t\t\tp.brand_id AS brand_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\tp.expires, \n\t\t\t\tkeyword,\n\t\t\t\tby_all_limit, \n\t\t\t\tby_brand_limit, \n\t\t\t\tby_user_limit, \n\t\t\t\tby_user_wait,\n\t\t\t\tnumUsers\n\t\t\tFROM promos p\n\t\t\tJOIN (\n\t\t\t\tSELECT promo_id, COUNT(DISTINCT from_user) as numUsers\n\t\t\t\tFROM records\n\t\t\t\twhere status=7 AND TIMESTAMPDIFF(DAY,created,NOW())<100\n\t\t\t\tGROUP BY promo_id\n\t\t\t\tORDER BY numUsers DESC\n\t\t\t) records USING (promo_id)\n\t\t\tJOIN relays USING (relay_id)\n\t\t\tJOIN brands USING (brand_id)\n\t\t\tWHERE promo_id {$this->ltgt} {$this->limitID} {$this->cond}\n\t\t\t\tAND (expires IS NULL OR expires>NOW())\n\t\t\t\tAND by_user_limit > 0 AND by_brand_limit > 0 AND by_all_limit > 0\n\t\t\tORDER BY promo_id {$this->pageOrder}\n\t\t\tLIMIT {$this->itemsLimit}"; $items = DBquery::get($sql, $this->condVals); Requester::detectMemberships(); foreach ($items as &$r) { $r['id'] = $r['promo_id']; $r['@id'] = "{$this->root}/promo/" . $r['promo_id']; $r['@type'] = 'promo'; if (Requester::isMember($r['brand_id'])) { $r['edit'] = '/form/promo-edit'; } $this->nestResources($r, $nestingRef, $graph, $tracked); $r['promoPage'] = Requester::$ProtDomain . "/ad/{$r['promo_id']}"; $r['code'] = "{$r['keyword']}-{$r['promo_id']}"; $r['payURL'] = Requester::$ProtDomain . "/for/{$r['code']}"; $r['amount'] = round($r['amount'], 2); if (!$r['imageURL']) { //$r['imageURL'] = "/ui/logo.php?brand=". $r['brand_name']; //$images[] = BrandLogo::wrap($r['brand_name'], $r['imageURL'], 'base64svg'); //$r['imageURL'] = BrandLogo::base64svg($r['brand_name'], $r['imageURL']); //$r['imageURL'] = BrandLogo::dataURL($r['brand_name']); $r['imageTemplate'] = "/ui/logo.php"; } if (!$r['expires']) { $r['expires'] = "2019-12-31 11:59:59"; } $this->{$this->collectionOf}[] = $r['@id']; $p[] = $r; $graph[] = $r; } $this->setPageOf(array("brand_id", "for", "keyword", "id")); $this->paginate('promo_id', $p); if ($this->cond) { return $graph; } return array_merge($graph, array(BrandLogo::svgTemplate())); }
function __construct($data = '') { $this->brand_id = $this->getID(); if (!Requester::isMember($this->brand_id)) { Error::http(403, "The requester is not a member of brand #{$this->brand_id}."); } $this->{"@type"} = "brandPromos"; $params = $_GET ? '?' . http_build_query($_GET) : ''; $this->{'@id'} = "{$this->root}/brand/{$this->brand_id}/promos" . $params; $this->table = "promos"; $this->idkey = 'promo_id'; $this->collectionOf = "promo"; if (Router::$method == 'add' or Router::$method == 'set') { $this->translateInput($data); } $this->pageOrder = "desc"; //prevents being reset $this->init($data); $this->okToFilterBy = array("brand_id", "promo_id", 'expires'); }