예제 #1
0
 public static final function call(\System\Collection\Map $serviceResult, \System\Db\Database $defaultDb)
 {
     self::validateHandles();
     $val = new \System\Security\Validate();
     $val->checkTextLength(self::$get->token, 'token', 10, true);
     $val->checkTextLength(self::$get->value, 'value', 1, true);
     if ($val->isInputOk()) {
         $vec = new \System\Collection\Vector();
         $vec[] = self::$get->token;
         $vec[] = self::$get->value;
         $onetimecall = \Module\Onetimecall\Onetimecall::load($defaultDb, 'token_value', $vec, false);
         if ($onetimecall) {
             $serviceResult->onetimeCall = $onetimecall;
             $onetimecall->delete($defaultDb);
             return true;
         }
         $event = new \Module\Onetimecall\Event\OnOnetimecallFailEvent();
         $event->raise();
     }
     return false;
 }
예제 #2
0
 /**
  * Create a new onetimecall
  * @param \System\Db\Database The database to query
  * @param string The key which we should use to find the appropriate callback
  * @param string The value to reference the object with
  * @return \Module\Onetimecall\Onetimecall the newly created instance
  */
 public static function create(\System\Db\Database $db, $key, $value)
 {
     $hash = new \System\Security\Hash();
     $hash->addString(\System\Calendar\Time::now());
     $token = $hash->getHash();
     $query = new \System\Db\Query($db, SQL_ONETIMECALL_CREATE);
     $query->bind($token, \System\Db\QueryType::TYPE_STRING);
     $query->bind($key, \System\Db\QueryType::TYPE_STRING);
     $query->bind((string) $value, \System\Db\QueryType::TYPE_STRING);
     $db->query($query);
     $insertId = $db->getInsertId();
     return \Module\Onetimecall\Onetimecall::loadPrimary($db, $insertId);
 }