Project

General

Profile

Bug #22921 » 14771_updates_sys-actions_v2.patch

Administrator Admin, 2010-06-17 22:58

View differences:

typo3/sysext/sys_action/class.tx_sysaction.php (Arbeitskopie)
<?php
/***************************************************************
* Copyright notice
*
* (c) 1999-2010 Kasper Skaarhoj (kasperYYYY@typo3.com)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* @author Kasper Sk?rh?j <kasperYYYY@typo3.com>
*/
class tx_sysaction extends mod_user_task {
var $todoTypesCache = array();
var $insCounter=0;
var $xCol;
/**
* TCEforms instance
*
* @var t3lib_TCEforms
*/
var $t3lib_TCEforms;
function overview_main() {
$mC = $this->renderActionList();
if ($mC) {
$icon = '<img src="'.$this->backPath.t3lib_extMgm::extRelPath("sys_action").'ext_icon.gif" width=18 height=16 class="absmiddle">';
return $this->mkMenuConfig($icon.$this->headLink("tx_sysaction",1),'',$mC);
}
}
function main() {
global $SOBE,$BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
return $this->renderActions();
}
function JScode() {
$this->t3lib_TCEforms = t3lib_div::makeInstance("t3lib_TCEforms");
$this->t3lib_TCEforms->backPath = $GLOBALS["BACK_PATH"];
return $this->t3lib_TCEforms->dbFileCon();
}
// ************************
// ACTIONS
// ***********************
function renderActions() {
global $LANG;
$uid = t3lib_div::intInRange(t3lib_div::_GP("sys_action_uid"),0);
$out="";
$header="";
if ($uid) {
$res = $this->getActionResPointer($uid);
if($actionRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
// Action header:
$header = t3lib_iconworks::getIconImage("sys_action",$actionRow,$this->backPath,'hspace="2" class="absmiddle"').'<strong>'.htmlspecialchars($actionRow["title"]).'</strong>';
$out.='<table border=0 cellpadding=0 cellspacing=1 width=100%>
<tr><td colspan=2 class="bgColor5">' . $header . '</td></tr>
<tr>
<td width=1% valign=top class="bgColor4">' . $LANG->sL(t3lib_BEfunc::getItemLabel('sys_action', 'type')). '&nbsp;' . '</td>
<td valign=top class="bgColor4">' . htmlspecialchars(t3lib_BEfunc::getProcessedValue('sys_action', 'type', $actionRow['type'])) . '</td>
</tr>
<tr>
<td width=1% valign=top class="bgColor4">' . $LANG->sL(t3lib_BEfunc::getItemLabel('sys_action', 'description')) . '&nbsp;' . '</td>
<td valign=top class="bgColor4">' . nl2br(htmlspecialchars($actionRow['description'])) . '</td>
</tr>';
$out.='</table>';
$theCode = $this->pObj->doc->section("",$out,0,1);
// Types of actions:
switch($actionRow["type"]) {
case 1: // new BE user
$actionContent="";
$beRec = t3lib_BEfunc::getRecord("be_users",intval($actionRow["t1_copy_of_user"]));
if (is_array($beRec)) {
// Create or update:
$inData = t3lib_div::_GP("data");
// debug($inData);
$userRecord="";
$newFlag=0;
if (is_array($inData["be_users"])) {
$nId = $this->action_t1_createUpdateBeUser($inData["be_users"],$actionRow);
$userRecord=t3lib_BEfunc::getRecord("be_users",$nId);
}
if (t3lib_div::_GP("be_users_uid")) {
$userRecord = t3lib_BEfunc::getRecord('be_users', t3lib_div::_GP('be_users_uid'), '*', ' AND cruser_id='.intval($this->BE_USER->user['uid']).' AND createdByAction='.intval($actionRow['uid']));
}
if (!is_array($userRecord)) {
$userRecord=array();
if (is_array($inData["be_users"]["NEW"])) { $userRecord=$inData["be_users"]["NEW"]; }
$userRecord["uid"]="NEW";
$newFlag=1;
}
// List of users...
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'be_users', 'pid=0 AND cruser_id='.intval($this->BE_USER->user['uid']).' AND createdByAction='.intval($actionRow['uid']).t3lib_BEfunc::deleteClause('be_users'), '', 'username');
$lines = array();
while($uRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$lines[] = "<nobr>".($uRow["uid"]==$userRecord["uid"]?"<strong>":"").$this->action_linkUserName(t3lib_iconworks::getIconImage("be_users",$uRow,$this->backPath,'title="uid='.$uRow["uid"].'" hspace="2" align="top"').$uRow["username"]." (".$uRow["realName"].")".($uRow["uid"]==$userRecord["uid"]?"</strong>":"")."</nobr>",$actionRow["uid"],$uRow["uid"])."<br>";
}
if (count($lines)) {
$theCode.= $this->pObj->doc->section($LANG->getLL("action_t1_listOfUsers"),implode("",$lines),0,1);
}
$formA=Array();
$opt=array();
$grList = t3lib_div::trimExplode(",",$actionRow["t1_allowed_groups"],1);
$opt[]='<option value=""></option>';
foreach ($grlist as $gu) {
$checkGr = t3lib_BEfunc::getRecord("be_groups",$gu);
if (is_array($checkGr)) $opt[]='<option value="'.$checkGr["uid"].'"'.(t3lib_div::inList($userRecord["usergroup"],$checkGr["uid"])?" selected":"").'>'.htmlspecialchars($checkGr["title"]).'</option>';
}
$formA[]=array($LANG->getLL("action_BEu_hidden").":&nbsp;", '<input type="checkbox" name="data[be_users]['.$userRecord["uid"].'][disable]" value=1'.($userRecord["disable"]?" checked":"").'>');
$formA[]=array($LANG->getLL("action_BEu_username").":&nbsp;", '<input type="text" name="data[be_users]['.$userRecord["uid"].'][username]" max=15 value="'.htmlspecialchars($userRecord["username"]).'"'.$this->pObj->doc->formWidth(15).'>');
$formA[]=array($LANG->getLL("action_BEu_password").":&nbsp;", '<input type="password" name="data[be_users]['.$userRecord["uid"].'][password]" max=40'.$this->pObj->doc->formWidth(15).'>');
$formA[]=array($LANG->getLL("action_BEu_realName").":&nbsp;", '<input type="text" name="data[be_users]['.$userRecord["uid"].'][realName]" value="'.htmlspecialchars($userRecord["realName"]).'"'.$this->pObj->doc->formWidth(30).'>');
$formA[]=array($LANG->getLL("action_BEu_email").":&nbsp;", '<input type="text" name="data[be_users]['.$userRecord["uid"].'][email]" value="'.htmlspecialchars($userRecord["email"]).'"'.$this->pObj->doc->formWidth(30).'>');
if (count($grList)) {
$formA[]=array($LANG->getLL("action_BEu_usergroups").":&nbsp;", '<select size='.t3lib_div::intInRange(count($opt),2).' multiple name="data[be_users]['.$userRecord["uid"].'][usergroups][]">'.implode("",$opt).'</select>');
}
// DB mounts:
$loadDB = t3lib_div::makeInstance("t3lib_loadDBGroup");
$loadDB->start($userRecord["db_mountpoints"],"pages");
$params=array(
"size" => 3
);
$formA[]=array($LANG->getLL("action_BEu_db_mount").":&nbsp;", $this->t3lib_TCEforms->dbFileIcons('data[be_users]['.$userRecord["uid"].'][db_mountpoints]','db','pages',$loadDB->itemArray,"",$params));
$formA[]=array("&nbsp;","&nbsp;");
$formA[]=array("&nbsp;", '<input type=hidden value="'.$uid.'" name="sys_action_uid"><input type=hidden value="'.t3lib_div::_GP("be_users_uid").'" name="be_users_uid"><input type=hidden value="'.$uid.'" name="sys_action_uid"><input type="submit" name="submit" value="'.$LANG->getLL($newFlag?"lCreate":"lUpdate").'">'.(!$newFlag?' <input type="submit" name="_delete_" value="'.$LANG->getLL("lDelete").'" onClick="return confirm('.$GLOBALS['LANG']->JScharCode($LANG->getLL("lDelete_warning")).');">':''));
if (!$newFlag) {
$p = 'uid='.$userRecord["uid"].", ".$LANG->getLL("lHomedir").": ";
$hPath=$this->action_getUserMainDir();
if ($hPath && @is_dir($hPath.$userRecord["uid"]."/")) {
$p.= $hPath;
} else {
$p.= $LANG->getLL("lNone");
}
$actionContent.=t3lib_iconworks::getIconImage("be_users",$userRecord,$this->backPath,'title="'.htmlspecialchars($p).'" hspace=2 align=top').$userRecord["username"]." (".$userRecord["realName"].")";
}
$actionContent.=$this->pObj->doc->table($formA);
$theCode.= $this->pObj->doc->section($LANG->getLL($newFlag?"action_Create":"action_Update"),$actionContent,0,1);
} else {
$theCode.= $this->pObj->doc->section($LANG->getLL("action_error"),'<span class="typo3-red">'.$LANG->getLL("action_notReady").'</span>',0,1);
}
break;
case 2: //SQL query
if (t3lib_extMgm::isLoaded("lowlevel")) {
$sql_query = unserialize($actionRow["t2_data"]);
if (is_array($sql_query) && strtoupper(substr(trim($sql_query["qSelect"]),0,6))=="SELECT") {
$fullsearch = t3lib_div::makeInstance("t3lib_fullsearch");
$fullsearch->formW = 40;
$fullsearch->noDownloadB=1;
$actionContent="";
// debug($sql_query);
$type = $sql_query["qC"]["search_query_makeQuery"];
$res = $GLOBALS['TYPO3_DB']->sql_query($sql_query["qSelect"]);
if (!$GLOBALS['TYPO3_DB']->sql_error()) {
$fullsearch->formW=48;
$cP=$fullsearch->getQueryResultCode($type,$res,$sql_query["qC"]["queryTable"]);
$actionContent=$cP["content"];
if ($type=="csv" || $type=="xml") {
$actionContent.='<BR><BR><a href="'.t3lib_div::getIndpEnv("REQUEST_URI").'&download_file=1"><strong>'.$LANG->getLL("action_download_file").'</strong></a>';
}
} else {
$actionContent.=$GLOBALS['TYPO3_DB']->sql_error();
}
if ($this->BE_USER->isAdmin()) {
$actionContent.="<HR>".$fullsearch->tableWrap($sql_query["qSelect"]);
$actionContent.='<BR><strong><a href="'.$this->backPath.t3lib_extMgm::extRelPath("lowlevel").'dbint/index.php?id='.
'&SET[function]=search'.
'&SET[search]=query'.
'&storeControl[STORE]=-'.$actionRow["uid"].
'&storeControl[LOAD]=1'.
'">' . $GLOBALS['LANG']->getLL('action_editQuery') . '</a></strong>';
}
$theCode.= $this->pObj->doc->section($LANG->getLL("action_t2_result"),$actionContent,0,1);
} else {
$theCode.= $this->pObj->doc->section($LANG->getLL("action_error"),'<span class="typo3-red">'.$LANG->getLL("action_notReady").'</span>',0,1);
}
} else {
$theCode.= $this->pObj->doc->section(
$GLOBALS['LANG']->getLL('action_error'),
'<span class="typo3-red">' . $GLOBALS['LANG']->getLL('action_lowlevelMissing', true) . '</span>',
0, 1
);
}
break;
case 3: //list records
return htmlspecialchars($this->headLInk('tx_taskcenterrootlist', 1)). '<br />'. $this->urlInIframe($this->backPath."db_list.php?id=".intval($actionRow["t3_listPid"])."&table=".$actionRow["t3_tables"],1);
break;
case 4: //edit records
$dbAnalysis = t3lib_div::makeInstance("t3lib_loadDBGroup");
$dbAnalysis->fromTC=0;
$dbAnalysis->start($actionRow["t4_recordsToEdit"],"*");
$dbAnalysis->getFromDB();
$lines=array();
foreach ($dbAnalysis->itemArray as $el) {
$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);
break;
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;
default:
$theCode.= $this->pObj->doc->section($LANG->getLL("action_error"),'<span class="typo3-red">'.$LANG->getLL("action_noType").'</span>',0,1);
break;
}
}
}
return $theCode;
}
function getActionResPointer($uid=0) {
if ($this->BE_USER->isAdmin()) {
$wQ='';
if (intval($uid)>0) $wQ.=' AND sys_action.uid='.intval($uid);
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_action', 'sys_action.pid=0'.$wQ, '', 'sys_action.sorting');
} else {
$wQ = 'be_groups.uid IN ('.($this->BE_USER->groupList?$this->BE_USER->groupList:0).')';
$hQ = 'AND sys_action.hidden=0 ';
if (intval($uid)>0) $wQ.=' AND sys_action.uid='.intval($uid);
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query(
'sys_action.*',
'sys_action',
'sys_action_asgr_mm',
'be_groups',
' AND '.$wQ.' AND sys_action.pid=0 '.$hQ,
'sys_action.uid',
'sys_action.sorting'
);
}
return $res;
}
function renderActionList() {
global $LANG;
$res = $this->getActionResPointer();
$lines=array();
while($actionRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$lines[]='<nobr>'.t3lib_iconworks::getIconImage("sys_action",$actionRow,$this->backPath,'hspace="2" align="top"').$this->action_link($this->fixed_lgd(htmlspecialchars($actionRow['title'])),$actionRow['uid'],htmlspecialchars($actionRow['description'])).'</nobr><br />';
}
$out = implode("",$lines);
return $out;
}
function action_link($str,$id,$title="") {
$str='<a href="index.php?SET[function]=tx_sysaction&sys_action_uid='.$id.'" onClick="this.blur();" title="'.htmlspecialchars($title).'">'.$str.'</a>';
return $str;
}
function action_linkUserName($str,$id,$bid) {
$str='<a href="index.php?sys_action_uid='.$id.'&be_users_uid='.$bid.'" onClick="this.blur();">'.$str.'</a>';
return $str;
}
function action_t1_createUpdateBeUser($arr,$actionRow=array()) {
reset($arr);
$key = key($arr);
$data="";
$nId=0;
$BEuid = $actionRow["t1_copy_of_user"];
if ($key=="NEW") {
$beRec = t3lib_BEfunc::getRecord("be_users",intval($BEuid));
if (is_array($beRec) && trim($arr[$key]["password"]) && $this->fixUsername($arr[$key]["username"],$actionRow["t1_userprefix"])) {
// debug($arr[$key]);
$data=array();
$data["be_users"][$key]=$beRec;
$data["be_users"][$key]["username"]=$this->fixUsername($arr[$key]["username"],$actionRow["t1_userprefix"]);
$data["be_users"][$key]["password"]=md5(trim($arr[$key]["password"]));
$data["be_users"][$key]["realName"]=$arr[$key]["realName"];
$data["be_users"][$key]["email"]=$arr[$key]["email"];
$data["be_users"][$key]["disable"]=intval($arr[$key]["disable"]);
$data["be_users"][$key]["admin"]=0;
$data["be_users"][$key]["usergroup"] = $this->fixUserGroup($data["be_users"][$key]["usergroup"],$actionRow["t1_allowed_groups"],$arr[$key]["usergroups"]);
$data["be_users"][$key]["db_mountpoints"]=$arr[$key]["db_mountpoints"];
$data["be_users"][$key]["createdByAction"]=$actionRow["uid"];
}
} else {
$beRec = t3lib_BEfunc::getRecord("be_users",intval($key));
if (is_array($beRec) && $beRec["cruser_id"]==$this->BE_USER->user["uid"]) {
if (t3lib_div::_GP("_delete_")) {
// delete... ?
$cmd=array();
$cmd["be_users"][$key]["delete"]=1;
$tce = t3lib_div::makeInstance("t3lib_TCEmain");
$tce->stripslashes_values=0;
$tce->start(Array(),$cmd,$this->BE_USER);
$tce->admin=1;
$tce->process_cmdmap();
// debug($cmd);
$nId = 0;
} elseif ($this->fixUsername($arr[$key]["username"],$actionRow["t1_userprefix"])) {
// check ownership...
$data=array();
$data["be_users"][$key]["username"]=$this->fixUsername($arr[$key]["username"],$actionRow["t1_userprefix"]);
if (trim($arr[$key]["password"])) {$data["be_users"][$key]["password"]=md5(trim($arr[$key]["password"]));}
$data["be_users"][$key]["realName"]=$arr[$key]["realName"];
$data["be_users"][$key]["email"]=$arr[$key]["email"];
$data["be_users"][$key]["disable"]=intval($arr[$key]["disable"]);
$data["be_users"][$key]["admin"]=0;
$data["be_users"][$key]["usergroup"] = $this->fixUserGroup($beRec["usergroup"],$actionRow["t1_allowed_groups"],$arr[$key]["usergroups"]);
$data["be_users"][$key]["db_mountpoints"]=$arr[$key]["db_mountpoints"];
$nId=$key;
}
}
}
if (is_array($data)) {
$tce = t3lib_div::makeInstance("t3lib_TCEmain");
$tce->stripslashes_values=0;
$tce->start($data,Array(),$this->BE_USER);
$tce->admin=1;
$tce->process_datamap();
$nId = intval($tce->substNEWwithIDs["NEW"]);
if ($nId) { // Create
$this->action_createDir($nId);
} else { // update
$nId=intval($key);
}
unset($tce);
}
return $nId;
}
function fixUsername($username,$prefix) {
$username=trim($username);
$prefix=trim($prefix);
$username=preg_replace('/^'.quotemeta($prefix).'/','',$username);
if ($username) {
return $prefix.$username;
} else return false;
}
function fixUserGroup($curUserGroup,$allowedGroups,$inGroups) {
// User group:
// All current groups:
$cGroups = array_flip(t3lib_div::trimExplode(",",$curUserGroup,1));
$grList = t3lib_div::intExplode(",",$allowedGroups);
foreach ($grList as $gu) {
unset($cGroups[$gu]); // Remove the group if it's in the array for some reason...
}
// reverse array again and set incoming groups:
$cGroups=array_keys($cGroups);
if (is_array($inGroups)) {
foreach ($inGroups as $gu) {
$checkGr = t3lib_BEfunc::getRecord("be_groups",$gu);
if (is_array($checkGr) && in_array($gu,$grList)) {
$cGroups[]=$gu;
}
}
}
return implode(",",$cGroups);
}
function action_createDir($uid) {
$path = $this->action_getUserMainDir();
if ($path) {
@mkdir($path.$uid,0755);
@mkdir($path.$uid."/_temp_",0755);
// debug($path);
}
}
function action_getUserMainDir() {
$path = $GLOBALS["TYPO3_CONF_VARS"]["BE"]["userHomePath"];
if ($path && @is_dir($path) &&
$GLOBALS["TYPO3_CONF_VARS"]["BE"]["lockRootPath"] &&
t3lib_div::isFirstPartOfStr($path,$GLOBALS["TYPO3_CONF_VARS"]["BE"]["lockRootPath"]) &&
substr($path,-1)=="/"
) {
return $path;
}
}
}
if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/sys_action/class.tx_sysaction.php"]) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/sys_action/class.tx_sysaction.php"]);
}
?>
typo3/sysext/sys_action/ext_emconf.php (Arbeitskopie)
'author_company' => 'Curby Soft Multimedia',
'CGLcompliance' => '',
'CGLcompliance_note' => '',
'version' => '1.2.0',
'version' => '2.0.0',
'_md5_values_when_last_written' => 'a:17:{s:8:"TODO.txt";s:4:"17ff";s:22:"class.tx_sysaction.php";s:4:"627a";s:16:"ext_autoload.php";s:4:"9b72";s:12:"ext_icon.gif";s:4:"f410";s:14:"ext_tables.php";s:4:"abdf";s:14:"ext_tables.sql";s:4:"c36f";s:13:"locallang.xml";s:4:"3327";s:27:"locallang_csh_sysaction.xml";s:4:"a1d4";s:17:"locallang_tca.xml";s:4:"abe1";s:14:"sys_action.gif";s:4:"eb3a";s:17:"sys_action__h.gif";s:4:"7a29";s:7:"tca.php";s:4:"3356";s:32:"task/class.tx_sysaction_task.php";s:4:"207e";s:46:"toolbarmenu/class.tx_sysaction_toolbarmenu.php";s:4:"11d3";s:35:"toolbarmenu/registerToolbarItem.php";s:4:"58a6";s:29:"toolbarmenu/tx_sysactions.css";s:4:"bd1b";s:28:"toolbarmenu/tx_sysactions.js";s:4:"deb0";}',
'constraints' => array(
'depends' => array(
'taskcenter' => '1.0.0-0.0.0',
'php' => '5.1.0-0.0.0',
'typo3' => '4.3.0-0.0.0',
'taskcenter' => '2.0.0-0.0.0',
'typo3' => '4.4.0-0.0.0',
),
'conflicts' => array(
),
typo3/sysext/sys_action/ext_tables.php (Arbeitskopie)
}
if (TYPO3_MODE == 'BE') {
$TCA['sys_action'] = array (
'ctrl' => array (
$TCA['sys_action'] = array(
'ctrl' => array(
'label' => 'title',
'tstamp' => 'tstamp',
'default_sortby' => 'ORDER BY title',
......
'adminOnly' => 1,
'rootLevel' => -1,
'setToDefaultOnCopy' => 'assign_to_groups',
'enablecolumns' => array (
'enablecolumns' => array(
'disabled' => 'hidden'
),
'type' => 'type',
......
t3lib_extMgm::addLLrefForTCAdescr('sys_action','EXT:sys_action/locallang_csh_sysaction.xml');
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['taskcenter']['sys_action']['tasks'] = array(
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['taskcenter']['sys_action']['tx_sysaction_task'] = array(
'title' => 'LLL:EXT:sys_action/locallang_tca.xml:sys_action',
'description' => 'LLL:EXT:sys_action/locallang_csh_sysaction.xml:.description',
'icon' => 'EXT:sys_action/sys_action.gif',
'task' => 'tx_sysaction_task'
);
}
?>
typo3/sysext/sys_action/task/class.tx_sysaction_task.php (Arbeitskopie)
// if no task selected, render the menu
if ($show == 0) {
$content .= $this->taskObject->description(
$GLOBALS['LANG']->getLL('sys_action'),
$GLOBALS['LANG']->getLL('description')
);
$GLOBALS['LANG']->getLL('sys_action'),
$GLOBALS['LANG']->getLL('description')
);
$content .= $this->renderActionList();
} else {
......
if (count($record) == 0) {
$flashMessage = t3lib_div::makeInstance(
't3lib_FlashMessage',
$GLOBALS['LANG']->getLL('action_error-not-found', true),
$GLOBALS['LANG']->getLL('action_error-not-found', TRUE),
$GLOBALS['LANG']->getLL('action_error'),
t3lib_FlashMessage::ERROR
);
......
default:
$flashMessage = t3lib_div::makeInstance(
't3lib_FlashMessage',
$GLOBALS['LANG']->getLL('action_noType', true),
$GLOBALS['LANG']->getLL('action_noType', TRUE),
$GLOBALS['LANG']->getLL('action_error'),
t3lib_FlashMessage::ERROR
);
......
$content = '<p>' . $GLOBALS['LANG']->getLL('description') . '</p>';
// get the actions
$lines = $this->getActions();
if (count($lines) > 0) {
$actionList = $this->getActions();
if (count($actionList) > 0) {
$items = '';
// render a single action menu item
foreach ($lines as $line) {
$active = (t3lib_div::_GP('show') === $line['uid']) ? ' class="active" ' : '';
foreach ($actionList as $action) {
$active = (t3lib_div::_GP('show') === $action['uid']) ? ' class="active" ' : '';
$items .= '<li' . $active . '>
<a href="' . $line['link'] . '" title="' . htmlspecialchars($line['description']) . '">' .
htmlspecialchars($line['title']) .
<a href="' . $action['link'] . '" title="' . htmlspecialchars($action['description']) . '">' .
htmlspecialchars($action['title']) .
'</a>
</li>';
}
......
* Get all actions of an user. Admins can see any action, all others only those
* whic are allowed in sys_action record itself.
*
* @param boolean $toOverview: If true, the link redirects to the taskcenter
* @param boolean $toOverview: If TRUE, the link redirects to the taskcenter
* @return array Array holding every needed information of a sys_action
*/
protected function getActions() {
$lines = array();
$actionList = array();
// admins can see any record
if ($GLOBALS['BE_USER']->isAdmin()) {
......
'</a>';
}
$lines[] = array(
$actionList[] = array(
'uid' => $actionRow['uid'],
'title' => $actionRow['title'],
'description' => $actionRow['description'],
'descriptionHtml' => nl2br(htmlspecialchars($actionRow['description'])) . $editActionLink,
'link' => 'mod.php?M=user_task&SET[function]=sys_action.tasks&show=' . $actionRow['uid'],
'link' => 'mod.php?M=user_task&SET[function]=sys_action.tx_sysaction_task&show=' . $actionRow['uid'],
'icon' => 'EXT:sys_action/sys_action.gif'
);
}
$GLOBALS['TYPO3_DB']->sql_free_result($res);
return $lines;
return $actionList;
}
/**
......
$content = '';
// get the sys_action records
$lines = $this->getActions();
$actionList = $this->getActions();
// if any actions are found for the current users
if (count($lines) > 0) {
$content .= $this->taskObject->renderListMenu($lines);
if (count($actionList) > 0) {
$content .= $this->taskObject->renderListMenu($actionList);
} else {
$flashMessage = t3lib_div::makeInstance (
't3lib_FlashMessage',
$GLOBALS['LANG']->getLL('action_not-found-description', true),
$GLOBALS['LANG']->getLL('action_not-found-description', TRUE),
$GLOBALS['LANG']->getLL('action_not-found'),
t3lib_FlashMessage::INFO
);
......
if (!is_array($beRec)) {
$flashMessage = t3lib_div::makeInstance(
't3lib_FlashMessage',
$GLOBALS['LANG']->getLL('action_notReady', true),
$GLOBALS['LANG']->getLL('action_notReady', TRUE),
$GLOBALS['LANG']->getLL('action_error'),
t3lib_FlashMessage::ERROR
);
......
return $content;
}
$userRecord = array();
$newFlag = 0;
$vars = t3lib_div::_POST('data');
$key = 'NEW';
......
}
// load BE user to edit
if (intval(t3lib_div::_GP('be_users_uid')) > 0) {
$tmpUserId = intval(t3lib_div::_GP('be_users_uid'));
// check if the selected user is created by the current user
$rawRecord = $this->isCreatedByUser($tmpUserId, $record);
if ($rawRecord) {
// delete user
if (t3lib_div::_GP('delete') == 1) {
......
$key = $tmpUserId;
$vars = $rawRecord;
}
}
$this->JScode();
......
<fieldset class="fields">
<legend>General fields</legend>
<div class="row">
<label for="disable">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xml:LGL.disable') . '</label>
<input type="checkbox" id="disable" name="data[disable]" value="1" class="checkbox" ' . ($vars['disable'] == 1 ? ' checked="checked" ' : '') . ' />
<label for="field_disable">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xml:LGL.disable') . '</label>
<input type="checkbox" id="field_disable" name="data[disable]" value="1" class="checkbox" ' . ($vars['disable'] == 1 ? ' checked="checked" ' : '') . ' />
</div>
<div class="row">
<label for="realname">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xml:LGL.name') . '</label>
<input type="text" id="realname" name="data[realName]" value="' . htmlspecialchars($vars['realName']) .'" />
<label for="field_realname">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xml:LGL.name') . '</label>
<input type="text" id="field_realname" name="data[realName]" value="' . htmlspecialchars($vars['realName']) .'" />
</div>
<div class="row">
<label for="username">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_tca.xml:be_users.username') . '</label>
<input type="text" id="username" name="data[username]" value="' . htmlspecialchars($vars['username']) .'" />
<label for="field_username">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_tca.xml:be_users.username') . '</label>
<input type="text" id="field_username" name="data[username]" value="' . htmlspecialchars($vars['username']) .'" />
</div>
<div class="row">
<label for="password">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_tca.xml:be_users.password') . '</label>
<input type="password" id="password" name="data[password]" value="" />
<label for="field_password">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_tca.xml:be_users.password') . '</label>
<input type="password" id="field_password" name="data[password]" value="" />
</div>
<div class="row">
<label for="email">' .$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xml:LGL.email') . '</label>
<input type="text" id="email" name="data[email]" value="' . htmlspecialchars($vars['email']) .'" />
<label for="field_email">' .$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xml:LGL.email') . '</label>
<input type="text" id="field_email" name="data[email]" value="' . htmlspecialchars($vars['email']) .'" />
</div>
</fieldset>
<fieldset class="fields">
<legend>Configuration</legend>
<div class="row">
<label for="usergroup">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_tca.xml:be_users.usergroup') . '</label>
<select id="usergroup" name="data[usergroup][]" multiple="multiple">
<label for="field_usergroup">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_tca.xml:be_users.usergroup') . '</label>
<select id="field_usergroup" name="data[usergroup][]" multiple="multiple">
' . $this->getUsergroups($record, $vars) . '
</select>
</div>
<div class="row">
<label for="db_mountpoints">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_tca.xml:be_users.options_db_mounts') . '</label>
<label for="field_db_mountpoints">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_tca.xml:be_users.options_db_mounts') . '</label>
' . $this->t3lib_TCEforms->dbFileIcons('data[db_mountpoints]', 'db', 'pages', $loadDB->itemArray, '', array('size' => 3)) . '
</div>
<div class="row">
......
'be_users',
'uid=' . $userId,
array (
'deleted' => 1,
'tstamp' => $GLOBALS['ACCESS_TIME']
'deleted' => 1,
'tstamp' => $GLOBALS['ACCESS_TIME']
)
);
......
*
* @param int $id: Id of the BE user
* @param array $action: sys_action record.
* @return mixed the record of the BE user if found, otherwise false
* @return mixed the record of the BE user if found, otherwise FALSE
*/
protected function isCreatedByUser($id, $action) {
$record = t3lib_BEfunc::getRecord(
'be_users',
$id,
'*',
' AND cruser_id=' . $GLOBALS['BE_USER']->user['uid'] . ' AND createdByAction=' . intval($action['uid'])
' AND cruser_id=' . $GLOBALS['BE_USER']->user['uid'] . ' AND createdByAction=' . $action['uid']
);
if (is_array($record)) {
......
*/
protected function getCreatedUsers($action, $selectedUser) {
$content = '';
$lines = array();
$userList = array();
// List of users
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
......
$line = '<strong>' . $line . '</strong>';
}
$lines[] = $line;
$userList[] = $line;
}
$GLOBALS['TYPO3_DB']->sql_free_result($res);
// if any records found
if (count($lines)) {
$content .= '<br />' . $this->taskObject->doc->section($GLOBALS['LANG']->getLL('action_t1_listOfUsers'), implode('<br />', $lines));
if (count($userList)) {
$content .= '<br />' . $this->taskObject->doc->section($GLOBALS['LANG']->getLL('action_t1_listOfUsers'), implode('<br />', $userList));
}
return $content;
......
* @return int Id of the new/updated user
*/
protected function saveNewBackendUser($record, $vars) {
$content = '';
// check if the db mount is a page the current user is allowed to.);
$vars['db_mountpoints'] = $this->fixDbMount($vars['db_mountpoints']);
// check if the usergroup is allowed
......
}
}
/**
* Get all allowed usergroups which can be applied to a user record
*
* @param array $record sys_action record
* @param array $vars Selected be_user record
* @return string rendered user groups
*/
protected function getUsergroups($record, $vars) {
$content = '';
// do nothing if no groups are allowed
......
*/
protected function viewEditRecord($record) {
$content = '';
$lines = array();
$actionList = array();
$dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup');
$dbAnalysis->fromTC = 0;
......
$description .= ' - ' . t3lib_BEfunc::dateTimeAge($record['crdate']);
}
$lines[$el['id']] = array(
$actionList[$el['id']] = array(
'title' => $title,
'description' => t3lib_BEfunc::getRecordTitle($el['table'], $dbAnalysis->results[$el['table']][$el['id']]),
'descriptionHtml' => $description,
......
}
// render the record list
$content .= $this->taskObject->renderListMenu($lines);
$content .= $this->taskObject->renderListMenu($actionList);
return $content;
}
......
$fullsearch->formW = 40;
$fullsearch->noDownloadB = 1;
$type = $sql_query['qC']['search_query_makeQuery'];
$res = $GLOBALS['TYPO3_DB']->sql_query($sql_query['qSelect']);
......
// Admin users are allowed to see and edit the query
if ($GLOBALS['BE_USER']->isAdmin()) {
$actionContent .= '<hr /> ' . $fullsearch->tableWrap($sql_query['qSelect']);
$actionContent .= '<br /><a title="' . $GLOBALS['LANG']->getLL('action_editQuery') . '" href="'.$GLOBALS['BACK_PATH'] . t3lib_extMgm::extRelPath('lowlevel') . 'dbint/index.php?id='.
$actionContent .= '<br /><a title="' . $GLOBALS['LANG']->getLL('action_editQuery') . '" href="' . $GLOBALS['BACK_PATH'] . t3lib_extMgm::extRelPath('lowlevel') . 'dbint/index.php?id=' .
'&SET[function]=search' .
'&SET[search]=query' .
'&storeControl[STORE]=-' . $record['uid'] .
'&storeControl[LOAD]=1' .
'">
<img class="icon"' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/edit2.gif') . ' alt="" />' .
$GLOBALS['LANG']->getLL('action_editQuery') . '</a><br /><br />';
$GLOBALS['LANG']->getLL('action_editQuery') . '</a><br /><br />';
}
$content .= $this->taskObject->doc->section($GLOBALS['LANG']->getLL('action_t2_result'), $actionContent, 0, 1);
......
// query is not configured
$flashMessage = t3lib_div::makeInstance (
't3lib_FlashMessage',
$GLOBALS['LANG']->getLL('action_notReady', true),
$GLOBALS['LANG']->getLL('action_notReady', TRUE),
$GLOBALS['LANG']->getLL('action_error'),
t3lib_FlashMessage::ERROR
);
......
// required sysext lowlevel is not installed
$flashMessage = t3lib_div::makeInstance (
't3lib_FlashMessage',
$GLOBALS['LANG']->getLL('action_lowlevelMissing', true),
$GLOBALS['LANG']->getLL('action_lowlevelMissing', TRUE),
$GLOBALS['LANG']->getLL('action_error'),
t3lib_FlashMessage::ERROR
);
......
if ($this->id == 0 || $this->table == '') {
$flashMessage = t3lib_div::makeInstance(
't3lib_FlashMessage',
$GLOBALS['LANG']->getLL('action_lowlevelMissing', true),
$GLOBALS['LANG']->getLL('action_lowlevelMissing', TRUE),
$GLOBALS['LANG']->getLL('action_error'),
t3lib_FlashMessage::ERROR
);
......
require_once($GLOBALS['BACK_PATH'] . 'class.db_list.inc');
require_once($GLOBALS['BACK_PATH'] . 'class.db_list_extra.inc');
// Start document template object:
// $this->doc = t3lib_div::makeInstance('template');
// Loading current page record and checking access:
$this->pageinfo = t3lib_BEfunc::readPageAccess($this->id,$this->taskObject->perms_clause);
$access = is_array($this->pageinfo) ? 1 : 0;
// If there is access to the page, then render the list contents and set up the document template object:
if ($access) {
// Initialize the dblist object:
......
// Setting up the context sensitive menu:
$this->taskObject->doc->getContextMenuCode();
// Begin to compile the whole page
$content .= '<form action="'.htmlspecialchars($dblist->listURL()).'" method="post" name="dblistForm">' .
$dblist->HTMLcode .
......
// If a listing was produced, create the page footer with search form etc:
if ($dblist->HTMLcode) {
// Making field select box (when extended view for a single table is enabled):
if ($dblist->table) {
$tmpBackpath = $GLOBALS['BACK_PATH'];
......
// not enough rights to access the list view or the page
$flashMessage = t3lib_div::makeInstance(
't3lib_FlashMessage',
$GLOBALS['LANG']->getLL('action_error-access', true),
$GLOBALS['LANG']->getLL('action_error-access', TRUE),
$GLOBALS['LANG']->getLL('action_error'),
t3lib_FlashMessage::ERROR
);
typo3/sysext/sys_action/tca.php (Arbeitskopie)
// ******************************************************************
// sys_action
// ******************************************************************
$TCA['sys_action'] = array (
$TCA['sys_action'] = array(
'ctrl' => $TCA['sys_action']['ctrl'],
'interface' => array (
'interface' => array(
'showRecordFieldList' => 'hidden,title,type,description,assign_to_groups'
),
'columns' => array (
'title' => array (
'columns' => array(
'title' => array(
'label' => 'LLL:EXT:lang/locallang_general.php:LGL.title',
'config' => array (
'config' => array(
'type' => 'input',
'size' => '25',
'max' => '256',
'eval' => 'trim,required'
)
),
'description' => array (
'description' => array(
'label' => 'LLL:EXT:lang/locallang_general.php:LGL.description',
'config' => array (
'config' => array(
'type' => 'text',
'rows' => 10,
'cols' => 48
)
),
'hidden' => array (
'hidden' => array(
'label' => 'LLL:EXT:sys_action/locallang_tca.php:sys_action.hidden',
'config' => array (
'config' => array(
'type' => 'check'
)
),
'type' => array (
'type' => array(
'label' => 'LLL:EXT:lang/locallang_general.php:LGL.type',
'config' => array (
'config' => array(
'type' => 'select',
'items' => array (
'items' => array(
array('', '0'),
array('LLL:EXT:sys_action/locallang_tca.php:sys_action.type.1', '1'),
array('LLL:EXT:sys_action/locallang_tca.php:sys_action.type.2', '2'),
......
)
)
),
'assign_to_groups' => array (
'assign_to_groups' => array(
'label' => 'LLL:EXT:sys_action/locallang_tca.php:sys_action.assign_to_groups',
'config' => array (
'config' => array(
'type' => 'select',
'foreign_table' => 'be_groups',
'foreign_table_where' => 'ORDER BY be_groups.title',
......
'autoSizeMax' => '10'
)
),
't1_userprefix' => array (
't1_userprefix' => array(
'label' => 'LLL:EXT:sys_action/locallang_tca.php:sys_action.t1_userprefix',
'config' => array (
'config' => array(
'type' => 'input',
'size' => '25',
'max' => '10',
'eval' => 'trim'
)
),
't1_allowed_groups' => array (
't1_allowed_groups' => array(
'label' => 'LLL:EXT:sys_action/locallang_tca.php:sys_action.t1_allowed_groups',
'config' => array (
'config' => array(
'type' => 'select',
'foreign_table' => 'be_groups',
'foreign_table_where' => 'ORDER BY be_groups.title',
......
'autoSizeMax' => '10'
)
),
't1_create_user_dir' => array (
't1_create_user_dir' => array(
'label' => 'LLL:EXT:sys_action/locallang_tca.php:sys_action.t1_create_user_dir',
'config' => array (
'config' => array(
'type' => 'check'
)
),
't1_copy_of_user' => array (
't1_copy_of_user' => array(
'label' => 'LLL:EXT:sys_action/locallang_tca.php:sys_action.t1_copy_of_user',
'config' => array (
'config' => array(
'type' => 'group',
'internal_type' => 'db',
'allowed' => 'be_users',
......
)
)
),
't3_listPid' => array (
't3_listPid' => array(
'label' => 'LLL:EXT:sys_action/locallang_tca.php:sys_action.t3_listPid',
'config' => array (
'config' => array(
'type' => 'group',
'internal_type' => 'db',
'allowed' => 'pages',
......
)
)
),
't3_tables' => array (
't3_tables' => array(
'label' => 'LLL:EXT:sys_action/locallang_tca.php:sys_action.t3_tables',
'config' => array (
'config' => array(
'type' => 'select',
'special' => 'tables',
'items' => array (
'items' => array(
array('','')
)
)
),
't4_recordsToEdit' => array (
't4_recordsToEdit' => array(
'label' => 'LLL:EXT:sys_action/locallang_tca.php:sys_action.t4_recordsToEdit',
'config' => array (
'config' => array(
'type' => 'group',
'internal_type' => 'db',
'allowed' => '*',
......
),
),
'types' => array (
'0' => array('showitem' => 'hidden;;;;1-1-1,type,title;;;;2-2-2'),
'types' => array(
'0' => array('showitem' => 'hidden;;;;1-1-1,type,title;;;;2-2-2,description;;;;3-3-3,assign_to_groups,'),
'1' => array('showitem' => 'hidden;;;;1-1-1,type,title;;;;2-2-2,description;;;;3-3-3,assign_to_groups,--div--,t1_userprefix;;;;5-5-5,t1_copy_of_user,t1_allowed_groups,t1_create_user_dir'),
'2' => array('showitem' => 'hidden;;;;1-1-1,type,title;;;;2-2-2,description;;;;3-3-3,assign_to_groups,--div--,'),
'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;'),
typo3/sysext/sys_action/TODO.txt (Arbeitskopie)
- BUG?: Save queries when you select "Edit query" for an action
typo3/sysext/sys_action/toolbarmenu/tx_sysactions.css (Arbeitskopie)
#tx-sys-action-menu ul {
position: absolute;
list-style: none;
padding: 2px 0px 0px;
margin: 0px;
padding: 2px 0 0;
margin: 0;
background-color: #f9f9f9;
border: 1px solid #abb2bc;
border-top: none;
typo3/sysext/sys_action/toolbarmenu/tx_sysactions.js (Arbeitskopie)
/***************************************************************
* Copyright notice
*
* (c) 2008-2010 Steffen Kamper <info@sk-typo3.de>
* (c) 2008-2009 Steffen Kamper <info@sk-typo3.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
......
initialize: function() {
Event.observe(window, 'resize', this.positionMenu);
Ext.onReady(function() {
Event.observe(window, 'load', function(){
this.positionMenu();
this.toolbarItemIcon = $$('#tx-sys-action-menu .toolbar-item img')[0].src;
Event.observe('tx-sys-action-menu', 'click', this.toggleMenu);
}, this);
}.bindAsEventListener(this));
},
/**
......
positionMenu: function() {
var calculatedOffset = 0;
var parentWidth = $('tx-sys-action-menu').getWidth();
var currentToolbarItemLayer = $$('#tx-sys-action-menu ul')[0];
var ownWidth = currentToolbarItemLayer.getWidth();
var ownWidth = $$('#tx-sys-action-menu ul')[0].getWidth();
var parentSiblings = $('tx-sys-action-menu').previousSiblings();
parentSiblings.each(function(toolbarItem) {
......
});
calculatedOffset = calculatedOffset - ownWidth + parentWidth;
// border correction
if (currentToolbarItemLayer.getStyle('display') !== 'none') {
calculatedOffset += 2;
}
$$('#tx-sys-action-menu ul')[0].setStyle({
left: calculatedOffset + 'px'
......
});
var TYPO3BackendSysactionMenu = new SysActionMenu();
(3-3/4)