phpPoA2
[ class tree: phpPoA2 ] [ index: phpPoA2 ] [ all elements ]

Source for file InviteDBADB.php

Documentation is available at InviteDBADB.php

  1. <?php
  2. /**
  3.  * @copyright Copyright 2005-2010 RedIRIS, http://www.rediris.es/
  4.  *
  5.  *  This file is part of phpPoA2.
  6.  *  
  7.  *  phpPoA2 is free software: you can redistribute it and/or modify
  8.  *  it under the terms of the GNU General Public License as published by
  9.  *  the Free Software Foundation, either version 3 of the License, or
  10.  *  (at your option) any later version.
  11.  *  
  12.  *  phpPoA2 is distributed in the hope that it will be useful,
  13.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.  *  GNU General Public License for more details.
  16.  *
  17.  *  You should have received a copy of the GNU General Public License
  18.  *  along with phpPoA2. If not, see <http://www.gnu.org/licenses/>.
  19.  *
  20.  * @license http://www.gnu.org/licenses/gpl.html GNU General Public License
  21.  * @version 2.0
  22.  * @author Jaime Perez <jaime.perez@rediris.es>
  23.  * @filesource
  24.  */
  25.  
  26. /**
  27.  * Invites binding to a Berkeley DB backend.
  28.  * @package phpPoA2
  29.  * @subpackage InviteAuthorizationEngine
  30.  */
  31. class InviteDBADB extends DBADB implements InviteDB {
  32.  
  33.     protected $invite;
  34.     protected $mandatory_options = array("InvitesDBFile");
  35.  
  36.     public function open({
  37.         $this->db = @dba_open($this->cfg->getInvitesDBFile()"cl""db4");
  38.         return ($this->dbtrue false;
  39.     }
  40.  
  41.     public function replace_invite($key$email$expires{
  42.         $this->invite['email'$email;
  43.         $this->invite['since'time();
  44.         $this->invite['expires'$expires;
  45.  
  46.         return @dba_replace($keyserialize($this->invite)$this->db);
  47.     }
  48.  
  49.     public function fetch($key{
  50.         $row @dba_fetch($key$this->db);
  51.  
  52.         if (!$rowreturn false;
  53.  
  54.         $this->invite = unserialize($row);
  55.  
  56.         return $this->invite;
  57.     }
  58.  
  59.     public function fetch_all({
  60.         $list parent::fetch_all();
  61.         $result array();
  62.  
  63.         foreach ($list as $key => $item{
  64.             $result[$keyunserialize($item);
  65.         }
  66.  
  67.         return $result;
  68.     }
  69.  
  70. }
  71.  
  72. ?>

Documentation generated on Fri, 11 Feb 2011 10:57:58 +0100 by phpDocumentor 1.4.3