Location: PHPKode > projects > BugIn and Ticketing System > bugin-0.65/inc/admin/pre/oedit.pre.inc.php
<?php

/* {{{ Select the Basic section if no section has been selected. */
if (!isset($_REQUEST['section'])) {
	$section = "basic";
}
else {
	$section = basename($_REQUEST['section']);
}
/* }}} */

/* {{{ i18n */
$menuItems = array();
$menuItems['basic'] = $verbage['adm_opt_basic'];
$menuItems['misc'] = $verbage['adm_opt_misc'];
$menuItems['htmlcolor'] = $verbage['adm_opt_htmlcol'];
$menuItems['notification'] = $verbage['notification'];
$menuItems['debug'] = "Debug";
/* }}} */

/* {{{ Database Update */
if (isset($update)) {
	$row = 0;
	$template_row=0;
	$empty = array();
	$update = array();

	$myOptions = $bugDatabase->getConfig($empty);
	while (list($key, $value) = each($mod)) {
		switch ($key) {
			case "debug":
				$_SESSION['debug']['debug'] = intval($value);
				break;
			case "norefresh":
				$_SESSION['debug']['norefresh'] = intval($value);
				break;
			case "notification":
			case "notify_subj":
			case "signup_email":

				# Make sure we have the templateLanguage
				$tl = intval($_REQUEST['templateLanguage']);

				if (!isset($bugDatabase->lists['lang'][$tl])) {
					buginError("Language ID $tl doesn't exist!");
					break;
				}

				$options = $bugDatabase->getTemplates($tl, $options);
				

				# Yet another ugly, ugly hack...
				switch ($key) {
					case "notification":
						$comp = "notificationTemplate";
						break;
					case "notify_subj":
						$comp = "notificationSubject";
						break;
					case "signup_email":
						$comp = "signupEmailTemplate";
						break;
				}


				if ($value != $options[$comp]) {
					$update[$row]['tableName'] = "templates";
					switch($options['templatesFromFile']) {
						case 1:
							$update[$row]['action'] = "add";
							$update[$row]['modify'][1]['fieldName'] = "lang_id";
							$update[$row]['modify'][1]['fieldValue'] = $tl;
							$update[$row]['modify'][2]['fieldName'] = "name";
							$update[$row]['modify'][2]['fieldValue'] = $bugDatabase->db->qstr($key);
							break;
						default:
							$update[$row]['action'] = "change";
							$update[$row]['rowmatches'] = array();
							$update[$row]['rowmatches']['name'] = $bugDatabase->db->qstr($key);
							$update[$row]['rowmatches']['lang_id'] = intval($tl);
							break;
							
					}
					$update[$row]['modify'][0]['fieldName'] = "value";
					$update[$row]['modify'][0]['fieldValue'] = $bugDatabase->db->qstr($value);
					$row ++;
				}
				break;
			default:
				// Comma seperate your arrays, son.
				if (is_array($value))
					$value = implode(",", $value);
	
				if ($value != $options[$key]) {
					$update[$row]['tableName'] = "config";
					if (!isset($myOptions[$key])) {
						$update[$row]['action'] = "add";
						$update[$row]['modify'][0]['fieldName'] = "name";
						$update[$row]['modify'][0]['fieldValue'] = $bugDatabase->db->qstr($key);
						$update[$row]['modify'][1]['fieldName'] = "value";
						$update[$row]['modify'][1]['fieldValue'] = $bugDatabase->db->qstr($value);
					}
					else {
						$update[$row]['action'] = "change";
						$update[$row]['uniqueRow'] = "name";
						$update[$row]['rowid'] = $bugDatabase->db->qstr($key);
						$update[$row]['modify'][0]['fieldName'] = "value";
						$update[$row]['modify'][0]['fieldValue'] = $bugDatabase->db->qstr($value);
					}
					$row ++;
				}
				break;
		}
	}
	if ($row) {
		// Now we assemble the DB info...
		$bugDatabase->alterDb($update);
		$options = $bugDatabase->getConfig($options);
		header("Location: {$options['baseURL']}?area=admin&action=oedit&section={$section}");
	}
}
/* }}} */

