Skip to content
Snippets Groups Projects
Commit 5493810c authored by colemanw's avatar colemanw
Browse files

Merge pull request #1144 from totten/CRM-12865-profile-name

CRM-12865 - Define regions and CSS classes for profile forms
parents 38eb6956 a8387f19
Branches
Tags
No related merge requests found
......@@ -66,6 +66,13 @@ class CRM_Profile_Form extends CRM_Core_Form {
*/
protected $_gid;
/**
* The group id that we are editing
*
* @var string
*/
protected $_ufGroupName = 'unknown';
/**
* The group id that we are passing in url
*
......@@ -256,16 +263,20 @@ class CRM_Profile_Form extends CRM_Core_Form {
}
$this->_isContactActivityProfile = CRM_Core_BAO_UFField::checkContactActivityProfileType($this->_gid);
//get values for captch and dupe update.
//get values for ufGroupName, captch and dupe update.
if ($this->_gid) {
$dao = new CRM_Core_DAO_UFGroup();
$dao->id = $this->_gid;
if ($dao->find(TRUE)) {
$this->_isUpdateDupe = $dao->is_update_dupe;
$this->_isAddCaptcha = $dao->add_captcha;
if (!empty($dao->name)) {
$this->_ufGroupName = $dao->name;
}
}
$dao->free();
}
$this->assign('ufGroupName', $this->_ufGroupName);
$gids = empty($this->_profileIds) ? $this->_gid : $this->_profileIds;
......@@ -573,6 +584,18 @@ class CRM_Profile_Form extends CRM_Core_Form {
* @access public
*/
public function buildQuickForm() {
switch ($this->_mode) {
case self::MODE_CREATE:
case self::MODE_EDIT:
case self::MODE_REGISTER:
CRM_Utils_Hook::buildProfile($this->_ufGroupName);
break;
case self::MODE_SEARCH:
CRM_Utils_Hook::searchProfile($this->_ufGroupName);
break;
default:
}
//lets have single status message, CRM-4363
$return = FALSE;
$statusMessage = NULL;
......@@ -868,6 +891,8 @@ class CRM_Profile_Form extends CRM_Core_Form {
* @static
*/
static function formRule($fields, $files, $form) {
CRM_Utils_Hook::validateProfile($form->_ufGroupName);
$errors = array();
// if no values, return
if (empty($fields)) {
......@@ -1066,6 +1091,7 @@ class CRM_Profile_Form extends CRM_Core_Form {
return;
}
}
CRM_Utils_Hook::processProfile($this->_ufGroupName);
if (CRM_Utils_Array::value('image_URL', $params)) {
CRM_Contact_BAO_Contact::processImageParams($params);
}
......
......@@ -333,6 +333,8 @@ class CRM_Profile_Page_Dynamic extends CRM_Core_Page {
}
$name = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $this->_gid, 'name');
$this->assign('ufGroupName', $name);
CRM_Utils_Hook::viewProfile($name);
if (strtolower($name) == 'summary_overlay') {
$template->assign('overlayProfile', TRUE);
......
......@@ -283,6 +283,7 @@ class CRM_Profile_Page_Listings extends CRM_Core_Page {
$this->preProcess();
$this->assign('recentlyViewed', FALSE);
$this->assign('ufGroupName', 'unknown'); // override later (if possible)
if ($this->_gid) {
$ufgroupDAO = new CRM_Core_DAO_UFGroup();
......@@ -297,6 +298,9 @@ class CRM_Profile_Page_Listings extends CRM_Core_Page {
if ($ufgroupDAO->title) {
CRM_Utils_System::setTitle($ufgroupDAO->title);
}
if ($ufgroupDAO->name) {
$this->assign('ufGroupName', $ufgroupDAO->name);
}
}
$this->assign('isReset', TRUE);
......
......@@ -1235,4 +1235,54 @@ abstract class CRM_Utils_Hook {
return self::singleton()->invoke(1, $entityTypes, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_entityTypes'
);
}
/**
* This hook is called while preparing a profile form
*
* @param string $name
* @return void
*/
static function buildProfile($name) {
return self::singleton()->invoke(1, $name, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_buildProfile');
}
/**
* This hook is called while validating a profile form submission
*
* @param string $name
* @return void
*/
static function validateProfile($name) {
return self::singleton()->invoke(1, $name, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_validateProfile');
}
/**
* This hook is called processing a valid profile form submission
*
* @param string $name
* @return void
*/
static function processProfile($name) {
return self::singleton()->invoke(1, $name, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_processProfile');
}
/**
* This hook is called while preparing a read-only profile screen
*
* @param string $name
* @return void
*/
static function viewProfile($name) {
return self::singleton()->invoke(1, $name, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_viewProfile');
}
/**
* This hook is called while preparing a list of contacts (based on a profile)
*
* @param string $name
* @return void
*/
static function searchProfile($name) {
return self::singleton()->invoke(1, $name, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_searchProfile');
}
}
......@@ -23,6 +23,9 @@
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*}
<div class="crm-profile-name-{$ufGroupName}">
{crmRegion name=profile-form-`$ufGroupName`}
{* Profile forms when embedded in CMS account create (mode=1) or
cms account edit (mode=8) or civicrm/profile (mode=4) pages *}
{if ($context eq 'multiProfileDialog')}
......@@ -374,3 +377,5 @@ cj(document).ready(function(){
</script>
{/literal}
{/crmRegion}
</div> {* end crm-profile-NAME *}
......@@ -29,6 +29,8 @@
{include file="CRM/Profile/Page/Overlay.tpl"}
{else}
<div id="crm-container" class="crm-container" lang="{$config->lcMessages|truncate:2:"":true}" xml:lang="{$config->lcMessages|truncate:2:"":true}">
<div class="crm-profile-name-{$ufGroupName}">
{crmRegion name=profile-view-`$ufGroupName`}
{foreach from=$profileFields item=field key=rowName}
<div id="row-{$rowName}" class="crm-section {$rowName}-section">
<div class="label">
......@@ -40,6 +42,8 @@
<div class="clear"></div>
</div>
{/foreach}
{/crmRegion}
</div>
</div>
{/if}
{/if}
......
......@@ -23,6 +23,10 @@
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*}
<div class="crm-profile-name-{$ufGroupName}">
{crmRegion name=profile-search-`$ufGroupName`}
{* make sure there are some fields in the selector *}
{if ! empty( $columnHeaders ) || $isReset }
......@@ -89,4 +93,7 @@
{ts}No fields in this Profile have been configured to display as a result column in the search results table. Ask the site administrator to check the Profile setup.{/ts}
</div>
{/if}
</div>
\ No newline at end of file
</div>
{/crmRegion}
</div>{* crm-profile-name-NAME *}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment