Пример #1
0
 static function fromAvatar(Avatar $avatar)
 {
     $alink = new AvatarLink();
     $alink->type = $avatar->mediatype;
     $alink->height = $avatar->height;
     $alink->width = $avatar->width;
     $alink->url = $avatar->displayUrl();
     return $alink;
 }
 public function getAvatar($email, $size = 100, $default = null)
 {
     if (!is_int($size)) {
         throw new \InvalidArgumentException('Size must be an integer');
     }
     $default = $this->_parseDefault($default);
     $hash = $this->_getHash($email);
     $url = $this->_buildUrl($hash, $size, $default);
     $avatar = new Avatar();
     $avatar->setUrl($url);
     $avatar->setSize($size);
     $avatar->setDefault($default);
     return $avatar;
 }
Пример #3
0
 /**
  * Mapping function where to find what
  * @param type $object the object
  * @param type $function the called function
  * @return string output
  */
 private static function map($object, $function)
 {
     /**
      * If you want to add an object to the helper simply add to this array
      */
     $mapping = array('User' => array('link' => function ($obj) {
         return URLHelper::getLink('dispatch.php/profile', array('username' => $obj->username));
     }, 'name' => function ($obj) {
         return htmlReady($obj->getFullname());
     }, 'avatar' => function ($obj) {
         return Avatar::getAvatar($obj->id, $obj->username)->getImageTag(Avatar::SMALL, array('title' => htmlReady($obj->getFullname('no_title'))));
     }), 'Course' => array('link' => function ($obj) {
         return URLHelper::getLink('seminar_main.php', array('auswahl' => $obj->id));
     }, 'name' => function ($obj) {
         return htmlReady($obj->name);
     }, 'avatar' => function ($obj) {
         return CourseAvatar::getAvatar($obj->id)->getImageTag($size = CourseAvatar::SMALL, array('title' => htmlReady($obj->name)));
     }));
     /*
      * Some php magic to call the right function if it exists
      */
     if ($object && $mapping[get_class($object)]) {
         return $mapping[get_class($object)][$function]($object);
     }
     return "";
 }
Пример #4
0
 /**
  * Take arguments for running
  *
  * @param array $args $_REQUEST args
  *
  * @return boolean success flag
  */
 protected function prepare(array $args = array())
 {
     parent::prepare($args);
     $this->count = 5000;
     // max 5000, completely arbitrary...
     $this->target = $this->getTargetProfile($this->arg('id'));
     if (!$this->target instanceof Profile) {
         // TRANS: Client error displayed when requesting a list of followers for a non-existing user.
         $this->clientError(_('No such user.'), 404);
     }
     $this->profiles = $this->getProfiles();
     // only keep id, name, nickname and avatar URL
     foreach ($this->profiles as $p) {
         try {
             $avatar = Avatar::byProfile($p, AVATAR_STREAM_SIZE);
             $avatar = $avatar->url;
         } catch (Exception $e) {
             $avatar = false;
         }
         $this_user = array($p->fullname, $p->nickname, $avatar);
         if (!$p->isLocal()) {
             $this_user[3] = $p->getUrl();
         } else {
             $this_user[3] = false;
         }
         $this->users_stripped[$p->id] = $this_user;
     }
     return true;
 }
