Example #1
0
 /**
  * Remove all expired tokens from the database.
  *
  * @return void
  * @access public
  */
 public function removeExpired()
 {
     $cleaner = new Oai_resumption();
     $now = date('Y-m-d H:i:s');
     $cleaner->whereAdd("\"expires\" <= '{$now}'");
     $cleaner->delete(true);
 }
Example #2
0
 /**
  * Generate a resumption token to continue the current operation.
  *
  * @param array $params        Current operational parameters.
  * @param int   $currentCursor Current cursor position in search results.
  * @param int   $listSize      Total size of search results.
  *
  * @return string              XML details about token.
  * @access protected
  */
 protected function saveResumptionToken($params, $currentCursor, $listSize)
 {
     global $interface;
     // Save the old cursor position to the template before overwriting it for
     // storage in the database!
     $interface->assign('oldCursor', $params['cursor']);
     $params['cursor'] = $currentCursor;
     // Save everything to the database:
     $search = new Oai_resumption();
     $search->saveParams($params);
     $expire = time() + 24 * 60 * 60;
     $search->expires = date('Y-m-d H:i:s', $expire);
     $token = $search->insert();
     // Send remaining details to the template:
     $interface->assign('resumptionToken', $token);
     $interface->assign('tokenExpiration', date($this->iso8601, $expire));
     $interface->assign('listSize', $listSize);
     // Build the XML:
     return $interface->fetch('OAI/resumption.tpl');
 }