function session($name, $value = false) { if ($value !== false) { mda_set($_SESSION, $name, $value); } return mda_get($_SESSION, $name); }
public static function update($staff_id, $data) { $update = array('email' => mda_get($data, 'email'), 'name' => mda_get($data, 'name'), 'is_manager' => mda_get($data, 'is_manager') ? 1 : 0); if (mda_get($data['password'])) { $update['password'] = bcrypt(mda_get($data, 'password')); } return Db::_get()->update('staff', 'staff_id', $staff_id, $update); }
public function write($position = 0, $data = null) { $rv = $this->io->write($position, $data); $bytes_written = mda_get($rv, 'bytes_written'); if (!is_numeric($bytes_written)) { return false; } return $bytes_written; }
public static function get($var = false) { if (!static::$session) { throw new Exception('No session exists', E_SESSION_NO_SESSION); } if (!$var) { return static::$session; } return mda_get(static::$session, $var); }
public static function get($sec = null, $name = null) { if (is_null($sec)) { return self::_get()->config; } if (self::_get()->debug) { printf("Config::get(%s%s)\n", $sec, is_null($name) ? '' : sprintf(',%s', $name)); } if (!mda_exists(self::_get()->config, $sec, $name)) { throw new Exception('Config var doesnt exist: ' . $sec . '.' . $name); } return mda_get(self::_get()->config, $sec, $name); }
public function __call($name, $args) { if (strpos($name, 'get') === 0) { $name = self::_realName($name, 'get'); return mda_get($this->data, $name); } if (strpos($name, 'set') === 0) { $name = self::_realName($name, 'set'); return mda_set($this->data, $name, array_shift($args)); } //we dont know what to do with this return false; }
public function getRequest($key = false) { if ($key === false) { //remove api key from request $request = $this->request; if (is_array($request) && isset($request['xport_auth_key'])) { unset($request['xport_auth_key']); } //send back return $request; } return mda_get($this->request, $key); }
protected static final function addMacroFields($c) { if (!is_array($c)) { return false; } //inject some value-added calculated pseudofields (rather than dupe this logic in multiple controllers) //add account_id for legacy purposes and generic purposes $c['account_id'] = $c[static::$account_key]; //check if this contact has a account_id (is an account) $c['__is_account'] = is_numeric(mda_get($c, 'account_id')) ? true : false; //generate standard displayed contact and account_id $c['contact_id_display'] = sprintf('%08d', mda_get($c, 'contact_id')); $c['account_id_display'] = mda_get($c, '__is_account') ? sprintf('%08d', mda_get($c, 'account_id')) : '(none)'; //generate standard displayed dates $c['created_display'] = date(Config::get('account.date.standard_format'), mda_get($c, 'created')); $c['contact_created_display'] = date(Config::get('account.date.standard_format'), mda_get($c, 'contact_created')); $c['last_login_display'] = mda_get($c, 'last_login') > 0 ? date(Config::get('account.date.standard_format'), mda_get($c, 'last_login')) : '(never)'; $c['contact_last_login_display'] = mda_get($c, 'contact_last_login') > 0 ? date(Config::get('account.date.standard_format'), mda_get($c, 'contact_last_login')) : '(never)'; $c['header_last_login'] = mda_get($c, 'contact_last_login_display'); if (mda_get($c, '__auth') & 2) { $c['header_last_login'] = mda_get($c, 'last_login_display'); } return array_merge($c); }
protected function errorHandler($result) { if (($msg = mda_get($result, 'error.msg')) != null && ($code = mda_get($result, 'error.code')) != null) { $obj = mda_get($result, 'error.exception'); if (!is_null($obj)) { $e = unserialize(base64_decode($obj)); if (is_object($e)) { switch ($this->getExceptMode()) { case self::EXCEPT_EXTRA: case self::EXCEPT_FULL: $class = get_class($e); throw new $class($e, $e->getCode()); break; case self::EXCEPT_NORMAL: default: throw $e; break; } } } throw new Exception($msg, $code); } return true; }
public static final function formatBlockShort(&$contact) { return strlen($address = (mda_get($contact, 'address_1') ? mda_get($contact, 'address_1') . PHP_EOL : '') . (mda_get($contact, 'address_2') ? mda_get($contact, 'address_2') . PHP_EOL : '') . (mda_get($contact, 'city') ? mda_get($contact, 'city') : '') . (mda_get($contact, 'state') ? ', ' . mda_get($contact, 'state') : '') . (mda_get($contact, 'zip') ? ' ' . mda_get($contact, 'zip') : '') . (mda_get($contact, 'country') ? ' ' . mda_get($contact, 'country') : '')) > 0 ? $address . PHP_EOL : ''; }
public function stream_stat() { $stat = array(); // 0 dev device number $stat[0] = $stat['dev'] = mda_get($this->info, 'dev'); // 1 ino inode number * $stat[1] = $stat['ino'] = mda_get($this->info, 'ino'); // 2 mode inode protection mode $stat[2] = $stat['mode'] = mda_get($this->info, 'mode'); // 3 nlink number of links $stat[3] = $stat['nlink'] = mda_get($this->info, 'nlink'); // 4 uid userid of owner * $stat[4] = $stat['uid'] = mda_get($this->info, 'uid'); // 5 gid groupid of owner * $stat[5] = $stat['gid'] = mda_get($this->info, 'gid'); // 6 rdev device type, if inode device $stat[6] = $stat['rdev'] = mda_get($this->info, 'rdev'); // 7 size size in bytes $stat[7] = $stat['size'] = $this->getSize(); // 8 atime time of last access (Unix timestamp) $stat[8] = $stat['atime'] = $this->getAtime(); // 9 mtime time of last modification (Unix timestamp) $stat[9] = $stat['mtime'] = $this->getMtime(); //10 ctime time of last inode change (Unix timestamp) $stat[10] = $stat['ctime'] = $this->getCtime(); //11 blksize blocksize of filesystem IO ** $stat[11] = $stat['blksize'] = mda_get($this->info, 'blksize'); if ($stat['blksize'] == 0) { $stat[11] = $stat['blksize'] = 512; } //12 blocks number of 512-byte blocks allocated ** $stat[12] = $stat['blocks'] = ceil($this->getSize() / $stat['blksize']); return $stat; }
public static function delete($identifier, $data, $type = 'A') { $identifier = self::_cleanHostname($identifier); $data = self::_cleanHostname($data); $type = strtoupper($type); $record = self::fetchRecord(array('type' => $type, 'name' => $identifier, 'content' => $data)); $info = '"' . $identifier . ' ' . $type . ' ' . $data . '"'; if (is_array($record) && is_numeric(mda_get($record, 'id'))) { dolog('Record ' . $info . ' found, deleting'); return self::deleteRecord($record); } dolog('Record ' . $info . ' NOT found'); return false; }
public function testMDAAdd() { $test = self::$test; mda_add($test, 'test2', 1); $this->assertEquals(1, mda_get($test, 'test2', 0)); }
public function getParam($key) { return mda_get($this->params, $key); }