Пример #5
0
 /**
  * Constructor
  *
  * @param User    $user    the user for the feed
  * @param User    $cur     the current authenticated user, if any
  * @param boolean $indent  flag to turn indenting on or off
  *
  * @return void
  */
 function __construct($user, $cur = null, $indent = true)
 {
     parent::__construct($cur, $indent);
     $this->user = $user;
     if (!empty($user)) {
         $profile = $user->getProfile();
         $ao = ActivityObject::fromProfile($profile);
         array_push($ao->extra, $profile->profileInfo($cur));
         // XXX: For users, we generate an author _AND_ an <activity:subject>
         // This is for backward compatibility with clients (especially
         // StatusNet's clients) that assume the Atom will conform to an
         // older version of the Activity Streams API. Subject should be
         // removed in future versions of StatusNet.
         $this->addAuthorRaw($ao->asString('author'));
         $depMsg = 'Deprecation warning: activity:subject is present ' . 'only for backward compatibility. It will be ' . 'removed in the next version of StatusNet.';
         $this->addAuthorRaw("<!--{$depMsg}-->\n" . $ao->asString('activity:subject'));
     }
     // TRANS: Title in atom user notice feed. %s is a user name.
     $title = sprintf(_("%s timeline"), $user->nickname);
     $this->setTitle($title);
     $sitename = common_config('site', 'name');
     $subtitle = sprintf(_('Updates from %1$s on %2$s!'), $user->nickname, $sitename);
     $this->setSubtitle($subtitle);
     $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
     $logo = $avatar ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE);
     $this->setLogo($logo);
     $this->setUpdated('now');
     $this->addLink(common_local_url('showstream', array('nickname' => $user->nickname)));
     $self = common_local_url('ApiTimelineUser', array('id' => $user->id, 'format' => 'atom'));
     $this->setId($self);
     $this->setSelfLink($self);
     $this->addLink(common_local_url('sup', null, null, $user->id), array('rel' => 'http://api.friendfeed.com/2008/03#sup', 'type' => 'application/json'));
 }
Пример #6
0
 public static function get_instance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new Avatar();
     }
     return self::$instance;
 }
Пример #7
0
 function showNotice($notice)
 {
     $profile = $notice->getProfile();
     if (empty($profile)) {
         common_log(LOG_WARNING, sprintf("Notice %d has no profile", $notice->id));
         return;
     }
     $this->out->elementStart('li', 'hentry notice');
     $this->out->elementStart('div', 'entry-title');
     $avatar = $profile->getAvatar(AVATAR_MINI_SIZE);
     $this->out->elementStart('span', 'vcard author');
     $this->out->elementStart('a', array('title' => $profile->fullname ? $profile->fullname : $profile->nickname, 'href' => $profile->profileurl, 'class' => 'url'));
     $this->out->element('img', array('src' => $avatar ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_MINI_SIZE), 'width' => AVATAR_MINI_SIZE, 'height' => AVATAR_MINI_SIZE, 'class' => 'avatar photo', 'alt' => $profile->fullname ? $profile->fullname : $profile->nickname));
     $this->out->text(' ');
     $this->out->element('span', 'fn nickname', $profile->nickname);
     $this->out->elementEnd('a');
     $this->out->elementEnd('span');
     $this->out->elementStart('p', 'entry-content');
     $this->out->raw($notice->rendered);
     $this->out->elementEnd('p');
     $this->out->elementStart('div', 'entry_content');
     class_exists('NoticeList');
     $nli = new NoticeListItem($notice, $this->out);
     $nli->showNoticeLink();
     $this->out->elementEnd('div');
     if (!empty($notice->value)) {
         $this->out->elementStart('p');
         $this->out->text($notice->value);
         $this->out->elementEnd('p');
     }
     $this->out->elementEnd('div');
     $this->out->elementEnd('li');
 }
Пример #8
0
 /**
  * Show the item
  *
  * @return void
  */
 function show()
 {
     $group = $this->gm->getGroup();
     $sender = $this->gm->getSender();
     $this->out->elementStart('li', array('class' => 'hentry notice message group-message', 'id' => 'message-' . $this->gm->id));
     $this->out->elementStart('div', 'entry-title');
     $this->out->elementStart('span', 'vcard author');
     $this->out->elementStart('a', array('href' => $sender->profileurl, 'class' => 'url'));
     $avatar = $sender->getAvatar(AVATAR_STREAM_SIZE);
     $this->out->element('img', array('src' => $avatar ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_STREAM_SIZE), 'width' => AVATAR_STREAM_SIZE, 'height' => AVATAR_STREAM_SIZE, 'class' => 'photo avatar', 'alt' => $sender->getBestName()));
     $this->out->element('span', array('class' => 'nickname fn'), $sender->nickname);
     $this->out->elementEnd('a');
     $this->out->elementEnd('span');
     $this->out->elementStart('p', array('class' => 'entry-content message-content'));
     $this->out->raw($this->gm->rendered);
     $this->out->elementEnd('p');
     $this->out->elementEnd('div');
     $this->out->elementStart('div', 'entry-content');
     $this->out->elementStart('a', array('rel' => 'bookmark', 'class' => 'timestamp', 'href' => $this->gm->url));
     $dt = common_date_iso8601($this->gm->created);
     $this->out->element('abbr', array('class' => 'published', 'title' => $dt), common_date_string($this->gm->created));
     $this->out->elementEnd('a');
     $this->out->elementEnd('div');
     $this->out->elementEnd('li');
 }
Пример #9
0
 public static function getInstance($class = '')
 {
     if (self::$_instances[$class]) {
         return self::$_instances[$class];
     }
     return self::$_instance = new Avatar();
 }
Пример #10
0
 /**
  * Class handler.
  *
  * @param array $args query arguments
  *
  * @return boolean false if nickname or user isn't found
  */
 protected function handle()
 {
     parent::handle();
     $nickname = $this->trimmed('nickname');
     if (!$nickname) {
         // TRANS: Client error displayed trying to get an avatar without providing a nickname.
         $this->clientError(_('No nickname.'));
     }
     $size = $this->trimmed('size') ?: 'original';
     $user = User::getKV('nickname', $nickname);
     if (!$user) {
         // TRANS: Client error displayed trying to get an avatar for a non-existing user.
         $this->clientError(_('No such user.'));
     }
     $profile = $user->getProfile();
     if (!$profile) {
         // TRANS: Error message displayed when referring to a user without a profile.
         $this->clientError(_('User has no profile.'));
     }
     if ($size === 'original') {
         try {
             $avatar = Avatar::getUploaded($profile);
             $url = $avatar->displayUrl();
         } catch (NoAvatarException $e) {
             $url = Avatar::defaultImage(AVATAR_PROFILE_SIZE);
         }
     } else {
         $url = $profile->avatarUrl($size);
     }
     common_redirect($url, 302);
 }
Пример #11
0
 function execute($par)
 {
     global $wgUser, $wgOut;
     $wgOut->disable();
     header("Content-type: text/plain;");
     header('Expires: ' . gmdate('D, d M Y H:i:s', 0) . ' GMT');
     header("Cache-Control: private, must-revalidate, max-age=0");
     if ($wgUser->getID() == 0) {
         return;
     }
     if (self::isUserBlocked()) {
         self::updateRemote();
         return;
     }
     $avatar = wfGetPad(Avatar::getAvatarURL($wgUser->getName()));
     $result = "";
     $result .= "UniqueID={$wgUser->getID()}\n";
     $result .= "Name={$wgUser->getName()}\n";
     $result .= "Email={$wgUser->getEmail()}\n";
     $result .= "Avatar={$avatar}\n";
     $result .= "CurrentDate=" . date("r") . "\n";
     $result .= "Groups=" . implode(',', $wgUser->getGroups()) . "\n";
     wfDebug("ProxyConnect: returning {$result}\n");
     print $result;
     self::updateRemote();
     return;
 }
function updateGroupAvatars($group)
{
    if (!have_option('q', 'quiet')) {
        print "Updating avatars for group '" . $group->nickname . "' (" . $group->id . ")...";
    }
    if (empty($group->original_logo)) {
        print "(none found)...";
    } else {
        // Using clone here was screwing up the group->find() iteration
        $orig = User_group::staticGet('id', $group->id);
        $group->original_logo = Avatar::url(basename($group->original_logo));
        $group->homepage_logo = Avatar::url(basename($group->homepage_logo));
        $group->stream_logo = Avatar::url(basename($group->stream_logo));
        $group->mini_logo = Avatar::url(basename($group->mini_logo));
        if (!$group->update($orig)) {
            throw new Exception("Can't update avatars for group " . $group->nickname . ".");
        }
    }
    if (have_option('v', 'verbose')) {
        print "DONE.";
    }
    if (!have_option('q', 'quiet') || have_option('v', 'verbose')) {
        print "\n";
    }
}
 public function afterStoreCallback()
 {
     if ($this->isDirty()) {
         //add notification to writer of review
         if (!$this->review['host_id'] && $this->review['user_id'] !== $this['user_id']) {
             PersonalNotifications::add($this->review['user_id'], URLHelper::getURL("plugins.php/lernmarktplatz/market/discussion/" . $this['review_id'] . "#comment_" . $this->getId()), sprintf(_("%s hat einen Kommentar zu Ihrem Review geschrieben."), $this['host_id'] ? LernmarktplatzUser::find($this['user_id'])->name : get_fullname($this['user_id'])), "comment_" . $this->getId(), Icon::create("support", "clickable"));
         }
         //add notification to all users of this servers who discussed this review but are neither the new
         //commentor nor the writer of the review
         $statement = DBManager::get()->prepare("\n                SELECT user_id\n                FROM lernmarktplatz_comments\n                WHERE review_id = :review_id\n                    AND host_id IS NULL\n                GROUP BY user_id\n            ");
         $statement->execute(array('review_id' => $this->review->getId()));
         foreach ($statement->fetchAll(PDO::FETCH_COLUMN, 0) as $user_id) {
             if (!in_array($user_id, array($this->review['user_id'], $this['user_id']))) {
                 PersonalNotifications::add($user_id, URLHelper::getURL("plugins.php/lernmarktplatz/market/discussion/" . $this['review_id'] . "#comment_" . $this->getId()), sprintf(_("%s hat auch einen Kommentar geschrieben."), $this['host_id'] ? LernmarktplatzUser::find($this['user_id'])->name : get_fullname($this['user_id'])), "comment_" . $this->getId(), Icon::create("support", "clickable"));
             }
         }
         //only push if the comment is from this server and the material-server is different
         if (!$this['host_id']) {
             $myHost = LernmarktplatzHost::thisOne();
             $data = array();
             $data['host'] = array('name' => $myHost['name'], 'url' => $myHost['url'], 'public_key' => $myHost['public_key']);
             $data['data'] = $this->toArray();
             $data['data']['foreign_comment_id'] = $data['data']['comment_id'];
             unset($data['data']['comment_id']);
             unset($data['data']['id']);
             unset($data['data']['user_id']);
             unset($data['data']['host_id']);
             $user_description_datafield = DataField::find(get_config("LERNMARKTPLATZ_USER_DESCRIPTION_DATAFIELD")) ?: DataField::findOneBySQL("name = ?", array(get_config("LERNMARKTPLATZ_USER_DESCRIPTION_DATAFIELD")));
             if ($user_description_datafield) {
                 $datafield_entry = DatafieldEntryModel::findOneBySQL("range_id = ? AND datafield_id = ?", array($this['user_id'], $user_description_datafield->getId()));
             }
             $data['user'] = array('user_id' => $this['user_id'], 'name' => get_fullname($this['user_id']), 'avatar' => Avatar::getAvatar($this['user_id'])->getURL(Avatar::NORMAL), 'description' => $datafield_entry ? $datafield_entry['content'] : null);
             $statement = DBManager::get()->prepare("\n                    SELECT host_id\n                    FROM lernmarktplatz_comments\n                    WHERE review_id = :review_id\n                        AND host_id IS NOT NULL\n                    GROUP BY host_id\n                ");
             $statement->execute(array('review_id' => $this->review->getId()));
             $hosts = $statement->fetchAll(PDO::FETCH_COLUMN, 0);
             if ($this->review['host_id'] && !in_array($this->review['host_id'], $hosts)) {
                 $hosts[] = $this->review['host_id'];
             }
             if ($this->review->material['host_id'] && !in_array($this->review->material['host_id'], $hosts)) {
                 $hosts[] = $this->review->material['host_id'];
             }
             foreach ($hosts as $host_id) {
                 $remote = new LernmarktplatzHost($host_id);
                 if (!$remote->isMe()) {
                     $review_id = $this->review['foreign_review_id'] ?: $this->review->getId();
                     if ($this->review['foreign_review_id']) {
                         if ($this->review->host_id === $remote->getId()) {
                             $host_hash = null;
                         } else {
                             $host_hash = md5($this->review->host['public_key']);
                         }
                     } else {
                         $host_hash = md5($myHost['public_key']);
                     }
                     $remote->pushDataToEndpoint("add_comment/" . $review_id . "/" . $host_hash, $data);
                 }
             }
         }
     }
 }
Пример #14
0
 /**
  * Gets the avatar information for the user.  The avatars are provided by
  * plugins that can integrate with a variety of services like gravatar.com,
  * LDAP, Social Identities, etc.
  *
  * If logged in user doesn't have access to view avatars or not avatar is found,
  * then a default avatar will be used.
  *
  * Note that the provided user id may no longer has a corresponding user in the
  * system, if the user was deleted.
  *
  * @param integer $p_user_id  The user id.
  * @param integer $p_size     The desired width/height of the avatar.
  *
  * @return array The array with avatar information.
  */
 public static function get($p_user_id, $p_size = 80)
 {
     $t_enabled = config_get('show_avatar') !== OFF;
     $t_avatar = null;
     if ($t_enabled) {
         $t_user_exists = user_exists($p_user_id);
         if ($t_user_exists && access_has_project_level(config_get('show_avatar_threshold'), null, $p_user_id)) {
             $t_avatar = event_signal('EVENT_USER_AVATAR', array($p_user_id, $p_size));
         }
         if ($t_avatar === null) {
             $t_avatar = new Avatar();
         }
         $t_avatar->normalize($p_user_id, $t_user_exists);
     }
     return $t_avatar;
 }
Пример #15
0
 /**
  * Constructor
  *
  * @param User    $user    the user for the feed
  * @param User    $cur     the current authenticated user, if any
  * @param boolean $indent  flag to turn indenting on or off
  *
  * @return void
  */
 function __construct($user, $cur = null, $indent = true)
 {
     parent::__construct($cur, $indent);
     $this->user = $user;
     if (!empty($user)) {
         $profile = $user->getProfile();
         $this->addAuthor($profile->nickname, $user->uri);
         $this->setActivitySubject($profile->asActivityNoun('subject'));
     }
     // TRANS: Title in atom user notice feed. %s is a user name.
     $title = sprintf(_("%s timeline"), $user->nickname);
     $this->setTitle($title);
     $sitename = common_config('site', 'name');
     $subtitle = sprintf(_('Updates from %1$s on %2$s!'), $user->nickname, $sitename);
     $this->setSubtitle($subtitle);
     $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
     $logo = $avatar ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE);
     $this->setLogo($logo);
     $this->setUpdated('now');
     $this->addLink(common_local_url('showstream', array('nickname' => $user->nickname)));
     $self = common_local_url('ApiTimelineUser', array('id' => $user->id, 'format' => 'atom'));
     $this->setId($self);
     $this->setSelfLink($self);
     $this->addLink(common_local_url('sup', null, null, $user->id), array('rel' => 'http://api.friendfeed.com/2008/03#sup', 'type' => 'application/json'));
 }
