~eventum-developers/eventum/trunk

« back to all changes in this revision

Viewing changes to htdocs/view.php

  • Committer: Bryan Alsdorf
  • Date: 2013-08-23 03:50:34 UTC
  • mto: (4033.1.168 eventum-skysql)
  • mto: This revision was merged to the branch mainline in revision 4660.
  • Revision ID: bryan@montyprogram.com-20130823035034-7f5r3pt1xg0xnnhk
Initial commit of CRM migration

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
 
57
57
$details = Issue::getDetails($issue_id);
58
58
if ($details == '') {
59
 
    Misc::setMessage(ev_gettext('Error: The issue #%1$s could not be found.', $issue_id), Misc::MSG_ERROR);
60
 
    $tpl->displayTemplate();
61
 
    exit;
 
59
    Misc::displayErrorMessage(ev_gettext('Error: The issue #%1$s could not be found.', $issue_id));
62
60
}
63
61
 
64
62
// TRANSLATORS: %1 = issue id
65
63
$tpl->assign("issue", $details);
66
 
$tpl->assign('customer_template_path', Customer::getTemplatePath($prj_id));
67
64
 
68
65
// in the case of a customer user, also need to check if that customer has access to this issue
69
 
if (($role_id == User::getRoleID('customer')) && ((empty($details)) || (User::getCustomerID($usr_id) != $details['iss_customer_id'])) ||
70
 
        !Issue::canAccess($issue_id, $usr_id)) {
71
 
    Misc::setMessage(ev_gettext('Sorry, you do not have the required privileges to view this issue.'), Misc::MSG_ERROR);
72
 
    $tpl->displayTemplate();
73
 
    exit;
 
66
if (!Issue::canAccess($issue_id, $usr_id)) {
 
67
    Misc::displayErrorMessage(ev_gettext('Sorry, you do not have the required privileges to view this issue.'));
74
68
} else {
 
69
 
 
70
    // if the issue has a different customer then the currently selected one, switch customers
 
71
    if (Auth::getCurrentRole() == User::getRoleID("Customer") && Auth::getCurrentCustomerID() != $details['iss_customer_id']) {
 
72
        Auth::setCurrentCustomerID($details['iss_customer_id']);
 
73
        Misc::setMessage("Active customer changed to '" . $details['customer']->getName() . '"');
 
74
        Auth::redirect(APP_RELATIVE_URL . "view.php?id=" . $issue_id);
 
75
    }
 
76
 
75
77
    $associated_projects = @array_keys(Project::getAssocList($usr_id));
76
78
    if ((empty($details)) || ($details['iss_prj_id'] != $prj_id)) {
77
 
        $tpl->assign('issue', '');
 
79
        Misc::displayErrorMessage(ev_gettext(ev_gettext('Error: The issue #%1$s could not be found.', $issue_id)));
78
80
    } else {
79
81
        // now that we can access to the issue, add more verbose HTML <title>
80
82
        // TRANSLATORS: Page HTML title: %1 = issue id, %2 = issue summary
83
85
        // check if the requested issue is a part of one of the projects
84
86
        // associated with this user
85
87
        if (!@in_array($details['iss_prj_id'], $associated_projects)) {
86
 
            $tpl->assign("auth_customer", 'denied');
 
88
            Misc::displayErrorMessage(ev_gettext('Sorry, you do not have the required privileges to view this issue.'));
87
89
        } else {
88
90
            $options = Search::saveSearchParams();
89
91
            $sides = Issue::getSides($issue_id, $options);