/**
     * 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>';
    }
 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>&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);
             // 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">&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);
     //
     // 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 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>';
 }
Beispiel #3
0
 /**
  * Display access control management for gitolite backend
  *
  * @param GitRepository $repository The repository
  * 
  * @return void
  */
 protected function _accessControlGitolite($repository)
 {
     echo '<table>';
     echo '<thead><tr>';
     echo '<td>' . $this->getText('perm_R') . '</td>';
     echo '<td>' . $this->getText('perm_W') . '</td>';
     echo '<td>' . $this->getText('perm_W+') . '</td>';
     echo '</tr></thead>';
     echo '<tbody><tr>';
     // R
     echo '<td>';
     echo permission_fetch_selection_field('PLUGIN_GIT_READ', $repository->getId(), $this->groupId, 'repo_access[read]');
     echo '</td>';
     // W
     echo '<td>';
     echo permission_fetch_selection_field('PLUGIN_GIT_WRITE', $repository->getId(), $this->groupId, 'repo_access[write]');
     echo '</td>';
     // W+
     echo '<td>';
     echo permission_fetch_selection_field('PLUGIN_GIT_WPLUS', $repository->getId(), $this->groupId, 'repo_access[wplus]');
     echo '</td>';
     echo '</tr></tbody>';
     echo '</table>';
 }
 public function getPlanningPermissionForm($planning_id, $group_id, $permission, $html_element_name)
 {
     return permission_fetch_selection_field($permission, $planning_id, $group_id, $html_element_name);
 }
Beispiel #5
0
function permission_fetch_selection_field_without_project_admins_and_nobody($permission_type, $object_id, $group_id, $htmlname = 'ugroups', $disabled = false)
{
    return permission_fetch_selection_field($permission_type, $object_id, $group_id, $htmlname, $disabled, false, false);
}
Beispiel #6
0
/**
 * Display permission selection box for the given object.
 * The result of this form should be parsed with permission_process_selection_form()
 *
 * For the list of supported permission_type and id, see above in file header.
 */
function permission_fetch_selection_form($permission_type, $object_id, $group_id, $post_url)
{
    $html = '';
    if (!$post_url) {
        $post_url = $_SERVER['PHP_SELF'];
    }
    // Display form
    $html .= '<FORM ACTION="' . $post_url . '" METHOD="POST">
        <INPUT TYPE="HIDDEN" NAME="func" VALUE="update_permissions">
        <INPUT TYPE="HIDDEN" NAME="group_id" VALUE="' . $group_id . '">
        <INPUT TYPE="HIDDEN" NAME="permission_type" VALUE="' . $permission_type . '">
        <INPUT TYPE="HIDDEN" NAME="object_id" VALUE="' . $object_id . '">';
    $html .= permission_fetch_selection_field($permission_type, $object_id, $group_id);
    $html .= '<p><INPUT TYPE="SUBMIT" NAME="submit" VALUE="' . $GLOBALS['Language']->getText('project_admin_permissions', 'submit_perm') . '">';
    $html .= '<INPUT TYPE="SUBMIT" NAME="reset" VALUE="' . $GLOBALS['Language']->getText('project_admin_permissions', 'reset_to_def') . '">';
    $html .= '</FORM>';
    $html .= '<p>' . $GLOBALS['Language']->getText('project_admin_permissions', 'admins_create_modify_ug', array("/project/admin/editugroup.php?func=create&group_id={$group_id}", "/project/admin/ugroup.php?group_id={$group_id}"));
    return $html;
}