Пример #1
0
 /**
  * run this page (figure out the action needed and perform it).
  *
  * @return void
  */
 function run()
 {
     $this->preProcess();
     $this->assign('recentlyViewed', FALSE);
     $this->assign('ufGroupName', 'unknown');
     // override later (if possible)
     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);
         }
         if ($ufgroupDAO->name) {
             $this->assign('ufGroupName', $ufgroupDAO->name);
         }
     }
     $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->getHookedTemplateFileName());
     $this->assign('search', $this->_search);
     // search if search returned a form error?
     if ((empty($_GET['reset']) || !empty($_GET['force'])) && !$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 (!empty($this->_params['group'])) {
             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();
 }