示例#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);
 }
示例#2
0
 /**
  * Method used to save the login information into a log file. It will be
  * useful for administrative purposes, so we know which customers were able
  * to login.
  *
  * @access  public
  * @param   string $email The email associated with the user
  * @param   string $type Whether it was a successful login or not
  * @param   string $extra The reason for not being a successful login
  */
 function saveLoginAttempt($email, $type, $extra = false)
 {
     $msg = Date_API::getCurrentDateGMT() . " - Login attempt by '{$email}' was ";
     if ($type == 'success') {
         $msg .= "successful.\n";
     } else {
         $msg .= "not successful because of '{$extra}'.\n";
     }
     $fp = @fopen(APP_LOGIN_LOG, "a");
     @fwrite($fp, $msg);
     @fclose($fp);
 }
示例#3
0
 /**
  * Returns the contract status associated with the given customer ID. 
  * Possible return values are 'active', 'in_grace_period' and 'expired'.
  *
  * @access  public
  * @param   integer $customer_id The customer ID
  * @return  string The contract status
  */
 function getContractStatus($customer_id)
 {
     // active contracts have an expiration date in the future
     $expiration = strtotime($this->data[$customer_id]['expiration_date']);
     $now = Date_API::getCurrentUnixTimestampGMT();
     if ($expiration > $now) {
         return 'active';
     } elseif ($expiration > $now + DAY * $this->getExpirationOffset()) {
         return 'in_grace_period';
     } else {
         return 'expired';
     }
 }
 /**
  * Method used to save a history entry about the execution of the current
  * reminder.
  *
  * @access  public
  * @param   integer $issue_id The issue ID
  * @param   integer $rma_id The reminder action ID
  * @return  boolean
  */
 function saveHistory($issue_id, $rma_id)
 {
     $stmt = "INSERT INTO\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_history\n                 (\n                    rmh_iss_id,\n                    rmh_rma_id,\n                    rmh_created_date\n                 ) VALUES (\n                    " . Misc::escapeInteger($issue_id) . ",\n                    " . Misc::escapeInteger($rma_id) . ",\n                    '" . Date_API::getCurrentDateGMT() . "'\n                 )";
     $res = $GLOBALS["db_api"]->dbh->query($stmt);
     if (PEAR::isError($res)) {
         Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
         return false;
     } else {
         return true;
     }
 }
示例#5
0
 /**
  * Method used to get the list of issues in a project, and group
  * them by the assignee.
  *
  * @access  public
  * @param   integer $prj_id The project ID
  * @return  array The list of issues
  */
 function getIssuesByUser($prj_id)
 {
     $stmt = "SELECT\n                    usr_full_name,\n                    iss_id,\n                    iss_summary,\n                    sta_title,\n                    iss_sta_id,\n                    iss_created_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                    iss_prj_id=" . Misc::escapeInteger($prj_id) . " AND\n                    iss_id=isu_iss_id AND\n                    isu_usr_id=usr_id\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++) {
             $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']);
         }
         return $issues;
     }
 }
示例#6
0
 /**
  * Method used to format a RFC 822 compliant date for the given unix
  * timestamp.
  *
  * @access  public
  * @param   integer $ts The unix timestamp
  * @return  string The formatted date string
  */
 function formatReplyDate($ts)
 {
     // On Fri, 01 Apr 2005, 17:07:44 GMT
     return Date_API::getFormattedDate($ts);
 }
 /**
  * Returns the mail queue for a specific issue.
  *
  * @access  public
  * @param   integer $issue_is The issue ID
  * @return  array An array of emails from the queue
  */
 function getListByIssueID($issue_id)
 {
     $issue_id = Misc::escapeInteger($issue_id);
     $stmt = "SELECT\n                    maq_id,\n                    maq_queued_date,\n                    maq_status,\n                    maq_recipient,\n                    maq_subject\n                 FROM\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "mail_queue\n                 WHERE\n                    maq_iss_id = " . Misc::escapeInteger($issue_id) . "\n                 ORDER BY\n                    maq_queued_date 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 false;
     }
     if (count($res) > 0) {
         for ($i = 0; $i < count($res); $i++) {
             $res[$i]['maq_recipient'] = Mime_Helper::decodeAddress($res[$i]['maq_recipient']);
             $res[$i]['maq_queued_date'] = Date_API::getFormattedDate(Date_API::getUnixTimestamp($res[$i]['maq_queued_date'], 'GMT'));
             $res[$i]['maq_subject'] = Mime_Helper::fixEncoding($res[$i]['maq_subject']);
         }
     }
     return $res;
 }
