--- /dev/null
+<?php
+/************************************************************************
+ * Mailer v0.2.1-FINAL Start: 01/22/2013 *
+ * =================== Last change: 01/22/2013 *
+ * *
+ * -------------------------------------------------------------------- *
+ * File : pool-functions.php *
+ * -------------------------------------------------------------------- *
+ * Short description : Functions for handling status codes *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung : Funktionen zum Umgang mit Status-Funktionen *
+ * -------------------------------------------------------------------- *
+ * $Revision:: $ *
+ * $Date:: $ *
+ * $Tag:: 0.2.1-FINAL $ *
+ * $Author:: $ *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2009 by Roland Haeder *
+ * Copyright (c) 2009 - 2012 by Mailer Developer Team *
+ * For more information visit: http://mxchange.org *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 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 General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
+ * MA 02110-1301 USA *
+ ************************************************************************/
+
+// Some security stuff...
+if (!defined('__SECURITY')) {
+ die();
+} // END - if
+
+// "Getter" for pool data from given id number
+// @TODO "Hook" ext-html_mail into this to allow column `html_msg`
+function getPoolDataFromId ($poolId) {
+ // Init content array
+ $content = array();
+
+ // Search for pool data
+ $result = SQL_QUERY_ESC('SELECT
+ `id`,
+ `sender`,
+ `subject`,
+ `text`,
+ `receivers`,
+ `payment_id`,
+ `data_type`,
+ `timestamp`,
+ `url`,
+ `target_send`,
+ `cat_id`,
+ `zip`
+FROM
+ `{?_MYSQL_PREFIX?}_pool`
+WHERE
+ `id`=%s
+LIMIT 1',
+ array(bigintval($poolId)), __FUNCTION__, __LINE__);
+
+ // Is there an entry?
+ if (SQL_NUMROWS($result) == 1) {
+ // Load data
+ $content = SQL_FETCHARRAY($result);
+ } // END - if
+
+ // Free result
+ SQL_FREERESULT($result);
+
+ // Return found data
+ return $content;
+}
+
+// Update the pool
+function updatePoolDataById ($poolId, $columnName, $data, $updateMode = NULL, $whereSql = '', $moreSql = '') {
+ // Is update mode set?
+ if (!is_null($updateMode)) {
+ // Don't allow array as data here
+ assert(!is_array($data));
+
+ // Then use this on the column with this mode (mostly counters)
+ SQL_QUERY_ESC('UPDATE `{?_MYSQL_PREFIX?}_pool` SET `%s`=`%s`%s%s WHERE `id`=%s' . $whereSql . ' LIMIT 1',
+ array(
+ $columnName,
+ $columnName,
+ $updateMode,
+ $data,
+ bigintval($poolId)
+ ), __FUNCTION__, __LINE__);
+ } elseif (is_array($data)) {
+ /*
+ * Update multiple columns, $columnName and $updateMode are being
+ * ignored as last doesn't work and first is given in $data array.
+ */
+ $sql = 'UPDATE `{?_MYSQL_PREFIX?}_pool` SET ';
+ foreach ($data as $key => $value) {
+ // Add it
+ $sql .= sprintf("`%s`='%s',", SQL_ESCAPE($key), SQL_ESCAPE($value));
+ } // END - foreach
+
+ // Finish SQL
+ $sql = substr($sql, 0, -1) . $moreSql . ' WHERE `id`=' . bigintval($id) . $whereSql . ' LIMIT 1';
+
+ // And finally run it
+ SQL_QUERY($sql, __FUNCTION__, __LINE__);
+ } else {
+ // Regular update
+ SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_pool` SET `%s`='%s' WHERE `id`=%s" . $whereSql . ' LIMIT 1',
+ array(
+ $columnName,
+ $data,
+ bigintval($poolId)
+ ), __FUNCTION__, __LINE__);
+ }
+
+ // Return if it has an affected row
+ return (SQL_AFFECTEDROWS() == 1);
+}
+
+// [EOF]
+?>