Feature #18990 » sys_action.patch

Administrator Admin, 2008-06-19 20:24

View differences:

typo3conf/ext/sys_action/class.tx_sysaction.php 2008-06-19 20:22:08.000000000 +0200
25 25
*  This copyright notice MUST APPEAR in all copies of the script!
26 26
***************************************************************/
27 27
/**
28
 * @author	Kasper Sk?rh?j <kasperYYYY@typo3.com>
28
 * @author	Kasper Sk�rh�j <kasperYYYY@typo3.com>
29
 * @author Peter Russ <peter.russ@4many.net>
29 30
 */
30 31

  
31 32
require_once(PATH_t3lib."class.t3lib_tceforms.php");
......
40 41
	var $insCounter=0;
41 42
	var $xCol;
42 43
	var $t3lib_TCEforms;
44
	var $extKey='tx_sysaction';
43 45

  
44 46
	function overview_main()	{
45 47
		$mC = $this->renderActionList();
......
67 69
		$uid = t3lib_div::intInRange(t3lib_div::_GP("sys_action_uid"),0);
68 70
		$out="";
69 71
		$header="";
72
		#get SessionData
73
		$session=$GLOBALS['BE_USER']->getSessionData($this->extKey);
74
		#reset if no uid given i.e. just arrived in taskcenter and no action selected
70 75
		if ($uid)	{
71 76
			$res = $this->getActionResPointer($uid);
72 77
			if($actionRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))	{
73 78

  
74
					// Action header:
79
				// Action header:
75 80
				$header = t3lib_iconworks::getIconImage("sys_action",$actionRow,$this->backPath,'hspace="2" class="absmiddle"').'<b>'.$actionRow["title"].'</b>';
76 81
				$out.='<table border=0 cellpadding=0 cellspacing=1 width=100%>
77 82
					<tr><td colspan=2 class="bgColor5">'.fw($header).'</td></tr>
......
233 238
					case 5: //new record
234 239
						return htmlspecialchars($this->headLInk('tx_taskcenterrootlist', 1)). '<br />'. $this->urlInIframe($this->backPath.'alt_doc.php?returnUrl='.rawurlencode('db_list.php?id='.intval($actionRow['t3_listPid']).'&table='.$actionRow['t3_tables']).'&edit['.$actionRow['t3_tables'].']['.intval($actionRow['t3_listPid']).']=new',1);
235 240
					break;
241
					case 6:// copy and edit
242
						if (is_array($session) && $session[6]['pid'] && $session[6]['t3_listPid']==$actionRow['t3_listPid'])
243
						{
244
							$pid=$session[6]['pid'];
245
						} else {
246
							$pid=$this->copyPageTo($actionRow['t3_listPid'],$actionRow['t6_listPid']);
247
							if (is_array($session))
248
							{
249
								unset($session[6]);
250
							} else {
251
								$session=array();
252
							}
253
							$session[6]=array(
254
								'pid'=> $pid,
255
								't3_listPid' => $actionRow['t3_listPid'],
256
							);
257
						}
258
						if ($pid>0)
259
						{
260
							$actions=$this->getT4_RecordsToEdit($pid);
261
							$dbAnalysis = t3lib_div::makeInstance("t3lib_loadDBGroup");
262
							$dbAnalysis->fromTC=0;
263
							$dbAnalysis->start($actions,"*");
264
							$dbAnalysis->getFromDB();
265
							$lines=array();
266
							reset($dbAnalysis->itemArray);
267
							while(list(,$el)=each($dbAnalysis->itemArray))	{
268
								$path = t3lib_BEfunc::getRecordPath ($el["id"],$this->perms_clause,$this->BE_USER->uc["titleLen"]);
269
								$lines[]='<tr>
270
									<td nowrap class="bgColor4">'.
271
										'<a href="'.$this->backPath.'alt_doc.php?returnUrl='.rawurlencode(t3lib_div::getIndpEnv("REQUEST_URI")).'&edit['.$el["table"].']['.$el["id"].']=edit">'.
272
										t3lib_iconworks::getIconImage($el["table"],$dbAnalysis->results[$el["table"]][$el["id"]],$this->backPath,'hspace="2" align="top" title="'.htmlspecialchars($path).'"').
273
										t3lib_BEfunc::getRecordTitle($el["table"],$dbAnalysis->results[$el["table"]][$el["id"]],TRUE).'</a></td>
274
									</tr>';
275
							}
276
							$actionContent = '<table border=0 cellpadding=0 cellspacing=2>'.implode("",$lines).'</table>';
277
							$theCode.= $this->pObj->doc->section($LANG->getLL("action_t4_edit"),$actionContent,0,1);
278
						}else {
279
							$theCode.= $this->pObj->doc->section($LANG->getLL("action_error"),'<span class="typo3-red">'.$LANG->getLL("action_noPID").'</span>',0,1);
280
						}
281
						break;
282
					case 7: // new content element
283
						if (is_array($session) && $session[6]['pid'])
284
						{
285
							$pos=$this->getLastContentElement($session[6]['pid']);
286
							return htmlspecialchars($this->headLInk('tx_taskcenterrootlist', 1)). '<br />'. $this->urlInIframe($this->backPath.'alt_doc.php?returnUrl='.rawurlencode('db_list.php?id='.intval($session[6]['pid']).'&table=tt_content').'&defVals[tt_content][CType]='.$actionRow['t7_ctype'].'&edit[tt_content]['.$pos.']=new',1);
287
						} else {
288
							$theCode.= $this->pObj->doc->section($LANG->getLL("action_error"),'<span class="typo3-red">'.$LANG->getLL("action_copyFirst").'</span>',0,1);
289
						}
290
						break;
291
					case 8: // reset
292
						if (is_array($session) && $session[6]['pid'])
293
						{
294
							$session[6]=null;
295
							$theCode.= $this->pObj->doc->section($LANG->getLL("action_t8_reset"),$LANG->getLL("action_t8_done"),0,1);
296
						} else {
297
							$theCode.= $this->pObj->doc->section($LANG->getLL("action_error"),'<span class="typo3-red">'.$LANG->getLL("action_noReset").'</span>',0,1);
298
						}
299
						break;
236 300
					default:
237 301
						$theCode.= $this->pObj->doc->section($LANG->getLL("action_error"),'<span class="typo3-red">'.$LANG->getLL("action_noType").'</span>',0,1);
238 302
					break;
......
240 304

  
241 305
			}
242 306
		}
