PHP Classes

File: engine/modules/core/access/access.qtags.inc

Recommend this page to a friend!
  Classes of Aldo Tripiciano   Quanta CMS   engine/modules/core/access/access.qtags.inc   Download  
File: engine/modules/core/access/access.qtags.inc
Role: Example script
Content type: text/plain
Description: Example script
Class: Quanta CMS
Manage content that works without a database
Author: By
Last change:
Date: 5 years ago
Size: 836 bytes
 

Contents

Class file image Download
<?php
/**
 * Implements qtag PERMISSION.
 *
 * Show a permission of a node.
 *
 * @param Environment $env
 * The Environment.
 *
 * @param string $target
 * The qtag's target.
 *
 * @param array $attributes
 * The qtag's attributes.
 *
 * @return string
 * The rendered qtag.
 */
function qtag_PERMISSION($env, $target, $attributes) {
 
$node = empty($target) ? NodeFactory::current($env) : NodeFactory::load($env, $target);
  if (
$node->isNew()) {
   
$permission = 'inherit';
  }
  else {
    if (!empty(
$node->getAttributeJSON('permissions')->{$attributes['name']})) {
     
// Try to fetch the permission from the node, first.
     
$permission = $node->getAttributeJSON('permissions')->{$attributes['name']};
    }
    else {
     
$permission = $node->getPermission($attributes['name']);
    }
  }
  return
$permission;
}