private static function createAccessToken($user, $actor, $type) { $user = self::getUser($user); if ($user === null) { return "User not found"; } $actor = self::getActor($actor); if ($actor === null) { return "Invalid target for access token creation"; } try { $token = new Default_Model_AccessToken(); $token->actorid = $actor->guid; $token->type = $type; $token->addedbyid = $user->id; $token->save(); } catch (Exception $ex) { return $ex->getMessage(); } return true; }
public function save(Default_Model_AccessToken $value) { global $application; $data = array(); if (!isnull($value->getId())) { $data['id'] = $value->getId(); } if (!isnull($value->getToken())) { $data['token'] = $value->getToken(); } if (!isnull($value->getActorid())) { $data['actor'] = $value->getActorid(); } if (!isnull($value->getCreatedOn())) { $data['createdon'] = $value->getCreatedOn(); } if (!isnull($value->getType())) { $data['type'] = $value->getType(); } if (!isnull($value->getAddedByID())) { $data['addedby'] = $value->getAddedByID(); } $q1 = 'id = ?'; $q2 = $value->id; if (null === ($id = $value->id)) { unset($data['id']); $value->id = $this->getDbTable()->insert($data); } else { $s = $this->getDbTable()->getAdapter()->quoteInto($q1, $q2); $this->getDbTable()->update($data, $s); } }