Ejemplo n.º 1
0
    /**
     * 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 . '&nbsp;</TD>
            <TD valign="top">' . $value . '&nbsp;</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 . '">&nbsp</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>&nbsp;';
        echo $this->cannedResponseBox();
        echo '
            &nbsp;&nbsp;&nbsp;<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>&nbsp;
                        <input type="text" name="artifact_id_dependent" size="20" maxlength="255">
                        &nbsp;<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>';
    }
Ejemplo n.º 2
0
 /**
  * Display the artifact
  *
  * @param ro: read only parameter - Display mode or update mode
  * @param pv: printer version
  *
  * @return void
  */
 function displayCopy($ro, $pv)
 {
     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_fields = $art_field_fact->getAllUsedFields();
     $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="postcopy">
             <INPUT TYPE="HIDDEN" NAME="group_id" VALUE="' . (int) $group_id . '">
             <INPUT TYPE="HIDDEN" NAME="group_artifact_id" VALUE="' . (int) $group_artifact_id . '">
             <INPUT TYPE="HIDDEN" NAME="atid" VALUE="' . (int) $group_artifact_id . '">';
     echo '<TABLE><TR><TD class="artifact">';
     $summary = $this->getValue('summary');
     echo "<TABLE width='100%'><TR><TD>";
     echo "<H2>[ " . $hp->purify($Language->getText('tracker_include_artifact', 'copy_of', $this->ArtifactType->getItemName() . " #" . $this->getID()) . " ] " . $summary, CODENDI_PURIFIER_CONVERT_HTML) . "</H2>";
     echo "</TD></TR></TABLE>";
     $html = '';
     $pm = ProjectManager::instance();
     $html .= '
         <table width="100%">
           <tr><td colspan="' . (int) $columns_number . '"><B>' . $Language->getText('tracker_include_artifact', 'group') . ':</B>&nbsp;' . $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);
             //echo $field_html->dumpStandard()."<br>";
             // if the field is a special field (except summary and details)
             // then skip it.
             if ($field->userCanSubmit($group_id, $group_artifact_id) && (!$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
                 $display_fieldset = true;
                 // For multi select box, we need to retrieve all the values
                 if ($field->isMultiSelectBox()) {
                     $field_value = $field->getValues($this->getID());
                 } else {
                     if ($field->getName() == 'summary') {
                         $field_value = '[' . $Language->getText('tracker_include_artifact', 'copy') . '] ' . $this->getValue($field->getName());
                     } else {
                         $field_value = $this->getValue($field->getName());
                     }
                 }
                 list($sz, ) = explode("/", $field->getDisplaySize());
                 $label = $field_html->labelDisplay(false, false, !$ro);
                 $value = $field_html->display($this->ArtifactType->getID(), $field_value, false, false, $ro);
                 $star = $field->isEmptyOk() ? '' : '<span class="highlight"><big>*</big></b></span>';
                 // Details field must be on one row
                 if ($sz > $max_size || $field->getName() == 'details') {
                     $fieldset_html .= "\n<TR>" . '<TD valign="middle">' . $label . $star . '</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">' . $label . $star . '</td>' . '<TD valign="middle">' . $value . '</TD>';
                     $i++;
                     $fieldset_html .= $i % $fields_per_line ? '<td class="artifact_spacer">&nbsp;</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 . '">&nbsp</TD></TR>';
             $html .= '<TR class="boxtitle"><TD class="left" COLSPAN="' . (int) $columns_number . '">&nbsp;<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);
     //
     // Followups comments
     //
     $html = '';
     $html .= '<div>';
     if (!$ro) {
         if (db_numrows($this->ArtifactType->getCannedResponses())) {
             $html .= '<p><b>' . $Language->getText('tracker_include_artifact', 'use_canned') . '</b>&nbsp;';
             $html .= $this->ArtifactType->cannedResponseBox();
             $html .= '</p>';
         }
         $field = $art_field_fact->getFieldFromName('comment_type_id');
         if ($field && $field->isUsed() && db_numrows($field->getFieldPredefinedValues($group_artifact_id)) > 1) {
             $field_html = new ArtifactFieldHtml($field);
             $html .= '<P><B>' . $Language->getText('tracker_include_artifact', 'comment_type') . '</B>' . $field_html->fieldBox('', $group_artifact_id, $field->getDefaultValue(), true, $Language->getText('global', 'none')) . '<BR>';
         }
         // This div id used just to show the toggle of html format
         $html .= '<DIV ID="follow_up_comment_label"></DIV>';
         $html .= '<TEXTAREA NAME="follow_up_comment" id="tracker_artifact_comment" ROWS="10" style="width:700px;" WRAP="SOFT">';
         $html .= $hp->purify($Language->getText('tracker_include_artifact', 'is_copy', array($this->ArtifactType->getItemName(), $this->ArtifactType->getItemName() . ' #' . $this->getID())), CODENDI_PURIFIER_CONVERT_HTML);
         $html .= '</TEXTAREA>';
     } else {
         if ($pv == 0) {
             $html .= '<b>' . $Language->getText('tracker_include_artifact', 'add_comment') . '</b>';
             $html .= '<DIV ID="follow_up_comment_label"></DIV>';
             $html .= '<TEXTAREA NAME="follow_up_comment" id="tracker_artifact_comment" ROWS="10" style="width:700px;" WRAP="SOFT">' . $hp->purify($Language->getText('tracker_include_artifact', 'is_copy', array($this->ArtifactType->getItemName(), $this->ArtifactType->getItemName() . ' #' . $this->getID())), CODENDI_PURIFIER_CONVERT_HTML) . '</TEXTAREA>';
         }
     }
     if (!user_isloggedin() && $pv == 0) {
         $html .= $Language->getText('tracker_include_artifact', 'not_logged_in', '/account/login.php?return_to=' . urlencode($_SERVER['REQUEST_URI']));
         $html .= '<br><input type="text" name="email" maxsize="100" size="50"/><p>';
     }
     $html .= '</div>';
     $html .= "<br />";
     $title = $Language->getText('tracker_include_artifact', 'follow_ups') . ' ';
     $title .= help_button('tracker-v3.html#comments');
     echo $this->_getSection('artifact_section_followups', $title, $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>&nbsp;&nbsp;&nbsp;' . $Language->getText('tracker_include_artifact', 'fill_cc_list_cmt') . ":&nbsp</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 dependencies
     //
     $html = '
     <P><B>' . $Language->getText('tracker_include_artifact', 'dependent_on') . '</B><BR>
     <P>';
     if (!$ro) {
         $html .= '
                     <B>' . $Language->getText('tracker_include_artifact', 'aids') . '</B>&nbsp;
                     <input type="text" name="artifact_id_dependent" size="20" maxlength="255" value="' . (int) $this->getID() . '">
                     &nbsp;<span style="color:#666">' . $Language->getText('tracker_include_artifact', 'fill') . '</span><p>';
     }
     echo $this->_getSection('artifact_section_dependencies', $Language->getText('tracker_include_artifact', 'dependencies') . ' ' . help_button('tracker-v3.html#artifact-dependencies'), $html, true);
     //
     // 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>';
 }