コード例 #1
0
 /**
  * Returns the columns that should be displayed for the specified page.
  * This method will remove columns that should not be displayed, due to
  * lack of customer integration or insufficient role.
  *
  * @access  public
  * @param   integer $prj_id The ID of the project.
  * @param   string $page The page to return columns for.
  * @return  array An array of columns that should be displayed.
  */
 function getColumnsToDisplay($prj_id, $page)
 {
     static $returns;
     // poor man's caching system
     if (!empty($returns[$prj_id][$page])) {
         return $returns[$prj_id][$page];
     }
     $current_role = Auth::getCurrentRole();
     $data = Display_Column::getSelectedColumns($prj_id, $page);
     $has_customer_integration = Customer::hasCustomerIntegration($prj_id);
     $only_with_customers = array('iss_customer_id');
     // remove groups if there are no groups in the system.
     if (count(Group::getAssocList($prj_id)) < 1) {
         unset($data['iss_grp_id']);
     }
     // remove category column if there are no categories in the system
     if (count(Category::getAssocList($prj_id)) < 1) {
         unset($data['prc_title']);
     }
     // remove custom fields column if there are no custom fields
     if (count(Custom_Field::getFieldsToBeListed($prj_id)) < 1) {
         unset($data['custom_fields']);
     }
     // remove customer field if user has a role of customer
     if ($current_role == User::getRoleID("Customer")) {
         unset($data['iss_customer_id']);
     }
     foreach ($data as $field => $info) {
         // remove fields based on role
         if ($info['min_role'] > $current_role) {
             unset($data[$field]);
             continue;
         }
         // remove fields based on customer integration
         if (!$has_customer_integration && in_array($field, $only_with_customers)) {
             unset($data[$field]);
             continue;
         }
         // get title
         $data[$field] = Display_Column::getColumnInfo($page, $field);
     }
     $returns[$prj_id][$page] = $data;
     return $data;
 }
コード例 #2
0
$prj_id = $_REQUEST['prj_id'];
$tpl = new Template_API();
$tpl->setTemplate("manage/index.tpl.html");
Auth::checkAuthentication(APP_COOKIE);
$tpl->assign("type", "column_display");
$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"] == "save") {
        $tpl->assign("result", Display_Column::save());
    }
    $page = 'list_issues';
    $available = Display_Column::getAllColumns($page);
    $selected = Display_Column::getSelectedColumns($prj_id, $page);
    // re-order available array to match rank
    $available_ordered = array();
    foreach ($selected as $field_name => $field_info) {
        $available_ordered[$field_name] = $available[$field_name];
        unset($available[$field_name]);
    }
    if (count($available) > 0) {
        $available_ordered += $available;
    }
    $excluded_roles = array();
    if (!Customer::hasCustomerIntegration($prj_id)) {
        $excluded_roles[] = "customer";
    }
    $user_roles = User::getRoles($excluded_roles);
    $user_roles[9] = "Never Display";