class_RMProfileCollection.inc.php 7.28 KB
<?php
/**
 * @file	RMProfileCollection.inc.php
 * @category freeSN
 * @mailto	code [at] netz.coop
 * @version 0.4.200901
 * @link http://netz.coop
 * 
 *  @copyright Copyright by netz.coop e.G. 2015
 *  
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */
class RMProfileCollection extends aLosp {

	private $BasisElementID = null;

	/**
	 * profile collection read list
	 * @var array
	 */
	private $PCAuthReadList = array();

	/**
	 * profile collection write list
	 * @var array
	 */
	private $PCAuthWriteList = array();
	/**
	 *		indirect read rights
	 * @var int	is the ListID for the profile collection ids which have special rights for the BasisElement
	 */
	private $PCAuthReadListID = 0 ;
	/**
	 *		indirect write rights
	 * @var int	is the ListID for the profile collection ids which have special rights for the BasisElement
	 */
	private $PCAuthWriteListID = 0 ;

	public function __toString() {
		return 'obj('.$this->ThisClassName.' BasisElementID('.$this->BasisElementID.') PCAuthReadListID('.$this->PCAuthReadListID.') PCAuthWriteListID('.$this->PCAuthWriteListID.') )';

	}


	public function getPCAuthReadListID() {
		return $this->PCAuthReadListID;
	}
	/**
	 *	@friend RightManagement
	 *	@friend PDORightManagement
	 * @param int $param_PCAuthReadListID
	 */
	public function setPCAuthReadListID($param_PCAuthReadListID) {
		$this->PCAuthReadListID = $param_PCAuthReadListID;
	}
	public function getPCAuthWriteListID() {
		return $this->PCAuthWriteListID;
	}
	/**
	 *	@friend PDORightManagement
	 * @param int $param_PCAuthReadListID
	 */
	public function setPCAuthWriteListID($param_PCAuthWriteListID) {
		$this->PCAuthWriteListID = $param_PCAuthWriteListID;
	}
	public function setPCAuthWriteList(array $param_PCAuthWriteList) {
		$this->PCAuthWriteList =$param_PCAuthWriteList;
	}
	public function setPCAuthReadList(array $param_PCAuthReadList) {
		$this->PCAuthReadList =$param_PCAuthReadList;
	}

	public static function createNewInstance($param_BasisElementID, RightManagement $param_RightManagement) {
		return new RMProfileCollection($param_BasisElementID, $param_RightManagement);
	}

	private $RightManagement = null;
	private function __construct($param_BasisElementID, RightManagement $param_RightManagement) {
		$this->BasisElementID = $param_BasisElementID;
		$this->RightManagement = $param_RightManagement;
	}

	public  function setConstructValues($param_BasisElementID, RightManagement $param_RightManagement) {
		$this->BasisElementID = $param_BasisElementID;
		$this->RightManagement = $param_RightManagement;
	}

	public function getRightManagement() {
		return $this->RightManagement;
	}

	public function setData(Account &$param_HostAccount, iStorable &$param_iStorable, array $param_Data) {
//D::show($param_Data, $this.'-> ReadSelected')			;
		if(array_key_exists('ReadSelected', $param_Data)) {

			foreach($param_Data['ReadSelected'] as $ProfileCollectionBEID) {
				if(!array_key_exists($ProfileCollectionBEID, $this->PCAuthReadList)) {
					$this->PCAuthReadList[$ProfileCollectionBEID] = array();
				}
			}
		} else {
			$this->PCAuthReadList = array();
			$this->PCAuthReadListID = 0;
		}
		if(array_key_exists('WriteSelected', $param_Data)) {
			foreach($param_Data['WriteSelected'] as $ProfileCollectionBEID) {
				if(!array_key_exists($ProfileCollectionBEID, $this->PCAuthWriteList)) {
					$this->PCAuthWriteList[$ProfileCollectionBEID] = array();
				}
			}
		} else {
			$this->PCAuthWriteList = array();
			$this->PCAuthWriteListID = 0;
		}
	}

