Fixed bug #11985: Optimize disposal of t3lib_PageRenderer
[Packages/TYPO3.CMS.git] / typo3 / sysext / taskcenter / task / class.mod_user_task.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
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 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Module class for task module
29 *
30 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
31 * @author Christian Jul Jensen <christian(at)jul(dot)net>
32 *
33 * Revision for TYPO3 3.8.0 / Native Workflow System
34 */
35
36 class mod_user_task extends t3lib_extobjbase {
37 var $getUserNamesFields = 'username,usergroup,usergroup_cached_list,uid,realName,email';
38 var $userGroupArray = array();
39 var $perms_clause = '';
40
41 var $backPath;
42
43 /**
44 * BE user
45 *
46 * @var t3lib_beUserAuth
47 */
48 var $BE_USER;
49
50 function JScode() {
51
52 }
53
54 /**
55 * Send an email...
56 *
57 * @param string $email: the email address to send to
58 * @param string $subject: the subject of the emil
59 * @param string $message: the message body of the email
60 * @return void
61 */
62 function sendEmail($recipient, $subject, $message) {
63 $message .= '
64
65 --------
66 '.sprintf($GLOBALS['LANG']->getLL('messages_emailFooter'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'], t3lib_div::getIndpEnv('HTTP_HOST'));
67
68 $email = t3lib_div::makeInstance('t3lib_htmlmail');
69 $email->start();
70 $email->useBase64();
71 $email->subject = $GLOBALS['TYPO3_CONF_VARS']['BE']['notificationPrefix'].' '.$subject;
72 $email->from_email = $this->BE_USER->user['email'];
73 $email->from_name = $this->BE_USER->user['realName'];
74 $email->addPlain($message);
75 $email->setHTML($email->encodeMsg($message));
76 $email->setHeaders();
77 $email->setContent();
78 $email->recipient = $recipient;
79 $email->sendTheMail();
80 }
81
82 /**
83 * Initialise the object
84 *
85 * @param object $BE_USER: instance of t3lib_beuserauth representing the current be user.
86 * @return void
87 */
88 function mod_user_task_init($BE_USER) {
89 $this->BE_USER = $BE_USER;
90 $this->perms_clause = $this->BE_USER->getPagePermsClause(1);
91 }
92
93 /**
94 * Return helpbubble image
95 *
96 * @return string image tag (HTML)
97 */
98 function helpBubble() {
99 return '<img src="'.$this->backPath.'gfx/helpbubble.gif" width="14" height="14" hspace=2 align=top'.$GLOBALS['SOBE']->doc->helpStyle().'>';
100 }
101
102
103 /**
104 * Create a link to the module with the name of the module as link text.
105 *
106 * @param string $key: the classname of the module
107 * @param bool $dontLink: Just return the name of the module without a link.
108 * @param stting $params: HTTP GET parameter string to add to the link (not used if dontLink true)
109 * @return string link (HTML) / name of module (regular string)
110 */
111 function headLink($key, $dontLink = false, $params = '') {
112 $str = $GLOBALS['SOBE']->MOD_MENU['function'][$key];
113 if (!$dontLink) $str = '<a href="index.php?SET[function]='.$key.$params.'" onClick="this.blur();">'.htmlspecialchars($str).'</a>';
114 return $str;
115 }
116
117 /**
118 * Return a string cropped to a fixed length according to system setting or parameter
119 *
120 * @param string $str: string to be cropped.
121 * @param int $len: length of the cropped string, system settings is used if none is given
122 * @return string cropped string
123 */
124 function fixed_lgd($str, $len = 0) {
125 return t3lib_div::fixed_lgd_cs($str, $len?$len:$this->BE_USER->uc['titleLen']);
126 }
127
128 /**
129 * Return an error icon
130 *
131 * @return string Image tag (HTML)
132 */
133 function errorIcon() {
134 return '<img src="'.$this->backPath.'gfx/icon_fatalerror.gif" width="18" height="16" align=top>';
135 }
136
137 /**
138 * [Describe function...]
139 *
140 * @return array ...
141 */
142 function getUserAndGroupArrays() {
143 // Get groupnames for todo-tasks
144 $be_group_Array = t3lib_BEfunc::getListGroupNames('title,uid');
145 $groupArray = array_keys($be_group_Array);
146 // Usernames
147 $be_user_Array = $be_user_Array_o = t3lib_BEfunc::getUserNames($this->getUserNamesFields);
148 if (!$GLOBALS['BE_USER']->isAdmin()) $be_user_Array = t3lib_BEfunc::blindUserNames($be_user_Array, $groupArray, 1);
149
150 $this->userGroupArray = array($be_user_Array, $be_group_Array, $be_user_Array_o);
151 return $this->userGroupArray;
152 }
153
154 /**
155 * [Describe function...]
156 *
157 * @param [type] $tstamp: ...
158 * @param [type] $prefix: ...
159 * @return [type] ...
160 */
161 function dateTimeAge($tstamp, $prefix = 1) {
162 return t3lib_BEfunc::dateTimeAge($tstamp, $prefix);
163 }
164
165 /**
166 * [Describe function...]
167 *
168 * @param [type] $mod: ...
169 * @return [type] ...
170 */
171 function accessMod($mod) {
172 return $this->BE_USER->modAccess(array('name' => $mod, 'access' => 'user,group'), 0);
173 }
174
175 /**
176 * Create configuration for entry in the left tab menu.
177 *
178 * @param string $htmlContent: Content that does not get escaped, use this for icons links etc. (HTML)
179 * @param string $label: bTitle of the tab, escaped for HTML, dispalyed after html content.
180 * @param string $content: html content that gets displayed when the tab is activated. (HTML)
181 * @param string $popUpDescription: alt-text for the tab text
182 * @return array proper configuration for the tab menu.
183 */
184 function mkMenuConfig($htmlContent, $label = "", $content = "", $popUpDescription = '') {
185 $configArr = Array();
186 if ((string) $htmlContent) $configArr['icon'] = $htmlContent;
187 if ((string) $label) $configArr['label'] = $label;
188 if ((string) $content) $configArr['content'] = $content;
189 if ((string) $linkTitle) $configArr['linkTitle'] = $linkTitle;
190 return $configArr;
191 }
192
193 /**
194 * Returns HTML code to dislay an url in an iframe with the right side of the taskcenter
195 *
196 * @param string $url: url to display
197 * @param [type] $max: ...
198 * @return string code that inserts the iframe (HTML)
199 */
200 function urlInIframe($url,$max=0) {
201 return '<iframe onload="resizeIframe(this,'.$max.');" scrolling="auto" width="100%" src="'.$url.'" name="list_frame" id="list_frame" frameborder="no" style="border: none;"></iframe>';
202 }
203
204
205 }
206
207 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/taskcenter/task/class.mod_user_task.php']) {
208 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/taskcenter/task/class.mod_user_task.php']);
209 }
210
211 ?>