/**
  * Populates the "object_id" field of a "tx_beacl_acl" record depending on
  * whether the field "type" is set to "User" or "Group"
  *
  * @param		array		field configuration
  * @param		object
  * @return	void
  */
 function select($PA, $fobj)
 {
     global $BE_USER;
     if (!array_key_exists('row', $PA)) {
         return;
     }
     if (!array_key_exists('type', $PA['row'])) {
         return;
     }
     // Resetting the SELECT field items
     $PA['items'] = array(0 => array(0 => '', 1 => ''));
     // Get users or groups - The function copies functionality of the method acl_objectSelector()
     // of ux_SC_mod_web_perm_index class as for non-admins it returns only:
     // 1) Users which are members of the groups of the current user.
     // 2) Groups that the current user is a member of.
     switch ($PA['row']['type']) {
         // In case users shall be returned
         case '0':
             $items = t3lib_BEfunc::getUserNames();
             if (!$GLOBALS['BE_USER']->isAdmin()) {
                 $items = t3lib_BEfunc::blindUserNames($items, $BE_USER->userGroupsUID, 1);
             }
             foreach ($items as $row) {
                 $PA['items'][] = array(0 => $row['username'], 1 => $row['uid']);
             }
             break;
             // In case groups shall be returned
         // In case groups shall be returned
         case '1':
             $items = t3lib_BEfunc::getGroupNames();
             if (!$GLOBALS['BE_USER']->isAdmin()) {
                 $items = t3lib_BEfunc::blindGroupNames($items, $BE_USER->userGroupsUID, 1);
             }
             foreach ($items as $row) {
                 $PA['items'][] = array(0 => $row['title'], 1 => $row['uid']);
             }
             break;
         default:
             return;
     }
     return;
 }
 /**
  * outputs a selector for users / groups, returns current ACLs
  *
  * @param	integer		type of ACL. 0 -> user, 1 -> group
  * @param	string		Pointer where the display code is stored
  * @param	array		configuration of ACLs
  * @return	array		list of groups/users where the ACLs will be shown
  */
 function acl_objectSelector($type, &$displayPointer, $conf)
 {
     global $BE_USER;
     $aclObjects = array();
     $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tx_beacl_acl.object_id AS object_id, tx_beacl_acl.type AS type', 'tx_beacl_acl, be_groups, be_users', 'tx_beacl_acl.type=' . intval($type) . ' AND ((tx_beacl_acl.object_id=be_groups.uid AND tx_beacl_acl.type=1) OR (tx_beacl_acl.object_id=be_users.uid AND tx_beacl_acl.type=0))', '', 'be_groups.title ASC, be_users.realname ASC');
     while ($result = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
         $aclObjects[] = $result['object_id'];
     }
     $aclObjects = array_unique($aclObjects);
     // advanced selector disabled
     if (!$conf['enableFilterSelector']) {
         return $aclObjects;
     }
     if (!empty($aclObjects)) {
         // Get usernames and groupnames: The arrays we get in return contains only 1) users which are members of the groups of the current user, 2) groups that the current user is member of
         $groupArray = $BE_USER->userGroupsUID;
         $be_user_Array = t3lib_BEfunc::getUserNames();
         if (!$GLOBALS['BE_USER']->isAdmin()) {
             $be_user_Array = t3lib_BEfunc::blindUserNames($be_user_Array, $groupArray, 0);
         }
         $be_group_Array = t3lib_BEfunc::getGroupNames();
         if (!$GLOBALS['BE_USER']->isAdmin()) {
             $be_group_Array = t3lib_BEfunc::blindGroupNames($be_group_Array, $groupArray, 0);
         }
         // get current selection from UC, merge data, write it back to UC
         $currentSelection = is_array($BE_USER->uc['moduleData']['txbeacl_aclSelector'][$type]) ? $BE_USER->uc['moduleData']['txbeacl_aclSelector'][$type] : array();
         $currentSelectionOverride_raw = t3lib_div::_GP('tx_beacl_objsel');
         $currentSelectionOverride = array();
         if (is_array($currentSelectionOverride_raw[$type])) {
             foreach ($currentSelectionOverride_raw[$type] as $tmp) {
                 $currentSelectionOverride[$tmp] = $tmp;
             }
         }
         if ($currentSelectionOverride) {
             $currentSelection = $currentSelectionOverride;
         }
         $BE_USER->uc['moduleData']['txbeacl_aclSelector'][$type] = $currentSelection;
         $BE_USER->writeUC($BE_USER->uc);
         // display selector
         $displayCode = '<select size="' . t3lib_div::intInRange(count($aclObjects), 5, 15) . '" name="tx_beacl_objsel[' . $type . '][]" multiple="multiple">';
         foreach ($aclObjects as $singleObjectId) {
             if ($type == 0) {
                 $tmpnam = $be_user_Array[$singleObjectId]['username'];
             } else {
                 $tmpnam = $be_group_Array[$singleObjectId]['title'];
             }
             $displayCode .= '<option value="' . $singleObjectId . '" ' . (@in_array($singleObjectId, $currentSelection) ? 'selected' : '') . '>' . $tmpnam . '</option>';
         }
         $displayCode .= '</select>';
         $displayCode .= '<br /><input type="button" value="' . $GLOBALS['LANG']->getLL('aclObjSelUpdate') . '" onClick="document.editform.action=document.location; document.editform.submit()" /><p />';
         // create section
         switch ($type) {
             case 0:
                 $tmpnam = 'aclUsers';
                 break;
             default:
                 $tmpnam = 'aclGroups';
                 break;
         }
         $displayPointer = $this->doc->section($GLOBALS['LANG']->getLL($tmpnam, 1), $displayCode);
         return $currentSelection;
     }
     return NULL;
 }
Example #3
0
 /**
  * Will make the simulate-user selector if the logged in user is administrator.
  * It will also set the GLOBAL(!) BE_USER to the simulated user selected if any (and set $this->OLD_BE_USER to logged in user)
  *
  * @return	void
  */
 public function simulateUser()
 {
     global $BE_USER, $LANG, $BACK_PATH;
     // *******************************************************************************
     // If admin, allow simulation of another user
     // *******************************************************************************
     $this->simUser = 0;
     $this->simulateSelector = '';
     unset($this->OLD_BE_USER);
     if ($BE_USER->isAdmin()) {
         $this->simUser = intval(t3lib_div::_GP('simUser'));
         // Make user-selector:
         $users = t3lib_BEfunc::getUserNames('username,usergroup,usergroup_cached_list,uid,realName', t3lib_BEfunc::BEenableFields('be_users'));
         $opt = array();
         foreach ($users as $rr) {
             if ($rr['uid'] != $BE_USER->user['uid']) {
                 $opt[] = '<option value="' . $rr['uid'] . '"' . ($this->simUser == $rr['uid'] ? ' selected="selected"' : '') . '>' . htmlspecialchars($rr['username'] . ' (' . $rr['realName'] . ')') . '</option>';
             }
         }
         if (count($opt)) {
             $this->simulateSelector = '<select id="field_simulate" name="simulateUser" onchange="window.location.href=\'index.php?simUser=\'+this.options[this.selectedIndex].value;"><option></option>' . implode('', $opt) . '</select>';
         }
     }
     if ($this->simUser > 0) {
         // This can only be set if the previous code was executed.
         $this->OLD_BE_USER = $BE_USER;
         // Save old user...
         unset($BE_USER);
         // Unset current
         $BE_USER = t3lib_div::makeInstance('t3lib_beUserAuth');
         // New backend user object
         $BE_USER->OS = TYPO3_OS;
         $BE_USER->setBeUserByUid($this->simUser);
         $BE_USER->fetchGroupData();
         $BE_USER->backendSetUC();
         $GLOBALS['BE_USER'] = $BE_USER;
         // Must do this, because unsetting $BE_USER before apparently unsets the reference to the global variable by this name!
     }
 }
    /**
     * Main Task center module
     *
     * @return	string		HTML content.
     */
    public function main()
    {
        $content = '';
        $id = intval(t3lib_div::_GP('display'));
        // if a preset is found, it is rendered using an iframe
        if ($id > 0) {
            $url = $GLOBALS['BACK_PATH'] . t3lib_extMgm::extRelPath('impexp') . 'app/index.php?tx_impexp[action]=export&preset[load]=1&preset[select]=' . $id;
            return $this->taskObject->urlInIframe($url, 1);
        } else {
            // header
            $content .= $this->taskObject->description($GLOBALS['LANG']->getLL('.alttitle'), $GLOBALS['LANG']->getLL('.description'));
            $thumbnails = $lines = array();
            // Thumbnail folder and files:
            $tempDir = $this->userTempFolder();
            if ($tempDir) {
                $thumbnails = t3lib_div::getFilesInDir($tempDir, 'png,gif,jpg', 1);
            }
            $clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
            $usernames = t3lib_BEfunc::getUserNames();
            // Create preset links:
            $presets = $this->getPresets();
            // if any presets found
            if (is_array($presets)) {
                foreach ($presets as $key => $presetCfg) {
                    $configuration = unserialize($presetCfg['preset_data']);
                    $thumbnailFile = $thumbnails[$configuration['meta']['thumbnail']];
                    $title = strlen($presetCfg['title']) ? $presetCfg['title'] : '[' . $presetCfg['uid'] . ']';
                    $icon = 'EXT:impexp/export.gif';
                    $description = array();
                    // is public?
                    if ($presetCfg['public']) {
                        $description[] = $GLOBALS['LANG']->getLL('task.public') . ': ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:yes');
                    }
                    // owner
                    $description[] = $GLOBALS['LANG']->getLL('task.owner') . ': ' . ($presetCfg['user_uid'] === $GLOBALS['BE_USER']->user['uid'] ? $GLOBALS['LANG']->getLL('task.own') : '[' . htmlspecialchars($usernames[$presetCfg['user_uid']]['username']) . ']');
                    // page & path
                    if ($configuration['pagetree']['id']) {
                        $description[] = $GLOBALS['LANG']->getLL('task.page') . ': ' . $configuration['pagetree']['id'];
                        $description[] = $GLOBALS['LANG']->getLL('task.path') . ': ' . htmlspecialchars(t3lib_BEfunc::getRecordPath($configuration['pagetree']['id'], $clause, 20));
                    } else {
                        $description[] = $GLOBALS['LANG']->getLL('single-record');
                    }
                    // Meta information
                    if ($configuration['meta']['title'] || $configuration['meta']['description'] || $configuration['meta']['notes']) {
                        $metaInformation = '';
                        if ($configuration['meta']['title']) {
                            $metaInformation .= '<strong>' . htmlspecialchars($configuration['meta']['title']) . '</strong><br />';
                        }
                        if ($configuration['meta']['description']) {
                            $metaInformation .= htmlspecialchars($configuration['meta']['description']);
                        }
                        if ($configuration['meta']['notes']) {
                            $metaInformation .= '<br /><br />
												<strong>' . $GLOBALS['LANG']->getLL('notes') . ': </strong>
												<em>' . htmlspecialchars($configuration['meta']['notes']) . '</em>';
                        }
                        $description[] = '<br />' . $metaInformation;
                    }
                    // collect all preset information
                    $lines[$key] = array('icon' => $icon, 'title' => $title, 'descriptionHtml' => implode('<br />', $description), 'link' => 'mod.php?M=user_task&SET[function]=impexp.tx_impexp_task&display=' . $presetCfg['uid']);
                }
                // render preset list
                $content .= $this->taskObject->renderListMenu($lines);
            } else {
                // no presets found
                $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $GLOBALS['LANG']->getLL('no-presets'), '', t3lib_FlashMessage::NOTICE);
                $content .= $flashMessage->render();
            }
        }
        return $content;
    }
Example #5
0
    /**
     * Showing the permissions in a tree ($this->edit = false)
     * (Adding content to internal content variable)
     *
     * @return	void
     */
    public function notEdit()
    {
        global $BE_USER, $LANG, $BACK_PATH;
        // Get usernames and groupnames: The arrays we get in return contains only 1) users which are members of the groups of the current user, 2) groups that the current user is member of
        $beGroupKeys = $BE_USER->userGroupsUID;
        $beUserArray = t3lib_BEfunc::getUserNames();
        if (!$GLOBALS['BE_USER']->isAdmin()) {
            $beUserArray = t3lib_BEfunc::blindUserNames($beUserArray, $beGroupKeys, 0);
        }
        $beGroupArray = t3lib_BEfunc::getGroupNames();
        if (!$GLOBALS['BE_USER']->isAdmin()) {
            $beGroupArray = t3lib_BEfunc::blindGroupNames($beGroupArray, $beGroupKeys, 0);
        }
        // Length of strings:
        $tLen = $this->MOD_SETTINGS['mode'] == 'perms' ? 20 : 30;
        // Selector for depth:
        $code .= $LANG->getLL('Depth') . ': ';
        $code .= t3lib_BEfunc::getFuncMenu($this->id, 'SET[depth]', $this->MOD_SETTINGS['depth'], $this->MOD_MENU['depth']);
        $this->content .= $this->doc->section('', $code);
        $this->content .= $this->doc->spacer(5);
        // Initialize tree object:
        $tree = t3lib_div::makeInstance('t3lib_pageTree');
        $tree->init('AND ' . $this->perms_clause);
        $tree->addField('perms_user', 1);
        $tree->addField('perms_group', 1);
        $tree->addField('perms_everybody', 1);
        $tree->addField('perms_userid', 1);
        $tree->addField('perms_groupid', 1);
        $tree->addField('hidden');
        $tree->addField('fe_group');
        $tree->addField('starttime');
        $tree->addField('endtime');
        $tree->addField('editlock');
        // Creating top icon; the current page
        $HTML = t3lib_iconWorks::getSpriteIconForRecord('pages', $this->pageinfo);
        $tree->tree[] = array('row' => $this->pageinfo, 'HTML' => $HTML);
        // Create the tree from $this->id:
        $tree->getTree($this->id, $this->MOD_SETTINGS['depth'], '');
        // Make header of table:
        $code = '';
        if ($this->MOD_SETTINGS['mode'] == 'perms') {
            $code .= '
				<tr class="t3-row-header">
					<td colspan="2">&nbsp;</td>
					<td><img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/line.gif', 'width="5" height="16"') . ' alt="" /></td>
					<td>' . $LANG->getLL('Owner', TRUE) . '</td>
					<td><img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/line.gif', 'width="5" height="16"') . ' alt="" /></td>
					<td align="center">' . $LANG->getLL('Group', TRUE) . '</td>
					<td><img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/line.gif', 'width="5" height="16"') . ' alt="" /></td>
					<td align="center">' . $LANG->getLL('Everybody', TRUE) . '</td>
					<td><img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/line.gif', 'width="5" height="16"') . ' alt="" /></td>
					<td align="center">' . $LANG->getLL('EditLock', TRUE) . '</td>
				</tr>
			';
        } else {
            $code .= '
				<tr class="t3-row-header">
					<td colspan="2">&nbsp;</td>
					<td><img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/line.gif', 'width="5" height="16"') . ' alt="" /></td>
					<td align="center" nowrap="nowrap">' . $LANG->getLL('User', TRUE) . ': ' . htmlspecialchars($BE_USER->user['username']) . '</td>
					' . (!$BE_USER->isAdmin() ? '<td><img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/line.gif', 'width="5" height="16"') . ' alt="" /></td>
					<td align="center">' . $LANG->getLL('EditLock', TRUE) . '</td>' : '') . '
				</tr>';
        }
        // Traverse tree:
        foreach ($tree->tree as $data) {
            $cells = array();
            $pageId = $data['row']['uid'];
            // Background colors:
            $bgCol = $this->lastEdited == $pageId ? ' class="bgColor-20"' : '';
            $lE_bgCol = $bgCol;
            // User/Group names:
            $userName = $beUserArray[$data['row']['perms_userid']] ? $beUserArray[$data['row']['perms_userid']]['username'] : ($data['row']['perms_userid'] ? $data['row']['perms_userid'] : '');
            if ($data['row']['perms_userid'] && !$beUserArray[$data['row']['perms_userid']]) {
                $userName = SC_mod_web_perm_ajax::renderOwnername($pageId, $data['row']['perms_userid'], htmlspecialchars(t3lib_div::fixed_lgd_cs($userName, 20)), false);
            } else {
                $userName = SC_mod_web_perm_ajax::renderOwnername($pageId, $data['row']['perms_userid'], htmlspecialchars(t3lib_div::fixed_lgd_cs($userName, 20)));
            }
            $groupName = $beGroupArray[$data['row']['perms_groupid']] ? $beGroupArray[$data['row']['perms_groupid']]['title'] : ($data['row']['perms_groupid'] ? $data['row']['perms_groupid'] : '');
            if ($data['row']['perms_groupid'] && !$beGroupArray[$data['row']['perms_groupid']]) {
                $groupName = SC_mod_web_perm_ajax::renderGroupname($pageId, $data['row']['perms_groupid'], htmlspecialchars(t3lib_div::fixed_lgd_cs($groupName, 20)), false);
            } else {
                $groupName = SC_mod_web_perm_ajax::renderGroupname($pageId, $data['row']['perms_groupid'], htmlspecialchars(t3lib_div::fixed_lgd_cs($groupName, 20)));
            }
            // Seeing if editing of permissions are allowed for that page:
            $editPermsAllowed = $data['row']['perms_userid'] == $BE_USER->user['uid'] || $BE_USER->isAdmin();
            // First column:
            $cellAttrib = $data['row']['_CSSCLASS'] ? ' class="' . $data['row']['_CSSCLASS'] . '"' : '';
            $cells[] = '
					<td align="left" nowrap="nowrap"' . ($cellAttrib ? $cellAttrib : $bgCol) . '>' . $data['HTML'] . htmlspecialchars(t3lib_div::fixed_lgd_cs($data['row']['title'], $tLen)) . '&nbsp;</td>';
            // "Edit permissions" -icon
            if ($editPermsAllowed && $pageId) {
                $aHref = 'index.php?mode=' . $this->MOD_SETTINGS['mode'] . '&depth=' . $this->MOD_SETTINGS['depth'] . '&id=' . ($data['row']['_ORIG_uid'] ? $data['row']['_ORIG_uid'] : $pageId) . '&return_id=' . $this->id . '&edit=1';
                $cells[] = '
					<td' . $bgCol . '><a href="' . htmlspecialchars($aHref) . '" title="' . $LANG->getLL('ch_permissions', 1) . '">' . t3lib_iconWorks::getSpriteIcon('actions-document-open') . '</a></td>';
            } else {
                $cells[] = '
					<td' . $bgCol . '></td>';
            }
            // Rest of columns (depending on mode)
            if ($this->MOD_SETTINGS['mode'] == 'perms') {
                $cells[] = '
					<td' . $bgCol . ' class="center"><img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/line.gif', 'width="5" height="16"') . ' alt="" /></td>
					<td' . $bgCol . ' nowrap="nowrap">' . ($pageId ? SC_mod_web_perm_ajax::renderPermissions($data['row']['perms_user'], $pageId, 'user') . ' ' . $userName : '') . '</td>

					<td' . $bgCol . ' class="center"><img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/line.gif', 'width="5" height="16"') . ' alt="" /></td>
					<td' . $bgCol . ' nowrap="nowrap">' . ($pageId ? SC_mod_web_perm_ajax::renderPermissions($data['row']['perms_group'], $pageId, 'group') . ' ' . $groupName : '') . '</td>

					<td' . $bgCol . ' class="center"><img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/line.gif', 'width="5" height="16"') . ' alt="" /></td>
					<td' . $bgCol . ' nowrap="nowrap">' . ($pageId ? ' ' . SC_mod_web_perm_ajax::renderPermissions($data['row']['perms_everybody'], $pageId, 'everybody') : '') . '</td>

					<td' . $bgCol . ' class="center"><img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/line.gif', 'width="5" height="16"') . ' alt="" /></td>
					<td' . $bgCol . ' nowrap="nowrap">' . ($data['row']['editlock'] ? '<span id="el_' . $pageId . '" class="editlock"><a class="editlock" onclick="WebPermissions.toggleEditLock(\'' . $pageId . '\', \'1\');" title="' . $LANG->getLL('EditLock_descr', 1) . '">' . t3lib_iconWorks::getSpriteIcon('status-warning-lock') . '</a></span>' : ($pageId === 0 ? '' : '<span id="el_' . $pageId . '" class="editlock"><a class="editlock" onclick="WebPermissions.toggleEditLock(\'' . $pageId . '\', \'0\');" title="Enable the &raquo;Admin-only&laquo; edit lock for this page">[+]</a></span>')) . '</td>
				';
            } else {
                $cells[] = '
					<td' . $bgCol . ' class="center"><img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/line.gif', 'width="5" height="16"') . ' alt="" /></td>';
                $bgCol = $BE_USER->user['uid'] == $data['row']['perms_userid'] ? ' class="bgColor-20"' : $lE_bgCol;
                // FIXME $owner undefined
                $cells[] = '
					<td' . $bgCol . ' nowrap="nowrap" align="center">' . ($pageId ? $owner . SC_mod_web_perm_ajax::renderPermissions($BE_USER->calcPerms($data['row']), $pageId, 'user') : '') . '</td>
					' . (!$BE_USER->isAdmin() ? '
					<td' . $bgCol . ' class="center"><img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/line.gif', 'width="5" height="16"') . ' alt="" /></td>
					<td' . $bgCol . ' nowrap="nowrap">' . ($data['row']['editlock'] ? t3lib_iconWorks::getSpriteIcon('status-warning-lock', array('title' => $LANG->getLL('EditLock_descr', TRUE))) : '') . '</td>
					' : '');
                $bgCol = $lE_bgCol;
            }
            // Compile table row:
            $code .= '
				<tr>
					' . implode('
					', $cells) . '
				</tr>';
        }
        // Wrap rows in table tags:
        $code = '<table border="0" cellspacing="0" cellpadding="0" id="typo3-permissionList">' . $code . '</table>';
        // Adding the content as a section:
        $this->content .= $this->doc->section('', $code);
        // CSH for permissions setting
        $this->content .= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'perm_module', $GLOBALS['BACK_PATH'], '<br />|');
        // Creating legend table:
        $legendText = '<strong>' . $LANG->getLL('1', 1) . '</strong>: ' . $LANG->getLL('1_t', 1);
        $legendText .= '<br /><strong>' . $LANG->getLL('16', 1) . '</strong>: ' . $LANG->getLL('16_t', 1);
        $legendText .= '<br /><strong>' . $LANG->getLL('2', 1) . '</strong>: ' . $LANG->getLL('2_t', 1);
        $legendText .= '<br /><strong>' . $LANG->getLL('4', 1) . '</strong>: ' . $LANG->getLL('4_t', 1);
        $legendText .= '<br /><strong>' . $LANG->getLL('8', 1) . '</strong>: ' . $LANG->getLL('8_t', 1);
        $code = '<table border="0" id="typo3-legendTable">
			<tr>
				<td valign="top">
					<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/legend.gif', 'width="86" height="75"') . ' alt="" />
				</td>
				<td valign="top" nowrap="nowrap">' . $legendText . '</td>
			</tr>
		</table>';
        $code .= '<div id="perm-legend">' . $LANG->getLL('def', 1);
        $code .= '<br /><br />' . t3lib_iconWorks::getSpriteIcon('status-status-permission-granted') . ': ' . $LANG->getLL('A_Granted', 1);
        $code .= '<br />' . t3lib_iconWorks::getSpriteIcon('status-status-permission-denied') . ': ' . $LANG->getLL('A_Denied', 1);
        $code .= '</div>';
        // Adding section with legend code:
        $this->content .= $this->doc->spacer(20);
        $this->content .= $this->doc->section($LANG->getLL('Legend') . ':', $code, 0, 1);
    }
