1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-05 22:27:34 +02:00

#3622 - Download plugin - moving 'Report Broken Download' to e_notify

Work in progress:
- Convert previous 'download_email' pref
- Move broken download list to download plugin admin  /e107_admin/message.php
This commit is contained in:
Tijn Kuyper
2019-10-27 18:20:59 +01:00
parent 1322eef97c
commit e5f024e669
4 changed files with 91 additions and 30 deletions

View File

@@ -0,0 +1,48 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2014 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*/
if (!defined('e107_INIT')) { exit; }
// v2.x Standard
class download_notify extends notify // plugin-folder + '_notify'
{
function config()
{
$config = array();
$config[] = array(
'name' => LAN_DL_NT_01, // "Broken download reported"
'function' => "user_download_brokendownload_reported",
'category' => ''
);
return $config;
}
function user_download_brokendownload_reported($data)
{
$download_url = e107::url('download', 'item', $data, array('mode' => 'full'));
if (isset($data['id']) && isset($data['data']))
{
$message = 'Notify test: Broken download reported';
}
else
{
$message = LAN_DL_NT_02;
$message .= " <a href=".$download_url.">".$data['download_name']."</a><br>";
$message .= str_replace("[x]", $data['user'], LAN_DL_NT_03)."<br>";
$message .= $data['report_add'];
}
$this->send('user_download_brokendownload_reported', LAN_DL_NT_01, $message);
}
}

View File

@@ -899,33 +899,36 @@ class download
*/
private function renderReport()
{
$sql = e107::getDb();
$tp = e107::getParser();
$ns = e107::getRender();
$frm = e107::getForm();
$pref = e107::getPref();
$sql = e107::getDb();
$tp = e107::getParser();
$ns = e107::getRender();
$frm = e107::getForm();
$pref = e107::getPref();
$dlrow = $this->rows;
// extract($dlrow);
$download_name = $tp->toDB($dlrow['download_name']);
$download_id = (int) $dlrow['download_id'];
$breadcrumb = array();
$breadcrumb[] = array('text' => LAN_PLUGIN_DOWNLOAD_NAME, 'url' => e107::url('download','index', $dlrow));
$breadcrumb[] = array('text' => $dlrow['download_category_name'], 'url' => e107::url('download','category', $dlrow)); // e_SELF."?action=list&id=".$dlrow['download_category_id']);
$breadcrumb[] = array('text' => $dlrow['download_name'], 'url' => e107::url('download','item', $dlrow)); //e_SELF."?action=view&id=".$dlrow['download_id']);
$breadcrumb[] = array('text' => LAN_dl_45, 'url' => null);
$download_name = $tp->toDB($dlrow['download_name']);
$download_sef = $dlrow['download_sef'];
$download_id = (int) $dlrow['download_id'];
$breadcrumb = array();
$breadcrumb[] = array('text' => LAN_PLUGIN_DOWNLOAD_NAME, 'url' => e107::url('download','index', $dlrow));
$breadcrumb[] = array('text' => $dlrow['download_category_name'], 'url' => e107::url('download','category', $dlrow));
$breadcrumb[] = array('text' => $dlrow['download_name'], 'url' => e107::url('download','item', $dlrow));
$breadcrumb[] = array('text' => LAN_dl_45, 'url' => null);
e107::breadcrumb($breadcrumb);
if (isset($_POST['report_download']))
{
$report_add = $tp->toDB($_POST['report_add']);
$user = USER ? USERNAME : LAN_GUEST;
$ip = e107::getIPHandler()->getIP(false);
$user = USER ? USERNAME : LAN_GUEST;
// Replaced with e_notify
/*
if ($pref['download_email'])
{ // this needs to be moved into the NOTIFY, with an event.
require_once(e_HANDLER."mail.php");
@@ -933,27 +936,32 @@ class download
$report = LAN_dl_58." ".SITENAME.":\n".(substr(SITEURL, -1) == "/" ? SITEURL : SITEURL."/")."download.php?view.".$download_id."\n
".LAN_dl_59." ".$user."\n".$report_add;
sendemail(SITEADMINEMAIL, $subject, $report);
}
}*/
$brokendownload_data = array(
'download_id' => $download_id,
'download_sef' => $download_sef,
'download_name' => $download_name,
'report_add' => $report_add,
'user' => $user,
'ip' => $ip,
);
e107::getEvent()->trigger('user_download_brokendownload_reported', $brokendownload_data);
$sql->insert('generic', "0, 'Broken Download', ".time().",'".USERID."', '{$download_name}', {$download_id}, '{$report_add}'");
$text = $frm->breadcrumb($breadcrumb);
$text .= "<div class='alert alert-success'>".LAN_dl_48."</div>
<a class='btn btn-primary' href='".e107::url('download','item', $dlrow)."'>".LAN_dl_49."</a>";
return $ns->tablerender(LAN_PLUGIN_DOWNLOAD_NAME, $text, 'download-report', true);
}
else
{
// require_once(HEADERF);
$text = $frm->breadcrumb($breadcrumb);

View File

@@ -2229,11 +2229,15 @@ $columnInfo = array(
<tr>
<td>".DOWLAN_151."</td>
<td>". r_userclass("download_reportbroken", $pref['download_reportbroken'])."</td>
</tr>
</tr>";
//moved to e_notify
/*
<tr>
<td>".DOWLAN_150."</td>
<td>". ($pref['download_email'] ? "<input type='checkbox' name='download_email' value='1' checked='checked'/>" : "<input type='checkbox' name='download_email' value='1'/>")."</td>
</tr>
</tr>*/
$text .= "
</table>
</div>
</div>

View File

@@ -1,8 +1,9 @@
<?php
define("LAN_PLUGIN_DOWNLOAD_NAME", "Downloads");
define("LAN_PLUGIN_DOWNLOAD_DIZ", "This plugin is a fully featured File-download system");
define("LAN_PLUGIN_DOWNLOAD_DIZ", "This plugin is a fully featured File-download system");
?>
// NOTIFY
define("LAN_DL_NT_01", "Broken download reported");
define("LAN_DL_NT_02", "The following download has been reported as broken:");
define("LAN_DL_NT_03", "It was reported by [x] with the following comments:");