Skip to content

Commit

Permalink
Added portal module for latest Discord Posts
Browse files Browse the repository at this point in the history
  • Loading branch information
GodMod committed May 26, 2018
1 parent 11fdc5a commit 86580b9
Show file tree
Hide file tree
Showing 6 changed files with 427 additions and 8 deletions.
6 changes: 4 additions & 2 deletions discord_plugin_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static function __shortcuts()
return array_merge(parent::$shortcuts, $shortcuts);
}

public $version = '1.0.2';
public $version = '1.1.0';
public $build = '';
public $copyright = 'GodMod';
public $vstatus = 'Stable';
Expand Down Expand Up @@ -83,6 +83,8 @@ public function __construct()

$this->add_hook('avatar_provider', 'discord_avatar_provider_hook', 'avatar_provider');
$this->add_hook('user_avatarimg', 'discord_avatar_provider_hook', 'user_avatarimg');

$this->add_portal_module('discordlatestposts');
}

/**
Expand Down Expand Up @@ -134,4 +136,4 @@ private function gen_admin_menu()
}

}
?>
?>
18 changes: 15 additions & 3 deletions language/english/lang_main.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
'discord' => 'Discord',

// Description
'sk_discord_short_desc' => 'Init Discord',
'sk_discord_long_desc' => 'Initiated the connection between EQdkp Plus and Discord',
'discord_short_desc' => 'Init Discord',
'discord_long_desc' => 'Initiated the connection between EQdkp Plus and Discord',

'discord_plugin_not_installed' => 'Discord-Plugin is not installed.',

Expand All @@ -41,6 +41,18 @@
'discord_f_bot_token' => 'Access Token of the App Bot User',
'discord_f_help_bot_token' => 'For more information and instructions see https://eqdkp-plus.eu/wiki/Discord',
'discord_autorize_bot' => 'Add Bot to the Guildserver',

//Portalmodule
'discordlatestposts' => 'Latest Discord-Posts',
'discordlatestposts_name' => 'Latest Discord-Posts',
'discordlatestposts_desc' => 'Shows the latest Posts from your selected Discord Channels',
'discord_f_amount' => 'Number of shown posts',
'discord_f_blackwhitelist' => 'Black - or Whitelists',
'discord_f_help_blackwhitelist' => 'Reject the inserted Forum IDs (blacklisting) or accept them (whitelisting)',
'discord_f_cachetime' => 'Cachingtime of the posts',
'discord_f_help_privateforums2' => 'Select the forums for the shown usergroup used by Black-/Whitelist',
'discordlatestposts_noselectedboards' => "No selected Channels",
'discordlatestposts_noentries' => 'No posts available',
);

?>
?>
18 changes: 15 additions & 3 deletions language/german/lang_main.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
'discord' => 'Discord',

// Description
'sk_discord_short_desc' => 'Discord einrichten',
'sk_discord_long_desc' => 'Richte die Verbindung zwischen EQdkp Plus und Discord ein',
'discord_short_desc' => 'Discord einrichten',
'discord_long_desc' => 'Richte die Verbindung zwischen EQdkp Plus und Discord ein',

'discord_plugin_not_installed' => 'Das Discord-Plugin ist nicht installiert.',

Expand All @@ -41,6 +41,18 @@
'discord_f_bot_token' => 'Access Token des App Bot-Users',
'discord_f_help_bot_token' => 'Für weitere Informationen siehe https://eqdkp-plus.eu/wiki/Discord',
'discord_autorize_bot' => 'Bot zum Gildenserver hinzufügen',

//Portalmodule
'discordlatestposts' => 'Neuste Discord-Posts',
'discordlatestposts_name' => 'Neuste Discord-Posts',
'discordlatestposts_desc' => 'Zeigt die neuesten Beiträge aus deinen Discord-Channels an',
'discord_f_amount' => 'Anzahl an gezeigten Posts',
'discord_f_blackwhitelist' => 'Black - oder Whitelists',
'discord_f_help_blackwhitelist' => 'Ausgewählte Channels zulassen (Whitelist) oder Abweisen (Blacklist)',
'discord_f_cachetime' => 'Cachingzeit der Posts in Minuten',
'discord_f_help_privateforums2' => 'Wähle die Foren für die angezeigte Benutzergruppe aus, auf die die Black-/Whitelist angewendet werden soll',
'discordlatestposts_noselectedboards' => "Keine ausgewählten Channels",
'discordlatestposts_noentries' => 'Keine Einträge vorhanden',
);

?>
?>
40 changes: 40 additions & 0 deletions portal/ajax.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/* Project: EQdkp-Plus
* Package: Voice Portal Module
* Link: http://eqdkp-plus.eu
*
* Copyright (C) 2006-2015 EQdkp-Plus Developer Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

define('EQDKP_INC', true);

$eqdkp_root_path = './../../../';
include_once($eqdkp_root_path.'common.php');

$moduleID = registry::register('input')->get('mid');

//Check Permission
$objPortal = register('portal');
if(!$objPortal->check_visibility($moduleID)) exit;

include_once($eqdkp_root_path.'plugins/discord/portal/discordpostviewer.class.php');
$objDiscordPostViewer = register('discordpostviewer', array($moduleID));

$out = $objDiscordPostViewer->output();

header('content-type: text/html; charset=UTF-8');
echo $out;
exit;
133 changes: 133 additions & 0 deletions portal/discordlatestposts_portal.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
<?php
/* Project: EQdkp-Plus
* Package: Last posts Portal Module
* Link: http://eqdkp-plus.eu
*
* Copyright (C) 2006-2016 EQdkp-Plus Developer Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

if ( !defined('EQDKP_INC') ){
header('HTTP/1.0 404 Not Found');exit;
}

class discordlatestposts_portal extends portal_generic {

protected static $path = 'discordlatestposts';

protected static $data = array(
'name' => 'Latest Discord Posts',
'version' => '0.1.0',
'author' => 'GodMod',
'icon' => 'fa-group',
'contact' => EQDKP_PROJECT_URL,
'description' => 'View the latest Discord posts.',
'reload_on_vis' => true,
'lang_prefix' => 'discord_',
'multiple' => true,
);

protected static $multiple = true;

protected static $apiLevel = 20;

public function get_settings($state){
$moduleID = $this->config('_module_id');

$settings = array(
'amount' => array(
'type' => 'spinner',
),
'cachetime' => array(
'type' => 'spinner',
'default' => 3,
),
'blackwhitelist' => array(
'type' => 'dropdown',
'options' => array(
'black' => 'Blacklist',
'white' => 'Whitelist',
)
),
);

include_once($this->root_path.'plugins/discord/portal/discordpostviewer.class.php');
$objDiscordPostViewer = register('discordpostviewer', array($moduleID));

$arrOptions = $objDiscordPostViewer->getChannels();

$visibility = $this->config('visibility');
if (is_array($visibility)) {
foreach ($visibility as $key => $value){
$dir_lang = $this->user->lang('discordlatestposts_f_privateforums').(((int)$value == 0) ? $this->user->lang('cl_all') : $this->pdh->get('user_groups', 'name', array($value)));

$settings['privateforums_'.$value] = array(
'dir_lang' => $dir_lang,
'type' => 'multiselect',
'help' => 'discord_f_help_privateforums2',
'options' => $arrOptions,
);

}
}

return $settings;
}


public function output() {
$moduleID = $this->id;

$this->tpl->add_css(
".dclp_text_margin {
margin-left: 38px;
}
.dclp_text {
word-wrap:break-word;
}
.dclp_hori .dclp_text {
margin-left: 40px;
}
"
);

$intCachetime = ($this->config('cachetime')) ? (60*intval($this->config('cachetime'))) : (3*60);

$this->tpl->add_js('
setInterval(function() {
$.get("'.$this->server_path.'plugins/discord/portal/ajax.php'.$this->SID.'&mid='.$moduleID.'", function(data){
if(data){
$(".discordposts_'.$moduleID.'_container").html(data);
}
});
}, 1000*'.intval($intCachetime).');
');


include_once($this->root_path.'plugins/discord/portal/discordpostviewer.class.php');
$objDiscordPostViewer = register('discordpostviewer', array($moduleID, $this->wide_content));

$myOut = $objDiscordPostViewer->output();

return '<div class="discordposts_'.$moduleID.'_container">'.$myOut.'</div>';
}


}

?>
Loading

0 comments on commit 86580b9

Please sign in to comment.