Ejemplo n.º 1
0
 /**
  * Method used to get the system-wide default preferences.
  *
  * @access  public
  * @param   array $projects An array of projects this user will have access too.
  * @return  string The serialized array of the default preferences
  */
 function getDefaults($projects)
 {
     $prefs = array('receive_assigned_emails' => array(), 'receive_new_emails' => array(), 'timezone' => Date_API::getDefaultTimezone(), 'list_refresh_rate' => APP_DEFAULT_REFRESH_RATE, 'emails_refresh_rate' => APP_DEFAULT_REFRESH_RATE, 'email_signature' => '', 'auto_append_sig' => 'no', 'auto_append_note_sig' => 'no');
     foreach ($projects as $prj_id) {
         $prefs['receive_assigned_emails'][$prj_id] = APP_DEFAULT_ASSIGNED_EMAILS;
         $prefs['receive_new_emails'][$prj_id] = APP_DEFAULT_NEW_EMAILS;
     }
     return serialize($prefs);
 }
Ejemplo n.º 2
0
 /**
  * Method used to get all open issues and group them by user.
  *
  * @access  public
  * @param   integer $prj_id The project ID
  * @param   integer $cutoff_days The number of days to use as a cutoff period
  * @return  array The list of issues
  */
 function getOpenIssuesByUser($prj_id, $cutoff_days)
 {
     $prj_id = Misc::escapeInteger($prj_id);
     $cutoff_days = Misc::escapeInteger($cutoff_days);
     $ts = Date_API::getCurrentUnixTimestampGMT();
     $cutoff_ts = $ts - $cutoff_days * DAY;
     $stmt = "SELECT\n                    usr_full_name,\n                    iss_id,\n                    iss_summary,\n                    sta_title,\n                    iss_sta_id,\n                    iss_created_date,\n                    iss_updated_date,\n                    iss_last_response_date,\n                    sta_color\n                 FROM\n                    (\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue,\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user,\n                    " . ETEL_USER_TABLE . "\n                    )\n                 LEFT JOIN\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "status\n                 ON\n                    iss_sta_id=sta_id\n                 WHERE\n                    sta_is_closed=0 AND\n                    iss_prj_id={$prj_id} AND\n                    iss_id=isu_iss_id AND\n                    isu_usr_id=usr_id AND\n                    UNIX_TIMESTAMP(iss_created_date) < {$cutoff_ts}\n                 ORDER BY\n                    usr_full_name";
     $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 {
         Time_Tracking::getTimeSpentByIssues($res);
         $issues = array();
         for ($i = 0; $i < count($res); $i++) {
             if (empty($res[$i]['iss_updated_date'])) {
                 $res[$i]['iss_updated_date'] = $res[$i]['iss_created_date'];
             }
             if (empty($res[$i]['iss_last_response_date'])) {
                 $res[$i]['iss_last_response_date'] = $res[$i]['iss_created_date'];
             }
             $issues[$res[$i]['usr_full_name']][$res[$i]['iss_id']] = array('iss_summary' => $res[$i]['iss_summary'], 'sta_title' => $res[$i]['sta_title'], 'iss_created_date' => Date_API::getFormattedDate($res[$i]['iss_created_date']), 'time_spent' => Misc::getFormattedTime($res[$i]['time_spent']), 'status_color' => $res[$i]['sta_color'], 'last_update' => Date_API::getFormattedDateDiff($ts, Date_API::getUnixTimestamp($res[$i]['iss_updated_date'], Date_API::getDefaultTimezone())), 'last_email_response' => Date_API::getFormattedDateDiff($ts, Date_API::getUnixTimestamp($res[$i]['iss_last_response_date'], Date_API::getDefaultTimezone())));
         }
         return $issues;
     }
 }
Ejemplo n.º 3
0
 /**
  * Returns the status of a quarantine.
  *
  * @param   integer $issue_id The issue ID
  * @return  integer Indicates what the current state of quarantine is.
  */
 function getQuarantineInfo($issue_id)
 {
     $stmt = "SELECT\n                    iqu_status,\n                    iqu_expiration\n                 FROM\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_quarantine\n                 WHERE\n                    iqu_iss_id = " . Misc::escapeInteger($issue_id) . " AND\n                        (iqu_expiration > '" . Date_API::getCurrentDateGMT() . "' OR\n                        iqu_expiration IS NULL)";
     $res = $GLOBALS["db_api"]->dbh->getRow($stmt, DB_FETCHMODE_ASSOC);
     if (PEAR::isError($res)) {
         Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
         return array();
     } else {
         if (!empty($res["iqu_expiration"])) {
             $expiration_ts = Date_API::getUnixTimestamp($res['iqu_expiration'], Date_API::getDefaultTimezone());
             $res["time_till_expiration"] = Date_API::getFormattedDateDiff($expiration_ts, Date_API::getCurrentUnixTimestampGMT());
         }
         return $res;
     }
 }
Ejemplo n.º 4
0
 /**
  * Method used to get the timezone preferred by the user.
  *
  * @access  public
  * @param   integer $usr_id The user ID
  * @return  string The timezone preferred by the user
  */
 function getPreferredTimezone($usr_id = FALSE)
 {
     if ($usr_id === FALSE) {
         $usr_id = Auth::getUserID();
     }
     if (empty($usr_id)) {
         return Date_API::getDefaultTimezone();
     }
     $prefs = Prefs::get($usr_id);
     if (empty($prefs["timezone"])) {
         return Date_API::getDefaultTimezone();
     } else {
         return $prefs["timezone"];
     }
 }