コード例 #1
0
 /** 
  * run this page (figure out the action needed and perform it). 
  * 
  * @return void 
  */
 function run()
 {
     $this->preProcess();
     $this->assign('recentlyViewed', false);
     if ($this->_gid) {
         $ufgroupDAO = new CRM_Core_DAO_UFGroup();
         $ufgroupDAO->id = $this->_gid;
         if (!$ufgroupDAO->find(true)) {
             CRM_Core_Error::fatal();
         }
     }
     if ($this->_gid) {
         // set the title of the page
         if ($ufgroupDAO->title) {
             CRM_Utils_System::setTitle($ufgroupDAO->title);
         }
     }
     $this->assign('isReset', true);
     $formController = new CRM_Core_Controller_Simple('CRM_Profile_Form_Search', ts('Search Profile'), CRM_Core_Action::ADD);
     $formController->setEmbedded(true);
     $formController->set('gid', $this->_gid);
     $formController->process();
     $searchError = false;
     // check if there is a POST
     if (!empty($_POST)) {
         if ($formController->validate() !== true) {
             $searchError = true;
         }
     }
     // also get the search tpl name
     $this->assign('searchTPL', $formController->getTemplateFileName());
     $this->assign('search', $this->_search);
     // search if search returned a form error?
     if ((!CRM_Utils_Array::value('reset', $_GET) || CRM_Utils_Array::value('force', $_GET)) && !$searchError) {
         $this->assign('isReset', false);
         $gidString = $this->_gid;
         if (empty($this->_profileIds)) {
             $gids = $this->_gid;
         } else {
             $gids = $this->_profileIds;
             $gidString = implode(',', $this->_profileIds);
         }
         $map = 0;
         $linkToUF = 0;
         $editLink = false;
         if ($this->_gid) {
             $map = $ufgroupDAO->is_map;
             $linkToUF = $ufgroupDAO->is_uf_link;
             $editLink = $ufgroupDAO->is_edit_link;
         }
         if ($map) {
             $this->assign('mapURL', CRM_Utils_System::url('civicrm/profile/map', "map=1&gid={$gidString}&reset=1"));
         }
         if (CRM_Utils_Array::value('group', $this->_params)) {
             foreach ($this->_params['group'] as $key => $val) {
                 if (!$val) {
                     unset($this->_params['group'][$key]);
                 }
             }
         }
         // the selector will override this if the user does have
         // edit permissions as determined by the mask, CRM-4341
         // do not allow edit for anon users in joomla frontend, CRM-4668
         $config = CRM_Core_Config::singleton();
         if (!CRM_Core_Permission::check('access CiviCRM') || $config->userFrameworkFrontend == 1) {
             $editLink = false;
         }
         $selector = new CRM_Profile_Selector_Listings($this->_params, $this->_customFields, $gids, $map, $editLink, $linkToUF);
         $controller = new CRM_Core_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $this->get(CRM_Utils_Sort::SORT_ID), CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::TEMPLATE);
         $controller->setEmbedded(true);
         $controller->run();
     }
     //CRM-6862 -run form cotroller after
     //selector, since it erase $_POST
     $formController->run();
     return parent::run();
 }
