} $tpl->assign("info", $info); } if (!empty($HTTP_GET_VARS['field'])) { $field_title = Reminder_Condition::getFieldTitle($HTTP_GET_VARS['field']); if (Reminder_Condition::canFieldBeCompared($HTTP_GET_VARS['field'])) { $tpl->assign(array('show_field_options' => 'yes', 'comparable_fields' => Reminder_Condition::getFieldAdminList(true))); } elseif (strtolower($field_title) == 'status') { $prj_id = Reminder::getProjectID($rem_id); $tpl->assign(array('show_status_options' => 'yes', 'statuses' => Status::getAssocStatusList($prj_id))); } elseif (strtolower($field_title) == 'category') { $prj_id = Reminder::getProjectID($rem_id); $tpl->assign(array('show_category_options' => 'yes', 'categories' => Category::getAssocList($prj_id))); } else { $tpl->assign('show_status_options', 'no'); } if (@$HTTP_GET_VARS["cat"] != "edit") { $tpl->assign('info', array('rlc_rmf_id' => $HTTP_GET_VARS['field'], 'rlc_rmo_id' => '', 'rlc_value' => '')); } } $tpl->assign("rem_id", $rem_id); $tpl->assign("rma_id", $rma_id); $tpl->assign("rem_title", Reminder::getTitle($rem_id)); $tpl->assign("rma_title", Reminder_Action::getTitle($rma_id)); $tpl->assign("fields", Reminder_Condition::getFieldAdminList()); $tpl->assign("operators", Reminder_Condition::getOperatorAdminList()); $tpl->assign("list", Reminder_Condition::getAdminList($rma_id)); } else { $tpl->assign("show_not_allowed_msg", true); } $tpl->displayTemplate();
/** * 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; }
} $triggered_issues[] = $repeat_issues[$w]; } } if (count($issues) > 0) { for ($z = 0; $z < count($issues); $z++) { if (Reminder::isDebug()) { echo " - Processing issue '" . $issues[$z] . "'\n"; } // only perform one action per issue id if (in_array($issues[$z], $triggered_issues)) { if (Reminder::isDebug()) { echo " - Ignoring issue '" . $issues[$z] . "' because it was found in the list of already triggered issues\n"; } continue; } $triggered_issues[] = $issues[$z]; if (Reminder::isDebug()) { echo " - Triggered Action '" . $reminders[$i]['actions'][$y]['rma_title'] . "' for issue #" . $issues[$z] . "\n"; } Reminder_Action::perform($issues[$z], $reminders[$i], $reminders[$i]['actions'][$y]); } } else { if (Reminder::isDebug()) { echo " - No triggered issues for action '" . $reminders[$i]['actions'][$y]['rma_title'] . "'\n"; } } } } // release the lock Lock::release('check_reminders');
} $triggered_issues[] = $issue; } } if (count($issues) > 0) { foreach ($issues as $issue) { if (Reminder::isDebug()) { echo " - Processing issue '" . $issue . "'\n"; } // only perform one action per issue id if (in_array($issue, $triggered_issues)) { if (Reminder::isDebug()) { echo " - Ignoring issue '" . $issue . "' because it was found in the list of already triggered issues\n"; } continue; } $triggered_issues[] = $issue; if (Reminder::isDebug()) { echo " - Triggered Action '" . $action['rma_title'] . "' for issue #" . $issue . "\n"; } Reminder_Action::perform($issue, $reminder, $action); } } else { if (Reminder::isDebug()) { echo " - No triggered issues for action '" . $action['rma_title'] . "'\n"; } } } } // release the lock Lock::release('check_reminders');
/** * Method used to perform a specific action to an issue. * * @access public * @param integer $issue_id The issue ID * @param array $reminder The reminder details * @param array $action The action details * @return boolean */ function perform($issue_id, $reminder, $action) { $type = ''; // - see which action type we're talking about here... $action_type = Reminder_Action::getActionType($action['rma_rmt_id']); // - do we also need to alert the group leader about this? $group_leader_usr_id = 0; if ($action['rma_alert_group_leader']) { if (Reminder::isDebug()) { echo " - Processing Group Leader notification\n"; } $group_id = Issue::getGroupID($issue_id); // check if there's even a group associated with this issue if (empty($group_id)) { if (Reminder::isDebug()) { echo " - No group associated with issue {$issue_id}\n"; } } else { $group_details = Group::getDetails($group_id); if (!empty($group_details['grp_manager_usr_id'])) { $group_leader_usr_id = $group_details['grp_manager_usr_id']; } } } if (Reminder::isDebug()) { echo " - Performing action '{$action_type}' for issue #{$issue_id}\n"; } switch ($action_type) { case 'email_assignee': $type = 'email'; $assignees = Issue::getAssignedUserIDs($issue_id); $to = array(); foreach ($assignees as $assignee) { $to[] = User::getFromHeader($assignee); } // add the group leader to the recipient list, if needed if (!empty($group_leader_usr_id)) { $leader_email = User::getFromHeader($group_leader_usr_id); if (!empty($leader_email) && !in_array($leader_email, $to)) { $to[] = $leader_email; } } break; case 'email_list': $type = 'email'; $list = Reminder_Action::getUserList($action['rma_id']); $to = array(); foreach ($list as $key => $value) { // add the recipient to the list if it's a simple email address if (Validation::isEmail($key)) { $to[] = $key; } else { $to[] = User::getFromHeader($key); } } // add the group leader to the recipient list, if needed if (!empty($group_leader_usr_id)) { $leader_email = User::getFromHeader($group_leader_usr_id); if (!empty($leader_email) && !in_array($leader_email, $to)) { $to[] = $leader_email; } } break; case 'sms_assignee': $type = 'sms'; $assignees = Issue::getAssignedUserIDs($issue_id); $to = array(); foreach ($assignees as $assignee) { if (User::isClockedIn($assignee)) { $sms_email = User::getSMS($assignee); if (!empty($sms_email)) { $to[] = $sms_email; } } } // add the group leader to the recipient list, if needed if (!empty($group_leader_usr_id) && User::isClockedIn($group_leader_usr_id)) { $leader_sms_email = User::getSMS($group_leader_usr_id); if (!empty($leader_sms_email) && !in_array($leader_sms_email, $to)) { $to[] = $leader_sms_email; } } break; case 'sms_list': $type = 'sms'; $list = Reminder_Action::getUserList($action['rma_id']); $to = array(); foreach ($list as $key => $value) { // add the recipient to the list if it's a simple email address if (Validation::isEmail($key)) { $to[] = $key; } else { // otherwise, check for the clocked-in status if (User::isClockedIn($key)) { $sms_email = User::getSMS($key); if (!empty($sms_email)) { $to[] = $sms_email; } } } } // add the group leader to the recipient list, if needed if (!empty($group_leader_usr_id) && User::isClockedIn($group_leader_usr_id)) { $leader_sms_email = User::getSMS($group_leader_usr_id); if (!empty($leader_sms_email) && !in_array($leader_sms_email, $to)) { $to[] = $leader_sms_email; } } break; } $data = Notification::getIssueDetails($issue_id); $conditions = Reminder_Condition::getAdminList($action['rma_id']); // alert IRC if needed if ($action['rma_alert_irc']) { if (Reminder::isDebug()) { echo " - Processing IRC notification\n"; } $irc_notice = "Issue #{$issue_id} (Priority: " . $data['pri_title']; // also add information about the assignee, if any $assignment = Issue::getAssignedUsers($issue_id); if (count($assignment) > 0) { $irc_notice .= "; Assignment: " . implode(', ', $assignment); } if (!empty($data['iss_grp_id'])) { $irc_notice .= "; Group: " . Group::getName($data['iss_grp_id']); } $irc_notice .= "), Reminder action '" . $action['rma_title'] . "' was just triggered"; Notification::notifyIRC(Issue::getProjectID($issue_id), $irc_notice, $issue_id); } $setup = Setup::load(); // if there are no recipients, then just skip to the next action if (count($to) == 0) { if (Reminder::isDebug()) { echo " - No recipients could be found\n"; } // if not even an irc alert was sent, then save // a notice about this on reminder_sent@, if needed if (!$action['rma_alert_irc']) { if (@$setup['email_reminder']['status'] == 'enabled') { Reminder_Action::_recordNoRecipientError($issue_id, $type, $reminder, $action); } return false; } } // - save a history entry about this action Reminder_Action::saveHistory($issue_id, $action['rma_id']); // - save this action as the latest triggered one for the given issue ID Reminder_Action::recordLastTriggered($issue_id, $action['rma_id']); // - perform the action if (count($to) > 0) { // send a copy of this reminder to reminder_sent@, if needed if (@$setup['email_reminder']['status'] == 'enabled' && !empty($setup['email_reminder']['addresses'])) { $addresses = Reminder::_getReminderAlertAddresses(); if (count($addresses) > 0) { $to = array_merge($to, $addresses); } } $tpl = new Template_API(); $tpl->setTemplate('reminders/' . $type . '_alert.tpl.text'); $tpl->bulkAssign(array("data" => $data, "reminder" => $reminder, "action" => $action, "conditions" => $conditions, "has_customer_integration" => Customer::hasCustomerIntegration(Issue::getProjectID($issue_id)))); $text_message = $tpl->getTemplateContents(); foreach ($to as $address) { // send email (use PEAR's classes) $mail = new Mail_API(); $mail->setTextBody($text_message); $setup = $mail->getSMTPSettings(); $mail->send($setup["from"], $address, "[#{$issue_id}] Reminder: " . $action['rma_title'], 0, $issue_id, 'reminder'); } } // - eventum saves the day once again return true; }
/** * Method used to get the full list of reminders. * * @access public * @return array The list of reminders */ function getList() { $stmt = "SELECT\n *\n FROM\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_level\n ORDER BY\n rem_rank 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 array(); } else { if (empty($res)) { return array(); } else { $t = array(); for ($i = 0; $i < count($res); $i++) { // ignore reminders that have no actions set yet... $actions = Reminder_Action::getList($res[$i]['rem_id']); if (count($actions) == 0) { continue; } $res[$i]['actions'] = $actions; $t[] = $res[$i]; } return $t; } } }
/** * Method used to get the full list of reminders. * * @return array The list of reminders */ public static function getList() { $stmt = 'SELECT * FROM {{%reminder_level}} ORDER BY rem_rank ASC'; try { $res = DB_Helper::getInstance()->getAll($stmt); } catch (DbException $e) { return array(); } if (empty($res)) { return array(); } $t = array(); foreach ($res as &$row) { // ignore reminders that have no actions set yet... $actions = Reminder_Action::getList($row['rem_id']); if (count($actions) == 0) { continue; } $row['actions'] = $actions; $t[] = $row; unset($row); } return $t; }
/** * Method used to update the details of a specific issue. * * @access public * @param integer $issue_id The issue ID * @return integer 1 if the update worked, -1 or -2 otherwise */ function update($issue_id) { global $HTTP_POST_VARS; $issue_id = Misc::escapeInteger($issue_id); $usr_id = Auth::getUserID(); $prj_id = Issue::getProjectID($issue_id); // get all of the 'current' information of this issue $current = Issue::getDetails($issue_id); // update the issue associations $association_diff = Misc::arrayDiff($current['associated_issues'], @$HTTP_POST_VARS['associated_issues']); if (count($association_diff) > 0) { // go through the new assocations, if association already exists, skip it $associations_to_remove = $current['associated_issues']; if (count(@$HTTP_POST_VARS['associated_issues']) > 0) { foreach ($HTTP_POST_VARS['associated_issues'] as $index => $associated_id) { if (!in_array($associated_id, $current['associated_issues'])) { Issue::addAssociation($issue_id, $associated_id, $usr_id); } else { // already assigned, remove this user from list of users to remove unset($associations_to_remove[array_search($associated_id, $associations_to_remove)]); } } } if (count($associations_to_remove) > 0) { foreach ($associations_to_remove as $associated_id) { Issue::deleteAssociation($issue_id, $associated_id); } } } if (!empty($HTTP_POST_VARS['expected_resolution_date']['Year']) && !empty($HTTP_POST_VARS['expected_resolution_date']['Month']) && !empty($HTTP_POST_VARS['expected_resolution_date']['Day'])) { $HTTP_POST_VARS['expected_resolution_date'] = sprintf('%s-%s-%s', $HTTP_POST_VARS['expected_resolution_date']['Year'], $HTTP_POST_VARS['expected_resolution_date']['Month'], $HTTP_POST_VARS['expected_resolution_date']['Day']); } else { $HTTP_POST_VARS['expected_resolution_date'] = ''; } $assignments_changed = false; if (@$HTTP_POST_VARS["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($HTTP_POST_VARS['assignments'])) { $new_assignees = @$HTTP_POST_VARS['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)) { Issue::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)) { Issue::addUserAssociation($usr_id, $issue_id, $assignee); Notification::subscribeUser($usr_id, $issue_id, $assignee, Notification::getDefaultActions(), TRUE); $assignment_notifications[] = $assignee; $assignments_changed = true; } } if (count($assignment_notifications) > 0) { Notification::notifyNewAssignment($assignment_notifications, $issue_id); } } if (empty($HTTP_POST_VARS["estimated_dev_time"])) { $HTTP_POST_VARS["estimated_dev_time"] = 0; } $stmt = "UPDATE\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue\n SET\n iss_updated_date='" . Date_API::getCurrentDateGMT() . "',\n iss_last_public_action_date='" . Date_API::getCurrentDateGMT() . "',\n iss_last_public_action_type='updated',"; if (!empty($HTTP_POST_VARS["category"])) { $stmt .= "iss_prc_id=" . Misc::escapeInteger($HTTP_POST_VARS["category"]) . ","; } if (@$HTTP_POST_VARS["keep"] == "no") { $stmt .= "iss_pre_id=" . Misc::escapeInteger($HTTP_POST_VARS["release"]) . ","; } if (!empty($HTTP_POST_VARS['expected_resolution_date'])) { $stmt .= "iss_expected_resolution_date='" . Misc::escapeString($HTTP_POST_VARS['expected_resolution_date']) . "',"; } else { $stmt .= "iss_expected_resolution_date=null,"; } $stmt .= "\n iss_pre_id=" . Misc::escapeInteger($HTTP_POST_VARS["release"]) . ",\n iss_pri_id=" . Misc::escapeInteger($HTTP_POST_VARS["priority"]) . ",\n iss_sta_id=" . Misc::escapeInteger($HTTP_POST_VARS["status"]) . ",\n iss_res_id=" . Misc::escapeInteger($HTTP_POST_VARS["resolution"]) . ",\n iss_summary='" . Misc::escapeString($HTTP_POST_VARS["summary"]) . "',\n iss_description='" . Misc::escapeString($HTTP_POST_VARS["description"]) . "',\n iss_dev_time='" . Misc::escapeString($HTTP_POST_VARS["estimated_dev_time"]) . "',\n iss_percent_complete= '" . Misc::escapeString($HTTP_POST_VARS["percent_complete"]) . "',\n iss_trigger_reminders=" . Misc::escapeInteger($HTTP_POST_VARS["trigger_reminders"]) . ",\n iss_grp_id ='" . Misc::escapeInteger($HTTP_POST_VARS["group"]) . "'"; if (isset($HTTP_POST_VARS['private'])) { $stmt .= ",\n iss_private = " . Misc::escapeInteger($HTTP_POST_VARS['private']); } $stmt .= "\n WHERE\n iss_id={$issue_id}"; $res = $GLOBALS["db_api"]->dbh->query($stmt); if (PEAR::isError($res)) { Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); return -1; } else { // add change to the history (only for changes on specific fields?) $updated_fields = array(); if ($current["iss_expected_resolution_date"] != $HTTP_POST_VARS['expected_resolution_date']) { $updated_fields["Expected Resolution Date"] = History::formatChanges($current["iss_expected_resolution_date"], $HTTP_POST_VARS['expected_resolution_date']); } if ($current["iss_prc_id"] != $HTTP_POST_VARS["category"]) { $updated_fields["Category"] = History::formatChanges(Category::getTitle($current["iss_prc_id"]), Category::getTitle($HTTP_POST_VARS["category"])); } if ($current["iss_pre_id"] != $HTTP_POST_VARS["release"]) { $updated_fields["Release"] = History::formatChanges(Release::getTitle($current["iss_pre_id"]), Release::getTitle($HTTP_POST_VARS["release"])); } if ($current["iss_pri_id"] != $HTTP_POST_VARS["priority"]) { $updated_fields["Priority"] = History::formatChanges(Priority::getTitle($current["iss_pri_id"]), Priority::getTitle($HTTP_POST_VARS["priority"])); Workflow::handlePriorityChange($prj_id, $issue_id, $usr_id, $current, $HTTP_POST_VARS); } if ($current["iss_sta_id"] != $HTTP_POST_VARS["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($HTTP_POST_VARS["status"]); if ($new_status_details['sta_is_closed'] != 1) { Issue::clearClosed($issue_id); } } $updated_fields["Status"] = History::formatChanges(Status::getStatusTitle($current["iss_sta_id"]), Status::getStatusTitle($HTTP_POST_VARS["status"])); } if ($current["iss_res_id"] != $HTTP_POST_VARS["resolution"]) { $updated_fields["Resolution"] = History::formatChanges(Resolution::getTitle($current["iss_res_id"]), Resolution::getTitle($HTTP_POST_VARS["resolution"])); } if ($current["iss_dev_time"] != $HTTP_POST_VARS["estimated_dev_time"]) { $updated_fields["Estimated Dev. Time"] = History::formatChanges(Misc::getFormattedTime($current["iss_dev_time"] * 60), Misc::getFormattedTime($HTTP_POST_VARS["estimated_dev_time"] * 60)); } if ($current["iss_summary"] != $HTTP_POST_VARS["summary"]) { $updated_fields["Summary"] = ''; } if ($current["iss_description"] != $HTTP_POST_VARS["description"]) { $updated_fields["Description"] = ''; } 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, History::getTypeID('issue_updated'), "Issue updated ({$changes}) by " . User::getFullName($usr_id)); // send notifications for the issue being updated Notification::notifyIssueUpdated($issue_id, $current, $HTTP_POST_VARS); } // record group change as a seperate change if ($current["iss_grp_id"] != $HTTP_POST_VARS["group"]) { History::add($issue_id, $usr_id, History::getTypeID('group_changed'), "Group changed (" . History::formatChanges(Group::getName($current["iss_grp_id"]), Group::getName($HTTP_POST_VARS["group"])) . ") by " . User::getFullName($usr_id)); } // now update any duplicates, if any $update_dupe = array('Category', 'Release', 'Priority', 'Release', 'Resolution'); // COMPAT: the following line requires PHP > 4.0.4 $intersect = array_intersect($update_dupe, array_keys($updated_fields)); if ($current["duplicates"] != '' && count($intersect) > 0) { Issue::updateDuplicates($issue_id); } // if there is customer integration, mark last customer action if (Customer::hasCustomerIntegration($prj_id) && User::getRoleByUser($usr_id, $prj_id) == User::getRoleID('Customer')) { Issue::recordLastCustomerAction($issue_id); } if ($assignments_changed) { // XXX: we may want to also send the email notification for those "new" assignees Workflow::handleAssignmentChange(Issue::getProjectID($issue_id), $issue_id, $usr_id, Issue::getDetails($issue_id), @$HTTP_POST_VARS['assignments'], false); } Workflow::handleIssueUpdated($prj_id, $issue_id, $usr_id, $current, $HTTP_POST_VARS); return 1; } }
require_once dirname(__FILE__) . '/../../init.php'; $tpl = new Template_Helper(); $tpl->setTemplate('manage/reminder_actions.tpl.html'); Auth::checkAuthentication(APP_COOKIE); $rem_id = @$_POST['rem_id'] ? $_POST['rem_id'] : $_GET['rem_id']; $role_id = Auth::getCurrentRole(); if ($role_id < User::getRoleID('manager')) { Misc::setMessage(ev_gettext('Sorry, you are not allowed to access this page.'), Misc::MSG_ERROR); $tpl->displayTemplate(); exit; } if (@$_POST['cat'] == 'new') { $res = Reminder_Action::insert(); Misc::mapMessages($res, array(1 => array(ev_gettext('Thank you, the action was added successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to add the new action.'), Misc::MSG_ERROR), -2 => array(ev_gettext('Please enter the title for this new action.'), Misc::MSG_ERROR))); } elseif (@$_POST['cat'] == 'update') { $res = Reminder_Action::update(); Misc::mapMessages($res, array(1 => array(ev_gettext('Thank you, the action was updated successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to update the action.'), Misc::MSG_ERROR), -2 => array(ev_gettext('Please enter the title for this action.'), Misc::MSG_ERROR))); } elseif (@$_POST['cat'] == 'delete') { @Reminder_Action::remove($_POST['items']); } if (@$_GET['cat'] == 'edit') { $tpl->assign('info', Reminder_Action::getDetails($_GET['id'])); } elseif (@$_GET['cat'] == 'change_rank') { Reminder_Action::changeRank($_GET['rem_id'], $_GET['id'], $_GET['rank']); } $tpl->assign('rem_id', $rem_id); $tpl->assign('rem_title', Reminder::getTitle($rem_id)); $tpl->assign('action_types', Reminder_Action::getActionTypeList()); $tpl->assign('list', Reminder_Action::getAdminList($rem_id)); $tpl->assign('user_options', User::getActiveAssocList(Reminder::getProjectID($rem_id), User::getRoleID('Customer'))); $tpl->displayTemplate();