Example #6
0
    /**
     * Rendering the overview of versions in the current workspace
     *
     * @return	string		HTML (table)
     * @see typo3/mod/user/ws/index.php for sister function!
     */
    function displayWorkspaceOverview()
    {
        // Initialize variables:
        $this->showWorkspaceCol = $GLOBALS['BE_USER']->workspace === 0 && $this->MOD_SETTINGS['display'] <= -98;
        // Get usernames and groupnames
        $be_group_Array = t3lib_BEfunc::getListGroupNames('title,uid');
        $groupArray = array_keys($be_group_Array);
        $this->be_user_Array = t3lib_BEfunc::getUserNames();
        if (!$GLOBALS['BE_USER']->isAdmin()) {
            $this->be_user_Array = t3lib_BEfunc::blindUserNames($this->be_user_Array, $groupArray, 1);
        }
        // Initialize Workspace ID and filter-value:
        if ($GLOBALS['BE_USER']->workspace === 0) {
            $wsid = $this->details ? -99 : $this->MOD_SETTINGS['display'];
            // Set wsid to the value from the menu (displaying content of other workspaces)
            $filter = $this->details ? 0 : $this->MOD_SETTINGS['filter'];
        } else {
            $wsid = $GLOBALS['BE_USER']->workspace;
            $filter = 0;
        }
        // Initialize workspace object and request all pending versions:
        $wslibObj = t3lib_div::makeInstance('wslib');
        // Selecting ALL versions belonging to the workspace:
        $versions = $wslibObj->selectVersionsInWorkspace($wsid, $filter, -99, $this->uid);
        // $this->uid is the page id of LIVE record.
        // Traverse versions and build page-display array:
        $pArray = array();
        foreach ($versions as $table => $records) {
            foreach ($records as $rec) {
                $pageIdField = $table === 'pages' ? 't3ver_oid' : 'realpid';
                $this->displayWorkspaceOverview_setInPageArray($pArray, $table, $rec);
            }
        }
        // Make header of overview:
        $tableRows = array();
        if (count($pArray)) {
            $tableRows[] = '
				<tr class="bgColor5 tableheader">
					' . ($this->diffOnly ? '' : '<td nowrap="nowrap" colspan="2">' . $GLOBALS['LANG']->getLL('liveVersion') . '</td>') . '
					<td nowrap="nowrap" colspan="2">' . $GLOBALS['LANG']->getLL('wsVersions') . '</td>
					<td nowrap="nowrap"' . ($this->diffOnly ? ' colspan="2"' : ' colspan="4"') . '>' . $GLOBALS['LANG']->getLL('controls') . '</td>
				</tr>';
            // Add lines from overview:
            $tableRows = array_merge($tableRows, $this->displayWorkspaceOverview_list($pArray));
            $table = '<table border="0" cellpadding="0" cellspacing="1" class="lrPadding workspace-overview">' . implode('', $tableRows) . '</table>';
        } else {
            $table = '';
        }
        $linkBack = t3lib_div::_GP('returnUrl') ? '<a href="' . htmlspecialchars(t3lib_div::_GP('returnUrl')) . '" class="typo3-goBack">' . t3lib_iconWorks::getSpriteIcon('actions-view-go-back') . $GLOBALS['LANG']->getLL('goBack', TRUE) . '</a><br /><br />' : '';
        $resetDiffOnly = $this->diffOnly ? '<a href="index.php?id=' . intval($this->id) . '" class="typo3-goBack">' . $GLOBALS['LANG']->getLL('showAllInformation') . '</a><br /><br />' : '';
        $versionSelector = $GLOBALS['BE_USER']->workspace ? $this->doc->getVersionSelector($this->id) : '';
        return $versionSelector . $linkBack . $resetDiffOnly . $table . $this->markupNewOriginals();
    }
    /**
     * Main Task center module
     *
     * @return	string		HTML content.
     */
    function main()
    {
        if ($id = t3lib_div::_GP('display')) {
            return $this->urlInIframe($this->backPath . t3lib_extMgm::extRelPath('impexp') . 'app/index.php?tx_impexp[action]=export&preset[load]=1&preset[select]=' . $id, 1);
        } else {
            // Thumbnail folder and files:
            $tempDir = $this->userTempFolder();
            if ($tempDir) {
                $thumbnails = t3lib_div::getFilesInDir($tempDir, 'png,gif,jpg', 1);
            }
            $clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
            $usernames = t3lib_BEfunc::getUserNames();
            // Create preset links:
            $presets = $this->getPresets();
            $opt = array();
            $opt[] = '
			<tr class="bgColor5 tableheader">
				<td>Icon:</td>
				<td>Preset Title:</td>
				<td>Public</td>
				<td>Owner:</td>
				<td>Page:</td>
				<td>Path:</td>
				<td>Meta data:</td>
			</tr>';
            if (is_array($presets)) {
                foreach ($presets as $presetCfg) {
                    $configuration = unserialize($presetCfg['preset_data']);
                    $thumbnailFile = $thumbnails[$configuration['meta']['thumbnail']];
                    $title = strlen($presetCfg['title']) ? $presetCfg['title'] : '[' . $presetCfg['uid'] . ']';
                    $opt[] = '
					<tr class="bgColor4">
						<td>' . ($thumbnailFile ? '<img src="' . $this->backPath . '../' . substr($tempDir, strlen(PATH_site)) . basename($thumbnailFile) . '" hspace="2" width="70" style="border: solid black 1px;" alt="" /><br />' : '&nbsp;') . '</td>
						<td nowrap="nowrap"><a href="index.php?SET[function]=tx_impexp&display=' . $presetCfg['uid'] . '">' . htmlspecialchars(t3lib_div::fixed_lgd_cs($title, 30)) . '</a>&nbsp;</td>
						<td>' . ($presetCfg['public'] ? 'Yes' : '&nbsp;') . '</td>
						<td>' . ($presetCfg['user_uid'] === $GLOBALS['BE_USER']->user['uid'] ? 'Own' : '[' . $usernames[$presetCfg['user_uid']]['username'] . ']') . '</td>
						<td>' . ($configuration['pagetree']['id'] ? $configuration['pagetree']['id'] : '&nbsp;') . '</td>
						<td>' . htmlspecialchars($configuration['pagetree']['id'] ? t3lib_BEfunc::getRecordPath($configuration['pagetree']['id'], $clause, 20) : '[Single Records]') . '</td>
						<td>
							<strong>' . htmlspecialchars($configuration['meta']['title']) . '</strong><br />' . htmlspecialchars($configuration['meta']['description']) . ($configuration['meta']['notes'] ? '<br /><br /><strong>Notes:</strong> <em>' . htmlspecialchars($configuration['meta']['notes']) . '</em>' : '') . '
						</td>
					</tr>';
                }
                $content = '<table border="0" cellpadding="0" cellspacing="1" class="lrPadding">' . implode('', $opt) . '</table>';
            }
        }
        // Output:
        $theOutput .= $this->pObj->doc->spacer(5);
        $theOutput .= $this->pObj->doc->section('Export presets', $content, 0, 1);
        return $theOutput;
    }
 /**
  * Callback function to blind user and group accounts. Used as <code>itemsProcFunc</code> in <code>$TCA</code>.
  *
  * @param	array		$conf	Configuration array. The following elements are set:<ul><li>items - initial set of items (empty in our case)</li><li>config - field config from <code>$TCA</code></li><li>TSconfig - this function name</li><li>table - table name</li><li>row - record row (???)</li><li>field - field name</li></ul>
  * @param	object		$tceforms	<code>t3lib_div::TCEforms</code> object
  * @return	void
  */
 function processUserAndGroups($conf, $tceforms)
 {
     // Get usernames and groupnames
     $be_group_Array = t3lib_BEfunc::getListGroupNames('title,uid');
     $groupArray = array_keys($be_group_Array);
     $be_user_Array = t3lib_BEfunc::getUserNames();
     $be_user_Array = t3lib_BEfunc::blindUserNames($be_user_Array, $groupArray, 1);
     // users
     $title = $GLOBALS['LANG']->sL($GLOBALS['TCA']['be_users']['ctrl']['title']);
     foreach ($be_user_Array as $uid => $user) {
         $conf['items'][] = array($user['username'] . ' (' . $title . ')', 'be_users_' . $user['uid'], t3lib_iconWorks::getIcon('be_users', $user));
     }
     // Process groups only if necessary -- save time!
     if (strstr($conf['config']['mod_ws_allowed'], 'be_groups')) {
         // groups
         $be_group_Array = $be_group_Array_o = t3lib_BEfunc::getGroupNames();
         $be_group_Array = t3lib_BEfunc::blindGroupNames($be_group_Array_o, $groupArray, 1);
         $title = $GLOBALS['LANG']->sL($GLOBALS['TCA']['be_groups']['ctrl']['title']);
         foreach ($be_group_Array as $uid => $group) {
             $conf['items'][] = array($group['title'] . ' (' . $title . ')', 'be_groups_' . $group['uid'], t3lib_iconWorks::getIcon('be_groups', $user));
         }
     }
 }
