class_MySql.inc.php 45.2 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170
<?php
/**
 * @file	MySql.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	MySql
 */
class MySql extends PDOProtected  {

	/**
	 * @var array	existierende BasisElement Klassennamen (werden als Cache gespeichert)
	 */
	protected $Cache_ClassNameArray = array();

	/**
	 * @var array	Description from the losp Table here are saved
	 */
	protected $Cache_TableDescription = array();

	/**
	 * @var array	BasisElementID <=> BasisElementClassName Cache
	 */
	protected $Cache_BEID_ClassNameArray = array();

	/**
	 * @var array	Cache der BE BC RightManagement Daten
	 */
	protected $Cache_BEBasisClipboardsRightManagementArray = array();


	/**
	 * @var array of the BasisElementAddonDataBase
	 */
	private static $BasisElementAddonDataBaseArray = array();


	/**
	 * return the BasisElementAddonDataBase object
	 */
	public function &getBasisElementAddonDataBase($param_BEAName) {
		if(!array_key_exists($param_BEAName, self::$BasisElementAddonDataBaseArray) || !is_object(self::$BasisElementAddonDataBaseArray[$param_BEAName])) {
			$BEADBName = $param_BEAName.'BEADB';
			self::$BasisElementAddonDataBaseArray[$param_BEAName] = new  $BEADBName();
		}
		return self::$BasisElementAddonDataBaseArray[$param_BEAName];
	}

	/***	spezielle Portal (MySQL) Funktionen */
	public function install($param_Example) {
		system("mysql --user=".$this->User." --password=".$this->Password." ".$this->Database." < include/SQLDataBase/MySQL_Tables.sql ");
		system("mysql --user=".$this->User." --password=".$this->Password." ".$this->Database." < include/SQLDataBase/MySQL_Function.sql ");
		if($param_Example) {
			echo "<h1>Beispiel</h1>";
			system("mysql --user=".$this->User." --password=".$this->Password." ".$this->Database." < include/SQLDataBase/portal.sql ");
		}
	}




	/**
	 *	Funktion liest Datei ein und führt diese in der Mysql Datenbank aus
	 *
	 *	@attention	Fehler wenn Kommentarzeichen noch in der selben Zeile ist (z.B. select * -- hier darf kein kommentar stehen)
	 *	@attention	noch nicht PDO @deprecated since version number
	 *
	 *	@param		string param_FileBE	Dateiname
	 *	@return		string Fehlerausgabe
	 *	@version	v0
	 *	@date		2007-03-09
	 */
	public function transformFileToDatabase ($param_FileBE) {
		D::li('Funktion hat noch mysql Befehle');

		if (file_exists($param_FileBE)) {
			$sql = file($param_FileBE);
		} else {
			//D::li("Fehler: $param_FileBE existiert nicht",1,1);
			return "Fehler: $param_FileBE existiert nicht";

		}
		$sql_Befehle = array();
		$j=0;
		$var_delimiter = FALSE;
		for($i=0; $i<count($sql); $i++) {
			/**
			 * @new 100325 @f
			 */
			 if(!array_key_exists($j, $sql_Befehle)) {
				$sql_Befehle[$j] = '';
			 }

			if(false === strpos($sql[$i], "--") ) {

				if($var_delimiter) {
					if(FALSE !== strpos($sql[$i], $var_delimiter) ) {

						$var_delimiter = FALSE;
						$j++;
						$i++;
					} else {
						$sql_Befehle[$j] = $sql_Befehle[$j]." ".$sql[$i];
					}
				} else {
					$sql_Befehle[$j] = $sql_Befehle[$j]." ".$sql[$i];
					if(false !== strpos($sql[$i], "DELIMITER") ) {
						$var_delimiter = substr($sql[$i],strpos($sql[$i], "'")+1,(strripos($sql[$i], "'")-(strpos($sql[$i], "'")+1)));
						$j++;
					} else if(false !== strpos($sql[$i], ";") ) {
						$j++;
					}
				}
			}
		}
		$stringResult = "";
		$stringResult .= "<b>Datei (".$param_FileBE.") wird eingelesen und in der Datenbank (".$this->Database.") verarbeitet";
		$stringResult .= "<table width=\"100%\" border=1>";
		$installError = 0;
		for($i=0; $i<count($sql_Befehle); $i++) {

			if(false === strpos($sql_Befehle[$i], "DELIMITER")) {
				$stringResult .= "<tr>";

				$this->PDO_query($sql_Befehle[$i]);

				$stringResult .= "<td valign=top><b>".$i."</b></td>" .
				"<td valign=top><i>".$sql_Befehle[$i]."</i></td>";
				$stringResult .= "</tr>";
				$stringResult .= "<tr>";
				$stringResult .= "<td></td>";
				if(!mysql_error()) {
					$stringResult .= "<td valign=top><b>OK:</b></td>" ;
					$stringResult .= mysql_error();
				} else {
					$stringResult .= "<td valign=top><b>Fehler:".mysql_error()." </b></td>" ;
					$installError++;
					Error::newError('DevError',mysql_error());
				}
				$stringResult .= "</tr>";
			}

		}
		$stringResult .= "</table>";
		if($installError!=0) {
			$stringResult = "<p><strong style=\"color:red;\">Es sind ".$installError." Fehler bei der Installation aufgetreten</strong></p>".$stringResult;
		}
//		return $stringResult;
		return $installError;
	}

	public function &getPublicReadBasisElements(Account &$param_HostAccount, $param_BasisElementName) {
		$var_Tablename = CONFIG::getSQL_Data($param_BasisElementName, 'Tablename');
		$var_query = 'select * from '.$var_Tablename.'' .
					'	inner join losp_BasisElement on MTextID=ID' .
					'	where AuthReadListID=0';

		$stmt = $this->PDO_query($var_query);
		if($stmt) {
			$var_array = array();

			foreach($this->PDO_fetchAll($stmt) as $spalten) {
				$spalten['losp_classname'] = $param_BasisElementName;
				$var_array[] = $spalten;
			}
			$var_ObjArray =& DataTransformator::transformDBTableToObjectList($param_HostAccount, $this, $var_array);
			return $var_ObjArray;
		} else {
			return false;
		}

	}

	public static $count_checkAuthorisationQuery =0;

	public function Account_changePassword($param_ID, $param_OldPassword, $param_NewPassword) {
		$query = "select Password from losp_be_account where ID='".$param_ID."'";
		$stmt = $this->PDO_query($query);
		$row = $this->PDO_getResultRow($stmt);

		if (trim($param_OldPassword) ==  $row["Password"]){
			$query = "update losp_be_account set Password='".$param_NewPassword."' where ID='".$param_ID."'";
			$stmt = $this->PDO_query($query);
			if($stmt) {
				$this->PDO_getResultRow($stmt);
				return TRUE;
			} else return Error::newError('DevError',"Speicher des neuen Passwortes ist fehl geschlagen",$query);
		} else return Error::newError('DevError',"Falsches Passwort","");
	}



