public function __construct(User $user) { // store the parent user object $this->user = $user; // this should rather be coming from the user object $this->kirby = kirby::instance(); // try to find the avatar if ($file = f::resolve($this->kirby->roots()->avatars() . DS . $user->username(), ['jpg', 'jpeg', 'gif', 'png'])) { $filename = f::filename($file); } else { $filename = $user->username() . '.jpg'; $file = $this->kirby->roots()->avatars() . DS . $filename; } parent::__construct($file, $this->kirby->urls()->avatars() . '/' . $filename); }
public function getWritterUsername() { return $this->writter->username(); }
$thumb = "<img src='/tmbologo.gif' width='50' height='33' />"; } else { if(strlen($avatar->thumb())) { $info = getimagesize($avatar->thumb()); } // XXX: this could do with some filtering. $thumb = "<a href='".Link::upload($avatar)."' target='_blank'><img src='" . $avatar->thumbURL() . "' ".(is_array($info) ? $info[3] : "")." border='0' /></a>"; } $referer = $user->referred_by(); $refer = ""; if($referer) { if($referer->location()) { $refer = $user->username()." was invited by <a href='javascript:maxxerMap.posseClick(".$referer->id().");'>" .$referer->username()."</a>"; } else { $refer = $user->username()." was invited by ".$referer->username(); } } $possearr = $user->posse(); if(count($possearr) == 0) { $posse = ""; $overflow = ""; } else { $posse = "<p style='line-height: 10px; margin: 4px 0px 3px 0px;'><a style='text-decoration: none;' href='".Link::content("posse")."&userid=".$user->id()."'>".$user->username()." has a posse</a>"; $posse_markers = 0; $posse_list = "";
/** * Test if a given user has capability to perform a certain action. * * @param User $user * @param string $action * @return boolean */ public function userCan($user, $action) { // Ensure a valid user object is given if (!$user instanceof User) { return false; } // Test for authorship $isAuthor = $this->username() === $user->username(); if ($isAuthor && in_array($action, array('edit', 'delete'))) { return true; } // Test if the user has the required role $caps = plugin('comments')->config()->get('capabilities'); $roles = explode('|', a::get($caps, $action)); return in_array('all', $roles) || in_array($user->role(), $roles); }
private function existsUser(User $user) { $sql = "SELECT username FROM users WHERE username = :username"; $query = $this->session->prepare($sql); $query->bindParam(':username', $user->username()); $query->execute(); return $query->rowCount() > 0; }