public function getArrayTreeEmployee($id = null, $includeRoot = true, $includeBlocked = false, $includeFields = null) {
		$cachePath = 'employees_tree_arr_' . md5(serialize(func_get_args()));
		$cached = Cache::read($cachePath, CAKE_LDAP_CACHE_KEY_TREE_EMPLOYEES);
		if ($cached !== false) {
			return $cached;
		}

		$result = [];
		$conditions = $this->_getConditionsForEmployeeTreeInfo($id, $includeRoot, $includeBlocked);
		if ($conditions === false) {
			return $result;
		}

		if (empty($includeFields)) {
			$includeFields = [];
		} elseif (!is_array($includeFields)) {
			$includeFields = [$includeFields];
		}

		$fields = [
			$this->alias . '.id',
			$this->alias . '.parent_id',
			$this->alias . '.lft',
			$this->alias . '.rght',
			$this->Employee->alias . '.id',
			$this->Employee->alias . '.' . $this->Employee->displayField
		];
		if ($this->Employee->hasField(CAKE_LDAP_LDAP_ATTRIBUTE_TITLE)) {
			$fields[] = $this->Employee->alias . '.' . CAKE_LDAP_LDAP_ATTRIBUTE_TITLE;
		}
		if ($includeBlocked && $this->Employee->hasField('block')) {
			$fields[] = $this->Employee->alias . '.block';
		}
		if (!empty($includeFields)) {
			$fields = array_values(array_unique(array_merge($fields, $includeFields)));
		}
		$order = [
			$this->alias . '.lft' => 'asc'
		];
		$contain = [
			'Employee'
		];
		$data = $this->find('threaded', compact('conditions', 'fields', 'order', 'contain'));
		if ($data !== false) {
			$result = $data;
		}

		Cache::write($cachePath, $result, CAKE_LDAP_CACHE_KEY_TREE_EMPLOYEES);

		return $result;
	}
public function getArrayTreeEmployee($id = null, $includeRoot = true, $includeBlocked = false, $includeFields = null) {
		$cachePath = 'employees_tree_arr_' . md5(serialize(func_get_args()));
		$cached = Cache::read($cachePath, CAKE_LDAP_CACHE_KEY_TREE_EMPLOYEES);
		if ($cached !== false) {
			return $cached;
		}

		$result = [];
		$conditions = $this->_getConditionsForEmployeeTreeInfo($id, $includeRoot, $includeBlocked);
		if ($conditions === false) {
			return $result;
		}

		if (empty($includeFields)) {
			$includeFields = [];
		} elseif (!is_array($includeFields)) {
			$includeFields = [$includeFields];
		}

		$fields = [
			$this->alias . '.id',
			$this->alias . '.parent_id',
			$this->alias . '.lft',
			$this->alias . '.rght',
			$this->Employee->alias . '.id',
			$this->Employee->alias . '.' . $this->Employee->displayField
		];
		if ($this->Employee->hasField(CAKE_LDAP_LDAP_ATTRIBUTE_TITLE)) {
			$fields[] = $this->Employee->alias . '.' . CAKE_LDAP_LDAP_ATTRIBUTE_TITLE;
		}
		if ($includeBlocked && $this->Employee->hasField('block')) {
			$fields[] = $this->Employee->alias . '.block';
		}
		if (!empty($includeFields)) {
			$fields = array_values(array_unique(array_merge($fields, $includeFields)));
		}
		$order = [
			$this->alias . '.lft' => 'asc'
		];
		$contain = [
			'Employee'
		];
		$data = $this->find('threaded', compact('conditions', 'fields', 'order', 'contain'));
		if ($data !== false) {
			$result = $data;
		}

		Cache::write($cachePath, $result, CAKE_LDAP_CACHE_KEY_TREE_EMPLOYEES);

		return $result;
	}
public function getArrayTreeEmployee ( $ id = null , $ includeRoot = true , $ includeBlocked = false , $ includeFields = null ) { $ cachePath = 'employees_tree_arr_' . md5 ( serialize ( func_get_args ( ) ) ) ; $ cached = Cache :: read ( $ cachePath , CAKE_LDAP_CACHE_KEY_TREE_EMPLOYEES ) ; if ( $ cached !== false ) { return $ cached ; } $ result = [ ] ; $ conditions = $ this -> _getConditionsForEmployeeTreeInfo ( $ id , $ includeRoot , $ includeBlocked ) ; if ( $ conditions === false ) { return $ result ; } if ( empty ( $ includeFields ) ) { $ includeFields = [ ] ; } elseif ( ! is_array ( $ includeFields ) ) { $ includeFields = [ $ includeFields ] ; } $ fields = [ $ this -> alias . '.id' , $ this -> alias . '.parent_id' , $ this -> alias . '.lft' , $ this -> alias . '.rght' , $ this -> Employee -> alias . '.id' , $ this -> Employee -> alias . '.' . $ this -> Employee -> displayField ] ; if ( $ this -> Employee -> hasField ( CAKE_LDAP_LDAP_ATTRIBUTE_TITLE ) ) { $ fields [ ] = $ this -> Employee -> alias . '.' . CAKE_LDAP_LDAP_ATTRIBUTE_TITLE ; } if ( $ includeBlocked && $ this -> Employee -> hasField ( 'block' ) ) { $ fields [ ] = $ this -> Employee -> alias . '.block' ; } if ( ! empty ( $ includeFields ) ) { $ fields = array_values ( array_unique ( array_merge ( $ fields , $ includeFields ) ) ) ; } $ order = [ $ this -> alias . '.lft' => 'asc' ] ; $ contain = [ 'Employee' ] ; $ data = $ this -> find ( 'threaded' , compact ( 'conditions' , 'fields' , 'order' , 'contain' ) ) ; if ( $ data !== false ) { $ result = $ data ; } Cache :: write ( $ cachePath , $ result , CAKE_LDAP_CACHE_KEY_TREE_EMPLOYEES ) ; return $ result ; }
Return tree of subordinate employees

@param int|string $id ID of record as root element
@param bool $includeRoot If True, include root element in result
@param bool $includeBlocked If False, include only non-blocked employees.
@param array|string $includeFields List of fields for encluding to tree.
@return array Return tree of subordinate employees.
Return tree of subordinate employees