protected $_gid;
/**
- * The group id that we are editing
- *
- * @var string
+ * @var array details of the UFGroup used on this page
*/
- protected $_ufGroupName = 'unknown';
+ protected $_ufGroup = array('name' => 'unknown');
/**
* The group id that we are passing in url
*/
protected $_contact;
- /**
- * to store group_id of the group which is to be assigned to the contact
- *
- * @var int
- */
- protected $_addToGroupID;
-
/**
* Do we allow updates of the contact
*
*/
function preProcess() {
$this->_id = $this->get('id');
- $this->_gid = $this->get('gid');
$this->_profileIds = $this->get('profileIds');
$this->_grid = CRM_Utils_Request::retrieve('grid', 'Integer', $this);
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
}
$this->_duplicateButtonName = $this->getButtonName('upload', 'duplicate');
- $gids = explode(',', CRM_Utils_Request::retrieve('gid', 'String', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET'));
+ $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 (!$this->_gid) {
- $this->_gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this, FALSE, 0, 'GET');
+ $this->_gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this, FALSE, 0);
+ $this->set('gid', $this->_gid);
+ }
+
+ if (!$this->_gid) {
+ CRM_Core_Error::fatal(ts('The required parameter "gid" is missing or malformed.'));
}
$this->_activityId = CRM_Utils_Request::retrieve('aid', 'Positive', $this, FALSE, 0, 'GET');
if ($dao->find(TRUE)) {
$this->_isUpdateDupe = $dao->is_update_dupe;
$this->_isAddCaptcha = $dao->add_captcha;
- if (!empty($dao->name)) {
- $this->_ufGroupName = $dao->name;
- }
+ $this->_ufGroup = (array) $dao;
}
$dao->free();
}
- $this->assign('ufGroupName', $this->_ufGroupName);
+ $this->assign('ufGroupName', $this->_ufGroup['name']);
+
+ if (!CRM_Utils_Array::value('is_active', $this->_ufGroup)) {
+ CRM_Core_Error::fatal(ts('The requested profile (gid=%1) is inactive or does not exist.', array(
+ 1 => $this->_gid,
+ )));
+ }
$gids = empty($this->_profileIds) ? $this->_gid : $this->_profileIds;
* @access public
*/
public function buildQuickForm() {
+ $this->add('hidden', 'gid', $this->_gid);
+
switch ($this->_mode) {
case self::MODE_CREATE:
case self::MODE_EDIT:
case self::MODE_REGISTER:
- CRM_Utils_Hook::buildProfile($this->_ufGroupName);
+ CRM_Utils_Hook::buildProfile($this->_ufGroup['name']);
break;
case self::MODE_SEARCH:
- CRM_Utils_Hook::searchProfile($this->_ufGroupName);
+ CRM_Utils_Hook::searchProfile($this->_ufGroup['name']);
break;
default:
}
CRM_Core_BAO_UFGroup::buildProfile($this, $field, $this->_mode);
- if ($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'];
}
$this->assign("isCaptcha", $this->_isAddCaptcha);
- if ($this->_mode != self::MODE_SEARCH) {
- if (isset($addToGroupId)) {
- $this->add('hidden', "add_to_group", $addToGroupId);
- $this->_addToGroupID = $addToGroupId;
- }
- }
-
// lets do the defaults, so we can use it for the below state country routines
$this->setDefaultsValues();
* @static
*/
static function formRule($fields, $files, $form) {
- CRM_Utils_Hook::validateProfile($form->_ufGroupName);
+ CRM_Utils_Hook::validateProfile($form->_ufGroup['name']);
$errors = array();
// if no values, return
return;
}
}
- CRM_Utils_Hook::processProfile($this->_ufGroupName);
+ CRM_Utils_Hook::processProfile($this->_ufGroup['name']);
if (CRM_Utils_Array::value('image_URL', $params)) {
CRM_Contact_BAO_Contact::processImageParams($params);
}
}
}
- $addToGroupId = NULL;
- if (CRM_Utils_Array::value('add_to_group', $params)) {
- $addToGroupId = $params['add_to_group'];
-
+ $addToGroupId = CRM_Utils_Array::value('add_to_group_id', $this->_ufGroup);
+ if ($addToGroupId) {
//run same check whether group is a mailing list
$groupTypes = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group',
$addToGroupId, 'group_type', 'id'
parent::preProcess();
- // make sure the gid is set and valid
- if (!$this->_gid) {
- CRM_Core_Error::fatal(ts('The requested Profile (gid=%1) is disabled, OR there is no Profile with that ID, OR a valid \'gid=\' integer value is missing from the URL. Contact the site administrator if you need assistance.',
- array(1 => $this->_gid)
- ));
- }
-
// and also the profile is of type 'Profile'
$query = "
SELECT module
* @access public
*/
public function buildQuickForm() {
- // add the hidden field to redirect the postProcess from
- $ufGroup = new CRM_Core_DAO_UFGroup();
-
- $ufGroup->id = $this->_gid;
- if (!$ufGroup->find(TRUE)) {
+ if (empty($this->_ufGroup['id'])) {
CRM_Core_Error::fatal();
}
'Edit ' . $this->_customGroupTitle . ' Record' : $this->_customGroupTitle;
} else {
- $groupTitle = $ufGroup->title;
+ $groupTitle = $this->_ufGroup['title'];
}
CRM_Utils_System::setTitle($groupTitle);
$this->assign('recentlyViewed', FALSE);
if ($this->_context != 'dialog') {
- $this->_postURL = CRM_Utils_Array::value('postURL', $_POST);
- $this->_cancelURL = CRM_Utils_Array::value('cancelURL', $_POST);
+ $this->_postURL = $this->_ufGroup['post_URL'];
+ $this->_cancelURL = $this->_ufGroup['cancel_URL'];
$gidString = $this->_gid;
if (!empty($this->_profileIds)) {
$gidString = implode(',', $this->_profileIds);
}
- if (!$this->_postURL) {
- $this->_postURL = $ufGroup->post_URL;
- }
-
if (!$this->_postURL) {
if ($this->_context == 'Search') {
$this->_postURL = CRM_Utils_System::url('civicrm/contact/search');
}
if (!$this->_cancelURL) {
- if ($ufGroup->cancel_URL) {
- $this->_cancelURL = $ufGroup->cancel_URL;
- }
- else {
- $this->_cancelURL = CRM_Utils_System::url('civicrm/profile',
- "reset=1&gid={$gidString}"
- );
- }
+ $this->_cancelURL = CRM_Utils_System::url('civicrm/profile',
+ "reset=1&gid={$gidString}"
+ );
}
if ($this->_multiRecordProfile) {
$this->_postURL = str_replace('&', '&', $this->_postURL);
$this->_cancelURL = str_replace('&', '&', $this->_cancelURL);
- $this->addElement('hidden', 'postURL', $this->_postURL);
if ($this->_cancelURL) {
$this->addElement('hidden', 'cancelURL', $this->_cancelURL);
}