	/**
	 *	Funktion lädt eins ($param_only_ID!=0) oder alle Accounts
	 *
	 *	@param	Integer $param_only_ID
	 *	@return	Array
	 */
	public function Account_getAll($param_only_ID){
		$query= "select 'Account' as losp_classname, FirstName, SurName, Street, Streetnumber, City, ZipCode, EMail, ProfileID from losp_be_account ";
		$var_bindValueArray = array();
		if($param_only_ID){
			$query .= " where ID= :ID";
			$var_bindValueArray[':ID'] = $param_only_ID;
		}
		$stmt = $this->PDO_query($query, $var_bindValueArray);
		$tablerow = $this->PDO_fetchAll($stmt);
		return $tablerow;
	}





	public function getBEIDFromColumnValue($param_table, $param_column, $param_value){

		$query = "select MTextID from  ".$param_table." where ".$param_column."=:value ";
		$stmt = $this->PDO_query($query, array( ':value' => $param_value 	));
		if($stmt){
			$spalten = $this->PDO_getResultRow($stmt);
			return $spalten['MTextID'];
		} else {
			return false;
		}

	}





	public function deleteObject($param_Object, Account &$param_HostAccount) {

		if(get_class($param_Object)=="Account") {
			D::backtrace('Account Loeschung derzeit deaktiviert');
			return Error::newError('DevError','NoDeleteBE','Account Loeschung derzeit deaktiviert');

			/** Profile */
		} else if(get_class($param_Object)=="Profile") {
			return $this->deleteProfileFromDB($param_HostAccount, $param_Object);

			/**	FileBE  */
		}else if(get_class($param_Object)=="FileBE" || is_subclass_of($param_Object, 'FileBE')){
			/** Get the mysql tablename and  get path from to file directory to remove file  */

			$var_Link  = $param_Object->getObjVar('Link');
			if($var_Link != NULL)
			{
				$filepath ='files/'.$var_Link;

				if(file_exists($filepath) ){
					unlink($filepath);

					$filepath = str_replace(end(explode('/', $filepath)),  FileBE::$thumb_name.end(explode('/', $filepath)), $filepath);

					if(file_exists($filepath) ){
						unlink($filepath);
					}
				}

			}
			return $this->deleteBasisElementFromDB($param_HostAccount, $param_Object);

			/** MultimediaText */
		} else if(get_class($param_Object)=="MultimediaText" || is_subclass_of($param_Object, 'MultimediaText')) {
			return $this->deleteBasisElementFromDB($param_HostAccount, $param_Object);
		} else  {
			D::h1('DevUser'."nicht implementiert");
		}
	}

	public static $count_loadObject=0;
	/**
	 * @auth
	 * load object from database
	 * @param object Object
	 */
	public function &loadObject( &$param_Object, Account &$param_HostAccount=null, $param_Parameter=null) {
		MySql::$count_loadObject++;

		/**
		 * Config Optionen
		 */
		{

			if(is_subclass_of($param_Object, 'BasisElement') && $var_Config=CONFIG::getMultimediaTextPreferencs(get_class($param_Object) ,'Config')) {
				if(array_key_exists('CallbackFunction', $var_Config) && !empty($var_Config['CallbackFunction'])) {
//					D::li('Notice: CallbackFunction:  wurde bis jetzt noch nicht für '.$param_Object.' benutzt, muss evt. noch ueberarbeitet werden');
					$param_return=array();
					if(array_key_exists('depth', $var_Config['CallbackFunction'])) {
						$var_depth = $var_Config['CallbackFunction']['depth'];
					} else {
						$var_depth = 1;
					}
					TreeManipulator::runDBTree($param_HostAccount, $this, array('ID' => $param_Object->getObjVar('ID')), $param_BasisClipboardname=null, $var_Config['CallbackFunction'], $param_return, $var_depth, $param_KindOfObj=null, $param_State=null, $param_ConditionArray=null, $param_checkWrite=null);
					$param_Object->setVirtualData($param_return);
				}
			} else if(is_subclass_of($param_Object, 'BasisClipboard') && $var_Config=CONFIG::getBasisClipboardPreferencs(get_class($param_Object) ,'Config')) {
				//				D::li('Notice: Config:  wurde bis jetzt noch nicht für '.$param_Object.' benutzt, muss evt. noch ueberarbeitet werden');
			} else if(is_subclass_of($param_Object, 'aBasisElementAddon') && $var_Config=CONFIG::getMultimediaTextPreferencs(get_class($param_Object) ,'Config')) {

				if(array_key_exists('CallbackFunction', $var_Config) && !empty($var_Config['CallbackFunction'])) {
					$param_return=array();
					TreeManipulator::runDBTree($param_HostAccount, $this, array('ID' => $param_Object->getObjVar('Obj')->getObjVar('ID')), $param_BasisClipboardname=null, $var_Config['CallbackFunction'], $param_return, $param_Object->getObjVar('depth'), $param_KindOfObj=null, $param_State=null, $param_ConditionArray=null, $param_checkWrite=null);
					$param_Object->setVirtualData($param_return);
				}
			}
		}

		if((is_subclass_of($param_Object, "MultimediaText")) && $param_Object->getObjVar('ID') && CONFIG::getSQL_Data(get_class($param_Object), 'Tablename')) {

			$param_ConditionArray = array();
			$param_ConditionArray['column'] = "MTextID";
			$param_ConditionArray['from'] = $param_Object->getID();
			$param_ConditionArray['limit'] = "1";
			$param_ConditionArray['operator'] = "=";

			$table = $this->getMultimediaTextData($param_HostAccount, get_class($param_Object), $param_MTextClipboard=null, $param_ConditionArray, $param_checkWrite=true);
			if(is_array($table[0])) {
				DataTransformator::transformDBTableRowToObject($param_HostAccount, $this, $table[0], $param_Object);
			} else {
				$param_Object = false;
			}

		} else if(get_class($param_Object)=="Account") {
			$table = $this->Account_getAll($param_Object->getID());
			if(is_array($table[0])) {
				DataTransformator::transformDBTableRowToObject($param_HostAccount, $this, $table[0],$param_Object);
			}
		} else if(get_class($param_Object)==='RMProfileCollection') {
			$this->loadRMProfileCollection($param_HostAccount, $param_Object);
		} else if(get_class($param_Object)==='RightManagementBC') {
			$var_DBRightManagementValues = $this->getDBRightManagementValues($param_Object->getObjVar('PartOfObj')->getObjVar('ID'));
			$param_Object->setData($param_HostAccount, $this, array('DBRightManagementValues'=> $var_DBRightManagementValues));

		} else if(is_subclass_of($param_Object, 'iBasisDesign')) {
			$var_array = $this->loadValuesTable('losp_BasisElementDesign_values', $param_Object->getObjVar('ID'));
			$var_query = 'select * from losp_BasisElementDesign where ID=:ID ';
			$Resource =$this->PDO_query($var_query, array(':ID' => $param_Object->getObjVar('ID')));
			if($Resource){
				$row = $this->PDO_getResultRow($Resource);
				$row['Values'] = $var_array;
				$param_Object->setData($param_HostAccount, $this, $row);
			}

		} else if(is_subclass_of($param_Object, "BasisClipboard")) {
//D::li('############'.$param_Object);
			$table = $this->getFromClipboard($param_HostAccount, $param_Object->getObjVar("PartOfID"), $param_Object->getPartOfObjVarName(), $param_KindOfObj=null, $param_Object->getObjVar("State"), $param_Object->getObjVar('ConditionArray'), $param_Object->getObjVar("CheckWrite"));

			if(is_array($table)) {
				DataTransformator::transformDBTableRowToObject($param_HostAccount, $this, $table, $param_Object);
			}

		} else if(get_class($param_Object)=="AuthorisationList") {
			if($param_Object->getWriteListID() && !$param_Object->getAuthorisationWriteList()){
				$table = $this->AuthorisationList_selectProfileIDListFrom($param_Object->getWriteListID(), 'WriteAuthorisation');
				if($table){
					$param_Object->setAuthorisationWriteList(DataTransformator::transformDBTableToObjectList($param_HostAccount, $this, $table,'WriteAuthorisation'));
				}
			}
			if($param_Object->getReadListID() && !$param_Object->getAuthorisationReadList()){
				$table = $this->AuthorisationList_selectProfileIDListFrom($param_Object->getReadListID(), 'ReadAuthorisation');
				if($table){
					$param_Object->setAuthorisationReadList(DataTransformator::transformDBTableToObjectList($param_HostAccount, $this, $table, 'ReadAuthorisation'));
				}
			}

		} else if(get_class($param_Object)=="PostOffice") {
		} else if(((get_class($param_Object)=="MultimediaText") || ((is_subclass_of($param_Object, 'MultimediaText')) && $param_Object->getObjVar('ID') && !CONFIG::getSQL_Data(get_class($param_Object), 'Tablename')))) {
			$table = $this->MultimediaText_get($param_HostAccount,$param_Object->getID());
			if(is_array($table) && !empty($table)) {
				DataTransformator::transformDBTableRowToObject($param_HostAccount, $this, $table, $param_Object);
			} else {
				$param_Object = false;
			}

		} else if(is_subclass_of($param_Object, 'aBasisElementAddon')) {
			$var_BEADB = &$this->getBasisElementAddonDataBase(get_class($param_Object));
			$var_BEADB->loadObject($param_HostAccount, $this, $param_Object, $param_Parameter);
		} else  {
			D::li("MySQL->loadObject(".get_class($param_Object).")   Klasse nicht implementiert");
		}
		return $param_Object;
	}

