function set() { $this->setDetails(); if (!Requester::isBrandAdmin($this->brand_id)) { Error::http(403, "The requester is not an admin for brand #{$this->brand_id}."); } $this->update(array("throttle_id" => $this->throttle_id)); return array($this->obj); }
function get() { if (!Requester::isBrandAdmin($this->brand_id)) { Error::http(403, "Only admins of brand #{$this->brand_id} can view details of its budget issuance records."); } $sql = "SELECT r.record_id, r.created, from_acct, from_user, to_acct, to_user, amount, `note`\n\t\tFROM records r JOIN accounts a ON (r.from_acct = a.account_id)\n\t\tWHERE brand_id=? AND txntype='pn' \n\t\tORDER BY record_id DESC LIMIT 50"; $this->items = DBquery::get($sql, array($this->brand_id)); $this->setForms(); return array($this); }
function __construct($data = '') { $this->brand_id = $this->getID(); if (!Requester::isBrandAdmin($this->brand_id)) { Error::http(403, "The requester is not an admin for brand #{$this->brand_id}."); } $this->{"@type"} = 'brand'; $this->{"@id"} = "{$this->root}/brand/{$this->brand_id}"; $this->role = "admin"; $this->table = "brands"; $this->init($data); $this->okToSet = array("name", "ended", "mission", "description", "url", "advisor", "type_system", "type_id", "country_code", "area_code", "logo"); $this->okToFilterBy = array("brand_id"); }
function __construct($data = '') { $this->brand_id = $this->getID(); if (!Requester::isBrandAdmin($this->brand_id)) { Error::http(403, "The requester is not an admin for brand #{$this->brand_id}."); } $this->{"@type"} = 'brandAccounts'; $this->{"@id"} = "{$this->root}/brand/{$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"); $this->okToAdd = array("brand_id", 'name', 'authcode', 'unit', 'sign'); $this->okToSet = array("name", "authcode", "throttle_id"); $this->okToFilterBy = array("brand_id", "account_id"); }
function get() { $info = $this->getInfo()[0]; if (!$info) { return array(); } if (Requester::isBrandAdmin($info['brand_id'])) { $info['holders'] = $this->getByAdmin(); } else { if (Requester::isAccountHolder($this->account_id)) { $info['holders'] = $this->getByHolder(); } else { return array(array("balance" => $info['sign'] * $info['balance'], "unit" => $info['unit'])); } } return array($info); }
function __construct($data = '') { $this->brand_id = $this->getID(); if (!Requester::isBrandAdmin($this->brand_id)) { Error::http(403, "The requester is not an admin for brand #{$this->brand_id}."); } $this->{"@type"} = 'brandHolders'; $this->{"@id"} = "{$this->root}/brand/{$this->brand_id}/holders"; $this->table = "holders"; $this->idkey = 'holder_id'; $this->collectionOf = "holder"; $this->init($data); $this->okToAdd = array("user_id", "account_id", "authcode", "limkey"); $this->okToSet = array("authcode", "ended"); $this->okToFilterBy = array("account_id", "user_id", "holder_id"); $this->okToGet = array('holder_id', 'account_id', 'authcode'); }
function __construct($data = '') { $this->account_id = $this->getID(); $this->setDetails(); if (!Requester::isBrandAdmin($this->brand_id)) { Error::http(403, "Only brand admins can access member accounts resource."); } $this->{"@type"} = "accountHolders"; $this->{'@id'} = "{$this->root}/account/{$this->account_id}/holders"; $this->table = "holders"; $this->idkey = 'holder_id'; $this->collectionOf = "holder"; $this->init($data); $this->okToAdd = array("user_id", "account_id", "authcode", "limkey"); $this->okToGet = array("holder_id", "holder_auth", "brand_id", "account_id", "name", "account_auth"); $this->okToSet = array("authcode", "ended"); $this->okToFilterBy = array("holder_id"); }
function set() { if ($this->member_id) { $this->setDetails(); } if (Requester::isBrandAdmin($this->brand_id)) { array_push($this->okToSet, "role", 'hours', 'ended'); array_push($this->okToFilterBy, "brand_id", "member_id"); } if ($this->user_id == Requester::$user_id) { array_push($this->okToSet, "hours", 'ended'); array_push($this->okToFilterBy, "member_id"); if ($this->ended and $this->user_id == Requester::$user_id) { Error::http(403, 'To prevent a brand from not having an admin, an admin cannot deactivate his own membership.'); } } $this->update("WHERE member_id=?", array($this->member_id)); return $this; }
function __construct($data = '') { $this->brand_id = $this->getID(); if (!$this->brand_id and $data->brand_id) { $this->brand_id = $data->brand_id; } if (!Requester::isBrandAdmin($this->brand_id)) { Error::http(403, "The requester is not an admin for brand #{$this->brand_id}."); } $this->{"@type"} = 'brandMembers'; $this->{"@id"} = "{$this->root}/brand/{$this->brand_id}/members"; $this->table = "members"; $this->idkey = 'member_id'; $this->collectionOf = "member"; $this->init($data); $this->okToAdd = array("brand_id", 'user_id', 'role', 'hours'); $this->okToSet = array("role", 'hours', 'ended'); $this->okToFilterBy = array("member_id", "user_id"); }