/** * Modifies a current reservation, setting new start and end times or deleting it * @param array $all_invited_users array of all invited users to be used for DB insertion * @param array $users_to_invite array of newly invited users to be used for invitation emails * @param array $users_to_remove array of users that will be removed from invitation/participating in this reservation * @param array $unchanged_users array of users who have no status change at all * @param array $resources_to_add array of additional resources to add to this reservation * @param array $resources_to_remove array of additional resources to remove from this reservation * @param bool $del whether to delete it or not * @param boolean $mod_recur whether to modify all recurring reservations in this group */ function mod_res($users_to_invite, $users_to_remove, $unchanged_users, $resources_to_add, $resources_to_remove, $del, $mod_recur) { $recurs = array(); $valid_resids = array(); $this->type = RES_TYPE_MODIFY; $orig_start_date = $this->start_date; // Store the original dates because they will be changed if we repeat $orig_end_date = $this->end_date; $accept_code = $this->db->get_new_id(); if ($del) { // First, check if this should be deleted $this->del_res($mod_recur, mktime(0, 0, 0)); return; } if (!$this->is_blackout) { $this->check_perms(); // Check permissions $this->check_min_max(); // Check min/max reservation times } if ($this->check_startdate()) { $this->check_times(); // Check valid times } $this->is_repeat = $mod_recur; // If the mod_recur flag is set, it must be a recurring reservation $dates = array(); // First, modify the current reservation if ($this->has_errors()) { // Print any errors generated above and kill app $this->print_all_errors(true); } $reminder = new Reminder(); $reminder->setDB(new ReminderDB()); $tmp_valid = false; $this->is_pending = $this->resource->get_property('approval'); if ($this->is_repeat) { // Check and place all recurring reservations $recurs = $this->db->get_recur_ids($this->parentid, mktime(0, 0, 0)); for ($i = 0; $i < count($recurs); $i++) { $this->id = $recurs[$i]['resid']; // Load reservation data $this->start_date = $recurs[$i]['start_date']; if ($this->is_repeat) { // End date will always be the same as the start date for recurring reservations $this->end_date = $this->start_date; } $is_valid = $this->check_res($resources_to_add); // Check overlap (dont kill) if ($is_valid) { $tmp_valid = true; // Only one recurring needs to pass $this->db->mod_res($this, $users_to_invite, $users_to_remove, $resources_to_add, $resources_to_remove, $accept_code); // And place the reservation if (!empty($this->reminderid)) { $reminder->update($this, $this->reminder_minutes_prior); } else { if ($this->reminder_minutes_prior != 0 && empty($this->reminderid)) { $reminder->save($this, $this->reminder_minutes_prior); } } $dates[] = $this->start_date; $valid_resids[] = $this->id; CmnFns::write_log($this->word . ' ' . $this->id . ' modified. machid:' . $this->get_machid() . ', dates:' . $this->start_date . ' - ' . $this->end_date . ', start:' . $this->start . ', end:' . $this->end, $this->memberid, $_SERVER['REMOTE_ADDR']); } } } else { if ($this->check_res($resources_to_add)) { // Check overlap $this->db->mod_res($this, $users_to_invite, $users_to_remove, $resources_to_add, $resources_to_remove, $accept_code); // And place the reservation if (!empty($this->reminderid)) { $reminder->update($this, $this->reminder_minutes_prior); } else { if ($this->reminder_minutes_prior != 0 && empty($this->reminderid)) { $reminder->save($this, $this->reminder_minutes_prior); } } $dates[] = $this->start_date; $valid_resids[] = $this->id; } } // Restore original reservation dates $this->start_date = $orig_start_date; $this->end_date = $orig_end_date; if ($this->has_errors()) { // Print any errors generated when adding the reservations $this->print_all_errors(!$this->is_repeat); } if (!$this->is_blackout) { // Notify the user if they want $this->send_email('e_mod', null, $unchanged_users); } // Send out invites, if needed if (!$this->is_pending && count($users_to_invite) > 0) { $this->invite_users($users_to_invite, $dates, $accept_code); } if (!$this->is_pending && count($users_to_remove) > 0) { $this->remove_users_email($users_to_remove, $dates); } if (!$this->is_repeat || $tmp_valid) { $this->print_success('modified', $dates); } }
include_once APP_INC_PATH . "class.priority.php"; include_once APP_INC_PATH . "class.reminder.php"; include_once APP_INC_PATH . "class.issue.php"; $tpl = new Template_API(); $tpl->setTemplate("manage/index.tpl.html"); Auth::checkAuthentication(APP_COOKIE); $tpl->assign("type", "reminders"); $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", Reminder::insert()); } elseif (@$HTTP_POST_VARS["cat"] == "update") { $tpl->assign("result", Reminder::update()); } elseif (@$HTTP_POST_VARS["cat"] == "delete") { Reminder::remove(); } if (@$HTTP_GET_VARS["cat"] == "edit") { $info = Reminder::getDetails($HTTP_GET_VARS["id"]); if (!empty($HTTP_GET_VARS['prj_id'])) { $info['rem_prj_id'] = $HTTP_GET_VARS['prj_id']; } // only show customers and support levels if the selected project really needs it $project_has_customer_integration = Customer::hasCustomerIntegration($info['rem_prj_id']); $tpl->assign("project_has_customer_integration", $project_has_customer_integration); if ($project_has_customer_integration) { $tpl->assign("customers", Customer::getAssocList($info['rem_prj_id'])); $backend_uses_support_levels = Customer::doesBackendUseSupportLevels($info['rem_prj_id']); if ($backend_uses_support_levels) {
Html::back(); } else { if (isset($_POST["purge"])) { $remind->check($_POST["id"], PURGE); $remind->delete($_POST, 1); Event::log($_POST["id"], "reminder", 4, "tools", sprintf(__('%s purges an item'), $_SESSION["glpiname"])); if (!isset($_POST["from_planning_edit_ajax"])) { $remind->redirectToList(); } else { Html::back(); } } else { if (isset($_POST["update"])) { $remind->check($_POST["id"], UPDATE); // Right to update the reminder $remind->update($_POST); Event::log($_POST["id"], "reminder", 4, "tools", sprintf(__('%s updates an item'), $_SESSION["glpiname"])); Html::back(); } else { if (isset($_POST["addvisibility"])) { if (isset($_POST["_type"]) && !empty($_POST["_type"]) && isset($_POST["reminders_id"]) && $_POST["reminders_id"]) { $item = NULL; switch ($_POST["_type"]) { case 'User': if (isset($_POST['users_id']) && $_POST['users_id']) { $item = new Reminder_User(); } break; case 'Group': if (isset($_POST['groups_id']) && $_POST['groups_id']) { $item = new Group_Reminder();
$tpl = new Template_Helper(); $tpl->setTemplate('manage/reminders.tpl.html'); Auth::checkAuthentication(APP_COOKIE); $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; } $tpl->assign('backend_uses_support_levels', false); $tpl->assign('project_has_customer_integration', false); if (@$_POST['cat'] == 'new') { $res = Reminder::insert(); Misc::mapMessages($res, array(1 => array(ev_gettext('Thank you, the reminder was added successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to add the new reminder.'), Misc::MSG_ERROR), -2 => array(ev_gettext('Please enter the title for this new reminder.'), Misc::MSG_ERROR))); } elseif (@$_POST['cat'] == 'update') { $res = Reminder::update(); Misc::mapMessages($res, array(1 => array(ev_gettext('Thank you, the reminder was updated successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to update the reminder.'), Misc::MSG_ERROR), -2 => array(ev_gettext('Please enter the title for this reminder.'), Misc::MSG_ERROR))); } elseif (@$_POST['cat'] == 'delete') { Reminder::remove(); } if (@$_GET['cat'] == 'edit') { $info = Reminder::getDetails($_GET['id']); if (!empty($_GET['prj_id'])) { $info['rem_prj_id'] = $_GET['prj_id']; } // only show customers and support levels if the selected project really needs it $project_has_customer_integration = CRM::hasCustomerIntegration($info['rem_prj_id']); $tpl->assign('project_has_customer_integration', $project_has_customer_integration); if ($project_has_customer_integration) { $crm = CRM::getInstance($info['rem_prj_id']); $tpl->assign('customers', $crm->getCustomerAssocList());