function displayAdd($user_id) { global $art_field_fact, $art_fieldset_fact, $sys_max_size_attachment, $Language; $hp = Codendi_HTMLPurifier::instance(); $fields_per_line = 2; // the column number is the number of field per line * 2 (label + value) // + the number of field per line -1 (a blank column between each pair "label-value" to give more space) $columns_number = $fields_per_line * 2 + ($fields_per_line - 1); $max_size = 40; $group = $this->ArtifactType->getGroup(); $group_artifact_id = $this->ArtifactType->getID(); $group_id = $group->getGroupId(); $result_fieldsets = $art_fieldset_fact->getAllFieldSetsContainingUsedFields(); // Display submit informations if any if ($this->ArtifactType->getSubmitInstructions()) { echo $hp->purify(util_unconvert_htmlspecialchars($this->ArtifactType->getSubmitInstructions()), CODENDI_PURIFIER_FULL); } // Beginning of the submission form with fixed fields echo '<FORM ACTION="" METHOD="POST" enctype="multipart/form-data" NAME="artifact_form"> <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="' . $sys_max_size_attachment . '"> <INPUT TYPE="HIDDEN" NAME="func" VALUE="postadd"> <INPUT TYPE="HIDDEN" NAME="group_id" VALUE="' . (int) $group_id . '"> <INPUT TYPE="HIDDEN" NAME="atid" VALUE="' . (int) $group_artifact_id . '">'; echo '<TABLE><TR><TD class="artifact">'; $pm = ProjectManager::instance(); $html = ''; $html .= ' <TABLE width="100%"> <TR><TD VALIGN="TOP" COLSPAN="' . $columns_number . '"> <B>' . $Language->getText('tracker_include_artifact', 'group') . ':</B> ' . $hp->purify(util_unconvert_htmlspecialchars($pm->getProject($group_id)->getPublicName()), CODENDI_PURIFIER_CONVERT_HTML) . '</TD></TR>'; // Now display the variable part of the field list (depend on the project) foreach ($result_fieldsets as $fieldset_id => $result_fieldset) { // this variable will tell us if we have to display the fieldset or not (if there is at least one field to display or not) $display_fieldset = false; $fieldset_html = ''; $i = 0; $fields_in_fieldset = $result_fieldset->getAllUsedFields(); while (list($key, $field) = each($fields_in_fieldset)) { $field_html = new ArtifactFieldHtml($field); // if the field is a special field (except summary and original description) // or if not used by this project then skip it. // Plus only show fields allowed on the artifact submit_form if (!$field->isSpecial() || $field->getName() == 'summary' || $field->getName() == 'details') { if ($field->userCanSubmit($group_id, $group_artifact_id, $user_id)) { // display the artifact field with its default value // if field size is greatest than max_size chars then force it to // appear alone on a new line or it won't fit in the page // if the user can submit at least one field, we can display the fieldset this field is within $display_fieldset = true; $field_value = $field->getDefaultValue(); list($sz, ) = $field->getGlobalDisplaySize(); $label = $field_html->labelDisplay(false, false, true); $value = $field_html->display($group_artifact_id, $field_value, false, false); $star = $field->isEmptyOk() ? '' : '<span class="highlight"><big>*</big></b></span>'; if ($sz > $max_size || $field->getName() == 'details') { $fieldset_html .= "\n<TR>" . '<TD valign="top"><a class="artifact_field_tooltip" href="#" title="' . $hp->purify(SimpleSanitizer::unsanitize($field->getDescription()), CODENDI_PURIFIER_CONVERT_HTML) . '">' . $label . $star . '</a></td>' . '<TD valign="middle" colspan="' . ($columns_number - 1) . '">' . $value . '</TD>' . "\n</TR>"; $i = 0; } else { $fieldset_html .= $i % $fields_per_line ? '' : "\n<TR>"; $fieldset_html .= '<TD valign="middle"><a class="artifact_field_tooltip" href="#" title="' . $hp->purify(SimpleSanitizer::unsanitize($field->getDescription()), CODENDI_PURIFIER_CONVERT_HTML) . '">' . $label . $star . '</a></td>' . '<TD valign="middle">' . $value . '</TD>'; $i++; $fieldset_html .= $i % $fields_per_line ? '<td class="artifact_spacer"> </td>' : "\n</TR>"; } } } } // while // We display the fieldset only if there is at least one field inside that we can display if ($display_fieldset) { $html .= '<TR><TD COLSPAN="' . (int) $columns_number . '"> </TD></TR>'; $html .= '<TR class="boxtitle"><TD class="left" COLSPAN="' . (int) $columns_number . '"> <span title="' . $hp->purify(SimpleSanitizer::unsanitize($result_fieldset->getDescriptionText()), CODENDI_PURIFIER_CONVERT_HTML) . '">' . $hp->purify(SimpleSanitizer::unsanitize($result_fieldset->getLabel()), CODENDI_PURIFIER_CONVERT_HTML) . '</span></TD></TR>'; $html .= $fieldset_html; } } $html .= '</TABLE>'; echo $this->_getSection('artifact_section_details', $Language->getText('tracker_include_artifact', 'details'), $html, true); // // CC List // $html = ''; $html .= $Language->getText('tracker_include_artifact', 'fill_cc_list_msg'); $html .= $Language->getText('tracker_include_artifact', 'fill_cc_list_lbl'); $html .= '<textarea type="text" name="add_cc" id="tracker_cc" rows="2" cols="60" wrap="soft"></textarea>'; $html .= '<B> ' . $Language->getText('tracker_include_artifact', 'fill_cc_list_cmt') . ": </b>"; $html .= '<input type="text" name="cc_comment" size="40" maxlength="255">'; echo $this->_getSection('artifact_section_cc', $Language->getText('tracker_include_artifact', 'cc_list') . ' ' . help_button('tracker-v3.html#cc-list'), $html, true); // // File attachments // $html = ''; $html .= '<input type="file" name="input_file" size="40">'; $html .= $Language->getText('tracker_include_artifact', 'upload_file_msg', formatByteToMb($sys_max_size_attachment)); $html .= $Language->getText('tracker_include_artifact', 'upload_file_desc'); $html .= '<input type="text" name="file_description" size="60" maxlength="255">'; echo $this->_getSection('artifact_section_attachments', $Language->getText('tracker_include_artifact', 'attachment') . ' ' . help_button('tracker-v3.html#artifact-attachments'), $html, true); // // Artifact permissions // if ($this->ArtifactType->userIsAdmin()) { $checked = ''; if ($this->useArtifactPermissions()) { $checked = 'checked="checked"'; } $html = ''; $html .= '<p>'; $html .= '<label class="checkbox" for="use_artifact_permissions"><input type="hidden" name="use_artifact_permissions_name" value="0" />'; $html .= '<input type="checkbox" name="use_artifact_permissions_name" id="use_artifact_permissions" value="1" ' . $checked . ' />'; $html .= $GLOBALS['Language']->getText('tracker_include_artifact', 'permissions_label') . '</label>'; $html .= '</p>'; $html .= permission_fetch_selection_field('TRACKER_ARTIFACT_ACCESS', $this->getId(), $group_id); $html .= '<script type="text/javascript">'; $html .= "\n document.observe('dom:loaded', function() {\n if ( ! \$('use_artifact_permissions').checked) {\n \$('ugroups').disable();\n }\n \$('use_artifact_permissions').observe('click', function(evt) {\n if (this.checked) {\n \$('ugroups').enable();\n } else {\n \$('ugroups').disable();\n }\n });\n });\n </script>"; echo $this->_getSection('artifact_section_permissions', $Language->getText('tracker_include_artifact', 'permissions') . ' ' . help_button('tracker-v3.html#permissions-on-artifacts'), $html, false, $GLOBALS['Language']->getText('tracker_include_artifact', 'permissions_use_default')); } // // Final submit button // echo '<p><B><span class="highlight">' . $Language->getText('tracker_include_artifact', 'check_already_submitted') . '</b></p>'; echo '<div style="text-align:center"><INPUT CLASS="btn btn-primary" TYPE="SUBMIT" NAME="SUBMIT" VALUE="' . $Language->getText('tracker_include_artifact', 'submit') . '"></div>'; echo '</td></tr>'; echo '</table>'; echo '</form>'; }
/** * Display the artifact to do mass changes * * @param ro: read only parameter - Display mode or update mode * @param pv: printer version * @param query: only in the case of func=masschange, the query that retrieves all the artifacts to be changed * @param $mass_change_ids[]: only in the case of func=masschange_selected, an array containing all the artifact ids to be changed * * @return void */ function displayMassChange($ro, $mass_change_ids = null, $query = null, $art_report_html = null, $advsrch = 0) { global $art_field_fact, $sys_max_size_attachment, $Language; $hp = Codendi_HTMLPurifier::instance(); $fields_per_line = 2; $max_size = 40; $group = $this->getGroup(); $atid = $this->getID(); $group_id = $group->getGroupId(); if ($query) { $art_report_html->getQueryElements($query, $advsrch, $from, $where); $sql = "select distinct a.artifact_id " . $from . " " . $where; $result = db_query($sql); while ($row = db_fetch_array($result)) { $mass_change_ids[] = $row['artifact_id']; } } //if ($mass_change_ids) { echo '<H2>' . $Language->getText('tracker_include_type', 'changing_items', count($mass_change_ids)) . ' </H2>'; reset($mass_change_ids); while (list($key, $val) = each($mass_change_ids)) { $url = '/tracker/?func=detail&group_id=' . (int) $group_id . '&aid=' . (int) $val . '&atid=' . (int) $atid; if ($key == 0) { echo '<a href="' . $url . '">' . $hp->purify($this->getItemName(), CODENDI_PURIFIER_CONVERT_HTML) . ' #' . (int) $val . '</a>'; } if ($key > 0) { echo ', <a href="' . $url . '"> #' . (int) $val . '</a>'; } if ($key == 100) { echo ", .."; break; } } echo ' <br><br>'; echo ' <FORM ACTION="' . $_SERVER['PHP_SELF'] . '" METHOD="POST" enctype="multipart/form-data" NAME="masschange_form"> <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="' . $sys_max_size_attachment . '"> <INPUT TYPE="HIDDEN" NAME="func" VALUE="postmasschange"> <INPUT TYPE="HIDDEN" NAME="group_id" VALUE="' . (int) $group_id . '"> <INPUT TYPE="HIDDEN" NAME="atid" VALUE="' . (int) $atid . '">'; reset($mass_change_ids); while (list(, $val) = each($mass_change_ids)) { echo ' <INPUT TYPE="HIDDEN" NAME="mass_change_ids[]" VALUE="' . $hp->purify($val, CODENDI_PURIFIER_CONVERT_HTML) . '">'; } echo ' <TABLE cellpadding="0">'; //first special case for submitted_by $field = $art_field_fact->getFieldFromName('submitted_by'); $field_html = new ArtifactFieldHtml($field); $field_value = $Language->getText('global', 'unchanged'); list($sz, ) = explode("/", $field->getDisplaySize()); $label = $field_html->labelDisplay(false, false, !$ro); // original submission field must be displayed read-only $value = $field_html->display($this->getID(), $field_value, false, false, $ro, false, false, $Language->getText('global', 'none'), false, 'Any', true, $Language->getText('global', 'unchanged')); echo "\n<TR>"; echo ' <TD valign="top">' . $label . ' </TD> <TD valign="top">' . $value . ' </TD> <TD colspan="2"><FONT SIZE="-1"><INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="' . $Language->getText('tracker_include_type', 'submit_mass_change') . '"></TD>'; echo ' </TR> <TR><TD COLSPAN="' . $fields_per_line * 2 . '"> </TD></TR>'; // Now display the variable part of the field list (depend on the project) $i = 0; $result_fields = $art_field_fact->getAllUsedFields(); while (list($key, $field) = each($result_fields)) { $field_html = new ArtifactFieldHtml($field); // if the field is a special field (except summary and details) // then skip it. if (!$field->isSpecial() && $field->getName() != 'summary' && $field->getName() != 'details') { // display the artifact field // if field size is greatest than max_size chars then force it to // appear alone on a new line or it won't fit in the page $field_value = $Language->getText('global', 'unchanged'); list($sz, ) = explode("/", $field->getDisplaySize()); $label = $field_html->labelDisplay(false, false, !$ro); $value = $field_html->display($this->getID(), $field_value, false, false, $ro, false, false, $Language->getText('global', 'none'), false, $Language->getText('global', 'any'), true, $Language->getText('global', 'unchanged')); // Details field must be on one row if ($sz > $max_size) { echo "\n<TR>" . '<TD valign="top">' . $label . '</td>' . '<TD valign="top" colspan="' . (2 * $fields_per_line - 1) . '">' . $value . '</TD>' . "\n</TR>"; $i = 0; } else { echo $i % $fields_per_line ? '' : "\n<TR>"; echo '<TD valign="top">' . $label . '</td>' . '<TD valign="top">' . $value . '</TD>'; $i++; echo $i % $fields_per_line ? '' : "\n</TR>"; } } } // while echo ' </TABLE> <table cellspacing="0">'; // // Followups comments // echo ' <TR><TD colspan="2" align="top"><HR></td></TR> <TR><TD> <h3>' . $Language->getText('tracker_include_artifact', 'follow_ups') . ' ' . help_button('ArtifactUpdate.html#ArtifactComments') . '</h3></td> <TD> <INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="' . $Language->getText('tracker_include_type', 'submit_mass_change') . '"> </td></tr>'; echo ' <tr><TD colspan="2" align="top"> <B>' . $Language->getText('tracker_include_artifact', 'use_canned') . '</B> '; echo $this->cannedResponseBox(); echo ' <A HREF="/tracker/admin/?func=canned&atid=' . (int) $atid . '&group_id=' . (int) $group_id . '&create_canned=1">' . $Language->getText('tracker_include_artifact', 'define_canned') . '</A> </TD></TR>'; echo ' <TR><TD colspan="2">'; $field = $art_field_fact->getFieldFromName('comment_type_id'); if ($field) { $field_html = new ArtifactFieldHtml($field); echo '<P><B>' . $Language->getText('tracker_include_artifact', 'comment_type') . '</B>' . $field_html->fieldBox('', $atid, $field->getDefaultValue(), true, $Language->getText('global', 'none')) . '<BR>'; } // This div id used just to show the toggle of html format echo '<DIV ID="tracker_artifact_comment_label"></DIV>'; echo '<TEXTAREA NAME="comment" ID="tracker_artifact_comment" ROWS="10" style="width:100%" WRAP="SOFT"></TEXTAREA><p>'; echo '</td></tr>'; // // CC List // echo ' <TR><TD colspan="2"><hr></td></tr> <TR><TD colspan="2"> <h3>' . $Language->getText('tracker_include_artifact', 'cc_list') . ' ' . help_button('ArtifactUpdate.html#ArtifactCCList') . '</h3>'; if (!$ro) { echo ' ' . $Language->getText('tracker_include_artifact', 'fill_cc_list_msg'); echo $Language->getText('tracker_include_artifact', 'fill_cc_list_lbl'); echo '<input type="text" name="add_cc" id="tracker_cc" size="30">'; echo $Language->getText('tracker_include_artifact', 'fill_cc_list_cmt'); echo '<input type="text" name="cc_comment" size="40" maxlength="255">'; //echo autocomplete_for_lists_users('tracker_cc', 'tracker_cc_autocomplete'); } echo $this->showCCList($mass_change_ids); echo '</TD></TR>'; // // File attachments // echo ' <TR><TD colspan="2"><hr></td></tr> <TR><TD colspan="2"> <h3>' . $Language->getText('tracker_include_artifact', 'attachment') . ' ' . help_button('ArtifactUpdate.html#ArtifactAttachments') . '</h3>'; echo $Language->getText('tracker_include_artifact', 'upload_checkbox'); echo ' <input type="checkbox" name="add_file" VALUE="1">'; echo $Language->getText('tracker_include_artifact', 'upload_file_lbl'); echo '<input type="file" name="input_file" size="40">'; echo $Language->getText('tracker_include_artifact', 'upload_file_msg', formatByteToMb($sys_max_size_attachment)); echo $Language->getText('tracker_include_artifact', 'upload_file_desc'); echo '<input type="text" name="file_description" size="60" maxlength="255">'; reset($mass_change_ids); echo $this->showAttachedFiles($mass_change_ids); echo '</TD></TR>'; // // Artifact dependencies // echo ' <TR><TD colspan="2"><hr></td></tr> <TR ><TD colspan="2">'; echo '<h3>' . $Language->getText('tracker_include_artifact', 'dependencies') . ' ' . help_button('ArtifactUpdate.html#ArtifactDependencies') . '</h3> <B>' . $Language->getText('tracker_include_artifact', 'dependent_on') . '</B><BR> <P>'; if (!$ro) { echo ' <B>' . $Language->getText('tracker_include_artifact', 'aids') . '</B> <input type="text" name="artifact_id_dependent" size="20" maxlength="255"> <i>' . $Language->getText('tracker_include_artifact', 'fill') . '</i><p>'; } echo $this->showDependencies($mass_change_ids); echo '</TD></TR>'; // // Artifact permissions // if ($this->userIsAdmin()) { echo ' <TR><TD colspan="2"><hr></td></tr> <TR ><TD colspan="2">'; echo '<h3>' . $Language->getText('tracker_include_artifact', 'permissions') . ' ' . help_button('ArtifactUpdate.html#ArtifactPermissions') . '</h3>'; echo '<input type="hidden" name="change_permissions" value="0" />'; echo '<input type="checkbox" name="change_permissions" value="1" id="change_permissions" />'; echo '<label for="change_permissions">' . $GLOBALS['Language']->getText('tracker_include_type', 'mass_change_permissions') . '</label>'; echo '<blockquote>'; $checked = ''; $html = ''; $html .= '<p>'; $html .= '<input type="hidden" name="use_artifact_permissions_name" value="0" />'; $html .= '<input type="checkbox" name="use_artifact_permissions_name" id="use_artifact_permissions" value="1" ' . $checked . ' />'; $html .= '<label for="use_artifact_permissions">' . $GLOBALS['Language']->getText('tracker_include_artifact', 'permissions_label') . '</label>'; $html .= '</p>'; $html .= permission_fetch_selection_field('TRACKER_ARTIFACT_ACCESS', 0, $group_id); $html .= '<script type="text/javascript">'; $html .= "\n document.observe('dom:loaded', function() {\n //init\n if ( ! \$('use_artifact_permissions')|| ! \$('use_artifact_permissions').checked ) {\n \$('ugroups').disable();\n }\n if ( ! \$('change_permissions').checked) {\n \$('use_artifact_permissions').disable();\n }\n \n //event handlers\n \$('change_permissions').observe('change', function(evt) {\n if (this.checked) {\n \$('use_artifact_permissions').enable();\n if (\$('use_artifact_permissions').checked) {\n \$('ugroups').enable();\n }\n } else {\n \$('use_artifact_permissions').disable();\n \$('ugroups').disable();\n }\n });\n \n \$('use_artifact_permissions').observe('change', function(evt) {\n if (this.checked) {\n \$('ugroups').enable();\n } else {\n \$('ugroups').disable();\n }\n });\n });\n </script>"; echo $html; echo '</blockquote>'; echo '</TD></TR>'; } echo '<TR><TD colspan="2"><hr></td></tr>'; echo '</TD></TR> <TR><TD colspan="2" ALIGN="center"> <INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="' . $Language->getText('tracker_include_type', 'submit_mass_change') . '"> </FORM> </TD></TR>'; echo '</table>'; }
/** * return a field for the given user. * * @protected **/ function _getFieldLabelAndValueForHTMLMail($group_id, $group_artifact_id, $field, $field_perm) { $html = false; $read_only = true; $field_name = $field->getName(); if ($field_perm === false || isset($field_perm[$field_name]) && $field_perm[$field_name] && permission_can_read_field($field_perm[$field_name])) { // For multi select box, we need to retrieve all the values if ($field->isMultiSelectBox()) { $field_value = $field->getValues($this->getID()); } else { $field_value = $this->getValue($field->getName()); } $field_html = new ArtifactFieldHtml($field); $field_html->disableJavascript(); $label = $field_html->labelDisplay(false, false, false); if ($field->getName() == 'submitted_by') { $value = util_user_link(user_getname($field_value)); } else { if ($field->getName() == 'open_date') { $value = format_date($GLOBALS['Language']->getText('system', 'datefmt'), $field_value); } else { if ($field->getName() == 'last_update_date') { $value = format_date($GLOBALS['Language']->getText('system', 'datefmt'), $field_value); } else { $value = $field_html->display($this->ArtifactType->getID(), $field_value, false, false, $read_only, false, false, 0, false, 0, false, 0, false); $value = util_make_links($value, $group_id, $group_artifact_id); } } } $html = array('label' => $label, 'value' => $value); } return $html; }