Example #1
0
$tpl->setTemplate('select_customer.tpl.html');
session_start();
// check if cookies are enabled, first of all
if (!Auth::hasCookieSupport(APP_COOKIE)) {
    Auth::redirect('index.php?err=11');
}
if (!Auth::hasValidCookie(APP_COOKIE)) {
    Auth::redirect('index.php?err=5');
}
$prj_id = Auth::getCurrentProject();
$usr_id = Auth::getUserID();
$contact_id = User::getCustomerContactID($usr_id);
if (!CRM::hasCustomerIntegration($prj_id) || empty($contact_id)) {
    Auth::redirect('main.php');
}
$crm = CRM::getInstance($prj_id);
$contact = $crm->getContact($contact_id);
$customers = $contact->getCustomers();
if (isset($_REQUEST['customer_id'])) {
    $customer_id = $_REQUEST['customer_id'];
    if (in_array($customer_id, array_keys($customers))) {
        Auth::setCurrentCustomerID($customer_id);
        if (!empty($_POST['url'])) {
            Auth::redirect($_REQUEST['url']);
        } else {
            Auth::redirect('main.php');
        }
    }
}
$tpl->assign('customers', $customers);
$tpl->displayTemplate();
Example #2
0
    $auto_switched_from = $prj_id;
    $prj_id = $iss_prj_id;
}
$details = Issue::getDetails($issue_id);
if ($details == '') {
    Misc::displayErrorMessage(ev_gettext('Error: The issue #%1$s could not be found.', $issue_id));
}
// TRANSLATORS: %1 = issue id
$tpl->assign('issue', $details);
// in the case of a customer user, also need to check if that customer has access to this issue
if (!Issue::canAccess($issue_id, $usr_id)) {
    Misc::displayErrorMessage(ev_gettext('Sorry, you do not have the required privileges to view this issue.'));
} else {
    // if the issue has a different customer then the currently selected one, switch customers
    if (Auth::getCurrentRole() == User::getRoleID('Customer') && Auth::getCurrentCustomerID() != $details['iss_customer_id']) {
        Auth::setCurrentCustomerID($details['iss_customer_id']);
        Misc::setMessage("Active customer changed to '" . $details['customer']->getName() . '"');
        Auth::redirect(APP_RELATIVE_URL . 'view.php?id=' . $issue_id);
    }
    $associated_projects = @array_keys(Project::getAssocList($usr_id));
    if (empty($details) || $details['iss_prj_id'] != $prj_id) {
        Misc::displayErrorMessage(ev_gettext('Error: The issue #%1$s could not be found.', $issue_id));
    } else {
        // now that we can access to the issue, add more verbose HTML <title>
        // TRANSLATORS: Page HTML title: %1 = issue id, %2 = issue summary
        $tpl->assign('extra_title', ev_gettext('#%1$s - %2$s', $issue_id, $details['iss_summary']));
        // check if the requested issue is a part of one of the projects
        // associated with this user
        if (!@in_array($details['iss_prj_id'], $associated_projects)) {
            Misc::displayErrorMessage(ev_gettext('Sorry, you do not have the required privileges to view this issue.'));
        } else {