コード例 #2
0
ファイル: UFGroup.php プロジェクト: rollox/civicrm-core
 /**
  * Get the html for the form that represents this particular group.
  *
  * @param int $userID
  *   The user id that we are actually editing.
  * @param string $title
  *   The title of the group we are interested in.
  * @param int $action
  *   The action of the form.
  * @param bool $register
  *   Is this the registration form.
  * @param bool $reset
  *   Should we reset the form?.
  * @param int $profileID
  *   Do we have the profile ID?.
  *
  * @param bool $doNotProcess
  * @param null $ctype
  *
  * @return string
  *   the html for the form on success, otherwise empty string
  */
 public static function getEditHTML($userID, $title, $action = NULL, $register = FALSE, $reset = FALSE, $profileID = NULL, $doNotProcess = FALSE, $ctype = NULL)
 {
     if ($register) {
         $controller = new CRM_Core_Controller_Simple('CRM_Profile_Form_Dynamic', ts('Dynamic Form Creator'), $action);
         if ($reset || $doNotProcess) {
             // hack to make sure we do not process this form
             $oldQFDefault = CRM_Utils_Array::value('_qf_default', $_POST);
             unset($_POST['_qf_default']);
             unset($_REQUEST['_qf_default']);
             if ($reset) {
                 $controller->reset();
             }
         }
         $controller->set('id', $userID);
         $controller->set('register', 1);
         $controller->set('skipPermission', 1);
         $controller->set('ctype', $ctype);
         $controller->process();
         if ($doNotProcess || !empty($_POST)) {
             $controller->validate();
         }
         $controller->setEmbedded(TRUE);
         //CRM-5839 - though we want to process form, get the control back.
         $controller->setSkipRedirection($doNotProcess ? FALSE : TRUE);
         $controller->run();
         // we are done processing so restore the POST/REQUEST vars
         if (($reset || $doNotProcess) && $oldQFDefault) {
             $_POST['_qf_default'] = $_REQUEST['_qf_default'] = $oldQFDefault;
         }
         $template = CRM_Core_Smarty::singleton();
         // Hide CRM error messages if they are displayed using drupal form_set_error.
         if (!empty($_POST)) {
             $template->assign('suppressForm', TRUE);
         }
         return trim($template->fetch('CRM/Profile/Form/Dynamic.tpl'));
     } else {
         if (!$profileID) {
             // make sure we have a valid group
             $group = new CRM_Core_DAO_UFGroup();
             $group->title = $title;
             if ($group->find(TRUE)) {
                 $profileID = $group->id;
             }
         }
         if ($profileID) {
             // make sure profileID and ctype match if ctype exists
             if ($ctype) {
                 $profileType = CRM_Core_BAO_UFField::getProfileType($profileID);
                 if (CRM_Contact_BAO_ContactType::isaSubType($profileType)) {
                     $profileType = CRM_Contact_BAO_ContactType::getBasicType($profileType);
                 }
                 if ($profileType != 'Contact' && $profileType != $ctype) {
                     return NULL;
                 }
             }
             $controller = new CRM_Core_Controller_Simple('CRM_Profile_Form_Dynamic', ts('Dynamic Form Creator'), $action);
             if ($reset) {
                 $controller->reset();
             }
             $controller->set('gid', $profileID);
             $controller->set('id', $userID);
             $controller->set('register', 0);
             $controller->set('skipPermission', 1);
             if ($ctype) {
                 $controller->set('ctype', $ctype);
             }
             $controller->process();
             $controller->setEmbedded(TRUE);
             //CRM-5846 - give the control back to drupal.
             $controller->setSkipRedirection($doNotProcess ? FALSE : TRUE);
             $controller->run();
             $template = CRM_Core_Smarty::singleton();
             // Hide CRM error messages if they are displayed using drupal form_set_error.
             if (!empty($_POST) && CRM_Core_Config::singleton()->userFramework == 'Drupal') {
                 if (arg(0) == 'user' || arg(0) == 'admin' && arg(1) == 'people') {
                     $template->assign('suppressForm', TRUE);
                 }
             }
             $templateFile = "CRM/Profile/Form/{$profileID}/Dynamic.tpl";
             if (!$template->template_exists($templateFile)) {
                 $templateFile = 'CRM/Profile/Form/Dynamic.tpl';
             }
             return trim($template->fetch($templateFile));
         } else {
             $userEmail = CRM_Contact_BAO_Contact_Location::getEmailDetails($userID);
             // if post not empty then only proceed
             if (!empty($_POST)) {
                 // get the new email
                 $config = CRM_Core_Config::singleton();
                 $email = CRM_Utils_Array::value('mail', $_POST);
                 if (CRM_Utils_Rule::email($email) && $email != $userEmail[1]) {
                     CRM_Core_BAO_UFMatch::updateContactEmail($userID, $email);
                 }
             }
         }
     }
     return '';
 }
