Project

General

Profile

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
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* @author Kasper Sk?rh?j <kasperYYYY@typo3.com>
* @author Kasper Sk�rh�j <kasperYYYY@typo3.com>
* @author Peter Russ <peter.russ@4many.net>
*/
require_once(PATH_t3lib."class.t3lib_tceforms.php");
......
var $insCounter=0;
var $xCol;
var $t3lib_TCEforms;
var $extKey='tx_sysaction';
function overview_main() {
$mC = $this->renderActionList();
......
$uid = t3lib_div::intInRange(t3lib_div::_GP("sys_action_uid"),0);
$out="";
$header="";
#get SessionData
$session=$GLOBALS['BE_USER']->getSessionData($this->extKey);
#reset if no uid given i.e. just arrived in taskcenter and no action selected
if ($uid) {
$res = $this->getActionResPointer($uid);
if($actionRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
// Action header:
// Action header:
$header = t3lib_iconworks::getIconImage("sys_action",$actionRow,$this->backPath,'hspace="2" class="absmiddle"').'<b>'.$actionRow["title"].'</b>';
$out.='<table border=0 cellpadding=0 cellspacing=1 width=100%>
<tr><td colspan=2 class="bgColor5">'.fw($header).'</td></tr>
......
case 5: //new record
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);
break;
case 6:// copy and edit
if (is_array($session) && $session[6]['pid'] && $session[6]['t3_listPid']==$actionRow['t3_listPid'])
{
$pid=$session[6]['pid'];
} else {
$pid=$this->copyPageTo($actionRow['t3_listPid'],$actionRow['t6_listPid']);
if (is_array($session))
{
unset($session[6]);
} else {
$session=array();
}
$session[6]=array(
'pid'=> $pid,
't3_listPid' => $actionRow['t3_listPid'],
);
}
if ($pid>0)
{
$actions=$this->getT4_RecordsToEdit($pid);
$dbAnalysis = t3lib_div::makeInstance("t3lib_loadDBGroup");
$dbAnalysis->fromTC=0;
$dbAnalysis->start($actions,"*");
$dbAnalysis->getFromDB();
$lines=array();
reset($dbAnalysis->itemArray);
while(list(,$el)=each($dbAnalysis->itemArray)) {
$path = t3lib_BEfunc::getRecordPath ($el["id"],$this->perms_clause,$this->BE_USER->uc["titleLen"]);
$lines[]='<tr>
<td nowrap class="bgColor4">'.
'<a href="'.$this->backPath.'alt_doc.php?returnUrl='.rawurlencode(t3lib_div::getIndpEnv("REQUEST_URI")).'&edit['.$el["table"].']['.$el["id"].']=edit">'.
t3lib_iconworks::getIconImage($el["table"],$dbAnalysis->results[$el["table"]][$el["id"]],$this->backPath,'hspace="2" align="top" title="'.htmlspecialchars($path).'"').
t3lib_BEfunc::getRecordTitle($el["table"],$dbAnalysis->results[$el["table"]][$el["id"]],TRUE).'</a></td>
</tr>';
}
$actionContent = '<table border=0 cellpadding=0 cellspacing=2>'.implode("",$lines).'</table>';
$theCode.= $this->pObj->doc->section($LANG->getLL("action_t4_edit"),$actionContent,0,1);
}else {
$theCode.= $this->pObj->doc->section($LANG->getLL("action_error"),'<span class="typo3-red">'.$LANG->getLL("action_noPID").'</span>',0,1);
}
break;
case 7: // new content element
if (is_array($session) && $session[6]['pid'])
{
$pos=$this->getLastContentElement($session[6]['pid']);
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);
} else {
$theCode.= $this->pObj->doc->section($LANG->getLL("action_error"),'<span class="typo3-red">'.$LANG->getLL("action_copyFirst").'</span>',0,1);
}
break;
case 8: // reset
if (is_array($session) && $session[6]['pid'])
{
$session[6]=null;
$theCode.= $this->pObj->doc->section($LANG->getLL("action_t8_reset"),$LANG->getLL("action_t8_done"),0,1);
} else {
$theCode.= $this->pObj->doc->section($LANG->getLL("action_error"),'<span class="typo3-red">'.$LANG->getLL("action_noReset").'</span>',0,1);
}
break;
default:
$theCode.= $this->pObj->doc->section($LANG->getLL("action_error"),'<span class="typo3-red">'.$LANG->getLL("action_noType").'</span>',0,1);
break;
......
}
}
# save or reset the session i.e. when session=null
$GLOBALS['BE_USER']->setAndSaveSessionData($this->extKey,$session);
return $theCode;
}
function getLastContentElement($pid)
{
$uid=$pid;
$res=$GLOBALS['TYPO3_DB']->exec_SELECTquery(
'uid',
'tt_content',
'pid='.$pid,
'',
'sorting desc',
'1'
);
if ($rec=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))
{
$uid=-$rec['uid'];
}
return $uid;
}
function getT4_RecordsToEdit($pid)
{
$return=array();
$return[]='pages_'.$pid;
$res=$GLOBALS['TYPO3_DB']->exec_SELECTquery(
'uid',
'tt_content',
'pid='.$pid,
'',
'sorting'
);
while ($rec=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))
{
$return[]='tt_content_'.$rec['uid'];
}
return join(',',$return);
}
function copyPageTo($from,$to)
{
$return=0;
$tce = t3lib_div::makeInstance('t3lib_TCEmain');
$tce->stripslashes_values=0;
$cmd==array();
$cmd['pages'][$from]['copy']=intval($to);
$tce->start(array(),$cmd);
$tce->process_cmdmap();
$res=$GLOBALS['TYPO3_DB']->exec_SELECTquery(
'uid',
'pages',
'pid='.$to.' and cruser_id='.intval($this->BE_USER->user['uid']),
'',#group
'sorting',
'1'
);
if ($rec=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))
{
$return=$rec['uid'];
}
return $return;
}
function getActionResPointer($uid=0) {
if ($this->BE_USER->isAdmin()) {
$wQ='';
typo3conf/ext/sys_action/ext_tables.sql 2008-06-19 15:52:20.000000000 +0200
t3_listPid int(11) DEFAULT '0' NOT NULL,
t3_tables varchar(40) DEFAULT '' NOT NULL,
t4_recordsToEdit text NOT NULL,
t6_listPid int(11) DEFAULT '0' NOT NULL,
t7_ctype varchar(30) DEFAULT '' NOT NULL,
PRIMARY KEY (uid),
KEY cruser_id (cruser_id),
typo3conf/ext/sys_action/locallang.xml 2008-06-19 20:18:34.000000000 +0200
<data type="array">
<languageKey index="default" type="array">
<label index="action_noType">Error: The action had no type defined.</label>
<label index="action_noPID">Error: Could not copy page.</label>
<label index="action_copyFirst">Error: Copy page first!</label>
<label index="action_noReset">Error: There is nothing I could reset for you!</label>
<label index="action_notReady">Error: The action configuration is not finished.</label>
<label index="action_download_file">Click here to download the exported data in a file</label>
<label index="action_error">Action error!</label>
......
<label index="action_t1_listOfUsers">List of backend users</label>
<label index="action_BEu_db_mount">Pagetree starting points</label>
<label index="action_t4_edit">Select record to edit:</label>
<label index="action_t8_reset">Variables resetted:</label>
<label index="action_t8_done">The actions relatied variables got resetted.</label>
</languageKey>
</data>
</T3locallang>
typo3conf/ext/sys_action/tca.php 2008-06-19 20:09:17.000000000 +0200
Array('SQL-query', '2'),
Array('Record list', '3'),
Array('Edit records', '4'),
Array('New Record', '5')
Array('New Record', '5'),
Array('Copy Page & Edit','6'),
Array('Content on copied page','7'),
Array('Reset','8'),
)
)
),
......
'show_thumbs' => '1'
)
),
't6_listPid' => Array (
'label' => 'Target pid:',
'config' => Array (
'type' => 'group',
'internal_type' => 'db',
'allowed' => 'pages',
'size' => '1',
'maxitems' => '1',
'minitems' => '1',
'show_thumbs' => '1'
)
),
't7_ctype' => $TCA['tt_content']['columns']['CType'],
),
'types' => Array (
......
'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;'),
'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'),
'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:'),
'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:'),
'7' => Array('showitem' => 'hidden;;;;1-1-1,type,title;;;;2-2-2,description;;;;3-3-3,assign_to_groups,--div--,t7_ctype;'),
'8' => Array('showitem' => 'hidden;;;;1-1-1,type,title;;;;2-2-2,description;;;;3-3-3,assign_to_groups,--div--,;'),
)
);
?>
(2-2/2)