Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 22nd, 2012  |  syntax: None  |  size: 2.77 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. CakePHP / Facebook Plugin - Logout button linking to #
  2. if(!$session->check('Auth.User.id') && !$this->Connect->user('id')) {
  3.     echo $this->Html->link('LOGIN', array('controller' => 'users', 'action' => 'login'));
  4. } else {    
  5.     echo $facebook->logout(array('redirect' => array('controller'=>'users', 'action'=>'logout'), 'label' => 'LOGOUT'));
  6. }
  7.        
  8. if((isset($options['redirect']) && $options['redirect']) || $options['custom']){
  9.             $options['redirect'] = Router::url($options['redirect']);
  10.             $onclick = "logout('".$options['redirect']."');";
  11.             if(isset($options['confirm'])){
  12.                 $onclick = 'if(confirm("'.$options['confirm'].'")){'.$onclick.'}';
  13.             }
  14.             if($options['img']){
  15.                 $source = '/Facebook/img/'.$options['img'];
  16.                 return $this->Html->image($source, array(
  17.                 'alt' => $options['alt'],
  18.                 'id' => $options['id'],
  19.                 'url' => '#',
  20.                 'onclick' => $onclick));
  21.             }
  22.             else {   /* HERE  */
  23.                 return $this->Html->link($options['label'], '#', array(
  24.                     'onclick' => $onclick, 'id' => $options['id']));
  25.             }
  26.         } else {
  27.             $source = '/Facebook/img/facebook-logout.png';
  28.             return $this->Html->image($source, array(
  29.                 'alt' => 'Facebook logout',
  30.                 'url' => '#',
  31.                 'id' => $options['id'],
  32.                 'onclick' => 'logout();'));
  33.        
  34. if((isset($options['redirect']) && $options['redirect']) || $options['custom']){
  35.                     debug($options);
  36.         $onclick = "logout('".$options['redirect']."');";
  37.         if(isset($options['confirm'])){
  38.             $onclick = 'if(confirm("'.$options['confirm'].'")){'.$onclick.'}';
  39.         }
  40.         if($options['img']){
  41.             $source = '/Facebook/img/'.$options['img'];
  42.             return $this->Html->image($source, array(
  43.             'alt' => $options['alt'],
  44.             'id' => $options['id'],
  45.             'url' => '#',
  46.             'onclick' => $onclick));
  47.         }
  48.         else {
  49.                         //Yes it gets here!
  50.                         $source = '/Facebook/img/facebook-logout.png';
  51.                         $redirect=$options['redirect'];
  52.                         return $this->Html->image($source, array(
  53.             'alt' => 'Facebook logout',
  54.             //'url' => '#',
  55.                             'url' => $redirect,
  56.             'id' => $options['id'],
  57.             'onclick' => "logout('$redirect');"));
  58.         }
  59.     } else {
  60.         $source = '/Facebook/img/facebook-logout.png';
  61.         return $this->Html->image($source, array(
  62.             'alt' => 'Facebook logout',
  63.             'url' => '#',
  64.             'id' => $options['id'],
  65.             'onclick' => 'logout();'));
  66.     }
  67. }