function postProcess()
 {
     $values = $this->exportValues();
     $pcp_type_contact = $values['pcp_contact_id'];
     $pcp_type = $values['pcp_type'];
     $custom_group_name = CRM_Pcpteams_Constant::C_PCP_CUSTOM_GROUP_NAME;
     $customGroupParams = array('version' => 3, 'sequential' => 1, 'name' => $custom_group_name);
     $custom_group_ret = civicrm_api('CustomGroup', 'GET', $customGroupParams);
     $customGroupID = $custom_group_ret['id'];
     $customGroupTableName = $custom_group_ret['values'][0]['table_name'];
     $query = "SELECT ct.pcp_type_contact as contactID FROM {$customGroupTableName} ct WHERE ct.pcp_type = '{$pcp_type}'";
     $dao = CRM_Core_DAO::executeQuery($query);
     $pcpFound = FALSE;
     while ($dao->fetch()) {
         if ($dao->contactID == $pcp_type_contact) {
             CRM_Core_Session::setStatus(ts('PCP Found. Redirecting to dashboard'));
             CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/pcp/dashboard', 'reset=1'));
             $pcpFound = TRUE;
             break;
         }
     }
     if (!$pcpFound) {
         CRM_Core_Session::setStatus(ts('PCP Not Found. Creating New PCP Record'));
         $PcpID = $this->_pcpId;
         $insertQuery = "\n        INSERT INTO `civicrm_value_pcp_custom_set` (`id`, `entity_id`, `team_pcp_id`, `pcp_type`, `pcp_type_contact`) VALUES (NULL, {$PcpID}, NULL, '{$pcp_type}', {$pcp_type_contact})";
         $dao = CRM_Core_DAO::executeQuery($insertQuery);
         CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/pcp/dashboard', 'reset=1'));
     }
     //Fixme:
     parent::postProcess();
 }
 function run()
 {
     // title
     CRM_Utils_System::setTitle(ts('WindowSill'));
     // config
     // https://github.com/kreynen/civicrm-min/blob/master/CRM/Core/Extensions.php
     $config = CRM_Core_Config::singleton();
     if ($config->userFramework != 'Drupal') {
         $error = "<div class='messages status no-popup'><div class='icon inform-icon'></div>Not a Drupal installation</div>";
     } else {
         $error = "<div class='messages status no-popup'><div class='icon inform-icon'></div>Drupal installation</div>";
     }
     // error
     $this->assign('error', $error);
     // on form action update settings
     if (isset($_REQUEST['settings'])) {
         // set
         CRM_Core_BAO_Setting::setItem($_REQUEST['settings'], 'windowsill', 'settings');
         // notice
         CRM_Core_Session::setStatus(ts('Windowsill settings changed'), ts('Saved'), 'success');
     }
     // url
     $url = CRM_Utils_System::url() . "civicrm/ctrl/windowsill";
     $this->assign('url', $url);
     // render
     parent::run();
 }
 /**
  * Format size.
  *
  */
 public static function formatUnitSize($size, $checkForPostMax = FALSE)
 {
     if ($size) {
         $last = strtolower($size[strlen($size) - 1]);
         switch ($last) {
             // The 'G' modifier is available since PHP 5.1.0
             case 'g':
                 $size *= 1024;
             case 'm':
                 $size *= 1024;
             case 'k':
                 $size *= 1024;
         }
         if ($checkForPostMax) {
             $maxImportFileSize = self::formatUnitSize(ini_get('upload_max_filesize'));
             $postMaxSize = self::formatUnitSize(ini_get('post_max_size'));
             if ($maxImportFileSize > $postMaxSize && $postMaxSize == $size) {
                 CRM_Core_Session::setStatus(ts("Note: Upload max filesize ('upload_max_filesize') should not exceed Post max size ('post_max_size') as defined in PHP.ini, please check with your system administrator."), ts("Warning"), "alert");
             }
             //respect php.ini upload_max_filesize
             if ($size > $maxImportFileSize && $size !== $postMaxSize) {
                 $size = $maxImportFileSize;
                 CRM_Core_Session::setStatus(ts("Note: Please verify your configuration for Maximum File Size (in MB) <a href='%1'>Administrator >> System Settings >> Misc</a>. It should support 'upload_max_size' as defined in PHP.ini.Please check with your system administrator.", array(1 => CRM_Utils_System::url('civicrm/admin/setting/misc', 'reset=1'))), ts("Warning"), "alert");
             }
         }
         return $size;
     }
 }
 static function postProcess(&$form)
 {
     $values = $form->exportValues();
     $orgName = $values['organization_name'];
     $cSubType = CRM_Pcpteams_Constant::C_CONTACT_SUB_TYPE_TEAM;
     $params = array('version' => '1', 'contact_type' => 'Organization', 'contact_sub_type' => $cSubType, 'organization_name' => $orgName);
     $createTeam = civicrm_api3('Contact', 'create', $params);
     // Create Dummy Team PCP Page
     $teamPcpId = CRM_Pcpteams_Utils::createDefaultPcp($createTeam['id'], $form->get('component_page_id'));
     // Create/Update custom record with team pcp id and create relationship with user as Team Admin
     if ($teamPcpId) {
         $userId = CRM_Pcpteams_Utils::getloggedInUserId();
         CRM_Pcpteams_Utils::createTeamRelationship($userId, $createTeam['id'], $custom = array(), 'create');
         $params = array('version' => 3, 'entity_id' => $form->get('page_id'), "team_pcp_id" => $teamPcpId);
         $result = civicrm_api3('pcpteams', 'customcreate', $params);
         $form->set('teamName', $orgName);
         $form->set('teamContactID', $createTeam['id']);
         $form->set('teamPcpId', $teamPcpId);
         $actParams = array('target_contact_id' => $createTeam['id']);
         CRM_Pcpteams_Utils::createPcpActivity($actParams, CRM_Pcpteams_Constant::C_AT_TEAM_CREATE);
         CRM_Core_Session::setStatus(ts("Your Team %1 has been created, you can invite members from your team page.", array(1 => $orgName)), ts('New Team Created'));
     } else {
         CRM_Core_Session::setStatus(ts("Failed to Create Team \"{$orgName}\" ..."));
     }
 }
 /**
  * Save values.
  */
 public function postProcess()
 {
     $values = $this->exportValues();
     try {
         $result = civicrm_api3('Setting', 'create', array('statelegemail_key' => $values['key']));
         $success = TRUE;
     } catch (CiviCRM_API3_Exception $e) {
         $error = $e->getMessage();
         CRM_Core_Error::debug_log_message(t('API Error: %1', array(1 => $error, 'domain' => 'com.aghstrategies.statelegemail')));
         CRM_Core_Session::setStatus(ts('Error saving Sunlight Foundation API key', array('domain' => 'com.aghstrategies.statelegemail')), 'Error', 'error');
         $success = FALSE;
     }
     try {
         $result = civicrm_api3('Setting', 'create', array('statelegemail_states' => $values['states']));
     } catch (CiviCRM_API3_Exception $e) {
         $error = $e->getMessage();
         CRM_Core_Error::debug_log_message(t('API Error: %1', array(1 => $error, 'domain' => 'com.aghstrategies.statelegemail')));
         CRM_Core_Session::setStatus(ts('Error saving enabled states', array('domain' => 'com.aghstrategies.statelegemail')), 'Error', 'error');
         $success = FALSE;
     }
     if ($success) {
         CRM_Core_Session::setStatus(ts('You have successfully updated the state legislator petition settings.', array('domain' => 'com.aghstrategies.statelegemail')), 'Settings saved', 'success');
     }
     parent::postProcess();
 }
