<?php

// Display lists of image sources, or lists of projects that used image sources
// List contents vary with user permissions
$relPath = '../../pinc/';
include_once $relPath . 'base.inc';
include_once $relPath . 'theme.inc';
include_once $relPath . 'project_states.inc';
include_once $relPath . 'dpsql.inc';
include_once $relPath . 'misc.inc';
// array_get()
include_once $relPath . 'pg.inc';
require_login();
$theme_args['css_data'] = "\nh1 { margin-top: 1em; }\ntable.individual { border-collapse: collapse; width: 80%; margin: auto; }\ntable.individual td,th { border: 1px solid #999; padding: 5px; }\ntable.individual td.center { text-align: center; }\ntable.individual th { background-color: #eeeeee; }\n.headerbg { background-color: " . $theme['color_logobar_bg'] . "; }\n\ntable.listing { width: 90%; margin: auto; border: solid black 1px; border-collapse: collapse; }\ntable.listing td,th { padding: 5px; }\ntable.listing th { background-color: #eeeeee; }\ntable.listing th + td { vertical-align: top; border: none; }\ntable.listing th.tl { vertical-align: top; text-align: left; border: none;}\ntable.listing td.center { text-align: center; }\ntr.first { border-top: double black; }\n.fullname { font-size: 120%; }\n.sourcelink { font-size: 90%; margin: 10px 0px 3px 25px; }\n.w15 { width: 15%; }\n";
$which = get_enumerated_param($_GET, 'which', 'DONE', array('ALL', 'DONE', 'INPROG'));
$locuserSettings =& Settings::get_Settings($pguser);
// ---------------------------------------
// Page construction varies with whether the user is logged in or out
if (isset($GLOBALS['pguser'])) {
    $logged_in = TRUE;
} else {
    $logged_in = FALSE;
}
if ($logged_in) {
    if (user_is_image_sources_manager()) {
        $min_vis_level = 0;
    } else {
        if (user_is_PM()) {
            $min_vis_level = 1;
        } else {
            $min_vis_level = 2;
 function log_request_for_approval($requestor_username)
 {
     global $general_help_email_addr, $image_sources_manager_addr, $code_url, $site_abbreviation, $site_name, $site_signoff;
     $userSettings =& Settings::get_Settings($requestor_username);
     $userSettings->add_value('is_approval_notify', $this->code_name);
     $subject = sprintf(_('%s: New Image Source proposed'), $site_abbreviation) . " : " . $this->display_name;
     $body = "Hello,\n\nYou are receiving this email because\n" . "you are listed as an Image Sources manager at the {$site_name}\n" . "site. If this is an error, please contact <{$general_help_email_addr}>.\n\n" . "{$requestor_username} has proposed that {$this->display_name} be added\n" . "to the list of Image Sources. To edit or approve this Image Source,\n" . "visit\n    {$code_url}/tools/project_manager/manage_image_sources.php?action=show_sources#{$this->code_name}" . "\n\n{$site_signoff}";
     maybe_mail($image_sources_manager_addr, $subject, $body);
 }
Beispiel #3
0
function TaskDetails($tid)
{
    global $requester_u_id, $tasks_url;
    global $os_array, $browser_array, $tasks_close_array;
    global $pguser;
    if (!is_numeric($tid)) {
        ShowNotification("Error: task identifier '{$tid}' is not numeric.");
        return;
    }
    $res = mysql_query("SELECT * FROM tasks WHERE task_id = {$tid} LIMIT 1");
    if (mysql_num_rows($res) >= 1) {
        while ($row = mysql_fetch_assoc($res)) {
            $userSettings =& Settings::get_Settings($pguser);
            $notification_settings = $userSettings->get_values('taskctr_notice');
            if (in_array($tid, $notification_settings) || in_array('all', $notification_settings)) {
                $already_notified = 1;
            } else {
                $already_notified = 0;
            }
            $opened_by_link = property_format_value('opened_by', $row, FALSE);
            $edited_by_link = property_format_value('edited_by', $row, FALSE);
            // Task id, summary, and possible Edit/Re-Open Task buttons.
            echo "<table class='tasks'>\n";
            echo "<tr bgcolor='#ecdbb7'>";
            echo "<td width='90%' valign='middle'>";
            echo "Task #{$tid}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . property_format_value('task_summary', $row, FALSE);
            echo "</td>";
            echo "<td width='10%' valign='middle' style='text-align:right;'>";
            echo "<form action='{$tasks_url}' method='post'>\n";
            if ((user_is_a_sitemanager() || user_is_taskcenter_mgr() || $row['opened_by'] == $requester_u_id) && empty($row['closed_reason'])) {
                echo "<input type='hidden' name='action' value='show_editing_form'>\n";
                echo "<input type='hidden' name='task_id' value='{$tid}'>\n";
                echo "<input type='submit' value='Edit Task' class='taskinp2'>\n";
            } elseif (!empty($row['closed_reason'])) {
                echo "<input type='hidden' name='action' value='reopen'>\n";
                echo "<input type='hidden' name='task_id' value='{$tid}'>\n";
                echo "<input type='submit' value='Re-Open Task' class='taskinp2'>\n";
            } else {
                echo "&nbsp;\n";
            }
            echo "</form>";
            echo "</td>";
            echo "</tr>";
            echo "</table>\n";
            echo "<table class='tasks'>\n";
            // Row 1: Opened & Last edited. Link to toggle task notifications.
            echo "<tr>";
            echo "<td width='50%'>";
            echo "<small class='task'>";
            echo "Opened by {$opened_by_link} - " . property_format_value('date_opened', $row, FALSE);
            echo "<br />";
            echo "Last edited by {$edited_by_link} - " . property_format_value('date_edited', $row, FALSE);
            echo "</small>";
            echo "</td>";
            echo "<td width='50%' style='text-align:right;'>";
            if (empty($already_notified)) {
                echo "<a href='{$tasks_url}?action=notify_me&task_id={$tid}'>Signup for task notifications</a>";
            } else {
                echo "<a href='{$tasks_url}?action=unnotify_me&task_id={$tid}'>Remove me from task notifications</a>";
            }
            echo "</tr>\n";
            // Row 2: most of the task's simple properties
            echo "<tr>";
            echo "<td width='40%'>";
            echo "<table class='taskplain'>\n";
            property_echo_value_tr('task_type', $row);
            property_echo_value_tr('task_category', $row);
            property_echo_value_tr('task_status', $row);
            property_echo_value_tr('task_assignee', $row);
            property_echo_value_tr('task_os', $row);
            echo "</table>";
            echo "</td>";
            echo "<td width='50%'>";
            echo "<table class='taskplain'>\n";
            property_echo_value_tr('task_browser', $row);
            property_echo_value_tr('task_severity', $row);
            property_echo_value_tr('task_priority', $row);
            property_echo_value_tr('task_version', $row);
            property_echo_value_tr('percent_complete', $row);
            echo "</table>";
            echo "</td>";
            echo "</tr>\n";
            // Row 3: summary of votes/metoos
            $voteInfo = mysql_query("SELECT id FROM tasks_votes WHERE task_id = {$tid}");
            $osInfo = mysql_query("SELECT DISTINCT vote_os FROM tasks_votes WHERE task_id = {$tid}");
            $browserInfo = mysql_query("SELECT DISTINCT vote_browser FROM tasks_votes WHERE task_id = {$tid}");
            if (mysql_num_rows($voteInfo) > 0) {
                $reportedOS = "";
                $reportedBrowser = "";
                echo "<tr>";
                echo "<td colspan='2'>";
                echo "<table class='taskplain'>";
                echo "<tr>";
                echo "<td width='25%'>";
                echo "<b>Votes&nbsp;&nbsp;</b>";
                echo "</td>\n";
                echo "<td width='75%'>";
                echo mysql_num_rows($voteInfo);
                echo "</td>";
                echo "</tr>";
                echo "<tr>";
                echo "<td width='25%'>";
                echo "<b>Reported Operating Systems&nbsp;&nbsp;</b>";
                echo "</td>\n";
                echo "<td width='75%'>";
                while ($rowOS = mysql_fetch_assoc($osInfo)) {
                    $reportedOS .= $os_array[$rowOS['vote_os']] . ", ";
                }
                echo substr($reportedOS, 0, -2);
                echo "</td>";
                echo "</tr>";
                echo "<tr>";
                echo "<td width='25%'>";
                echo "<b>Reported Browsers&nbsp;&nbsp;</b>";
                echo "</td>\n";
                echo "<td width='75%'>";
                while ($rowBrowser = mysql_fetch_assoc($browserInfo)) {
                    $reportedBrowser .= $browser_array[$rowBrowser['vote_browser']] . ", ";
                }
                echo substr($reportedBrowser, 0, -2);
                echo "</td>";
                echo "</tr>";
                echo "</table>";
                echo "</td>";
                echo "</tr>";
            }
            // Row 4: details
            echo "<tr>";
            echo "<td>";
            echo "<br />";
            echo "<table class='taskplain'>";
            echo "<tr>";
            echo "<td width='5%'>";
            echo "<b>Details&nbsp;&nbsp;</b>";
            echo "</td>\n";
            echo "<td width='95%' class='taskvalue'>";
            echo property_format_value('task_details', $row, FALSE);
            echo "</td>";
            echo "</tr>";
            echo "</table>";
            echo "</td>";
            echo "</tr>\n";
            // Row 5: Close Task. Me Too!
            echo "<tr>\n";
            if ((user_is_a_sitemanager() || user_is_taskcenter_mgr()) && empty($row['closed_reason'])) {
                echo "\n                    <td>\n                      <br />\n                      <form action='{$tasks_url}' method='post'>\n                        <input type='hidden' name='action' value='close'>\n                        <input type='hidden' name='task_id' value='{$tid}'>\n                        <table class='taskplain'>\n                          <tr>\n                            <td width='20%' valign='bottom'>\n                              <b>Close Task&nbsp;&nbsp;</b>\n                            </td>\n                            <td valign='bottom' width='80%'>\n                ";
                dropdown_select('closed_reason', "", $tasks_close_array);
                echo "\n                              <input type='submit' value='Close Task' class='taskinp2'>\n                            </td>\n                          </tr>\n                        </table>\n                      </form>\n                    </td>\n                ";
            } elseif (!empty($row['closed_reason'])) {
                $closed_by = property_format_value('closed_by', $row, FALSE);
                $date_closed = property_format_value('date_closed', $row, FALSE);
                $reason = property_format_value('closed_reason', $row, FALSE);
                echo "\n                    <td>\n                      <br />\n                      <small class='task'>\n                        Closed by: {$closed_by}\n                        <br />\n                        Date Closed: {$date_closed}\n                        <br />\n                        Reason: {$reason}\n                      </small>\n                    </td>\n                ";
            }
            echo "<td>";
            echo "<br />";
            $meTooCheckResult = mysql_query("\n                SELECT id\n                FROM tasks_votes\n                WHERE task_id = {$tid} and u_id = {$requester_u_id}\n            ");
            $meTooAllowed = mysql_num_rows($meTooCheckResult) == 0;
            mysql_free_result($meTooCheckResult);
            if ($meTooAllowed) {
                echo "<input type='button' value='Me Too!' class='taskinp2' onClick=\"showSpan('MeTooMain');\">";
            } else {
                echo "&nbsp;";
            }
            echo "</td>";
            echo "</tr>";
            echo "</table>";
            echo "<br />\n";
            if ($meTooAllowed) {
                MeToo($tid, $row['task_os'], $row['task_browser']);
            }
            TaskComments($tid);
            RelatedTasks($tid);
            echo "<br />\n";
            RelatedPostings($tid);
        }
    } else {
        ShowNotification("Task #{$tid} was not found!");
    }
}
    // And it's an action hat is valid for the subject user at the current time.
    // So put it on the queue.
    // (Don't execute any actions unless they're all valid.)
    $actions[$activity_id] = $action_type;
}
if (count($actions) == 0) {
    die("Warning: you did not specify any modifications");
}
echo "<br>\n";
echo "Those modifications appear to be valid.<br>\n";
echo "Performing them now...<br>\n";
foreach ($actions as $activity_id => $action_type) {
    echo "<br>\n";
    echo "{$action_type} {$activity_id} ...<br>\n";
    $yesno = $action_type == 'grant' ? 'yes' : 'no';
    $userSettings =& Settings::get_Settings($subject_username);
    $userSettings->set_value("{$activity_id}.access", $yesno);
    log_access_change($subject_username, $pguser, $activity_id, $action_type);
}
echo "<br>\n";
echo "Done<br>\n<br>\n";
if ($notify_user) {
    echo "Notifying user... " . notify_user($subject_username, $actions) . "<br>\n<br>\n";
}
echo "Hit 'Back' to return to user's detail page. (And you may need to reload.)<br>\n";
// -----------------------------------------------------------------------------
function notify_user($username, $actions)
{
    global $site_name, $site_signoff;
    $user = new User($username);
    if (count($actions) == 1 && array_search('grant', $actions) !== false) {