More misc fixes and rewrites (sorry, lame description)
[mailer.git] / inc / libs / holiday_functions.php
index d155341c3c531d01a574afff72897c3404335ef5..e23f772dd42fda387cad593560c43d5627de682f 100644 (file)
  * -------------------------------------------------------------------- *
  * Kurzbeschreibung  : Funktionen fuer die admins-Erweiterung           *
  * -------------------------------------------------------------------- *
- *                                                                      *
+ * $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                           *
  * For more information visit: http://www.mxchange.org                  *
  ************************************************************************/
 
 // Some security stuff...
-if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
-{
-       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
+if (!defined('__SECURITY')) {
+       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
        require($INC);
 }
+
 //
-function HOLIDAY_STOP_HOLIDAYS()
-{
+function HOLIDAY_STOP_HOLIDAYS () {
        // Let's find some expired holiday requests...
-       $result_stop = SQL_QUERY("SELECT userid, holiday_start, holiday_end, comments
-FROM "._MYSQL_PREFIX."_user_holidays
-WHERE holiday_end <= UNIX_TIMESTAMP()
-ORDER BY userid", __FILE__, __LINE__);
-       if (SQL_NUMROWS($result_stop) > 0)
-       {
+       $result_stop = SQL_QUERY("SELECT
+       `userid`, `holiday_start`, `holiday_end`, `comments`
+FROM
+       `{!_MYSQL_PREFIX!}_user_holidays`
+WHERE
+       `holiday_end` <= UNIX_TIMESTAMP()
+ORDER BY
+       `userid` ASC", __FUNCTION__, __LINE__);
+       if (SQL_NUMROWS($result_stop) > 0) {
                // We foud at least one
-               $admin = "";
-               while (list($uid, $start, $end, $comments) = SQL_FETCHROW($result_stop))
-               {
+               $admin = '';
+               // Init SQLs
+               INIT_SQLS();
+
+               // Process all found entries
+               while ($content = SQL_FETCHARRAY($result_stop)) {
                        // Stop holiday
-                       $result_del = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_holidays WHERE userid=%s LIMIT 1",
-                        array(bigintval($uid)), __FILE__, __LINE__);
+                       ADD_SQL(SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_holidays` WHERE `userid`=%s LIMIT 1",
+                               array(bigintval($content['userid'])), __FUNCTION__, __LINE__, false));
 
                        // Unlock account
-                       $result_del = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data
-SET holiday_active='N', holiday_activated='0'
-WHERE userid=%s LIMIT 1", array(bigintval($uid)), __FILE__, __LINE__);
+                       ADD_SQL(SQL_QUERY_ESC("UPDATE
+       `{!_MYSQL_PREFIX!}_user_data`
+SET
+       `holiday_active`='N', `holiday_activated`=0
+WHERE
+       `userid`=%s
+LIMIT 1",
+                               array(bigintval($content['userid'])), __FUNCTION__, __LINE__, false));
 
                        // Prepare array
                        $content = array(
-                               'holiday_end'      => MAKE_DATETIME($end  , "3"),
-                               'holiday_start'    => MAKE_DATETIME($start, "3"),
-                               'holiday_comments' => $comments
+                               'holiday_end'      => generateDateTime($content['holiday_end']  , '3'),
+                               'holiday_start'    => generateDateTime($content['holiday_start'], '3'),
+                               'holiday_comments' => $content['comments']
                        );
 
                        // Send mail to user
-                       $msg = LOAD_EMAIL_TEMPLATE("member_holiday_unlock", $content, $uid);
-                       SEND_EMAIL($uid, HOLIDAY_MEMBER_UNLOCK_SUBJ, $msg);
+                       $message = LOAD_EMAIL_TEMPLATE('member_holiday_unlock', $content, $content['userid']);
+                       sendEmail($content['userid'], getMessage('HOLIDAY_MEMBER_UNLOCK_SUBJ'), $message);
 
                        // Remember userid for admin
-                       $admin .= $uid."\n";
-               }
+                       $admin .= $content['userid']."\n";
+               } // END - if
 
                // Send mail to admins
-               SEND_ADMIN_NOTIFICATION(HOLIDAY_ADMIN_UNLOCK_SUBJ, "admin_holiday_unlock", $admin, "0");
-       }
+               sendAdminNotification(getMessage('HOLIDAY_ADMIN_UNLOCK_SUBJ'), 'admin_holiday_unlock', $admin, '0');
+
+               // Run all SQLs
+               runFilterChain('run_sqls');
+       } // END - if
 
        // Free memory
        SQL_FREERESULT($result_stop);