testlinkInitPage($db, false, false, "checkRights");
$templateCfg = templateConfiguration();
$args = init_args();
$cfield_mgr = new cfield_mgr($db);
switch ($args->doAction) {
    case 'doAssign':
        $cfield_ids = array_keys($args->cfield);
        $cfield_mgr->link_to_testproject($args->testproject_id, $cfield_ids);
        break;
    case 'doUnassign':
        $cfield_ids = array_keys($args->cfield);
        $cfield_mgr->unlink_from_testproject($args->testproject_id, $cfield_ids);
        break;
    case 'doReorder':
        $cfield_ids = array_keys($args->display_order);
        $cfield_mgr->set_display_order($args->testproject_id, $args->display_order);
        if (!is_null($args->location)) {
            $cfield_mgr->setDisplayLocation($args->testproject_id, $args->location);
        }
        break;
    case 'doActiveMgmt':
        $my_cf = array_keys($args->hidden_active_cfield);
        if (!isset($args->active_cfield)) {
            $cfield_mgr->set_active_for_testproject($args->testproject_id, $my_cf, 0);
        } else {
            $active = null;
            $inactive = null;
            foreach ($my_cf as $cf_id) {
                if (isset($args->active_cfield[$cf_id])) {
                    $active[] = $cf_id;
                } else {