	public function getPCAuthReadList() {
		return $this->PCAuthReadList;
	}

	public function getPCAuthWriteList() {
		return $this->PCAuthWriteList;
	}



	/**
	 *	wird erstmal nicht mehr aufgerufen 100428 @f
	 *
	 *	@friend PDORightManagement
	 *
	 * @param int $param_PCID
	 * @param array $param_PCID_Array
	 */
	public  function addToPCAuthReadList($param_PCID, array $param_PCID_Array) {
//		D::backtrace("addToPCAuthReadList($param_PCID, array $param_PCID_Array)");
		if(!array_key_exists($param_PCID, $this->PCAuthReadList)) {
			$this->PCAuthReadList[$param_PCID] = $param_PCID_Array;
		}

	}


	public function getObjDOMElement(Account &$param_HostAccount, iStorable &$param_iStorable, DOMDocument $param_DOMDocument, $param_KindOf=null, array $param_DOMElemente=null) {
		$DOMElement = parent::getObjDOMElement($param_HostAccount, $param_iStorable, $param_DOMDocument, $param_KindOf, $param_DOMElemente);

		$DOMElement->setAttribute('label', Language::getWord(get_class($this)));

		$var_CONFIG = CONFIG::getRightManagement();
		/**
		 * @todo $param_HostAccount->getActiveProfileID() != 0 schön machen 10
		 */
		if(array_key_exists('RMProfileCollection', $var_CONFIG) && is_array($var_CONFIG['RMProfileCollection']) && $param_HostAccount->getActiveProfileID() != 0) {
			$var_AvaibleProfileCollectionDOMElement = $DOMElement->appendChild($param_DOMDocument->createElement('AvaibleProfileCollection'));
			foreach($var_CONFIG['RMProfileCollection'] as $var_BCName => $notused1) {
				foreach($param_HostAccount->getActiveProfile()->getClipboard($param_HostAccount, $param_iStorable, $var_BCName)->getObjVar('AttachIDList') as $var_ID => $notused2) {
					$var_PCBE = &MultimediaText::loadElement($param_HostAccount, $param_iStorable, null, $var_ID);
					$var_AvaibleProfileCollectionDOMElement->appendChild($var_PCBE->getShortObjDOMElement($param_HostAccount, $param_iStorable, $param_DOMDocument));
//					D::li($var_PCBE);
				}
			}
		}

		$var_ProfileCollectionReadListDOMElement = $DOMElement->appendChild($param_DOMDocument->createElement('ProfileCollectionReadList'));
		$var_ProfileCollectionReadListDOMElement->setAttribute('PCAuthReadListID', $this->PCAuthReadListID);
		$var_ProfileCollectionReadListDOMElement->setAttribute('label', Language::getWord('ProfileCollectionReadList') );
		foreach($this->PCAuthReadList as $var_ID => $notused) {
			$var_PCBE = &MultimediaText::loadElement($param_HostAccount, $param_iStorable, null, $var_ID);
			$var_ProfileCollectionReadListDOMElement->appendChild($var_PCBE->getShortObjDOMElement($param_HostAccount, $param_iStorable, $param_DOMDocument));
		}

		$var_ProfileCollectionWriteListDOMElement = $DOMElement->appendChild($param_DOMDocument->createElement('ProfileCollectionWriteList'));
		$var_ProfileCollectionWriteListDOMElement->setAttribute('PCAuthWriteListID', $this->PCAuthWriteListID);
		$var_ProfileCollectionWriteListDOMElement->setAttribute('label', Language::getWord('ProfileCollectionWriteList') );
		foreach($this->PCAuthWriteList as $var_ID => $notused) {
			$var_PCBE = &MultimediaText::loadElement($param_HostAccount, $param_iStorable, null, $var_ID);
			$var_ProfileCollectionWriteListDOMElement->appendChild($var_PCBE->getShortObjDOMElement($param_HostAccount, $param_iStorable, $param_DOMDocument));
		}


		return $DOMElement;
	}
}
?>