	public function BC_getStates() {

		$stmt = $this->PDO_query('select StateID, State from losp_BasisClipboard_state');
		if($stmt){
			$array = array();
			foreach($this->PDO_fetchAll($stmt) as $row) {
				$array[$row['StateID']] = $row['State'];
			}

			return $array;
		} else {
			return false;
		}
	}

	/**
	 *	@auth
	 *
	 * @param <type> $param_Object
	 * @return <type>
	 */
	public function saveObject( &$param_Object, Account &$param_HostAccount=null){

		if((is_subclass_of($param_Object, "MultimediaText") && $var_Tablename = CONFIG::getSQL_Data(get_class($param_Object), 'Tablename'))) {

			if($param_Object->getID()) {

				$Rights = $this->checkBEAuth($param_HostAccount, $param_Object->getID());
//D::show($Rights, $BasisElement);
				if($Rights['@write'] && Secure::checkObjectAndTransformToSql($param_Object)) {

//					$Columns = split(",", CONFIG::getSQL_Data(get_class($param_Object), 'SelectColumns'));
//					$Columns = array_map("trim", $Columns);
					$Columns = CONFIG::transformStringToArray(CONFIG::getSQL_Data(get_class($param_Object), 'SelectColumns'),'comma');
//D::show($Columns, CONFIG::getSQL_Data(get_class($param_Object), 'SelectColumns'),1,1);

					$var_BindValues = array();
					$query = "UPDATE " .$var_Tablename." SET ";

					$count_i = count($Columns);
					for($i=0; $i<$count_i; $i++) {
						if(0==substr_count(trim($Columns[$i]),' ')) {
							$query .= ' '.$Columns[$i].' = :'.$Columns[$i].', ';
							$var_BindValues[':'.$Columns[$i]] = $param_Object->getObjVar($Columns[$i]);
						}
					}
					$query = substr($query, 0, -2);
					$query .= "  WHERE MTextID = :MTextID ";
					$var_BindValues[':MTextID'] = $param_Object->getID();
//D::show($var_BindValues, $query);
					if($this->PDO_query($query, $var_BindValues) && $this->saveMultimediaText($param_HostAccount, $param_Object))	{
						return $param_Object;
					} else return Error::newError('DevError','NoSaveBE',$query);
				} else {
					return Error::newError('DevError','NoSaveBE','');
				}
			} else {
				$obj = $this->insertMultimediaTextData($param_Object, $param_HostAccount);
				if(is_object($obj)) {
					return $obj;
				} else {
					return Error::newError('DevError','NoSaveBE','');
				}
			}
		} else if((is_subclass_of($param_Object, "BasisDesign"))) {

			if($param_Object->getObjVar('ID') && $param_HostAccount->getActiveProfileID() && $param_Object->getObjVar('Author_ProfileID')==$param_HostAccount->getActiveProfileID()) {

				$query = "UPDATE losp_BasisElementDesign " .
						"	SET " .
						" 		BEClassName='".$param_Object->getObjVar('BEClassName')."', " .
						" 		CSS='".$param_Object->getObjVar('CSS')."', " .
						" 		Miscellaneous='".$param_Object->getObjVar('Miscellaneous')."', " .
						" 		DefaultBC='".$param_Object->getObjVar('DefaultBC')."' " .
						"	where ID = '".$param_Object->getObjVar('ID')."'";

				$var_BindValues = array(
						':BEClassName' => $param_Object->getObjVar('BEClassName'),
						':CSS' => $param_Object->getObjVar('CSS'),
						':ID' => $param_Object->getObjVar('ID'),
						':Miscellaneous' => $param_Object->getObjVar('Miscellaneous'),
						':DefaultBC' => $param_Object->getObjVar('DefaultBC'),
				);

				if(!$this->PDO_query($query, $var_BindValues))	{
					return false;
				}
			} else if($var_id = $this->insertBasisElementDesign($param_Object)) {
//D::ulli('new Design '.$var_id,1,1);
				$param_Object->setObjVar('ID', $var_id);
			} else {
//D::ulli('false Design',1,1);
				return false;
			}D::show($query,'$query');D::show($var_BindValues,'$var_BindValues');D::backtrace();
			$this->setValuesTable('losp_BasisElementDesign_values', $param_Object->getObjVar('ID'), $param_Object->getObjVar('Values'));

		} else if((get_class($param_Object)=='MultimediaText') || ((is_subclass_of($param_Object, 'MultimediaText') && !CONFIG::getSQL_Data(get_class($param_Object), 'SelectColumns')))) {

			if($param_Object->getID()) {
				$Rights = &$this->checkBEAuth($param_HostAccount, $param_Object->getID());

				if($Rights['@write']) {
					$this->saveMultimediaText($param_HostAccount, $param_Object);
				} else {
					return Error::newError('DevError','NoSaveBE','');
				}
			} else {

				$obj = $this->insertMultimediaTextData($param_Object, $param_HostAccount);
				if(is_object($obj)) {
					return $obj;
				} else {
					return Error::newError('DevError','NoSaveBE','');
				}
			}
			return $param_Object;

		} else if(get_class($param_Object)=='AuthorisationList') {
			$this->insertAuthorisationList($param_HostAccount, $param_Object);

		} else if(get_class($param_Object)==='RMProfileCollection') {
//			D::li(__CLASS__.'->'. __FUNCTION__.'  '.$param_Object);
			$this->saveRMProfileCollection($param_HostAccount, $param_Object);

		} else if(get_class($param_Object)=='RightManagementBC') {
			if(!is_array($param_Object->getObjVar('RightManagementValues'))) {
				$param_Object->loadObject($param_HostAccount, $this);
			}

			$this->saveRightManagementBCValues($param_Object->getObjVar('PartOfObj')->getObjVar('ID'), $param_Object->getObjVar('RightManagementValues'));


			/** Speichert Object Account
			 * @todo muss eh noch mal gemacht werden !!!!!!!!!!!!!!!
			 */
		} else if(get_class($param_Object)=="Account") {
			if($param_Object->getID()) {
				if($param_Object->getMainProfile()) {

					$param_Object->getMainProfile()->saveObject($param_HostAccount, $this);
					$ProfileID = $param_Object->getMainProfile()->getID();
				}

				$var_BindValues = array(
						':ProfileID' => $ProfileID,
						':FirstName' => $param_Object->getFirstName(),
						':SurName' => $param_Object->getObjVar('SurName'),
						':Street' => $param_Object->getStreet(),
						':Streetnumber' => $param_Object->getStreetnumber(),
						':City' => $param_Object->getCity(),
						':ZipCode' => $param_Object->getZipCode(),
						':EMail' => $param_Object->getObjVar('EMail'),
						':ID' => $param_Object->getID(),
				);
				$query = "UPDATE losp_be_account SET ProfileID= :ProfileID, FirstName= :FirstName, SurName= :SurName,
							Street= :Street, Streetnumber= :Streetnumber, City= :City,
							ZipCode= :ZipCode, EMail= :EMail
						where ID = :ID";
				if($this->PDO_query($query, $var_BindValues))	{
					return $param_Object;
				} else return Error::newError('DevError','NoSaveBE',$query);
			} else {
				$query = "select max(ID) as ID from losp_be_account";

				$stmt = $this->PDO_query($query);
				if($stmt){
					$row = $this->PDO_getResultRow($stmt);
					$param_Object->setID($row["ID"]+1);
					$query="insert into losp_be_account
							(ID, Password, FirstName, SurName,
								Street, Streetnumber, City, ZipCode, EMail)
							values(	'".$param_Object->getID()."','".$param_Object->getPassword()."', '".$param_Object->getFirstName()."',
									'".$param_Object->getObjVar('SurName')."',
									'".$param_Object->getStreet()."', '".$param_Object->getStreetnumber()."', '".$param_Object->getCity()."', '".$param_Object->getZipCode()."',
									'".$param_Object->getObjVar('EMail')."')";

					if($this->PDO_query($query)){
						if($param_Object->getObjVar('ProfileID')) {
							$ProfileID = $param_Object->getObjVar('ProfileID');
							$query = "UPDATE losp_be_account SET ProfileID='".$ProfileID."' where ID='".$param_Object->getID()."'";
							if(!$this->PDO_query($query))	{
								return false;
							}
						}
						return $param_Object;
					} else {
						return Error::newError('DevError','NoSaveBE',$query);
					}
				} else return Error::newError('DevError','NoSaveBE',$query);
			}

		} else if(is_subclass_of($param_Object, 'aBasisElementAddon')) {
			$var_BEADB = &$this->getBasisElementAddonDataBase(get_class($param_Object));
			$var_BEADB->saveObject($param_HostAccount, $this, $param_Object);

		}
	}