コード例 #3
0
ファイル: UFGroup.php プロジェクト: hampelm/Ginsberg-CiviDemo
 /**
  * get the html for the form that represents this particular group
  *
  * @param int     $userID    the user id that we are actually editing
  * @param string  $title     the title of the group we are interested in
  * @param int     $action    the action of the form
  * @param boolean $register  is this the registration form
  * @param boolean $reset     should we reset the form?
  * @param int     $profileID do we have the profile ID?
  *
  * @return string       the html for the form on success, otherwise empty string
  * @static
  * @access public
  */
 static function getEditHTML($userID, $title, $action = null, $register = false, $reset = false, $profileID = null, $doNotProcess = false, $ctype = null)
 {
     require_once "CRM/Core/Controller/Simple.php";
     $session = CRM_Core_Session::singleton();
     if ($register) {
         $controller = new CRM_Core_Controller_Simple('CRM_Profile_Form_Dynamic', ts('Dynamic Form Creator'), $action);
         if ($reset || $doNotProcess) {
             // hack to make sure we do not process this form
             $oldQFDefault = CRM_Utils_Array::value('_qf_default', $_POST);
             unset($_POST['_qf_default']);
             unset($_REQUEST['_qf_default']);
             if ($reset) {
                 $controller->reset();
             }
         }
         $controller->set('id', $userID);
         $controller->set('register', 1);
         $controller->set('skipPermission', 1);
         $controller->set('ctype', $ctype);
         $controller->process();
         if ($doNotProcess) {
             $controller->validate();
         }
         $controller->setEmbedded(true);
         //CRM-5839 - though we want to process form, get the control back.
         $controller->setSkipRedirection($doNotProcess ? false : true);
         $controller->run();
         // we are done processing so restore the POST/REQUEST vars
         if (($reset || $doNotProcess) && $oldQFDefault) {
             $_POST['_qf_default'] = $_REQUEST['_qf_default'] = $oldQFDefault;
         }
         $template = CRM_Core_Smarty::singleton();
         return trim($template->fetch('CRM/Profile/Form/Dynamic.tpl'));
     } else {
         if (!$profileID) {
             // make sure we have a valid group
             $group = new CRM_Core_DAO_UFGroup();
             $group->title = $title;
             if ($group->find(true)) {
                 $profileID = $group->id;
             }
         }
         if ($profileID) {
             // make sure profileID and ctype match if ctype exists
             if ($ctype) {
                 require_once 'CRM/Core/BAO/UFField.php';
                 $profileType = CRM_Core_BAO_UFField::getProfileType($profileID);
                 if (CRM_Contact_BAO_ContactType::isaSubType($profileType)) {
                     $profileType = CRM_Contact_BAO_ContactType::getBasicType($profileType);
                 }
                 if ($profileType != 'Contact' && $profileType != $ctype) {
                     return null;
                 }
             }
             $controller = new CRM_Core_Controller_Simple('CRM_Profile_Form_Dynamic', ts('Dynamic Form Creator'), $action);
             if ($reset) {
                 $controller->reset();
             }
             $controller->set('gid', $profileID);
             $controller->set('id', $userID);
             $controller->set('register', 0);
             $controller->set('skipPermission', 1);
             if ($ctype) {
                 $controller->set('ctype', $ctype);
             }
             $controller->process();
             $controller->setEmbedded(true);
             //CRM-5846 - give the control back to drupal.
             $controller->setSkipRedirection($doNotProcess ? false : true);
             $controller->run();
             $template = CRM_Core_Smarty::singleton();
             $templateFile = "CRM/Profile/Form/{$profileID}/Dynamic.tpl";
             if (!$template->template_exists($templateFile)) {
                 $templateFile = "CRM/Profile/Form/Dynamic.tpl";
             }
             return trim($template->fetch($templateFile));
         } else {
             require_once 'CRM/Contact/BAO/Contact/Location.php';
             $userEmail = CRM_Contact_BAO_Contact_Location::getEmailDetails($userID);
             // if post not empty then only proceed
             if (!empty($_POST)) {
                 // get the new email
                 $config = CRM_Core_Config::singleton();
                 $email = CRM_Utils_Array::value('mail', $_POST);
                 if (CRM_Utils_Rule::email($email) && $email != $userEmail[1]) {
                     require_once 'CRM/Core/BAO/UFMatch.php';
                     CRM_Core_BAO_UFMatch::updateContactEmail($userID, $email);
                 }
             }
         }
     }
     return '';
 }