示例#1
0
include_once APP_INC_PATH . "class.workflow.php";
include_once APP_INC_PATH . "db_access.php";
$tpl = new Template_API();
$tpl->setTemplate("manage/index.tpl.html");
Auth::checkAuthentication(APP_COOKIE);
$tpl->assign("type", "projects");
$role_id = Auth::getCurrentRole();
if ($role_id == User::getRoleID('administrator') || $role_id == User::getRoleID('manager')) {
    if ($role_id == User::getRoleID('administrator')) {
        $tpl->assign("show_setup_links", true);
    }
    if (@$HTTP_POST_VARS["cat"] == "new") {
        $tpl->assign("result", Project::insert());
    } elseif (@$HTTP_POST_VARS["cat"] == "update") {
        $tpl->assign("result", Project::update());
    } elseif (@$HTTP_POST_VARS["cat"] == "delete") {
        Project::remove();
    }
    $tpl->assign("active_projects", Project::getAssocList(Auth::getUserID(), true));
    if (@$HTTP_GET_VARS["cat"] == "edit") {
        $tpl->assign("info", Project::getDetails($HTTP_GET_VARS["id"]));
    }
    $tpl->assign("list", Project::getList());
    $tpl->assign("user_options", User::getActiveAssocList(false, NULL, false, false, true));
    $tpl->assign("status_options", Status::getAssocList());
    $tpl->assign("customer_backends", Customer::getBackendList());
    $tpl->assign("workflow_backends", Workflow::getBackendList());
} else {
    $tpl->assign("show_not_allowed_msg", true);
}
$tpl->displayTemplate();
示例#2
0
 /**
  * @param int $week
  * @param string $start
  * @param string $end
  * @param bool $separate_closed
  * @return string
  * @access protected
  * @deprecated use getWeeklyReportData() and format data yourself
  */
 public function getWeeklyReport($week, $start, $end, $separate_closed)
 {
     $usr_id = Auth::getUserID();
     $week = abs($week);
     // we have to set a project so the template class works, even though the weekly report doesn't actually need it
     $projects = Project::getAssocList(Auth::getUserID());
     $prj_id = current(array_keys($projects));
     AuthCookie::setProjectCookie($prj_id);
     $prj_id = Auth::getCurrentProject();
     // figure out the correct week
     if (empty($start) || empty($end)) {
         $start = date('U') - Date_Helper::DAY * (date('w') - 1);
         if ($week > 0) {
             $start = $start - Date_Helper::WEEK * $week;
         }
         $end = date('Y-m-d', $start + Date_Helper::DAY * 6);
         $start = date('Y-m-d', $start);
     }
     if ($separate_closed) {
         // emulate smarty value for reports/weekly_data.tpl.tmpl:
         // {if $smarty.post.separate_closed == 1}
         $_POST['separate_closed'] = true;
     }
     $options = array('separate_closed' => $separate_closed);
     $tpl = new Template_Helper();
     $tpl->setTemplate('reports/weekly_data.tpl.html');
     $tpl->assign(array('report_type' => 'weekly', 'data' => Report::getWeeklyReport($usr_id, $prj_id, $start, $end, $options)));
     $ret = $tpl->getTemplateContents() . "\n";
     return $ret;
 }
示例#3
0
 /**
  * Gets the current selected project from the project cookie.
  *
  * @access  public
  * @return  integer The project ID
  */
 function getCurrentProject()
 {
     $cookie = Auth::getCookieInfo(APP_PROJECT_COOKIE);
     if (empty($cookie)) {
         return "";
     }
     $usr_id = Auth::getUserID();
     $projects = Project::getAssocList($usr_id);
     if ($usr_id == APP_SYSTEM_USER_ID) {
         return $cookie['prj_id'];
     }
     if (!in_array($cookie["prj_id"], array_keys($projects))) {
         Auth::redirect(APP_RELATIVE_URL . "select_project.php?err=1");
     }
     return $cookie["prj_id"];
 }
示例#4
0
 /**
  * Gets the current selected project from the project cookie.
  *
  * @return  integer The project ID
  */
 public static function getCurrentProject($redirect = true)
 {
     $cookie = self::getCookieInfo(APP_PROJECT_COOKIE);
     if (empty($cookie) || @$cookie['prj_id'] == false) {
         return '';
     }
     $usr_id = self::getUserID();
     $projects = Project::getAssocList($usr_id);
     if ($usr_id == APP_SYSTEM_USER_ID) {
         return isset($cookie['prj_id']) ? (int) $cookie['prj_id'] : null;
     }
     if ($projects != null && !in_array($cookie['prj_id'], array_keys($projects))) {
         if ($redirect) {
             self::redirect('select_project.php');
         } else {
             return false;
         }
     }
     return $cookie['prj_id'];
 }
 /**
  * Method used to send the account details of an user.
  *
  * @access  public
  * @param   integer $usr_id The user ID
  * @return  void
  */
 function notifyAccountDetails($usr_id)
 {
     $info = User::getDetails($usr_id);
     $info["projects"] = Project::getAssocList($usr_id, true, true);
     // open text template
     $tpl = new Template_API();
     $tpl->setTemplate('notifications/account_details.tpl.text');
     $tpl->bulkAssign(array("app_title" => Misc::getToolCaption(), "user" => $info));
     $text_message = $tpl->getTemplateContents();
     // send email (use PEAR's classes)
     $mail = new Mail_API();
     $mail->setTextBody($text_message);
     $setup = $mail->getSMTPSettings();
     $mail->send($setup["from"], $mail->getFormattedName($info["usr_full_name"], $info["usr_email"]), APP_SHORT_NAME . ": Your User Account Details");
 }
