24 function set($name, $value)
26 $_SESSION[$name] = $value;
38 function get($name, $default=null)
40 if (isset($_SESSION) && array_key_exists($name, $_SESSION)) {
41 return $_SESSION[$name];
54 unset($_SESSION[$name]);
103 $required = $this->requiredKeys();
105 foreach ($required as $k) {
106 if (!array_key_exists($k, $data)) {
111 if (!$this->check($data)) {
115 $data = array_merge($data, $this->prepareForLoad($data));
116 $obj = $this->newObject($data);
122 foreach ($required as $k) {
123 $obj->$k = $data[$k];
165 foreach ($obj as $k => $v) {
169 $extra = $this->prepareForSave($obj);
171 if ($extra && is_array($extra)) {
172 foreach ($extra as $k => $v) {
206 foreach ($obj as $k => $v) {
214 return is_array($data[
'type_uris']);
226 return array(
'starting_url',
239 $data[
'session_key']);
244 return is_array($data[
'services']);
251 foreach ($data[
'services'] as $s) {
252 $services[] = $loader->fromSession($s);
254 return array(
'services' => $services);
261 foreach ($obj->services as $s) {
262 $services[] = $loader->toSession($s);
264 return array(
'services' => $services);
284 $services, $session_key)
287 $this->starting_url = $starting_url;
290 $this->yadis_url = $yadis_url;
293 $this->services = $services;
295 $this->session_key = $session_key;
298 $this->_current = null;
301 $this->stale =
false;
310 return count($this->services);
322 if ($this->services) {
323 $this->_current = array_shift($this->services);
325 $this->_current = null;
328 return $this->_current;
338 return $this->_current;
346 return in_array($url, array($this->starting_url, $this->yadis_url));
355 return $this->_current !== null;
374 var $DEFAULT_SUFFIX =
'auth';
379 var $PREFIX =
'_yadis_services_';
391 $session_key_suffix = null)
394 $this->session = $session;
396 if ($session_key_suffix === null) {
397 $session_key_suffix = $this->DEFAULT_SUFFIX;
400 $this->session_key_suffix = $session_key_suffix;
401 $this->session_key = $this->PREFIX . $this->session_key_suffix;
410 $manager = $this->getManager();
411 if (!$manager || (!$manager->services)) {
412 $this->destroyManager();
414 list($yadis_url, $services) = call_user_func_array($discover_cb,
420 $manager = $this->createManager($services, $yadis_url);
425 $service = $manager->nextService();
426 $this->session->set($this->session_key,
427 serialize($loader->toSession($manager)));
445 $manager = $this->getManager($force);
447 $service = $manager->current();
448 $this->destroyManager($force);
462 return $this->PREFIX . $this->session_key_suffix;
476 $manager_str = $this->session->get($this->getSessionKey());
479 if ($manager_str !== null) {
481 $manager = $loader->fromSession(unserialize($manager_str));
484 if ($manager && ($manager->forURL($this->url) || $force)) {
494 $key = $this->getSessionKey();
495 if ($this->getManager()) {
496 return $this->getManager();
503 $this->session->set($this->session_key,
504 serialize($loader->toSession($manager)));
517 if ($this->getManager($force) !== null) {
518 $key = $this->getSessionKey();
519 $this->session->del($key);
Auth_Yadis_Discovery($session, $url, $session_key_suffix=null)
Auth_Yadis_Manager($starting_url, $yadis_url, $services, $session_key)
getNextService($discover_cb, $fetcher)
destroyManager($force=false)
createManager($services, $yadis_url=null)