/** * artifact_to_soap : return the soap artifact structure giving a PHP Artifact Object. * @access private * * WARNING : We check the permissions here : only the readable fields are returned. * * @param Object{Artifact} $artifact the artifact to convert. * @return array the SOAPArtifact corresponding to the Artifact Object */ function artifact_to_soap($artifact) { $return = array(); // We check if the user can view this artifact if ($artifact->userCanView()) { // artifact_id $return['artifact_id'] = $artifact->getId(); // tracker_id $return['tracker_id'] = $artifact->getTrackerId(); // value $artifact_value = array(); $last_changeset = $artifact->getLastChangeset(); $last_changeset_values = $last_changeset->getValues(); $ff = Tracker_FormElementFactory::instance(); foreach ($last_changeset_values as $field_id => $field_value) { if ($field_value) { if ($field = $ff->getFormElementById($field_id)) { if ($field->userCanRead()) { $artifact_value[] = array('field_name' => $field->getName(), 'field_label' => $field->getLabel(), 'field_value' => $field_value->getSoapValue()); } } } } $return['value'] = $artifact_value; } return $return; }
/** * artifact_to_soap : return the soap artifact structure giving a PHP Artifact Object. * @access private * * WARNING : We check the permissions here : only the readable fields are returned. * * @param Object{Artifact} $artifact the artifact to convert. * @return array the SOAPArtifact corresponding to the Artifact Object */ function artifact_to_soap($artifact) { global $art_field_fact; $return = array(); // We check if the user can view this artifact if ($artifact->userCanView(user_getid())) { $extrafieldvalues = array(); $extrafielddata = $artifact->getExtraFieldData(); if (is_array($extrafielddata) && count($extrafielddata) > 0) { while (list($field_id, $value) = each($extrafielddata)) { $field = $art_field_fact->getFieldFromId($field_id); if ($field->userCanRead($artifact->ArtifactType->Group->getID(), $artifact->ArtifactType->getID(), user_getid())) { $extrafieldvalues[] = array('field_id' => $field_id, 'artifact_id' => $artifact->getID(), 'field_value' => html_entity_decode($value)); } } } // Check Permissions on standard fields (status_id, submitted_by, open_date, close_date, last_update_date, summary, details, severity) // artifact_id $field_artifact_id = $art_field_fact->getFieldFromName('artifact_id'); if ($field_artifact_id && $field_artifact_id->userCanRead($artifact->ArtifactType->Group->getID(), $artifact->ArtifactType->getID(), user_getid())) { $return['artifact_id'] = $artifact->getID(); } // group_artifact_id $return['group_artifact_id'] = $artifact->ArtifactType->getID(); // status_id $field_status_id = $art_field_fact->getFieldFromName('status_id'); if ($field_status_id && $field_status_id->userCanRead($artifact->ArtifactType->Group->getID(), $artifact->ArtifactType->getID(), user_getid())) { $return['status_id'] = $artifact->getStatusID(); } // submitted_by $field_submitted_by = $art_field_fact->getFieldFromName('submitted_by'); if ($field_submitted_by && $field_submitted_by->userCanRead($artifact->ArtifactType->Group->getID(), $artifact->ArtifactType->getID(), user_getid())) { $return['submitted_by'] = $artifact->getSubmittedBy(); } // open_date $field_open_date = $art_field_fact->getFieldFromName('open_date'); if ($field_open_date && $field_open_date->userCanRead($artifact->ArtifactType->Group->getID(), $artifact->ArtifactType->getID(), user_getid())) { $return['open_date'] = $artifact->getOpenDate(); } // close_date $field_close_date = $art_field_fact->getFieldFromName('close_date'); if ($field_close_date && $field_close_date->userCanRead($artifact->ArtifactType->Group->getID(), $artifact->ArtifactType->getID(), user_getid())) { $return['close_date'] = $artifact->getCloseDate(); } // last_update_date $field_last_update_date = $art_field_fact->getFieldFromName('last_update_date'); if ($field_last_update_date && $field_last_update_date->userCanRead($artifact->ArtifactType->Group->getID(), $artifact->ArtifactType->getID(), user_getid())) { $return['last_update_date'] = $artifact->getLastUpdateDate(); } // summary $field_summary = $art_field_fact->getFieldFromName('summary'); if ($field_summary && $field_summary->userCanRead($artifact->ArtifactType->Group->getID(), $artifact->ArtifactType->getID(), user_getid())) { $return['summary'] = util_unconvert_htmlspecialchars($artifact->getSummary()); } // details $field_details = $art_field_fact->getFieldFromName('details'); if ($field_details && $field_details->userCanRead($artifact->ArtifactType->Group->getID(), $artifact->ArtifactType->getID(), user_getid())) { $return['details'] = util_unconvert_htmlspecialchars($artifact->getDetails()); } // severity $field_severity = $art_field_fact->getFieldFromName('severity'); if ($field_severity && $field_severity->userCanRead($artifact->ArtifactType->Group->getID(), $artifact->ArtifactType->getID(), user_getid())) { $return['severity'] = $artifact->getSeverity(); } $return['extra_fields'] = $extrafieldvalues; } return $return; }