示例#6
0
function getWeeklyReport($p)
{
    $email = XML_RPC_decode($p->getParam(0));
    $password = XML_RPC_decode($p->getParam(1));
    $auth = authenticate($email, $password);
    if (is_object($auth)) {
        return $auth;
    }
    $week = abs(XML_RPC_decode($p->getParam(2)));
    $start = XML_RPC_decode($p->getParam(3));
    $end = XML_RPC_decode($p->getParam(4));
    // we have to set a project so the template class works, even though the weekly report doesn't actually need it
    $projects = Project::getAssocList(Auth::getUserID());
    createFakeCookie($email, current(array_keys($projects)));
    // figure out the correct week
    if (empty($start) || empty($end)) {
        $start = date("U") - DAY * (date("w") - 1);
        if ($week > 0) {
            $start = $start - WEEK * $week;
        }
        $end = date("Y-m-d", $start + DAY * 6);
        $start = date("Y-m-d", $start);
    }
    $tpl = new Template_API();
    $tpl->setTemplate("reports/weekly_data.tpl.html");
    $tpl->assign("data", Report::getWeeklyReport(User::getUserIDByEmail($email), $start, $end));
    $ret = $tpl->getTemplateContents() . "\n";
    return new XML_RPC_Response(XML_RPC_Encode(base64_encode($ret)));
}
示例#7
0
            Auth::setCurrentProject($prj_id, 0);
            checkCustomerAuthentication($prj_id);
            Auth::redirect($_GET['url']);
        }
    }
    $tpl->assign('active_projects', $assigned_projects);
}
if (@$_GET['err'] != '') {
    Auth::removeCookie(APP_PROJECT_COOKIE);
    $tpl->assign('err', $_GET['err']);
}
$select_prj = isset($_POST['cat']) && $_POST['cat'] == 'select' || isset($_GET['project']) && $_GET['project'];
if ($select_prj) {
    $prj_id = (int) (@$_POST['cat'] == 'select') ? (int) @$_POST['project'] : (int) @$_GET['project'];
    $usr_id = Auth::getUserID();
    $projects = Project::getAssocList($usr_id);
    if (!in_array($prj_id, array_keys($projects))) {
        // show error message
        $tpl->assign('err', 1);
    } else {
        // create cookie and redirect
        if (empty($_POST['remember'])) {
            $_POST['remember'] = 0;
        }
        Auth::setCurrentProject($prj_id, $_POST['remember']);
        checkCustomerAuthentication($prj_id);
        if (!empty($_POST['url'])) {
            Auth::redirect($_POST['url']);
        } else {
            Auth::redirect('list.php');
        }
示例#8
0
 /**
  * Method to update the details of a specific issue.
  *
  * @param   integer $issue_id The issue ID
  * @return  integer 1 if the update worked, -1 or -2 otherwise
  */
 public static function update($issue_id)
 {
     $issue_id = (int) $issue_id;
     $usr_id = Auth::getUserID();
     $prj_id = self::getProjectID($issue_id);
     $workflow = Workflow::preIssueUpdated($prj_id, $issue_id, $usr_id, $_POST);
     if ($workflow !== true) {
         return $workflow;
     }
     // get all of the 'current' information of this issue
     $current = self::getDetails($issue_id);
     $associated_issues = isset($_POST['associated_issues']) ? explode(',', $_POST['associated_issues']) : array();
     self::updateAssociatedIssuesRelations($issue_id, $associated_issues);
     $assignments_changed = false;
     if (@$_POST['keep_assignments'] == 'no') {
         // only change the issue-user associations if there really were any changes
         $old_assignees = array_merge($current['assigned_users'], $current['assigned_inactive_users']);
         if (!empty($_POST['assignments'])) {
             $new_assignees = @$_POST['assignments'];
         } else {
             $new_assignees = array();
         }
         $assignment_notifications = array();
         // remove people from the assignment list, if appropriate
         foreach ($old_assignees as $assignee) {
             if (!in_array($assignee, $new_assignees)) {
                 self::deleteUserAssociation($issue_id, $assignee);
                 $assignments_changed = true;
             }
         }
         // add people to the assignment list, if appropriate
         foreach ($new_assignees as $assignee) {
             if (!in_array($assignee, $old_assignees)) {
                 self::addUserAssociation($usr_id, $issue_id, $assignee);
                 Notification::subscribeUser($usr_id, $issue_id, $assignee, Notification::getDefaultActions($issue_id, User::getEmail($assignee), 'issue_update'), true);
                 $assignment_notifications[] = $assignee;
                 $assignments_changed = true;
             }
         }
         if (count($assignment_notifications) > 0) {
             Notification::notifyNewAssignment($assignment_notifications, $issue_id);
         }
     }
     if (empty($_POST['estimated_dev_time'])) {
         $_POST['estimated_dev_time'] = 0;
     }
     $params = array('iss_updated_date' => Date_Helper::getCurrentDateGMT(), 'iss_last_public_action_date' => Date_Helper::getCurrentDateGMT(), 'iss_last_public_action_type' => 'updated', 'iss_sta_id' => $_POST['status'], 'iss_summary' => $_POST['summary'], 'iss_description' => $_POST['description']);
     if (isset($_POST['release'])) {
         $params['iss_pre_id'] = $_POST['release'];
     }
     if (isset($_POST['percentage_complete'])) {
         $params['iss_percent_complete'] = $_POST['percentage_complete'];
     }
     if (isset($_POST['group'])) {
         $params['iss_grp_id'] = $_POST['group'];
     }
     if (isset($_POST['estimated_dev_time'])) {
         $params['iss_dev_time'] = $_POST['estimated_dev_time'];
     }
     if (isset($_POST['trigger_reminders'])) {
         $params['iss_trigger_reminders'] = $_POST['trigger_reminders'];
     }
     if (isset($_POST['resolution'])) {
         $params['iss_res_id'] = $_POST['resolution'];
     }
     if (!empty($_POST['category'])) {
         $params['iss_prc_id'] = $_POST['category'];
     }
     if (@$_POST['keep'] == 'no') {
         $params['iss_pre_id'] = $_POST['release'];
     }
     if (!empty($_POST['expected_resolution_date'])) {
         $params['iss_expected_resolution_date'] = $_POST['expected_resolution_date'];
     } else {
         $params['iss_expected_resolution_date'] = null;
     }
     if (isset($_POST['private'])) {
         $params['iss_private'] = $_POST['private'];
     }
     if (isset($_POST['priority'])) {
         $params['iss_pri_id'] = $_POST['priority'];
     }
     if (isset($_POST['severity'])) {
         $params['iss_sev_id'] = $_POST['severity'];
     }
     if (isset($_POST['scheduled_release'])) {
         $params['iss_pre_id'] = $_POST['scheduled_release'];
     }
     $stmt = 'UPDATE {{%issue}} SET ' . DB_Helper::buildSet($params) . ' WHERE iss_id=?';
     $params[] = $issue_id;
     try {
         DB_Helper::getInstance()->query($stmt, $params);
     } catch (DbException $e) {
         return -1;
     }
     // change product
     if (isset($_POST['product'])) {
         $product_changes = Product::updateProductsByIssue($issue_id, $_POST['product'], $_POST['product_version']);
     }
     // add change to the history (only for changes on specific fields?)
     $updated_fields = array();
     if ($current['iss_expected_resolution_date'] != $_POST['expected_resolution_date']) {
         $updated_fields['Expected Resolution Date'] = History::formatChanges($current['iss_expected_resolution_date'], $_POST['expected_resolution_date']);
     }
     if (isset($_POST['category']) && $current['iss_prc_id'] != $_POST['category']) {
         $updated_fields['Category'] = History::formatChanges(Category::getTitle($current['iss_prc_id']), Category::getTitle($_POST['category']));
     }
     if (isset($_POST['release']) && $current['iss_pre_id'] != $_POST['release']) {
         $updated_fields['Release'] = History::formatChanges(Release::getTitle($current['iss_pre_id']), Release::getTitle($_POST['release']));
     }
     if (isset($_POST['priority']) && $current['iss_pri_id'] != $_POST['priority']) {
         $updated_fields['Priority'] = History::formatChanges(Priority::getTitle($current['iss_pri_id']), Priority::getTitle($_POST['priority']));
         Workflow::handlePriorityChange($prj_id, $issue_id, $usr_id, $current, $_POST);
     }
     if (isset($_POST['severity']) && $current['iss_sev_id'] != $_POST['severity']) {
         $updated_fields['Severity'] = History::formatChanges(Severity::getTitle($current['iss_sev_id']), Severity::getTitle($_POST['severity']));
         Workflow::handleSeverityChange($prj_id, $issue_id, $usr_id, $current, $_POST);
     }
     if (isset($_POST['scheduled_release']) && $current['iss_pre_id'] != $_POST['scheduled_release']) {
         $updated_fields['Scheduled Release'] = History::formatChanges(Release::getTitle($current['iss_pre_id']), Release::getTitle($_POST['scheduled_release']));
     }
     if (isset($_POST['status']) && $current['iss_sta_id'] != $_POST['status']) {
         // clear out the last-triggered-reminder flag when changing the status of an issue
         Reminder_Action::clearLastTriggered($issue_id);
         // if old status was closed and new status is not, clear closed data from issue.
         $old_status_details = Status::getDetails($current['iss_sta_id']);
         if ($old_status_details['sta_is_closed'] == 1) {
             $new_status_details = Status::getDetails($_POST['status']);
             if ($new_status_details['sta_is_closed'] != 1) {
                 self::clearClosed($issue_id);
             }
         }
         $updated_fields['Status'] = History::formatChanges(Status::getStatusTitle($current['iss_sta_id']), Status::getStatusTitle($_POST['status']));
     }
     if (isset($_POST['resolution']) && $current['iss_res_id'] != $_POST['resolution']) {
         $updated_fields['Resolution'] = History::formatChanges(Resolution::getTitle($current['iss_res_id']), Resolution::getTitle($_POST['resolution']));
     }
     if (isset($_POST['estimated_dev_time']) && $current['iss_dev_time'] != $_POST['estimated_dev_time']) {
         $updated_fields['Estimated Dev. Time'] = History::formatChanges(Misc::getFormattedTime($current['iss_dev_time'] * 60), Misc::getFormattedTime($_POST['estimated_dev_time'] * 60));
     }
     if ($current['iss_summary'] != $_POST['summary']) {
         $updated_fields['Summary'] = '';
     }
     if (isset($_POST['percentage_complete']) && $current['iss_original_percent_complete'] != $_POST['percentage_complete']) {
         $updated_fields['Percentage complete'] = History::formatChanges($current['iss_original_percent_complete'], $_POST['percentage_complete']);
     }
     if ($current['iss_original_description'] != $_POST['description']) {
         $updated_fields['Description'] = '';
     }
     if (isset($_POST['private']) && $_POST['private'] != $current['iss_private']) {
         $updated_fields['Private'] = History::formatChanges(Misc::getBooleanDisplayValue($current['iss_private']), Misc::getBooleanDisplayValue($_POST['private']));
     }
     if (isset($_POST['product']) && count($product_changes) > 0) {
         $updated_fields['Product'] = implode('; ', $product_changes);
     }
     if (isset($_POST['custom_fields']) && count($_POST['custom_fields']) > 0) {
         $updated_custom_fields = Custom_Field::updateValues($issue_id, $_POST['custom_fields']);
     } else {
         $updated_custom_fields = array();
     }
     if (count($updated_fields) > 0) {
         // log the changes
         $changes = '';
         $i = 0;
         foreach ($updated_fields as $key => $value) {
             if ($i > 0) {
                 $changes .= '; ';
             }
             if ($key != 'Summary' && $key != 'Description') {
                 $changes .= "{$key}: {$value}";
             } else {
                 $changes .= "{$key}";
             }
             $i++;
         }
         History::add($issue_id, $usr_id, 'issue_updated', 'Issue updated ({changes}) by {user}', array('changes' => $changes, 'user' => User::getFullName($usr_id)));
     }
     if (count($updated_fields) > 0 || count($updated_custom_fields) > 0) {
         // send notifications for the issue being updated
         Notification::notifyIssueUpdated($issue_id, $current, $_POST, $updated_custom_fields);
     }
     // record group change as a separate change
     if (isset($_POST['group']) && $current['iss_grp_id'] != (int) $_POST['group']) {
         History::add($issue_id, $usr_id, 'group_changed', 'Group changed ({changes}) by {user}', array('changes' => History::formatChanges(Group::getName($current['iss_grp_id']), Group::getName($_POST['group'])), 'user' => User::getFullName($usr_id)));
     }
     // now update any duplicates, if any
     $update_dupe = array('Category', 'Release', 'Priority', 'Release', 'Resolution');
     $intersect = array_intersect($update_dupe, array_keys($updated_fields));
     if ($current['duplicates'] != '' && count($intersect) > 0) {
         self::updateDuplicates($issue_id);
     }
     // if there is customer integration, mark last customer action
     if (CRM::hasCustomerIntegration($prj_id) && User::getRoleByUser($usr_id, $prj_id) == User::ROLE_CUSTOMER) {
         self::recordLastCustomerAction($issue_id);
     }
     if ($assignments_changed) {
         // XXX: we may want to also send the email notification for those "new" assignees
         Workflow::handleAssignmentChange(self::getProjectID($issue_id), $issue_id, $usr_id, self::getDetails($issue_id), @$_POST['assignments'], false);
     }
     Workflow::handleIssueUpdated($prj_id, $issue_id, $usr_id, $current, $_POST);
     // Move issue to another project
     if (isset($_POST['move_issue']) and User::getRoleByUser($usr_id, $prj_id) >= User::ROLE_DEVELOPER) {
         $new_prj_id = (int) @$_POST['new_prj'];
         if ($prj_id != $new_prj_id && array_key_exists($new_prj_id, Project::getAssocList($usr_id))) {
             if (User::getRoleByUser($usr_id, $new_prj_id) >= User::ROLE_REPORTER) {
                 $res = self::moveIssue($issue_id, $new_prj_id);
                 if ($res == -1) {
                     return $res;
                 }
             } else {
                 return -1;
             }
         }
     }
     return 1;
 }
示例#9
0
include_once APP_INC_PATH . "class.setup.php";
include_once APP_INC_PATH . "class.date.php";
include_once APP_INC_PATH . "db_access.php";
$tpl = new Template_API();
$tpl->setTemplate("preferences.tpl.html");
Auth::checkAuthentication(APP_COOKIE);
$usr_id = Auth::getUserID();
if (@$HTTP_POST_VARS["cat"] == "update_account") {
    $res = Prefs::set($usr_id);
    $tpl->assign('update_account_result', $res);
    User::updateSMS($usr_id, @$HTTP_POST_VARS['sms_email']);
} elseif (@$HTTP_POST_VARS["cat"] == "update_name") {
    $res = User::updateFullName($usr_id);
    $tpl->assign('update_name_result', $res);
} elseif (@$HTTP_POST_VARS["cat"] == "update_email") {
    $res = User::updateEmail($usr_id);
    $tpl->assign('update_email_result', $res);
} elseif (@$HTTP_POST_VARS["cat"] == "update_password") {
    $res = User::updatePassword($usr_id);
    $tpl->assign('update_password_result', $res);
}
$prefs = Prefs::get($usr_id);
$prefs['sms_email'] = User::getSMS($usr_id);
// if the user has no preferences set yet, get it from the system-wide options
if (empty($prefs)) {
    $prefs = Setup::load();
}
$tpl->assign("user_prefs", $prefs);
$tpl->assign("assigned_projects", Project::getAssocList($usr_id, false, true));
$tpl->assign("zones", Date_API::getTimezoneList());
$tpl->displayTemplate();
示例#10
0
$auto_switched_from = false;
if (!empty($iss_prj_id) && $iss_prj_id != $prj_id && in_array($iss_prj_id, $associated_projects)) {
    $cookie = Auth::getCookieInfo(APP_PROJECT_COOKIE);
    Auth::setCurrentProject($iss_prj_id, $cookie["remember"], true);
    $auto_switched_from = $prj_id;
    $prj_id = $iss_prj_id;
}
$details = Issue::getDetails($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 ($role_id == User::getRoleID('customer') && User::getCustomerID($usr_id) != $details['iss_customer_id']) {
    $tpl->assign("auth_customer", 'denied');
} elseif (!Issue::canAccess($issue_id, $usr_id)) {
    $tpl->assign("auth_user", 'denied');
} else {
    $associated_projects = @array_keys(Project::getAssocList($usr_id));
    if (empty($details) || $details['iss_prj_id'] != $prj_id) {
        $tpl->assign('issue', '');
    } else {
        // 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)) {
            $tpl->assign("auth_customer", 'denied');
        } else {
            $options = Issue::saveSearchParams();
            $sides = Issue::getSides($issue_id, $options);
            // check if scheduled release should be displayed
            $releases = Release::getAssocList($prj_id);
            if (count($releases) > 0) {
                $show_releases = 1;
            } else {
示例#11
0
// | Boston, MA 02110-1301, USA.                                          |
// +----------------------------------------------------------------------+
// | Authors: João Prado Maia <*****@*****.**>                             |
// +----------------------------------------------------------------------+
require_once dirname(__FILE__) . '/../init.php';
$usr_id = Auth::getUserID();
$prj_id = Auth::getCurrentProject();
$tpl = new Template_Helper();
$tpl->setTemplate('view_email.tpl.html');
Auth::checkAuthentication(APP_COOKIE, 'index.php?err=5', true);
$issue_id = Support::getIssueFromEmail($_GET['id']);
if ($issue_id != 0 && !Issue::canAccess($issue_id, $usr_id) || $issue_id == 0 && User::getRoleByUser($usr_id, $prj_id) < User::ROLE_USER) {
    $tpl->setTemplate('permission_denied.tpl.html');
    $tpl->displayTemplate();
    exit;
}
$email = Support::getEmailDetails($_GET['ema_id'], $_GET['id']);
$email['seb_body'] = str_replace('&amp;nbsp;', '&nbsp;', $email['seb_body']);
$tpl->assign(array('email' => $email, 'issue_id' => $issue_id, 'extra_title' => ev_gettext('Issue #%1$s Email #%3$s: %2$s', $issue_id, $email['sup_subject'], Support::getSequenceByID($_GET['id'])), 'email_accounts' => Email_Account::getAssocList(array_keys(Project::getAssocList(Auth::getUserID())), true), 'recipients' => Mail_Queue::getMessageRecipients(array('customer_email', 'other_email'), $_GET['id'])));
if (@$_GET['cat'] == 'list_emails') {
    $sides = Support::getListingSides($_GET['id']);
    $tpl->assign(array('previous' => $sides['previous'], 'next' => $sides['next']));
} elseif (@$_GET['cat'] == 'move_email' && Auth::getCurrentRole() >= User::getRoleID('Standard User')) {
    $res = Support::moveEmail(@$_GET['id'], @$_GET['ema_id'], @$_GET['new_ema_id']);
    $tpl->assign('move_email_result', $res);
    $tpl->assign('current_user_prefs', Prefs::get(Auth::getUserID()));
} else {
    $sides = Support::getIssueSides($issue_id, $_GET['id']);
    $tpl->assign(array('previous' => $sides['previous'], 'next' => $sides['next']));
}
$tpl->displayTemplate();
示例#12
0
 /**
  * Method used to send the account details of an user.
  *
  * @param   integer $usr_id The user ID
  * @return  void
  */
 public function notifyAccountDetails($usr_id)
 {
     $info = User::getDetails($usr_id);
     $info['projects'] = Project::getAssocList($usr_id, true, true);
     // open text template
     $tpl = new Template_Helper();
     $tpl->setTemplate('notifications/account_details.tpl.text');
     $tpl->assign(array('app_title' => Misc::getToolCaption(), 'user' => $info));
     Language::set(User::getLang($usr_id));
     $text_message = $tpl->getTemplateContents();
     // send email (use PEAR's classes)
     $mail = new Mail_Helper();
     $mail->setTextBody($text_message);
     $setup = $mail->getSMTPSettings();
     $to = $mail->getFormattedName($info['usr_full_name'], $info['usr_email']);
     // TRANSLATORS: %s = APP_SHORT_NAME
     $subject = ev_gettext('%s: Your User Account Details', APP_SHORT_NAME);
     $mail->send($setup['from'], $to, $subject);
     Language::restore();
 }
示例#13
0
 /**
  * Method used to get the list of users available in the system.
  *
  * @access  public
  * @param   boolean $show_customers Whether to return customers or not
  * @return  array The list of users
  */
 function getList($show_customers)
 {
     $stmt = "SELECT\n                    *\n                 FROM\n                    " . ETEL_USER_TABLE . "\n                 WHERE\n                    usr_id != " . APP_SYSTEM_USER_ID . "\n                 ORDER BY\n                    usr_status ASC,\n                    usr_full_name ASC";
     $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
     if (PEAR::isError($res)) {
         Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
         return "";
     } else {
         $data = array();
         $count = count($res);
         for ($i = 0; $i < $count; $i++) {
             $roles = Project::getAssocList($res[$i]['usr_id'], false, true);
             $role = current($roles);
             $role = $role['pru_role'];
             if ($show_customers == false && (@$roles[Auth::getCurrentProject()]['pru_role'] == User::getRoleID("Customer") || count($roles) == 1 && $role == User::getRoleID("Customer"))) {
                 continue;
             }
             $row = $res[$i];
             $row["roles"] = $roles;
             if (!empty($res[$i]["usr_grp_id"])) {
                 $row["group_name"] = Group::getName($res[$i]["usr_grp_id"]);
             }
             $data[] = $row;
         }
         return $data;
     }
 }
示例#14
0
 /**
  * Method used to get the list of users available in the system.
  *
  * @param   boolean $show_customers Whether to return customers or not
  * @return  array The list of users
  */
 public static function getList($show_customers, $show_inactive)
 {
     // FIXME: what about other statuses like "pending"?
     $stmt = 'SELECT
                 *
              FROM
                 {{%user}}
              WHERE
                 usr_id != ?';
     $params = array(APP_SYSTEM_USER_ID);
     if (!$show_inactive) {
         $stmt .= ' AND usr_status != ?';
         $params[] = 'inactive';
     }
     $stmt .= '
             ORDER BY
                 usr_status ASC,
                 usr_full_name ASC';
     try {
         $res = DB_Helper::getInstance()->getAll($stmt, $params);
     } catch (DbException $e) {
         return '';
     }
     $data = array();
     foreach ($res as &$row) {
         $roles = Project::getAssocList($row['usr_id'], false, true);
         $role = current($roles);
         $role = $role['pru_role'];
         if ($show_customers == false && (@$roles[Auth::getCurrentProject()]['pru_role'] == self::getRoleID('Customer') || count($roles) == 1 && $role == self::getRoleID('Customer'))) {
             continue;
         }
         $row['roles'] = $roles;
         if (!empty($row['usr_grp_id'])) {
             $row['group_name'] = Group::getName($row['usr_grp_id']);
         }
         if (!empty($row['usr_par_code'])) {
             $row['partner_name'] = Partner::getName($row['usr_par_code']);
         }
         // add email aliases
         $row['aliases'] = User::getAliases($row['usr_id']);
         $data[] = $row;
     }
     return $data;
 }
示例#15
0
 /**
  * Processes the template and assign common variables automatically.
  * @return $this
  */
 private function processTemplate()
 {
     $core = array('rel_url' => APP_RELATIVE_URL, 'base_url' => APP_BASE_URL, 'app_title' => APP_NAME, 'app_version' => APP_VERSION, 'app_setup' => Setup::load(), 'messages' => Misc::getMessages(), 'roles' => User::getAssocRoleIDs(), 'auth_backend' => APP_AUTH_BACKEND, 'current_url' => $_SERVER['PHP_SELF']);
     // If VCS version is present "Eventum 2.3.3-148-g78b3368", link ref to github
     $vcsVersion = self::getVcsVersion();
     if ($vcsVersion) {
         $link = "https://github.com/eventum/eventum/commit/{$vcsVersion}";
         $core['application_version_link'] = $link;
         // append VCS version if not yet there
         if (!preg_match('/-g[0-9a-f]+$/', APP_VERSION)) {
             $core['app_version'] = "v{$core['app_version']}-g{$vcsVersion}";
         }
     }
     $usr_id = Auth::getUserID();
     if ($usr_id) {
         $core['user'] = User::getDetails($usr_id);
         $prj_id = Auth::getCurrentProject();
         $setup = Setup::load();
         if (!empty($prj_id)) {
             $role_id = User::getRoleByUser($usr_id, $prj_id);
             $has_crm = CRM::hasCustomerIntegration($prj_id);
             $core = $core + array('project_id' => $prj_id, 'project_name' => Auth::getCurrentProjectName(), 'has_crm' => $has_crm, 'current_role' => $role_id, 'current_role_name' => User::getRole($role_id), 'feature_access' => Access::getFeatureAccessArray($usr_id));
             if ($has_crm) {
                 $crm = CRM::getInstance($prj_id);
                 $core['crm_template_path'] = $crm->getTemplatePath();
                 if ($role_id == User::getRoleID('Customer')) {
                     try {
                         $contact = $crm->getContact($core['user']['usr_customer_contact_id']);
                         $core['allowed_customers'] = $contact->getCustomers();
                         $core['current_customer'] = $crm->getCustomer(Auth::getCurrentCustomerID(false));
                     } catch (CRMException $e) {
                     }
                 }
             }
         }
         $info = User::getDetails($usr_id);
         $raw_projects = Project::getAssocList(Auth::getUserID(), false, true);
         $active_projects = array();
         foreach ($raw_projects as $prj_id => $prj_info) {
             if ($prj_info['status'] == 'archived') {
                 $prj_info['prj_title'] .= ' ' . ev_gettext('(archived)');
             }
             $active_projects[$prj_id] = $prj_info['prj_title'];
         }
         $core = $core + array('active_projects' => $active_projects, 'current_full_name' => $info['usr_full_name'], 'current_email' => $info['usr_email'], 'current_user_id' => $usr_id, 'current_user_datetime' => Date_Helper::getISO8601date('now', '', true), 'is_current_user_clocked_in' => User::isCLockedIn($usr_id), 'is_anon_user' => Auth::isAnonUser(), 'is_current_user_partner' => !empty($info['usr_par_code']), 'roles' => User::getAssocRoleIDs(), 'current_user_prefs' => Prefs::get(Auth::getUserID()));
         $this->assign('current_full_name', $core['user']['usr_full_name']);
         $this->assign('current_email', $core['user']['usr_email']);
         $this->assign('current_user_id', $usr_id);
         $this->assign('handle_clock_in', $setup['handle_clock_in'] == 'enabled');
         $this->assign('is_current_user_clocked_in', User::isClockedIn($usr_id));
         $this->assign('roles', User::getAssocRoleIDs());
     }
     $this->assign('core', $core);
     return $this;
 }
示例#16
0
 /**
  * Method used to set the preferences for a specific user.
  *
  * @param   integer $usr_id The user ID
  * @param   array   $preferences An array of preferences
  * @return  integer 1 if the update worked, -1 otherwise
  */
 public static function set($usr_id, $preferences)
 {
     // set global preferences
     $sql = 'REPLACE INTO
                 {{%user_preference}}
             SET
                 upr_usr_id = ?,
                 upr_timezone = ?,
                 upr_week_firstday = ?,
                 upr_list_refresh_rate = ?,
                 upr_email_refresh_rate = ?,
                 upr_email_signature = ?,
                 upr_auto_append_email_sig = ?,
                 upr_auto_append_note_sig = ?,
                 upr_auto_close_popup_window = ?';
     try {
         DB_Helper::getInstance()->query($sql, array($usr_id, @$preferences['timezone'], @$preferences['week_firstday'], @$preferences['list_refresh_rate'], @$preferences['email_refresh_rate'], @$preferences['email_signature'], @$preferences['auto_append_email_sig'], @$preferences['auto_append_note_sig'], @$preferences['close_popup_windows']));
     } catch (DbException $e) {
         return -1;
     }
     // set per project preferences
     $projects = Project::getAssocList($usr_id);
     foreach ($projects as $prj_id => $project_name) {
         $sql = 'REPLACE INTO
                     {{%user_project_preference}}
                 SET
                     upp_usr_id = ?,
                     upp_prj_id = ?,
                     upp_receive_assigned_email = ?,
                     upp_receive_new_issue_email = ?,
                     upp_receive_copy_of_own_action = ?';
         try {
             DB_Helper::getInstance()->query($sql, array($usr_id, $prj_id, $preferences['receive_assigned_email'][$prj_id], $preferences['receive_new_issue_email'][$prj_id], $preferences['receive_copy_of_own_action'][$prj_id]));
         } catch (DbException $e) {
             return -1;
         }
     }
     return 1;
 }
示例#17
0
 /**
  * Processes the template and assigns common variables automatically.
  * 
  * @access	private
  */
 function processTemplate()
 {
     global $HTTP_SERVER_VARS;
     // determine the correct CSS file to use
     if (ereg('MSIE ([0-9].[0-9]{1,2})', @$HTTP_SERVER_VARS["HTTP_USER_AGENT"], $log_version)) {
         $user_agent = 'ie';
     } else {
         $user_agent = 'other';
     }
     $this->assign("user_agent", $user_agent);
     // create the list of projects
     $usr_id = Auth::getUserID();
     if ($usr_id != '') {
         $prj_id = Auth::getCurrentProject();
         if (!empty($prj_id)) {
             $role_id = User::getRoleByUser($usr_id, $prj_id);
             $this->assign("current_project", $prj_id);
             $this->assign("current_project_name", Auth::getCurrentProjectName());
             $has_customer_integration = Customer::hasCustomerIntegration($prj_id);
             $this->assign("has_customer_integration", $has_customer_integration);
             if ($has_customer_integration) {
                 $this->assign("customer_backend_name", Customer::getBackendImplementationName($prj_id));
             }
             if ($role_id == User::getRoleID('administrator') || $role_id == User::getRoleID('manager')) {
                 $this->assign("show_admin_link", true);
             }
             if ($role_id > 0) {
                 $this->assign("current_role", (int) $role_id);
                 $this->assign("current_role_name", User::getRole($role_id));
             }
         }
         $info = User::getNameEmail($usr_id);
         $this->assign("active_projects", Project::getAssocList($usr_id));
         $this->assign("current_full_name", $info["usr_full_name"]);
         $this->assign("current_email", $info["usr_email"]);
         $this->assign("current_user_id", $usr_id);
         $this->assign("is_current_user_clocked_in", User::isClockedIn($usr_id));
         $this->assign("roles", User::getAssocRoleIDs());
     }
     $this->assign("app_setup", Setup::load());
     $this->assign("app_setup_path", APP_SETUP_PATH);
     $this->assign("app_setup_file", APP_SETUP_FILE);
     $this->assign("application_version", APP_VERSION);
     $this->assign("application_title", APP_NAME);
     $this->assign("app_base_url", APP_BASE_URL);
     $this->assign("rel_url", APP_RELATIVE_URL);
     $this->assign("lang", APP_CURRENT_LANG);
     $this->assign("SID", SID);
     // now for the browser detection stuff
     Net_UserAgent_Detect::detect();
     $this->assign("browser", Net_UserAgent_Detect::_getStaticProperty('browser'));
     $this->assign("os", Net_UserAgent_Detect::_getStaticProperty('os'));
     // this is only used by the textarea resize script
     $js_script_name = str_replace('/', '_', str_replace('.php', '', $HTTP_SERVER_VARS['PHP_SELF']));
     $this->assign("js_script_name", $js_script_name);
     $this->assign("total_queries", $GLOBALS['TOTAL_QUERIES']);
     $this->assign(array("cell_color" => APP_CELL_COLOR, "light_color" => APP_LIGHT_COLOR, "middle_color" => APP_MIDDLE_COLOR, "dark_color" => APP_DARK_COLOR, "cycle" => APP_CYCLE_COLORS, "internal_color" => APP_INTERNAL_COLOR));
 }
示例#18
0
文件: new.php 项目: korusdipl/eventum
// +----------------------------------------------------------------------+
require_once dirname(__FILE__) . '/../init.php';
Auth::checkAuthentication(APP_COOKIE);
$usr_id = Auth::getUserID();
$prj_id = Auth::getCurrentProject();
if (!Access::canCreateIssue($usr_id)) {
    Auth::redirect('main.php');
}
$tpl = new Template_Helper();
$tpl->setTemplate('new.tpl.html');
$tpl->assign('new_issue_id', '');
// If the project has changed since the new issue form was requested, then change it back
$issue_prj_id = !empty($_REQUEST['prj_id']) ? (int) $_REQUEST['prj_id'] : 0;
if ($issue_prj_id > 0 && $issue_prj_id != $prj_id) {
    // Switch the project back
    $assigned_projects = Project::getAssocList($usr_id);
    if (isset($assigned_projects[$issue_prj_id])) {
        $cookie = Auth::getCookieInfo(APP_PROJECT_COOKIE);
        Auth::setCurrentProject($issue_prj_id, $cookie['remember']);
        $prj_id = $issue_prj_id;
    } else {
        Misc::setMessage(ev_gettext('There was an error creating your issue.'), Misc::MSG_ERROR);
        $tpl->assign('error_msg', '1');
    }
}
if (CRM::hasCustomerIntegration($prj_id)) {
    if (Auth::getCurrentRole() == User::getRoleID('Customer')) {
        $crm = CRM::getInstance($prj_id);
        $customer_id = Auth::getCurrentCustomerID();
        $customer = $crm->getCustomer($customer_id);
        $new_issue_message = $customer->getNewIssueMessage();
示例#19
0
include_once APP_INC_PATH . "class.issue.php";
include_once APP_INC_PATH . "class.misc.php";
include_once APP_INC_PATH . "class.support.php";
include_once APP_INC_PATH . "db_access.php";
$tpl = new Template_API();
$tpl->setTemplate("view_email.tpl.html");
Auth::checkAuthentication(APP_COOKIE, 'index.php?err=5', true);
$email = Support::getEmailDetails($HTTP_GET_VARS["ema_id"], $HTTP_GET_VARS["id"]);
$email["message"] = str_replace("&amp;nbsp;", "&nbsp;", $email["message"]);
$issue_id = Support::getIssueFromEmail($HTTP_GET_VARS["id"]);
if (!Issue::canAccess($issue_id, Auth::getUserID())) {
    $tpl->setTemplate("permission_denied.tpl.html");
    $tpl->displayTemplate();
    exit;
}
$tpl->bulkAssign(array("email" => $email, "issue_id" => $issue_id, 'extra_title' => "Email #" . $HTTP_GET_VARS['id'] . ": " . $email['sup_subject'], 'email_accounts' => Email_Account::getAssocList(array_keys(Project::getAssocList(Auth::getUserID())), true)));
if (@$HTTP_GET_VARS['cat'] == 'list_emails') {
    $sides = Support::getListingSides($HTTP_GET_VARS["id"]);
    $tpl->assign(array('previous' => $sides['previous'], 'next' => $sides['next']));
} elseif (@$HTTP_GET_VARS['cat'] == 'move_email' && Auth::getCurrentRole() >= User::getRoleID("Standard User")) {
    $res = Support::moveEmail(@$HTTP_GET_VARS['id'], @$HTTP_GET_VARS['ema_id'], @$HTTP_GET_VARS['new_ema_id']);
    $tpl->assign("move_email_result", $res);
    $tpl->assign("current_user_prefs", Prefs::get(Auth::getUserID()));
} else {
    $sides = Support::getIssueSides($issue_id, $HTTP_GET_VARS["id"]);
    $tpl->assign(array('previous' => $sides['previous'], 'next' => $sides['next']));
}
// set the page charset to whatever is set on this email
$charset = Mime_Helper::getCharacterSet($email['seb_full_email']);
if (!empty($charset)) {
    header("Content-Type: text/html; charset=" . $charset);