本文整理汇总了PHP中CRM_Admin_Form类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Admin_Form类的具体用法?PHP CRM_Admin_Form怎么用?PHP CRM_Admin_Form使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Admin_Form类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildQuickForm
/**
* Build the form object.
*/
public function buildQuickForm()
{
parent::buildQuickForm();
$this->setPageTitle(ts('Contact Type'));
if ($this->_action & CRM_Core_Action::DELETE) {
return;
}
$this->applyFilter('__ALL__', 'trim');
$this->add('text', 'label', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_ContactType', 'label'), TRUE);
$contactType = $this->add('select', 'parent_id', ts('Basic Contact Type'), CRM_Contact_BAO_ContactType::basicTypePairs(FALSE, 'id'));
$enabled = $this->add('checkbox', 'is_active', ts('Enabled?'));
if ($this->_action & CRM_Core_Action::UPDATE) {
$contactType->freeze();
// We'll display actual "name" for built-in types (for reference) when editing their label / image_URL
$contactTypeName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_ContactType', $this->_id, 'name');
$this->assign('contactTypeName', $contactTypeName);
$this->_parentId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_ContactType', $this->_id, 'parent_id');
// Freeze Enabled field for built-in contact types (parent_id is NULL for these)
if (is_null($this->_parentId)) {
$enabled->freeze();
}
}
$this->addElement('text', 'image_URL', ts('Image URL'));
$this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_ContactType', 'description'));
$this->assign('cid', $this->_id);
$this->addFormRule(array('CRM_Admin_Form_ContactType', 'formRule'), $this);
}
示例2: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
parent::buildQuickForm();
if ($this->_action & CRM_Core_Action::DELETE) {
return;
}
$attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_PreferencesDate');
$this->applyFilter('__ALL__', 'trim');
$name =& $this->add('text', 'name', ts('Name'), $attributes['name'], true);
$name->freeze();
$this->add('text', 'description', ts('Description'), $attributes['description'], false);
$this->add('text', 'start', ts('Start Offset'), $attributes['start'], true);
$this->add('text', 'end', ts('End Offset'), $attributes['end'], true);
$formatType = CRM_Core_Dao::getFieldValue('CRM_Core_DAO_PreferencesDate', $this->_id, 'name');
if ($formatType == 'creditCard') {
$this->add('text', 'date_format', ts('Format'), $attributes['date_format'], true);
} else {
$this->add('select', 'date_format', ts('Format'), array('' => ts('- default input format -')) + CRM_Core_SelectValues::getDatePluginInputFormats());
$this->add('select', 'time_format', ts('Time'), array('' => ts('- none -')) + CRM_Core_SelectValues::getTimeFormats());
}
$this->addRule('start', ts('Value should be a positive number'), 'positiveInteger');
$this->addRule('end', ts('Value should be a positive number'), 'positiveInteger');
// add a form rule
$this->addFormRule(array('CRM_Admin_Form_PreferencesDate', 'formRule'));
}
示例3: buildQuickForm
/**
* Build the form object.
*
* @param bool $check
*
* @return void
*/
public function buildQuickForm($check = FALSE)
{
parent::buildQuickForm();
if ($this->_action & CRM_Core_Action::DELETE) {
return;
}
$attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Job');
$this->add('text', 'name', ts('Name'), $attributes['name'], TRUE);
$this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array('CRM_Core_DAO_Job', $this->_id));
$this->add('text', 'description', ts('Description'), $attributes['description']);
$this->add('text', 'api_entity', ts('API Call Entity'), $attributes['api_entity'], TRUE);
$this->add('text', 'api_action', ts('API Call Action'), $attributes['api_action'], TRUE);
$this->add('select', 'run_frequency', ts('Run frequency'), CRM_Core_SelectValues::getJobFrequency());
/************************************
* begin com.klangsoft.flexiblejobs *
************************************/
$this->addDateTime('schedule_at', ts(($this->_id ? 'Next' : 'First') . ' Run Date / Time'), FALSE, array('formatType' => 'activityDateTime'));
$this->assign('schedule_at', $this->_id ? 'run next' : 'first be run');
/**********************************
* end com.klangsoft.flexiblejobs *
**********************************/
$this->add('textarea', 'parameters', ts('Command parameters'), "cols=50 rows=6");
// is this job active ?
$this->add('checkbox', 'is_active', ts('Is this Scheduled Job active?'));
$this->addFormRule(array('CRM_Admin_Form_Job', 'formRule'));
}
示例4: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
parent::buildQuickForm();
if ($this->_action & CRM_Core_Action::DELETE) {
return;
}
if (isset($this->_id)) {
$params = array('id' => $this->_id);
CRM_Core_BAO_Navigation::retrieve($params, $this->_defaults);
}
$this->applyFilter('__ALL__', 'trim');
$this->add('text', 'label', ts('Title'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Navigation', 'label'), true);
$this->add('text', 'url', ts('Url'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Navigation', 'url'));
require_once 'CRM/Core/Permission.php';
$permissions = CRM_Core_Permission::basicPermissions(true);
$include =& $this->addElement('advmultiselect', 'permission', ts('Permission') . ' ', $permissions, array('size' => 5, 'style' => 'width:150px', 'class' => 'advmultiselect'));
$include->setButtonAttributes('add', array('value' => ts('Add >>')));
$include->setButtonAttributes('remove', array('value' => ts('<< Remove')));
$operators = array('AND' => 'AND', 'OR' => 'OR');
$this->add('select', 'permission_operator', ts('Operator'), $operators);
$this->add('checkbox', 'has_separator', ts('Separator?'));
$active = $this->add('checkbox', 'is_active', ts('Enabled?'));
if ($this->_defaults['name'] == 'Home') {
$active->freeze();
} else {
$parentMenu = CRM_Core_BAO_Navigation::getNavigationList();
if (isset($this->_id)) {
unset($parentMenu[$this->_id]);
}
// also unset home.
$homeMenuId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Home', 'id', 'name');
unset($parentMenu[$homeMenuId]);
$parent = $this->add('select', 'parent_id', ts('Parent'), array('' => ts('-- select --')) + $parentMenu);
}
}
示例5: buildQuickForm
/**
* Function to build the form
*
* @return void
* @access public
*/
public function buildQuickForm()
{
parent::buildQuickForm();
if ($this->_action & CRM_Core_Action::DELETE) {
return;
}
CRM_Utils_System::setTitle(ts('Dropdown Options'));
$this->applyFilter('__ALL__', 'trim');
$this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionGroup', 'name'), TRUE);
$this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array('CRM_Core_DAO_OptionGroup', $this->_id));
$this->add('text', 'title', ts('Group Title'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionGroup', 'title'));
$this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionGroup', 'description'));
$element = $this->add('checkbox', 'is_active', ts('Enabled?'));
if ($this->_action & CRM_Core_Action::UPDATE) {
if (in_array($this->_values['name'], array('encounter_medium', 'case_type', 'case_status'))) {
static $caseCount = NULL;
if (!isset($caseCount)) {
$caseCount = CRM_Case_BAO_Case::caseCount(NULL, FALSE);
}
if ($caseCount > 0) {
$element->freeze();
}
}
if (!empty($this->_values['is_reserved'])) {
$this->freeze(array('name', 'is_active'));
}
}
$this->assign('id', $this->_id);
}
示例6: buildQuickForm
/**
* Build the form object.
*/
public function buildQuickForm()
{
parent::buildQuickForm();
if ($this->_action & CRM_Core_Action::DELETE) {
$formatName = CRM_Core_BAO_PdfFormat::getFieldValue('CRM_Core_BAO_PdfFormat', $this->_id, 'name');
$this->assign('formatName', $formatName);
return;
}
$attributes = CRM_Core_DAO::getAttribute('CRM_Core_BAO_PdfFormat');
$this->add('text', 'name', ts('Name'), $attributes['name'], TRUE);
$this->add('text', 'description', ts('Description'), array('size' => CRM_Utils_Type::HUGE));
$this->add('checkbox', 'is_default', ts('Is this PDF Page Format the default?'));
$this->add('select', 'paper_size', ts('Paper Size'), array(0 => ts('- default -')) + CRM_Core_BAO_PaperSize::getList(TRUE), FALSE, array('onChange' => "selectPaper( this.value );"));
$this->add('static', 'paper_dimensions', NULL, ts('Width x Height'));
$this->add('select', 'orientation', ts('Orientation'), CRM_Core_BAO_PdfFormat::getPageOrientations(), FALSE, array('onChange' => "updatePaperDimensions();"));
$this->add('select', 'metric', ts('Unit of Measure'), CRM_Core_BAO_PdfFormat::getUnits(), FALSE, array('onChange' => "selectMetric( this.value );"));
$this->add('text', 'margin_left', ts('Left Margin'), array('size' => 8, 'maxlength' => 8), TRUE);
$this->add('text', 'margin_right', ts('Right Margin'), array('size' => 8, 'maxlength' => 8), TRUE);
$this->add('text', 'margin_top', ts('Top Margin'), array('size' => 8, 'maxlength' => 8), TRUE);
$this->add('text', 'margin_bottom', ts('Bottom Margin'), array('size' => 8, 'maxlength' => 8), TRUE);
$this->add('text', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Core_BAO_PdfFormat', 'weight'), TRUE);
$this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array('CRM_Core_BAO_PdfFormat', $this->_id));
$this->addRule('margin_left', ts('Margin must be numeric'), 'numeric');
$this->addRule('margin_right', ts('Margin must be numeric'), 'numeric');
$this->addRule('margin_top', ts('Margin must be numeric'), 'numeric');
$this->addRule('margin_bottom', ts('Margin must be numeric'), 'numeric');
$this->addRule('weight', ts('Weight must be integer'), 'integer');
}
示例7: buildQuickForm
/**
* Build the form object.
*/
public function buildQuickForm()
{
parent::buildQuickForm();
$this->setPageTitle(ts('Location Type'));
if ($this->_action & CRM_Core_Action::DELETE) {
return;
}
$this->applyFilter('__ALL__', 'trim');
$this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_LocationType', 'name'), TRUE);
$this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array('CRM_Core_DAO_LocationType', $this->_id));
$this->addRule('name', ts('Name can only consist of alpha-numeric characters'), 'variable');
$this->add('text', 'display_name', ts('Display Name'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_LocationType', 'display_name'), TRUE);
$this->add('text', 'vcard_name', ts('vCard Name'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_LocationType', 'vcard_name'));
$this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_LocationType', 'description'));
$this->add('checkbox', 'is_active', ts('Enabled?'));
$this->add('checkbox', 'is_default', ts('Default?'));
if ($this->_action & CRM_Core_Action::UPDATE) {
if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_LocationType', $this->_id, 'is_reserved')) {
$this->freeze(array('name', 'description', 'is_active'));
}
if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_LocationType', $this->_id, 'is_default')) {
$this->freeze(array('is_default'));
}
}
}
示例8: preProcess
/**
* For pre-processing
*
* @return void
*/
public function preProcess()
{
parent::preProcess();
$this->_key = CRM_Utils_Request::retrieve('key', 'String', $this, FALSE, 0);
$session = CRM_Core_Session::singleton();
$url = CRM_Utils_System::url('civicrm/admin/extensions', 'reset=1&action=browse');
$session->pushUserContext($url);
$this->assign('id', $this->_id);
$this->assign('key', $this->_key);
switch ($this->_action) {
case CRM_Core_Action::ADD:
case CRM_Core_Action::DELETE:
case CRM_Core_Action::ENABLE:
case CRM_Core_Action::DISABLE:
$info = CRM_Extension_System::singleton()->getMapper()->keyToInfo($this->_key);
$extInfo = CRM_Admin_Page_Extensions::createExtendedInfo($info);
$this->assign('extension', $extInfo);
break;
case CRM_Core_Action::UPDATE:
if (!CRM_Extension_System::singleton()->getBrowser()->isEnabled()) {
CRM_Core_Error::fatal(ts('The system administrator has disabled this feature.'));
}
$info = CRM_Extension_System::singleton()->getBrowser()->getExtension($this->_key);
$extInfo = CRM_Admin_Page_Extensions::createExtendedInfo($info);
$this->assign('extension', $extInfo);
break;
default:
CRM_Core_Error::fatal(ts('Unsupported action'));
}
}
示例9: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
parent::buildQuickForm();
if ($this->_action & CRM_Core_Action::DELETE) {
return;
}
$this->applyFilter('__ALL__', 'trim');
$this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionGroup', 'name'), true);
$this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array('CRM_Core_DAO_OptionGroup', $this->_id));
$this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionGroup', 'description'));
$element = $this->add('checkbox', 'is_active', ts('Enabled?'));
if ($this->_action & CRM_Core_Action::UPDATE) {
if (in_array($this->_values['name'], array('encounter_medium', 'case_type', 'case_status'))) {
static $caseCount = null;
require_once 'CRM/Case/BAO/Case.php';
if (!isset($caseCount)) {
$caseCount = CRM_Case_BAO_Case::caseCount(null, false);
}
if ($caseCount > 0) {
$element->freeze();
}
}
if ($this->_values['is_reserved']) {
$this->freeze(array('name', 'description', 'is_active'));
}
}
$this->assign('id', $this->_id);
}
示例10: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
parent::buildQuickForm();
if ($this->_action & CRM_Core_Action::DELETE) {
return;
}
$this->applyFilter('__ALL__', 'trim');
//get the attributes.
$attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_MailSettings');
//build setting form
$this->add('text', 'name', ts('Name'), $attributes['name'], true);
$this->add('text', 'domain', ts('Email Domain'), $attributes['domain'], true);
$this->addRule('domain', ts('Email domain must use a valid internet domain format (e.g. \'example.org\').'), 'domain');
$this->add('text', 'localpart', ts('Localpart'), $attributes['localpart']);
$this->add('text', 'return_path', ts('Return-Path'), $attributes['return_path']);
$this->addRule('return_path', ts('Return-Path must use a valid email address format.'), 'email');
require_once 'CRM/Core/PseudoConstant.php';
$this->add('select', 'protocol', ts('Protocol'), array('' => ts('- select -')) + CRM_Core_PseudoConstant::mailProtocol(), true);
$this->add('text', 'server', ts('Server'), $attributes['server']);
$this->add('text', 'username', ts('Username'), array('autocomplete' => 'off'));
$this->add('password', 'password', ts('Password'), array('autocomplete' => 'off'));
$this->add('text', 'source', ts('Source'), $attributes['source']);
$this->add('checkbox', 'is_ssl', ts('Use SSL?'));
$this->add('checkbox', 'is_default', ts('Default Option?'));
}
示例11: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
if ($this->_action == CRM_Core_Action::DELETE) {
if ($this->_id && ($tag = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $this->_id, 'name', 'parent_id'))) {
CRM_Core_Session::setStatus(ts("This tag cannot be deleted! You must Delete all its child tags ('%1', etc) prior to deleting this tag.", array(1 => $tag)));
$url = CRM_Utils_System::url('civicrm/admin/tag', "reset=1");
CRM_Utils_System::redirect($url);
return true;
} else {
$this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
}
} else {
$this->applyFilter('__ALL__', 'trim');
$this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Tag', 'name'), true);
$this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array('CRM_Core_DAO_Tag', $this->_id));
$this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Tag', 'description'));
//@lobo haven't a clue why the checkbox isn't displayed (it should be checked by default
$this->add('checkbox', 'is_selectable', ts("If it's a tag or a category"));
$allTag = array('' => '- ' . ts('select') . ' -') + CRM_Core_PseudoConstant::tag();
if ($this->_id) {
unset($allTag[$this->_id]);
}
$this->add('select', 'parent_id', ts('Parent Tag'), $allTag);
parent::buildQuickForm();
}
}
示例12: buildQuickForm
/**
* Build the form object.
*/
public function buildQuickForm()
{
parent::buildQuickForm();
$this->setPageTitle(ts('Mail Account'));
if ($this->_action & CRM_Core_Action::DELETE) {
return;
}
$this->applyFilter('__ALL__', 'trim');
//get the attributes.
$attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_MailSettings');
//build setting form
$this->add('text', 'name', ts('Name'), $attributes['name'], TRUE);
$this->add('text', 'domain', ts('Email Domain'), $attributes['domain'], TRUE);
$this->addRule('domain', ts('Email domain must use a valid internet domain format (e.g. \'example.org\').'), 'domain');
$this->add('text', 'localpart', ts('Localpart'), $attributes['localpart']);
$this->add('text', 'return_path', ts('Return-Path'), $attributes['return_path']);
$this->addRule('return_path', ts('Return-Path must use a valid email address format.'), 'email');
$this->add('select', 'protocol', ts('Protocol'), array('' => ts('- select -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_MailSettings', 'protocol'), TRUE);
$this->add('text', 'server', ts('Server'), $attributes['server']);
$this->add('text', 'username', ts('Username'), array('autocomplete' => 'off'));
$this->add('password', 'password', ts('Password'), array('autocomplete' => 'off'));
$this->add('text', 'source', ts('Source'), $attributes['source']);
$this->add('checkbox', 'is_ssl', ts('Use SSL?'));
$usedfor = array(1 => ts('Bounce Processing'), 0 => ts('Email-to-Activity Processing'));
$this->add('select', 'is_default', ts('Used For?'), $usedfor);
}
示例13: preProcess
public function preProcess()
{
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add');
$this->assign('action', $this->_action);
$this->_BAOName = 'CRM_Core_BAO_MessageTemplate';
$this->set('BAOName', $this->_BAOName);
parent::preProcess();
}
示例14: setDefaultValues
/**
* Set default values.
*
* @return array
*/
public function setDefaultValues()
{
$defaults = parent::setDefaultValues();
if (empty($defaults['weight'])) {
$defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Event_DAO_ParticipantStatusType');
}
$this->_isReserved = CRM_Utils_Array::value('is_reserved', $defaults);
if ($this->_isReserved) {
$this->freeze(array('name', 'class', 'is_active'));
}
return $defaults;
}
示例15: buildQuickForm
/**
* Function to actually build the form
*
* @return None
* @access public
*/
function buildQuickForm()
{
parent::buildQuickForm();
if ($this->_action & CRM_CORE_ACTION_DELETE) {
return;
}
$this->applyFilter('__ALL__', 'trim');
$this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_IMProvider', 'name'));
$this->addRule('name', ts('Please enter a valid name.'), 'required');
$this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array('CRM_Core_DAO_IMProvider', $this->_id));
$this->add('checkbox', 'is_active', ts('Enabled?'));
}