	/**
	 *
	 */
	public function BC_changeState($param_PartOfID, $param_AttachID, $param_StateID) {

		$var_BindValues = array(
			':AttachStateID' => $param_StateID,
			':PartOfID' => $param_PartOfID,
			':AttachID' => $param_AttachID,
		);

		$query ="UPDATE losp_BasisClipboard SET AttachStateID=:AttachStateID WHERE PartOfID=:PartOfID AND AttachID=:AttachID LIMIT 1 ";

		$stmt = $this->PDO_query($query, $var_BindValues);

		if($stmt) {
			$this->PDO_getResultRow($stmt);
			return true;
		} else {
			return false;
		}
	}

	public function Profile_setOnlineState($ID, $State){
		$var_BindValues = array(
			':OnlineState' => $State,
			':MTextID' => $ID,
		);
		$query = "UPDATE ".CONFIG::getSQL_Data('Profile', 'Tablename')." SET OnlineSince='".time()."', OnlineState= :OnlineState
					where MTextID = :MTextID";
		$stmt = $this->PDO_query($query, $var_BindValues);
		if($stmt) {
			$row = $this->PDO_getResultRow($stmt);
			return TRUE;
		}
		else {
			return Error::newError('DevError','',$query);
		}
	}

	/**
	 *	@auth
	 * gibt Liste von Objekten zurück die (rückwärts) mit param_AttachID verknüpft sin
	 *
	 * @param int param_AttachID
	 * @param string param_PartOfObjVar
	 * @param bool param_Backward (true wenn nur Objekte der Klasse geladen werden sollen die PartOfObjVar beinhalten darf [komplettes Objekt wird geladen, bei false nicht])
	 * @param bool param_checkWrite
	 */
	public function BC_getPartOfObject(Account &$param_HostAccount, $param_AttachID, $param_PartOfObjVar, $param_Backward=false, $param_checkWrite=null) {
//D::backtrace("$param_HostAccount, $param_AttachID, $param_PartOfObjVar, $param_Backward=false, $param_checkWrite");
		if($param_Backward) {
			$var_classname = CONFIG::getBC_MultimediaText($param_PartOfObjVar);
			$var_CONFIGMText = CONFIG::getSQL_Data($var_classname, $param_ask=false);


			if($var_CONFIGMText) {
				if(array_key_exists('SelectColumns', $var_CONFIGMText)) {
					$var_SelectColumns = ', MTextID,'.$var_CONFIGMText['SelectColumns'];
				} else {
					$var_SelectColumns = ', MTextID';
				}
				if(array_key_exists('Tablename', $var_CONFIGMText)) {
					$var_Tablename = $var_CONFIGMText['Tablename'];
				} else {
					$var_Tablename =false;
				}
				//				$var_SelectColumns = ', MTextID,'.$var_CONFIGMText['SelectColumns'];
				//				$var_Tablename = $var_CONFIGMText['Tablename'];
			} else {
				$var_SelectColumns = ', MTextID';
				$var_Tablename =false;
			}
		} else {
			$var_SelectColumns = '';
			$var_Tablename = '';
			$var_classname = false;
		}

		$param_BindValues = array(
			':AttachID'	=>	$param_AttachID,
		);

		$var_query =' select ' .
				'	PartOfID, PartOfObjVarID, AttachID, AttachStateID, LinkerProfileID, ' .
				'   ID, Author_ProfileID, Subject,  Text, CreateDate, TagListID, BECategoryChoiceBEID, BECategoryListID, AuthReadListID, AuthWriteListID, PCAuthReadListID, PCAuthWriteListID, BasisElementDesignID, ClassID ' .
				'	 '. $var_SelectColumns.'' .
				'	from losp_BasisClipboard ' .
				'	inner join losp_BasisElement on losp_BasisClipboard.PartOfID=losp_BasisElement.ID ';

		if($var_Tablename) {
			$var_query .= '	inner join '.$var_Tablename.' on losp_BasisClipboard.PartOfID='.$var_Tablename.'.MTextID ';
		}

		$var_query .= $this->getMTextSubQueryAuthString ($param_HostAccount, null, ' AttachID = :AttachID ', $param_ConditionArray=null, $param_checkWrite=null, $param_OnlyGroups=false, $param_OnlyWithWriteRight=false, $param_BindValues, $param_PartOfID=null, $param_BasisClipboardName=null);
//D::show($param_BindValues, __CLASS__.'->'. __FUNCTION__.'  # '.$query);
		$var_array = $this->checkAuthorisationQuery($param_HostAccount, $var_query, $param_BindValues,$param_checkWrite, $param_checkWriteColumnValue=null);

		if($var_array) {
			$i_count = count($var_array);
			for($i=0; $i<$i_count; $i++) {

				if(MultimediaText::getFromMTextArray($var_array[$i]['ID'])) {
					$var_array[$i]['losp_object'] = &MultimediaText::getFromMTextArray($var_array[$i]['ID']);
					$var_array[$i]['ID']  = $var_array[$i]['ID'];
				} else if(class_exists($var_classname)) {
					$var_array[$i]['losp_classname'] = $var_classname;
				} else {
					$var_array[$i]['losp_classname'] = $this->getClassName($var_array[$i]['ClassID']);
					$var_ConditionArray = array();
					$var_ConditionArray['limit'] = '1';
					$var_ConditionArray['column'] = 'ID';
					$var_ConditionArray['operator'] = '=';
					$var_ConditionArray['from'] = $var_array[$i]['ID'];
					$var_MTextArray = $this->getMultimediaTextData($param_HostAccount, $var_array[$i]['losp_classname'], $param_MTextClipboard=null, $var_ConditionArray, $param_checkWrite, $param_OnlyGroups=false, $param_OnlyWithWriteRight=false);

					if(is_array($var_MTextArray[0])) {
						foreach($var_MTextArray[0] as $var_key => $var_value) {
							$var_array[$i][$var_key] = $var_value;
						}
					}
				}
			}
			return DataTransformator::transformDBTableToObjectList($param_HostAccount, $this, $var_array);
		} else {
			return false;
		}
	}
	public function BC_getIndirect(Account &$param_HostAccount, $param_PartOfID, $param_PartOfObjVar, $param_depth, $param_onlyThisClipboard, $param_whichBasisClipboard, $param_State=null, array $param_ConditionArray=null, $param_checkWrite=null) {
		$var_indirectMTexts = $this->BC_getIndirectArray($param_HostAccount, $param_PartOfID, $param_PartOfObjVar, $param_depth, $param_onlyThisClipboard, $param_whichBasisClipboard, $param_State, $param_ConditionArray, $param_checkWrite);
		return DataTransformator::transformDBTableToObjectList($param_HostAccount, $this, $var_indirectMTexts);
	}