307
		# save or reset the session i.e. when session=null
308
		$GLOBALS['BE_USER']->setAndSaveSessionData($this->extKey,$session);
243 309
		return $theCode;
244 310
	}
311
	function getLastContentElement($pid)
312
	{
313
		$uid=$pid;
314
		$res=$GLOBALS['TYPO3_DB']->exec_SELECTquery(
315
			'uid',
316
			'tt_content',
317
			'pid='.$pid,
318
			'',
319
			'sorting desc',
320
			'1'
321
		);
322
		if ($rec=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))
323
		{
324
			$uid=-$rec['uid'];
325
		}
326
		return $uid;
327
	}
328
	function getT4_RecordsToEdit($pid)
329
	{
330
		$return=array();
331
		$return[]='pages_'.$pid;
332
		$res=$GLOBALS['TYPO3_DB']->exec_SELECTquery(
333
			'uid',
334
			'tt_content',
335
			'pid='.$pid,
336
			'',
337
			'sorting'
338
		);
339
		while ($rec=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))
340
		{
341
			$return[]='tt_content_'.$rec['uid'];
342
		}
343
		return join(',',$return);
344
	}
345
	function copyPageTo($from,$to)
346
	{
347
		$return=0;
348
		$tce = t3lib_div::makeInstance('t3lib_TCEmain');
349
		$tce->stripslashes_values=0;
350
		$cmd==array();
351
		$cmd['pages'][$from]['copy']=intval($to);
352
		$tce->start(array(),$cmd);
353
		$tce->process_cmdmap();
354
		$res=$GLOBALS['TYPO3_DB']->exec_SELECTquery(
355
			'uid',
356
			'pages',
357
			'pid='.$to.' and cruser_id='.intval($this->BE_USER->user['uid']),
358
			'',#group
359
			'sorting',
360
			'1'
361
		);
362
		if ($rec=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))
363
		{
364
			$return=$rec['uid'];
365
		}
366
		return $return;
367
	}