示例#8
0
 /**
  * Returns the SQL used to calculate the difference of 2 dates, not counting weekends.
  * This thing is truly a work of art, the type of art that throws lemon juice in your eye and then laughs.
  * If $end_date_field is null, the current date is used instead.
  *
  * @access  public
  * @param   string $start_date_field The name of the field the first date is.
  * @param   string $end_date_field The name of the field where the second date is.
  * @return  string The SQL used to compare the 2 dates.
  */
 function getNoWeekendDateDiffSQL($start_date_field, $end_date_field = false)
 {
     if ($end_date_field == false) {
         $end_date_field = "'" . Date_API::getCurrentDateGMT() . "'";
     }
     // this is crazy, but it does work. Anyone with a better solution email bryan@mysql.com
     $sql = "((UNIX_TIMESTAMP({$end_date_field}) - UNIX_TIMESTAMP({$start_date_field})) - (CASE\n            WHEN DAYOFWEEK({$start_date_field}) = 1 THEN (floor(((TO_DAYS({$end_date_field}) - TO_DAYS({$start_date_field}))-1)/7) * 86400 * 2)\n            WHEN DAYOFWEEK({$start_date_field}) = 2 THEN (floor(((TO_DAYS({$end_date_field}) - TO_DAYS({$start_date_field})))/7) * 86400 *2)\n            WHEN DAYOFWEEK({$start_date_field}) = 3 THEN (floor(((TO_DAYS({$end_date_field}) - TO_DAYS({$start_date_field}))+1)/7) * 86400 *2)\n            WHEN DAYOFWEEK({$start_date_field}) = 4 THEN (floor(((TO_DAYS({$end_date_field}) - TO_DAYS({$start_date_field}))+2)/7) * 86400 *2)\n            WHEN DAYOFWEEK({$start_date_field}) = 5 THEN (floor(((TO_DAYS({$end_date_field}) - TO_DAYS({$start_date_field}))+3)/7) * 86400 *2)\n            WHEN DAYOFWEEK({$start_date_field}) = 6 THEN (floor(((TO_DAYS({$end_date_field}) - TO_DAYS({$start_date_field}))+4)/7) * 86400 *2)\n            WHEN DAYOFWEEK({$start_date_field}) = 7 THEN (floor(((TO_DAYS({$end_date_field}) - TO_DAYS({$start_date_field}))-2)/7) * 86400 *2)\n        END) - (CASE\n            WHEN DAYOFWEEK({$start_date_field}) = 7 THEN (86400 + (86400 - time_to_sec({$start_date_field})))\n            WHEN DAYOFWEEK({$start_date_field}) = 1 THEN (86400 - time_to_sec({$start_date_field}))\n            ELSE 0\n        END) - CASE\n            WHEN DAYOFWEEK({$end_date_field}) = 7 THEN time_to_sec({$end_date_field})\n            WHEN DAYOFWEEK({$end_date_field}) = 1 THEN (86400 + time_to_sec({$end_date_field}))\n            ELSE 0\n        END)";
     return str_replace("\n", " ", $sql);
 }
 /**
  * Retrieves the next assignee in the given project's round robin queue.
  *
  * @access  public
  * @param   integer $prj_id The project ID
  * @return  integer The assignee's user ID
  */
 function getNextAssignee($prj_id)
 {
     // get the full list of users for the given project
     list($blackout_start, $blackout_end, $users) = Round_Robin::getUsersByProject($prj_id);
     if (count($users) == 0) {
         return 0;
     } else {
         $user_ids = array_keys($users);
         $next_usr_id = 0;
         foreach ($users as $usr_id => $details) {
             if ($details['is_next']) {
                 $next_usr_id = $usr_id;
                 break;
             }
         }
         // if no user is currently set as the 'next' assignee,
         // then just get the first one in the list
         if (empty($next_usr_id)) {
             $next_usr_id = $user_ids[0];
         }
         // counter to keep the number of times we found an invalid user
         $ignored_users = 0;
         // check the blackout hours
         do {
             $user = new Date(Date_API::getCurrentUnixTimestampGMT());
             $user->convertTZById($users[$next_usr_id]['timezone']);
             list($today, $tomorrow) = Round_Robin::getBlackoutDates(&$user, $blackout_start, $blackout_end);
             $first = new Date($today . ' ' . $blackout_start);
             $first->setTZById($users[$next_usr_id]['timezone']);
             $second = new Date($tomorrow . ' ' . $blackout_end);
             $second->setTZById($users[$next_usr_id]['timezone']);
             if (Date::compare($first, $user) == -1 && Date::compare($user, $second) == -1) {
                 $ignored_users++;
                 $current_index = array_search($next_usr_id, $user_ids);
                 // if we reached the end of the list of users and none of them
                 // was a valid one, then just select the first one
                 // however, we want to complete at least one full iteration over the list of users
                 // that is, if we didn't start checking the users in the beginning of the list,
                 // then do another run over the users just in case
                 if ($ignored_users >= count($user_ids) && $current_index == count($user_ids) - 1) {
                     $assignee = $user_ids[0];
                     break;
                 }
                 // if we reached the end of the list, and we still didn't find an user,
                 // then go back to the beginning of the list one last time
                 if ($current_index == count($user_ids) - 1) {
                     $current_index = 0;
                     $next_usr_id = $user_ids[++$current_index];
                     $found = 0;
                     continue;
                 }
                 $next_usr_id = $user_ids[++$current_index];
                 $found = 0;
             } else {
                 $assignee = $next_usr_id;
                 $found = 1;
             }
         } while (!$found);
         // mark the next user in the list as the 'next' assignment
         $assignee_index = array_search($assignee, $user_ids);
         if ($assignee_index == count($user_ids) - 1) {
             $next_assignee = $user_ids[0];
         } else {
             $next_assignee = $user_ids[++$assignee_index];
         }
         Round_Robin::markNextAssignee($prj_id, $next_assignee);
         return $assignee;
     }
 }
    $bplot = new BarPlot(array_values($values));
    if ($performer == "customer") {
        $color = "#99ccff";
    } else {
        $color = "#ffcc00";
    }
    $bplot->SetFillColor($color);
    $bplot->setLegend(ucfirst($performer) . " " . $event_type);
    $plots[] = $bplot;
}
$graph = new Graph(800, 350);
$graph->SetScale("textlin");
$graph->img->SetMargin(60, 30, 40, 40);
$graph->yaxis->SetTitleMargin(45);
$graph->SetShadow();
// Turn the tickmarks
$graph->xaxis->SetTickDirection(SIDE_DOWN);
$graph->yaxis->SetTickDirection(SIDE_LEFT);
$graph->xaxis->SetTickLabels(array_keys($data["developer"] + $data["customer"]));
// group plots together
$grouped = new GroupBarPlot($plots);
$graph->Add($grouped);
$graph->title->Set($graph_title);
$graph->xaxis->title->Set("Hours (" . Date_API::getTimezoneShortNameByUser($usr_id) . ")");
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->yaxis->title->Set(ucfirst($event_type) . " (%)");
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->legend->Pos(0.01, 0.09, 'left', 'bottom');
$graph->legend->SetLayout(LEGEND_HOR);
$graph->Stroke();
示例#11
0
    echo htmlspecialchars($issue['sta_title']);
    ?>
&lt;BR&gt;
      Priority: <?php 
    echo htmlspecialchars($issue['pri_title']);
    ?>
&lt;BR&gt;
      Category: <?php 
    echo htmlspecialchars($issue['prc_title']);
    ?>
&lt;BR&gt;
      &lt;BR&gt;<?php 
    echo htmlspecialchars(Link_Filter::activateLinks(nl2br($issue['iss_description'])));
    ?>
&lt;BR&gt;
      </description>
      <author><?php 
    echo htmlspecialchars($issue['reporter']);
    ?>
</author>
      <pubDate><?php 
    echo Date_API::getRFC822Date($issue['iss_created_date'], "GMT");
    ?>
</pubDate>
    </item>
<?php 
}
?>

  </channel>