Beispiel #6
0
 /**
  * run this page (figure out the action needed and perform it).
  *
  * @return void
  */
 function run()
 {
     if (!CRM_Core_Permission::check('administer Reports')) {
         return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/report/list', 'reset=1'));
     }
     $optionVal = CRM_Report_Utils_Report::getValueFromUrl();
     $templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', "{$optionVal}", 'value', 'String', FALSE);
     $extKey = strpos(CRM_Utils_Array::value('name', $templateInfo), '.');
     $reportClass = NULL;
     if ($extKey !== FALSE) {
         $ext = CRM_Extension_System::singleton()->getMapper();
         $reportClass = $ext->keyToClass($templateInfo['name'], 'report');
         $templateInfo['name'] = $reportClass;
     }
     if (strstr(CRM_Utils_Array::value('name', $templateInfo), '_Form') || !is_null($reportClass)) {
         CRM_Utils_System::setTitle($templateInfo['label'] . ' - Template');
         $this->assign('reportTitle', $templateInfo['label']);
         $session = CRM_Core_Session::singleton();
         $session->set('reportDescription', $templateInfo['description']);
         $wrapper = new CRM_Utils_Wrapper();
         return $wrapper->run($templateInfo['name'], NULL, NULL);
     }
     if ($optionVal) {
         CRM_Core_Session::setStatus(ts('Could not find the report template. Make sure the report template is registered and / or url is correct.'), ts('Template Not Found'), 'error');
     }
     return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/report/list', 'reset=1'));
 }
 function buildQuickForm()
 {
     require_once 'UK_Direct_Debit/Form/Main.php';
     // If no civicrm_sd, then create that table
     if (!CRM_Core_DAO::checkTableExists('civicrm_sd')) {
         $creatSql = "CREATE TABLE `civicrm_sd` (\n          `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n          `start_date` datetime NOT NULL,\n          `frequency_unit` enum('day','week','month','year') CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT 'month',\n          `frequency_interval` int(10) unsigned DEFAULT NULL,\n\t\t\t\t\t`amount` decimal(20,2) DEFAULT NULL,\n          `transaction_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,\n          `contact_id` int(10) unsigned DEFAULT NULL,\n          `external_id` int(10) unsigned DEFAULT NULL,\n          `membership_id` int(10) unsigned DEFAULT NULL,\n          `member_count` int(10) unsigned DEFAULT NULL,\n          `payment_processor_id` varchar(255) DEFAULT NULL,\n          `payment_instrument_id` int(10) unsigned DEFAULT NULL,\n          `cycle_day` int(10) unsigned NOT NULL DEFAULT '1',\n          `contribution_status_id` int(10) DEFAULT '1',\n          `is_valid` int(4) NOT NULL DEFAULT '1',\n          `payerReference` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,\n\t  `recur_id` int(10) unsigned DEFAULT NULL,\n          PRIMARY KEY (`id`)\n         ) ENGINE=InnoDB AUTO_INCREMENT=350 DEFAULT CHARSET=latin1";
         CRM_Core_DAO::executeQuery($creatSql);
         $columnExists = CRM_Core_DAO::checkFieldExists('civicrm_contribution_recur', 'membership_id');
         if (!$columnExists) {
             $query = "\n          ALTER TABLE civicrm_contribution_recur\n          ADD membership_id int(10) unsigned AFTER contact_id,\n          ADD CONSTRAINT FK_civicrm_contribution_recur_membership_id\n          FOREIGN KEY(membership_id) REFERENCES civicrm_membership(id) ON DELETE CASCADE ON UPDATE RESTRICT";
             CRM_Core_DAO::executeQuery($query);
         }
     } else {
         $emptySql = "TRUNCATE TABLE `civicrm_sd`";
         CRM_Core_DAO::executeQuery($emptySql);
     }
     $smartDebitArray = self::getSmartDebitPayments(NULL);
     foreach ($smartDebitArray as $key => $smartDebitRecord) {
         if ($smartDebitRecord['current_state'] == 10 || $smartDebitRecord['current_state'] == 1 || $smartDebitRecord['current_state'] == 11) {
             $regularAmount = substr($smartDebitRecord['regular_amount'], 2);
             // Extract the number from reference_number
             $output = preg_match("/\\d+/", $smartDebitRecord['reference_number'], $results);
             if ($regularAmount && $results[0]) {
                 list($y, $m, $d) = explode('-', $smartDebitRecord['start_date']);
                 $sql = "INSERT INTO `civicrm_sd`(`start_date`, `frequency_unit`, `amount`, `transaction_id`, `external_id`, `payment_processor_id`, `payment_instrument_id`, `cycle_day`, `contribution_status_id`, `frequency_interval`, `payerReference`) VALUES (%1,%2,%3,%4,%5,%6,%7,%8,%9,%10,%11)";
                 $params = array(1 => array($smartDebitRecord['start_date'], 'String'), 2 => array(self::translateSmartDebitFrequencyUnit($smartDebitRecord['frequency_type']), 'String'), 3 => array($regularAmount, 'Float'), 4 => array($smartDebitRecord['reference_number'], 'String'), 5 => array($results[0], 'Int'), 6 => array(self::getSmartDebitPaymentProcessorID(), 'Int'), 7 => array(5, 'Int'), 8 => array($d, 'Int'), 9 => array(5, 'Int'), 10 => array($smartDebitRecord['frequency_factor'], 'Int'), 11 => array($smartDebitRecord['payerReference'], 'String'));
                 CRM_Core_DAO::executeQuery($sql, $params);
             }
         }
     }
     if ($smartDebitArray) {
         CRM_Core_Session::setStatus('Smart debit data retreived successfully.', 'Success', 'info');
     }
 }
 /**
  * Browse all jobs.
  *
  * @param null $action
  *
  * @return void
  */
 public function browse($action = NULL)
 {
     $qm = new CRM_Queryrunner_QueryManager();
     // using Export action for Execute. Doh.
     if ($this->_action & CRM_Core_Action::EXPORT) {
         $qm->execute($this->_id, TRUE);
         $name = $qm->getNameFromId($this->_id);
         CRM_Core_Session::setStatus(ts("The {$name} query has been executed."), ts("Executed"), "success");
     }
     $freqs = CRM_Queryrunner_Query::getQueryFrequency();
     $rows = array();
     foreach ($qm->queries as $query) {
         $action = array_sum(array_keys($this->links()));
         if ($query->is_active) {
             $action -= CRM_Core_Action::ENABLE;
         } else {
             $action -= CRM_Core_Action::DISABLE;
         }
         $query->action = CRM_Core_Action::formLink(self::links(), $action, array('id' => $query->id), ts('more'), FALSE, 'query.manage.action', 'Query', $query->id);
         $query->last_run = $query->last_run ? date('M j, Y, g:ia', $query->last_run) : 'never';
         $query->scheduled_run = $query->scheduled_run ? date('M j, Y, g:ia', $query->scheduled_run) : '';
         $query->run_frequency = $freqs[$query->run_frequency];
         $query = get_object_vars($query);
         $rows[] = $query;
         if ($query['id'] == $this->_id) {
             $this->assign('query', $query);
         }
     }
     $this->assign('rows', $rows);
     if ($this->_action & CRM_Core_Action::PREVIEW) {
         $this->assign('server', isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''));
         $this->assign('doc_root', $_SERVER['DOCUMENT_ROOT']);
     }
 }