Example #9
0
 /**
  * Inits all BE-users available, for development ONLY!
  *
  * @return	void
  */
 function initUsers()
 {
     // Initializing all users in order to generate the usergroup_cached_list
     $users = t3lib_BEfunc::getUserNames();
     // This is used to test with other users. Development ONLY!
     foreach ($users as $r) {
         $tempBE_USER = t3lib_div::makeInstance('local_beUserAuth');
         // New backend user object
         /* @var $tempBE_USER local_beUserAuth */
         $tempBE_USER->OS = TYPO3_OS;
         $tempBE_USER->setBeUserByUid($r['uid']);
         $tempBE_USER->fetchGroupData();
     }
 }
    /**
     * Creates an info-box for the current page (identified by input record).
     *
     * @param	array		Page record
     * @param	boolean		If set, there will be shown an edit icon, linking to editing of the page properties.
     * @return	string		HTML for the box.
     */
    function getPageInfoBox($rec, $edit = 0)
    {
        global $LANG;
        // If editing of the page properties is allowed:
        if ($edit) {
            $params = '&edit[pages][' . $rec['uid'] . ']=edit';
            $editIcon = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick($params, $this->backPath)) . '" title="' . $GLOBALS['LANG']->getLL('edit', TRUE) . '">' . t3lib_iconWorks::getSpriteIcon('actions-document-open') . '</a>';
        } else {
            $editIcon = $this->noEditIcon('noEditPage');
        }
        // Setting page icon, link, title:
        $outPutContent = t3lib_iconWorks::getSpriteIconForRecord('pages', $rec, array('title' => t3lib_BEfunc::titleAttribForPages($rec))) . $editIcon . '&nbsp;' . htmlspecialchars($rec['title']);
        // Init array where infomation is accumulated as label/value pairs.
        $lines = array();
        // Owner user/group:
        if ($this->pI_showUser) {
            // User:
            $users = t3lib_BEfunc::getUserNames('username,usergroup,usergroup_cached_list,uid,realName');
            $groupArray = explode(',', $GLOBALS['BE_USER']->user['usergroup_cached_list']);
            $users = t3lib_BEfunc::blindUserNames($users, $groupArray);
            $lines[] = array($LANG->getLL('pI_crUser') . ':', htmlspecialchars($users[$rec['cruser_id']]['username']) . ' (' . $users[$rec['cruser_id']]['realName'] . ')');
        }
        // Created:
        $lines[] = array($LANG->getLL('pI_crDate') . ':', t3lib_BEfunc::datetime($rec['crdate']) . ' (' . t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME'] - $rec['crdate'], $this->agePrefixes) . ')');
        // Last change:
        $lines[] = array($LANG->getLL('pI_lastChange') . ':', t3lib_BEfunc::datetime($rec['tstamp']) . ' (' . t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME'] - $rec['tstamp'], $this->agePrefixes) . ')');
        // Last change of content:
        if ($rec['SYS_LASTCHANGED']) {
            $lines[] = array($LANG->getLL('pI_lastChangeContent') . ':', t3lib_BEfunc::datetime($rec['SYS_LASTCHANGED']) . ' (' . t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME'] - $rec['SYS_LASTCHANGED'], $this->agePrefixes) . ')');
        }
        // Spacer:
        $lines[] = '';
        // Display contents of certain page fields, if any value:
        $dfields = explode(',', 'alias,target,hidden,starttime,endtime,fe_group,no_cache,cache_timeout,newUntil,lastUpdated,subtitle,keywords,description,abstract,author,author_email');
        foreach ($dfields as $fV) {
            if ($rec[$fV]) {
                $lines[] = array($GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel('pages', $fV)), t3lib_BEfunc::getProcessedValue('pages', $fV, $rec[$fV]));
            }
        }
        // Page hits (depends on "sys_stat" extension)
        if ($this->pI_showStat && t3lib_extMgm::isLoaded('sys_stat')) {
            // Counting total hits:
            $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', 'sys_stat', 'page_id=' . intval($rec['uid']));
            if ($count) {
                // Get min/max
                $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('min(tstamp) AS min,max(tstamp) AS max', 'sys_stat', 'page_id=' . intval($rec['uid']));
                $rrow2 = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
                $lines[] = '';
                $lines[] = array($LANG->getLL('pI_hitsPeriod') . ':', t3lib_BEfunc::date($rrow2[0]) . ' - ' . t3lib_BEfunc::date($rrow2[1]) . ' (' . t3lib_BEfunc::calcAge($rrow2[1] - $rrow2[0], $this->agePrefixes) . ')');
                $lines[] = array($LANG->getLL('pI_hitsTotal') . ':', $rrow[0]);
                // Last 10 days
                $nextMidNight = mktime(0, 0, 0) + 1 * 3600 * 24;
                $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*), FLOOR((' . $nextMidNight . '-tstamp)/(24*3600)) AS day', 'sys_stat', 'page_id=' . intval($rec['uid']) . ' AND tstamp>' . ($nextMidNight - 10 * 24 * 3600), 'day');
                $days = array();
                while ($rrow = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
                    $days[$rrow[1]] = $rrow[0];
                }
                $headerH = array();
                $contentH = array();
                for ($a = 9; $a >= 0; $a--) {
                    $headerH[] = '
							<td class="bgColor5" nowrap="nowrap">&nbsp;' . date('d', $nextMidNight - ($a + 1) * 24 * 3600) . '&nbsp;</td>';
                    $contentH[] = '
							<td align="center">' . ($days[$a] ? intval($days[$a]) : '-') . '</td>';
                }
                // Compile first hit-table (last 10 days)
                $hitTable = '
					<table border="0" cellpadding="0" cellspacing="1" class="typo3-page-hits">
						<tr>' . implode('', $headerH) . '</tr>
						<tr>' . implode('', $contentH) . '</tr>
					</table>';
                $lines[] = array($LANG->getLL('pI_hits10days') . ':', $hitTable, 1);
                // Last 24 hours
                $nextHour = mktime(date('H'), 0, 0) + 3600;
                $hours = 16;
                $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*), FLOOR((' . $nextHour . '-tstamp)/3600) AS hours', 'sys_stat', 'page_id=' . intval($rec['uid']) . ' AND tstamp>' . ($nextHour - $hours * 3600), 'hours');
                $days = array();
                while ($rrow = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
                    $days[$rrow[1]] = $rrow[0];
                }
                $headerH = array();
                $contentH = array();
                for ($a = $hours - 1; $a >= 0; $a--) {
                    $headerH[] = '
							<td class="bgColor5" nowrap="nowrap">&nbsp;' . intval(date('H', $nextHour - ($a + 1) * 3600)) . '&nbsp;</td>';
                    $contentH[] = '
							<td align="center">' . ($days[$a] ? intval($days[$a]) : '-') . '</td>';
                }
                // Compile second hit-table (last 24 hours)
                $hitTable = '
					<table border="0" cellpadding="0" cellspacing="1" class="typo3-page-stat">
						<tr>' . implode('', $headerH) . '</tr>
						<tr>' . implode('', $contentH) . '</tr>
					</table>';
                $lines[] = array($LANG->getLL('pI_hits24hours') . ':', $hitTable, 1);
            }
        }
        // Finally, wrap the elements in the $lines array in table cells/rows
        foreach ($lines as $fV) {
            if (is_array($fV)) {
                if (!$fV[2]) {
                    $fV[1] = htmlspecialchars($fV[1]);
                }
                $out .= '
				<tr>
					<td class="bgColor4" nowrap="nowrap"><strong>' . htmlspecialchars($fV[0]) . '&nbsp;&nbsp;</strong></td>
					<td class="bgColor4">' . $fV[1] . '</td>
				</tr>';
            } else {
                $out .= '
				<tr>
					<td colspan="2"><img src="clear.gif" width="1" height="3" alt="" /></td>
				</tr>';
            }
        }
        // Wrap table tags around...
        $outPutContent .= '



			<!--
				Page info box:
			-->
			<table border="0" cellpadding="0" cellspacing="1" id="typo3-page-info">
				' . $out . '
			</table>';
        // ... and return it.
        return $outPutContent;
    }
 /**
  * Initializes several class variables
  *
  * @return	void
  */
 function initVars()
 {
     // Init users
     $be_group_Array = t3lib_BEfunc::getListGroupNames('title,uid');
     $groupArray = array_keys($be_group_Array);
     // Need 'admin' field for t3lib_iconWorks::getIconImage()
     $this->be_user_Array = t3lib_BEfunc::getUserNames('username,usergroup,usergroup_cached_list,uid,admin,workspace_perms');
     if (!$GLOBALS['BE_USER']->isAdmin()) {
         $this->be_user_Array = t3lib_BEfunc::blindUserNames($this->be_user_Array, $groupArray, 1);
     }
     // If another page module was specified, replace the default Page module with the new one
     $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
     $this->pageModule = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
     // Setting publish access permission for workspace:
     $this->publishAccess = $GLOBALS['BE_USER']->workspacePublishAccess($GLOBALS['BE_USER']->workspace);
     // FIXME Should be $this->workspaceId here?
 }