</rss>
 /**
  * Method used to remotely record a time tracking entry.
  *
  * @access  public
  * @param   integer $issue_id The issue ID
  * @param   integer $usr_id The user ID
  * @param   integer $cat_id The time tracking category ID
  * @param   string $summary The summary of the work entry
  * @param   integer $time_spent The time spent in minutes
  * @return  integer 1 if the insert worked, -1 otherwise
  */
 function recordRemoteEntry($issue_id, $usr_id, $cat_id, $summary, $time_spent)
 {
     $stmt = "INSERT INTO\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "time_tracking\n                 (\n                    ttr_ttc_id,\n                    ttr_iss_id,\n                    ttr_usr_id,\n                    ttr_created_date,\n                    ttr_time_spent,\n                    ttr_summary\n                 ) VALUES (\n                    " . Misc::escapeInteger($cat_id) . ",\n                    " . Misc::escapeInteger($issue_id) . ",\n                    " . Misc::escapeInteger($usr_id) . ",\n                    '" . Date_API::getCurrentDateGMT() . "',\n                    " . Misc::escapeInteger($time_spent) . ",\n                    '" . Misc::escapeString($summary) . "'\n                 )";
     $res = $GLOBALS["db_api"]->dbh->query($stmt);
     if (PEAR::isError($res)) {
         Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
         return -1;
     } else {
         Issue::markAsUpdated($issue_id);
         // need to save a history entry for this
         History::add($issue_id, $usr_id, History::getTypeID('remote_time_added'), 'Time tracking entry submitted remotely by ' . User::getFullName($usr_id));
         return 1;
     }
 }
// | Boston, MA 02111-1307, USA.                                          |
// +----------------------------------------------------------------------+
// | Authors: Bryan Alsdorf <*****@*****.**>                             |
// +----------------------------------------------------------------------+
//
// @(#) $Id$
//
include_once "../config.inc.php";
include_once APP_INC_PATH . "class.template.php";
include_once APP_INC_PATH . "class.auth.php";
include_once APP_INC_PATH . "class.report.php";
include_once APP_INC_PATH . "class.date.php";
include_once APP_INC_PATH . "db_access.php";
$tpl = new Template_API();
$tpl->setTemplate("reports/workload_time_period.tpl.html");
Auth::checkAuthentication(APP_COOKIE);
$usr_id = Auth::getUserID();
if (Auth::getCurrentRole() <= User::getRoleID("Customer")) {
    echo "Invalid role";
    exit;
}
$prj_id = Auth::getCurrentProject();
// get timezone of current user
$user_prefs = Prefs::get($usr_id);
if (@$HTTP_GET_VARS["type"] == "email") {
    $data = Report::getEmailWorkloadByTimePeriod(@$user_prefs["timezone"]);
} else {
    $data = Report::getWorkloadByTimePeriod(@$user_prefs["timezone"]);
}
$tpl->assign(array("data" => $data, "type" => @$HTTP_GET_VARS["type"], "user_tz" => Date_API::getTimezoneShortNameByUser($usr_id)));
$tpl->displayTemplate();
示例#14
0
// | Authors: Bryan Alsdorf <*****@*****.**>                             |
// +----------------------------------------------------------------------+
//
//
include_once "../../config.inc.php";
include_once APP_INC_PATH . "db_access.php";
include_once APP_INC_PATH . "class.customer.php";
include_once APP_INC_PATH . "class.user.php";
// creates user accounts for all the customers
$prj_id = 1;
$customers = Customer::getAssocList($prj_id);
foreach ($customers as $customer_id => $customer_name) {
    echo "Customer: {$customer_name}<br />\n";
    $details = Customer::getDetails($prj_id, $customer_id);
    foreach ($details['contacts'] as $contact) {
        echo "Contact: " . $contact['first_name'] . " " . $contact['last_name'] . " (" . $contact['email'] . ")<br />\n";
        $contact_id = User::getUserIDByContactID($contact['contact_id']);
        if (empty($contact_id)) {
            $sql = "INSERT INTO\n                        " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "user\n                    SET\n                        usr_created_date = '" . Date_API::getCurrentDateGMT() . "',\n                        usr_full_name = '" . Misc::escapeString($contact['first_name'] . " " . $contact['last_name']) . "',\n                        usr_email = '" . $contact['email'] . "',\n                        usr_customer_id = " . $customer_id . ",\n                        usr_customer_contact_id = " . $contact['contact_id'] . ",\n                        usr_preferences = '" . Misc::escapeString(Prefs::getDefaults(array($prj_id))) . "'";
            $res = $GLOBALS["db_api"]->dbh->query($sql);
            if (PEAR::isError($res)) {
                echo "Error inserting user<br /><pre>";
                print_r($res);
                echo "</pre>";
            }
            $new_usr_id = $GLOBALS['db_api']->get_last_insert_id();
            Project::associateUser($prj_id, $new_usr_id, User::getRoleID("Customer"));
        }
    }
    echo "<hr />";
}
示例#15
0
 /**
  * Adds a quick note for the specified customer.
  * 
  * @access  public
  * @param   integer $prj_id The project ID
  * @param   integer $customer_id The id of the customer.
  * @param   string  $note The note to add.
  */
 function insertNote($prj_id, $customer_id, $note)
 {
     $stmt = "INSERT INTO\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "customer_note\n                 (\n                    cno_prj_id,\n                    cno_customer_id,\n                    cno_created_date,\n                    cno_updated_date,\n                    cno_note\n                 ) VALUES (\n                    " . Misc::escapeInteger($prj_id) . ",\n                    " . Misc::escapeInteger($customer_id) . ",\n                    '" . Date_API::getCurrentDateGMT() . "',\n                    '" . Date_API::getCurrentDateGMT() . "',\n                    '" . Misc::escapeString($note) . "'\n                 )";
     $res = $GLOBALS['db_api']->dbh->query($stmt);
     if (PEAR::isError($res)) {
         Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
         return -1;
     } else {
         return 1;
     }
 }
