Location: PHPKode > projects > Content*Builder > contentbuilder/plugins/user_managment/usrPortrait.inc.php
<?
	$hasEditPerms = 0;
	if((USR_MNG & $cbPerms) || (ADMIN & $cbPerms) || ($cbUserID == $id)) {
		$hasEditPerms = 1;
	}
	
	if($hasEditPerms) {
	
		if(file_exists($lang_path.$lang_pf."/plugin/media.lang.php")) {
			include($lang_path.$lang_pf."/plugin/media.lang.php");
		} else {
			include($lang_path."en/plugin/media.lang.php");
		}
		
		$tpl->assign( "mediaMessages", $media);
		
		if(empty($id)) {
			exit();
		} else {
			$uQuery = mysql_fetch_object(mysql_query("SELECT * FROM ".TABLE."_profile WHERE userid = '$id'"));
			$portraitID = $uQuery->portraitID;
		}
		
		$myMedia  = new MediaManagement();
		
		
		/*
		* Smarty Template für das Medien Management ableiten
		*/
		$mediaTPL = new Smarty;
		$mediaTPL->template_dir = CB_TEMPLATE_DIR;
		$mediaTPL->compile_dir  = CB_TEMPLATE_DIR."compiled/";
		
		$mediaBranch = $cbOption->getSingleOption('generalMedia');
		$portraitTID = $cbOption->getSingleOption('portraitTID');
		
		$myMedia->mediaText = $media;
		$myMedia->setUserID($cbUserID);
		$myMedia->setLimit('1');				
		$myMedia->setBranchID($mediaBranch);
		$myMedia->setOptionObject($cbOption);
		$myMedia->setTemplateObject($mediaTPL);
		
		$myMedia->tpl->assign("ID", $id);
		$myMedia->tpl->assign(
			array ( "IDNAME"  => array("id"), 
					"IDVALUE" => array($id)
			)
		);
		
		$tpl->assign("ID", $id);
		
		if(isset($_POST[delbox])) {
			$myMedia->deleteFiles($_POST[delbox]);
		}
		
		if(isset($unmainbox)) {
			foreach($unmainbox as $k => $v) {
				$dquery = mysql_query("UPDATE ".TABLE."_profile SET portraitID = '' WHERE userid = '$id'");
			}
		}
			
		if(isset($mainbox)) {
			foreach($mainbox as $k => $v) {
				$dquery = mysql_query("UPDATE ".TABLE."_profile SET portraitID = '$v' WHERE userid = '$id'");
				$portraitID = "$v";
			}
		}
		
		if(!empty($mediaBranch) && !empty($portraitTID)) {
			if($action == "add") {
				// Max. Dateigröße bestimmen
				if(empty($uploadbutton)) {
					$myMedia->mediaTypeID = $portraitTID;
					$myMedia->packUploadTemplate();
					$myMedia->activateTemplate("upload_heading_set");
					$myMedia->activateTemplate("upload_title_set");
					$myMedia->activateTemplate("upload_description_set");
					$myMedia->activateTemplate("upload_keywords_set");
					$mainPluginContent[] = $myMedia->fetchTemplate("upload_form_set");
				} else {
					$myMedia->mediaTypeID = $portraitTID;
					$myMedia->addFileValues(
						array ( "title"       => $_POST[title],
								"description" => $_POST[description],
								"keywords"    => $_POST[keywords]
						)
					);
					$myMedia->moveFiles();
					$display = "overview";
				}
			} else {$display = "overview";}
		} else {
			$display = "error";
			$error[] = $usr_msg["MMConNotConfigured"];
		}
		
		if($display == "overview") {
			$myMedia->mediaTypeID = $portraitTID;
			
			$noUploads = true;
			$fileList = array();
			$fileQuery = mysql_query("SELECT fileID, typeID, branchID, userid, filename, options, insertdate, parameter FROM ".TABLE."_mm_files WHERE typeID = '$portraitTID' AND branchID = '$mediaBranch' ORDER BY filename ASC");
			while($fileRow = mysql_fetch_object($fileQuery)) {
				$date = $myMedia->getDate($fileRow->insertdate);
				
				if($fileRow->fileID == $portraitID) {
					$portraitSelected = "checked";
					$portraitFileName = $fileRow->filename;
				} else { 
					$portraitSelected = ""; 
				}
						
				$files['id'][]      = $fileRow->fileID;
				$files['name'][]    = $fileRow->filename;
				$files['type'][]    = $myMedia->typeArray[$fileRow->typeID];
				$files['user'][]    = $myMedia->userArray[$fileRow->userid];
				$files['date'][]    = $date;
				$files['mainSel'][] = $portraitSelected;
				$noUploads = false;
			} // while
				
			if(!$noUploads) {
				$tpl->assign("portraitListTpl_set", "1");
				$tpl->assign("portraitList",
					array( "FID"         => $files['id'],
						   "NAME"        => $files['name'],
						   "TYPE"        => $files['type'],
						   "DATE"        => $files['date'],
						   "MAINCHECKED" => $files['mainSel'],
						   "BY"          => $files['user']
					)
				);
			}
							
			if(!empty($portraitFileName)) {
				$tpl->assign("userPortrait_set", "1");
				$tpl->assign("userPortrait",
					array ( "BID"              => $mediaBranch,
							"DIRECTORY"        => $myMedia->getBranchDirectory(),
							"FILENAME"         => $portraitFileName
					)
				);
			}
			
			if(!$noUploads) {
				$tpl->assign("submitBox_set", "1");
			}
			$tpl->assign("fileoverview_set", "1");
		} elseif ($display == "error") {
			if(count($error) > 0) {
				$tpl->assign("errorSet", "1");
				$tpl->assign("errorList", $error);
			}
		}
		
		$mainPluginContent[]  = $tpl->fetch($config['templates']."usrPortrait.template", null, "pluginUsr".$cbUserID);
		$mainMessageContent[] = $tpl->fetch($config['templates']."messages.template", null, "pluginUsr".$cbUserID);
	}
?>
Return current item: Content*Builder