Пример #1
0
Auth::checkAuthentication(APP_COOKIE);
$tpl->assign("type", "custom_fields");
$role_id = Auth::getCurrentRole();
if ($role_id == User::getRoleID('administrator')) {
    $tpl->assign("show_setup_links", true);
    if (@$HTTP_POST_VARS["cat"] == "new") {
        $tpl->assign("result", Custom_Field::insert());
    } elseif (@$HTTP_POST_VARS["cat"] == "update") {
        $tpl->assign("result", Custom_Field::update());
    } elseif (@$HTTP_POST_VARS["cat"] == "delete") {
        Custom_Field::remove();
    } elseif (@$_REQUEST["cat"] == "change_rank") {
        Custom_Field::changeRank();
    }
    if (@$HTTP_GET_VARS["cat"] == "edit") {
        $tpl->assign("info", Custom_Field::getDetails($HTTP_GET_VARS["id"]));
    }
    $excluded_roles = array();
    if (!Customer::hasCustomerIntegration(Auth::getCurrentProject())) {
        $excluded_roles[] = "customer";
    }
    $user_roles = User::getRoles($excluded_roles);
    $user_roles[9] = "Never Display";
    $tpl->assign("list", Custom_Field::getList());
    $tpl->assign("project_list", Project::getAll());
    $tpl->assign("user_roles", $user_roles);
    $tpl->assign("backend_list", Custom_Field::getBackendList());
} else {
    $tpl->assign("show_not_allowed_msg", true);
}
$tpl->displayTemplate();
Пример #2
0
 /**
  * Changes the rank of a custom field
  *
  * @access  public
  */
 function changeRank()
 {
     $fld_id = $_REQUEST['id'];
     $direction = $_REQUEST['direction'];
     // get array of all fields and current ranks
     $fields = Custom_Field::getList();
     for ($i = 0; $i < count($fields); $i++) {
         if ($fields[$i]['fld_id'] == $fld_id) {
             // this is the field we want to mess with
             if ($i == 0 && $direction == -1 || $i + 1 == count($fields) && $direction == +1) {
                 // trying to move first entry lower or last entry higher will not work
                 break;
             }
             $target_index = $i + $direction;
             $target_row = $fields[$target_index];
             if (empty($target_row)) {
                 break;
             }
             // update this entry
             Custom_Field::setRank($fld_id, $target_row['fld_rank']);
             // update field we stole this rank from
             Custom_Field::setRank($target_row['fld_id'], $fields[$i]['fld_rank']);
         }
     }
     // re-order everything starting from 1
     $fields = Custom_Field::getList();
     $rank = 1;
     foreach ($fields as $field) {
         Custom_Field::setRank($field['fld_id'], $rank++);
     }
     return 1;
 }
Пример #3
0
    Misc::setMessage(ev_gettext('Sorry, you are not allowed to access this page.'), Misc::MSG_ERROR);
    $tpl->displayTemplate();
    exit;
}
$tpl->assign('project_list', Project::getAll());
if (@$_POST['cat'] == 'new') {
    $res = Custom_Field::insert();
    Misc::mapMessages($res, array(1 => array(ev_gettext('Thank you, the custom field was added successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to add the new custom field.'), Misc::MSG_ERROR)));
} elseif (@$_POST['cat'] == 'update') {
    $res = Custom_Field::update();
    Misc::mapMessages($res, array(1 => array(ev_gettext('Thank you, the custom field was updated successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to update the custom field information.'), Misc::MSG_ERROR)));
} elseif (@$_POST['cat'] == 'delete') {
    $res = Custom_Field::remove();
    Misc::mapMessages($res, array(true => array(ev_gettext('Thank you, the custom field was removed successfully.'), Misc::MSG_INFO), false => array(ev_gettext('An error occurred while trying to remove the custom field information.'), Misc::MSG_ERROR)));
} elseif (@$_REQUEST['cat'] == 'change_rank') {
    Custom_Field::changeRank();
}
if (@$_GET['cat'] == 'edit') {
    $tpl->assign('info', Custom_Field::getDetails($_GET['id']));
}
$excluded_roles = array();
if (!CRM::hasCustomerIntegration(Auth::getCurrentProject())) {
    $excluded_roles[] = 'customer';
}
$user_roles = User::getRoles($excluded_roles);
$user_roles[9] = 'Never Display';
$tpl->assign('list', Custom_Field::getList());
$tpl->assign('project_list', Project::getAll());
$tpl->assign('user_roles', $user_roles);
$tpl->assign('backend_list', Custom_Field::getBackendList());
$tpl->displayTemplate();