示例#16
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();
示例#17
0
function processResult($res, $date_field, $issue_field)
{
    global $prj_id;
    global $usr_id;
    $data = array();
    for ($i = 0; $i < count($res); $i++) {
        if (!Issue::canAccess($res[$i][$issue_field], $usr_id)) {
            continue;
        }
        if (Customer::hasCustomerIntegration($prj_id)) {
            $details = Customer::getDetails($prj_id, Issue::getCustomerID($res[$i][$issue_field]));
            $res[$i]["customer"] = @$details['customer_name'];
        }
        $res[$i]["date"] = Date_API::getFormattedDate($res[$i][$date_field], Date_API::getPreferredTimezone($usr_id));
        // need to decode From:, To: mail headers
        if (isset($res[$i]["sup_from"])) {
            $res[$i]["sup_from"] = Mime_Helper::fixEncoding($res[$i]["sup_from"]);
        }
        if (isset($res[$i]["sup_to"])) {
            $res[$i]["sup_to"] = Mime_Helper::fixEncoding($res[$i]["sup_to"]);
        }
        $data[] = $res[$i];
    }
    return $data;
}
示例#18
0
$usr_id = Auth::getUserID();
$prj_id = Auth::getCurrentProject();
if (!Customer::hasCustomerIntegration($prj_id)) {
    // show all FAQ entries
    $support_level_id = -1;
} else {
    if (!Customer::doesBackendUseSupportLevels($prj_id)) {
        // show all FAQ entries
        $support_level_id = -1;
    } else {
        if (Auth::getCurrentRole() != User::getRoleID('Customer')) {
            // show all FAQ entries
            $support_level_id = -1;
        } else {
            $customer_id = User::getCustomerID(Auth::getUserID());
            $support_level_id = Customer::getSupportLevelID($prj_id, $customer_id);
        }
    }
}
$tpl->assign("faqs", FAQ::getListBySupportLevel($support_level_id));
if (!empty($HTTP_GET_VARS["id"])) {
    $t = FAQ::getDetails($HTTP_GET_VARS['id']);
    // check if this customer should have access to this FAQ entry or not
    if ($support_level_id != -1 && !in_array($support_level_id, $t['support_levels'])) {
        $tpl->assign('faq', -1);
    } else {
        $t['faq_created_date'] = Date_API::getFormattedDate($t["faq_created_date"]);
        $tpl->assign("faq", $t);
    }
}
$tpl->displayTemplate();
示例#19
0
     $show_releases = 0;
 }
 // get if categories should be displayed
 $cats = Category::getList($prj_id);
 if (count($cats) > 0) {
     $show_category = 1;
 } else {
     $show_category = 0;
 }
 $cookie = Auth::getCookieInfo(APP_PROJECT_COOKIE);
 if (!empty($auto_switched_from)) {
     $tpl->assign(array("project_auto_switched" => 1, "old_project" => Project::getName($auto_switched_from)));
 }
 $setup = Setup::load();
 $tpl->assign("allow_unassigned_issues", @$setup["allow_unassigned_issues"]);
 $tpl->assign(array('next_issue' => @$sides['next'], 'previous_issue' => @$sides['previous'], 'subscribers' => Notification::getSubscribers($issue_id), 'custom_fields' => Custom_Field::getListByIssue($prj_id, $issue_id), 'files' => Attachment::getList($issue_id), 'emails' => Support::getEmailsByIssue($issue_id), 'zones' => Date_API::getTimezoneList(), 'users' => Project::getUserAssocList($prj_id, 'active', User::getRoleID('Customer')), 'ema_id' => Email_Account::getEmailAccount(), 'max_attachment_size' => Attachment::getMaxAttachmentSize(), 'show_releases' => $show_releases, 'show_category' => $show_category, 'categories' => Category::getAssocList($prj_id), 'quarantine' => Issue::getQuarantineInfo($issue_id)));
 if ($role_id != User::getRoleID('customer')) {
     if (@$_REQUEST['show_all_drafts'] == 1) {
         $show_all_drafts = true;
     } else {
         $show_all_drafts = false;
     }
     if (Workflow::hasWorkflowIntegration($prj_id)) {
         $statuses = Workflow::getAllowedStatuses($prj_id, $issue_id);
         // if currently selected release is not on list, go ahead and add it.
     } else {
         $statuses = Status::getAssocStatusList($prj_id);
     }
     if (!empty($details['iss_sta_id']) && empty($statuses[$details['iss_sta_id']])) {
         $statuses[$details['iss_sta_id']] = Status::getStatusTitle($details['iss_sta_id']);
     }
$stmt = "SELECT MAX(usr_id)+1 FROM eventum_user";
$new_usr_id = $GLOBALS["db_api"]->dbh->getOne($stmt);
if (PEAR::isError($new_usr_id)) {
    echo "ERROR:<br /><br />";
    var_dump($new_usr_iod);
    exit(1);
}
$stmt = "UPDATE eventum_user SET usr_id = {$new_usr_id} WHERE usr_id = 1";
$res = $GLOBALS["db_api"]->dbh->query($stmt);
if (PEAR::isError($res)) {
    echo "ERROR:<br /><br />";
    var_dump($res);
    exit(1);
}
$fixes = array("UPDATE eventum_custom_filter SET cst_usr_id = {$new_usr_id} WHERE cst_usr_id = 1", "UPDATE eventum_issue SET iss_usr_id = {$new_usr_id} WHERE iss_usr_id = 1", "UPDATE eventum_issue_attachment SET iat_usr_id = {$new_usr_id} WHERE iat_usr_id = 1", "UPDATE eventum_issue_requirement SET isr_usr_id = {$new_usr_id} WHERE isr_usr_id = 1", "UPDATE eventum_issue_user SET isu_usr_id = {$new_usr_id} WHERE isu_usr_id = 1", "UPDATE eventum_note SET not_usr_id = {$new_usr_id} WHERE not_usr_id = 1", "UPDATE eventum_project SET prj_lead_usr_id = {$new_usr_id} WHERE prj_lead_usr_id = 1", "UPDATE eventum_project_user SET pru_usr_id = {$new_usr_id} WHERE pru_usr_id = 1", "UPDATE eventum_subscription SET sub_usr_id = {$new_usr_id} WHERE sub_usr_id = 1", "UPDATE eventum_time_tracking SET ttr_usr_id = {$new_usr_id} WHERE ttr_usr_id = 1", "UPDATE eventum_phone_support SET phs_usr_id = {$new_usr_id} WHERE phs_usr_id = 1", "UPDATE eventum_reminder_action_list SET ral_usr_id = {$new_usr_id} WHERE ral_usr_id = 1", "UPDATE eventum_news SET nws_usr_id = {$new_usr_id} WHERE nws_usr_id = 1", "UPDATE eventum_round_robin_user SET rru_usr_id = {$new_usr_id} WHERE rru_usr_id = 1", "UPDATE eventum_email_draft SET emd_usr_id = {$new_usr_id} WHERE emd_usr_id = 1");
foreach ($fixes as $stmt) {
    $res = $GLOBALS["db_api"]->dbh->query($stmt);
    if (PEAR::isError($res)) {
        echo "ERROR:<br /><br />";
        var_dump($res);
        exit(1);
    }
}
// add the system account as user id == 1
$stmt = "INSERT INTO\n            eventum_user\n         (\n            usr_id,\n            usr_created_date,\n            usr_password,\n            usr_full_name,\n            usr_email,\n            usr_role,\n            usr_preferences\n         ) VALUES (\n            1,\n            '" . Date_API::getCurrentDateGMT() . "',\n            '14589714398751513457adf349173434',\n            'system',\n            '*****@*****.**',\n            5,\n            ''\n         )";
$res = $GLOBALS["db_api"]->dbh->query($stmt);
if (PEAR::isError($res)) {
    echo "ERROR:<br /><br />";
    var_dump($res);
    exit(1);
}
示例#21
0
 /**
  * Method used to send an email from the user interface.
  *
  * @access  public
  * @return  integer 1 if it worked, -1 otherwise
  */
 function sendEmail($parent_sup_id = FALSE)
 {
     global $HTTP_POST_VARS, $HTTP_SERVER_VARS;
     // if we are replying to an existing email, set the In-Reply-To: header accordingly
     if ($parent_sup_id) {
         $in_reply_to = Support::getMessageIDByID($parent_sup_id);
     } else {
         $in_reply_to = false;
     }
     // get ID of whoever is sending this.
     $sender_usr_id = User::getUserIDByEmail(Mail_API::getEmailAddress($HTTP_POST_VARS["from"]));
     if (empty($sender_usr_id)) {
         $sender_usr_id = false;
     }
     // get type of email this is
     if (!empty($HTTP_POST_VARS['type'])) {
         $type = $HTTP_POST_VARS['type'];
     } else {
         $type = '';
     }
     // remove extra 'Re: ' from subject
     $HTTP_POST_VARS['subject'] = Mail_API::removeExcessRe($HTTP_POST_VARS['subject'], true);
     $internal_only = false;
     $message_id = Mail_API::generateMessageID();
     // hack needed to get the full headers of this web-based email
     $full_email = Support::buildFullHeaders($HTTP_POST_VARS["issue_id"], $message_id, $HTTP_POST_VARS["from"], $HTTP_POST_VARS["to"], $HTTP_POST_VARS["cc"], $HTTP_POST_VARS["subject"], $HTTP_POST_VARS["message"], $in_reply_to);
     // email blocking should only be done if this is an email about an associated issue
     if (!empty($HTTP_POST_VARS['issue_id'])) {
         $user_info = User::getNameEmail(Auth::getUserID());
         // check whether the current user is allowed to send this email to customers or not
         if (!Support::isAllowedToEmail($HTTP_POST_VARS["issue_id"], $user_info['usr_email'])) {
             // add the message body as a note
             $HTTP_POST_VARS['blocked_msg'] = $full_email;
             $HTTP_POST_VARS['title'] = $HTTP_POST_VARS["subject"];
             $HTTP_POST_VARS['note'] = Mail_API::getCannedBlockedMsgExplanation() . $HTTP_POST_VARS["message"];
             Note::insert(Auth::getUserID(), $HTTP_POST_VARS["issue_id"]);
             Workflow::handleBlockedEmail(Issue::getProjectID($HTTP_POST_VARS['issue_id']), $HTTP_POST_VARS['issue_id'], $HTTP_POST_VARS, 'web');
             return 1;
         }
     }
     // only send a direct email if the user doesn't want to add the Cc'ed people to the notification list
     if (@$HTTP_POST_VARS['add_unknown'] == 'yes') {
         if (!empty($HTTP_POST_VARS['issue_id'])) {
             // add the recipients to the notification list of the associated issue
             $recipients = array($HTTP_POST_VARS['to']);
             $recipients = array_merge($recipients, Support::getRecipientsCC($HTTP_POST_VARS['cc']));
             for ($i = 0; $i < count($recipients); $i++) {
                 if (!empty($recipients[$i]) && !Notification::isIssueRoutingSender($HTTP_POST_VARS["issue_id"], $recipients[$i])) {
                     Notification::subscribeEmail(Auth::getUserID(), $HTTP_POST_VARS["issue_id"], Mail_API::getEmailAddress($recipients[$i]), array('emails'));
                 }
             }
         }
     } else {
         // Usually when sending out emails associated to an issue, we would
         // simply insert the email in the table and call the Notification::notifyNewEmail() method,
         // but on this case we need to actually send the email to the recipients that are not
         // already in the notification list for the associated issue, if any.
         // In the case of replying to an email that is not yet associated with an issue, then
         // we are always directly sending the email, without using any notification list
         // functionality.
         if (!empty($HTTP_POST_VARS['issue_id'])) {
             // send direct emails only to the unknown addresses, and leave the rest to be
             // catched by the notification list
             $from = Notification::getFixedFromHeader($HTTP_POST_VARS['issue_id'], $HTTP_POST_VARS['from'], 'issue');
             // build the list of unknown recipients
             if (!empty($HTTP_POST_VARS['to'])) {
                 $recipients = array($HTTP_POST_VARS['to']);
                 $recipients = array_merge($recipients, Support::getRecipientsCC($HTTP_POST_VARS['cc']));
             } else {
                 $recipients = Support::getRecipientsCC($HTTP_POST_VARS['cc']);
             }
             $unknowns = array();
             for ($i = 0; $i < count($recipients); $i++) {
                 if (!Notification::isSubscribedToEmails($HTTP_POST_VARS['issue_id'], $recipients[$i])) {
                     $unknowns[] = $recipients[$i];
                 }
             }
             if (count($unknowns) > 0) {
                 $to = array_shift($unknowns);
                 $cc = implode('; ', $unknowns);
                 // send direct emails
                 Support::sendDirectEmail($HTTP_POST_VARS['issue_id'], $from, $to, $cc, $HTTP_POST_VARS['subject'], $HTTP_POST_VARS['message'], $message_id, $sender_usr_id);
             }
         } else {
             // send direct emails to all recipients, since we don't have an associated issue
             $project_info = Project::getOutgoingSenderAddress(Auth::getCurrentProject());
             // use the project-related outgoing email address, if there is one
             if (!empty($project_info['email'])) {
                 $from = Mail_API::getFormattedName(User::getFullName(Auth::getUserID()), $project_info['email']);
             } else {
                 // otherwise, use the real email address for the current user
                 $from = User::getFromHeader(Auth::getUserID());
             }
             // send direct emails
             Support::sendDirectEmail($HTTP_POST_VARS['issue_id'], $from, $HTTP_POST_VARS['to'], $HTTP_POST_VARS['cc'], $HTTP_POST_VARS['subject'], $HTTP_POST_VARS['message'], $message_id);
         }
     }
     $t = array('customer_id' => 'NULL', 'issue_id' => $HTTP_POST_VARS["issue_id"] ? $HTTP_POST_VARS["issue_id"] : 0, 'ema_id' => $HTTP_POST_VARS['ema_id'], 'message_id' => $message_id, 'date' => Date_API::getCurrentDateGMT(), 'from' => $HTTP_POST_VARS['from'], 'to' => $HTTP_POST_VARS['to'], 'cc' => @$HTTP_POST_VARS['cc'], 'subject' => @$HTTP_POST_VARS['subject'], 'body' => $HTTP_POST_VARS['message'], 'full_email' => $full_email, 'has_attachment' => 0);
     // associate this new email with a customer, if appropriate
     if (Auth::getCurrentRole() == User::getRoleID('Customer')) {
         $customer_id = User::getCustomerID(Auth::getUserID());
         if (!empty($customer_id) && $customer_id != -1) {
             $t['customer_id'] = $customer_id;
         }
     }
     $structure = Mime_Helper::decode($full_email, true, false);
     $t['headers'] = $structure->headers;
     $res = Support::insertEmail($t, $structure, $sup_id);
     if (!empty($HTTP_POST_VARS["issue_id"])) {
         // need to send a notification
         Notification::notifyNewEmail(Auth::getUserID(), $HTTP_POST_VARS["issue_id"], $t, $internal_only, false, $type, $sup_id);
         // mark this issue as updated
         if (!empty($t['customer_id']) && $t['customer_id'] != 'NULL') {
             Issue::markAsUpdated($HTTP_POST_VARS["issue_id"], 'customer action');
         } else {
             if (!empty($sender_usr_id) && User::getRoleByUser($sender_usr_id, Issue::getProjectID($HTTP_POST_VARS['issue_id'])) > User::getRoleID('Customer')) {
                 Issue::markAsUpdated($HTTP_POST_VARS["issue_id"], 'staff response');
             } else {
                 Issue::markAsUpdated($HTTP_POST_VARS["issue_id"], 'user response');
             }
         }
         // save a history entry for this
         History::add($HTTP_POST_VARS["issue_id"], Auth::getUserID(), History::getTypeID('email_sent'), 'Outgoing email sent by ' . User::getFullName(Auth::getUserID()));
         // also update the last_response_date field for the associated issue
         if (Auth::getCurrentRole() > User::getRoleID('Customer')) {
             $stmt = "UPDATE\n                            " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue\n                         SET\n                            iss_last_response_date='" . Date_API::getCurrentDateGMT() . "'\n                         WHERE\n                            iss_id=" . Misc::escapeInteger($HTTP_POST_VARS["issue_id"]);
             $GLOBALS["db_api"]->dbh->query($stmt);
             $stmt = "UPDATE\n                            " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue\n                         SET\n                            iss_first_response_date='" . Date_API::getCurrentDateGMT() . "'\n                         WHERE\n                            iss_first_response_date IS NULL AND\n                            iss_id=" . Misc::escapeInteger($HTTP_POST_VARS["issue_id"]);
             $GLOBALS["db_api"]->dbh->query($stmt);
         }
     }
     return 1;
 }
示例#22
0
 /**
  * Returns a list of drafts associated with an issue.
  *
  * @access  public
  * @param   integer $issue_id The ID of the issue.
  * @param   boolean $show_all If all draft statuses should be shown
  * @return  array An array of drafts.
  */
 function getList($issue_id, $show_all = false)
 {
     $issue_id = Misc::escapeInteger($issue_id);
     $stmt = "SELECT\n                    emd_id,\n                    emd_usr_id,\n                    emd_subject,\n                    emd_updated_date,\n                    emd_unknown_user,\n                    emd_status\n                 FROM\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "email_draft\n                 WHERE\n                    emd_iss_id={$issue_id}\n";
     if ($show_all == false) {
         $stmt .= "AND emd_status = 'pending'\n";
     }
     $stmt .= "ORDER BY\n                    emd_id";
     $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 {
         for ($i = 0; $i < count($res); $i++) {
             $res[$i]["emd_updated_date"] = Date_API::getFormattedDate($res[$i]["emd_updated_date"]);
             if (!empty($res[$i]['emd_unknown_user'])) {
                 $res[$i]['from'] = $res[$i]["emd_unknown_user"];
             } else {
                 $res[$i]['from'] = User::getFromHeader($res[$i]['emd_usr_id']);
             }
             list($res[$i]['to'], ) = Draft::getEmailRecipients($res[$i]['emd_id']);
             if (empty($res[$i]['to'])) {
                 $res[$i]['to'] = "Notification List";
             }
         }
         return $res;
     }
 }
示例#23
0
}
$prj_id = Auth::getCurrentProject();
if (count(@$HTTP_POST_VARS["start"]) > 0 && @$HTTP_POST_VARS["start"]["Year"] != 0 && @$HTTP_POST_VARS["start"]["Month"] != 0 && @$HTTP_POST_VARS["start"]["Day"] != 0) {
    $start_date = join("-", $HTTP_POST_VARS["start"]);
}
if (count(@$HTTP_POST_VARS["end"]) > 0 && @$HTTP_POST_VARS["end"]["Year"] != 0 && @$HTTP_POST_VARS["end"]["Month"] != 0 && @$HTTP_POST_VARS["end"]["Day"] != 0) {
    $end_date = join("-", $HTTP_POST_VARS["end"]);
}
$tpl->assign(array("weeks" => Date_API::getWeekOptions(3, 0), "users" => Project::getUserAssocList($prj_id, 'active', User::getRoleID('Customer')), "start_date" => @$start_date, "end_date" => @$end_date, "report_type" => @$HTTP_POST_VARS["report_type"]));
if (!empty($HTTP_POST_VARS["developer"])) {
    //split date up
    if (@$HTTP_POST_VARS["report_type"] == "weekly") {
        $dates = explode("_", $HTTP_POST_VARS["week"]);
    } else {
        $dates = array($start_date, $end_date);
    }
    // print out emails
    $data = Report::getWeeklyReport($HTTP_POST_VARS["developer"], $dates[0], $dates[1], @$_REQUEST['separate_closed']);
    $tpl->assign("data", $data);
}
if (empty($HTTP_POST_VARS["week"])) {
    $tpl->assign("week", Date_API::getCurrentWeek());
} else {
    $tpl->assign("week", $HTTP_POST_VARS["week"]);
}
if (empty($HTTP_POST_VARS["developer"])) {
    $tpl->assign("developer", Auth::getUserID());
} else {
    $tpl->assign("developer", $HTTP_POST_VARS["developer"]);
}
$tpl->displayTemplate();
示例#24
0
 /**
  * Converts a note to a draft or an email
  *
  * @access  public
  * @param   $note_id The id of the note
  * @param   $target What the not should be converted too
  * @param   $authorize_sender If the sender should be added to authorized senders list.
  */
 function convertNote($note_id, $target, $authorize_sender = false)
 {
     $note_id = Misc::escapeInteger($note_id);
     $issue_id = Note::getIssueID($note_id);
     $email_account_id = Email_Account::getEmailAccount();
     $blocked_message = Note::getBlockedMessage($note_id);
     $unknown_user = Note::getUnknownUser($note_id);
     $structure = Mime_Helper::decode($blocked_message, true, true);
     $body = Mime_Helper::getMessageBody($structure);
     $sender_email = strtolower(Mail_API::getEmailAddress($structure->headers['from']));
     if ($target == 'email') {
         if (Mime_Helper::hasAttachments($blocked_message)) {
             $has_attachments = 1;
         } else {
             $has_attachments = 0;
         }
         list($blocked_message, $headers) = Mail_API::rewriteThreadingHeaders($issue_id, $blocked_message, @$structure->headers);
         $t = array('issue_id' => $issue_id, 'ema_id' => $email_account_id, 'message_id' => @$structure->headers['message-id'], 'date' => Date_API::getCurrentDateGMT(), 'from' => @$structure->headers['from'], 'to' => @$structure->headers['to'], 'cc' => @$structure->headers['cc'], 'subject' => @$structure->headers['subject'], 'body' => @$body, 'full_email' => @$blocked_message, 'has_attachment' => $has_attachments, 'headers' => $headers);
         // need to check for a possible customer association
         if (!empty($structure->headers['from'])) {
             $details = Email_Account::getDetails($email_account_id);
             // check from the associated project if we need to lookup any customers by this email address
             if (Customer::hasCustomerIntegration($details['ema_prj_id'])) {
                 // check for any customer contact association
                 list($customer_id, ) = Customer::getCustomerIDByEmails($details['ema_prj_id'], array($sender_email));
                 if (!empty($customer_id)) {
                     $t['customer_id'] = $customer_id;
                 }
             }
         }
         if (empty($t['customer_id'])) {
             $update_type = 'staff response';
             $t['customer_id'] = "NULL";
         } else {
             $update_type = 'customer action';
         }
         $res = Support::insertEmail($t, $structure, $sup_id);
         if ($res != -1) {
             Support::extractAttachments($issue_id, $blocked_message);
             // notifications about new emails are always external
             $internal_only = false;
             // special case when emails are bounced back, so we don't want to notify the customer about those
             if (Notification::isBounceMessage($sender_email)) {
                 $internal_only = true;
             }
             Notification::notifyNewEmail(Auth::getUserID(), $issue_id, $t, $internal_only, false, '', $sup_id);
             Issue::markAsUpdated($issue_id, $update_type);
             Note::remove($note_id, false);
             History::add($issue_id, Auth::getUserID(), History::getTypeID('note_converted_email'), "Note converted to e-mail (from: " . @$structure->headers['from'] . ") by " . User::getFullName(Auth::getUserID()));
             // now add sender as an authorized replier
             if ($authorize_sender) {
                 Authorized_Replier::manualInsert($issue_id, @$structure->headers['from']);
             }
         }
         return $res;
     } else {
         // save message as a draft
         $res = Draft::saveEmail($issue_id, $structure->headers['to'], $structure->headers['cc'], $structure->headers['subject'], $body, false, $unknown_user);
         // remove the note, if the draft was created successfully
         if ($res) {
             Note::remove($note_id, false);
             History::add($issue_id, Auth::getUserID(), History::getTypeID('note_converted_draft'), "Note converted to draft (from: " . @$structure->headers['from'] . ") by " . User::getFullName(Auth::getUserID()));
         }
         return $res;
     }
 }