Пример #16
0
function updateGroupUrls()
{
    printfnq("Updating group URLs...\n");
    $group = new User_group();
    if ($group->find()) {
        while ($group->fetch()) {
            try {
                printfv("Updating group {$group->nickname}...");
                $orig = User_group::getKV('id', $group->id);
                if (!empty($group->original_logo)) {
                    $group->original_logo = Avatar::url(basename($group->original_logo));
                    $group->homepage_logo = Avatar::url(basename($group->homepage_logo));
                    $group->stream_logo = Avatar::url(basename($group->stream_logo));
                    $group->mini_logo = Avatar::url(basename($group->mini_logo));
                }
                // XXX: this is a hack to see if a group is local or not
                $localUri = common_local_url('groupbyid', array('id' => $group->id));
                if ($group->getUri() != $localUri) {
                    $group->mainpage = common_local_url('showgroup', array('nickname' => $group->nickname));
                }
                $group->update($orig);
                printfv("DONE.");
            } catch (Exception $e) {
                echo "Can't update avatars for group " . $group->nickname . ": " . $e->getMessage();
            }
        }
    }
}
Пример #17
0
 function delete()
 {
     $filename = $this->filename;
     if (parent::delete()) {
         @unlink(Avatar::path($filename));
     }
 }
 public function afterStoreCallback()
 {
     if (!$this->material['host_id'] && $this->material['user_id'] !== $GLOBALS['user']->id) {
         PersonalNotifications::add($this->material['user_id'], URLHelper::getURL("plugins.php/lernmarktplatz/market/details/" . $this->material->getId() . "#review_" . $this->getId()), $this->isNew() ? sprintf(_("%s hat ein Review zu '%s' geschrieben."), $this['host_id'] ? LernmarktplatzUser::find($this['user_id'])->name : get_fullname($this['user_id']), $this->material['name']) : sprintf(_("%s hat ein Review zu '%s' verändert."), $this['host_id'] ? LernmarktplatzUser::find($this['user_id'])->name : get_fullname($this['user_id']), $this->material['name']), "review_" . $this->getId(), Icon::create("support", "clickable"));
     }
     //only push if the comment is from this server and the material-server is different
     if ($this->material['host_id'] && !$this['host_id'] && $this->isDirty()) {
         $remote = new LernmarktplatzHost($this->material['host_id']);
         $myHost = LernmarktplatzHost::thisOne();
         $data = array();
         $data['host'] = array('name' => $myHost['name'], 'url' => $myHost['url'], 'public_key' => $myHost['public_key']);
         $data['data'] = $this->toArray();
         $data['data']['foreign_review_id'] = $data['data']['review_id'];
         unset($data['data']['review_id']);
         unset($data['data']['id']);
         unset($data['data']['user_id']);
         unset($data['data']['host_id']);
         $user_description_datafield = DataField::find(get_config("LERNMARKTPLATZ_USER_DESCRIPTION_DATAFIELD")) ?: DataField::findOneBySQL("name = ?", array(get_config("LERNMARKTPLATZ_USER_DESCRIPTION_DATAFIELD")));
         if ($user_description_datafield) {
             $datafield_entry = DatafieldEntryModel::findOneBySQL("range_id = ? AND datafield_id = ?", array($this['user_id'], $user_description_datafield->getId()));
         }
         $data['user'] = array('user_id' => $this['user_id'], 'name' => get_fullname($this['user_id']), 'avatar' => Avatar::getAvatar($this['user_id'])->getURL(Avatar::NORMAL), 'description' => $datafield_entry ? $datafield_entry['content'] : null);
         if (!$remote->isMe()) {
             $remote->pushDataToEndpoint("add_review/" . $this->material['foreign_material_id'], $data);
         }
     }
 }
Пример #19
0
function updateAvatars($user)
{
    $touched = false;
    if (!have_option('q', 'quiet')) {
        print "Updating avatars for user '" . $user->nickname . "' (" . $user->id . ")...";
    }
    $avatar = new Avatar();
    $avatar->profile_id = $user->id;
    if (!$avatar->find()) {
        if (have_option('v', 'verbose')) {
            print "(none found)...";
        }
    } else {
        while ($avatar->fetch()) {
            if (have_option('v', 'verbose')) {
                if ($avatar->original) {
                    print "original...";
                } else {
                    print $avatar->width . "...";
                }
            }
            $orig_url = $avatar->url;
            $avatar->url = Avatar::url($avatar->filename);
            if ($avatar->url != $orig_url) {
                $sql = "UPDATE avatar SET url = '" . $avatar->url . "' " . "WHERE profile_id = " . $avatar->profile_id . " " . "AND width = " . $avatar->width . " " . "AND height = " . $avatar->height . " ";
                if ($avatar->original) {
                    $sql .= "AND original = 1 ";
                }
                if (!$avatar->query($sql)) {
                    throw new Exception("Can't update avatar for user " . $user->nickname . ".");
                } else {
                    $touched = true;
                }
            }
        }
    }
    if ($touched) {
        $profile = $user->getProfile();
        common_broadcast_profile($profile);
    }
    if (have_option('v', 'verbose')) {
        print "DONE.";
    }
    if (!have_option('q', 'quiet') || have_option('v', 'verbose')) {
        print "\n";
    }
}
Пример #20
0
 /**
  * Returns html string representing the beginning block of a timeline entry
  * @return string
  */
 public function html_start()
 {
     $t_avatar = Avatar::get($this->user_id, 32);
     if ($t_avatar === null) {
         return sprintf('<div class="entry"><div class="timestamp">%s</div>', $this->format_timestamp($this->timestamp));
     }
     return sprintf('<div class="entry"><div class="avatar"><a href="%s"><img class="avatar" src="%s" alt="%s" width="32" height="32" /></a></div><div class="timestamp">%s</div>', $t_avatar->link, $t_avatar->image, $t_avatar->text, $this->format_timestamp($this->timestamp));
 }
 function avatar()
 {
     $avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
     if (empty($avatar)) {
         $avatar = $this->profile->getAvatar(73);
     }
     return !empty($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE);
 }