Example #12
0
 /**
  * Main function for Workspace Manager module.
  *
  * @return	void
  */
 function main()
 {
     global $LANG, $BE_USER, $BACK_PATH;
     // See if we need to switch workspace
     $changeWorkspace = t3lib_div::_GET('changeWorkspace');
     if ($changeWorkspace != '') {
         $BE_USER->setWorkspace($changeWorkspace);
         $this->content .= $this->doc->wrapScriptTags('top.location.href="' . $BACK_PATH . t3lib_BEfunc::getBackendScript() . '";');
     } else {
         // Starting page:
         $this->content .= $this->doc->header($LANG->getLL('title'));
         $this->content .= $this->doc->spacer(5);
         // Get usernames and groupnames
         $be_group_Array = t3lib_BEfunc::getListGroupNames('title,uid');
         $groupArray = array_keys($be_group_Array);
         // Need 'admin' field for t3lib_iconWorks::getIconImage()
         $this->be_user_Array_full = $this->be_user_Array = t3lib_BEfunc::getUserNames('username,usergroup,usergroup_cached_list,uid,admin,workspace_perms');
         if (!$GLOBALS['BE_USER']->isAdmin()) {
             $this->be_user_Array = t3lib_BEfunc::blindUserNames($this->be_user_Array, $groupArray, 1);
         }
         // Build top menu:
         $menuItems = array();
         $menuItems[] = array('label' => $LANG->getLL('menuitem_review'), 'content' => $this->moduleContent_publish());
         $menuItems[] = array('label' => $LANG->getLL('menuitem_workspaces'), 'content' => $this->moduleContent_workspaceList());
         // Add hidden fields and create tabs:
         $content = $this->doc->getDynTabMenu($menuItems, 'user_ws');
         $this->content .= $this->doc->section('', $content, 0, 1);
         // Setting up the buttons and markers for docheader
         $docHeaderButtons = $this->getButtons();
         // $markers['CSH'] = $docHeaderButtons['csh'];
     }
     $markers['CONTENT'] = $this->content;
     // Build the <body> for the module
     $this->content = $this->doc->startPage($LANG->getLL('title'));
     $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
     $this->content .= $this->doc->endPage();
     $this->content = $this->doc->insertStylesAndJS($this->content);
 }
 /**
  * Generate the user selector element
  *
  * @param	Integer		$page: The page id to change the user for
  * @param	Integer		$ownerUid: The page owner uid
  * @param	String		$username: The username to display
  * @return	String		The html select element
  */
 protected function renderUserSelector($page, $ownerUid, $username = '')
 {
     // Get usernames
     $beUsers = t3lib_BEfunc::getUserNames();
     // Init groupArray
     $groups = array();
     if (!$GLOBALS['BE_USER']->isAdmin()) {
         $beUsers = t3lib_BEfunc::blindUserNames($beUsers, $groups, 1);
     }
     // Owner selector:
     $options = '';
     // Loop through the users
     foreach ($beUsers as $uid => $row) {
         $selected = $uid == $ownerUid ? ' selected="selected"' : '';
         $options .= '<option value="' . $uid . '"' . $selected . '>' . htmlspecialchars($row['username']) . '</option>';
     }
     $elementId = 'o_' . $page;
     $options = '<option value="0"></option>' . $options;
     $selector = '<select name="new_page_owner" id="new_page_owner">' . $options . '</select>';
     $saveButton = '<a onclick="WebPermissions.changeOwner(' . $page . ', ' . $ownerUid . ', \'' . $elementId . '\');" title="Change owner">' . t3lib_iconWorks::getSpriteIcon('actions-document-save') . '</a>';
     $cancelButton = '<a onclick="WebPermissions.restoreOwner(' . $page . ', ' . $ownerUid . ', \'' . ($username == '' ? '<span class=not_set>[not set]</span>' : htmlspecialchars($username)) . '\', \'' . $elementId . '\');" title="Cancel">' . t3lib_iconWorks::getSpriteIcon('actions-document-close') . '</a>';
     $ret = $selector . $saveButton . $cancelButton;
     return $ret;
 }