	public function BC_getCategoryID($param_Categoryname) {
		if($param_Categoryname) {

			$param_BindValues = array(
				':CategoryName'	=>	$param_Categoryname,
			);
			$var_query = 'select CategoryID from losp_BasisClipboard_category where CategoryName= :CategoryName';
			$Resource = $this->PDO_query($var_query, $param_BindValues);
			if($Resource){
				$row = $this->PDO_getResultRow($Resource);
				if($row) {
					return $row['CategoryID'];
				} else {
					return false;
				}
			} else {
				return false;
			}
		} else {
			return false;
		}
	}

	public function BC_getPartOfObjVarID($param_PartOfObjVar) {
		if($param_PartOfObjVar) {
			$param_BindValues = array(
				':PartOfObjVar'	=>	$param_PartOfObjVar,
			);
			$var_query = 'select PartOfObjVarID from losp_BasisClipboard_objvar where PartOfObjVar= :PartOfObjVar';

			$Resource = $this->PDO_query($var_query, $param_BindValues);
			if($Resource){
				$row = $this->PDO_getResultRow($Resource);
				if($row) {
					return $row['PartOfObjVarID'];
				} else {
					return false;
				}
			} else {
				return false;
			}
		} else {
			return false;
		}
	}

	public function BC_getRow($param_PartOfID=null, $param_AttachID=null, $param_PartOfObjVarID=null, $param_AttachStateID=null, $param_LinkerProfileID=null, $param_CategoryID=null) {
		$query = "select * from losp_BasisClipboard ";
		$param_BindValues = array();

		if($param_PartOfID || $param_AttachID || $param_AttachStateID || $param_LinkerProfileID) {
			$query .= "where ";
			$tmp=false;
			if($param_PartOfID) {
				$query .= " PartOfID= :PartOfID";
				$param_BindValues[':PartOfID']  = $param_PartOfID;
				$tmp=true;
			}
			if($param_PartOfObjVarID) {
				if($tmp) {
					$query .= " and ";
				}
				$query .= " PartOfObjVarID= :PartOfObjVarID";
				$param_BindValues[':PartOfObjVarID']  = $param_PartOfObjVarID;
			}
			if($param_AttachID) {
				if($tmp) {
					$query .= " and ";
				}
				$query .= " AttachID= :AttachID";
				$param_BindValues[':AttachID']  = $param_AttachID;
			}
			if($param_AttachStateID) {
				if($tmp) {
					$query .= " and ";
				}
				$query .= " AttachStateID= :AttachStateID";
				$param_BindValues[':AttachStateID']  = $param_AttachStateID;
			}
			if($param_CategoryID) {
				if($tmp) {
					$query .= " and ";
				}
				$query .= " CategoryID= :CategoryID";
				$param_BindValues[':CategoryID']  = $param_CategoryID;
			}
			if($param_LinkerProfileID) {
				if($tmp) {
					$query .= " and ";
				}
				$query .= " LinkerProfileID= :LinkerProfileID";
				$param_BindValues[':LinkerProfileID']  = $param_LinkerProfileID;
			}
		}


		$var_result = array();
		$Resource = $this->PDO_query($query, $param_BindValues);
		if($Resource){
			$var_result = $this->PDO_fetchAll($Resource);
		} else {
			D::li('WARUM');
		}
		return $var_result;
	}