Beispiel #9
0
 /**
  * Process the form submission.
  */
 public function postProcess()
 {
     $params = $this->controller->exportValues($this->_name);
     if ($this->_action & CRM_Core_Action::DELETE) {
         CRM_Core_Session::setStatus("", ts("Batch Deleted"), "success");
         CRM_Batch_BAO_Batch::deleteBatch($this->_id);
         return;
     }
     if ($this->_id) {
         $params['id'] = $this->_id;
     } else {
         $session = CRM_Core_Session::singleton();
         $params['created_id'] = $session->get('userID');
         $params['created_date'] = CRM_Utils_Date::processDate(date("Y-m-d"), date("H:i:s"));
     }
     // always create with data entry status
     $params['status_id'] = CRM_Core_OptionGroup::getValue('batch_status', 'Data Entry', 'name');
     $batch = CRM_Batch_BAO_Batch::create($params);
     // redirect to batch entry page.
     $session = CRM_Core_Session::singleton();
     if ($this->_action & CRM_Core_Action::ADD) {
         $session->replaceUserContext(CRM_Utils_System::url('civicrm/batch/entry', "id={$batch->id}&reset=1&action=add"));
     } else {
         $session->replaceUserContext(CRM_Utils_System::url('civicrm/batch/entry', "id={$batch->id}&reset=1"));
     }
 }
 /**
  * Form submission of new/edit api is processed.
  *
  * @access public
  *
  * @return None
  */
 public function postProcess()
 {
     //get the submitted values in an array
     $params = $this->controller->exportValues($this->_name);
     // Save the API Key & Save the Security Key
     if (CRM_Utils_Array::value('api_key', $params)) {
         CRM_Core_BAO_Setting::setItem($params['api_key'], self::MC_SETTING_GROUP, 'api_key');
     }
     $session = CRM_Core_Session::singleton();
     $message = "Api Key has been Saved!";
     $session->setStatus($message, ts('Api Key Saved'), 'success');
     $urlParams = null;
     $session->replaceUserContext(CRM_Utils_System::url('civicrm/mailchimp/apikeyregister', $urlParams));
     try {
         $mcClient = new Mailchimp($params['api_key']);
         $mcHelper = new Mailchimp_Helper($mcClient);
         $details = $mcHelper->accountDetails();
     } catch (Mailchimp_Invalid_ApiKey $e) {
         CRM_Core_Session::setStatus($e->getMessage());
         return FALSE;
     } catch (Mailchimp_HttpError $e) {
         CRM_Core_Session::setStatus($e->getMessage());
         return FALSE;
     }
     $message = "Following is the account information received from API callback:<br/>\n        <table class='mailchimp-table'>\n        <tr><td>Company:</td><td>{$details['contact']['company']}</td></tr>\n        <tr><td>First Name:</td><td>{$details['contact']['fname']}</td></tr>\n        <tr><td>Last Name:</td><td>{$details['contact']['lname']}</td></tr>\n        </table>";
     CRM_Core_Session::setStatus($message);
 }
Beispiel #11
0
 function run()
 {
     require_once 'CRM/Utils/Request.php';
     require_once 'CRM/Core/DAO.php';
     $eid = CRM_Utils_Request::retrieve('eid', 'Positive', $this, true);
     $fid = CRM_Utils_Request::retrieve('fid', 'Positive', $this, false);
     $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, true);
     $quest = CRM_Utils_Request::retrieve('quest', 'String', $this);
     $action = CRM_Utils_Request::retrieve('action', 'String', $this);
     require_once 'CRM/Core/BAO/File.php';
     list($path, $mimeType) = CRM_Core_BAO_File::path($id, $eid, null, $quest);
     if (!$path) {
         CRM_Core_Error::statusBounce('Could not retrieve the file');
     }
     $buffer = file_get_contents($path);
     if (!$buffer) {
         CRM_Core_Error::statusBounce('The file is either empty or you do not have permission to retrieve the file');
     }
     if ($action & CRM_Core_Action::DELETE) {
         if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', CRM_Core_DAO::$_nullObject)) {
             CRM_Core_BAO_File::delete($id, $eid, $fid);
             CRM_Core_Session::setStatus(ts('The attached file has been deleted.'));
             $session = CRM_Core_Session::singleton();
             $toUrl = $session->popUserContext();
             CRM_Utils_System::redirect($toUrl);
         } else {
             $wrapper = new CRM_Utils_Wrapper();
             return $wrapper->run('CRM_Custom_Form_DeleteFile', ts('Domain Information Page'), null);
         }
     } else {
         require_once 'CRM/Utils/File.php';
         CRM_Utils_System::download(CRM_Utils_File::cleanFileName(basename($path)), $mimeType, $buffer);
     }
 }
Beispiel #12
0
 /**
  * @return string
  */
 function run()
 {
     $errorMessage = '';
     // ensure that all CiviCRM tables are InnoDB, else abort
     // this is not a very fast operation, so we do it randomly 10% of the times
     // but we do it for most / all tables
     // http://bugs.mysql.com/bug.php?id=43664
     if (rand(1, 10) == 3 && CRM_Core_DAO::isDBMyISAM(150)) {
         $errorMessage = ts('Your database is configured to use the MyISAM database engine. CiviCRM requires InnoDB. You will need to convert any MyISAM tables in your database to InnoDB. Using MyISAM tables will result in data integrity issues.');
         CRM_Core_Session::setStatus($errorMessage, ts('Warning'), "alert");
     }
     if (!CRM_Utils_System::isDBVersionValid($errorMessage)) {
         CRM_Core_Session::setStatus($errorMessage, ts('Warning'), "alert", array('expires' => 0));
     }
     $groups = array('Customize Data and Screens' => ts('Customize Data and Screens'), 'Communications' => ts('Communications'), 'Localization' => ts('Localization'), 'Users and Permissions' => ts('Users and Permissions'), 'System Settings' => ts('System Settings'));
     $config = CRM_Core_Config::singleton();
     if (in_array('CiviContribute', $config->enableComponents)) {
         $groups['CiviContribute'] = ts('CiviContribute');
     }
     if (in_array('CiviMember', $config->enableComponents)) {
         $groups['CiviMember'] = ts('CiviMember');
     }
     if (in_array('CiviEvent', $config->enableComponents)) {
         $groups['CiviEvent'] = ts('CiviEvent');
     }
     if (in_array('CiviMail', $config->enableComponents)) {
         $groups['CiviMail'] = ts('CiviMail');
     }
     if (in_array('CiviCase', $config->enableComponents)) {
         $groups['CiviCase'] = ts('CiviCase');
     }
     if (in_array('CiviReport', $config->enableComponents)) {
         $groups['CiviReport'] = ts('CiviReport');
     }
     if (in_array('CiviCampaign', $config->enableComponents)) {
         $groups['CiviCampaign'] = ts('CiviCampaign');
     }
     $values = CRM_Core_Menu::getAdminLinks();
     $this->_showHide = new CRM_Core_ShowHideBlocks();
     foreach ($groups as $group => $title) {
         $groupId = str_replace(' ', '_', $group);
         $this->_showHide->addShow("id_{$groupId}_show");
         $this->_showHide->addHide("id_{$groupId}");
         $v = CRM_Core_ShowHideBlocks::links($this, $groupId, '', '', FALSE);
         if (isset($values[$group])) {
             $adminPanel[$groupId] = $values[$group];
             $adminPanel[$groupId]['show'] = $v['show'];
             $adminPanel[$groupId]['hide'] = $v['hide'];
             $adminPanel[$groupId]['title'] = $title;
         } else {
             $adminPanel[$groupId] = array();
             $adminPanel[$groupId]['show'] = '';
             $adminPanel[$groupId]['hide'] = '';
             $adminPanel[$groupId]['title'] = $title;
         }
     }
     $this->assign('adminPanel', $adminPanel);
     $this->_showHide->addToTemplate();
     return parent::run();
 }
 /**
  * Function to process the form
  *
  * @access public
  *
  * @return None
  */
 public function postProcess()
 {
     $params = $this->controller->exportValues($this->_name);
     if (self::updateSettingsWithDAO($params)) {
         CRM_Core_Session::setStatus(ts('Training settings saved.'));
     }
 }
 /**
  * Method to process civicrm pre hook:
  * If objectName = GroupContact and Group is a protected group, check if user has permission.
  * When user does not have permission, redirect to user context with status message
  *
  */
 public static function pre($op, $objectName, $objectId, $params)
 {
     if ($objectName == 'GroupContact' && self::groupIsProtected($objectId) == TRUE) {
         // check if request is from webform, and allow groupcontact action if from webform
         $webFormRequest = FALSE;
         $request = CRM_Utils_Request::exportValues();
         if (isset($request['form_id'])) {
             $requestParts = explode('_', $request['form_id']);
             if (isset($requestParts[2])) {
                 if ($requestParts[0] == 'webform' && $requestParts[1] == 'client' && ($requestParts[2] = 'form')) {
                     $webFormRequest = TRUE;
                 }
             }
         }
         if (!$webFormRequest) {
             if (!CRM_Core_Permission::check('manage protected groups')) {
                 CRM_Core_Session::setStatus(ts("You are not allowed to add or remove contacts to this group"), ts("Not allowed"), "error");
                 // if from report, redirect to report instance
                 if (isset($request['q']) && substr($request['q'], 0, 15) == "civicrm/report/") {
                     CRM_Utils_System::redirect(CRM_Utils_System::url($request['q'], 'reset=1', true));
                 } else {
                     $session = CRM_Core_Session::singleton();
                     CRM_Utils_System::redirect($session->readUserContext());
                 }
             }
         }
     }
 }