Пример #22
0
 public function activate($user)
 {
     // Get Facebook profile info
     $facebookID = $user["id"];
     $name = $user["name"];
     $email = $user["email"];
     // Put that profile info into the database
     $sql = "INSERT INTO artists (name, email, photo, facebookID) values(:name, :email, 'facebook.jpg', :facebookID)";
     $stmt = $this->profile->con->prepare($sql);
     $stmt->execute(array("name" => $name, "email" => $email, "facebookID" => $facebookID));
     // Get Facebook profile pic and put it in the user's avatar directory
     $photo = "http://graph.facebook.com/" . $facebookID . "/picture?width=225";
     $id = $this->profile->gimme("id", "email", $email);
     include_once $_SERVER["DOCUMENT_ROOT"] . "/app/model/avatar.model.php";
     $avatar = new Avatar();
     $avatar->save($photo, $id);
     return $id;
 }
Пример #23
0
 static function getUsersAvatar($userid, $username = null, $forceCreate = false)
 {
     $avatar = Avatar::findOne('userid = ?', [$userid]);
     if (!$avatar && $forceCreate) {
         self::setUsersAvatar($userid, $username);
         return self::getDefault();
     }
     return $avatar ? $avatar->url : self::getDefault();
 }
Пример #24
0
 /**
  * Save the user information.
  *
  * @param array $post
  */
 public function save(array $post)
 {
     $avatar = Avatar::factory($this->user, array('driver' => $post['avatar-type']));
     $this->user->set_property('avatar', $avatar->data($post));
     $this->user->set_property('about', Security::xss_clean(Arr::get($post, 'about')));
     $this->user->set_property('signature', Security::xss_clean(Arr::get($post, 'signature')));
     $this->user->update();
     // Save cached_properties.
 }
 public function change_img_profile()
 {
     parent::loadHeader();
     $data = array();
     $data['list_avatars'] = Avatar::getAvatarsByUserId(unserialize($this->session->userdata('user_obj'))->id);
     $this->load->view('notification_zone');
     $this->load->view('account/change_avatar', $data);
     parent::loadFooter();
 }
Пример #26
0
 function showNotice($notice)
 {
     $profile = $notice->getProfile();
     if (empty($profile)) {
         common_log(LOG_WARNING, sprintf("Notice %d has no profile", $notice->id));
         return;
     }
     $this->out->elementStart('li', 'hentry notice');
     $this->out->elementStart('div', 'entry-title');
     $avatar = $profile->getAvatar(AVATAR_MINI_SIZE);
     $this->out->elementStart('span', 'vcard author');
     $this->out->elementStart('a', array('title' => $profile->fullname ? $profile->fullname : $profile->nickname, 'href' => $profile->profileurl, 'class' => 'url'));
     $this->out->element('img', array('src' => $avatar ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_MINI_SIZE), 'width' => AVATAR_MINI_SIZE, 'height' => AVATAR_MINI_SIZE, 'class' => 'avatar photo', 'alt' => $profile->fullname ? $profile->fullname : $profile->nickname));
     $this->out->text(' ');
     $this->out->element('span', 'fn nickname', $profile->nickname);
     $this->out->elementEnd('a');
     $this->out->elementEnd('span');
     $this->out->elementStart('p', 'entry-content');
     $this->out->raw($notice->rendered);
     $notice_link_cfg = common_config('site', 'notice_link');
     if ('direct' === $notice_link_cfg) {
         $this->out->text(' (');
         $this->out->element('a', array('href' => $notice->uri), 'see');
         $this->out->text(')');
     } elseif ('attachment' === $notice_link_cfg) {
         if ($count = $notice->hasAttachments()) {
             // link to attachment(s) pages
             if (1 === $count) {
                 $f2p = File_to_post::staticGet('post_id', $notice->id);
                 $href = common_local_url('attachment', array('attachment' => $f2p->file_id));
                 $att_class = 'attachment';
             } else {
                 $href = common_local_url('attachments', array('notice' => $notice->id));
                 $att_class = 'attachments';
             }
             $clip = Theme::path('images/icons/clip.png', 'base');
             $this->out->elementStart('a', array('class' => $att_class, 'style' => "font-style: italic;", 'href' => $href, 'title' => "# of attachments: {$count}"));
             $this->out->raw(" ({$count}&nbsp");
             $this->out->element('img', array('style' => 'display: inline', 'align' => 'top', 'width' => 20, 'height' => 20, 'src' => $clip, 'alt' => 'alt'));
             $this->out->text(')');
             $this->out->elementEnd('a');
         } else {
             $this->out->text(' (');
             $this->out->element('a', array('href' => $notice->uri), 'see');
             $this->out->text(')');
         }
     }
     $this->out->elementEnd('p');
     if (!empty($notice->value)) {
         $this->out->elementStart('p');
         $this->out->text($notice->value);
         $this->out->elementEnd('p');
     }
     $this->out->elementEnd('div');
     $this->out->elementEnd('li');
 }
