projects
/
civicrm-core.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Filter groups according to included profiles
[civicrm-core.git]
/
CRM
/
Profile
/
Form.php
diff --git
a/CRM/Profile/Form.php
b/CRM/Profile/Form.php
index e8e58cb7f74fb7c99ee754af2a6189a84a7aa316..6f63c185288c06e591c90b40df9ed238392b47a4 100644
(file)
--- a/
CRM/Profile/Form.php
+++ b/
CRM/Profile/Form.php
@@
-101,8
+101,6
@@
class CRM_Profile_Form extends CRM_Core_Form {
*/
public $_ruleGroupID = NULL;
*/
public $_ruleGroupID = NULL;
- public $_isAddCaptcha = FALSE;
-
protected $_isPermissionedChecksum = FALSE;
/**
protected $_isPermissionedChecksum = FALSE;
/**
@@
-281,12
+279,7
@@
class CRM_Profile_Form extends CRM_Core_Form {
* @return array
*/
public function getUFGroupIDs() {
* @return array
*/
public function getUFGroupIDs() {
- if (empty($this->_profileIds)) {
- $dao = new CRM_Core_DAO_UFGroup();
- $dao->id = $this->_gid;
- $this->_profileIds = (array) $dao;
- }
- return $this->_profileIds;
+ return [$this->_gid];
}
/**
}
/**
@@
-338,7
+331,7
@@
class CRM_Profile_Form extends CRM_Core_Form {
}
$this->_duplicateButtonName = $this->getButtonName('upload', 'duplicate');
}
$this->_duplicateButtonName = $this->getButtonName('upload', 'duplicate');
- $gids = explode(',',
CRM_Utils_Request::retrieve('gid', 'String', CRM_Core_DAO::$_nullObject, FALSE, 0
));
+ $gids = explode(',',
(CRM_Utils_Request::retrieve('gid', 'String', CRM_Core_DAO::$_nullObject, FALSE, 0) ?? ''
));
if ((count($gids) > 1) && !$this->_profileIds && empty($this->_profileIds)) {
if (!empty($gids)) {
if ((count($gids) > 1) && !$this->_profileIds && empty($this->_profileIds)) {
if (!empty($gids)) {
@@
-374,13
+367,12
@@
class CRM_Profile_Form extends CRM_Core_Form {
}
$this->_isContactActivityProfile = CRM_Core_BAO_UFField::checkContactActivityProfileType($this->_gid);
}
$this->_isContactActivityProfile = CRM_Core_BAO_UFField::checkContactActivityProfileType($this->_gid);
- //get values for ufGroupName
, captcha
and dupe update.
+ //get values for ufGroupName 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;
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;
$this->_ufGroup = (array) $dao;
}
$this->_ufGroup = (array) $dao;
}
@@
-697,8
+689,9
@@
class CRM_Profile_Form extends CRM_Core_Form {
* Build the form object.
*
*/
* Build the form object.
*
*/
- public function buildQuickForm() {
+ public function buildQuickForm()
: void
{
$this->add('hidden', 'gid', $this->_gid);
$this->add('hidden', 'gid', $this->_gid);
+ $this->assign('deleteRecord', $this->isDeleteMode());
switch ($this->_mode) {
case self::MODE_CREATE:
switch ($this->_mode) {
case self::MODE_CREATE:
@@
-721,13
+714,10
@@
class CRM_Profile_Form extends CRM_Core_Form {
return;
}
return;
}
- if (
($this->_multiRecord & CRM_Core_Action::DELETE
)) {
+ if (
$this->isDeleteMode(
)) {
if (!$this->_recordExists) {
CRM_Core_Session::setStatus(ts('The record %1 doesnot exists', [1 => $this->_recordId]), ts('Record doesnot exists'), 'alert');
}
if (!$this->_recordExists) {
CRM_Core_Session::setStatus(ts('The record %1 doesnot exists', [1 => $this->_recordId]), ts('Record doesnot exists'), 'alert');
}
- else {
- $this->assign('deleteRecord', TRUE);
- }
return;
}
return;
}
@@
-794,7
+784,7
@@
class CRM_Profile_Form extends CRM_Core_Form {
//lets have single status message,
$this->assign('statusMessage', $statusMessage);
if ($return) {
//lets have single status message,
$this->assign('statusMessage', $statusMessage);
if ($return) {
- return
FALSE
;
+ return;
}
$this->assign('id', $this->_id);
}
$this->assign('id', $this->_id);
@@
-837,7
+827,6
@@
class CRM_Profile_Form extends CRM_Core_Form {
}
$this->assign('anonUser', $anonUser);
}
$this->assign('anonUser', $anonUser);
- $addCaptcha = [];
$emailPresent = FALSE;
// add the form elements
$emailPresent = FALSE;
// add the form elements
@@
-855,7
+844,7
@@
class CRM_Profile_Form extends CRM_Core_Form {
continue;
}
continue;
}
-
list($prefixName, $index)
= CRM_Utils_System::explode('-', $name, 2);
+
[$prefixName, $index]
= CRM_Utils_System::explode('-', $name, 2);
CRM_Core_BAO_UFGroup::buildProfile($this, $field, $this->_mode);
CRM_Core_BAO_UFGroup::buildProfile($this, $field, $this->_mode);
@@
-863,27
+852,13
@@
class CRM_Profile_Form extends CRM_Core_Form {
$addToGroupId = $field['add_to_group_id'];
}
$addToGroupId = $field['add_to_group_id'];
}
- //build array for captcha
- if ($field['add_captcha']) {
- $addCaptcha[$field['group_id']] = $field['add_captcha'];
- }
-
if (($name == 'email-Primary') || ($name == 'email-' . ($primaryLocationType ?? ""))) {
$emailPresent = TRUE;
$this->_mail = $name;
}
}
if (($name == 'email-Primary') || ($name == 'email-' . ($primaryLocationType ?? ""))) {
$emailPresent = TRUE;
$this->_mail = $name;
}
}
- // add captcha only for create mode.
if ($this->_mode == self::MODE_CREATE) {
if ($this->_mode == self::MODE_CREATE) {
- // suppress captcha for logged in users only
- if ($this->_currentUserID) {
- $this->_isAddCaptcha = FALSE;
- }
- elseif (!$this->_isAddCaptcha && !empty($addCaptcha)) {
- $this->_isAddCaptcha = TRUE;
- }
-
if ($this->_gid) {
$dao = new CRM_Core_DAO_UFGroup();
$dao->id = $this->_gid;
if ($this->_gid) {
$dao = new CRM_Core_DAO_UFGroup();
$dao->id = $this->_gid;
@@
-896,14
+871,6
@@
class CRM_Profile_Form extends CRM_Core_Form {
}
}
}
}
}
}
- else {
- $this->_isAddCaptcha = FALSE;
- }
-
- //finally add captcha to form.
- if ($this->_isAddCaptcha) {
- CRM_Utils_ReCAPTCHA::enableCaptchaOnForm($this);
- }
if ($this->_mode != self::MODE_SEARCH) {
if (isset($addToGroupId)) {
if ($this->_mode != self::MODE_SEARCH) {
if (isset($addToGroupId)) {
@@
-1039,7
+1006,7
@@
class CRM_Profile_Form extends CRM_Core_Form {
}
foreach ($fields as $key => $value) {
}
foreach ($fields as $key => $value) {
-
list($fieldName, $locTypeId, $phoneTypeId)
= CRM_Utils_System::explode('-', $key, 3);
+
[$fieldName, $locTypeId, $phoneTypeId]
= CRM_Utils_System::explode('-', $key, 3);
if ($fieldName == 'state_province' && !empty($fields["country-{$locTypeId}"])) {
// Validate Country - State list
$countryId = $fields["country-{$locTypeId}"];
if ($fieldName == 'state_province' && !empty($fields["country-{$locTypeId}"])) {
// Validate Country - State list
$countryId = $fields["country-{$locTypeId}"];
@@
-1302,6
+1269,9
@@
class CRM_Profile_Form extends CRM_Core_Form {
$params['customRecordValues'][$this->_recordId] = array_keys($this->_multiRecordFields);
}
$params['customRecordValues'][$this->_recordId] = array_keys($this->_multiRecordFields);
}
+ // sudoman hack: re-insert filtered group memberships
+ $params = CRM_Contact_Form_Edit_TagsAndGroups::reInsertFilteredGroupMemberships([$this->_gid], $this->_id, TRUE, $params);
+
$this->_id = CRM_Contact_BAO_Contact::createProfileContact(
$params,
$profileFields,
$this->_id = CRM_Contact_BAO_Contact::createProfileContact(
$params,
$profileFields,
@@
-1353,9
+1323,12
@@
class CRM_Profile_Form extends CRM_Core_Form {
}
/**
}
/**
- *
@param null $suffix
+ *
Check template file exists.
*
*
- * @return null|string
+ * @param string|null $suffix
+ *
+ * @return string|null
+ * Template file path, else null
*/
public function checkTemplateFileExists($suffix = NULL) {
if ($this->_gid) {
*/
public function checkTemplateFileExists($suffix = NULL) {
if ($this->_gid) {
@@
-1398,4
+1371,11
@@
class CRM_Profile_Form extends CRM_Core_Form {
return $fileName ? $fileName : parent::overrideExtraTemplateFileName();
}
return $fileName ? $fileName : parent::overrideExtraTemplateFileName();
}
+ /**
+ * @return int|string
+ */
+ private function isDeleteMode() {
+ return ($this->_multiRecord & CRM_Core_Action::DELETE);
+ }
+
}
}