Example #14
0
 /**
  * Menu configuration
  *
  * @return	void
  */
 function menuConfig()
 {
     global $BE_USER, $LANG, $BACK_PATH, $TCA_DESCR, $TCA, $CLIENT, $TYPO3_CONF_VARS, $TYPO3_DB;
     // MENU-ITEMS:
     // If array, then it's a selector box menu
     // If empty string it's just a variable, that'll be saved.
     // Values NOT in this array will not be saved in the settings-array for the module.
     $this->MOD_MENU = array('users' => array(0 => $GLOBALS['LANG']->getLL('any'), '-1' => $GLOBALS['LANG']->getLL('self')), 'workspaces' => array('-99' => $GLOBALS['LANG']->getLL('any'), 0 => $GLOBALS['LANG']->getLL('live'), '-1' => $GLOBALS['LANG']->getLL('draft')), 'time' => array(0 => $GLOBALS['LANG']->getLL('thisWeek'), 1 => $GLOBALS['LANG']->getLL('lastWeek'), 2 => $GLOBALS['LANG']->getLL('last7Days'), 10 => $GLOBALS['LANG']->getLL('thisMonth'), 11 => $GLOBALS['LANG']->getLL('lastMonth'), 12 => $GLOBALS['LANG']->getLL('last31Days'), 20 => $GLOBALS['LANG']->getLL('noLimit'), 30 => $GLOBALS['LANG']->getLL('userdefined')), 'max' => array(20 => $GLOBALS['LANG']->getLL('20'), 50 => $GLOBALS['LANG']->getLL('50'), 100 => $GLOBALS['LANG']->getLL('100'), 200 => $GLOBALS['LANG']->getLL('200'), 500 => $GLOBALS['LANG']->getLL('500'), 1000 => $GLOBALS['LANG']->getLL('1000'), 1000000 => $GLOBALS['LANG']->getLL('any')), 'action' => array(0 => $GLOBALS['LANG']->getLL('any'), 1 => $GLOBALS['LANG']->getLL('actionDatabase'), 2 => $GLOBALS['LANG']->getLL('actionFile'), 254 => $GLOBALS['LANG']->getLL('actionSettings'), 255 => $GLOBALS['LANG']->getLL('actionLogin'), '-1' => $GLOBALS['LANG']->getLL('actionErrors')), 'manualdate' => '', 'manualdate_end' => '', 'groupByPage' => '');
     // Add custom workspaces (selecting all, filtering by BE_USER check):
     $workspaces = $TYPO3_DB->exec_SELECTgetRows('uid,title', 'sys_workspace', 'pid=0' . t3lib_BEfunc::deleteClause('sys_workspace'), '', 'title');
     if (count($workspaces)) {
         foreach ($workspaces as $rec) {
             $this->MOD_MENU['workspaces'][$rec['uid']] = $rec['uid'] . ': ' . $rec['title'];
         }
     }
     // Adding groups to the users_array
     $groups = t3lib_BEfunc::getGroupNames();
     if (is_array($groups)) {
         foreach ($groups as $grVals) {
             $this->MOD_MENU['users']['gr-' . $grVals['uid']] = $GLOBALS['LANG']->getLL('group') . ' ' . $grVals['title'];
         }
     }
     $users = t3lib_BEfunc::getUserNames();
     if (is_array($users)) {
         foreach ($users as $grVals) {
             $this->MOD_MENU['users']['us-' . $grVals['uid']] = $GLOBALS['LANG']->getLL('user') . ' ' . $grVals['username'];
         }
     }
     // CLEANSE SETTINGS
     $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
     // manual dates
     if ($this->MOD_SETTINGS['time'] == 30) {
         if (!trim($this->MOD_SETTINGS['manualdate'])) {
             $this->theTime = $this->MOD_SETTINGS['manualdate'] = 0;
         } else {
             $this->theTime = $this->parseDate($this->MOD_SETTINGS['manualdate']);
             if (!$this->theTime) {
                 $this->MOD_SETTINGS['manualdate'] = '';
             } else {
                 $this->MOD_SETTINGS['manualdate'] = date($this->dateFormat, $this->theTime);
             }
         }
         if (!trim($this->MOD_SETTINGS['manualdate_end'])) {
             $this->theTime_end = $this->MOD_SETTINGS['manualdate_end'] = 0;
         } else {
             $this->theTime_end = $this->parseDate($this->MOD_SETTINGS['manualdate_end']);
             if (!$this->theTime_end) {
                 $this->MOD_SETTINGS['manualdate_end'] = '';
             } else {
                 $this->MOD_SETTINGS['manualdate_end'] = date($this->dateFormat, $this->theTime_end);
             }
         }
     }
 }
