Exemplo n.º 1
0
 /**
  * Obtener los datos para la ficha de campo personalizado
  */
 public function getCustomField()
 {
     $this->view->addTemplate('customfields');
     $customField = \SP\CustomFieldDef::getCustomFields($this->view->itemId, true);
     $field = unserialize($customField->customfielddef_field);
     $this->view->assign('gotData', $customField && $field instanceof CustomFieldDef);
     $this->view->assign('customField', $customField);
     $this->view->assign('field', $field);
     $this->view->assign('types', \SP\CustomFieldDef::getFieldsTypes());
     $this->view->assign('modules', \SP\CustomFieldDef::getFieldsModules());
 }
Exemplo n.º 2
0
        }
        $CustomFieldDef = new \SP\CustomFieldDef($frmFieldName, $frmFieldType, $frmFieldModule);
        $CustomFieldDef->setHelp($frmFieldHelp);
        $CustomFieldDef->setRequired($frmFieldRequired);
        if ($actionId === \SP\Controller\ActionsInterface::ACTION_MGM_CUSTOMFIELDS_NEW) {
            try {
                $CustomFieldDef->addCustomField();
            } catch (\SP\SPException $e) {
                SP\Response::printJSON($e->getMessage(), 2);
            }
            SP\Response::printJSON(_('Campo creado'), 0, $doActionOnClose);
        } elseif ($actionId === \SP\Controller\ActionsInterface::ACTION_MGM_CUSTOMFIELDS_EDIT) {
            try {
                $CustomFieldDef->setId($itemId);
                $CustomFieldDef->updateCustomField();
            } catch (\SP\SPException $e) {
                SP\Response::printJSON($e->getMessage(), 2);
            }
            SP\Response::printJSON(_('Campo actualizado'), 0, $doActionOnClose);
        }
    } elseif ($actionId === \SP\Controller\ActionsInterface::ACTION_MGM_CUSTOMFIELDS_DELETE) {
        try {
            \SP\CustomFieldDef::deleteCustomField($itemId);
        } catch (\SP\SPException $e) {
            SP\Response::printJSON($e->getMessage(), 2);
        }
        SP\Response::printJSON(_('Campo eliminado'), 0, $doActionOnClose);
    }
} else {
    SP\Response::printJSON(_('Acción Inválida'));
}