public function __construct()
{
- $this->functionsDescription = array('in_array'=>_('Test if a value is in an (json) array'));
- $this->functionsDescription = array('datetime_add'=>_('Add to a date/time a duration (duration in ISO 8601 Format)'));
+ $this->functionsDescription['in_array'] = _('Test if a value is in an (json) array');
+ $this->functionsDescription['datetime_add'] = _('Add to a date/time a duration (duration in ISO 8601 Format)');
$this->expression = new Expression;
$this->expression->suppress_errors = true;
$this->expression->fb = array();
if (is_integer($value)) {
$expression = $name.'='.$value;
} else {
- $expression = $name.'=\''.$value.'\'';
+ $expression = $name.'='.json_encode($value);
}
$result = $this->expression->evaluate($expression);
$result = $this->vb[] = $name;
}
function expr_datetime_add($datetime, $interval) {
+ if (!trim($datetime)) {
+ return '';
+ }
$dateTimeObj = DateTime::createFromFormat(_('Y-m-d H:i'), $datetime);
+ if (!$dateTimeObj) {
+ return '';
+ }
$intervalObj = new DateInterval($interval);
+ if (!$intervalObj) {
+ return '';
+ }
$dateTimeObj->add($intervalObj);
return $dateTimeObj->format(_('Y-m-d H:i'));
}
return $return;
}
+ /**
+ * getFieldsInFormula - Get array of extra fields used in formula
+ *
+ * @return array arrays of data;
+ */
+ function getFieldsInFormula() {
+ $return = array();
+ if ($this->usesCustomStatuses()) {
+ $fields = array( 'assigned_to','priority','summary','description');
+ } else {
+ $fields = array( 'assigned_to','priority','summary','description','status');
+ }
+ $res = db_query_params('SELECT string_agg(formula,chr(10)) FROM artifact_extra_field_formula NATURAL INNER JOIN artifact_extra_field_list WHERE is_disabled=0 AND group_artifact_id=$1',
+ array ($this->getID()));
+ if (db_numrows($res) > 0) {
+ $row = db_fetch_array($res);
+ if (preg_match_all("/([a-z]\w*)/m", $row[0], $matches)) {
+ foreach ($fields as $field) {
+ if (in_array($field,$matches[0])) {
+ $return[]=$field;
+ }
+ }
+ }
+ }
+ return $return;
+ }
+
/**
* getExtraFieldsWithFormula - Get array of extra fields with formula
*
// Constants assignment
// Internal Fields
if (!$at->usesCustomStatuses()) {
+ if (!$status) {
+ $status = $at->getStatusName(1);
+ }
$expr->setConstant('status', $status);
if ($expr->isError()) {
$ret['message'] = $expr->getErrorMessage()._(':').' status=\''.$status.'\'';
return json_encode($ret);
exit();
}
+
// Extra Fields
$extraFields = $at->getExtraFields();
foreach ($extraFields as $extraField) {
$type = $extraField['field_type'];
if ($type==ARTIFACT_EXTRAFIELDTYPE_INTEGER) {
$value = (integer)$extra_fields[$extraField['extra_field_id']];
- } elseif ($type==ARTIFACT_EXTRAFIELDTYPE_TEXT ||
- $type==ARTIFACT_EXTRAFIELDTYPE_TEXTAREA ||
- $type==ARTIFACT_EXTRAFIELDTYPE_RELATION ||
+ } elseif ($type==ARTIFACT_EXTRAFIELDTYPE_RELATION ||
$type==ARTIFACT_EXTRAFIELDTYPE_DATETIME) {
$value = addslashes($extra_fields[$extraField['extra_field_id']]);
+ } elseif ($type==ARTIFACT_EXTRAFIELDTYPE_TEXT ||
+ $type==ARTIFACT_EXTRAFIELDTYPE_TEXTAREA ) {
+ $value = $extra_fields[$extraField['extra_field_id']];
} elseif (in_array($type, unserialize(ARTIFACT_EXTRAFIELDTYPEGROUP_SINGLECHOICE))) {
$ef = new ArtifactExtraField($at, $extraField['extra_field_id']);
$efe = new ArtifactExtraFieldElement($ef,$extra_fields[$extraField['extra_field_id']] );
<?php
$ath->renderExtraFields($ah->getExtraFieldData(),true,'none',false,'Any',array(),false,'UPDATE');
+ $fieldInFormula = $ath->getFieldsInFormula();
?>
<tr>
<td>
<strong><?php echo _('State')._(':'); ?></strong><br />
<span id="tracker-status_id" title="<?php echo util_html_secure(html_get_tooltip_description('status_id_tracker')) ?>">
- <?php echo $ath->statusBox ('status_id', $ah->getStatusID() ); ?>
+ <?php
+ if (in_array('status', $fieldInFormula)) {
+ echo $ath->statusBox('status_id', $ah->getStatusID(), false, 'none', array('class'=>'in-formula'));
+ } else {
+ echo $ath->statusBox('status_id', $ah->getStatusID());
+ }
+ ?>
</span>
</td>
<td>
</tr>
<?php
$ath->renderExtraFields($ah->getExtraFieldData(),true,'none',false,'Any',array(),false,'UPDATE');
+ $fieldInFormula = $ath->getFieldsInFormula();
?>
<tr>
<td><strong><?php echo _('Assigned to')._(': ') ?></strong><br />
<?php
- echo $ath->technicianBox('assigned_to', $ah->getAssignedTo() );
+ if (in_array('assigned_to', $fieldInFormula)) {
+ echo $ath->technicianBox('assigned_to', $ah->getAssignedTo(), true, 'none', -1, '', false, array('class'=>'in-formula'));
+ } else {
+ echo $ath->technicianBox('assigned_to', $ah->getAssignedTo());
+ }
echo " ";
echo util_make_link('/tracker/admin/?group_id='.$group_id.'&atid='.$ath->getID().'&update_users=1', '('._('Admin').')');
?>
</td><td>
<strong><?php echo _('Priority'). _(': ') ?></strong><br />
- <?php echo build_priority_select_box('priority',$ah->getPriority()); ?>
+ <?php
+ if (in_array('priority', $fieldInFormula)) {
+ echo $ath->priorityBox('priority',$ah->getPriority(), false, array('class'=>'in-formula'));
+ } else {
+ echo $ath->priorityBox('priority',$ah->getPriority());
+ }
+ ?>
</td>
</tr>
<tr>
<td>
<strong><?php echo _('State')._(': ') ?></strong><br />
- <?php echo $ath->statusBox ('status_id', $ah->getStatusID() ); ?>
+ <?php
+ if (in_array('status', $fieldInFormula)) {
+ echo $ath->statusBox('status_id', $ah->getStatusID(), false, 'none', array('class'=>'in-formula'));
+ } else {
+ echo $ath->statusBox('status_id', $ah->getStatusID());
+ }
+ ?>
</td>
<td>
</td>
?>
<tr>
<td colspan="2"><strong><?php echo _('Summary').utils_requiredField()._(':') ?></strong><br />
- <input id="tracker-summary" required="required" title="<?php echo _('The summary text-box represents a short tracker item summary. Useful when browsing through several tracker items.') ?>" type="text" name="summary" size="70" value="<?php
- echo $ah->getSummary();
- ?>" maxlength="255" />
+ <?php if (in_array('summary', $fieldInFormula)) { ?>
+ <input id="tracker-summary" required="required" title="<?php echo _('The summary text-box represents a short tracker item summary. Useful when browsing through several tracker items.') ?>" type="text" name="summary" size="70" value="<?php
+ echo $ah->getSummary();
+ ?>" maxlength="255" class="in-formula"/>
+ <?php } else { ?>
+ <input id="tracker-summary" required="required" title="<?php echo _('The summary text-box represents a short tracker item summary. Useful when browsing through several tracker items.') ?>" type="text" name="summary" size="70" value="<?php
+ echo $ah->getSummary();
+ ?>" maxlength="255" />
+ <?php } ?>
</td>
</tr>
<tr><td colspan="2">
- <div id="edit" class="hide">
- <strong><?php echo _('Detailed description') ?><?php echo utils_requiredField(); ?><?php echo _(': ') ?><?php echo notepad_button('document.forms.trackermodform.description') ?></strong>
- <br />
- <textarea id="tracker-description" required="required" name="description" rows="30" style="width: 100%" title="<?php echo html_get_tooltip_description('description') ?>"><?php echo $ah->getDetails(); ?></textarea>
- </div>
- <div id="show" style="display:block;">
- <?php echo $ah->showDetails(true); ?>
- </div>
+
+ <?php
+ if (in_array('description', $fieldInFormula)) {
+ echo $ah->showDetails(true, array('class'=>'in-formula'));
+ } else {
+ echo $ah->showDetails(true);
+ }
+ ?>
+
</td></tr>
<?php echo $HTML->listTableBottom(); ?>
<div id="tabber" >
return html_build_select_box($this->getStatuses(), $name, $checked, $show_100, $text_100, false, '', false, $attrs);
}
+ /**
+ * priorityBox - show the priorities
+ *
+ * @return string HTML code
+ */
+ function priorityBox($name = 'priority', $checked_val = '3', $nochange = false, $attrs = array(), $show_any = false){
+ return html_build_priority_select_box($name, $checked_val, $nochange, $attrs, $show_any);
+ }
+
function javascript() {
$jsvariable ="
var invalidSelectMsg = '"._("One or more of the selected options is not allowed")."';
}).on('keydown', function(event){
if(event.keyCode !== 9) return false;
});
- $(".in-formula[name^='extra_fields']").on('change', function(){
- console.log('rtype=ajax&function=get_formulas_results&group_id='+groupId+'&atid='+atId+'&status='+$("select[name='status_id'] option:selected").text()+'&assigned_to='+$("select[name='assigned_to'] option:selected").text()+'&priority='+$("select[name='priority'] option:selected").text()+'&summary='+$('input#tracker-summary').val()+'&description='+$('textarea#tracker-description').val()+'&'+$("[name^='extra_fields']" ).serialize());
+ $(".in-formula").on('change', function(){
$.ajax({
type: 'POST',
url: 'index.php',
- data: 'rtype=ajax&function=get_formulas_results&group_id='+groupId+'&atid='+atId+'&status='+$("select[name='status_id'] option:selected").text()+'&assigned_to='+$("select[name='assigned_to'] option:selected").text()+'&priority='+$("select[name='priority'] option:selected").text()+'&summary='+$('input#tracker-summary').val()+'&description='+$('textarea#tracker-description').val()+'&'+$("[name^='extra_fields']" ).serialize(),
+ data: 'rtype=ajax&function=get_formulas_results&group_id='+groupId+'&atid='+atId+'&status='+$("select[name='status_id'] option:selected").text()+'&assigned_to='+$("select[name='assigned_to'] option:selected").text()+'&priority='+$("select[name='priority'] option:selected").text()+'&'+$("[name^='extra_fields'], #tracker-summary, #tracker-description").serialize(),
async: false,
dataType: 'json',
success: function(answer){
$ath->renderExtraFields($extra_fields,true,'none',false,'Any',array(),false,'NEW');
+ $fieldInFormula = $ath->getFieldsInFormula();
+
if (forge_check_perm ('tracker', $ath->getID(), 'manager')) {
$content = html_e('strong', array(), _('Assigned to')._(':')).html_e('br');
- $content .= $ath->technicianBox('assigned_to', $assigned_to);
+ if (in_array('assigned_to', $fieldInFormula)) {
+ $content .= $ath->technicianBox('assigned_to', $assigned_to, true, 'none', -1, '', false, array('class'=>'in-formula'));
+ } else {
+ $content .= $ath->technicianBox('assigned_to', $assigned_to);
+ }
$content .= ' '.util_make_link('/tracker/admin/?group_id='.$group->getID().'&atid='.$ath->getID().'&update_users=1', '('._('Admin').')' );
$cells = array();
$cells[][] = $content;
$content = html_e('strong', array(), _('Priority')._(':')).html_e('br');
- if (empty($priority)) {
- $content .= html_build_priority_select_box('priority');
+ if (in_array('priority', $fieldInFormula)) {
+ $content .= $ath->priorityBox('priority',$priority, false, array('class'=>'in-formula'));
} else {
- $content .= html_build_priority_select_box('priority',$priority);
+ $content .= $ath->priorityBox('priority',$priority);
}
$cells[][] = $content;
echo $HTML->multiTableRow(array(), $cells);
}
$content = html_e('strong', array(), _('Summary').utils_requiredField()._(':')).html_e('br');
- $content .= html_e('input', array('id'=>'tracker-summary', 'value'=>$summary, 'required'=>'required', 'type'=>'text', 'name'=>'summary', 'size'=>'80', 'maxlength'=>'255', 'title'=>util_html_secure(html_get_tooltip_description('summary'))));
+ if (in_array('summary', $fieldInFormula)) {
+ $content .= html_e('input', array('id'=>'tracker-summary', 'value'=>$summary, 'required'=>'required', 'type'=>'text', 'name'=>'summary', 'size'=>'80', 'maxlength'=>'255', 'title'=>util_html_secure(html_get_tooltip_description('summary')), 'class'=>'in-formula'));
+ } else {
+ $content .= html_e('input', array('id'=>'tracker-summary', 'value'=>$summary, 'required'=>'required', 'type'=>'text', 'name'=>'summary', 'size'=>'80', 'maxlength'=>'255', 'title'=>util_html_secure(html_get_tooltip_description('summary'))));
+ }
$cells = array();
$cells[] = array($content, 'colspan'=>'2');
echo $HTML->multiTableRow(array(), $cells);
$content = html_e('strong', array(), _('Detailed description').utils_requiredField()._(':'));
$content .= notepad_button('document.forms.trackeraddform.details').html_e('br');
- $content .= html_e('textarea', array('id'=>'tracker-description', 'required'=>'required', 'name'=>'details', 'rows'=>'20', 'style'=>'width: 100%', 'title'=>util_html_secure(html_get_tooltip_description('description'))), $details, false);
+ if (in_array('description', $fieldInFormula)) {
+ $content .= html_e('textarea', array('id'=>'tracker-description', 'required'=>'required', 'name'=>'details', 'rows'=>'20', 'class'=>'fullwidth in-formula', 'title'=>util_html_secure(html_get_tooltip_description('description'))), $details, false);
+ } else {
+ $content .= html_e('textarea', array('id'=>'tracker-description', 'required'=>'required', 'name'=>'details', 'rows'=>'20', 'class'=>'fullwidth', 'title'=>util_html_secure(html_get_tooltip_description('description'))), $details, false);
+ }
$cells = array();
$cells[] = array($content, 'colspan'=>'2');
echo $HTML->multiTableRow(array(), $cells);
$efarr [] = array('field_name'=>'Detailed description','alias'=>'description', 'field_type'=>ARTIFACT_EXTRAFIELDTYPE_TEXTAREA, 'extra_field_id'=>0);
if (!$ath->usesCustomStatuses()) {
- $efarr [] = array('field_name'=>'Status','alias'=>'status', 'field_type'=>'');
+ $efarr [] = array('field_name'=>'Status','alias'=>'status', 'field_type'=>ARTIFACT_EXTRAFIELDTYPE_STATUS);
}
usort($efarr, function($a, $b) {
$return = $HTML->listTableTop();
$i = 0;
$atf = new ArtifactTypeFactory ($group);
+ $fieldInFormula = $ath->getFieldsInFormula();
$cells = array();
if (forge_check_perm('tracker', $atid, 'manager') && ($func == 'detail')) {
$tids = array();
$cells = array();
$cells[][] = html_e('strong', array(), _('Assigned to')._(': '));
if (forge_check_perm('tracker', $atid, 'manager')) {
+ if (in_array('assigned_to', $fieldInFormula)) {
+ $techBoxClass = 'in-formula';
+ } else {
+ $techBoxClass = '';
+ }
if ($func == 'detail') {
- $cells[][] = $ath->technicianBox('assigned_to', $ah->getAssignedTo(), true, 'none', -1, '', false, array('form' => 'trackerform'));
+ $cells[][] = $ath->technicianBox('assigned_to', $ah->getAssignedTo(), true, 'none', -1, '', false, array('form' => 'trackerform', 'class'=>$class));
} else {
- $cells[][] = $ath->technicianBox('assigned_to', $assigned_to, true, 'none', -1, '', false, array('form' => 'trackerform'));
+ $cells[][] = $ath->technicianBox('assigned_to', $assigned_to, true, 'none', -1, '', false, array('form' => 'trackerform', 'class'=>$class));
}
} else {
$cells[][] = $ah->getAssignedRealName().' ('.$ah->getAssignedUnixName().')';
$cells = array();
$cells[][] = html_e('strong', array(), _('State')._(': '));
if (forge_check_perm('tracker', $atid, 'tech')) {
+ if (in_array('status', $fieldInFormula)) {
+ $class = 'in-formula';
+ } else {
+ $class = '';
+ }
if ($func == 'detail') {
- $cells[][] = $ath->statusBox('status_id', $ah->getStatusID(), false, '', array('form' => 'trackerform'));
+ $cells[][] = $ath->statusBox('status_id', $ah->getStatusID(), false, '', array('form' => 'trackerform', 'class'=>$class));
} else {
- $cells[][] = $ath->statusBox('status_id', 'xzxz', false, '', array('form' => 'trackerform'));
+ $cells[][] = $ath->statusBox('status_id', 'xzxz', false, '', array('form' => 'trackerform', 'class'=>$class));
}
} else {
$cells[][] = $ah->getStatusName();
$cells[][] = html_e('strong', array(), _('Priority')._(': '));
if (forge_check_perm('tracker', $atid, 'manager')) {
if ($func == 'detail') {
- $cells[][] = build_priority_select_box('priority', $ah->getPriority(), false, array('form' => 'trackerform'));
+ if (in_array('priority', $fieldInFormula)) {
+ $class = 'in-formula';
+ } else {
+ $class = '';
+ }
+ $cells[][] = $ath->priorityBox('priority', $ah->getPriority(), false, array('form' => 'trackerform', 'class'=>$class));
} else {
- $cells[][] = build_priority_select_box('priority', $priority, false, array('form' => 'trackerform'));
+ $cells[][] = $ath->priorityBox('priority', $priority, false, array('form' => 'trackerform', 'class'=>$class));
}
} else {
$cells[][] = $ah->getPriority();
global $summary;
global $details;
+ $fieldInFormula = $ath->getFieldsInFormula();
+
$return = '';
$inputAttrs = array('form' => 'trackerform', 'type' => 'text', 'name' => 'summary', 'style' => 'width:99%', 'value' => $summary);
if ($func == 'detail') {
$inputAttrs['required'] = 'required';
$requiredInfo = utils_requiredField();
}
+ if (in_array('summary', $fieldInFormula)) {
+ $inputAttrs['class'] = 'in-formula';
+ }
$return .= html_e('p', array(), _('Summary')._(': ').$requiredInfo.html_e('input', $inputAttrs));
+
+ if (in_array('description', $fieldInFormula)) {
+ $class = 'in-formula';
+ } else {
+ $class = '';
+ }
if ($func == 'detail') {
if (forge_check_perm('tracker', $atid, 'manager')) {
$editable = true;
} else {
$editable = false;
}
- $return .= $ah->showDetails($editable, array('form' => 'trackerform'));
+ $return .= $ah->showDetails($editable, array('form' => 'trackerform', 'class'=>$class));
} elseif ($func == 'add') {
$return .= notepad_func();
$return .= $HTML->listTableTop();
$content = html_e('strong', array(), _('Detailed description').$requiredInfo._(':'));
$content .= notepad_button('document.forms.trackerform.details');
- $content .= html_e('textarea', array('form' => 'trackerform', 'id'=>'tracker-description', 'required'=>'required', 'name'=>'details', 'rows'=>'20', 'style'=>'box-sizing: border-box; width: 100%', 'title'=>util_html_secure(html_get_tooltip_description('description'))), $details, false);
+ $content .= html_e('textarea', array('form' => 'trackerform', 'id'=>'tracker-description', 'required'=>'required', 'name'=>'details', 'rows'=>'20', 'class'=>$class, 'style'=>'box-sizing: border-box; width: 100%', 'title'=>util_html_secure(html_get_tooltip_description('description'))), $details, false);
$cells = array();
$cells[][] = $content;
$return .= $HTML->multiTableRow(array(), $cells);
* }
*/
$first_argument = false;
- $ternary = false;
while ( 1 ) { // 1 Infinite Loop ;)
$op = substr ( $expr, $index, 2 ); // get the first two characters at the current index
if (preg_match ( "/^[+\-*\/^_\"<>=%(){\[!~,?:](?!=|~)/", $op ) || preg_match ( "/\w/", $op )) {