Working Copy
[TYPO3CMS/Extensions/powermailCond.git] / oldLib / class.tx_powermailcond_div.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2010 Alexander Kellner <alexander.kellner@in2code.de>, in2code.
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 *
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
24
25 /**
26 * This class is for misc stuff and could be called from all other methods of this extension
27 *
28 * @author Alex Kellner <alexander.kellner@in2code.de>, in2code.
29 * @package TYPO3
30 * @subpackage tx_powermailcond_div
31 */
32 class tx_powermailcond_div {
33
34 public $extKey = 'powermail_cond'; // Extension key
35 public $prefixId = 'tx_powermailcond_pi1';
36
37 /**
38 * Write values to session
39 *
40 * @param array $array: Array for session store
41 * @param string $sesName: Session name
42 * @return void
43 */
44 public function saveInSession($array, $sesName) {
45 // get current stored values from session
46 $oldArray = $GLOBALS['TSFE']->fe_user->getKey('ses', $sesName);
47
48 // merge old with new values
49 $array = array_merge((array) $oldArray, (array) $array);
50
51 // store new session
52 $GLOBALS['TSFE']->fe_user->setKey('ses', $sesName, $array); // Generate Session with piVars array
53 $GLOBALS['TSFE']->storeSessionData(); // Save session
54 }
55
56 /**
57 * Return all values from the session (could be used for debugging, etc..)
58 *
59 * @param string $sesName: Session name
60 * @return array $array: with session values
61 */
62 public function getAllSessionValues($sesName) {
63 // get current stored values from session
64 $array = $GLOBALS['TSFE']->fe_user->getKey('ses', $sesName);
65 return $array;
66 }
67
68 /**
69 * Get tt_content UID from field UID
70 *
71 * @param integer $fuid: UID of tx_powermail_fields
72 * @return integer $uid: tt_content UID
73 */
74 public function getTtcontentUid($fuid) {
75 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery ( // DB query
76 'tt_content.uid',
77 'tx_powermail_fieldsets LEFT JOIN tx_powermail_fields ON tx_powermail_fieldsets.uid = tx_powermail_fields.fieldset LEFT JOIN tt_content ON tx_powermail_fieldsets.tt_content = tt_content.uid',
78 'tx_powermail_fields.uid = ' . intval($fuid),
79 '',
80 '',
81 1
82 );
83 if (!$res) { // If there is a result
84 return false;
85 }
86
87 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
88 return $row['uid'];
89 }
90
91 /**
92 * Write values to session
93 *
94 * @param array $conf: Configuration Array
95 * @return array $array: With all Startfields
96 */
97 public function getStartFields($conf) {
98 $array = array();
99 foreach ((array) $conf as $confLevel1) {
100 foreach ((array) $confLevel1 as $confLevel2) {
101 if (!empty($confLevel2['startField'])) {
102 $array[] = $confLevel2['startField'];
103 }
104 }
105 }
106 return $array;
107 }
108
109 }
110
111 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/powermail_cond/lib/class.tx_powermailcond_div.php']) {
112 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/powermail_cond/lib/class.tx_powermailcond_div.php']);
113 }
114 ?>