/* {{{ Zero out values */
$closedSelectOptions = "";
$DefaultGroupSelectOptions = "";
$formMethodSelected['POST'] = "";
$formMethodSelected['GET'] = "";
$anonCLAccess[0] = "";
$anonCLAccess[1] = "";
$anonTicketAccess[0] = "";
$anonTicketAccess[1] = "";
$signupEnableSelected[0] = "";
$signupEnableSelected[1] = "";
$noSignupTicketEnableSelected[0] = "";
$noSignupTicketEnableSelected[1] = "";
$defaultOwnerSelected['creator'] = "";
$defaultOwnerSelected['unowned'] = "";
$defaultOwnerSelected['UID'] = "";
$ldapEnable[0] = "";
$ldapEnable[1] = "";
$notifyByName[0] = "";
$notifyByName[1] = "";
$debugSelected[1] = "";
$debugSelected[0] = "";
$noRefreshSelected[0] = "";
$noRefreshSelected[1] = "";
$noEmailSelected[0] = "";
$noEmailSelected[1] = "";
/* }}} */

/* {{{ Set the actual values.... */
$formMethodSelected[strtoupper($options['formMethod'])] = " SELECTED";
$signupEnableSelected[$options['signupEnable']] = " SELECTED";
$noSignupTicketEnableSelected[$options['noSignupTicketEnable']] = " SELECTED";
$debugSelected[$options['debug']] = " SELECTED";
$noRefreshSelected[$options['norefresh']] = " SELECTED";
$noEmailSelected[$options['noEmail']] = " SELECTED";
$defaultOwnerSelected[$options['defaultOwner']] = " SELECTED";
$ticketSubmitMatch[$options['ticketSubmitMatch']] = " SELECTED";
$ldapEnable[$options['ldapEnable']] = " SELECTED";
$anonCLAccess[$options['anonCLAccess']] = " SELECTED";
$anonTicketAccess[$options['anonTicketAccess']] = " SELECTED";
$dateFormat = htmlentities($options['dateFormat']);

// Multi selects "selected"
$closedList = explode(",", $options['closedNum']);
while (list($key, $value) = each($bugDatabase->lists['status'])) {
	if (in_array($value['id'], $closedList) )
		$selected = " SELECTED";
	else
		$selected = "";
	$closedSelectOptions .= <<<EOT
						<option value="{$value['id']}"{$selected}>({$value['id']}) {$value['name']}{$selected}</option>

EOT;
}
/* }}} */

/* {{{ Multi selects "selected" */
$defaultGroupList = explode(",", $options['defaultGroups']);
while (list($key, $value) = each($bugDatabase->lists['group'])) {
	if (in_array($value['id'], $defaultGroupList) )
		$selected = " SELECTED";
	else
		$selected = "";

	$defaultGroupSelectOptions .= <<<EOT
						<option value="{$value['id']}"{$selected}>({$value['id']}) {$value['name']}{$selected}</option>

EOT;
}

buginError("Generating category list", 1);
$defaultAddCategory = "<option value=\"-1\">User must Select Category</option>\n";
$defaultAddCategory .= generateOptionList($bugDatabase->lists['category'], "id", $options['defaultAddCategory'], "name", 1);
/* }}} */

/* {{{ Assemble the project list */
buginError("Generating project list", 1);
$defaultAddProject = "<option value=\"-1\">User must Select Project</option>\n";
$defaultAddProject .= generateOptionList($bugDatabase->lists['project'], "id", $options['defaultAddProject'], "optionName", 1);
/* }}} */

/* {{{ Assemble the priority list */
buginError("Generating priority list", 1);
$defaultAddPriority = generateOptionList($bugDatabase->lists['priority'], "id", $options['defaultAddPriority']);
/* }}} */

/* {{{ Section-based variable cleaning */
switch($section) {
	case "notification":
		if (!isset($_REQUEST['templateLanguage'])) {
			$tl = $options['defaultLanguage'];
		}
		else {
			$tl = intval($_REQUEST['templateLanguage']);
		}

		$options = $bugDatabase->getTemplates($tl, $options);


		// htmlize options...
		$msgTemplate = htmlentities($options['notificationTemplate']);
		$subjTemplate = htmlentities($options['notificationSubjectTemplate']);
		$signupEmailTemplate = htmlentities($options['signupEmailTemplate']);
		$notifyByName[$options['notifyByName']] = " SELECTED";
		$langList = generateOptionList($bugDatabase->lists['lang'], "id", $tl);
		break;
	default:
		$langList = generateOptionList($bugDatabase->lists['lang'], "id", $options['defaultLanguage']);
		$systemName = htmlentities($options['systemName']);
		$ticketName = htmlentities($options['ticketName']);
		$baseURL = htmlentities($options['baseURL']);
		$defaultUID = htmlentities($options['defaultUID']);
		$modEmail = htmlentities($options['modEmail']);
		$ldapReadServer = htmlentities($options['ldapReadServer']);
		$ldapDomain = htmlentities($options['ldapDomain']);
		$footerText = htmlentities($options['footerText']);
		break;
}
/* }}} */

?>
Return current item: BugIn and Ticketing System