/** * 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>'; }
/** for a certain set of users being part of the same ugroups * create the mail body containing only fields that they have the permission to read */ function createMailForUsers($ugroups, $changes, $group_id, $group_artifact_id, &$ok, &$subject) { global $art_field_fact, $art_fieldset_fact, $Language; $fmt_len = 40; $fmt_left = sprintf("%%-%ds ", $fmt_len - 1); $fmt_right = "%s"; $artifact_href = get_server_url() . "/tracker/?func=detail&aid=" . $this->getID() . "&atid={$group_artifact_id}&group_id={$group_id}"; $used_fields = $art_field_fact->getAllUsedFields(); $art_fieldset_fact = new ArtifactFieldsetFactory($this->ArtifactType); $used_fieldsets = $art_fieldset_fact->getAllFieldSetsContainingUsedFields(); $ok = false; $body = ''; //generate the field permissions (TRACKER_FIELD_READ, TRACKER_FIEDL_UPDATE or nothing) //for all fields of this tracker given the $ugroups the user is part of $field_perm = false; if ($ugroups) { $field_perm = $this->ArtifactType->getFieldPermissions($ugroups); } $summ = ""; if ($field_perm === false || isset($field_perm['summary']) && $field_perm['summary'] && permission_can_read_field($field_perm['summary'])) { $summ = util_unconvert_htmlspecialchars($this->getValue('summary')); } $subject = '[' . $this->ArtifactType->getCapsItemName() . ' #' . $this->getID() . '] ' . $summ; //echo "<br>......... field_perm for "; print_r($ugroups); echo " = "; print_r($field_perm); // artifact fields // Generate the message preamble with all required // artifact fields - Changes first if there are some. if ($changes) { $body = $GLOBALS['sys_lf'] . "============= " . strtoupper(SimpleSanitizer::unsanitize($this->ArtifactType->getName())) . " #" . $this->getID() . ": " . $Language->getText('tracker_include_artifact', 'latest_modif') . " =============" . $GLOBALS['sys_lf'] . $artifact_href . $GLOBALS['sys_lf'] . $GLOBALS['sys_lf'] . $this->formatChanges($changes, $field_perm, $visible_change) . $GLOBALS['sys_lf'] . $GLOBALS['sys_lf'] . $GLOBALS['sys_lf'] . $GLOBALS['sys_lf'] . ""; if (!$visible_change) { return; } } $ok = true; $visible_snapshot = false; $full_snapshot = ""; // We write the name of the project $pm = ProjectManager::instance(); $full_snapshot .= sprintf($fmt_left . $GLOBALS['sys_lf'] . "", $Language->getText('tracker_include_artifact', 'project') . ' ' . util_unconvert_htmlspecialchars($pm->getProject($group_id)->getPublicName())); // Write all the fields, grouped by fieldsetset and ordered by rank. $left = 1; $visible_fieldset = false; // fetch list of used fieldsets for this artifact foreach ($used_fieldsets as $fieldset_id => $fieldset) { $fieldset_snapshot = ''; $used_fields = $fieldset->getAllUsedFields(); // fetch list of used fields and the current field values // for this artifact while (list($key, $field) = each($used_fields)) { $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])) { $field_html = new ArtifactFieldHtml($field); $visible_fieldset = true; $visible_snapshot = true; // 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()); } $display = $field_html->display($group_artifact_id, $field_value, false, true, true, true); $item = sprintf($left ? $fmt_left : $fmt_right, $display); if (strlen($item) > $fmt_len) { if (!$left) { $fieldset_snapshot .= "" . $GLOBALS['sys_lf'] . ""; } $fieldset_snapshot .= sprintf($fmt_right, $display); $fieldset_snapshot .= "" . $GLOBALS['sys_lf'] . ""; $left = 1; } else { $fieldset_snapshot .= $item; $left = !$left; if ($left) { $fieldset_snapshot .= "" . $GLOBALS['sys_lf'] . ""; } } } } // while if ($visible_fieldset) { $full_snapshot .= "" . $GLOBALS['sys_lf'] . ""; $full_snapshot .= $left ? "" : "" . $GLOBALS['sys_lf'] . ""; $full_snapshot .= '--- ' . SimpleSanitizer::unsanitize($fieldset->getLabel()) . ' ---'; $full_snapshot .= "" . $GLOBALS['sys_lf'] . ""; $full_snapshot .= $fieldset_snapshot; } } if ($visible_snapshot) { $full_snapshot .= "" . $GLOBALS['sys_lf'] . ""; } $body .= "============= " . strtoupper(SimpleSanitizer::unsanitize($this->ArtifactType->getName())) . " #" . $this->getID() . ": " . $Language->getText('tracker_include_artifact', 'full_snapshot') . " =============" . $GLOBALS['sys_lf'] . ($changes ? '' : $artifact_href) . $GLOBALS['sys_lf'] . $GLOBALS['sys_lf'] . $full_snapshot; if (!$left) { $body .= "" . $GLOBALS['sys_lf'] . ""; } // Now display other special fields // Then output the history of bug comments from newest to oldest $body .= $this->showFollowUpComments($group_id, 0, self::OUTPUT_MAIL_TEXT); // Then output the CC list $body .= "" . $GLOBALS['sys_lf'] . $GLOBALS['sys_lf'] . $this->showCCList($group_id, $group_artifact_id, true); // Then output the dependencies $body .= "" . $GLOBALS['sys_lf'] . $GLOBALS['sys_lf'] . $this->showDependencies($group_id, $group_artifact_id, true); // Then output the history of attached files from newest to oldest $body .= "" . $GLOBALS['sys_lf'] . $GLOBALS['sys_lf'] . $this->showAttachedFiles($group_id, $group_artifact_id, true); // Extract references from the message $referenceManager =& ReferenceManager::instance(); $ref_array = $referenceManager->extractReferencesGrouped($body, $group_id); if (count($ref_array) > 0) { $body .= $GLOBALS['sys_lf'] . $GLOBALS['sys_lf'] . $Language->getText('tracker_include_artifact', 'references') . $GLOBALS['sys_lf']; } foreach ($ref_array as $description => $match_array) { $body .= $GLOBALS['sys_lf'] . $description . ":" . $GLOBALS['sys_lf']; foreach ($match_array as $match => $ref_instance) { $reference =& $ref_instance->getReference(); $body .= ' ' . $ref_instance->getMatch() . ': ' . $ref_instance->getFullGotoLink() . $GLOBALS['sys_lf']; } } // Finally output the message trailer $body .= "" . $GLOBALS['sys_lf'] . $GLOBALS['sys_lf'] . $Language->getText('tracker_include_artifact', 'follow_link'); $body .= "" . $GLOBALS['sys_lf'] . $artifact_href; if ($ok) { $mail = new Mail(); $mail->setBody($body); return $mail; } else { return null; } }
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 HTML code to display the query fields * * @param prefs: array of parameters used for the current query * @param advsrch,pv: HTTP get variables * * @return string * */ function displayQueryFields($prefs, $advsrch, $pv) { global $ath, $Language; $hp = Codendi_HTMLPurifier::instance(); $html_select = ''; // // Loop through the list of used fields to define label and fields/boxes // used as search criteria // $query_fields = $this->getQueryFields(); //the width has been removed to correct the display of the Query Form (related to the fix of STTab theme) $html_select .= "<table>"; $labels = ''; $boxes = ''; // Number of search criteria (boxes) displayed in one row $this->fields_per_line = 5; $ib = 0; $is = 0; $load_cal = false; while (list($key, $field) = each($query_fields)) { $field_html = new ArtifactFieldHtml($field); //echo $field->getName()."-".$field->display_type."-".$field->data_type."-".$field->dump()."<br>"; // beginning of a new row if ($ib % $this->fields_per_line == 0) { $align = "left"; $labels .= "\n" . '<TR align="' . $align . '" valign="top">'; $boxes .= "\n" . '<TR align="' . $align . '" valign="top">'; } // Need to build help button argument. // Concatenate 3 args in one string $group_id = $ath->Group->getID(); $help_args = $group_id . '|' . $this->group_artifact_id . '|' . $field->getName(); $labels .= '<td class="small"><b>' . $hp->purify(SimpleSanitizer::unsanitize($field->getLabel()), CODENDI_PURIFIER_CONVERT_HTML) . ' ' . help_button('browse_tracker_query_field', $help_args) . '</b></td>'; $boxes .= '<TD><FONT SIZE="-1">'; if ($field->isSelectBox()) { // Check for advanced search if you have the field in the $prefs (HTTP parameters) if ($advsrch) { if (isset($prefs[$field->getName()]) && $prefs[$field->getName()]) { if (is_array($prefs[$field->getName()])) { $values = $prefs[$field->getName()]; } else { $values[] = $prefs[$field->getName()]; } } else { $values[] = 0; } } else { if (isset($prefs[$field->getName()][0])) { $values = $prefs[$field->getName()][0]; } else { $values = ""; } } $boxes .= $field_html->display($this->group_artifact_id, $values, false, false, $pv != 0 ? true : false, false, true, $Language->getText('global', 'none'), true, $Language->getText('global', 'any')); } else { if ($field->isMultiSelectBox()) { $boxes .= $field_html->display($this->group_artifact_id, $prefs[$field->getName()], false, false, $pv != 0 ? true : false, false, true, $Language->getText('global', 'none'), true, $Language->getText('global', 'any')); } else { if ($field->isDateField()) { $load_cal = true; // We need to load the Javascript Calendar if ($advsrch) { $date_begin = isset($prefs[$field->getName()][0]) ? $prefs[$field->getName()][0] : ''; $date_end = isset($prefs[$field->getName() . '_end'][0]) ? $prefs[$field->getName() . '_end'][0] : ''; $boxes .= $field_html->multipleFieldDate($date_begin, $date_end, 0, 0, $pv); } else { $val_op = isset($prefs[$field->getName() . '_op'][0]) ? $prefs[$field->getName() . '_op'][0] : ''; $val = isset($prefs[$field->getName()][0]) ? $prefs[$field->getName()][0] : ''; $boxes .= $field_html->fieldDateOperator($val_op, $pv) . $field_html->fieldDate($val, $pv); } } else { if ($field->isTextField() || $field->isTextArea()) { $val = isset($prefs[$field->getName()][0]) ? $prefs[$field->getName()][0] : ""; $boxes .= $pv != 0 ? $val : $field_html->fieldText(stripslashes($val), 15, 80); } } } } $boxes .= "</TD>\n"; $ib++; // end of this row if ($ib % $this->fields_per_line == 0) { $html_select .= $labels . '</TR>' . $boxes . '</TR>'; $labels = $boxes = ''; } } // Make sure the last few cells are in the table if ($labels) { $html_select .= $labels . '</TR>' . $boxes . '</TR>'; } $html_select .= "</table>"; return $html_select; }