	/**
	 * @auth
	 *	@deprecated realize at 100125 @f
	 */
	public function confirmWriteRightAspirantTo( Account &$param_HostAccount, $param_PartOfID, $param_AspirantProfileID, $param_State){

		if(is_object($param_PartOfID) && (is_subclass_of($param_PartOfID, "MultimediaText") || get_class($param_PartOfID)==="MultimediaText")) {
			$param_PartOfID = $param_PartOfID->getID();
		}
		if(is_object($param_AspirantProfileID) && (is_subclass_of($param_AspirantProfileID, "MultimediaText") || get_class($param_AspirantProfileID)==="MultimediaText")) {
			$param_AspirantProfileID = $param_AspirantProfileID->getID();
		}

		if($param_State==null) {
			$param_State = "unreaded";
		}
		$param_BindValues = array(
			':PartOfID'	=>	$param_PartOfID,
			':AspirantProfileID'	=>	$param_AspirantProfileID,
			':RequestProfileID'	=>	$param_HostAccount->getActiveProfileID(),
			':State'	=>	$param_State,
		);
		$query="select confirmWriteRightAspirantTo( :PartOfID, :AspirantProfileID, :RequestProfileID, :State) as ID";

		$Resource= $this->PDO_query($query, $param_BindValues);
		if($Resource) {
			$row = $this->PDO_getResultRow($Resource);
			D::backtrace('ist Funktion noch nötig!! 100125');
			return $row["ID"];
		} else {
			return Error::newError('DevError','',$query);
		}
	}

