Ejemplo n.º 1
0
 /**
  * Method used to update the details of a specific reminder.
  *
  * @access  public
  * @return  integer 1 if the update worked, -1 or -2 otherwise
  */
 function update()
 {
     global $HTTP_POST_VARS;
     $stmt = "UPDATE\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_level\n                 SET\n                    rem_last_updated_date='" . Date_API::getCurrentDateGMT() . "',\n                    rem_rank=" . Misc::escapeInteger($HTTP_POST_VARS['rank']) . ",\n                    rem_title='" . Misc::escapeString($HTTP_POST_VARS['title']) . "',\n                    rem_prj_id=" . Misc::escapeInteger($HTTP_POST_VARS['project']) . ",\n                    rem_skip_weekend=" . Misc::escapeInteger($HTTP_POST_VARS['skip_weekend']) . "\n                 WHERE\n                    rem_id=" . Misc::escapeInteger($HTTP_POST_VARS['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 {
         Reminder::removeAllAssociations($HTTP_POST_VARS['id']);
         // map the reminder requirements now
         if (@$HTTP_POST_VARS['reminder_type'] == 'support_level' && count($HTTP_POST_VARS['support_levels']) > 0) {
             for ($i = 0; $i < count($HTTP_POST_VARS['support_levels']); $i++) {
                 Reminder::addSupportLevelAssociation($HTTP_POST_VARS['id'], $HTTP_POST_VARS['support_levels'][$i]);
             }
         } elseif (@$HTTP_POST_VARS['reminder_type'] == 'issue' && count($HTTP_POST_VARS['issues']) > 0) {
             for ($i = 0; $i < count($HTTP_POST_VARS['issues']); $i++) {
                 Reminder::addIssueAssociation($HTTP_POST_VARS['id'], $HTTP_POST_VARS['issues'][$i]);
             }
         } elseif (@$HTTP_POST_VARS['reminder_type'] == 'customer' && count($HTTP_POST_VARS['customers']) > 0) {
             for ($i = 0; $i < count($HTTP_POST_VARS['customers']); $i++) {
                 Reminder::addCustomerAssociation($HTTP_POST_VARS['id'], $HTTP_POST_VARS['customers'][$i]);
             }
         } elseif (@$HTTP_POST_VARS['reminder_type'] == 'all_issues') {
             Reminder::associateAllIssues($HTTP_POST_VARS['id']);
         }
         if (@$HTTP_POST_VARS['check_priority'] == 'yes' && count($HTTP_POST_VARS['priorities']) > 0) {
             for ($i = 0; $i < count($HTTP_POST_VARS['priorities']); $i++) {
                 Reminder::addPriorityAssociation($HTTP_POST_VARS['id'], $HTTP_POST_VARS['priorities'][$i]);
             }
         }
         return 1;
     }
 }