本文整理汇总了PHP中Permissions类的典型用法代码示例。如果您正苦于以下问题:PHP Permissions类的具体用法?PHP Permissions怎么用?PHP Permissions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Permissions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
public function add()
{
$filesystem = new Filesystem();
if ($this->request->request->has('currentFolder')) {
$node = Node::getByID($this->request->request->get('currentFolder'));
if (is_object($node) && $node instanceof FileFolder) {
$folder = $node;
}
}
if (!isset($folder)) {
$folder = $filesystem->getRootFolder();
}
$permissions = new \Permissions($folder);
$error = $this->app->make('error');
$response = new EditResponse();
$response->setError($error);
if (!$permissions->canAddTreeSubNode()) {
$error->add(t('You do not have permission to add a folder here.'));
}
if (!$error->has()) {
$folder = $filesystem->addFolder($folder, $this->request->request->get('folderName'));
$response->setMessage(t('Folder added.'));
$response->setAdditionalDataAttribute('folder', $folder);
}
$response->outputJSON();
}
示例2: on_page_view
public function on_page_view()
{
$stack = Stack::getByID($this->stID);
if (!is_object($stack)) {
return false;
}
$p = new Permissions($stack);
if ($p->canViewPage()) {
$blocks = $stack->getBlocks();
foreach ($blocks as $b) {
$bp = new Permissions($b);
if ($bp->canViewBlock()) {
$btc = $b->getInstance();
if ('Controller' != get_class($btc)) {
$btc->outputAutoHeaderItems();
}
$csr = $b->getBlockCustomStyleRule();
if (is_object($csr)) {
$styleHeader = '#' . $csr->getCustomStyleRuleCSSID(1) . ' {' . $csr->getCustomStyleRuleText() . "} \r\n";
$btc->addHeaderItem("<style type=\"text/css\"> \r\n" . $styleHeader . '</style>', 'VIEW');
}
$btc->runTask('on_page_view', array($view));
}
}
}
}
示例3: delete
public function delete($ptID = false)
{
$pagetype = PageType::getByID($ptID);
if (!is_object($pagetype)) {
$this->error->add(t('Invalid page type object.'));
}
$cmp = new \Permissions($pagetype);
if (!$cmp->canDeletePageType()) {
$this->error->add(t('You do not have access to delete this page type.'));
}
$count = $pagetype->getPageTypeUsageCount();
if ($count > 0) {
$this->error->add(t2(
'This page type is in use on %d page.',
'This page type is in use on %d pages.', $count));
}
if (!$this->token->validate('delete_page_type')) {
$this->error->add(t($this->token->getErrorMessage()));
}
if (!$this->error->has()) {
$pagetype->delete();
$this->redirect('/dashboard/pages/types', 'page_type_deleted');
}
$this->view();
}
示例4: delete
public function delete($cID = false, $token = false) {
if (Loader::helper('validation/token')->validate('delete', $token)) {
$s = Stack::getByID($cID);
if (is_object($s)) {
$sps = new Permissions($s);
if ($sps->canDeletePage()) {
$u = new User();
$pkr = new DeletePagePageWorkflowRequest();
$pkr->setRequestedPage($s);
$pkr->setRequesterUserID($u->getUserID());
$response = $pkr->trigger();
if ($response instanceof WorkflowProgressResponse) {
// we only get this response if we have skipped workflows and jumped straight in to an approve() step.
$this->redirect('/dashboard/blocks/stacks', 'stack_deleted');
} else {
$this->redirect('/dashboard/blocks/stacks', 'view_details', $cID, 'delete_saved');
}
} else {
$this->error->add(t('You do not have access to delete this stack.'));
}
} else {
$this->error->add(t('Invalid stack'));
}
} else {
$this->error->add(Loader::helper('validation/token')->getErrorMessage());
}
}
示例5: getSearchResultFromQuery
public function getSearchResultFromQuery(Query $query)
{
$result = parent::getSearchResultFromQuery($query);
$u = new \User();
if (!$u->isSuperUser()) {
$gIDs = array(-1);
$gs = new GroupList();
$groups = $gs->getResults();
foreach ($groups as $g) {
$gp = new \Permissions($g);
if ($gp->canSearchUsersInGroup()) {
$gIDs[] = $g->getGroupID();
}
}
$result->getItemListObject()->getQueryObject()->leftJoin("u", "UserGroups", "ugRequired", "ugRequired.uID = u.uID");
$groups = 'ugRequired.gID in (' . implode(',', $gIDs) . ')';
$gg = \Group::getByID(REGISTERED_GROUP_ID);
$ggp = new \Permissions($gg);
if ($ggp->canSearchUsersInGroup()) {
$null = 'ugRequired.gID is null';
}
$result->getItemListObject()->getQueryObject()->select('distinct (u.uID)');
$expr = $result->getItemListObject()->getQueryObject()->expr()->orX($groups, $null);
$result->getItemListObject()->getQueryObject()->andwhere($expr);
}
return $result;
}
示例6: view
public function view()
{
session_write_close();
$keywords = $_REQUEST['q'];
$pl = new \PageList();
$pl->filterByName($keywords);
$pl->sortBy('cID', 'asc');
$pl->setItemsPerPage(5);
$pl->setPermissionsChecker(function ($page) {
$pp = new \Permissions($page);
return $pp->canViewPageInSitemap();
});
$pagination = $pl->getPagination();
$pages = $pagination->getCurrentPageResults();
$results = array();
$nh = \Core::make('helper/navigation');
foreach ($pages as $c) {
$obj = new \stdClass();
$obj->href = $nh->getLinkToCollection($c);
$obj->cID = $c->getCollectionID();
$obj->name = $c->getCollectionName();
$results[] = $obj;
}
echo json_encode($results);
\Core::shutdown(array('jobs' => true));
}
示例7: on_start
public function on_start()
{
$c = Page::getByPath('/dashboard/blocks/stacks');
$cp = new Permissions($c);
if ($cp->canViewPage()) {
$c = Page::getCurrentPage();
$pcp = new Permissions($c);
if (!$pcp->canViewPageVersions() || $_GET['vtask'] != 'view_versions' && $_GET['vtask'] != 'compare') {
$cID = $c->getCollectionID();
$this->redirect('/dashboard/blocks/stacks', 'view_details', $cID);
} else {
$this->theme = 'dashboard';
}
} else {
global $c;
// ugh
$v = View::getInstance();
$c = new Page();
$c->loadError(COLLECTION_NOT_FOUND);
$v->setCollectionObject($c);
$this->c = $c;
$cont = Loader::controller("/page_not_found");
$v->setController($cont);
$v->render('/page_not_found');
}
}
示例8: action_post
public function action_post() {
// happens through ajax
$pagetype = PageType::getByID($this->ptID);
if (is_object($pagetype) && $this->enableNewTopics) {
$ccp = new Permissions($pagetype);
if ($ccp->canAddPageType()) {
$pagetypes = $pagetype->getPageTypeComposerPageTypeObjects();
$ctTopic = $pagetypes[0];
$c = Page::getCurrentPage();
$e = $pagetype->validatePublishRequest($ctTopic, $c);
$r = new PageTypePublishResponse($e);
if (!$e->has()) {
$d = $pagetype->createDraft($ctTopic);
$d->setPageDraftTargetParentPageID($c->getCollectionID());
$d->saveForm();
$d->publish();
$nc = Page::getByID($d->getCollectionID(), 'RECENT');
$link = Loader::helper('navigation')->getLinkToCollection($nc, true);
$r->setRedirectURL($link);
}
$r->outputJSON();
}
}
exit;
}
示例9: indexAction
public function indexAction()
{
$this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Status"), $this->view->translate("System Logs")));
$config = Zend_Registry::get('config');
include $config->system->path->base . "/inspectors/Permissions.php";
$test = new Permissions();
$response = $test->getTests();
$form = new Snep_Form(new Zend_Config_Xml('./modules/default/forms/logs.xml', 'general', true));
$form->setAction($this->getFrontController()->getBaseUrl() . '/logs/view');
$locale = Snep_Locale::getInstance()->getLocale();
$now = Zend_Date::now();
if ($locale == 'en_US') {
$now = $now->toString('YYYY-MM-dd HH:mm');
} else {
$now = $now->toString('dd/MM/YYYY HH:mm');
}
$initDay = $form->getElement('init_day');
$initDay->setValue($now);
$endDay = $form->getElement('end_day');
$endDay->setValue($now);
$status = $form->getElement('status');
$status->setValue('ALL');
$realtime = $form->getElement('real_time');
$realtime->setValue('no');
$submit = $form->getElement("submit");
$submit->setLabel("Log Search");
$this->initLogFile();
$this->view->form = $form;
}
示例10: from_idmobject
public static function from_idmobject()
{
$perm = new Permissions();
$grant = array();
if (\IDMObject::authZ('role', 'tcert')) {
$grant[] = 'tcert';
}
if (\IDMObject::authz('permission', 'tcert_admin')) {
$grant[] = 'admin';
}
if (\IDMObject::authz('permission', 'tcert_gatesystem_ug')) {
$grant[] = 'gatesystem_ug';
}
if (\IDMObject::authz('permission', 'tcert_gatesystem_gr')) {
$grant[] = 'gatesystem_gr';
}
if (\IDMObject::authz('permission', 'mis')) {
$grant[] = 'superadmin';
}
if (\IDMObject::authz('role', 'faculty')) {
$grant[] = 'faculty';
}
$perm->grant($grant);
$perm->pidm = $_SESSION['pidm'];
return $perm;
}
示例11: preview
public function preview()
{
$request = \Request::getInstance();
$c = \Page::getByID($this->request->get('cID'));
$cp = new \Permissions($c);
if ($cp->canViewPageVersions()) {
$c->loadVersionObject(\Core::make('helper/security')->sanitizeInt($_REQUEST['cvID']));
$spoofed_request = \Request::createFromGlobals();
if ($device_handle = $request->headers->get('x-device-handle')) {
if ($device = \Core::make('device/manager')->get($device_handle)) {
if ($agent = $device->getUserAgent()) {
$spoofed_request->headers->set('User-Agent', $agent);
}
}
}
$spoofed_request->setCustomRequestUser(-1);
$spoofed_request->setCurrentPage($c);
\Request::setInstance($spoofed_request);
$controller = $c->getPageController();
$controller->runTask('view', array());
$view = $controller->getViewObject();
$response = new \Response();
$content = $view->render();
// Reset just in case.
\Request::setInstance($request);
$response->setContent($content);
$response->send();
exit;
}
}
示例12: create
function create($aData)
{
try {
$sCode = $aData['PER_CODE'];
$oCriteria = new Criteria('rbac');
$oCriteria->add(PermissionsPeer::PER_CODE, $sCode);
$oDataset = PermissionsPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
$aRow = $oDataset->getRow();
if (is_array($aRow)) {
return 1;
}
$aData['PER_UID'] = G::generateUniqueID();
$aData['PER_CODE'] = $aData['PER_CODE'];
$aData['PER_CREATE_DATE'] = date('Y-m-d H:i:s');
$aData['PER_UPDATE_DATE'] = $aData['PER_CREATE_DATE'];
$aData['PER_STATUS'] = 1;
$oPermission = new Permissions();
$oPermission->fromArray($aData, BasePeer::TYPE_FIELDNAME);
$iResult = $oPermission->save();
return $aData['PER_UID'];
} catch (Exception $oError) {
throw $oError;
}
}
示例13: create_entry
public function create_entry($id = null, $owner_entry_id = null)
{
$r = $this->entityManager->getRepository('\\Concrete\\Core\\Entity\\Express\\Entity');
$entity = $r->findOneById($id);
if (!is_object($entity)) {
$this->redirect('/dashboard/express/entries');
}
if ($owner_entry_id) {
$r = $this->entityManager->getRepository('\\Concrete\\Core\\Entity\\Express\\Entry');
$entry = $r->findOneById($owner_entry_id);
}
$permissions = new \Permissions($entity);
if (!$permissions->canAddExpressEntries()) {
throw new \Exception(t('You do not have access to add entries of this entity type.'));
}
$this->set('entity', $entity);
$form = $entity->getDefaultEditForm();
if (is_object($entry) && $entry->getEntity() == $entity->getOwnedBy()) {
$form = new OwnedEntityForm($form, $entry);
$this->set('backURL', $this->getViewEntryURL($entry));
} else {
$this->set('backURL', $this->getBackURL($entity));
}
$renderer = \Core::make('Concrete\\Core\\Express\\Form\\StandardFormRenderer', ['form' => $form]);
$this->set('renderer', $renderer);
$this->render('/dashboard/express/entries/create', false);
}
示例14: canAccess
protected function canAccess()
{
$tree = $this->getTree();
$node = $tree->getRootTreeNodeObject();
$np = new \Permissions($node);
return $np->canViewTreeNode();
}
示例15: canAccess
protected function canAccess()
{
list($sourceNodes, $destNode) = $this->getNodes();
if (is_object($destNode)) {
$dp = new \Permissions($destNode);
return $dp->canAddTreeSubNode();
}
}