示例#25
0
// |                                                                      |
// | You should have received a copy of the GNU General Public License    |
// | along with this program; if not, write to:                           |
// |                                                                      |
// | Free Software Foundation, Inc.                                       |
// | 59 Temple Place - Suite 330                                          |
// | Boston, MA 02111-1307, USA.                                          |
// +----------------------------------------------------------------------+
// | Authors: João Prado Maia <*****@*****.**>                             |
// +----------------------------------------------------------------------+
//
// @(#) $Id: s.news.php 1.1 04/01/13 20:02:51-00:00 jpradomaia $
//
include_once "config.inc.php";
include_once APP_INC_PATH . "class.template.php";
include_once APP_INC_PATH . "class.auth.php";
include_once APP_INC_PATH . "class.news.php";
include_once APP_INC_PATH . "class.date.php";
include_once APP_INC_PATH . "db_access.php";
$tpl = new Template_API();
$tpl->setTemplate('news.tpl.html');
Auth::checkAuthentication(APP_COOKIE, 'index.php?err=5', true);
$prj_id = Auth::getCurrentProject();
if (!empty($HTTP_GET_VARS["id"])) {
    $t = News::getDetails($HTTP_GET_VARS['id']);
    $t['nws_created_date'] = Date_API::getFormattedDate($t["nws_created_date"]);
    $tpl->assign("news", array($t));
} else {
    $tpl->assign("news", News::getListByProject($prj_id, TRUE));
}
$tpl->displayTemplate();
示例#26
0
 /**
  * Method used to get the list of changes made against a specific issue.
  *
  * @access  public
  * @param   integer $iss_id The issue ID
  * @param   string $order_by The order to sort the history
  * @return  array The list of changes
  */
 function getListing($iss_id, $order_by = 'DESC')
 {
     $stmt = "SELECT\n                    *\n                 FROM\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_history,\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "history_type\n                 WHERE\n                    htt_id = his_htt_id AND\n                    his_is_hidden != 1 AND\n                    his_iss_id=" . Misc::escapeInteger($iss_id) . " AND\n                    htt_role <= " . Auth::getCurrentRole() . "\n                 ORDER BY\n                    his_id {$order_by}";
     $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 {
         for ($i = 0; $i < count($res); $i++) {
             $res[$i]["his_created_date"] = Date_API::getFormattedDate($res[$i]["his_created_date"]);
             $res[$i]["his_summary"] = Mime_Helper::fixEncoding($res[$i]["his_summary"]);
         }
         return $res;
     }
 }
示例#27
0
 /**
  * Method used to add a new project to the system.
  *
  * @access  public
  * @return  integer 1 if the update worked, -1 or -2 otherwise
  */
 function insert()
 {
     global $HTTP_POST_VARS;
     if (Validation::isWhitespace($HTTP_POST_VARS["title"])) {
         return -2;
     }
     $stmt = "INSERT INTO\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project\n                 (\n                    prj_created_date,\n                    prj_title,\n                    prj_status,\n                    prj_lead_usr_id,\n                    prj_initial_sta_id,\n                    prj_outgoing_sender_name,\n                    prj_outgoing_sender_email,\n                    prj_remote_invocation,\n                    prj_customer_backend,\n                    prj_workflow_backend\n                 ) VALUES (\n                    '" . Date_API::getCurrentDateGMT() . "',\n                    '" . Misc::escapeString($HTTP_POST_VARS["title"]) . "',\n                    '" . Misc::escapeString($HTTP_POST_VARS["status"]) . "',\n                    " . Misc::escapeInteger($HTTP_POST_VARS["lead_usr_id"]) . ",\n                    " . Misc::escapeInteger($HTTP_POST_VARS["initial_status"]) . ",\n                    '" . Misc::escapeString($HTTP_POST_VARS["outgoing_sender_name"]) . "',\n                    '" . Misc::escapeString($HTTP_POST_VARS["outgoing_sender_email"]) . "',\n                    '" . Misc::escapeString($HTTP_POST_VARS["remote_invocation"]) . "',\n                    '" . Misc::escapeString($HTTP_POST_VARS["customer_backend"]) . "',\n                    '" . Misc::escapeString($HTTP_POST_VARS["workflow_backend"]) . "'\n                 )";
     $res = $GLOBALS["db_api"]->dbh->query($stmt);
     if (PEAR::isError($res)) {
         Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
         return -1;
     } else {
         $new_prj_id = $GLOBALS["db_api"]->get_last_insert_id();
         for ($i = 0; $i < count($HTTP_POST_VARS["users"]); $i++) {
             if ($HTTP_POST_VARS["users"][$i] == $HTTP_POST_VARS["lead_usr_id"]) {
                 $role_id = User::getRoleID("Manager");
             } else {
                 $role_id = User::getRoleID("Standard User");
             }
             Project::associateUser($new_prj_id, $HTTP_POST_VARS["users"][$i], $role_id);
         }
         foreach ($HTTP_POST_VARS['statuses'] as $sta_id) {
             Status::addProjectAssociation($sta_id, $new_prj_id);
         }
         Display_Column::setupNewProject($new_prj_id);
         return 1;
     }
 }
 /**
  * Method used to update the details of a specific reminder condition.
  *
  * @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_condition\n                 SET\n                    rlc_last_updated_date='" . Date_API::getCurrentDateGMT() . "',\n                    rlc_rmf_id=" . Misc::escapeInteger($HTTP_POST_VARS['field']) . ",\n                    rlc_rmo_id=" . Misc::escapeInteger($HTTP_POST_VARS['operator']) . ",\n                    rlc_value='" . Misc::escapeString(@$HTTP_POST_VARS['value']) . "',\n                    rlc_comparison_rmf_id = '" . Misc::escapeInteger(@$HTTP_POST_VARS['comparison_field']) . "'\n                 WHERE\n                    rlc_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 {
         return 1;
     }
 }
示例#29
0
 /**
  * Method used to get the details of a FAQ entry for a given FAQ ID.
  *
  * @access  public
  * @param   integer $faq_id The FAQ entry ID
  * @return  array The FAQ entry details
  */
 function getDetails($faq_id)
 {
     $stmt = "SELECT\n                    *\n                 FROM\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "faq\n                 WHERE\n                    faq_id=" . Misc::escapeInteger($faq_id);
     $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 "";
     } else {
         if (Customer::doesBackendUseSupportLevels($res['faq_prj_id'])) {
             // get all of the support level associations here as well
             $res['support_levels'] = array_keys(FAQ::getAssociatedSupportLevels($res['faq_prj_id'], $res['faq_id']));
         }
         if (empty($res['faq_updated_date'])) {
             $res['faq_updated_date'] = $res['faq_created_date'];
         }
         $res['faq_updated_date'] = Date_API::getFormattedDate($res['faq_updated_date']);
         $res['message'] = Misc::activateLinks(nl2br(htmlspecialchars($res['faq_message'])));
         return $res;
     }
 }
示例#30
0
 /**
  * Method used to list the history of triggered reminder actions
  * for a given issue.
  *
  * @access  public
  * @param   integer $iss_id The issue ID
  * @return  array The list of triggered reminder actions
  */
 function getHistoryList($iss_id)
 {
     $stmt = "SELECT\n                    rmh_created_date,\n                    rma_title\n                 FROM\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_history,\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_action\n                 WHERE\n                    rmh_iss_id=" . Misc::escapeInteger($iss_id) . " AND\n                    rmh_rma_id=rma_id\n                 ORDER BY\n                    rmh_created_date DESC";
     $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 {
         for ($i = 0; $i < count($res); $i++) {
             $res[$i]["rmh_created_date"] = Date_API::getFormattedDate($res[$i]["rmh_created_date"]);
         }
         return $res;
     }
 }