Beispiel #15
0
 function buildForm(&$form)
 {
     $groups =& CRM_Core_PseudoConstant::group();
     $tags =& CRM_Core_PseudoConstant::tag();
     if (count($groups) == 0 || count($tags) == 0) {
         CRM_Core_Session::setStatus(ts("Atleast one Group and Tag must be present, for Custom Group / Tag search."));
         $url = CRM_Utils_System::url('civicrm/contact/search/custom/list', 'reset=1');
         CRM_Utils_System::redirect($url);
     }
     $inG =& $form->addElement('advmultiselect', 'includeGroups', ts('Include Group(s)') . ' ', $groups, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect'));
     $outG =& $form->addElement('advmultiselect', 'excludeGroups', ts('Exclude Group(s)') . ' ', $groups, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect'));
     $andOr =& $form->addElement('checkbox', 'andOr', 'Combine With (AND, Uncheck For OR)', null, array('checked' => 'checked'));
     $int =& $form->addElement('advmultiselect', 'includeTags', ts('Include Tag(s)') . ' ', $tags, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect'));
     $outt =& $form->addElement('advmultiselect', 'excludeTags', ts('Exclude Tag(s)') . ' ', $tags, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect'));
     //add/remove buttons for groups
     $inG->setButtonAttributes('add', array('value' => ts('Add >>')));
     $outG->setButtonAttributes('add', array('value' => ts('Add >>')));
     $inG->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     $outG->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     //add/remove buttons for tags
     $int->setButtonAttributes('add', array('value' => ts('Add >>')));
     $outt->setButtonAttributes('add', array('value' => ts('Add >>')));
     $int->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     $outt->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     /**
      * if you are using the standard template, this array tells the template what elements
      * are part of the search criteria
      */
     $form->assign('elements', array('includeGroups', 'excludeGroups', 'andOr', 'includeTags', 'excludeTags'));
 }
 /**
  * Add relationships from form.
  */
 public function addRelationships()
 {
     if (!is_array($this->_contactIds)) {
         // Could this really happen?
         return;
     }
     $relationshipTypeParts = explode('_', $this->params['relationship_type_id']);
     $params = array('relationship_type_id' => $relationshipTypeParts[0], 'is_active' => 1);
     $secondaryRelationshipSide = $relationshipTypeParts[1];
     $primaryRelationshipSide = $relationshipTypeParts[2];
     $primaryFieldName = 'contact_id_' . $primaryRelationshipSide;
     $secondaryFieldName = 'contact_id_' . $secondaryRelationshipSide;
     $relationshipLabel = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', $params['relationship_type_id'], "label_{$secondaryRelationshipSide}_{$primaryRelationshipSide}");
     $params[$secondaryFieldName] = $this->_contactIds;
     $params[$primaryFieldName] = $this->params['contact_check'];
     $outcome = CRM_Contact_BAO_Relationship::createMultiple($params, $primaryRelationshipSide);
     $relatedContactName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $params[$primaryFieldName], 'display_name');
     $status = array(ts('%count %2 %3 relationship created', array('count' => $outcome['valid'], 'plural' => '%count %2 %3 relationships created', 2 => $relationshipLabel, 3 => $relatedContactName)));
     if ($outcome['duplicate']) {
         $status[] = ts('%count was skipped because the contact is already %2 %3', array('count' => $outcome['duplicate'], 'plural' => '%count were skipped because the contacts are already %2 %3', 2 => $relationshipLabel, 3 => $relatedContactName));
     }
     if ($outcome['invalid']) {
         $status[] = ts('%count relationship was not created because the contact is not of the right type for this relationship', array('count' => $outcome['invalid'], 'plural' => '%count relationships were not created because the contact is not of the right type for this relationship'));
     }
     $status = '<ul><li>' . implode('</li><li>', $status) . '</li></ul>';
     CRM_Core_Session::setStatus($status, ts('Relationship created.', array('count' => $outcome['valid'], 'plural' => 'Relationships created.')), 'success', array('expires' => 0));
 }
 static function postProcess(&$form)
 {
     $values = $form->exportValues();
     $teamId = $values['pcp_team_contact'];
     $teampcpId = CRM_Pcpteams_Utils::getPcpIdByContactAndEvent($form->get('component_page_id'), $teamId);
     $userId = CRM_Pcpteams_Utils::getloggedInUserId();
     // Create Team Member of relation to this Team
     $cfpcpab = CRM_Pcpteams_Utils::getPcpABCustomFieldId();
     $cfpcpba = CRM_Pcpteams_Utils::getPcpBACustomFieldId();
     $customParams = array("custom_{$cfpcpab}" => $form->get('page_id'), "custom_{$cfpcpba}" => $teampcpId);
     CRM_Pcpteams_Utils::createTeamRelationship($userId, $teamId, $customParams);
     $form->_teamName = CRM_Contact_BAO_Contact::displayName($teamId);
     $form->set('teamName', $form->_teamName);
     $form->set('teamContactID', $teamId);
     $form->set('teamPcpId', $teampcpId);
     $teamAdminId = CRM_Pcpteams_Utils::getTeamAdmin($teampcpId);
     // Team Join: create activity
     $actParams = array('target_contact_id' => $teamId, 'assignee_contact_id' => $teamAdminId);
     CRM_Pcpteams_Utils::createPcpActivity($actParams, CRM_Pcpteams_Constant::C_AT_REQ_MADE);
     CRM_Core_Session::setStatus(ts('A notification has been sent to the team. Once approved, team should be visible on your page.'), ts('Team Request Sent'));
     //send email once the team request has done.
     list($teamAdminName, $teamAdminEmail) = CRM_Contact_BAO_Contact::getContactDetails($teamAdminId);
     $contactDetails = civicrm_api('Contact', 'get', array('version' => 3, 'sequential' => 1, 'id' => $userId));
     $emailParams = array('tplParams' => array('teamAdminName' => $teamAdminName, 'userFirstName' => $contactDetails['values'][0]['first_name'], 'userlastName' => $contactDetails['values'][0]['last_name'], 'teamName' => $form->_teamName, 'pageURL' => CRM_Utils_System::url('civicrm/pcp/manage', "reset=1&id={$teampcpId}", TRUE, NULL, FALSE, TRUE)), 'email' => array($teamAdminName => array('first_name' => $teamAdminName, 'last_name' => $teamAdminName, 'email-Primary' => $teamAdminEmail, 'display_name' => $teamAdminName)), 'valueName' => CRM_Pcpteams_Constant::C_MSG_TPL_JOIN_REQUEST);
     $sendEmail = CRM_Pcpteams_Utils::sendMail($userId, $emailParams);
 }
Beispiel #18
0
 public function run()
 {
     $eid = CRM_Utils_Request::retrieve('eid', 'Positive', $this, TRUE);
     $fid = CRM_Utils_Request::retrieve('fid', 'Positive', $this, FALSE);
     $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
     $quest = CRM_Utils_Request::retrieve('quest', 'String', $this);
     $action = CRM_Utils_Request::retrieve('action', 'String', $this);
     list($path, $mimeType) = CRM_Core_BAO_File::path($id, $eid, NULL, $quest);
     if (!$path) {
         CRM_Core_Error::statusBounce('Could not retrieve the file');
     }
     $buffer = file_get_contents($path);
     if (!$buffer) {
         CRM_Core_Error::statusBounce('The file is either empty or you do not have permission to retrieve the file');
     }
     if ($action & CRM_Core_Action::DELETE) {
         if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', CRM_Core_DAO::$_nullObject)) {
             CRM_Core_BAO_File::deleteFileReferences($id, $eid, $fid);
             CRM_Core_Session::setStatus(ts('The attached file has been deleted.'), ts('Complete'), 'success');
             $session = CRM_Core_Session::singleton();
             $toUrl = $session->popUserContext();
             CRM_Utils_System::redirect($toUrl);
         }
     } else {
         CRM_Utils_System::download(CRM_Utils_File::cleanFileName(basename($path)), $mimeType, $buffer);
     }
 }
Beispiel #19
0
 /**
  * run this page (figure out the action needed and perform it).
  *
  * @return void
  */
 function run()
 {
     $instanceId = CRM_Report_Utils_Report::getInstanceID();
     $action = CRM_Utils_Request::retrieve('action', 'String', $this);
     $optionVal = CRM_Report_Utils_Report::getValueFromUrl($instanceId);
     $reportUrl = CRM_Utils_System::url('civicrm/report/list', "reset=1");
     if ($action & CRM_Core_Action::DELETE) {
         if (!CRM_Core_Permission::check('administer Reports')) {
             $statusMessage = ts('Your do not have permission to Delete Report.');
             CRM_Core_Error::statusBounce($statusMessage, $reportUrl);
         }
         CRM_Report_BAO_Instance::delete($instanceId);
         CRM_Core_Session::setStatus(ts('Selected Instance has been deleted.'));
     } else {
         require_once 'CRM/Core/OptionGroup.php';
         $templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', "{$optionVal}", 'value');
         if (strstr($templateInfo['name'], '_Form')) {
             $instanceInfo = array();
             CRM_Report_BAO_Instance::retrieve(array('id' => $instanceId), $instanceInfo);
             if (!empty($instanceInfo['title'])) {
                 CRM_Utils_System::setTitle($instanceInfo['title']);
                 $this->assign('reportTitle', $instanceInfo['title']);
             } else {
                 CRM_Utils_System::setTitle($templateInfo['label']);
                 $this->assign('reportTitle', $templateInfo['label']);
             }
             $wrapper =& new CRM_Utils_Wrapper();
             return $wrapper->run($templateInfo['name'], null, null);
         }
         CRM_Core_Session::setStatus(ts('Could not find template for the instance.'));
     }
     return CRM_Utils_System::redirect($reportUrl);
 }
 function postProcess()
 {
     // define some stats
     $activities_total = count($this->_activityHolderIds);
     $activities_processed = 0;
     $activities_detected = 0;
     $activities_fixed = 0;
     // filter for relevant activities
     $activity_type_id = (int) CRM_Householdmerge_Logic_Configuration::getCheckHouseholdActivityTypeID();
     $activity_status_ids = CRM_Householdmerge_Logic_Configuration::getFixableActivityStatusIDs();
     $activity_ids = implode(',', $this->_activityHolderIds);
     $filter_query = "SELECT id AS activity_id FROM civicrm_activity\n                     WHERE civicrm_activity.activity_type_id = {$activity_type_id} \n                       AND civicrm_activity.status_id IN ({$activity_status_ids})\n                       AND civicrm_activity.id IN ({$activity_ids});";
     $filtered_activities = CRM_Core_DAO::executeQuery($filter_query);
     // go through all activites and try to fix them
     while ($filtered_activities->fetch()) {
         $activities_processed += 1;
         $problem = CRM_Householdmerge_Logic_Problem::extractProblem($filtered_activities->activity_id);
         if ($problem) {
             $activities_detected += 1;
             if ($problem->fix()) {
                 $activities_fixed += 1;
             }
         }
     }
     // show stats
     CRM_Core_Session::setStatus(ts('%1 of the %2 selected activities were processed, %3 of them could be fixed.', array(1 => $activities_detected, 2 => $activities_total, 3 => $activities_fixed, 'domain' => 'de.systopia.householdmerge')), ts('%1 Household Problems Fixed', array(1 => $activities_fixed, 'domain' => 'de.systopia.householdmerge')), $activities_fixed > 0 ? 'info' : 'warn');
     parent::postProcess();
 }
Beispiel #21
0
 public function invalidKey()
 {
     $message = ts('Because your session timed out, we have reset the search page.');
     CRM_Core_Session::setStatus($message);
     // see if we can figure out the url and redirect to the right search form
     // note that this happens really early on, so we cant use any of the form or controller
     // variables
     $config = CRM_Core_Config::singleton();
     $qString = $_GET[$config->userFrameworkURLVar];
     $args = "reset=1";
     $path = 'civicrm/contact/search/advanced';
     if (strpos($qString, 'basic') !== FALSE) {
         $path = 'civicrm/contact/search/basic';
     } else {
         if (strpos($qString, 'builder') !== FALSE) {
             $path = 'civicrm/contact/search/builder';
         } else {
             if (strpos($qString, 'custom') !== FALSE && isset($_REQUEST['csid'])) {
                 $path = 'civicrm/contact/search/custom';
                 $args = "reset=1&csid={$_REQUEST['csid']}";
             }
         }
     }
     $url = CRM_Utils_System::url($path, $args);
     CRM_Utils_System::redirect($url);
 }
Beispiel #22
0
 public function postProcess()
 {
     $values = $this->exportValues();
     $options = $this->getColorOptions();
     CRM_Core_Session::setStatus(ts('You picked color "%1"', array(1 => $options[$values['favorite_color']])));
     parent::postProcess();
 }
Beispiel #23
0
 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     if ($this->_action == CRM_Core_Action::DELETE) {
         if ($this->_id && ($tag = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $this->_id, 'name', 'parent_id'))) {
             CRM_Core_Session::setStatus(ts("This tag cannot be deleted! You must Delete all its child tags ('%1', etc) prior to deleting this tag.", array(1 => $tag)));
             $url = CRM_Utils_System::url('civicrm/admin/tag', "reset=1");
             CRM_Utils_System::redirect($url);
             return true;
         } else {
             $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
         }
     } else {
         $this->applyFilter('__ALL__', 'trim');
         $this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Tag', 'name'), true);
         $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array('CRM_Core_DAO_Tag', $this->_id));
         $this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Tag', 'description'));
         //@lobo haven't a clue why the checkbox isn't displayed (it should be checked by default
         $this->add('checkbox', 'is_selectable', ts("If it's a tag or a category"));
         $allTag = array('' => '- ' . ts('select') . ' -') + CRM_Core_PseudoConstant::tag();
         if ($this->_id) {
             unset($allTag[$this->_id]);
         }
         $this->add('select', 'parent_id', ts('Parent Tag'), $allTag);
         parent::buildQuickForm();
     }
 }
 function __construct()
 {
     // don’t display the ‘Add these Contacts to Group’ button
     $this->_add2groupSupported = FALSE;
     $dsn = defined('CIVICRM_LOGGING_DSN') ? DB::parseDSN(CIVICRM_LOGGING_DSN) : DB::parseDSN(CIVICRM_DSN);
     $this->db = $dsn['database'];
     $this->log_conn_id = CRM_Utils_Request::retrieve('log_conn_id', 'Integer', CRM_Core_DAO::$_nullObject);
     $this->log_date = CRM_Utils_Request::retrieve('log_date', 'String', CRM_Core_DAO::$_nullObject);
     $this->cid = CRM_Utils_Request::retrieve('cid', 'Integer', CRM_Core_DAO::$_nullObject);
     $this->raw = CRM_Utils_Request::retrieve('raw', 'Boolean', CRM_Core_DAO::$_nullObject);
     parent::__construct();
     CRM_Utils_System::resetBreadCrumb();
     $breadcrumb = array(array('title' => ts('Home'), 'url' => CRM_Utils_System::url()), array('title' => ts('CiviCRM'), 'url' => CRM_Utils_System::url('civicrm', 'reset=1')), array('title' => ts('View Contact'), 'url' => CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->cid}")), array('title' => ts('Search Results'), 'url' => CRM_Utils_System::url('civicrm/contact/search', "force=1")));
     CRM_Utils_System::appendBreadCrumb($breadcrumb);
     if (CRM_Utils_Request::retrieve('revert', 'Boolean', CRM_Core_DAO::$_nullObject)) {
         $reverter = new CRM_Logging_Reverter($this->log_conn_id, $this->log_date);
         $reverter->revert($this->tables);
         CRM_Core_Session::setStatus(ts('The changes have been reverted.'));
         if ($this->cid) {
             CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/view', "reset=1&selectedChild=log&cid={$this->cid}", FALSE, NULL, FALSE));
         } else {
             CRM_Utils_System::redirect(CRM_Report_Utils_Report::getNextUrl($this->summary, 'reset=1', FALSE, TRUE));
         }
     }
     // make sure the report works even without the params
     if (!$this->log_conn_id or !$this->log_date) {
         $dao = new CRM_Core_DAO();
         $dao->query("SELECT log_conn_id, log_date FROM `{$this->db}`.log_{$this->tables[0]} WHERE log_action = 'Update' ORDER BY log_date DESC LIMIT 1");
         $dao->fetch();
         $this->log_conn_id = $dao->log_conn_id;
         $this->log_date = $dao->log_date;
     }
     $this->_columnHeaders = array('field' => array('title' => ts('Field')), 'from' => array('title' => ts('Changed From')), 'to' => array('title' => ts('Changed To')));
 }
Beispiel #25
0
 function buildForm(&$form)
 {
     $this->setTitle(ts('Include / Exclude Search'));
     $groups = CRM_Core_PseudoConstant::group();
     $tags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
     if (count($groups) == 0 || count($tags) == 0) {
         CRM_Core_Session::setStatus(ts("At least one Group and Tag must be present for Custom Group / Tag search."), ts('Missing Group/Tag'));
         $url = CRM_Utils_System::url('civicrm/contact/search/custom/list', 'reset=1');
         CRM_Utils_System::redirect($url);
     }
     $inG =& $form->addElement('advmultiselect', 'includeGroups', ts('Include Group(s)') . ' ', $groups, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect'));
     $outG =& $form->addElement('advmultiselect', 'excludeGroups', ts('Exclude Group(s)') . ' ', $groups, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect'));
     $andOr = array('1' => ts('Show contacts that meet the Groups criteria AND the Tags criteria'), '0' => ts('Show contacts that meet the Groups criteria OR  the Tags criteria'));
     $form->addRadio('andOr', ts('AND/OR'), $andOr, NULL, '<br />', TRUE);
     $int =& $form->addElement('advmultiselect', 'includeTags', ts('Include Tag(s)') . ' ', $tags, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect'));
     $outt =& $form->addElement('advmultiselect', 'excludeTags', ts('Exclude Tag(s)') . ' ', $tags, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect'));
     //add/remove buttons for groups
     $inG->setButtonAttributes('add', array('value' => ts('Add >>')));
     $outG->setButtonAttributes('add', array('value' => ts('Add >>')));
     $inG->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     $outG->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     //add/remove buttons for tags
     $int->setButtonAttributes('add', array('value' => ts('Add >>')));
     $outt->setButtonAttributes('add', array('value' => ts('Add >>')));
     $int->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     $outt->setButtonAttributes('remove', array('value' => ts('<< Remove')));
     /**
      * if you are using the standard template, this array tells the template what elements
      * are part of the search criteria
      */
     $form->assign('elements', array('includeGroups', 'excludeGroups', 'andOr', 'includeTags', 'excludeTags'));
 }
 public function postProcess()
 {
     $values = $this->exportValues();
     $utils = new CRM_Eventpermissions_Utils();
     $utils->setHostId($values['permission_role']);
     CRM_Core_Session::setStatus(ts('Permissioned role(s) updated.', array('domain' => 'com.aghstrategies.eventpermissions')));
     parent::postProcess();
 }
 function postProcess()
 {
     $values = $this->exportValues();
     civicrm_api3('setting', 'create', array('sequential' => 1, 'default_wci_profile' => $values['default_profile']));
     civicrm_api3('setting', 'create', array('sequential' => 1, 'widget_cache_timeout' => $values['widget_cache_timeout']));
     CRM_Core_Session::setStatus(ts('Widget settings are saved to database'), '', 'success');
     parent::postProcess();
 }
Beispiel #28
0
 function postProcess()
 {
     $vals = $this->controller->exportValues($this->_name);
     CRM_Core_Session::setStatus(ts('You saved a new room </br>' . 'label: %1 </br>' . 'room_no: %2 </br>' . 'floor: %3 </br>' . 'ext: %4', array(1 => $vals['label'], 2 => $vals['room_no'], 3 => $vals['floor'], 4 => $vals['ext'])));
     $query = "INSERT INTO civicrm_room (label, room_no, floor, ext) " . "VALUES ('{$vals['label']}', '{$vals['room_no']}', '{$vals['floor']}','{$vals['ext']}')";
     $count = CRM_Core_DAO::singleValueQuery($query);
     parent::postProcess();
 }
 /**
  * Process the form when submitted
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     if (CRM_Price_BAO_PriceSet::deleteSet($this->_sid)) {
         CRM_Core_Session::setStatus(ts('The Price Set \'%1\' has been deleted.', array(1 => $this->_title), ts('Deleted'), 'success'));
     } else {
         CRM_Core_Session::setStatus(ts('The Price Set \'%1\' has not been deleted! You must delete all price fields in this set prior to deleting the set.', array(1 => $this->_title)), 'Unable to Delete', 'error');
     }
 }
 /**
  * Process the form when submitted
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     CRM_Core_BAO_File::delete($this->_id, $this->_eid);
     CRM_Core_Session::setStatus(ts('The attached file has been deleted.'));
     $session = CRM_Core_Session::singleton();
     $toUrl = $session->popUserContext();
     CRM_Utils_System::redirect($toUrl);
 }