Location: PHPKode > projects > Content*Builder > contentbuilder/plugins/user_managment/usrGroup2.inc.php
<?php
	$hasEditPerms = 0;
	if((USR_MNG & $cbPerms) || (ADMIN & $cbPerms)) {
		$hasEditPerms = 1;
	}
	
	if($hasEditPerms) {
		// Aktionen der Gruppenübersichtsseite (Liste) verarbeiten
		if(empty($groupSub)) {
		    // Fall: Gruppen Löschen
			if(!empty($_GET[deleteID]) && ereg("(^[0-9]*$)", $_GET[deleteID])) {
				$delGroupData = mysql_fetch_object(mysql_query("SELECT * FROM ".TABLE."_usergroups WHERE groupID = '".$_GET[deleteID]."'"));
				$query = mysql_query("DELETE FROM ".TABLE."_usergroups WHERE groupID = '".$_GET[deleteID]."'");
				$query = mysql_query("DELETE FROM ".TABLE."_perms WHERE permID = '".$delGroupData->permID."'");
			}
			// Fall: Gruppe hinzufügen
			if(!empty($_POST[addGroup]) && $_POST[groupname] != "") {
				$getgroup = mysql_query("SELECT * FROM ".TABLE."_usergroups ORDER BY groupID ASC");
				$counter = 1;
				$idfound = false;
				while($groups = mysql_fetch_array($getgroup)) {
					if($groups[groupID] != $counter && $idfound == false) {
						$idfound = true;
						$newID = $counter;
					}
					++$counter;
				}
				if($idfound == false) {
					$idfound = true;
					$newID = $counter;
				}
				$dateadd = date("Y-m-d H:i:s");
				$permID  = md5($dateadd); // UserID wird aus dem aktuellen Datum erzeugt.
				
				$query = mysql_query("INSERT INTO ".TABLE."_perms (permID, system) VALUES ('$permID', '0')");
				$query = mysql_query("INSERT INTO ".TABLE."_usergroups (groupID, permID, name, groupType) VALUES ('$newID', '$permID', '".$_POST[groupname]."', '".$_POST[grouptype]."')");
			}
	        // Anzeige der Liste vorbereiten und Liste folgend ausgeben	
			$getgroup = mysql_query("SELECT * FROM ".TABLE."_usergroups ORDER BY groupID ASC");
			$counter = 1;
			while($cad = mysql_fetch_array($getgroup)) {
				$overview_row["GROUPNAME"][] = $cad["name"];
				$overview_row["GROUPID"][]   = $cad["groupID"];
				$overview_row["GROUPNR"][]   = $counter;
				$overview_row["GROUPTYPE"][] = $cbUser->groupTypesAllowed[$cad["groupType"]];
				$groupSet = true;
				++$counter;
			}
			$tpl->assign("overview_row", $overview_row);
			$tpl->assign("overview_row_set", "1");
			
			if($counter == 1) {
				$message[] = $usr_msg["msgNoGroup"];
				$tpl->assign("overview_row_set", "0");
			}
			
			$tpl->assign("overview_set", "1");
			// Ende Ausgabe Gruppenübersicht
			
		} elseif($groupSub == 1) { // SubDialog: Gruppe modifizieren
		   // modifizierte Daten aus Formular entgegenehmen und verarbeiten
			if(!empty($_POST[modGroup]) && ereg("(^[0-9]*$)", $_POST[groupID])) {
				$mGroupData  = mysql_fetch_object(mysql_query("SELECT * FROM ".TABLE."_usergroups WHERE groupID = '$groupID'"));
				$mGroupPerms = mysql_fetch_object(mysql_query("SELECT * FROM ".TABLE."_perms WHERE permID = '".$mGroupData->permID."'"));
				$gp = $mGroupPerms->system;
				
				if(!(ADMIN & $cbPerms)) {
					if(ART_SET & $cbPerms)       { if(isset($artset)) { $gp |= ART_SET; } else { $gp &= ~ART_SET; } }
					if(HEAD_NEWS & $cbPerms)     { if(isset($headnews)) { $gp |= HEAD_NEWS; } else { $gp &= ~HEAD_NEWS; } }
					if(USR_MNG & $cbPerms)       { if(isset($usermanagement)) { $gp |= USR_MNG; } else { $gp &= ~USR_MNG; } }
					if(COL_MNG & $cbPerms)       { if(isset($folder_mng)) { $gp |= COL_MNG; } else { $gp &= ~COL_MNG; } }
					if(SET_GEN & $cbPerms)       { if(isset($set_gen)) { $gp |= SET_GEN; } else { $gp &= ~SET_GEN; } }
					if(SET_LOG & $cbPerms)       { if(isset($set_log)) { $gp |= SET_LOG; } else { $gp &= ~SET_LOG; } }
					if(SYS_MSG & $cbPerms)       { if(isset($sys_msg)) { $gp |= SYS_MSG; } else { $gp &= ~SYS_MSG; } }
					if(V_LOG & $cbPerms)         { if(isset($v_log)) { $gp |= V_LOG; } else { $gp &= ~V_LOG; } }
					if(UPLOAD & $cbPerms)        { if(isset($f_up)) { $gp |= UPLOAD; } else { $gp &= ~UPLOAD; } }
					if(HEAD_NEWS_ALL & $cbPerms) { if(isset($headnews_all)) { $gp |= HEAD_NEWS_ALL; } else { $gp &= ~HEAD_NEWS_ALL; } }
				} else {
					if(isset($admin))          { $gp |= ADMIN; }   else { $gp &= ~ADMIN; }
					if(isset($artset))         { $gp |= ART_SET; } else { $gp &= ~ART_SET; }
					if(isset($headnews))       { $gp |= HEAD_NEWS;}else { $gp &= ~HEAD_NEWS; }
					if(isset($usermanagement)) { $gp |= USR_MNG; } else { $gp &= ~USR_MNG; }
					if(isset($folder_mng))     { $gp |= COL_MNG; } else { $gp &= ~COL_MNG; }
					if(isset($set_gen))        { $gp |= SET_GEN; } else { $gp &= ~SET_GEN; }
					if(isset($set_log))        { $gp |= SET_LOG; } else { $gp &= ~SET_LOG; }
					if(isset($sys_msg))        { $gp |= SYS_MSG; } else { $gp &= ~SYS_MSG; }
					if(isset($v_log))          { $gp |= V_LOG; }   else { $gp &= ~V_LOG; }
					if(isset($f_up))           { $gp |= UPLOAD; }  else { $gp &= ~UPLOAD; }
					if(isset($headnews_all))   { $gp |= HEAD_NEWS_ALL; } else { $gp &= ~HEAD_NEWS_ALL; }
					
					// ggf. GroupType aktualisieren ..
					if ( (isset($grouptype)) && ($mGroupData->groupType != constant($grouptype) )){
					    $sql="update ".TABLE."_usergroups set groupType='".constant($grouptype)."' where groupID = '".$groupID."'";
					    $query=mysql_query($sql);
					}
				}
				$query = mysql_query("UPDATE ".TABLE."_perms SET system = '$gp' WHERE permID = '".$mGroupData->permID."'");
			}
			
			// Anzeige der Gruppenrechte vorbereiten und ausgeben ...
			$mGroupData  = mysql_fetch_object(mysql_query("SELECT * FROM ".TABLE."_usergroups WHERE groupID = '$groupID'"));
			$mGroupPerms = mysql_fetch_object(mysql_query("SELECT * FROM ".TABLE."_perms WHERE permID = '".$mGroupData->permID."'"));
			$gp = $mGroupPerms->system;
			if(ADMIN & $gp)         { $tpl->assign("CHK_ADMIN",    "checked"); }
			if(ART_SET & $gp)       { $tpl->assign("CHK_ARTSET",   "checked"); }
			if(HEAD_NEWS & $gp)     { $tpl->assign("CHK_HEADNEWS", "checked"); }
			if(HEAD_NEWS_ALL & $gp) { $tpl->assign("CHK_HEADNALL", "checked"); }
			if(UPLOAD & $gp)        { $tpl->assign("CHK_FUP",      "checked"); }
			if(COL_MNG & $gp)       { $tpl->assign("CHK_FOLDERMANAGE", "checked"); }
			if(SYS_MSG & $gp) 	    { $tpl->assign("CHK_SYSMSG",   "checked"); }
			if(USR_MNG & $gp)       { $tpl->assign("CHK_USRMANAGE","checked"); }
			if(SET_GEN & $gp)       { $tpl->assign("CHK_SETGEN",   "checked"); }
			if(SET_LOG & $gp)       { $tpl->assign("CHK_SETLOG",   "checked"); }
			if(V_LOG   & $gp)       { $tpl->assign("CHK_VLOG",     "checked"); }		
			
			$tpl->assign("modify",
				array ( "DISPLAY_GROUPNAME" => $mGroupData->name,
						"ID"                => $groupID
				)
			);
				  
			// adding grouptype rollup data ...
			foreach ($cbUser->groupTypesAllowed as $k => $v){
			    //print_r($cbUser->groupTypesAllowed);
			    $rollup["TYPEID"][]=$k;
			    $rollup["TYPENAME"][]=$v;
			    if (constant($k) == $mGroupData->groupType) {
	                $rollup["TYPESELECTED"][]="SELECTED";
	            }else{
	                $rollup["TYPESELECTED"][]="";
	            }
			}
			$tpl->assign("rollup_grouptype", $rollup);
			
			$tpl->assign("modify_set", "1");
		}
		
		if(count($error) > 0) {
			$tpl->assign("errorSet", "1");
			$tpl->assign("errorList", $error);
		}
		if(count($message) > 0) {
			$tpl->assign("messageSet", "1");
			$tpl->assign("messageList", $message);
		}
		
		$mainPluginContent[]  = $tpl->fetch($config['templates']."userGroup2.template", null, "pluginUsr".$cbUserID);
		$mainMessageContent[] = $tpl->fetch($config['templates']."messages.template", null, "pluginUsr".$cbUserID);
	}
?>
Return current item: Content*Builder