Location: PHPKode > projects > Content*Builder > contentbuilder/lib/permission/perm.column.class.php
<?php
/*
* Column Optionen
*/
define("COLUMN_OPTION_ONLINE",          1 << 0);
define("COLUMN_OPTION_LOCAL_PERMS",     1 << 1);

define("COLUMN_PERM_EDIT_COLUMN",       1 << 0);
define("COLUMN_PERM_EDIT_OWN_ARTICLES", 1 << 1);
define("COLUMN_PERM_EDIT_ALL_ARTICLES", 1 << 2);
define("COLUMN_PERM_PUBLISH_ARTICLES",  1 << 3);
define("COLUMN_PERM_MEDIA_UPLOAD",      1 << 4);

class CB_permission_column extends CB_permission {
	var $cbPerms = 0;
	var $allUserPerms = 0;
	
	/**
	 * CB_permission_column::CB_permission_column()
	 * 
	 * @param boolean $optionArr
	 * @return 
	 **/
	function CB_permission_column($optionArr = false) {
		parent::CB_permission($optionArr);
		
		$this->setType("columnPerms");
		$this->getPermissionList();
		
		$this->cbPerms      = $optionArr['cbPerms'];
		$this->allUserPerms = $this->getAllPermissionSet(true);
		$this->allUserPerms = $this->checkAdmin($this->allUserPerms, $this->cbPerms);
	}
	
	/**
	 * CB_permission_column::hasEditPermission()
	 * 
	 * @param boolean $id
	 * @param boolean $optionArr
	 * @return 
	 **/
	function hasEditPermission($id = false, $optionArr = false) {
		$generalSet = $this->getSpecificPermissionSet('general');
		if($id == false) {
			if(COLUMN_PERM_EDIT_COLUMN & $generalSet) {
				return 1;
			} else {
				return 0;
			}
		} else {
			$editAllowed = 0;
			$node = $this->nestedSet->getNode($id, true);
			if($node != false) {
				$nodePermissionSet = $this->checkAdmin($this->getMultiplePermissionSet($id, true), $this->cbPerms);
				if(COLUMN_OPTION_LOCAL_PERMS & $node[options]) {
					if(COLUMN_PERM_EDIT_COLUMN & $nodePermissionSet) {
						$editAllowed = 1;
					}
				} else {
					if((COLUMN_PERM_EDIT_COLUMN & $generalSet) || (COLUMN_PERM_EDIT_COLUMN & $nodePermissionSet)) {
						$editAllowed = 1;
					}
				}
			}
			return $editAllowed;
		}
	}
	
	/**
	 * CB_permission_column::setNestedSetObject()
	 * 
	 * @param $nestedSet
	 * @return 
	 **/
	function setNestedSetObject(&$nestedSet) {
		$this->nestedSet = $nestedSet;
	}
	
	/**
	 * CB_permission_column::getSpecificPermissionSet()
	 * 
	 * @param $id
	 * @return 
	 **/
	function getSpecificPermissionSet($id) {
		$rights = $this->getMultiplePermissionSet($id, true);
		$rights = $this->checkAdmin($rights, $this->cbPerms);
		return $rights;
	}
	
	/**
	 * CB_permission_column::hasAccess()
	 * 
	 * @return 
	 **/
	function hasAccess() {
		$result = false;
		if(COLUMN_PERM_EDIT_COLUMN & $this->allUserPerms) {
			$result = true;
		}
		return $result;
	}
	
	/**
	 * CB_permission_column::checkAdmin()
	 * 
	 * @param $rights
	 * @param $_perms
	 * @return 
	 **/
	function checkAdmin($rights, $perms) {
		if((ADMIN & $perms) || (COL_MNG & $perms)) {
			/*
			* ersten 16 Bits auf 1 setzen, Admin darf immer alles
			*/
			$rights = 65535;
		}
		return $rights;
	}
}
?>
Return current item: Content*Builder