From: Duck (Jakob Munih) Date: Thu, 29 Jan 2009 23:49:50 +0000 (+0100) Subject: Fix report X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=3d008f1da8019dd1e8b964305adcead450093fa1;p=horde.git Fix report --- diff --git a/folks/lib/Friends.php b/folks/lib/Friends.php index f038b3e40..402d1d3c2 100644 --- a/folks/lib/Friends.php +++ b/folks/lib/Friends.php @@ -56,7 +56,7 @@ class Folks_Friends { * @return Folks_Friends The newly created concrete Folks_Friends * instance, or false on an error. */ - public function factory($driver = null, $params = null) + static public function factory($driver = null, $params = null) { if ($driver === null) { $driver = $GLOBALS['conf']['friends']; diff --git a/folks/lib/Report.php b/folks/lib/Report.php index 8b44b2ad6..b080da886 100644 --- a/folks/lib/Report.php +++ b/folks/lib/Report.php @@ -4,12 +4,12 @@ * * $Horde: ansel/lib/Report.php,v 1.9 2008-07-03 04:16:00 mrubinsk Exp $ * - * Copyright 2008-2009 The Horde Project (http://www.horde.org) + * Copyright 2009 The Horde Project (http://www.horde.org) * * See the enclosed file COPYING for license information (GPL). If you * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. * - * Copyright 2008-2009 The Horde Project (http://www.horde.org) + * Copyright 2008 The Horde Project (http://www.horde.org) * * See the enclosed file COPYING for license information (GPL). If you * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. @@ -24,7 +24,7 @@ class Folks_Report { /** * Create instance */ - function factory($driver = null, $params = array()) + public static factory($driver = null, $params = array()) { if ($driver === null) { $driver = $GLOBALS['conf']['report_content']['driver']; @@ -34,13 +34,13 @@ class Folks_Report { $params = $GLOBALS['conf']['report_content']; } - require_once ANSEL_BASE . '/lib/Report/' . $driver . '.php'; + require_once FOLKS_BASE . '/lib/Report/' . $driver . '.php'; $class_name = 'Folks_Report_' . $driver; if (!class_exists($class_name)) { return PEAR::RaiseError(_("Report driver does not exist.")); } - $report = &new $class_name($params); + $report = new $class_name($params); return $report; } @@ -48,7 +48,7 @@ class Folks_Report { /** * Get reporting user email */ - function getUserEmail() + public function getUserEmail() { return $this->_getUserEmail(); } @@ -56,7 +56,7 @@ class Folks_Report { /** * Get user email */ - function _getUserEmail($user = null) + public function _getUserEmail($user = null) { require_once 'Horde/Identity.php'; @@ -68,7 +68,7 @@ class Folks_Report { /** * Get scope admins */ - function getAdmins() + public function getAdmins() { $name = $GLOBALS['registry']->getApp() . ':admin'; @@ -84,7 +84,7 @@ class Folks_Report { /** * Set title */ - function setTitle($title) + public function setTitle($title) { $this->_title = $title; } @@ -92,7 +92,7 @@ class Folks_Report { /** * Get report message title */ - function getTitle() + public function getTitle() { if (empty($this->_title)) { return sprintf(_("Content abuse report in %s"), $GLOBALS['registry']->get('name')); @@ -104,7 +104,7 @@ class Folks_Report { /** * Get report message content */ - function getMessage($message) + public function getMessage($message) { $message .= "\n\n" . _("Report by user") . ': ' . Auth::getAuth() . ' (' . $_SERVER['REMOTE_ADDR'] . ')'; @@ -117,7 +117,7 @@ class Folks_Report { * * @param string $message to pass */ - function report($message, $users = array()) + public function report($message, $users = array()) { return PEAR::raiseError(_("Unsupported")); } diff --git a/folks/lib/Report/letter.php b/folks/lib/Report/letter.php index 41ea51fc5..ed9a21d37 100644 --- a/folks/lib/Report/letter.php +++ b/folks/lib/Report/letter.php @@ -12,7 +12,7 @@ class Folks_Report_letter extends Folks_Report { /** * Report */ - function report($message, $users = array()) + public function report($message, $users = array()) { if (!empty($users)) { // We are sending a report to to the gallery owner diff --git a/folks/lib/Report/mail.php b/folks/lib/Report/mail.php index 14b65c7c1..f5a7b951a 100644 --- a/folks/lib/Report/mail.php +++ b/folks/lib/Report/mail.php @@ -12,7 +12,7 @@ class Folks_Report_mail extends Folks_Report { /** * Report */ - function report($message, $users = array()) + public function report($message, $users = array()) { global $conf; @@ -27,30 +27,14 @@ class Folks_Report_mail extends Folks_Report { } } - require_once 'Horde/MIME.php'; - require_once 'Horde/MIME/Headers.php'; - require_once 'Horde/MIME/Message.php'; - - $email = $this->getUserEmail(); - - $msg_headers = new MIME_Headers(); - $msg_headers->addReceivedHeader(); - $msg_headers->addMessageIdHeader(); - $msg_headers->addAgentHeader(); - $msg_headers->addHeader('Date', date('r')); - $msg_headers->addHeader('To', $to); - $msg_headers->addHeader('Subject', $this->getTitle()); - $msg_headers->addHeader('From', $email); + /* + * Needed for the Horde 4 mime library - use autoload everywhere we can + * when this is *really* refactored for horde 4 + */ + $mail = new Horde_Mime_Mail($this->getTitle(), $this->getMessage($message), $to, $this->getUserEmail()); //FIXME: This address should be configurable - $msg_headers->addHeader('Sender', 'horde-problem@' . $conf['report_content']['maildomain']); - - $mime = new MIME_Message(); - $mime->addPart( - new MIME_Part('text/plain', - String::wrap($this->getMessage($message), 80, "\n"), - NLS::getCharset())); - $msg_headers->addMIMEHeaders($mime); + $mail->addHeader('Sender', 'horde-problem@' . $conf['report_content']['maildomain']); $mail_driver = $conf['mailer']['type']; $mail_params = $conf['mailer']['params']; @@ -66,7 +50,6 @@ class Folks_Report_mail extends Folks_Report { } } - return $mime->send($conf['report_content']['email'], - $msg_headers, $mail_driver, $mail_params); + return $mail->send($mail_driver, $mail_params); } } \ No newline at end of file diff --git a/folks/lib/Report/tickets.php b/folks/lib/Report/tickets.php index 1feefbf43..0d445d247 100644 --- a/folks/lib/Report/tickets.php +++ b/folks/lib/Report/tickets.php @@ -12,7 +12,7 @@ class Folks_Report_tickets extends Folks_Report { /** * Report */ - function report($message) + public function report($message) { $info = array_merge($GLOBALS['conf']['report_content']['ticket_params'], array('summary' => $this->getTitle(), diff --git a/folks/report.php b/folks/report.php index 1556242ff..a31b8ed9b 100644 --- a/folks/report.php +++ b/folks/report.php @@ -4,7 +4,7 @@ * * $Horde: folks/report.php,v 1.5 2008-08-03 18:32:29 mrubinsk Exp $ * - * Copyright 2007-2009 The Horde Project (http://www.horde.org/) + * Copyright 2007-2008 The Horde Project (http://www.horde.org/) * * See the enclosed file COPYING for license information (GPL). If you * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. @@ -55,10 +55,10 @@ if ($form->validate()) { $body = _("User") . ': ' . $user . "\n" . _("Report type") . ': ' . $enum[$vars->get('type')] . "\n" . _("Report reason") . ': ' . $vars->get('reason') . "\n" - . $return_url; + . Folks::getUrlFor('user', $user); $result = $report->report($body); - if (is_a($result, 'PEAR_Error')) { + if ($result instanceof PEAR_Error) { $notification->push(_("User was not reported.") . ' ' . $result->getMessage(), 'horde.error'); } else { @@ -67,7 +67,7 @@ if ($form->validate()) { } else { $notification->push(_("User was not reported."), 'horde.warning'); } - header('Location: ' . $return_url); + header('Location: ' . Folks::getUrlFor('user', $user)); exit; }