More rewrites, and output-mode fixed (we should documentate this)
[mailer.git] / inc / modules / admin / what-admins_contct.php
index 31d92eaf701373a37bdab08dde42ff3dced41f1b..dd56097715e5ea802f28c77eb0376724ce61eccf 100644 (file)
  * -------------------------------------------------------------------- *
  * Kurzbeschreibung  : Admin per Mail oder Nachricht kontaktieren       *
  * -------------------------------------------------------------------- *
- *                                                                      *
+ * $Revision::                                                        $ *
+ * $Date::                                                            $ *
+ * $Tag:: 0.2.1-FINAL                                                 $ *
+ * $Author::                                                          $ *
+ * Needs to be in all Files and every File needs "svn propset           *
+ * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
- * Copyright (c) 2003 - 2008 by Roland Haeder                           *
+ * Copyright (c) 2003 - 2009 by Roland Haeder                           *
  * For more information visit: http://www.mxchange.org                  *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
  ************************************************************************/
 
 // Some security stuff...
-if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN()))
-{
-       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
-       require($INC);
+if ((!defined('__SECURITY')) || (!isAdmin())) {
+       die();
 }
+
 // Add description as navigation point
-ADD_DESCR("admin", basename(__FILE__));
+addMenuDescription('admin', __FILE__);
 
-if ((isset($_POST['ok'])) && (!empty($_GET['admin'])))
-{
+if ((isFormSent()) && (isGetRequestElementSet('admin'))) {
        // Send mail or message
-       if ((EXT_IS_ACTIVE("msg")) && ($_POST['type'] == "msg"))
-       {
+       if ((isExtensionActive('msg')) && (postRequestElement('type') == 'message')) {
                // Add message
-               $msg = LOAD_EMAIL_TEMPLATE("admins_msg_contct_admin", $_POST['text'], "0");
-               SEND_ADMIN_MESSAGE($_GET['admin'], ADMINS_MSG_FROM_ADMIN, $msg);
-       }
-        else
-       {
+               $message = loadEmailTemplate('admins_msg_contct_admin', postRequestElement('text'), 0);
+               SEND_ADMIN_MESSAGE(getRequestElement('admin'), ADMINS_MSG_FROM_ADMIN, $message);
+       } else {
                // Load admin's email address
-               $result = SQL_QUERY_ESC("SELECT email FROM "._MYSQL_PREFIX."_admins WHERE id=%s LIMIT 1",
-                array(bigintval($_GET['admin'])), __FILE__, __LINE__);
-               list($email) = SQL_FETCHROW($result);
-               SQL_FREERESULT($result);
+               $email = getAdminEmail(bigintval(getRequestElement('admin')));
 
                // Load email template and send the mail to the admin
-               $msg = LOAD_EMAIL_TEMPLATE("admins_mail_contct_admin", $_POST['text'], "0");
-               SEND_EMAIL($email, ADMINS_MSG_FROM_ADMIN, $msg);
+               $message = loadEmailTemplate('admins_mail_contct_admin', postRequestElement('text'), 0);
+               sendEmail($email, getMessage('ADMINS_MSG_FROM_ADMIN'), $message);
        }
+
        // Mail / message dropped
-       LOAD_TEMPLATE("admin_settings_saved", false, ADMINS_ADMIN_CONTACTED);
-}
- elseif (!empty($_GET['admin']))
-{
+       loadTemplate('admin_settings_saved', false, getMessage('ADMINS_ADMIN_CONTACTED'));
+} elseif (isGetRequestElementSet('admin')) {
        // Load contact form template
-       define('__ADMIN', $_GET['admin']);
-       if (EXT_IS_ACTIVE("msg"))
-       {
+       $content['admin'] = getRequestElement('admin');
+
+       if (isExtensionActive('msg')) {
                // Add option to select between mail and message
-               define('ADMINS_MESSAGING_SELECTION', LOAD_TEMPLATE("admin_admins_contct_select", true));
-       }
-        else
-       {
+               $content['message_selection'] = loadTemplate('admin_admins_contct_select', true);
+       } else {
                // Outout hidden input
-               define('ADMINS_MESSAGING_SELECTION', LOAD_TEMPLATE("admin_admins_contct_default", true));
+               $content['message_selection'] = loadTemplate('admin_admins_contct_default', true);
        }
-       LOAD_TEMPLATE("admin_admins_contct_form");
-}
- else
-{
+
+       // Load main form
+       loadTemplate('admin_admins_contct_form', false, $content);
+} else {
        // Please select an admin!
-       LOAD_TEMPLATE("admin_settings_saved", false, ADMINS_SELECT_ADMIN);
+       loadTemplate('admin_settings_saved', false, getMessage('ADMINS_SELECT_ADMIN'));
 }
-//
+
+// [EOF]
 ?>