Пример #27
0
 function showProfile()
 {
     $this->out->elementStart('li', 'vcard');
     $this->out->elementStart('a', array('title' => $this->profile->getBestName(), 'href' => $this->profile->profileurl, 'rel' => 'contact member', 'class' => 'url'));
     $avatar = $this->profile->getAvatar(AVATAR_MINI_SIZE);
     $this->out->element('img', array('src' => $avatar ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_MINI_SIZE), 'width' => AVATAR_MINI_SIZE, 'height' => AVATAR_MINI_SIZE, 'class' => 'avatar photo', 'alt' => $this->profile->fullname ? $this->profile->fullname : $this->profile->nickname));
     $this->out->element('span', 'fn nickname', $this->profile->nickname);
     $this->out->elementEnd('a');
     $this->out->elementEnd('li');
 }
 /**
  * Gets avatar from Gravatar
  * 
  * @param string  $email  Email address of user to look for
  * @param int  $size  Size of the avatar to retrieve
  * @return string
  */
 public static function getGravatar($email, $size)
 {
     if (!self::$is_gravatar_loaded) {
         self::$is_gravatar_loaded = true;
         self::$gravatar = new \emberlabs\GravatarLib\Gravatar();
         self::$gravatar->setDefaultImage('http://f.cl.ly/items/3M1e2a0x423F2w312J1M/buck.jpg');
     }
     self::$gravatar->setAvatarSize($size);
     self::$gravatar->enableSecureImages();
     return self::$gravatar->buildGravatarURL($email);
 }
Пример #29
0
 /**
  * Gets avatar from Gravatar
  * 
  * @param string  $email  Email address of user to look for
  * @param int  $size  Size of the avatar to retrieve
  * @return string
  */
 public static function getGravatar($email, $size)
 {
     if (!self::$is_gravatar_loaded) {
         self::$is_gravatar_loaded = true;
         self::$gravatar = new \emberlabs\GravatarLib\Gravatar();
         self::$gravatar->setDefaultImage('http://www.jeffreydcreative.com/default-member-image.jpg');
     }
     self::$gravatar->setAvatarSize($size);
     self::$gravatar->enableSecureImages();
     return self::$gravatar->buildGravatarURL($email);
 }
Пример #30
0
 /**
  * Load the database object
  * @param array
  */
 public function __construct($arrAttributes = null)
 {
     $GLOBALS['TL_CSS']['avatar_handler'] = 'system/modules/avatar/assets/handler/handler.min.css';
     // Include jQuery
     $this->addJQuery = true;
     parent::__construct($arrAttributes);
     // Set the value
     if ($this->varValue == '') {
         $this->varValue = \Avatar::find($this->getId(), $this->getUploadPath());
     }
 }