	/**
	 * @auth
	 * Funktion gibt ein Array mit Objektdaten aus der Datenbank zurück die über
	 * die losp_BasisClipboard Tabelle mit param_PartOfID verknüpft sind
	 *
	 *
	 * @param int param_PartOfID
	 * @param string param_PartOfObjVar (BasisClipboardName || * || null)
	 * @param string param_KindOfObj
	 * @param param_State
	 * @param array param_ConditionArray (keys: column, from, limit, direction)
	 * @param bool param_checkWrite
	 * @return array Object Data
	 */
	public function getFromClipboard(Account &$param_HostAccount, $param_PartOfID=false, $param_PartOfObjVar=null, $param_KindOfObj=null, $param_State=null, array $param_ConditionArray=null, $param_checkWrite=null ){
		$var_SPECIALbool = false;
		$var_BasisClipboardNameArray = CONFIG::transformStringToArray($param_PartOfObjVar, 'category');

		$param_BindValues = array();




		//	$param_PartOfObjVar = $var_BasisClipboardNameArray[0];
		$param_checkWrite=true;
		if($param_KindOfObj=='*' || $param_KindOfObj==null) {
			if(!$var_BasisClipboardNameArray[0] || $var_BasisClipboardNameArray[0]=='LinkList') {
				$var_classname = '*';
			} else {
				$var_classname = CONFIG::getBC_MultimediaText($param_PartOfObjVar);
			}
		} else {
			$var_classname = $param_KindOfObj;
		}

		if($var_classname =='*') {


			$query = 'select * from losp_BasisClipboard ' .
					'	INNER JOIN losp_BasisClipboard_objvar ON losp_BasisClipboard_objvar.PartOfObjVarID=losp_BasisClipboard.PartOfObjVarID ' .
					'	INNER JOIN losp_BasisClipboard_state ON losp_BasisClipboard_state.StateID=losp_BasisClipboard.AttachStateID ';

			if(array_key_exists(1, $var_BasisClipboardNameArray) && $var_BasisClipboardNameArray[1]) {
				$query .='	INNER JOIN losp_BasisClipboard_category ON losp_BasisClipboard_category.CategoryID=losp_BasisClipboard.CategoryID ';
			}

			$query .='	INNER JOIN losp_BasisElement ON losp_BasisElement.ID=losp_BasisClipboard.AttachID ';


			if($param_PartOfID) {
				$var_Where = ' PartOfID= :PartOfID ';
				$param_BindValues[':PartOfID']  = $param_PartOfID;
			} else {
				$var_Where = false;
			}

			//			@new
			if($var_BasisClipboardNameArray[0] && $var_BasisClipboardNameArray[0]!='*') {

				if((array_key_exists(1, $var_BasisClipboardNameArray) && strpos($var_BasisClipboardNameArray[1], 'SPECIAL:')!==false) && strpos($var_BasisClipboardNameArray[1], 'NoPartOfID')) {
					$var_Where = false;
				}

				if((array_key_exists(1, $var_BasisClipboardNameArray) && strpos($var_BasisClipboardNameArray[1], 'SPECIAL:')!==false) && strpos($var_BasisClipboardNameArray[1], 'NoPartOfVar')) {
					$var_SPECIALbool = true;
				} else {
					if(array_key_exists(1, $var_BasisClipboardNameArray) && $var_BasisClipboardNameArray[1]) {
						if($var_Where) {
							$var_Where .= ' AND ' ;
						}
						//						$var_Where .='	CategoryName= :CategoryName AND  ';
						$var_Where .='	CategoryName= :CategoryName  ';
						$param_BindValues[':CategoryName']  = $var_BasisClipboardNameArray[1];
					}
					if($var_Where) {
						$var_Where .= ' AND ' ;
					}
					$var_Where .= ' PartOfObjVar= :PartOfObjVar   ';
					$param_BindValues[':PartOfObjVar']  = $var_BasisClipboardNameArray[0];
				}
			}

			$query .= $this->getMTextSubQueryAuthString($param_HostAccount, $param_orderbydefault=null, $var_Where, $param_ConditionArray, $param_checkWrite, $param_OnlyGroups=false, $param_OnlyWithWriteRight=false, $param_BindValues, $param_PartOfID, $param_PartOfObjVar);
//D::show($param_BindValues, __CLASS__.'->'. __FUNCTION__.'  # '.$query);
			$Resource1 = $this->PDO_query($query, $param_BindValues);
			if($Resource1){
				$var_array = array();
				$ConditionArray = array();
				$ConditionArray['limit'] = '1';
				$ConditionArray['column'] = 'ID';
				$ConditionArray['operator'] = '=';

				$i=0;
				foreach($this->PDO_fetchAll($Resource1) as $spalten) {
					$var_right = true;
					if($var_SPECIALbool) {
						if($spalten['CategoryID']) {
							$var_ObjVarCategory = $spalten['PartOfObjVar'].'::'.$spalten['CategoryName'];
						} else {
							$var_ObjVarCategory = $spalten['PartOfObjVar'];
						}
						if(!MultimediaText::getFromMTextArray($spalten['PartOfID'])->getObjVar('RightManagement')->checkReadRightForBasisClipboard($param_HostAccount, $var_ObjVarCategory)) {
							$var_right = false;
						}

//						D::li(MultimediaText::getFromMTextArray($spalten['PartOfID']).' - '.$var_ObjVarCategory.' = '.$spalten['ID']. ' #### '.MultimediaText::getFromMTextArray($spalten['PartOfID'])->getObjVar('RightManagement')->checkReadRightForBasisClipboard($param_HostAccount, $var_ObjVarCategory),1,1);
					}

					if($var_right) {
						if(MultimediaText::getFromMTextArray($spalten['AttachID'])) {
							$var_array[$i] = array();
							$var_array[$i]['losp_object'] = &MultimediaText::getFromMTextArray($spalten['AttachID']);
							$var_array[$i]['ID']  = $spalten['AttachID'];
						} else {
							$ConditionArray['from'] = $spalten['AttachID'];
							$var_tmparray = $this->getMultimediaTextData($param_HostAccount, $var_classname, $var_BasisClipboardNameArray[0], $ConditionArray, $param_checkWrite);
							if(!empty($var_tmparray) ) {
								$var_array[$i] = $var_tmparray[0];
							} else {
								$i--;
							}
						}
						if(is_array($var_array[$i])) {
							//D::show($spalten);
							if($spalten['CategoryID']) {
								$var_array[$i]['CategoryID'] = $spalten['CategoryID'];
								$var_array[$i]['CategoryName'] = $spalten['CategoryName'];
							}

							$var_array[$i]['CDate'] = $spalten['CDate'];
							$var_array[$i]['PartOfID'] = $spalten['PartOfID'];
							$var_array[$i]['PartOfObjVarID'] = $spalten['PartOfObjVarID'];
							$var_array[$i]['AttachStateID'] = $spalten['AttachStateID'];
							$var_array[$i]['StateID'] = $spalten['StateID'];
							$var_array[$i]['State'] = $spalten['State'];
							$var_array[$i]['PartOfObjVar'] = $spalten['PartOfObjVar'];
							$var_array[$i]['AttachID'] = $spalten['AttachID'];
							$var_array[$i]['LinkerProfileID'] = $spalten['LinkerProfileID'];

						}


						$i++;
					}
				}
			}
			return $var_array;

		} else {

			if(is_subclass_of($var_classname, 'MultimediaText') || ((is_object($var_classname) && get_class($var_classname)=='MultimediaText') || ($var_classname=='MultimediaText') )) {
				$TableName = CONFIG::getSQL_Data($var_classname, 'Tablename');

				if((boolean) CONFIG::getSQL_Data($var_classname, 'SelectColumns')) {
					$SelectColumns = CONFIG::getSQL_Data($var_classname, 'SelectColumns') .", ";
				} else {
					$SelectColumns = '';
				}
				$SelectColumns .= 'PartOfID, AttachID, AttachStateID, StateID, State, PartOfObjVar, ';

				if((boolean) CONFIG::getSQL_Data($var_classname, 'Joins')) {
					$SelectJoins = CONFIG::getSQL_Data($var_classname, 'Joins') ." ";
				} else {
					$SelectJoins = ' ';
				}
				$SelectJoins .= ' INNER JOIN  losp_BasisClipboard_state on losp_BasisClipboard_state.StateID = losp_BasisClipboard.AttachStateID ' .
								' INNER JOIN  losp_BasisClipboard_objvar on losp_BasisClipboard_objvar.PartOfObjVarID = losp_BasisClipboard.PartOfObjVarID ' .
								'  ';

				if($TableName) {
					$SelectColumns .= ' ClassID, ';
					$SelectJoins .= ' inner join '.$TableName.' on '.$TableName.'.MTextID = losp_BasisClipboard.AttachID ';
					$MTextSubQueryString = ' inner join losp_BasisElement on losp_BasisElement.ID='.$TableName.'.MTextID ';
				} else {
					$MTextSubQueryString = ' inner join losp_BasisElement on losp_BasisElement.ID=losp_BasisClipboard.AttachID ';
				}

				if(array_key_exists(1, $var_BasisClipboardNameArray)  && $var_BasisClipboardNameArray[1]) {
					$SelectJoins .='	INNER JOIN losp_BasisClipboard_category ON losp_BasisClipboard_category.CategoryID=losp_BasisClipboard.CategoryID ';
					$SelectColumns .= 'losp_BasisClipboard_category.CategoryID as CategoryID, CategoryName, ';
				}

				$param_OnlyGroups=null;
				$param_OnlyWithWriteRight=null;
				$var_where = array();
				$var_where[0] = CONFIG::getSQL_Data($var_classname, 'Where');

				if($var_where[0]) {
					$var_where[0] .= ' AND ';
				}

				$var_NOTAND = true;
				$var_where[1] = '';
				if((is_subclass_of($var_classname, 'FileBE') ||$var_classname=='FileBE') && $param_ConditionArray['FileManager']==TRUE ){
					$var_where[1] .= " losp_BasisClipboard.LinkerProfileID = :LinkerProfileID ";
					$param_BindValues[':LinkerProfileID']  = $param_HostAccount->getActiveProfileID();
				} else if($param_PartOfID) {
					$var_where[1] .= " losp_BasisClipboard.PartOfID = :PartOfID ";
					$param_BindValues[':PartOfID']  = $param_PartOfID;
				} else {
					$var_NOTAND = false;
				}

				if($var_BasisClipboardNameArray[0]!=null && $var_BasisClipboardNameArray[0]!='*') {
					$var_where[2] = '';
					if($var_NOTAND) {
						$var_where[2] .= ' AND ';
					}
					$var_where[2] .= "  losp_BasisClipboard_objvar.PartOfObjVar= :PartOfObjVar";
					$param_BindValues[':PartOfObjVar']  = $var_BasisClipboardNameArray[0];
				}

				if(array_key_exists(1, $var_BasisClipboardNameArray)  && $var_BasisClipboardNameArray[1]) {
					if($var_NOTAND) {
						$var_where[2] .= ' AND ';
					}
					$var_where[2] .=' losp_BasisClipboard_category.CategoryName= :CategoryName ';
					$param_BindValues[':CategoryName']  = $var_BasisClipboardNameArray[1];
				}

				$query =" SELECT distinct '".$var_classname."' as losp_classname, LinkerProfileID, ".$SelectColumns.$this->getMTextSubQueryString($TableName)." ".
						"	FROM losp_BasisClipboard " .$SelectJoins ;

				$query .=	" ".$MTextSubQueryString.$this->getMTextSubQueryAuthString ($param_HostAccount, CONFIG::getSQL_Data($var_classname, 'OrderByDefault'), $var_where, $param_ConditionArray, $param_checkWrite, $param_OnlyGroups, $param_OnlyWithWriteRight, $param_BindValues, $param_PartOfID, $param_PartOfObjVar);
//D::show($param_BindValues, __CLASS__.'->'. __FUNCTION__.'  # '.$query,1,1);

				$var_DataArray = $this->checkAuthorisationQuery($param_HostAccount, $query, $param_BindValues,$param_checkWrite);

				if($var_DataArray) {
					return $var_DataArray;
				} else {
					false;
				}

			} else {
				D::li("getFromClipboard_old wurde geloescht       $TableName = CONFIG::getSQL_Data(<b>$var_classname</b>, 'Tablename')",1);
				D::ulli('if(is_subclass_of('.$var_classname.', MultimediaText)['.is_subclass_of($var_classname, 'MultimediaText').'] || ((is_object('.$var_classname.')['.is_object($var_classname).'] && get_class('.$var_classname.')==MultimediaText) || ('.$var_classname.'==MultimediaText) ))');
			}
		}
	}