245 368
	function getActionResPointer($uid=0)	{
246 369
		if ($this->BE_USER->isAdmin())	{
247 370
			$wQ='';
typo3conf/ext/sys_action/ext_tables.sql 2008-06-19 15:52:20.000000000 +0200
21 21
  t3_listPid int(11) DEFAULT '0' NOT NULL,
22 22
  t3_tables varchar(40) DEFAULT '' NOT NULL,
23 23
  t4_recordsToEdit text NOT NULL,
24
  t6_listPid int(11) DEFAULT '0' NOT NULL,
25
  t7_ctype varchar(30) DEFAULT '' NOT NULL,
24 26

  
25 27
  PRIMARY KEY (uid),
26 28
  KEY cruser_id (cruser_id),
typo3conf/ext/sys_action/locallang.xml 2008-06-19 20:18:34.000000000 +0200
7 7
	<data type="array">
8 8
		<languageKey index="default" type="array">
9 9
			<label index="action_noType">Error: The action had no type defined.</label>
10
			<label index="action_noPID">Error: Could not copy page.</label>
11
			<label index="action_copyFirst">Error: Copy page first!</label>
12
			<label index="action_noReset">Error: There is nothing I could reset for you!</label>
10 13
			<label index="action_notReady">Error: The action configuration is not finished.</label>
11 14
			<label index="action_download_file">Click here to download the exported data in a file</label>
12 15
			<label index="action_error">Action error!</label>
......
22 25
			<label index="action_t1_listOfUsers">List of backend users</label>
23 26
			<label index="action_BEu_db_mount">Pagetree starting points</label>
24 27
			<label index="action_t4_edit">Select record to edit:</label>
28
			<label index="action_t8_reset">Variables resetted:</label>
29
			<label index="action_t8_done">The actions relatied variables got resetted.</label>
25 30
		</languageKey>
26 31
	</data>
27 32
</T3locallang>
typo3conf/ext/sys_action/tca.php 2008-06-19 20:09:17.000000000 +0200
42 42
					Array('SQL-query', '2'),
43 43
					Array('Record list', '3'),
44 44
					Array('Edit records', '4'),
45
					Array('New Record', '5')
45
					Array('New Record', '5'),
46
					Array('Copy Page & Edit','6'),
47
					Array('Content on copied page','7'),
48
					Array('Reset','8'),
46 49
				)
47 50
			)
48 51
		),
......
130 133
				'show_thumbs' => '1'
131 134
			)
132 135
		),
136
		't6_listPid' => Array (
137
			'label' => 'Target pid:',
138
			'config' => Array (
139
				'type' => 'group',
140
				'internal_type' => 'db',
141
				'allowed' => 'pages',
142
				'size' => '1',
143
				'maxitems' => '1',
144
				'minitems' => '1',
145
				'show_thumbs' => '1'
146
			)
147
		),
148
		't7_ctype' => $TCA['tt_content']['columns']['CType'],
133 149

  
134 150
	),
135 151
	'types' => Array (
......
139 155
		'3' => Array('showitem' => 'hidden;;;;1-1-1,type,title;;;;2-2-2,description;;;;3-3-3,assign_to_groups,--div--,t3_listPid;;;;5-5-5,t3_tables;'),
140 156
		'4' => Array('showitem' => 'hidden;;;;1-1-1,type,title;;;;2-2-2,description;;;;3-3-3,assign_to_groups,--div--,t4_recordsToEdit;;;;5-5-5'),
141 157
		'5' => Array('showitem' => 'hidden;;;;1-1-1,type,title;;;;2-2-2,description;;;;3-3-3,assign_to_groups,--div--,t3_listPid;Where to create records:;;;5-5-5,t3_tables;Create records in table:'),
158
		'6' => Array('showitem' => 'hidden;;;;1-1-1,type,title;;;;2-2-2,description;;;;3-3-3,assign_to_groups,--div--,t3_listPid;Page to be copied:;;;5-5-5,t6_listPid;Where to copy page on first position:'),
159
		'7' => Array('showitem' => 'hidden;;;;1-1-1,type,title;;;;2-2-2,description;;;;3-3-3,assign_to_groups,--div--,t7_ctype;'),
160
		'8' => Array('showitem' => 'hidden;;;;1-1-1,type,title;;;;2-2-2,description;;;;3-3-3,assign_to_groups,--div--,;'),
142 161
	)
143 162
);
144 163
?>
(2-2/2)