示例#1
0
 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);
 }
示例#2
0
 function verifyOther()
 {
     if (strpos($this->from_acct, '-')) {
         list($holder_id, $limkey) = explode("-", $this->from_acct);
         $sql = "SELECT user_id, account_id, limkey, authcode FROM holders WHERE holder_id={$holder_id}";
         $row = DBquery::get($sql);
         if ($row[0]['limkey'] != $limkey) {
             Error::http(401, 'Invalid limkey.');
         }
         $this->addKeyVal('from_acct', $row[0]['account_id']);
         $this->addKeyVal('from_user', $row[0]['user_id']);
         $this->from_holder = $row[0];
     } else {
         $this->from_holder = Requester::isAccountHolder($this->from_acct);
         if (!$holder) {
             Error::http(401, 'The to_acct must be held by the Requester or submitted as encoded relay information.');
         }
         $this->addKeyVal('from_user', Requester::$user_id);
     }
 }
示例#3
0
 function __construct($data = '')
 {
     $this->account_id = $this->getID();
     if (!($info = Requester::isAccountHolder($this->account_id))) {
         Error::http(403, "The requester is not an accountholder for account #{$this->account_id}.");
     }
     $this->brand_id = $info['brand_id'];
     $this->holder_id = $info['holder_id'];
     $this->limkey = $info['limkey'];
     $this->{"@type"} = "accountRecords";
     $this->{'@id'} = "{$this->root}/account/{$this->account_id}/records";
     $this->table = "records";
     $this->idkey = 'account_id';
     $this->pageOrder = "desc";
     //prevents being reset
     $this->collectionOf = "record";
     $this->init($data);
     $this->okToGet = array("brand_id", "account_id", "name", "balance", "unit", "authcode");
     $this->okToSet = array("status");
     $this->okToFilterBy = array("record_id");
 }