/** * Sets the default permissions for Objects without an Admin * * @param int $usergroupId Usergroup Id * @return bool TRUE on success or FALSE in case of an error */ function setDefaultPermissions($usergroupId) { // For Templates $templateMgr = new Templates(); $allTemplates = $templateMgr->getList(); $permissionList = array(); foreach ($allTemplates as $allTemplate) { $permissionList[] = array('RREAD' => 1, 'RSUB' => 1, 'RWRITE' => 1, 'RDELETE' => 1, 'OID' => $allTemplate['ID'], 'USERGROUPID' => $usergroupId); } $templateMgr->permissions->setPermissions($permissionList); // For Views $viewMgr = new Views(); $allViews = $viewMgr->getList(); $permissionList = array(); foreach ($allViews as $allView) { $permissionList[] = array('RREAD' => 1, 'RSUB' => 1, 'RWRITE' => 1, 'RDELETE' => 1, 'OID' => $allView['ID'], 'USERGROUPID' => $usergroupId); } $viewMgr->permissions->setPermissions($permissionList); // For Entrymasks $entrymaskMgr = new Entrymasks(); $allEntrymasks = $entrymaskMgr->getList(); $permissionList = array(); foreach ($allEntrymasks as $allEntrymask) { $permissionList[] = array('RREAD' => 1, 'RSUB' => 1, 'RWRITE' => 1, 'RDELETE' => 1, 'OID' => $allEntrymask['ID'], 'USERGROUPID' => $usergroupId); } $entrymaskMgr->permissions->setPermissions($permissionList); // For Cblock blindfolder $embeddedCblockFolder = (int) sConfig()->getVar("CONFIG/EMBEDDED_CBLOCKFOLDER"); $permissionList = array(); $permissionList[] = array('RREAD' => 1, 'RSUB' => 1, 'RWRITE' => 1, 'OID' => $embeddedCblockFolder, 'USERGROUPID' => $usergroupId); sCblockMgr()->permissions->setPermissions($permissionList); // Remove rights for Cblock root node $cblockRootNodeId = sCblockMgr()->tree->getRoot(); $permissionList = array(); $permissionList[] = array('RREAD' => 0, 'RSUB' => 0, 'RWRITE' => 0, 'RDELETE' => 0, 'OID' => $cblockRootNodeId, 'USERGROUPID' => $usergroupId); sCblockMgr()->permissions->setPermissions($permissionList); }
<?php $tmpUser = new User(sUserMgr()->getCurrentUserID()); $tmpUserInfo = $tmpUser->get(); $adminAllowed = $tmpUser->checkPermission('RVIEWS'); if ($adminAllowed) { $viewMgr = new Views(); $views = $viewMgr->getList(); } $empty_info = array('NAME' => '', 'ID' => '__NEW__', 'WIDTH' => '0', 'HEIGHT' => '0', 'WIDTHCROP' => 0, 'HEIGHTCROP' => 0, 'CONSTRAINHEIGHT' => 0, 'CONSTRAINWIDTH' => 0); $user = new User(sUserMgr()->getCurrentUserID()); $smarty->assign("RVIEWS", $user->checkPermission("RVIEWS")); $smarty->assign('views', $views); $smarty->assign('empty_info', $empty_info); $smarty->assign('win_no', $this->request->parameters['win_no']); $smarty->display('file:' . $this->page_template);
<?php // Get all available views $viewMgr = new Views(); $views = $viewMgr->getList('prop.NAME'); // Remove Root-Node from views $realViews = array(); foreach ($views as $view) { if ($view['LEVEL'] > 1) { array_push($realViews, $view); } } $views = $realViews; $smarty->assign('views', $views); $smarty->assign('viewcount', count($views)); $smarty->assign('win_no', $this->request->parameters['win_no']); $smarty->display('file:' . $this->page_template);