-
Notifications
You must be signed in to change notification settings - Fork 13
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
skywalker512
committed
Jul 8, 2018
1 parent
3cbd871
commit ed41012
Showing
8 changed files
with
234 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
$definitions["Unignore"] = "未忽视"; | ||
$definitions["Unignore member"] = "取消忽视"; | ||
$definitions["Ignore member"] = "忽视该用户"; | ||
$definitions["Ignored"] = "忽视"; | ||
$definitions["message.noIgnoredMembers"] = "你还没有忽略任何用户"; |
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,37 @@ | ||
.buildpath | ||
.project | ||
.settings | ||
.htaccess | ||
|
||
# Compiled source | ||
*.com | ||
*.class | ||
*.dll | ||
*.exe | ||
*.o | ||
*.so | ||
|
||
# Packages | ||
*.7z | ||
*.dmg | ||
*.gz | ||
*.iso | ||
*.jar | ||
*.rar | ||
*.tar | ||
*.zip | ||
|
||
# Logs and databases | ||
*.log | ||
*.sql | ||
*.sqlite | ||
|
||
# OS generated files | ||
.DS_Store | ||
.DS_Store? | ||
._* | ||
.Spotlight-V100 | ||
.Trashes | ||
ehthumbs.db | ||
Thumbs.db | ||
*~ |
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,23 @@ | ||
# Ignore Plugin | ||
|
||
Allows users to ignore other users and hide their posts. | ||
|
||
## Installation | ||
|
||
[Download](https://github.com/esotalk/Ignore/archive/master.zip) or clone the Ignore plugin repo into your esoTalk plugin directory: | ||
|
||
cd ESOTALK_DIR/addons/plugins/ | ||
git clone [email protected]:esotalk/Ignore.git Ignore | ||
|
||
Navigate to the the admin/plugins page and activate the Ignore plugin. | ||
|
||
## Translation | ||
|
||
Create `definitions.Ignore.php` in your language pack with the following definitions: | ||
|
||
$definitions["Unignore"] = "Unignore"; | ||
$definitions["Unignore member"] = "Unignore member"; | ||
$definitions["Ignore member"] = "Ignore member"; | ||
$definitions["Ignored"] = "Ignored"; | ||
$definitions["Ignored"] = "Ignored"; | ||
$definitions["message.noIgnoredMembers"] = "You haven't ignored any members. To ignore a member, go to their profile and choose <strong>Controls → Ignore member</strong>."; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
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,128 @@ | ||
<?php | ||
// Copyright 2014 Toby Zerner, Simon Zerner | ||
// This file is part of esoTalk. Please see the included license file for usage information. | ||
|
||
if (!defined("IN_ESOTALK")) exit; | ||
|
||
ET::$pluginInfo["Ignore"] = array( | ||
"name" => "忽略发言", | ||
"description" => "允许用户忽略某些用户的发言,仅作用于关注的帖子", | ||
"version" => ESOTALK_VERSION, | ||
"author" => "Toby Zerner", | ||
"authorEmail" => "[email protected]", | ||
"authorURL" => "http://esotalk.org", | ||
"license" => "GPLv2", | ||
"dependencies" => array( | ||
"esoTalk" => "1.0.0g4" | ||
) | ||
); | ||
|
||
class ETPlugin_Ignore extends ETPlugin { | ||
|
||
// Setup: add a follow column to the member_channel table. | ||
public function setup($oldVersion = "") | ||
{ | ||
$structure = ET::$database->structure(); | ||
$structure->table("member_member") | ||
->column("ignored", "bool", 0) | ||
->exec(false); | ||
|
||
return true; | ||
} | ||
|
||
public function init() | ||
{ | ||
ET::define("message.noIgnoredMembers", "You haven't ignored any members. To ignore a member, go to their profile and choose <strong>Controls → Ignore member</strong>."); | ||
} | ||
|
||
public function handler_memberController_initProfile($sender, &$member, $panes, $controls, $actions) | ||
{ | ||
if (!ET::$session->user or $member["memberId"] == ET::$session->userId) return; | ||
|
||
$controls->separator(0); | ||
$controls->add("ignore", "<a href='".URL("member/ignore/".$member["memberId"]."?token=".ET::$session->token."&return=".urlencode(ET::$controller->selfURL))."' id='ignoreLink'><i class='icon-eye-close'></i>".T($member["ignored"] ? "Unignore member" : "Ignore member")."</a>", 0); | ||
} | ||
|
||
// Add an action to toggle the ignoring status of a member. | ||
public function action_memberController_ignore($controller, $memberId = "") | ||
{ | ||
if (!ET::$session->user or !$controller->validateToken()) return; | ||
|
||
// Make sure the member that we're trying to ignore exists. | ||
if (!ET::SQL()->select("memberId")->from("member")->where("memberId", (int)$memberId)->exec()->numRows()) return; | ||
|
||
// Work out if we're already ignored or not, and switch to the opposite of that. | ||
$ignored = !ET::SQL() | ||
->select("ignored") | ||
->from("member_member") | ||
->where("memberId1", ET::$session->userId) | ||
->where("memberId2", (int)$memberId) | ||
->exec() | ||
->result(); | ||
|
||
// Write to the database. | ||
ET::memberModel()->setStatus(ET::$session->userId, $memberId, array("ignored" => $ignored)); | ||
|
||
// Redirect back to the member profile. | ||
$controller->redirect(R("return", URL("member/".$memberId))); | ||
} | ||
|
||
protected function getIgnored() | ||
{ | ||
// Get a list of all the members that the user has ignored. | ||
$result = ET::SQL() | ||
->select("memberId2") | ||
->from("member_member") | ||
->where("memberId1", ET::$session->userId) | ||
->where("ignored", 1) | ||
->exec(); | ||
$ignoredIds = array_keys($result->allRows("memberId2")); | ||
|
||
return $ignoredIds; | ||
} | ||
|
||
public function handler_postModel_getPostsAfter($sender, &$posts) | ||
{ | ||
$ignoredIds = $this->getIgnored(); | ||
|
||
foreach ($posts as $k => &$post) { | ||
if (in_array($post["memberId"], $ignoredIds)) unset($posts[$k]); | ||
} | ||
} | ||
|
||
public function handler_searchModel_afterGetResults($sender, &$results) | ||
{ | ||
$ignoredIds = $this->getIgnored(); | ||
|
||
foreach ($results as &$result) { | ||
if (in_array($result["lastPostMemberId"], $ignoredIds)) $result["unread"] = 0; | ||
} | ||
} | ||
|
||
public function handler_settingsController_initProfile($controller, $panes) | ||
{ | ||
$panes->add("ignored", "<a href='".URL("settings/ignored")."'>".T("Ignored")."</a>"); | ||
} | ||
|
||
public function action_settingsController_ignored($controller) | ||
{ | ||
// The profile method sets up the settings page and returns the member's details. | ||
// The argument is the name of the currently-active pane. | ||
if (!($member = $controller->profile("ignored"))) return; | ||
|
||
$ignoredIds = $this->getIgnored(); | ||
|
||
if ($ignoredIds) { | ||
$sql = ET::SQL(); | ||
$sql->where("m.memberId IN (:memberIds)") | ||
->bind(":memberIds", $ignoredIds) | ||
->orderBy("m.username ASC"); | ||
$members = ET::memberModel()->getWithSQL($sql); | ||
$controller->data("ignored", $members); | ||
} | ||
|
||
$controller->addCSSFile($this->resource("ignore.css")); | ||
$controller->renderProfile($this->view("ignored")); | ||
} | ||
|
||
} |
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,14 @@ | ||
.ignoredMembers { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
.ignoredMembers li { | ||
overflow: hidden; | ||
} | ||
.ignoredMembers li .button { | ||
visibility: hidden; | ||
margin-left: 10px; | ||
} | ||
.ignoredMembers li:hover .button { | ||
visibility: visible; | ||
} |
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,26 @@ | ||
<?php | ||
// Copyright 2014 Toby Zerner, Simon Zerner | ||
// This file is part of esoTalk. Please see the included license file for usage information. | ||
|
||
if (!defined("IN_ESOTALK")) exit; | ||
?> | ||
|
||
<?php if (!empty($data["ignored"])): ?> | ||
|
||
<ul class='ignoredMembers'> | ||
|
||
<?php foreach ($data["ignored"] as $k => $member): ?> | ||
<li class='action'> | ||
<a href='<?php echo URL(memberURL($member["memberId"], $member["username"])); ?>' class='name'> | ||
<?php echo avatar($member, "thumb"); ?> | ||
<?php echo name($member["username"]); ?> | ||
</a> | ||
<a href='<?php echo URL(memberURL($member["memberId"], $member["username"], "ignore")."?token=".ET::$session->token."&return=".$this->selfURL); ?>' class='button'><?php echo T("Unignore"); ?></a> | ||
</li> | ||
<?php endforeach; ?> | ||
|
||
</ul> | ||
|
||
<?php else: ?> | ||
<p class="help"><?php echo T("message.noIgnoredMembers"); ?></p> | ||
<?php endif; ?> |