forked from NamelessMC/Nameless
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
95430d2
commit f698c5e
Showing
7 changed files
with
127 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<div class="ui fluid card" id="widget-latest-posts"> | ||
<div class="content"> | ||
<h4 class="ui header">{$LATEST_PROFILE_POSTS}</h4> | ||
<div class="description"> | ||
{if isset($POSTS)} | ||
{foreach from=$POSTS name=latest_posts item=post} | ||
<div class="ui relaxed list"> | ||
<div class="item"> | ||
<img class="ui mini circular image" src="{$post.avatar}" alt="{$post.username}"> | ||
<div class="content"> | ||
<a class="header" href="{$post.link}">{$post.content}</a> | ||
<div class="ui wide popup"> | ||
<h4 class="ui header">{$post.topic_title}</h4> | ||
{$BY|capitalize} <a href="{$post.user_profile_link}" style="{$post.username_style}">{$post.username}</a> | {$post.last_reply} | ||
</div> | ||
<a href="{$post.user_profile_link}" style="{$post.username_style}}" data-poload="{$USER_INFO_URL}{$post.user_id}">{$post.username}</a> | ||
· <span data-toggle="tooltip" data-content="{$post.date_ago}">{$post.ago}</span> | ||
</div> | ||
</div> | ||
</div> | ||
{/foreach} | ||
{else} | ||
{$NO_PROFILE_POSTS} | ||
{/if} | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
/* | ||
* Made by Aberdeener | ||
* https://github.com/NamelessMC/Nameless/ | ||
* NamelessMC version 2.0.0-pr8 | ||
* | ||
* License: MIT | ||
* | ||
* Profile Posts Widget | ||
*/ | ||
class ProfilePostsWidget extends WidgetBase { | ||
private $_cache, $_smarty, $_language, $_user, $_timeago; | ||
|
||
public function __construct($pages = array(), $smarty, $language, $cache, $user, $timeago) { | ||
$this->_language = $language; | ||
$this->_smarty = $smarty; | ||
$this->_cache = $cache; | ||
$this->_user = $user; | ||
$this->_timeago = $timeago; | ||
|
||
parent::__construct($pages); | ||
|
||
// Get order | ||
$order = DB::getInstance()->query('SELECT `order` FROM nl2_widgets WHERE `name` = ?', array('Latest Profile Posts'))->first(); | ||
|
||
// Set widget variables | ||
$this->_module = 'Core'; | ||
$this->_name = 'Latest Profile Posts'; | ||
$this->_location = 'right'; | ||
$this->_description = 'Display the latest profile posts on your site.'; | ||
$this->_order = $order->order; | ||
} | ||
|
||
public function initialise() { | ||
// Generate HTML code for widget | ||
if ($this->_user->isLoggedIn()) { | ||
$user_group = $this->_user->data()->group_id; | ||
} else { | ||
$user_group = null; | ||
} | ||
|
||
if ($user_group) { | ||
$cache_name = 'profile_posts_' . $user_group; | ||
$user_id = $this->_user->data()->id; | ||
} else { | ||
$cache_name = 'profile_posts_guest'; | ||
$user_id = 0; | ||
} | ||
$this->_cache->setCache($cache_name); | ||
|
||
$posts_array = array(); | ||
|
||
if ($this->_cache->isCached('profile_posts_' . $user_id)) { | ||
$posts_array = $this->_cache->retrieve('profile_posts_' . $user_id); | ||
} else { | ||
$posts = DB::getInstance()->query('SELECT * FROM nl2_user_profile_wall_posts ORDER BY time DESC LIMIT 5')->results(); | ||
foreach ($posts as $post) { | ||
|
||
if ($user_group) { | ||
if ($this->_user->isBlocked($post->author_id, $this->_user->data()->id)) continue; | ||
if ($this->_user->isPrivateProfile($post->author_id) && !$this->_user->hasPermission('profile.private.bypass')) continue; | ||
} else if ($this->_user->isPrivateProfile($post->author_id)) continue; | ||
|
||
$posts_array[] = array( | ||
'avatar' => $this->_user->getAvatar($post->author_id, "../", 64), | ||
'username' => $this->_user->idToNickname($post->author_id), | ||
'username_style' => $this->_user->getGroupClass($post->author_id), | ||
'content' => Util::truncate($post->content, 20), | ||
'link' => URL::build('/profile/' . $this->_user->idToName($post->author_id) . '/#post-' . $post->id), | ||
'date_ago' => date('d M Y, H:i', $post->time), | ||
'user_id' => $post->author_id, | ||
'user_profile_link' => URL::build('/profile/' . $this->_user->idToName($post->author_id)), | ||
'ago' => $this->_timeago->inWords(date('d M Y, H:i', $post->time), $this->_language->getTimeLanguage()) | ||
); | ||
} | ||
$this->_cache->store('profile_posts_' . $user_id, $posts_array, 120); | ||
} | ||
if (count($posts_array) >= 1) { | ||
$this->_smarty->assign(array( | ||
'POSTS' => $posts_array | ||
)); | ||
} | ||
$this->_smarty->assign(array( | ||
'LATEST_PROFILE_POSTS' => $this->_language->get('user', 'latest_profile_posts'), | ||
'NO_PROFILE_POSTS' => $this->_language->get('user', 'no_profile_posts') | ||
)); | ||
$this->_content = $this->_smarty->fetch('widgets/profile_posts.tpl');; | ||
} | ||
} |