Пример #1
0
 /**
  * Create an access key with the given information.
  * @param $context string The context of the access key
  * @param $userId int The ID of the effective user for this access key
  * @param $assocId int The associated ID of the key
  * @param $expiryDays int The number of days before this key expires
  * @return accessKey string The generated passkey
  */
 function createKey($context, $userId, $assocId, $expiryDays)
 {
     $accessKey = new AccessKey();
     $accessKey->setContext($context);
     $accessKey->setUserId($userId);
     $accessKey->setAssocId($assocId);
     $accessKey->setExpiryDate(Core::getCurrentDate(time() + 60 * 60 * 24 * $expiryDays));
     $key = Validation::generatePassword();
     $accessKey->setKeyHash($this->generateKeyHash($key));
     $this->accessKeyDao->insertObject($accessKey);
     return $key;
 }
 /**
  * Internal function to return an AccessKey object from a row.
  * @param $row array
  * @return AccessKey
  */
 function &_returnAccessKeyFromRow(&$row)
 {
     $accessKey = new AccessKey();
     $accessKey->setId($row['access_key_id']);
     $accessKey->setKeyHash($row['key_hash']);
     $accessKey->setExpiryDate($this->datetimeFromDB($row['expiry_date']));
     $accessKey->setContext($row['context']);
     $accessKey->setAssocId($row['assoc_id']);
     $accessKey->setUserId($row['user_id']);
     HookRegistry::call('AccessKeyDAO::_returnAccessKeyFromRow', array(&$accessKey, &$row));
     return $accessKey;
 }