Example #15
0
 /**
  * Get array of all responsilbe be_users for a stage
  *
  * @param	int	stage id
  * @return	array be_users with e-mail and name
  */
 public function getResponsibleBeUser($stageId)
 {
     $workspaceRec = t3lib_BEfunc::getRecord('sys_workspace', $this->getWorkspaceId());
     $recipientArray = array();
     switch ($stageId) {
         case self::STAGE_PUBLISH_EXECUTE_ID:
         case self::STAGE_PUBLISH_ID:
             $userList = $this->getResponsibleUser($workspaceRec['adminusers']);
             break;
         case self::STAGE_EDIT_ID:
             $userList = $this->getResponsibleUser($workspaceRec['members']);
             break;
         default:
             $responsible_persons = $this->getPropertyOfCurrentWorkspaceStage($stageId, 'responsible_persons');
             $userList = $this->getResponsibleUser($responsible_persons);
             break;
     }
     if (!empty($userList)) {
         $userRecords = t3lib_BEfunc::getUserNames('username, uid, email, realName', 'AND uid IN (' . $userList . ')');
     }
     if (!empty($userRecords) && is_array($userRecords)) {
         foreach ($userRecords as $userUid => $userRecord) {
             $recipientArray[$userUid] = $userRecord;
         }
     }
     return $recipientArray;
 }
 /**
  * Show the log entries for page
  *
  * @return	string		HTML output
  */
 function main()
 {
     global $SOBE, $LANG;
     $this->localLang();
     $lF = t3lib_div::makeInstance('logFunctions_ext');
     $theOutput = '';
     $menu = '';
     $menu .= '&nbsp;' . $LANG->getLL('chLog_menuUsers') . ': ' . t3lib_BEfunc::getFuncMenu($this->pObj->id, 'SET[log_users]', $this->pObj->MOD_SETTINGS['log_users'], $this->pObj->MOD_MENU['log_users']);
     $menu .= '&nbsp;' . $LANG->getLL('chLog_menuDepth') . ': ' . t3lib_BEfunc::getFuncMenu($this->pObj->id, 'SET[depth]', $this->pObj->MOD_SETTINGS['depth'], $this->pObj->MOD_MENU['depth']);
     $menu .= '&nbsp;' . $LANG->getLL('chLog_menuTime') . ': ' . t3lib_BEfunc::getFuncMenu($this->pObj->id, 'SET[log_time]', $this->pObj->MOD_SETTINGS['log_time'], $this->pObj->MOD_MENU['log_time']);
     $theOutput .= $this->pObj->doc->section($LANG->getLL('chLog_title'), '<span class="nobr">' . $menu . '</span>', 0, 1);
     // Build query
     $where_part = '';
     // Get the id-list of pages for the tree structure.
     $tree = t3lib_div::makeInstance('t3lib_pageTree');
     $tree->init('AND ' . $this->pObj->perms_clause);
     $tree->makeHTML = 0;
     $tree->fieldArray = array('uid');
     if ($this->pObj->MOD_SETTINGS['depth']) {
         $tree->getTree($this->pObj->id, $this->pObj->MOD_SETTINGS['depth'], '');
     }
     $tree->ids[] = $this->pObj->id;
     $idList = implode($tree->ids, ',');
     $where_part .= ' AND (event_pid in (' . $idList . '))';
     // DB
     // Time:
     $starttime = 0;
     $endtime = $GLOBALS['EXEC_TIME'];
     switch ($this->pObj->MOD_SETTINGS['log_time']) {
         case 0:
             // This week
             $week = (date('w') ? date('w') : 7) - 1;
             $starttime = mktime(0, 0, 0) - $week * 3600 * 24;
             break;
         case 1:
             // Last week
             $week = (date('w') ? date('w') : 7) - 1;
             $starttime = mktime(0, 0, 0) - ($week + 7) * 3600 * 24;
             $endtime = mktime(0, 0, 0) - $week * 3600 * 24;
             break;
         case 2:
             // Last 7 days
             $starttime = mktime(0, 0, 0) - 7 * 3600 * 24;
             break;
         case 10:
             // This month
             $starttime = mktime(0, 0, 0, date('m'), 1);
             break;
         case 11:
             // Last month
             $starttime = mktime(0, 0, 0, date('m') - 1, 1);
             $endtime = mktime(0, 0, 0, date('m'), 1);
             break;
         case 12:
             // Last 31 days
             $starttime = mktime(0, 0, 0) - 31 * 3600 * 24;
             break;
     }
     if ($starttime) {
         $where_part .= ' AND tstamp>=' . $starttime . ' AND tstamp<' . $endtime;
     }
     $where_part .= ' AND type=1';
     // DB
     // Users
     $this->pObj->be_user_Array = t3lib_BEfunc::getUserNames();
     if (!$this->pObj->MOD_SETTINGS['log_users']) {
         // All users
         // Get usernames and groupnames
         if (!$GLOBALS['BE_USER']->isAdmin()) {
             $groupArray = explode(',', $GLOBALS['BE_USER']->user['usergroup_cached_list']);
             $this->pObj->be_user_Array = t3lib_BEfunc::blindUserNames($this->pObj->be_user_Array, $groupArray, 1);
         }
         if (is_array($this->pObj->be_user_Array)) {
             foreach ($this->pObj->be_user_Array as $val) {
                 $selectUsers[] = $val['uid'];
             }
         }
         $selectUsers[] = $GLOBALS['BE_USER']->user['uid'];
         $where_part .= ' AND userid in (' . implode($selectUsers, ',') . ')';
     } else {
         $where_part .= ' AND userid=' . $GLOBALS['BE_USER']->user['uid'];
         // Self user
     }
     $lF->be_user_Array =& $this->pObj->be_user_Array;
     if ($GLOBALS['BE_USER']->workspace !== 0) {
         $where_part .= ' AND workspace=' . intval($GLOBALS['BE_USER']->workspace);
     }
     // Select 100 recent log entries:
     $log = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_log', '1=1' . $where_part, '', 'uid DESC', 100);
     $codeArr = $lF->initArray();
     $oldHeader = '';
     while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($log)) {
         $header = $this->pObj->doc->formatTime($row['tstamp'], 10);
         if (!$oldHeader) {
             $oldHeader = $header;
         }
         if ($header != $oldHeader) {
             $theOutput .= $this->pObj->doc->spacer(10);
             $theOutput .= $this->pObj->doc->section($oldHeader, $this->pObj->doc->table($codeArr));
             $codeArr = $lF->initArray();
             $oldHeader = $header;
             $lF->reset();
         }
         $i++;
         $codeArr[$i][] = $lF->getTimeLabel($row['tstamp']);
         $codeArr[$i][] = $lF->getUserLabel($row['userid'], $row['workspace']);
         $codeArr[$i][] = $row['error'] ? $lF->getErrorFormatting($lF->errorSign[$row['error']], $row['error']) : '';
         $codeArr[$i][] = $lF->getActionLabel($row['type'] . '_' . $row['action']);
         $codeArr[$i][] = $row['tablename'];
         $codeArr[$i][] = $lF->formatDetailsForList($row);
     }
     $theOutput .= $this->pObj->doc->spacer(10);
     $theOutput .= $this->pObj->doc->section($header, $this->pObj->doc->table($codeArr));
     $GLOBALS['TYPO3_DB']->sql_free_result($log);
     return $theOutput;
 }