[CS-Project-svn_notify] SF.net SVN: cs-project:[954] releases/1.2
Brought to you by:
crazedsanity
From: <cra...@us...> - 2009-02-09 19:13:16
|
Revision: 954 http://cs-project.svn.sourceforge.net/cs-project/?rev=954&view=rev Author: crazedsanity Date: 2009-02-09 19:13:13 +0000 (Mon, 09 Feb 2009) Log Message: ----------- *** RELEASE 1.2.0-ALPHA11 *** CHANGE LOG::: * fix inability to solve issues introduced in 1.2.0-ALPHA10 (#250) * implement cs_siteConfig (#251) * minor superficial code changes * removed some commented-out code & some old debugging stuff. SVN COMMANDS::: merge --depth=infinity -r949:HEAD https://cs-project.svn.sourceforge.net/svnroot/cs-project/trunk/1.2 Modified Paths: -------------- releases/1.2/VERSION releases/1.2/includes/content/helpdesk/view.inc releases/1.2/lib/config.class.php releases/1.2/lib/helpdeskClass.php releases/1.2/lib/site_config.php Modified: releases/1.2/VERSION =================================================================== --- releases/1.2/VERSION 2009-02-09 19:08:54 UTC (rev 953) +++ releases/1.2/VERSION 2009-02-09 19:13:13 UTC (rev 954) @@ -1,4 +1,4 @@ $Id:VERSION 628 2007-11-20 16:58:45Z crazedsanity $ -VERSION: 1.2.0-ALPHA10 +VERSION: 1.2.0-ALPHA11 $HeadURL:https://cs-project.svn.sourceforge.net/svnroot/cs-project/trunk/VERSION $ Modified: releases/1.2/includes/content/helpdesk/view.inc =================================================================== --- releases/1.2/includes/content/helpdesk/view.inc 2009-02-09 19:08:54 UTC (rev 953) +++ releases/1.2/includes/content/helpdesk/view.inc 2009-02-09 19:13:13 UTC (rev 954) @@ -78,8 +78,6 @@ $useRespondLink = FALSE; if($_POST['isSolution']) { //IT'S A SOLUTION - //solve it & make sure they know if it was good or not. - #$result = $proj->helpdeskObj->solve($helpdeskId, $_POST['solution']); $remarks[] = array( 'remark' => $_POST['remark'], 'isSolution' => true @@ -155,9 +153,6 @@ ); } - #$page->gfObj->debug_print($_POST,1); - #$page->gfObj->debug_print($setMessage,1); - #exit; $page->set_message_wrapper($setMessage); } elseif($action == "re-open") { @@ -197,20 +192,7 @@ unset($_SESSION['goBackLink']); } - if($action == "create") { - create_page_title($page, array('title' => "Create a Helpdesk Issue")); - $page->set_all_block_rows("content"); - - //show the "category" selection. - $categoryList = $proj->helpdeskObj->get_category_list('bug', TRUE); - $page->add_template_var("select_tags", $categoryList); - - // - $page->add_template_var("email", $_SESSION['email']); - $page->add_template_var("linked_proj", cleanString($_GET['proj']),"numeric"); - - } - elseif($action == "view" && !is_numeric($helpdeskId)) { + if($action == "view" && !is_numeric($helpdeskId)) { //missing ID: throw a message & send 'em packin'. set_message_wrapper(array( "title" => "Invalid ID Specified", @@ -269,20 +251,6 @@ $doNotRipRows[] = "assigned_optionList"; $doNotRipRows[] = "priority_optionList"; $doNotRipRows[] = "editable_tags"; - if(($assignedStr == $_SESSION['contact_id']) || ($assignedStr == "" || is_null($assignedStr))) { - //well, we can show 'em the update/modify button. - $doNotRipRows[] = "update_button"; - if($_SESSION['contact_id'] == $assignedStr) { - //they're the owner... show 'em more options. - $doNotRipRows[] = "solution_row"; - $doNotRipRows[] = "owner_options"; - } - //if they're the owner, show 'em more options... - } - elseif($_SESSION['isGroupOwner']) { - //we got an OWNER!!! - $doNotRipRows[] = "owner_options"; - } $doNotRipRows[] = "remark_row"; $doNotRipRows[] = "buttons_row"; $doNotRipRows[] = 'accessBlock__modifyButton'; @@ -295,9 +263,6 @@ //keep the set of data allows it to be linked to a project. $doNotRipRows[] = "edit_project_selection"; - - //TODO: implement a link for updating project associations. - #$page->add_template_var("select_project_list", $proj->create_project_option_list($helpdeskData['ancestry'], NULL)); } $doNotRipRows[] = 'update_button'; Modified: releases/1.2/lib/config.class.php =================================================================== --- releases/1.2/lib/config.class.php 2009-02-09 19:08:54 UTC (rev 953) +++ releases/1.2/lib/config.class.php 2009-02-09 19:13:13 UTC (rev 954) @@ -1,6 +1,8 @@ <?php -class config { +require_once(dirname(__FILE__) .'/cs-content/cs_siteConfig.class.php'); + +class config extends cs_siteConfig { private $data; @@ -11,7 +13,7 @@ private $siteStatus; private $setupRequired = FALSE; private $fileName; - private $config; + protected $config; //------------------------------------------------------------------------- public function __construct($fileName=NULL) { @@ -36,6 +38,20 @@ if(!$this->fs->is_writable(CONFIG_DIRECTORY)) { throw new exception(__METHOD__ .": the config directory (". CONFIG_DIRECTORY .") isn't writable!"); } + + if($this->fileExists) { + //check to see if it all config items are directly under the root, or if they're already in sections. + $xml = new cs_phpxmlParser($this->fs->read($this->fileName)); + $checkThis = $xml->get_attribute('/CONFIG', 'USECSSITECONFIG'); + + if(!strlen($checkThis)) { + $this->gf->debug_print(__METHOD__ .": converting to use sections..."); + $this->convert_to_sections(); + } + } + + parent::__construct($this->fs->realcwd .'/'. $this->fileName); + $this->config = $this->get_config_contents(TRUE); }//end __construct() //------------------------------------------------------------------------- @@ -55,10 +71,10 @@ if($simple) { $config = $xmlParser->get_tree(TRUE); - $config = $config['CONFIG']; + $config = $config['CONFIG']['MAIN']; } else { - $config = $xmlParser->get_path('/CONFIG'); + $config = $xmlParser->get_path('/CONFIG/MAIN'); unset($config['type'], $config['attributes']); } @@ -66,7 +82,7 @@ $myConfig = $config; if(!$simple) { $myConfig = $xmlParser->get_tree(TRUE); - $myConfig = $myConfig['CONFIG']; + $myConfig = $myConfig['CONFIG']['MAIN']; } $conditionallySet = array('VERSION_STRING', 'WORKINGONIT'); foreach($myConfig as $index=>$value) { @@ -76,9 +92,6 @@ define($index, $value); } } - else { - define($index, $value); - } } } } @@ -95,27 +108,11 @@ //------------------------------------------------------------------------- /** - * Read the XML config file & return it's simplified contents + * Read the XML config file & return it's simplified contents (just a + * wrapper for get_config_contents(); kept for backwards-compatibility) */ public function read_config_file($defineConstants=TRUE, $setEverything=TRUE) { - $config = $this->get_config_contents(TRUE); - - if(!is_null($config) && $defineConstants) { - $conditionallySet = array('VERSION_STRING', 'WORKINGONIT'); - foreach($config as $index=>$value) { - if(in_array($index, $conditionallySet)) { - //only set this part if we're told to. - if($setEverything) { - define($index, $value); - } - } - else { - define($index, $value); - } - } - } - - return($config); + return($this->get_config_contents(TRUE)); }//end read_config_file() //------------------------------------------------------------------------- @@ -310,5 +307,89 @@ return($this->fs->rm(SETUP_FILE_LOCATION)); }//end remove_setup_config() //------------------------------------------------------------------------- + + + + //------------------------------------------------------------------------- + /** + * Convert sections to be in a format that cs_siteConfig{} expects them to + * be in. + */ + private function convert_to_sections() { + + //make a copy of the old data. + $backupFilename = $this->fileName .".backup_convertToSections__". date("YmdHis"); + $this->fs->create_file($backupFilename); + $this->fs->write($this->fs->read($this->fileName)); + + $xml = new cs_phpxmlParser($this->fs->read($this->fileName)); + $rootElement = $xml->get_root_element(); + + $creator=new cs_phpxmlCreator($rootElement); + + $dataArray = $xml->get_tree(); + $dataArray = $dataArray[$rootElement]; + + + $rootAttribs = $dataArray['attributes']; + + //remove unnecessary indexes. + unset($dataArray['type'], $dataArray['attributes']); + + if(!is_array($rootAttribs)) { + $rootAttribs = array(); + } + $rootAttribs['USECSSITECONFIG'] = 1; + $creator->add_attribute('/'. $rootElement, $rootAttribs); + + //set special value for SITE_ROOT + $dataArray['SITE_ROOT']['value'] = '{_DIRNAMEOFFILE_}/..'; + $dataArray['SITE_ROOT']['attributes']['cleanpath'] = 1; + + //Set some other special values... + { + $dataArray['DOCUMENT_ROOT']['value'] = '{/MAIN/SITE_ROOT}'; + $dataArray['LIBDIR']['value'] = '{/MAIN/SITE_ROOT}/lib'; + $dataArray['TMPLDIR']['value'] = '{/MAIN/SITE_ROOT}/templates'; + $dataArray['SEQ_HELPDESK']['value'] = 'special__helpdesk_public_id_seq'; + $dataArray['SEQ_PROJECT']['value'] = 'special__project_public_id_seq'; + $dataArray['SEQ_MAIN']['value'] = 'record_table_record_id_seq'; + $dataArray['TABLE_TODOCOMMENT']['value'] = 'task_comment_table'; + $dataArray['FORMAT_WORDWRAP']['value'] = '90'; + } + + //define what items should also be GLOBAL. + $defineAsGlobal = array('SITE_ROOT', 'LIBDIR', 'TMPLDIR'); + + //skip some things that should NOT be automatically set as constants. + $skipSetConstant = array('VERSION_STRING', 'WORKINGONIT'); + + //create the main section that our old settings will go under. + $mainPath = '/'. $rootElement .'/MAIN'; + $creator->add_tag($mainPath); + $creator->set_tag_as_multiple($mainPath); + $creator->add_attribute($mainPath, array('FIX'=>'sanitizeDirs')); + + + //now add all the old settings. + foreach($dataArray as $index=>$data) { + if(!is_array($data['attributes'])) { + $data['attributes'] = array(); + } + if(!in_array($index, $skipSetConstant)) { + $data['attributes']['setconstant']=1; + } + if(in_array($index, $defineAsGlobal)) { + $data['attributes']['setglobal']=1; + } + $creator->add_tag($mainPath .'/'. $index, $data['value'], $data['attributes']); + } + + + //now write changes to the file. + $this->fs->truncate_file($this->fileName); + $this->fs->write($creator->create_xml_string(), $this->fileName); + }//end convert_to_sections() + //------------------------------------------------------------------------- }//end config{} ?> \ No newline at end of file Modified: releases/1.2/lib/helpdeskClass.php =================================================================== --- releases/1.2/lib/helpdeskClass.php 2009-02-09 19:08:54 UTC (rev 953) +++ releases/1.2/lib/helpdeskClass.php 2009-02-09 19:13:13 UTC (rev 954) @@ -153,85 +153,85 @@ $retval = -1; } else { - //start a transaction so if one part fails, they all fail. - $this->db->beginTrans(); - - $tmp = $this->get_record($helpdeskId); - $noteObj = new noteClass($this->db); - $noteData = array( - 'record_id' => $tmp['record_id'], + //start a transaction so if one part fails, they all fail. + $this->db->beginTrans(); - //TODO: allow user to specify subject! - 'subject' => 'Comment', - 'body' => $remark, - 'is_solution' => cleanString($isSolution, 'boolean_strict') - ); - $retval = $noteObj->create_note($noteData); - - if(is_numeric($noteObj->lastContactId) && $noteObj->lastContactId > 0) { - $this->lastContactId = $noteObj->lastContactId; - $recordContactLink = new recordContactLink($this->db); - $recordContactLink->add_link($tmp['record_id'], $noteObj->lastContactId); - } - - if($retval > 0) { - //send the submitter an email - $newRemarks = $remark; - $emailTemplate = html_file_to_string("email/helpdesk.tmpl"); - $linkAction = "view"; - - if($useRespondLink) { - $linkAction = "respond"; - } - $parseArr = array( - "newRemark" => $newRemarks, - "linkAction" => $linkAction, - "linkExtra" => "&check=". $this->create_md5($helpdeskId) + $this->helpdeskId = $helpdeskId; + $tmp = $this->get_record($helpdeskId); + $noteObj = new noteClass($this->db); + $noteData = array( + 'record_id' => $tmp['record_id'], + + //TODO: allow user to specify subject! + 'subject' => 'Comment', + 'body' => $remark, + 'is_solution' => cleanString($isSolution, 'boolean_strict') ); - $parseArr = array_merge($tmp, $parseArr); + $retval = $noteObj->create_note($noteData); - //set the list of recipients. - $recipientsArr = array(); - $myUserClass = new userClass($this->db,NULL); - $assignedUserData = $myUserClass->get_user_info($tmp['assigned']); - $recipientsArr[] = $assignedUserData['email']; - if(strlen($_SESSION['login_email']) && $_SESSION['login_email'] != $tmp['email']) { - $recipientsArr[] = $_SESSION['login_email']; + if(is_numeric($noteObj->lastContactId) && $noteObj->lastContactId > 0) { + $this->lastContactId = $noteObj->lastContactId; + $recordContactLink = new recordContactLink($this->db); + $recordContactLink->add_link($tmp['record_id'], $noteObj->lastContactId); } - $recipientsArr[] = $tmp['email']; - //okay, now send the email. The function "send_email()" should be ensuring that all values in - // the recipients array are valid, and there's no dups. - $subject = "Helpdesk Issue #". $helpdeskId ." -- ". $tmp['name']; - $sendEmailRes = send_email($recipientsArr, $subject, $emailTemplate, $parseArr); - - //log who we sent the emails to. - $details = 'Sent notification(s) of for [helpdesk_id='. $helpdeskId .'] remark to: '. $sendEmailRes; - $this->logsObj->log_by_class($details, 'information', NULL, $this->recordTypeId, $helpdeskId); - - if($isSolution && strlen(constant('HELPDESK_ISSUE_ANNOUNCE_EMAIL'))) { - $subject = '[ALERT] Helpdesk Issue #'. $helpdeskId .' was SOLVED'; - if(strlen($_SESSION['login_username'])) { - $subject .= ' by '. $_SESSION['login_username']; + if($retval > 0) { + //send the submitter an email + $newRemarks = $remark; + $emailTemplate = html_file_to_string("email/helpdesk.tmpl"); + $linkAction = "view"; + + if($useRespondLink) { + $linkAction = "respond"; } - $subject .= " -- ". $tmp['name']; - $sendEmailRes = send_email(HELPDESK_ISSUE_ANNOUNCE_EMAIL, $subject, $emailTemplate, $parseArr); - $details = 'Sent notifications of SOLUTION for [helpdesk_id='. $helpdeskId .'] to: '. $sendEmailRes; - $this->logsObj->log_by_class($details, 'information'); + $parseArr = array( + "newRemark" => $newRemarks, + "linkAction" => $linkAction, + "linkExtra" => "&check=". $this->create_md5($helpdeskId) + ); + $parseArr = array_merge($tmp, $parseArr); - $this->solve(); + //set the list of recipients. + $recipientsArr = array(); + $myUserClass = new userClass($this->db,NULL); + $assignedUserData = $myUserClass->get_user_info($tmp['assigned']); + $recipientsArr[] = $assignedUserData['email']; + if(strlen($_SESSION['login_email']) && $_SESSION['login_email'] != $tmp['email']) { + $recipientsArr[] = $_SESSION['login_email']; + } + $recipientsArr[] = $tmp['email']; + + //okay, now send the email. The function "send_email()" should be ensuring that all values in + // the recipients array are valid, and there's no dups. + $subject = "Helpdesk Issue #". $helpdeskId ." -- ". $tmp['name']; + $sendEmailRes = send_email($recipientsArr, $subject, $emailTemplate, $parseArr); + + //log who we sent the emails to. + $details = 'Sent notification(s) of for [helpdesk_id='. $helpdeskId .'] remark to: '. $sendEmailRes; + $this->logsObj->log_by_class($details, 'information', NULL, $this->recordTypeId, $helpdeskId); + + if($isSolution) { + $this->solve(); + } + if($isSolution && strlen(constant('HELPDESK_ISSUE_ANNOUNCE_EMAIL'))) { + $subject = '[ALERT] Helpdesk Issue #'. $helpdeskId .' was SOLVED'; + if(strlen($_SESSION['login_username'])) { + $subject .= ' by '. $_SESSION['login_username']; + } + $subject .= " -- ". $tmp['name']; + $sendEmailRes = send_email(HELPDESK_ISSUE_ANNOUNCE_EMAIL, $subject, $emailTemplate, $parseArr); + $details = 'Sent notifications of SOLUTION for [helpdesk_id='. $helpdeskId .'] to: '. $sendEmailRes; + $this->logsObj->log_by_class($details, 'information'); + } + $this->db->commitTrans(); } - $this->db->commitTrans(); + else { + $this->rollbackTrans(); + //something went wrong. + $this->logsObj->log_by_class(__METHOD__ .": failed to remark on [helpdesk_id=". $helpdeskId ."] (". $retval .")", 'error'); + } } - else { - $this->rollbackTrans(); - //something went wrong. - $this->logsObj->log_by_class(__METHOD__ .": failed to remark on [helpdesk_id=". $helpdeskId ."] (". $retval .")", 'error'); - } - } - $this->gfObj->debug_print(__METHOD__ .": result=(". $retval .")",1); - return($retval); }//end remark() Modified: releases/1.2/lib/site_config.php =================================================================== --- releases/1.2/lib/site_config.php 2009-02-09 19:08:54 UTC (rev 953) +++ releases/1.2/lib/site_config.php 2009-02-09 19:13:13 UTC (rev 954) @@ -44,7 +44,7 @@ //attempt to log the problem; if it happens too early, we can't do much about it. try { - print "<pre><h3>FATAL EXCEPTION ENCOUNTERED: </h3>". $exception->getMessage() ."</pre>"; + print "<pre><h3>FATAL EXCEPTION ENCOUNTERED: </h3>". $exception->getMessage() ."</pre>"; include_once(dirname(__FILE__) ."/globalFunctions.php"); if(function_exists('get_config_db_params') && class_exists('cs_phpDB') && class_exists('logsClass')) { $db = new cs_phpDB; @@ -104,19 +104,6 @@ } -if($_SERVER['DOCUMENT_ROOT']) { - //it was called from the web... - $GLOBALS['SITE_ROOT'] = $_SERVER['DOCUMENT_ROOT']; - $GLOBALS['SITE_ROOT'] = str_replace("/public_html", "", $GLOBALS['SITE_ROOT']); -} -else { - //called from the command line. - $GLOBALS['SITE_ROOT'] = $_SERVER['HOME']; -} - -$GLOBALS['LIBDIR']=$GLOBALS['SITE_ROOT'] . "/lib"; -$GLOBALS['TMPLDIR']=$GLOBALS['SITE_ROOT'] . "/templates"; - //define an array of status_id's that are "NOT ENDED". $GLOBALS['STATUS_NOTENDED'] = array(0,1,2,6); @@ -130,13 +117,6 @@ ); -//define some constants... -define('SEQ_HELPDESK', 'special__helpdesk_public_id_seq'); -define('SEQ_PROJECT', 'special__project_public_id_seq'); -define('SEQ_MAIN', 'record_table_record_id_seq'); -define('TABLE_TODOCOMMENT', 'task_comment_table'); -define('FORMAT_WORDWRAP', 90); - //========================================================================= /** * Special PHP5 function: last-ditch effort to include all files necessary to This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |