2adc6d67a23a1d6a029d66ce64c15b5a32ae1d0e
[Packages/TYPO3.CMS.git] / typo3 / sysext / taskcenter / task / class.mod_user_task.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2004 Kasper Skaarhoj (kasper@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 * Revision for TYPO3 3.8.0 / Native Workflow System
33 */
34
35 require_once(PATH_t3lib.'class.t3lib_extobjbase.php');
36
37 class mod_user_task extends t3lib_extobjbase {
38 var $getUserNamesFields = 'username,usergroup,usergroup_cached_list,uid,realName,email';
39 var $userGroupArray = array();
40 var $perms_clause = '';
41
42 var $backPath;
43 var $BE_USER;
44
45 function JScode() {
46
47 }
48
49 /**
50 * Send an email...
51 *
52 * @param string $email: the email address to send to
53 * @param string $subject: the subject of the emil
54 * @param string $message: the message body of the email
55 * @return void
56 *
57 * @todo this function is from the old implementation of the
58 * taskcenter, it should be updated to modern standards
59 */
60 function sendEmail($email, $subject, $message) {
61 $sender = $this->BE_USER->user['realName'].' <'.$this->BE_USER->user['email'].'>';
62 $message .= '
63
64 --------
65 '.sprintf($GLOBALS['LANG']->getLL('messages_emailFooter'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'], t3lib_div::getIndpEnv('HTTP_HOST'));
66 mail($email, $GLOBALS['TYPO3_CONF_VARS']['BE']['notificationPrefix'].' '.$subject, $message, "From: ".$sender);
67
68 // debug($email);
69 // debug($message);
70 }
71
72 /**
73 * Initialise the object
74 *
75 * @param object $BE_USER: instance of t3lib_beuserauth representing the current be user.
76 * @return void
77 */
78 function mod_user_task_init($BE_USER) {
79 debug($BE_USER,'$BE_USER',__LINE__,__FILE__);
80
81 $this->BE_USER = $BE_USER;
82 $this->perms_clause = $this->BE_USER->getPagePermsClause(1);
83 }
84
85 /**
86 * Return helpbubble image
87 *
88 * @return string image tag (HTML)
89 */
90 function helpBubble() {
91 return '<img src="'.$this->backPath.'gfx/helpbubble.gif" width="14" height="14" hspace=2 align=top'.$GLOBALS['SOBE']->doc->helpStyle().'>';
92 }
93
94
95 /**
96 * Create a link to the module with the name of the module as link text.
97 *
98 * @param string $key: the classname of the module
99 * @param bool $dontLink: Just return the name of the module without a link.
100 * @param stting $params: HTTP GET parameter string to add to the link (not used if dontLink true)
101 * @return string link (HTML) / name of module (regular string)
102 */
103 function headLink($key, $dontLink = false, $params = '') {
104 debug($this->BE_USER->uc,'$this->BE_USER->uc',__LINE__,__FILE__);
105
106 $str = $GLOBALS['SOBE']->MOD_MENU['function'][$key];
107 if (!$dontLink) $str = '<a href="index.php?SET[function]='.$key.$params.'" onClick="this.blur();">'.htmlspecialchars($str).'</a>';
108 return $str;
109 }
110
111 /**
112 * Return a string cropped to a fixed length according to system setting or parameter
113 *
114 * @param string $str: string to be cropped.
115 * @param int $len: length of the cropped string, system settings is used if none is given
116 * @return string cropped string
117 */
118 function fixed_lgd($str, $len = 0) {
119 return t3lib_div::fixed_lgd($str, $len?$len:$this->BE_USER->uc['titleLen']);
120 }
121
122 /**
123 * Return an error icon
124 *
125 * @return string Image tag (HTML)
126 */
127 function errorIcon() {
128 return '<img src="'.$this->backPath.'gfx/icon_fatalerror.gif" width="18" height="16" align=top>';
129 }
130
131 /**
132 * [Describe function...]
133 *
134 * @return array ...
135 */
136 function getUserAndGroupArrays() {
137 // Get groupnames for todo-tasks
138 $be_group_Array = t3lib_BEfunc::getListGroupNames('title,uid');
139 $groupArray = array_keys($be_group_Array);
140 // Usernames
141 $be_user_Array = $be_user_Array_o = t3lib_BEfunc::getUserNames($this->getUserNamesFields);
142 if (!$GLOBALS['BE_USER']->isAdmin()) $be_user_Array = t3lib_BEfunc::blindUserNames($be_user_Array, $groupArray, 1);
143
144 $this->userGroupArray = array($be_user_Array, $be_group_Array, $be_user_Array_o);
145 return $this->userGroupArray;
146 }
147
148 /**
149 * [Describe function...]
150 *
151 * @param [type] $tstamp: ...
152 * @param [type] $prefix: ...
153 * @return [type] ...
154 */
155 function dateTimeAge($tstamp, $prefix = 1) {
156 return t3lib_BEfunc::dateTimeAge($tstamp, $prefix);
157 }
158
159 /**
160 * [Describe function...]
161 *
162 * @param [type] $mod: ...
163 * @return [type] ...
164 */
165 function accessMod($mod) {
166 return $this->BE_USER->modAccess(array('name' => $mod, 'access' => 'user,group'), 0);
167 }
168
169 /**
170 * Create configuration for entry in the left tab menu.
171 *
172 * @param string $htmlContent: Content that does not get escaped, use this for icons links etc. (HTML)
173 * @param string $label: Title of the tab, escaped for HTML, dispalyed after html content.
174 * @param string $content: html content that gets displayed when the tab is activated. (HTML)
175 * @param string $popUpDescription: alt-text for the tab text
176 * @return array proper configuration for the tab menu.
177 */
178 function mkMenuConfig($htmlContent, $label = "", $content = "", $popUpDescription = '') {
179 $configArr = Array();
180 if ((string) $htmlContent) $configArr['icon'] = $htmlContent;
181 if ((string) $label) $configArr['label'] = $label;
182 if ((string) $content) $configArr['content'] = $content;
183 if ((string) $linkTitle) $configArr['linkTitle'] = $linkTitle;
184 return $configArr;
185 }
186
187 /**
188 * Returns HTML code to dislay an url in an iframe with the right side of the taskcenter
189 *
190 * @param string $url: url to display
191 * @return string code that inserts the iframe (HTML)
192 */
193 function urlInIframe($url) {
194 return '<iframe src="'.$url.'" width="100%" height="100%" style="width: 100%; height: 1200px; border: none;" />';
195 }
196
197
198 }
199
200 // Include extension?
201 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/taskcenter/task/class.mod_user_task.php']) {
202 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/taskcenter/task/class.mod_user_task.php']);
203 }
204
205
206 ?>