$new = '';
foreach (explode(' ',$value) as $id) {
if (preg_match('/^(\d+)$/', $id)) {
- if ($id == $this->getID) {
+ if ($id == $this->getID()) {
$this->setError('Illegal id '.$id.', self reference for field: '.$ef[$efid]['field_name'].'.'); // @todo: lang
return false;
}
return $return;
}
+ function setParent($parent_id){
+ $return = false;
+ $update = false;
+ if ($this->getParent()) {
+ if ($this->getParent() == $parent_id) {
+ return true;
+ } else {
+ $this->setError(_('Error')._(':').' '.sprintf(_('Artifact $s has already a parent', $child_id)));
+ return false;
+ }
+ }
+ $extra_fields = $this->getExtraFieldData();
+ $priority = $this->getPriority();
+ $status_id = $this->getStatusID();
+ $status_id = $this->getArtifactType()->remapStatus($status_id, $extra_fields);
+ $assigned_to = $this->getAssignedTo();
+ $summary = $this->getSummary();
+ $canned_response = 100;
+ $details = "";
+ $artifact_type_id = $this->getArtifactType()->getID();
+ $description = $this->getDetails();
+ $ef_parent_arr= $this->getArtifactType()->getExtraFields(array(ARTIFACT_EXTRAFIELDTYPE_PARENT));
+ $ef_parent = array_shift($ef_parent_arr);
+ $ef_parent_id = $ef_parent['extra_field_id'];
+ $extra_fields[$ef_parent_id] = $parent_id;
+ $ret['ef_parent_id'] = $ef_parent_id;
+ $return = $this->update($priority,$status_id,
+ $assigned_to,$summary,$canned_response,$details,$artifact_type_id,
+ $extra_fields, $description);
+ unset($this->parent);
+ $this->fetchData($this->getID());
+ return $return;
+ }
+
function getPermalink() {
return '/tracker/a_follow.php/'.$this->getID();
}
*/
require_once $gfcommon.'tracker/ArtifactExpression.class.php';
+require_once $gfcommon.'tracker/Artifact.class.php';
global $group;
global $atid;
$description = getStringFromRequest('description');
echo get_formulas_results($group, $atid, $extra_fields, $status, $assigned_to, $priority, $summary, $description);
break;
+ case 'add_parent':
+ $aid = getIntFromRequest('aid');
+ $parent_id = getIntFromRequest('parent_id');
+ echo add_parent($aid, $parent_id);
+ break;
+ case 'add_child':
+ $aid = getIntFromRequest('aid');
+ $child_id = getIntFromRequest('child_id');
+ echo add_child($aid, $child_id);
+ break;
default:
echo '';
break;
$ret['fields'] = $result;
return json_encode($ret);
}
+
+function add_parent($child_id, $parent_id){
+ $ret = array('message' => '');
+ $artifact = artifact_get_object($child_id);
+ $at = $artifact->getArtifactType();
+ $child = new ArtifactHtml($at, $child_id);
+ if (!$child->setParent($parent_id)) {
+ $ret['message']=$child->getErrorMessage();
+ return json_encode($ret);
+ exit();
+ }
+ $ret['parent_id'] = $parent_id;
+ $ef_parent_arr= $at->getExtraFields(array(ARTIFACT_EXTRAFIELDTYPE_PARENT));
+ $ef_parent = array_shift($ef_parent_arr);
+ $ret['parent_efid'] = $ef_parent['extra_field_id'];
+ $ret['parent_link'] = _artifactid2url($parent_id, 'title');
+ $ret['parent'] = $child->showParent();
+ return json_encode($ret);
+ exit();
+}
+
+function add_child($parent_id, $child_id){
+ $ret = array('message' => '');
+ $artifact = artifact_get_object($child_id);
+ $at = $artifact->getArtifactType();
+ $child = new ArtifactHtml($at, $child_id);
+ if (!$child->setParent($parent_id)) {
+ $ret['message']=$child->getErrorMessage();
+ return json_encode($ret);
+ exit();
+ }
+ $artifact = artifact_get_object($parent_id);
+ $at = $artifact->getArtifactType();
+ $parent= new ArtifactHtml($at, $parent_id);
+ $ret['children'] = $parent->showChildren();
+ return json_encode($ret);
+ exit();
+}
\ No newline at end of file
</div><?php
if (forge_get_config('use_artefacts_dependencies')) { ?>
<div id="tabber-dependencies" class="tabbertab">
- <?php
- echo '<strong>'._('Parent').'</strong><br>';
- echo $ah->showParent().'<br>';
- echo '<strong>'._('Children').'</strong><br>';
- echo $ah->showChildren();
+ <?php echo $ah->showDependencies()
?>
</div><?php
}
</div><?php
if (forge_get_config('use_artefacts_dependencies')) { ?>
<div id="tabber-dependencies" class="tabbertab">
- <?php
- echo '<strong>'._('Parent').'</strong><br>';
- echo $ah->showParent().'<br>';
- echo '<strong>'._('Children').'</strong><br>';
- echo $ah->showChildren();
+ <?php echo $ah->showDependencies();
?>
</div><?php
}
</div><?php
if (forge_get_config('use_artefacts_dependencies')) { ?>
<div id="tabber-dependencies" class="tabbertab">
- <?php
- echo '<strong>'._('Parent').'</strong><br>';
- echo $ah->showParent().'<br>';
- echo '<strong>'._('Children').'</strong><br>';
- echo $ah->showChildren();
- ?>
+ <?php echo $ah->showDependencies(); ?>
</div><?php
}
if (forge_get_config('use_object_associations')) { ?>
$rows= count($children);
$return = '';
if ($rows > 0){
- $return = ' <table class="fullwidth">
+ $return = ' <table class="children fullwidth">
<tr>
<td colspan="2">';
$current = '';
$return = '';
if ($parentId){
$parent = artifact_get_object($parentId);
- $return = ' <table class="fullwidth">
+ $return = ' <table class="parent fullwidth">
<tr>
<td colspan="2">';
$parentAt = $parent->getArtifactType();
$return .= '</td>
</tr>
</table>';
+ } else {
+ $return = ' <table class="parent fullwidth"></table>';
+ }
+ return $return;
+ }
+
+ function showDependencies() {
+ global $HTML;
+ $return = '';
+ $ef_parent = $this->getArtifactType()->getExtraFields(array(ARTIFACT_EXTRAFIELDTYPE_PARENT));
+ if (count($ef_parent)) {
+ $return .= html_e('input', array('type'=>'hidden','id'=>'aid', 'value'=>$this->getID()));
+ $return .= html_ao('div',array('class'=>'fullwidth'));
+ $return .= html_e('strong',array(),_('Parent')).html_e('br');
+ $return .= $this->showParent();
+ if ($this->hasParent()) {
+ $return .= html_ao('div',array('class'=>'fullwidth addparent hide'));
+ } else {
+ $return .= html_ao('div',array('class'=>'fullwidth addparent'));
+ }
+ $return .= html_e('input', array('type'=>'text', 'id'=>'parent_id', 'value'=>'', 'size'=>20, 'maxlength'=>80, 'pattern'=>'^(?!'.$this->getID().'$)\d*$'));
+ $return .= $HTML->getAddPic(_('Click to add parent'), _('Click to add parent'), array('name'=>'addparent')).html_e('br');
+ $return .= html_ac(html_ap()-1);
+ $return .= html_ac(html_ap()-1).html_e('br');
+ $return .= html_ao('div',array('class'=>'fullwidth'));
+ $return .= html_e('strong',array(),_('Children')).html_e('br');
+ $return .= $this->showChildren();
+ $return .= html_ao('div',array('class'=>'fullwidth addchild'));
+ $return .= html_e('input', array('type'=>'text', 'id'=>'child_id', 'value'=>'', 'size'=>20, 'maxlength'=>80, 'pattern'=>'^(?!'.$this->getID().'$)\d*$'));
+ $return .= $HTML->getAddPic(_('Click to add child'), _('Click to add child'), array('name'=>'addchild'));
+ $return .= html_ac(html_ap()-1);
+ $return .= html_ac(html_ap()-1);
}
return $return;
}
var invalidInputMsg = '". _("This choice is not allowed")."';
var groupId =".$this->Group->getID().";
var atId = ".$this->getID().";";
-
$effortUnitSet = New EffortUnitSet($this, $this->getEffortUnitSet());
if ($effortUnitSet->isAutoconvert()) {
$jseffort = <<<'EOS'
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()+'&'+$("[name^='extra_fields'], #tracker-summary, #tracker-description, [name='priority']").serialize(),
async: false,
dataType: 'json',
- contentType:"application/json; charset=utf-8",
success: function(answer){
if(answer['message']) {
showMessage(answer['message'], 'error');
}
});
});
+
+
+
+
+ $("img[name='addparent']").click(function(){
+ $.ajax({
+ type: 'POST',
+ url: 'index.php',
+ data: 'rtype=ajax&function=add_parent&group_id='+groupId+'&atid='+atId+'&aid='+$("input#aid").val()+'&parent_id='+$("input#parent_id").val(),
+ async: false,
+ dataType: 'json',
+ success: function(answer){
+ if(answer['message']) {
+ showMessage(answer['message'], 'error');
+ } else {
+ $("table.parent").replaceWith(answer['parent']);
+ $("input[name='extra_fields["+answer['parent_efid']+"]']").val(answer['parent_id']);
+ $("div#show"+answer['parent_efid']).html(answer['parent_link']);
+ $("input#parent_id").val('');
+ $("div.addparent").addClass('hide');
+ }
+ return true;
+ }
+ });
+ });
+
+
+ $("img[name='addchild']").click(function(){
+ $.ajax({
+ type: 'POST',
+ url: 'index.php',
+ data: 'rtype=ajax&function=add_child&group_id='+groupId+'&atid='+atId+'&aid='+$("input#aid").val()+'&child_id='+$("input#child_id").val(),
+ async: false,
+ dataType: 'json',
+ success: function(answer){
+ if(answer['message']) {
+ showMessage(answer['message'], 'error');
+ } else {
+ $("table.children").replaceWith(answer['children']);
+ $("input#child_id").val('');
+ }
+ return true;
+ }
+ });
+ });
+
+
$(".autoassign[name^='extra_fields']").change(function(){
if ($(this).prop('tagName') == 'SELECT') {
var elmnts = $(this).children('option:selected');
$ah->showRelations());
if (forge_get_config('use_artefacts_dependencies')) {
$tabberContent .= html_e('div', array('id' => 'tabber-dependencies', 'class' => 'tabbertab'),
- html_e('strong',array(),_('Parent')).html_e('br').
- $ah->showParent().html_e('br').
- html_e('strong',array(),_('Children')).html_e('br').
- $ah->showChildren());
+ $ah->showDependencies());
}
if (forge_get_config('use_object_associations')) {
$associationContent = $ah->showAssociations('/tracker/?func=removeassoc&aid='.$ah->getID().'&group_id='.$group_id.'&atid='.$ath->getID());
return $this->getPicto('ic/add.png', $title, $alt, 20, 20, $otherAttr);
}
+ function getAddPic($title = '', $alt = '', $otherAttr = array()) {
+ return $this->getPicto('ic/add-16.png', $title, $alt, 16, 16, $otherAttr);
+ }
+
function getFolderPic($title = '', $alt = '', $otherAttr = array()) {
return $this->getPicto('ic/folder.png', $title, $alt, 20, 20, $otherAttr);
}