public static function getAssociations(ezcDbHandler $db, $url) { $options = new ezcAuthenticationOpenidDbStoreOptions(); $table = $options->tableAssociations; $query = new ezcQuerySelect($db); $e = $query->expr; $query->select('*')->from($db->quoteIdentifier($table['name']))->where($e->eq($db->quoteIdentifier($table['fields']['url']), $query->bindValue($url))); $query = $query->prepare(); $query->execute(); $rows = $query->fetchAll(); if (count($rows) > 0) { $rows = $rows[0]; $data = $rows[$table['fields']['association']]; return $data; } }
/** * Returns the unserialized association linked to the OpenID provider URL. * * Returns false if the association could not be retrieved or if it expired. * * @param string $url The URL of the OpenID provider * @return ezcAuthenticationOpenidAssociation */ public function getAssociation($url) { $table = $this->options->tableAssociations; $query = new ezcQuerySelect($this->instance); $e = $query->expr; $query->select('*')->from($this->instance->quoteIdentifier($table['name']))->where($e->eq($this->instance->quoteIdentifier($table['fields']['url']), $query->bindValue($url))); $query = $query->prepare(); $query->execute(); $rows = $query->fetchAll(); if (count($rows) > 0) { $rows = $rows[0]; $data = unserialize($rows[$table['fields']['association']]); return $data; } // no association was found for $url return false; }
/** * Runs the filter and returns a status code when finished. * * @param ezcAuthenticationPasswordCredentials $credentials Authentication credentials * @return int */ public function run($credentials) { $db = $this->database; // see if username exists $query = new ezcQuerySelect($db->instance); $e = $query->expr; $query->select('COUNT( ' . $db->instance->quoteIdentifier($db->fields[0]) . ' )')->from($db->instance->quoteIdentifier($db->table))->where($e->eq($db->instance->quoteIdentifier($db->fields[0]), $query->bindValue($credentials->id))); $rows = $query->prepare(); $rows->execute(); $count = (int) $rows->fetchColumn(0); if ($count === 0) { return self::STATUS_USERNAME_INCORRECT; } $rows->closeCursor(); if (count($this->requestedData) > 0) { // fetch extra data from the database $query = new ezcQuerySelect($db->instance); $e = $query->expr; $params = array(); foreach ($this->requestedData as $param) { $params[] = $db->instance->quoteIdentifier($param); } $query->select(implode(', ', $params))->from($db->instance->quoteIdentifier($db->table))->where($e->lAnd($e->eq($db->instance->quoteIdentifier($db->fields[0]), $query->bindValue($credentials->id)))); $rows = $query->prepare(); $rows->execute(); $data = $rows->fetchAll(); $data = $data[0]; foreach ($this->requestedData as $attribute) { $this->data[$attribute] = array($data[$attribute]); } } return self::STATUS_OK; }