public function apply($app, $controller, $action) { YuppLoader::load('twitter.model', 'TUser'); $user = TUser::getLogged(); if ($user == NULL) { $this->flash['message'] = "Ups, you can't do that, please login..."; return $this->redirect(array('app' => 'twitter', 'controller' => 'user', 'action' => 'login')); } return true; }
public function sendMessageAction() { if (isset($this->params['doit'])) { $user = TUser::getLogged(); $message = new Message($this->params); $message->setCreatedBy($user); if (!$message->save()) { $this->flash['error'] = 'twitter.message.sendMessage.error'; $messages = Message::getTimeline($user); $this->params['messages'] = $messages; $this->params['user'] = $user; return $this->render('../user/timeline'); } // go back to my timeline return $this->redirect(array('controller' => 'user', 'action' => 'timeline')); } // renders sendMessage.view.php }
/** * Muestra una tag img con la direccion de un gravatar para el usuario logueado. * https://es.gravatar.com/site/implement/images/ * * @param $size indica las dimensiones de la imagen 1..512 * @param $default indica el codigo gravatar o la url de la imagen por defecto sino se encuentra el gravatar para el email del usuario logueado. */ public static function gravatar($size = 40, $user = NULL, $default = 'mm') { if ($user == NULL) { $user = TUser::getLogged(); } // Si no le paso usuario y ademas no hay usuario logueado if ($user == NULL) { throw new Exception('Deberia haber un usuario logueado o pasar un usuario por parametro'); } $hash = md5(strtolower(trim($user->getEmail()))); // $size <= 512 && $size > 0 if ($size > 512) { $size = 512; } if ($size <= 0) { $size = 40; } echo '<img src="http://www.gravatar.com/avatar/' . $hash . '.jpg?s=' . $size . '&d=' . $default . '" />'; }
<layout name="twitter" /> <head> <style type="text/css"> .user-result { width: 150px; display: inline-block; align: left; margin-bottom: 5px; } .user-result img { vertical-align: middle; margin-right: 5px; } </style> </head> <body> <div class="well"> <legend>Search result:</legend> <!-- search result --> <?php foreach ($users as $user) { echo '<div class="user-result">'; // TODO: template para mostrar cada usuario THelpers::gravatar(40, $user); echo h('link', array('action' => 'timeline', 'id' => $user->getId(), 'body' => $user->getName())), $user->getId() == TUser::getLogged()->getId() ? ' (you)' : ''; echo '</div>'; } ?> </div> </body> </html>
<span style="padding:10px; display: inline-block; vertical-align: middle;"> <?php /*echo h('locale_chooser');*/ ?> <?php if (($u = TUser::getLogged()) !== NULL) { ?> <?php echo msg('twitter.user.welcome'); ?> <?php echo h('link', array('controller' => 'user', 'action' => 'timeline', 'body' => $u->getName())); ?> <?php THelpers::gravatar(20, $u); ?> / <?php echo h('link', array('controller' => 'user', 'action' => 'logout', 'body' => 'logout')); ?> <?php } ?> </span>
public function followAction() { if (isset($this->params['id'])) { // EXCEPT: debe seleccionar un usuario a seguir } $user = TUser::getLogged(); $follow = TUser::get($this->params['id']); if (isset($this->params['follow'])) { $this->flash['message'] = 'You started following ' . $follow->getName(); $user->addToFollowing($follow); } else { if (isset($this->params['unfollow'])) { $this->flash['message'] = 'You stoped following ' . $follow->getName(); $user->removeFromFollowing($follow); } } $user->save(); return $this->redirect(array('action' => 'timeline')); }
{ console.log('>=30'); $('#charNum').css('color', '#000'); } } } </script> </head> <body> <div class="row-fluid"> <div class="span4"> <div class="row-fluid"> <div class="span12"><!-- ponerle 12 es como ponerle 100%, si le pongo 6 queda de la mitad del width --> <!-- follow/unfollow this user if it's not me, twitt if it's me --> <?php $logged = TUser::getLogged(); if ($logged->getId() != $user->getId()) { Helpers::template(array('controller' => 'templates', 'name' => 'follow-unfollow', 'args' => array('user' => $user, 'logged' => $logged))); } else { Helpers::template(array('controller' => 'templates', 'name' => 'twitt', 'args' => array('m' => $m))); } ?> </div> </div> <div class="row-fluid"> <div class="span12"> <!-- users followed by $user --> <div id="following" class="well"> <legend><?php echo $user->getName(), msg('twitter.user.timeline.isFollowing'); ?>