Location: PHPKode > projects > Content*Builder > contentbuilder/plugins/article2/headlineManager.inc.php
<?php
#################################
# Netbuilder-Headlinemanagement #
#################################
require_once($cbDirLib."CB_pageSplit.class.php");

$errorList = array();
$messageList = array();
	
if(!(ADMIN & $cbPerms)) {
	if(!(HEAD_NEWS_ALL & $cbPerms) && !(HEAD_NEWS & $cbPerms)) {
		$errorList[] = $error_msg["permission-denied"];
	}
}	
	
if(count($errorList) == 0) {
	if(empty($mod)) {
		if(isset($newheadline)) {
			//insert into database
			$userquery = mysql_fetch_array(mysql_query("SELECT * FROM ".TABLE."_user WHERE name = '$HTTP_SESSION_VARS[user]'"));
			$pf = $userquery["initial"];
			$zeit = date("YmdHis");
			$id = md5($zeit);
			if(isset($headline) AND isset($content)) {
				if((strlen($content) > 20) AND (!empty($headline))) {
					$query = mysql_query("INSERT INTO ".TABLE."_headlines VALUES ('$id','$headline','$content','$zeit','$pf','0')");
				} else {
					$query = false;
					$toshort = 1;
				}
			}
			if(!$query) {
				if(isset($toshort)) {
					$errorList[] = $amError["text_short"];
				} else {
					$errorList[] = $amError["db_query"];
				}
			} else {
				$messageList[] = $success_msg["headline_create"];
				// Log user actions
				cb_log(2);
			}
		}
	} else {
		if(isset($modifycreate)) {
			// Modifying database entries
			$userquery = mysql_fetch_array(mysql_query("SELECT * FROM ".TABLE."_user WHERE name = '$HTTP_SESSION_VARS[user]'"));
			$pf = $userquery["initial"];
			$zeit = date("YmdHis");
			if(isset($headline) AND isset($content)) {
				if((strlen($content) > 20) AND (!empty($headline))) {
					$query = mysql_query("REPLACE INTO ".TABLE."_headlines VALUES ('$id','$headline','$content','$zeit','$pf','0')");
				} else {
					$query = false;
					$toshort = 1;
				}
			}
			if(!$query) {
				if(isset($toshort)) {
					$errorList[] = $amError["text_short"];
				} else {
					$errorList[] = $amError["db_query"];
				}
			} else {
				$messageList[] = $success_msg["headline_modify"];
				// Log user actions
				cb_log(4);
			}
		}
	}

	if(is_array($delbox)) {
		foreach($delbox as $v) {
			$dquery = mysql_query("DELETE FROM ".TABLE."_headlines WHERE headlineid = '$v'");
		}
		cb_log(3);
	}
	
	if(!preg_match("/^([1-9]+[0-9]*)$/", $limit)) { $limit = 3; }
	if(!preg_match("/^([1-9]+[0-9]*)$/", $offset)) { $offset = 0; }

	$getuser = mysql_fetch_assoc(mysql_query("SELECT * FROM ".TABLE."_user WHERE userid = '$cbUserID'"));
	$pref = $getuser["initial"];
	$usern = $getuser["name"];

	if((HEAD_NEWS & $cbPerms) || (HEAD_NEWS_ALL & $cbPerms) || (ADMIN & $cbPerms)) {
		if(!(HEAD_NEWS_ALL & $cbPerms) || (ADMIN & $cbPerms)) {
			$query_where = "WHERE prf = '$pref'";
			$queryt = mysql_query("SELECT * FROM ".TABLE."_headlines
			$query_where ORDER BY datum DESC LIMIT $offset,$limit");
		}
		if((MOD_ALL & $cbPerms) || !(ADMIN & $cbPerms)){
			$query_where = "";
			$queryt = mysql_query("SELECT * FROM ".TABLE."_headlines ORDER BY datum DESC LIMIT $offset,$limit");
		}

		if(!$queryt){
			$errorList[] = $amError["no_user_article"];
		} else {
			$result = mysql_query("SELECT COUNT(*) FROM ".TABLE."_headlines $query_where");
			// Page Split Objekt anlegen
			$pageSplitObj = & new CB_pageSplit($limit, $offset, mysql_num_rows($result));
 
 			$counter = 0;
			while($getquery = mysql_fetch_array($queryt)) {
				$tempTitle = substr($getquery["headline"],0,30);
				if(strlen($getquery["title"]) > 30) {
					$tempTitle .= "...";
				}

				$datum = substr($getquery["datum"],0,10);
				$d1 = substr($datum,0,4);
				$d2 = substr($datum,5,2);
				$d3 = substr($datum,8,2);
				$getquery["datum"] = $d3.".".$d2.".".$d1;

				if(!(MOD_ALL & $cbPerms)) {
					$userquery = mysql_query("SELECT * FROM ".TABLE."_user WHERE name = '$HTTP_SESSION_VARS[user]'");
				} else {
					$getpref = $getquery["prf"];
					$userquery = mysql_query("SELECT * FROM ".TABLE."_user WHERE initial = '$getpref'");
					$userquery = mysql_fetch_array($userquery);
				}

				$headlineData[$counter]['title']  = $tempTitle;
				$headlineData[$counter]['date']   = $getquery["datum"];
				$headlineData[$counter]['author'] = $userquery["fullname"].' ('.$getquery["prf"].')';
				$headlineData[$counter]['id']     = $getquery["headlineid"];
				++$counter;
			}
			
			$tpl->assign("pageNav",
				array ( "split_status" => $pageSplitObj->isSplitInPages(),
						"next_set"     => $pageSplitObj->nextPageExists(),
						"last_set"     => $pageSplitObj->lastPageExists(),
						"next_offset"  => $pageSplitObj->getNextOffset(),
						"last_offset"  => $pageSplitObj->getLastOffset(),
						"pages"        => $pageSplitObj->getPages(),
						"actual_page"  => $pageSplitObj->getActualPage()
				)
			);
			
			$tpl->assign("headlineData", $headlineData);
			$tpl->assign("head_form_set", "1");
		}
	} else {
		$errorList[] = $amError["cannot_modify"];
	}

	if(empty($mod)) {
		$tpl->assign("new_headline_set", "1");
	} else {
		$head = mysql_fetch_array(mysql_query("SELECT * FROM ".TABLE."_headlines WHERE headlineid = '$id'"));
		$tpl->assign("actualHeadline",
			array ( "title"   => $head["headline"],
					"text"    => $head["msg"],
					"id"      => $head["headlineid"]
			)
		);
		$tpl->assign("mod_headline_set", "1");
	}
}
	
	
if(count($messageList) > 0) {
	$tpl->assign("messageSet", "1");
	$tpl->assign("messageList", $messageList);
}

if(count($errorList) > 0) {
	$tpl->assign("errorSet", "1");
	$tpl->assign("errorList", $errorList);
}
	
$mainPluginContent[]  = $tpl->fetch($config['templates']."headline.template", null, "pluginArt2".$cbUserID);
$mainMessageContent[] = $tpl->fetch($config['templates']."messages.template", null, "pluginArt2".$cbUserID);
?>
Return current item: Content*Builder