	public function &loadAllObjects(Account &$param_HostAccount, $param_Class,  $param_MTextClipboard=null, $param_ConditionArray , $param_checkWrite=null,  $param_OnlyGroups=false, $param_OnlyWithWriteRight=false) {

		if(CONFIG::getSQL_Data($param_Class, 'Tablename')) {
			$table = $this->getMultimediaTextData($param_HostAccount, $param_Class , $param_MTextClipboard, $param_ConditionArray, $param_checkWrite, $param_OnlyGroups, $param_OnlyWithWriteRight);
//									  transformDBTableToObjectList(Account &$param_HostAccount, iStorable &$param_iStorable, $tablerow, $KindOf=null, $PartOf=null, array &$out_ObjecCloakArray = null){
			return DataTransformator::transformDBTableToObjectList($param_HostAccount, $this, $table, $param_Class, 0);
		}


		if(($param_Class==CONSTKindOf::ACCOUNT) || ($param_Class=="Account") ) {
			return DataTransformator::transformDBTableToObjectList($this,$this->Account_getAll(0), $param_RequestProfileID, $param_Class, 0);
		} else if(($param_Class==CONSTKindOf::PROFILE)  || ($param_Class=="Profile")) {
			return DataTransformator::transformDBTableToObjectList($this,$this->Profile_getAll($param_RequestProfileID, $param_MTextClipboard,  $param_ConditionArray, $param_checkWrite,  $param_OnlyGroups, $param_OnlyWithWriteRight),$param_RequestProfileID, $param_Class, 0);
		} else if((($param_Class=="MultimediaText") || $param_Class==CONSTKindOf::MULTIMEDIATEXT)) {
			D::h1("Funktion muss noch gefüllt werden");
		}
	}

	public static $count_getMultimediaTextData=0;
	/**
	 * @auth
	 *	Funktion gibt ein Array mit Objektdaten aus der Datenbank zurück
	 *
	 *
	 *	@param string param_classname
	 *	@param param_MTextClipboard (until now not relevant)
	 *	@param array param_ConditionArray (keys: column, from, limit, direction)
	 *	@param bool param_checkWrite
	 *	@param boll param_OnlyGroups
	 *	@param bool param_OnlyWithWriteRight
	 * 	@return	 array Object Data
	 */
	public function getMultimediaTextData(Account &$param_HostAccount, $param_classname, $param_MTextClipboard=null, $param_ConditionArray=null, $param_checkWrite=true, $param_OnlyGroups=false, $param_OnlyWithWriteRight=false) {
		self::$count_getMultimediaTextData++;
		$param_BindValues = array();
		$param_checkWrite=true;
		if((($param_classname == '*') || (!$param_classname)) && array_key_exists('column', $param_ConditionArray)
			&& array_key_exists('from', $param_ConditionArray) && array_key_exists('limit', $param_ConditionArray)
			&& $param_ConditionArray['column'] == 'ID' && $param_ConditionArray['from']) {
			$param_classname = $this->getClassNameFromMTextID($param_ConditionArray['from']);
		}
		$query = $this->getMTextQuery($param_HostAccount, $param_classname, $param_ConditionArray, $param_checkWrite, $param_OnlyGroups, $param_OnlyWithWriteRight, $param_MTextClipboard, $param_BindValues);
		$var_DataArray = $this->checkAuthorisationQuery($param_HostAccount, $query, $param_BindValues,$param_checkWrite);
		if($var_DataArray) {
			return $var_DataArray;
		} else {
			return false;
		}
	}
}
?>