00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 class t3lib_matchCondition_backend extends t3lib_matchCondition_abstract {
00039
00040
00041
00042
00043
00044 public function __construct() {
00045 }
00046
00047
00048
00049
00050
00051
00052
00053
00054 protected function evaluateCondition($string) {
00055 list($key, $value) = t3lib_div::trimExplode('=', $string, false, 2);
00056
00057 $result = parent::evaluateConditionCommon($key, $value);
00058
00059 if (is_bool($result)) {
00060 return $result;
00061 } else {
00062 switch ($key) {
00063 case 'usergroup':
00064 $groupList = $this->getGroupList();
00065 $values = t3lib_div::trimExplode(',', $value, true);
00066 foreach ($values as $test) {
00067 if ($test == '*' || t3lib_div::inList($groupList, $test)) {
00068 return true;
00069 }
00070 }
00071 break;
00072 case 'adminUser':
00073 if ($this->isUserLoggedIn()) {
00074 $result = !((bool)$value XOR $this->isAdminUser());
00075 return $result;
00076 }
00077 break;
00078 case 'treeLevel':
00079 $values = t3lib_div::trimExplode(',', $value, true);
00080 $treeLevel = count($this->rootline) - 1;
00081
00082 if ($this->isNewPageWithPageId($this->pageId)) {
00083 $treeLevel++;
00084 }
00085 foreach ($values as $test) {
00086 if ($test == $treeLevel) {
00087 return true;
00088 }
00089 }
00090 break;
00091 case 'PIDupinRootline':
00092 case 'PIDinRootline':
00093 $values = t3lib_div::trimExplode(',', $value, true);
00094 if (($key=='PIDinRootline') || (!in_array($this->pageId, $values)) || $this->isNewPageWithPageId($this->pageId)) {
00095 foreach ($values as $test) {
00096 foreach ($this->rootline as $rl_dat) {
00097 if ($rl_dat['uid'] == $test) {
00098 return true;
00099 }
00100 }
00101 }
00102 }
00103 break;
00104 }
00105 }
00106
00107 return false;
00108 }
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118 protected function getVariable($var) {
00119 $vars = explode(':', $var, 2);
00120
00121 $val = parent::getVariableCommon($vars);
00122
00123 return $val;
00124 }
00125
00126
00127
00128
00129
00130
00131 protected function getGroupList() {
00132 $groupList = $GLOBALS['BE_USER']->groupList;
00133 return $groupList;
00134 }
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144 protected function determinePageId() {
00145 $pageId = 0;
00146 $editStatement = t3lib_div::_GP('edit');
00147 $commandStatement = t3lib_div::_GP('cmd');
00148
00149
00150 if ($id = intval(t3lib_div::_GP('id'))) {
00151 $pageId = $id;
00152
00153 } elseif (is_array($editStatement)) {
00154 list($table, $uidAndAction) = each($editStatement);
00155 list($uid, $action) = each($uidAndAction);
00156
00157 if ($action === 'edit') {
00158 $pageId = $this->getPageIdByRecord($table, $uid);
00159 } elseif ($action === 'new') {
00160 $pageId = $this->getPageIdByRecord($table, $uid, true);
00161 }
00162
00163 } elseif (is_array($commandStatement)) {
00164 list($table, $uidActionAndTarget) = each($commandStatement);
00165 list($uid, $actionAndTarget) = each($uidActionAndTarget);
00166 list($action, $target) = each($actionAndTarget);
00167
00168 if ($action === 'delete') {
00169 $pageId = $this->getPageIdByRecord($table, $uid);
00170 } elseif (($action === 'copy') || ($action === 'move')) {
00171 $pageId = $this->getPageIdByRecord($table, $target, true);
00172 }
00173 }
00174
00175 return $pageId;
00176 }
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187 protected function getPageIdByRecord($table, $id, $ignoreTable = false) {
00188 $pageId = 0;
00189 $id = (int)$id;
00190
00191 if ($table && $id) {
00192 if (($ignoreTable || $table === 'pages') && $id >= 0) {
00193 $pageId = $id;
00194 } else {
00195 $record = t3lib_BEfunc::getRecordWSOL($table, abs($id), '*', '', false);
00196 $pageId = $record['pid'];
00197 }
00198 }
00199
00200 return $pageId;
00201 }
00202
00203
00204
00205
00206
00207
00208
00209
00210 protected function isNewPageWithPageId($pageId) {
00211 if (isset($GLOBALS['SOBE']) && $GLOBALS['SOBE'] instanceof SC_alt_doc) {
00212 $pageId = intval($pageId);
00213 $elementsData = $GLOBALS['SOBE']->elementsData;
00214 $data = $GLOBALS['SOBE']->data;
00215
00216
00217 if (is_array($data) && isset($data['pages']) && is_array($data['pages'])) {
00218 foreach ($data['pages'] as $uid => $fields) {
00219 if (strpos($uid, 'NEW') === 0 && $fields['pid'] == $pageId) {
00220 return true;
00221 }
00222 }
00223 }
00224
00225 if (is_array($elementsData)) {
00226 foreach ($elementsData as $element) {
00227 if ($element['cmd'] == 'new' && $element['table'] == 'pages') {
00228 if ($element['pid'] < 0) {
00229 $pageRecord = t3lib_BEfunc::getRecord('pages', abs($element['pid']), 'pid');
00230 $element['pid'] = $pageRecord['pid'];
00231 }
00232 if ($element['pid'] == $pageId) {
00233 return true;
00234 }
00235 }
00236 }
00237 }
00238 }
00239
00240 return false;
00241 }
00242
00243
00244
00245
00246
00247
00248 protected function determineRootline() {
00249 $pageId = (isset($this->pageId) ? $this->pageId : $this->determinePageId());
00250 $rootline = t3lib_BEfunc::BEgetRootLine($pageId, '', true);
00251 return $rootline;
00252 }
00253
00254
00255
00256
00257
00258
00259 protected function getUserFuncClassPrefix() {
00260 $userFuncClassPrefix = 'user_';
00261 return $userFuncClassPrefix;
00262 }
00263
00264
00265
00266
00267
00268
00269 protected function getUserId() {
00270 $userId = $GLOBALS['BE_USER']->user['uid'];
00271 return $userId;
00272 }
00273
00274
00275
00276
00277
00278
00279 protected function isUserLoggedIn() {
00280 $userLoggedIn = false;
00281 if ($GLOBALS['BE_USER']->user['uid']) {
00282 $userLoggedIn = true;
00283 }
00284 return $userLoggedIn;
00285 }
00286
00287
00288
00289
00290
00291
00292 protected function isAdminUser() {
00293 $isAdminUser = false;
00294 if ($GLOBALS['BE_USER']->user['admin']) {
00295 $isAdminUser = true;
00296 }
00297 return $isAdminUser;
00298 }
00299
00300
00301
00302
00303
00304
00305
00306 protected function log($message) {
00307 if (is_object($GLOBALS['BE_USER'])) {
00308 $GLOBALS['BE_USER']->writelog(3, 0, 1, 0, $message, array());
00309 }
00310 }
00311 }
00312
00313
00314 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/matchcondition/class.t3lib_matchcondition_backend.php']) {
00315 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/matchcondition/class.t3lib_matchcondition_backend.php']);
00316 }
00317
00318 ?>