[Cs-project-svn_notify] SF.net SVN: cs-project: [653] trunk/lib/helpdeskClass.php
Brought to you by:
crazedsanity
From: <cra...@us...> - 2007-11-21 16:56:23
|
Revision: 653 http://cs-project.svn.sourceforge.net/cs-project/?rev=653&view=rev Author: crazedsanity Date: 2007-11-21 08:56:20 -0800 (Wed, 21 Nov 2007) Log Message: ----------- Colorized tag list w/modifiers, set initial priority based on selected tag mods. /lib/helpdeskClass.php: * create_record(): -- get list of tags & update priority based on the modifiers of the selected tags. -- add each of the selected tags to the record. * get_category_list(): -- special magic to colorize the list. -- NOTE: there's no reason to reference categories in place of tags anymore; this should be updated. Modified Paths: -------------- trunk/lib/helpdeskClass.php Modified: trunk/lib/helpdeskClass.php =================================================================== --- trunk/lib/helpdeskClass.php 2007-11-21 16:51:23 UTC (rev 652) +++ trunk/lib/helpdeskClass.php 2007-11-21 16:56:20 UTC (rev 653) @@ -292,6 +292,25 @@ if(!is_numeric($dataArr['priority'])) { $dataArr['priority'] = 9; } + + $tagObj = new tagClass($this->db); + if(is_array($dataArr['initialTag']) && count($dataArr['initialTag'])) { + + //get the list of tags, so we know what the total modifier is. + $allTags = $tagObj->get_tag_list(); + + foreach($dataArr['initialTag'] as $id) { + $dataArr['priority'] += $allTags[$id]['modifier']; + } + + if($dataArr['priority'] > 9) { + $dataArr['priority'] = 9; + } + elseif($dataArr['priority'] < 0) { + $dataArr['priority'] = 0; + } + + } $dataArr['is_helpdesk_issue'] = 't'; $newRecord = parent::create_record($dataArr, TRUE); @@ -311,9 +330,10 @@ $linkObj->add_link($newRecord, $myNewRecordArr[$retval]['creator_contact_id']); //now, let's tag it. - if(isset($dataArr['initialTag']) && is_numeric($dataArr['initialTag'])) { - $tagObj = new tagClass($this->db); - $tagObj->add_tag($newRecord, $dataArr['initialTag']); + if(is_array($dataArr['initialTag']) && count($dataArr['initialTag'])) { + foreach($dataArr['initialTag'] as $id) { + $tagObj->add_tag($newRecord, $id); + } } //determine what to do next... @@ -393,10 +413,43 @@ function get_category_list($selectThis=NULL) { //create a list of tags. $object = new tagClass($this->db); - $tagList = $object->get_tag_list(); + $mainTagList = $object->get_tag_list(); + //create the "replacement array" and such. + $tagList = array(); + foreach($mainTagList as $tagNameId => $subData) { + $tagList[$tagNameId] = $subData['name']; + $mod = $subData['modifier']; + if($mod > 0) { + if($mod == 1) { + $mainTagList[$tagNameId]['bgcolor'] = '#CCC'; + } + elseif($mod == 2) { + $mainTagList[$tagNameId]['bgcolor'] = '#BBB'; + } + else { + $mainTagList[$tagNameId]['bgcolor'] = '#AAA'; + } + } + elseif($mod < 0) { + if($mod == -1) { + $mainTagList[$tagNameId]['bgcolor'] = 'yellow'; + } + elseif($mod == -2) { + $mainTagList[$tagNameId]['bgcolor'] = 'orange'; + } + else { + $mainTagList[$tagNameId]['bgcolor'] = 'red'; + } + } + else { + $mainTagList[$tagNameId]['bgcolor'] = 'white'; + } + } + //now create the list. - $retval = array_as_option_list($tagList); + $templateString = "\t\t<option value='%%value%%' %%selectedString%% style=\"background-color:%%bgcolor%%\">%%display%% (%%modifier%%)</option>"; + $retval = array_as_option_list($tagList, $selectThis, 'select', $templateString, $mainTagList); return($retval); }//end get_category_list() //================================================================================================ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |