Exemplo n.º 1
0
 /**
  * Method used to get the list of FAQ entries available in the system.
  *
  * @access  public
  * @return  array The list of news entries
  */
 function getList()
 {
     $stmt = "SELECT\n                    faq_id,\n                    faq_prj_id,\n                    faq_title,\n                    faq_rank\n                 FROM\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "faq\n                 ORDER BY\n                    faq_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 "";
     } else {
         // get the list of associated support levels
         for ($i = 0; $i < count($res); $i++) {
             if (Customer::doesBackendUseSupportLevels($res[$i]['faq_prj_id'])) {
                 $res[$i]['support_levels'] = implode(", ", array_values(FAQ::getAssociatedSupportLevels($res[$i]['faq_prj_id'], $res[$i]['faq_id'])));
             }
         }
         return $res;
     }
 }
Exemplo n.º 2
0
        $tpl->assign("result", FAQ::update());
    } elseif (@$HTTP_POST_VARS["cat"] == "delete") {
        FAQ::remove();
    } elseif (!empty($HTTP_GET_VARS['prj_id'])) {
        $tpl->assign("info", array('faq_prj_id' => $HTTP_GET_VARS['prj_id']));
        $backend_uses_support_levels = Customer::doesBackendUseSupportLevels($HTTP_GET_VARS['prj_id']);
        $tpl->assign("backend_uses_support_levels", $backend_uses_support_levels);
        if ($backend_uses_support_levels) {
            $tpl->assign("support_levels", Customer::getSupportLevelAssocList($HTTP_GET_VARS['prj_id']));
        }
    }
    if (@$HTTP_GET_VARS["cat"] == "edit") {
        $info = FAQ::getDetails($HTTP_GET_VARS["id"]);
        if (!empty($HTTP_GET_VARS['prj_id'])) {
            $info['faq_prj_id'] = $HTTP_GET_VARS['prj_id'];
        }
        $backend_uses_support_levels = Customer::doesBackendUseSupportLevels($info['faq_prj_id']);
        $tpl->assign("backend_uses_support_levels", $backend_uses_support_levels);
        if ($backend_uses_support_levels) {
            $tpl->assign("support_levels", Customer::getSupportLevelAssocList($info['faq_prj_id']));
        }
        $tpl->assign("info", $info);
    } elseif (@$HTTP_GET_VARS["cat"] == "change_rank") {
        FAQ::changeRank($HTTP_GET_VARS['id'], $HTTP_GET_VARS['rank']);
    }
    $tpl->assign("list", FAQ::getList());
    $tpl->assign("project_list", Project::getAll());
} else {
    $tpl->assign("show_not_allowed_msg", true);
}
$tpl->displayTemplate();
Exemplo n.º 3
0
include_once "config.inc.php";
include_once APP_INC_PATH . "db_access.php";
include_once APP_INC_PATH . "class.template.php";
include_once APP_INC_PATH . "class.auth.php";
include_once APP_INC_PATH . "class.faq.php";
include_once APP_INC_PATH . "class.customer.php";
$tpl = new Template_API();
$tpl->setTemplate("faq.tpl.html");
Auth::checkAuthentication(APP_COOKIE, 'index.php?err=5', true);
$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']);
Exemplo n.º 4
0
        $priorities = array_flip(Priority::getAssocList($info['rem_prj_id']));
        unset($priorities['Not Prioritized']);
        $tpl->assign("priorities", array_flip($priorities));
    } elseif (@$HTTP_GET_VARS["cat"] == "change_rank") {
        Reminder::changeRank($HTTP_GET_VARS['id'], $HTTP_GET_VARS['rank']);
    } elseif (!empty($HTTP_GET_VARS['prj_id'])) {
        $tpl->assign("info", array('rem_prj_id' => $HTTP_GET_VARS['prj_id']));
        $tpl->assign('issues', Reminder::getIssueAssocListByProject($HTTP_GET_VARS['prj_id']));
        // wouldn't make much sense to create a reminder for a 'Not Prioritized'
        // issue, so let's remove that as an option
        $priorities = array_flip(Priority::getAssocList($HTTP_GET_VARS['prj_id']));
        unset($priorities['Not Prioritized']);
        $tpl->assign("priorities", array_flip($priorities));
        // only show customers and support levels if the selected project really needs it
        $project_has_customer_integration = Customer::hasCustomerIntegration($HTTP_GET_VARS['prj_id']);
        $tpl->assign("project_has_customer_integration", $project_has_customer_integration);
        if ($project_has_customer_integration) {
            $tpl->assign("customers", Customer::getAssocList($HTTP_GET_VARS['prj_id']));
            $backend_uses_support_levels = Customer::doesBackendUseSupportLevels($HTTP_GET_VARS['prj_id']);
            if ($backend_uses_support_levels) {
                $tpl->assign("support_levels", Customer::getSupportLevelAssocList($HTTP_GET_VARS['prj_id']));
            }
            $tpl->assign("backend_uses_support_levels", $backend_uses_support_levels);
        }
    }
    $tpl->assign("project_list", Project::getAll());
    $tpl->assign("list", Reminder::getAdminList());
} else {
    $tpl->assign("show_not_allowed_msg", true);
}
$tpl->displayTemplate();
Exemplo n.º 5
0
 /**
  * Method used to generate a where clause from the given list of conditions.
  *
  * @access  public
  * @param   array $reminder An array of reminder info.
  * @param   array $conditions The list of conditions
  * @return  string The where clause
  */
 function getWhereClause($reminder, $conditions)
 {
     $stmt = '
               WHERE
                 iss_prj_id=' . $reminder['rem_prj_id'] . "\n";
     $requirement = Reminder::getRequirements($reminder['rem_id']);
     if ($requirement['type'] == 'issue') {
         $stmt .= ' AND iss_id IN (' . implode(', ', $requirement['values']) . ")\n";
     } else {
         if (Customer::hasCustomerIntegration($reminder['rem_prj_id'])) {
             if ($requirement['type'] == 'customer') {
                 $stmt .= ' AND iss_customer_id IN (' . implode(', ', $requirement['values']) . ")\n";
             } elseif ($requirement['type'] == 'support_level') {
                 if (Customer::doesBackendUseSupportLevels($reminder['rem_prj_id'])) {
                     $customer_ids = Customer::getListBySupportLevel($reminder['rem_prj_id'], $requirement['values'], CUSTOMER_EXCLUDE_EXPIRED);
                     // break the query on purpose if no customers could be found
                     if (count($customer_ids) == 0) {
                         $customer_ids = array(-1);
                     }
                     $stmt .= ' AND iss_customer_id IN (' . implode(', ', $customer_ids) . ")\n";
                 }
             }
         }
     }
     $priorities = Reminder::getAssociatedPriorities($reminder['rem_id']);
     if (count($priorities) > 0) {
         $stmt .= ' AND iss_pri_id IN (' . implode(', ', $priorities) . ")\n";
     }
     // now for the interesting stuff
     for ($i = 0; $i < count($conditions); $i++) {
         // check for fields that compare to other fields
         if (!empty($conditions[$i]['rlc_comparison_rmf_id'])) {
             $sql_field = Reminder_Condition::getSQLField($conditions[$i]['rlc_comparison_rmf_id']);
             $stmt .= sprintf(" AND %s %s %s\n", $conditions[$i]['rmf_sql_field'], $conditions[$i]['rmo_sql_representation'], $sql_field);
         } else {
             // date field values are always saved as number of hours, so let's calculate them now as seconds
             if (stristr($conditions[$i]['rmf_title'], 'date')) {
                 // support NULL as values for a date field
                 if (strtoupper($conditions[$i]['rlc_value']) == 'NULL') {
                     $conditions[$i]['rmf_sql_representation'] = $conditions[$i]['rmf_sql_field'];
                 } else {
                     $conditions[$i]['rlc_value'] = $conditions[$i]['rlc_value'] * 60 * 60;
                     if (@$reminder["rem_skip_weekend"] == 1) {
                         $sql_field = Reminder_Condition::getSQLField($conditions[$i]['rlc_rmf_id']);
                         $conditions[$i]['rmf_sql_representation'] = DB_API::getNoWeekendDateDiffSQL($sql_field);
                     }
                 }
             }
             $stmt .= sprintf(" AND %s %s %s\n", $conditions[$i]['rmf_sql_representation'], $conditions[$i]['rmo_sql_representation'], $conditions[$i]['rlc_value']);
         }
     }
     return $stmt;
 }
Exemplo n.º 6
0
}
if (count(@$HTTP_POST_VARS["display_sections"]) < 1) {
    $HTTP_POST_VARS["display_sections"] = array_keys(Customer_Stats_Report::getDisplaySections());
    unset($HTTP_POST_VARS["display_sections"][4]);
}
$support_levels = array('Aggregate' => 'Aggregate');
$grouped_levels = Customer::getGroupedSupportLevels($prj_id);
foreach ($grouped_levels as $level_name => $level_ids) {
    $support_levels[$level_name] = $level_name;
}
if (count(@$HTTP_POST_VARS["support_level"]) < 1) {
    $HTTP_POST_VARS["support_level"] = array('Aggregate');
}
// XXX: internal only - Remove all mentions of InnoDB
$prj_id = Auth::getCurrentProject();
$tpl->assign(array("has_support_levels" => Customer::doesBackendUseSupportLevels($prj_id), "project_name" => Auth::getCurrentProjectName(), "support_levels" => $support_levels, "support_level" => @$HTTP_POST_VARS["support_level"], "start_date" => $start_date, "end_date" => $end_date, "sections" => Customer_Stats_Report::getDisplaySections(), "display_sections" => $HTTP_POST_VARS["display_sections"], "split_innoDB" => @$HTTP_POST_VARS["split_innoDB"], "include_expired" => @$HTTP_POST_VARS["include_expired"], "graphs" => Customer_Stats_Report::getGraphTypes()));
// only set customers if user has role of manager or above
if (Auth::getCurrentRole() >= User::getRoleID('manager')) {
    $tpl->assign(array("customers" => Customer::getAssocList($prj_id), "customer" => @$HTTP_POST_VARS["customer"]));
}
// loop through display sections
$display = array();
foreach ($HTTP_POST_VARS["display_sections"] as $section) {
    $display[$section] = 1;
}
$tpl->assign("display", $display);
if (@$HTTP_POST_VARS["cat"] == "Generate") {
    if ($start_date == "0000-00-00") {
        $start_date = '';
    }
    if ($end_date == "0000-00-00") {