/**
  * @param $entityTable
  */
 public static function preProcess($entityTable)
 {
     self::$_entityId = (int) CRM_Utils_Request::retrieve('id', 'Positive');
     self::$_entityTable = $entityTable;
     if (self::$_entityId && $entityTable) {
         $checkParentExistsForThisId = CRM_Core_BAO_RecurringEntity::getParentFor(self::$_entityId, $entityTable);
         if ($checkParentExistsForThisId) {
             self::$_hasParent = TRUE;
             self::$_parentEntityId = $checkParentExistsForThisId;
             self::$_scheduleReminderDetails = CRM_Core_BAO_RecurringEntity::getReminderDetailsByEntityId($checkParentExistsForThisId, $entityTable);
         } else {
             self::$_parentEntityId = self::$_entityId;
             self::$_scheduleReminderDetails = CRM_Core_BAO_RecurringEntity::getReminderDetailsByEntityId(self::$_entityId, $entityTable);
         }
         if (property_exists(self::$_scheduleReminderDetails, 'id')) {
             self::$_scheduleReminderID = self::$_scheduleReminderDetails->id;
         }
     }
     CRM_Core_OptionValue::getValues(array('name' => $entityTable . '_repeat_exclude_dates_' . self::$_parentEntityId), $optionValue);
     $excludeOptionValues = array();
     if (!empty($optionValue)) {
         foreach ($optionValue as $key => $val) {
             $excludeOptionValues[$val['value']] = substr(CRM_Utils_Date::mysqlToIso($val['value']), 0, 10);
         }
         self::$_excludeDateInfo = $excludeOptionValues;
     }
     // Assign variables
     $entityType = CRM_Core_DAO_AllCoreTables::getBriefName(CRM_Core_DAO_AllCoreTables::getClassForTable($entityTable));
     $tpl = CRM_Core_Smarty::singleton();
     $tpl->assign('recurringEntityType', ts($entityType));
     $tpl->assign('currentEntityId', self::$_entityId);
     $tpl->assign('entityTable', self::$_entityTable);
     $tpl->assign('scheduleReminderId', self::$_scheduleReminderID);
     $tpl->assign('hasParent', self::$_hasParent);
 }
 /**
  * Class constructor.
  */
 public 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->loggingDB = $dsn['database'];
     // used for redirect back to contact summary
     $this->cid = CRM_Utils_Request::retrieve('cid', 'Integer', CRM_Core_DAO::$_nullObject);
     $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
     $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
     $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
     $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
     $this->_logTables = array('log_civicrm_contact' => array('fk' => 'id'), 'log_civicrm_email' => array('fk' => 'contact_id', 'log_type' => 'Contact'), 'log_civicrm_phone' => array('fk' => 'contact_id', 'log_type' => 'Contact'), 'log_civicrm_address' => array('fk' => 'contact_id', 'log_type' => 'Contact'), 'log_civicrm_note' => array('fk' => 'entity_id', 'entity_table' => TRUE, 'bracket_info' => array('table' => 'log_civicrm_note', 'column' => 'subject')), 'log_civicrm_note_comment' => array('fk' => 'entity_id', 'table_name' => 'log_civicrm_note', 'joins' => array('table' => 'log_civicrm_note', 'join' => "entity_log_civireport.entity_id = fk_table.id AND entity_log_civireport.entity_table = 'civicrm_note'"), 'entity_table' => TRUE, 'bracket_info' => array('table' => 'log_civicrm_note', 'column' => 'subject')), 'log_civicrm_group_contact' => array('fk' => 'contact_id', 'bracket_info' => array('entity_column' => 'group_id', 'table' => 'log_civicrm_group', 'column' => 'title'), 'action_column' => 'status', 'log_type' => 'Group'), 'log_civicrm_entity_tag' => array('fk' => 'entity_id', 'bracket_info' => array('entity_column' => 'tag_id', 'table' => 'log_civicrm_tag', 'column' => 'name'), 'entity_table' => TRUE), 'log_civicrm_relationship' => array('fk' => 'contact_id_a', 'bracket_info' => array('entity_column' => 'relationship_type_id', 'table' => 'log_civicrm_relationship_type', 'column' => 'label_a_b')), 'log_civicrm_activity_for_target' => array('fk' => 'contact_id', 'table_name' => 'log_civicrm_activity', 'joins' => array('table' => 'log_civicrm_activity_contact', 'join' => "(entity_log_civireport.id = fk_table.activity_id AND fk_table.record_type_id = {$targetID})"), 'bracket_info' => array('entity_column' => 'activity_type_id', 'options' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE)), 'log_type' => 'Activity'), 'log_civicrm_activity_for_assignee' => array('fk' => 'contact_id', 'table_name' => 'log_civicrm_activity', 'joins' => array('table' => 'log_civicrm_activity_contact', 'join' => "entity_log_civireport.id = fk_table.activity_id AND fk_table.record_type_id = {$assigneeID}"), 'bracket_info' => array('entity_column' => 'activity_type_id', 'options' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE)), 'log_type' => 'Activity'), 'log_civicrm_activity_for_source' => array('fk' => 'contact_id', 'table_name' => 'log_civicrm_activity', 'joins' => array('table' => 'log_civicrm_activity_contact', 'join' => "entity_log_civireport.id = fk_table.activity_id AND fk_table.record_type_id = {$sourceID}"), 'bracket_info' => array('entity_column' => 'activity_type_id', 'options' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE)), 'log_type' => 'Activity'), 'log_civicrm_case' => array('fk' => 'contact_id', 'joins' => array('table' => 'log_civicrm_case_contact', 'join' => 'entity_log_civireport.id = fk_table.case_id'), 'bracket_info' => array('entity_column' => 'case_type_id', 'options' => CRM_Case_PseudoConstant::caseType('title', FALSE))));
     $logging = new CRM_Logging_Schema();
     // build _logTables for contact custom tables
     $customTables = $logging->entityCustomDataLogTables('Contact');
     foreach ($customTables as $table) {
         $this->_logTables[$table] = array('fk' => 'entity_id', 'log_type' => 'Contact');
     }
     // build _logTables for address custom tables
     $customTables = $logging->entityCustomDataLogTables('Address');
     foreach ($customTables as $table) {
         $this->_logTables[$table] = array('fk' => 'contact_id', 'joins' => array('table' => 'log_civicrm_address', 'join' => 'entity_log_civireport.entity_id = fk_table.id'), 'log_type' => 'Contact');
     }
     // Allow log tables to be extended via report hooks.
     CRM_Report_BAO_Hook::singleton()->alterLogTables($this, $this->_logTables);
     parent::__construct();
 }
Example #3
0
 /**
  * Set variables up before form is built.
  */
 public function preProcess()
 {
     $this->_mailingID = $this->get('mailing_id');
     if (!$this->_mailingID) {
         $this->_mailingID = CRM_Utils_Request::retrieve('mid', 'Integer', $this, TRUE);
     }
 }
Example #4
0
 public function preProcess()
 {
     if (!CRM_Campaign_BAO_Campaign::accessCampaign()) {
         CRM_Utils_System::permissionDenied();
     }
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add', 'REQUEST');
     $this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
     if ($this->_surveyId) {
         $this->_single = TRUE;
         $params = array('id' => $this->_surveyId);
         CRM_Campaign_BAO_Survey::retrieve($params, $surveyInfo);
         $this->_surveyTitle = $surveyInfo['title'];
         $this->assign('surveyTitle', $this->_surveyTitle);
         CRM_Utils_System::setTitle(ts('Configure Survey - %1', array(1 => $this->_surveyTitle)));
     }
     $this->assign('action', $this->_action);
     $this->assign('surveyId', $this->_surveyId);
     // when custom data is included in this page
     if (!empty($_POST['hidden_custom'])) {
         $this->set('type', 'Event');
         $this->set('entityId', $this->_surveyId);
         CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, 1, 'Survey', $this->_surveyId);
         CRM_Custom_Form_CustomData::buildQuickForm($this);
         CRM_Custom_Form_CustomData::setDefaultValues($this);
     }
     // CRM-11480, CRM-11682
     // Preload libraries required by the "Questions" tab
     CRM_UF_Page_ProfileEditor::registerProfileScripts();
     CRM_UF_Page_ProfileEditor::registerSchemas(array('IndividualModel', 'ActivityModel'));
     CRM_Campaign_Form_Survey_TabHeader::build($this);
 }
Example #5
0
 /**
  * Function to pre processing
  *
  * @return None
  * @access public
  */
 function preProcess()
 {
     $this->_rgid = CRM_Utils_Request::retrieve('id', 'Positive', $this, false, 0);
     $this->_contactType = CRM_Utils_Request::retrieve('contact_type', 'String', $this, false, 0);
     if ($this->_rgid) {
         $rgDao =& new CRM_Dedupe_DAO_RuleGroup();
         $rgDao->id = $this->_rgid;
         $rgDao->find(true);
         $this->_defaults['threshold'] = $rgDao->threshold;
         $this->_contactType = $rgDao->contact_type;
         $this->_defaults['level'] = $rgDao->level;
         $this->_defaults['name'] = $rgDao->name;
         $ruleDao =& new CRM_Dedupe_DAO_Rule();
         $ruleDao->dedupe_rule_group_id = $this->_rgid;
         $ruleDao->find();
         $count = 0;
         while ($ruleDao->fetch()) {
             $this->_defaults["where_{$count}"] = "{$ruleDao->rule_table}.{$ruleDao->rule_field}";
             $this->_defaults["length_{$count}"] = $ruleDao->rule_length;
             $this->_defaults["weight_{$count}"] = $ruleDao->rule_weight;
             $count++;
         }
     }
     $supported =& CRM_Dedupe_BAO_RuleGroup::supportedFields($this->_contactType);
     if (is_array($supported)) {
         foreach ($supported as $table => $fields) {
             foreach ($fields as $field => $title) {
                 $this->_fields["{$table}.{$field}"] = $title;
             }
         }
     }
     asort($this->_fields);
 }
 /**
  * @return $this
  */
 private function addSearchContactIdsToSession()
 {
     $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $form);
     $cacheKey = "civicrm search {$qfKey}";
     $selectedCids = CRM_Core_BAO_PrevNextCache::getSelection($cacheKey);
     $contactIds = array();
     // Set contact IDs to the IDs of contacts selected (ticked) on the search result
     foreach ($selectedCids[$cacheKey] as $selectedCid => $ignore) {
         $contactIds[$selectedCid] = $selectedCid;
     }
     // So a bit of magic happens here
     // When you instantiate a CRM_Contract_Controller_Search object, it checks to see if a qfKey is passed in the $_REQUEST
     // in our case you should see it in the GET
     // If this is passed in, the controller tries to create itself using data from the SESSION
     // that means your controller is automatically populated with search data from a previous page
     $searchController = new CRM_Contact_Controller_Search();
     $totalContacts = count($contactIds);
     if ($totalContacts <= 0) {
         $totalContacts = $searchController->get('rowCount');
     }
     // CS: This needs to be commented out because the contact IDs are irrelevant at this point.
     // If the user hasn't ticked any users then this code would just give you back the first 50 contacts
     // Better to leave the contactIds empty which tells us that nothing is actually selected
     if (!$contactIds) {
         foreach ($this->get('rows') as $contact) {
             $contactIds[$contact['contact_id']] = $contact['contact_id'];
         }
     }
     simplemail_civicrm_addToSessionScope('contactCountFromSearch', $totalContacts);
     simplemail_civicrm_addToSessionScope('contactIds', $contactIds);
     return $this;
 }
 /**
  * Call preprocess.
  */
 public function preProcess()
 {
     parent::preProcess();
     $this->_locBlockNo = CRM_Utils_Request::retrieve('locno', 'Positive', $this, TRUE, NULL, $_REQUEST);
     $this->assign('blockId', $this->_locBlockNo);
     $addressSequence = CRM_Core_BAO_Address::addressSequence();
     $this->assign('addressSequence', $addressSequence);
     $this->_values = array();
     $this->_addressId = CRM_Utils_Request::retrieve('aid', 'Positive', $this, FALSE, NULL, $_REQUEST);
     $this->_action = CRM_Core_Action::ADD;
     if ($this->_addressId) {
         $params = array('id' => $this->_addressId);
         $address = CRM_Core_BAO_Address::getValues($params, FALSE, 'id');
         $this->_values['address'][$this->_locBlockNo] = array_pop($address);
         $this->_action = CRM_Core_Action::UPDATE;
     } else {
         $this->_addressId = 0;
     }
     $this->assign('action', $this->_action);
     $this->assign('addressId', $this->_addressId);
     // parse street address, CRM-5450
     $this->_parseStreetAddress = $this->get('parseStreetAddress');
     if (!isset($this->_parseStreetAddress)) {
         $addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options');
         $this->_parseStreetAddress = FALSE;
         if (!empty($addressOptions['street_address']) && !empty($addressOptions['street_address_parsing'])) {
             $this->_parseStreetAddress = TRUE;
         }
         $this->set('parseStreetAddress', $this->_parseStreetAddress);
     }
     $this->assign('parseStreetAddress', $this->_parseStreetAddress);
 }
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     // reset action from the session
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'update');
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
     $rcid = CRM_Utils_Request::retrieve('rcid', 'Positive', $this);
     $rcid = $rcid ? "&id={$rcid}" : '';
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext(CRM_Utils_System::url('civicrm/user', "reset=1{$rcid}"));
     if ($this->_contactId) {
         $contact = new CRM_Contact_DAO_Contact();
         $contact->id = $this->_contactId;
         if (!$contact->find(TRUE)) {
             CRM_Core_Error::statusBounce(ts('contact does not exist: %1', array(1 => $this->_contactId)));
         }
         $this->_contactType = $contact->contact_type;
         // check for permissions
         if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
             CRM_Core_Error::statusBounce(ts('You do not have the necessary permission to edit this contact.'));
         }
         list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($this->_contactId);
         CRM_Utils_System::setTitle($displayName, $contactImage . ' ' . $displayName);
     } else {
         CRM_Core_Error::statusBounce(ts('Could not get a contact_id and/or contact_type'));
     }
 }
Example #9
0
 /**
  * Build all the data structures needed to build the form.
  */
 public function preProcess()
 {
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
     CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
     $context = CRM_Utils_Request::retrieve('context', 'String', $this);
     //get current client name.
     $this->assign('currentClientName', CRM_Contact_BAO_Contact::displayName($cid));
     //set the context.
     $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&force=1&cid={$cid}&selectedChild=case");
     if ($context == 'search') {
         $qfKey = CRM_Utils_Request::retrieve('key', 'String', $this);
         //validate the qfKey
         $urlParams = 'force=1';
         if (CRM_Utils_Rule::qfKey($qfKey)) {
             $urlParams .= "&qfKey={$qfKey}";
         }
         $url = CRM_Utils_System::url('civicrm/case/search', $urlParams);
     } elseif ($context == 'dashboard') {
         $url = CRM_Utils_System::url('civicrm/case', 'reset=1');
     } elseif (in_array($context, array('dashlet', 'dashletFullscreen'))) {
         $url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
     }
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext($url);
 }
Example #10
0
 public function preProcess()
 {
     $this->_type = 'unsubscribe';
     $this->_job_id = $job_id = CRM_Utils_Request::retrieve('jid', 'Integer', $this);
     $this->_queue_id = $queue_id = CRM_Utils_Request::retrieve('qid', 'Integer', $this);
     $this->_hash = $hash = CRM_Utils_Request::retrieve('h', 'String', $this);
     if (!$job_id || !$queue_id || !$hash) {
         CRM_Core_Error::fatal(ts("Missing Parameters"));
     }
     // verify that the three numbers above match
     $q = CRM_Mailing_Event_BAO_Queue::verify($job_id, $queue_id, $hash);
     if (!$q) {
         CRM_Core_Error::fatal(ts("There was an error in your request"));
     }
     list($displayName, $email) = CRM_Mailing_Event_BAO_Queue::getContactInfo($queue_id);
     $this->assign('display_name', $displayName);
     $emailMasked = CRM_Utils_String::maskEmail($email);
     $this->assign('email_masked', $emailMasked);
     $this->assign('email', $email);
     $this->_email = $email;
     $groups = CRM_Mailing_Event_BAO_Unsubscribe::unsub_from_mailing($job_id, $queue_id, $hash, TRUE);
     $this->assign('groups', $groups);
     $groupExist = NULL;
     foreach ($groups as $key => $value) {
         if ($value) {
             $groupExist = TRUE;
         }
     }
     if (!$groupExist) {
         $statusMsg = ts('Email: %1 has been successfully unsubscribed from this Mailing List/Group.', array(1 => $email));
         CRM_Core_Session::setStatus($statusMsg, '', 'fail');
     }
     $this->assign('groupExist', $groupExist);
 }
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     $this->_aid = CRM_Utils_Request::retrieve('aid', 'Positive', $this);
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     if (!$this->_id && $this->_action & CRM_Core_Action::UPDATE) {
         $this->_id = CRM_Utils_Type::escape($this->_id, 'Positive');
     }
     $url = CRM_Utils_System::url('civicrm/admin/financial/financialType/accounts', "reset=1&action=browse&aid={$this->_aid}");
     $this->_BAOName = 'CRM_Financial_BAO_FinancialTypeAccount';
     if ($this->_aid && $this->_action & CRM_Core_Action::ADD) {
         $this->_title = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $this->_aid, 'name');
         CRM_Utils_System::setTitle($this->_title . ' - ' . ts('Financial Accounts'));
         $session = CRM_Core_Session::singleton();
         $session->pushUserContext($url);
     }
     // CRM-12492
     if (!($this->_action & CRM_Core_Action::ADD)) {
         $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' "));
         $accountRelationship = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_EntityFinancialAccount', $this->_id, 'account_relationship');
         if ($accountRelationship == $relationTypeId) {
             $this->_isARFlag = TRUE;
             if ($this->_action & CRM_Core_Action::DELETE) {
                 CRM_Core_Session::setStatus(ts("Selected financial type account with 'Accounts Receivable Account is' account relationship cannot be deleted."), '', 'error');
                 CRM_Utils_System::redirect($url);
             }
         }
     }
     if ($this->_id) {
         $financialAccount = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_EntityFinancialAccount', $this->_id, 'financial_account_id');
         $fieldTitle = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialAccount', $financialAccount, 'name');
         CRM_Utils_System::setTitle($fieldTitle . ' - ' . ts('Financial Type Accounts'));
     }
     $breadCrumb = array(array('title' => ts('Financial Type Accounts'), 'url' => $url));
     CRM_Utils_System::appendBreadCrumb($breadCrumb);
 }
Example #12
0
 public function preProcess()
 {
     $this->set('searchFormName', 'Custom');
     $this->set('context', 'custom');
     $csID = CRM_Utils_Request::retrieve('csid', 'Integer', $this);
     $ssID = CRM_Utils_Request::retrieve('ssID', 'Integer', $this);
     $gID = CRM_Utils_Request::retrieve('gid', 'Integer', $this);
     list($this->_customSearchID, $this->_customSearchClass, $formValues) = CRM_Contact_BAO_SearchCustom::details($csID, $ssID, $gID);
     if (!$this->_customSearchID) {
         CRM_Core_Error::fatal('Could not get details for custom search.');
     }
     // stash this as a hidden element so we can potentially go there if the session
     // is reset but this is available in the POST
     $this->addElement('hidden', 'csid', $csID);
     if (!empty($formValues)) {
         $this->_formValues = $formValues;
     }
     // set breadcrumb to return to Custom Search listings page
     $breadCrumb = array(array('title' => ts('Custom Searches'), 'url' => CRM_Utils_System::url('civicrm/contact/search/custom/list', 'reset=1')));
     CRM_Utils_System::appendBreadCrumb($breadCrumb);
     // use the custom selector
     self::$_selectorName = 'CRM_Contact_Selector_Custom';
     $this->set('customSearchID', $this->_customSearchID);
     $this->set('customSearchClass', $this->_customSearchClass);
     parent::preProcess();
     // instantiate the new class
     $this->_customClass = new $this->_customSearchClass($this->_formValues);
     // CRM-12747
     if (isset($this->_customClass->_permissionedComponent) && !self::isPermissioned($this->_customClass->_permissionedComponent)) {
         CRM_Utils_System::permissionDenied();
     }
 }
Example #13
0
 /**
  * set up variables to build the form
  *
  * @return void
  * @acess protected
  */
 function preProcess()
 {
     $this->_srcFID = CRM_Utils_Request::retrieve('fid', 'Positive', $this, true);
     $this->_srcGID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $this->_srcFID, 'custom_group_id');
     $this->_label = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $this->_srcFID, 'label');
     CRM_Utils_System::setTitle(ts('Custom Field Move: %1', array(1 => $this->_label)));
 }
Example #14
0
 /** 
  * Function to set variables up before form is built 
  *                                                           
  * @return void 
  * @access public
  */
 public function preProcess()
 {
     $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->assign('action', $this->_action);
     $this->assign('context', $this->_context);
     //check permission for action.
     if (!CRM_Core_Permission::checkActionPermission('CiviGrant', $this->_action)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
     }
     if ($this->_action & CRM_Core_Action::DELETE) {
         return;
     }
     $this->_noteId = null;
     if ($this->_id) {
         require_once 'CRM/Core/BAO/Note.php';
         $noteDAO = new CRM_Core_BAO_Note();
         $noteDAO->entity_table = 'civicrm_grant';
         $noteDAO->entity_id = $this->_id;
         if ($noteDAO->find(true)) {
             $this->_noteId = $noteDAO->id;
         }
     }
     //build custom data
     CRM_Custom_Form_Customdata::preProcess($this, null, null, 1, 'Grant', $this->_id);
 }
 /**
  * This function is called prior to building and submitting the form
  */
 function preProcess()
 {
     // check contact_id
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     if (empty($this->_contactId)) {
         CRM_Core_Error::statusBounce(ts('Could not get a contact id.'), NULL, ts('Lidmaatschap Wijziging - Contact'));
         // this also redirects to the default civicrm page
     }
     // check for permissions
     $session = CRM_Core_Session::singleton();
     if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
         CRM_Core_Error::statusBounce(ts('You do not have the necessary permission to edit this contact.'), NULL, ts('Lidmaatschap Wijziging - Contact'));
         // this also redirects to the default civicrm page
     }
     // get request
     $this->_request = CRM_Utils_Request::retrieve('request', 'String', $this, FALSE, 'choose');
     // get session
     $session = CRM_Core_Session::singleton();
     // get values
     $this->_configRelationship = CRM_Lidmaatschapwijziging_ConfigRelationship::singleton($this->_contactId);
     $this->_values = $this->_configRelationship->getContact();
     // set contact id
     $this->_values['contact_id'] = $this->_contactId;
     // set display name
     $this->_display_name = $this->_values['display_name'];
     // set request
     $this->_values['request'] = $this->_request;
     // set title
     CRM_Utils_System::setTitle('LidmaatschapWijziging - Relatie - ' . $this->_values['display_name']);
     // request
     if ('empty' == $this->_request) {
     }
     if ('choose' == $this->_request) {
         // if there is no relatiosnhips then the options are empty, we
         // show a message that there are no memebrships and a submit butten to
         // go to the relationship, first we redirect them to request empty
         $relationships = $this->_configRelationship->getRelationships();
         if (empty($relationships)) {
             // redirect user
             $url = CRM_Utils_System::url('civicrm/lidmaatschapwijziging/relationship', 'reset=1&request=empty&cid=' . $this->_contactId);
             CRM_Utils_System::redirect($url);
         }
     }
     if ('update' == $this->_request) {
         // get relationship id
         $this->_relationshipId = CRM_Utils_Request::retrieve('relationship_id', 'Positive', $this);
         $this->_values['relationship_id'] = $this->_relationshipId;
         // get relationship
         $this->_values = array_merge($this->_values, $this->_configRelationship->getRelationship($this->_relationshipId));
         if (!empty($this->_values['contact_a']['display_name'])) {
             $this->assign('sort_name_a', $this->_values['contact_a']['display_name']);
         }
         if (!empty($this->_values['contact_b']['display_name'])) {
             $this->assign('sort_name_b', $this->_values['contact_b']['display_name']);
         }
         // note
         $this->_values['note_id'] = $this->_values['notes']['id'];
         $this->_values['note'] = $this->_values['notes']['note'];
     }
 }
 /**
  * Build the form object.
  *
  * @return void
  */
 public function buildQuickForm()
 {
     // get the list of all the groups
     if ($this->_context == 'user') {
         $onlyPublicGroups = CRM_Utils_Request::retrieve('onlyPublicGroups', 'Boolean', $this, FALSE);
         $allGroups = CRM_Core_PseudoConstant::staticGroup($onlyPublicGroups);
     } else {
         $allGroups = CRM_Core_PseudoConstant::group();
     }
     // Arrange groups into hierarchical listing (child groups follow their parents and have indentation spacing in title)
     $groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($allGroups, NULL, '&nbsp;&nbsp;', TRUE);
     // get the list of groups contact is currently in ("Added") or unsubscribed ("Removed").
     $currentGroups = CRM_Contact_BAO_GroupContact::getGroupList($this->_contactId);
     // Remove current groups from drowdown options ($groupSelect)
     if (is_array($currentGroups)) {
         // Compare array keys, since the array values (group title) in $groupList may have extra spaces for indenting child groups
         $groupSelect = array_diff_key($groupHierarchy, $currentGroups);
     } else {
         $groupSelect = $groupHierarchy;
     }
     $groupSelect = array('' => ts('- select group -')) + $groupSelect;
     if (count($groupSelect) > 1) {
         $session = CRM_Core_Session::singleton();
         // user dashboard
         if (strstr($session->readUserContext(), 'user')) {
             $msg = ts('Join a Group');
         } else {
             $msg = ts('Add to a group');
         }
         $this->addField('group_id', array('class' => 'crm-action-menu action-icon-plus', 'placeholder' => $msg, 'options' => $groupSelect));
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Add'), 'isDefault' => TRUE)));
     }
 }
Example #17
0
 public function preProcess()
 {
     $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE);
     $this->_system = CRM_Utils_Request::retrieve('system', 'Boolean', $this, FALSE, TRUE);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'update');
     if (isset($action)) {
         $this->assign('action', $action);
     }
     $session = CRM_Core_Session::singleton();
     $this->_config = new CRM_Core_DAO();
     if ($this->_system) {
         if (CRM_Core_Permission::check('administer CiviCRM')) {
             $this->_contactID = NULL;
         } else {
             CRM_Utils_System::fatal('You do not have permission to edit preferences');
         }
         $this->_config->contact_id = NULL;
     } else {
         if (!$this->_contactID) {
             $this->_contactID = $session->get('userID');
             if (!$this->_contactID) {
                 CRM_Utils_System::fatal('Could not retrieve contact id');
             }
             $this->set('cid', $this->_contactID);
         }
         $this->_config->contact_id = $this->_contactID;
     }
     $settings = Civi::settings();
     foreach ($this->_varNames as $groupName => $settingNames) {
         foreach ($settingNames as $settingName => $options) {
             $this->_config->{$settingName} = $settings->get($settingName);
         }
     }
     $session->pushUserContext(CRM_Utils_System::url('civicrm/admin', 'reset=1'));
 }
Example #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);
     }
 }
Example #19
0
 /**
  * Function to pre processing
  *
  * @return None
  * @access public
  */
 function preProcess()
 {
     $this->_BAOName = CRM_Admin_Page_DupeMatch::getBAOName();
     $this->_advanced = CRM_Utils_Request::retrieve('advance', $this, false);
     $dupematch =& new CRM_Core_DAO_DupeMatch();
     $dupematch->domain_id = CRM_Core_Config::domainID();
     $dupematch->find(true);
     $id = $dupematch->id;
     $rule = $dupematch->rule;
     $tokens = preg_split('/[\\s]+/', $rule, -1, PREG_SPLIT_NO_EMPTY);
     $rule = explode(' ', $rule);
     if (count($tokens) > 9) {
         $this->_advanced = true;
     }
     foreach ($rule as $value) {
         if ($value == 'OR' || $value == '(' || $value == ')') {
             $this->_advanced = true;
         } else {
             if (substr($value, 0, 1) == '(') {
                 $this->_advanced = true;
             }
         }
     }
     $this->_id = $id;
     $this->assign('advance', $this->_advanced);
 }
 function preProcess()
 {
     parent::preProcess();
     CRM_Utils_System::setTitle(ts('Settings - Resource Configuration Option'));
     $this->_sid = CRM_Utils_Request::retrieve('sid', 'Positive', $this, FALSE, 0);
     $this->assign('sid', $this->_sid);
 }
Example #21
0
 /**
  * Function for building Event combo box
  */
 function event()
 {
     $name = trim(CRM_Utils_Type::escape($_GET['s'], 'String'));
     if (!$name) {
         $name = '%';
     }
     $whereClause = " title LIKE '{$name}%' AND ( civicrm_event.is_template IS NULL OR civicrm_event.is_template = 0 )";
     $includeOld = CRM_Utils_Request::retrieve('includeOld', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, TRUE);
     if (!$includeOld) {
         $whereClause .= " AND ( end_date IS NULL OR end_date >= NOW() )";
     }
     $query = "\n      SELECT civicrm_event.title AS title,\n        civicrm_event.id AS id,\n        civicrm_address.city AS city,\n        civicrm_event.start_date\n      FROM civicrm_event\n        LEFT JOIN civicrm_loc_block ON\n          civicrm_event.loc_block_id = civicrm_loc_block.id\n        LEFT JOIN civicrm_address ON\n          civicrm_loc_block.address_id = civicrm_address.id\n      WHERE\n        {$whereClause}\n      ORDER BY\n        civicrm_event.title\n";
     $dao = CRM_Core_DAO::executeQuery($query);
     $results = array();
     while ($dao->fetch()) {
         $fields = array();
         foreach (array('title', 'city') as $field) {
             if (isset($dao->{$field})) {
                 array_push($fields, $dao->{$field});
             }
         }
         if (isset($dao->start_date)) {
             array_push($fields, CRM_Utils_Date::customFormat($dao->start_date));
         }
         $results[$dao->id] = implode(' - ', $fields);
     }
     CRM_Core_Page_AJAX::autocompleteResults($results);
 }
 /**
  * For pre-processing
  *
  * @return void
  */
 public function preProcess()
 {
     parent::preProcess();
     $this->_key = CRM_Utils_Request::retrieve('key', 'String', $this, FALSE, 0);
     $session = CRM_Core_Session::singleton();
     $url = CRM_Utils_System::url('civicrm/admin/extensions', 'reset=1&action=browse');
     $session->pushUserContext($url);
     $this->assign('id', $this->_id);
     $this->assign('key', $this->_key);
     switch ($this->_action) {
         case CRM_Core_Action::ADD:
         case CRM_Core_Action::DELETE:
         case CRM_Core_Action::ENABLE:
         case CRM_Core_Action::DISABLE:
             $info = CRM_Extension_System::singleton()->getMapper()->keyToInfo($this->_key);
             $extInfo = CRM_Admin_Page_Extensions::createExtendedInfo($info);
             $this->assign('extension', $extInfo);
             break;
         case CRM_Core_Action::UPDATE:
             if (!CRM_Extension_System::singleton()->getBrowser()->isEnabled()) {
                 CRM_Core_Error::fatal(ts('The system administrator has disabled this feature.'));
             }
             $info = CRM_Extension_System::singleton()->getBrowser()->getExtension($this->_key);
             $extInfo = CRM_Admin_Page_Extensions::createExtendedInfo($info);
             $this->assign('extension', $extInfo);
             break;
         default:
             CRM_Core_Error::fatal(ts('Unsupported action'));
     }
 }
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     $this->_participantId = CRM_Utils_Request::retrieve('participantId', 'Positive', $this);
     $this->_cc = CRM_Utils_Request::retrieve('cc', 'String', $this);
     //get the contact and event id and assing to session.
     $values = array();
     $csContactID = NULL;
     if ($this->_participantId) {
         $params = array('id' => $this->_participantId);
         CRM_Core_DAO::commonRetrieve('CRM_Event_DAO_Participant', $params, $values, array('contact_id', 'event_id', 'status_id'));
     }
     $this->_participantStatusId = CRM_Utils_Array::value('status_id', $values);
     $this->_eventId = CRM_Utils_Array::value('event_id', $values);
     $csContactId = CRM_Utils_Array::value('contact_id', $values);
     // make sure we have right permission to edit this user
     $this->_csContactID = NULL;
     if ($csContactId && $this->_eventId) {
         $session = CRM_Core_Session::singleton();
         if ($csContactId == $session->get('userID')) {
             $this->_csContactID = $csContactId;
         } else {
             if (CRM_Contact_BAO_Contact_Permission::validateChecksumContact($csContactId, $this)) {
                 //since we have landing page so get this contact
                 //id in session if user really want to walk wizard.
                 $this->_csContactID = $csContactId;
             }
         }
     }
     if (!$this->_csContactID) {
         $config = CRM_Core_Config::singleton();
         CRM_Core_Error::statusBounce(ts('You do not have permission to access this event registration. Contact the site administrator if you need assistance.'), $config->userFrameworkBaseURL);
     }
 }
Example #24
0
 /**
  * @return string
  */
 public function run()
 {
     $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 0);
     $this->assign('action', $action);
     $this->browse();
     return parent::run();
 }
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     parent::preProcess();
     $newReminder = CRM_Utils_Request::retrieve('new', 'Boolean', $this, FALSE, FALSE);
     if ($this->_action & CRM_Core_Action::UPDATE && !$newReminder) {
         $field = 'civicrm_event';
         if ($this->_isTemplate) {
             $field = 'event_template';
         }
         $reminderList = CRM_Core_BAO_ActionSchedule::getList(FALSE, $field, $this->_id);
         if ($reminderList && is_array($reminderList)) {
             // Add action links to each of the reminders
             foreach ($reminderList as &$format) {
                 $action = CRM_Core_Action::UPDATE + CRM_Core_Action::DELETE;
                 if ($format['is_active']) {
                     $action += CRM_Core_Action::DISABLE;
                 } else {
                     $action += CRM_Core_Action::ENABLE;
                 }
                 $links = CRM_Admin_Page_ScheduleReminders::links();
                 $links[CRM_Core_Action::DELETE]['qs'] .= "&context=event&eventId={$this->_id}";
                 $links[CRM_Core_Action::UPDATE]['qs'] .= "&context=event&eventId={$this->_id}";
                 $format['action'] = CRM_Core_Action::formLink($links, $action, array('id' => $format['id']), ts('more'), FALSE, 'event.reminder.list', 'Event', $this->_id);
             }
         } else {
             $reminderList = TRUE;
         }
         $this->assign('rows', $reminderList);
         // Update tab "disabled" css class
         $this->ajaxResponse['tabValid'] = !empty($reminderList) && is_array($reminderList);
     }
 }
Example #26
0
 /**
  * Constructor.
  *
  * @param null $path
  *   The class Path of the form being implemented
  * @param bool $title
  * @param string $mode
  * @param bool $imageUpload
  * @param bool $addSequence
  *   Should we add a unique sequence number to the end of the key.
  * @param bool $ignoreKey
  *   Should we not set a qfKey for this controller (for standalone forms).
  * @param bool $attachUpload
  *
  * @return \CRM_Core_Controller_Simple
  */
 public function __construct($path, $title, $mode = NULL, $imageUpload = FALSE, $addSequence = FALSE, $ignoreKey = FALSE, $attachUpload = FALSE)
 {
     // by definition a single page is modal :). We use the form name as the scope for this controller
     parent::__construct($title, TRUE, $mode, $path, $addSequence, $ignoreKey);
     $this->_stateMachine = new CRM_Core_StateMachine($this);
     $params = array($path => NULL);
     $savedAction = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, NULL);
     if (!empty($savedAction) && $savedAction != $mode) {
         $mode = $savedAction;
     }
     $this->_stateMachine->addSequentialPages($params, $mode);
     $this->addPages($this->_stateMachine, $mode);
     //changes for custom data type File
     $uploadNames = $this->get('uploadNames');
     $config = CRM_Core_Config::singleton();
     if (is_array($uploadNames) && !empty($uploadNames)) {
         $uploadArray = $uploadNames;
         $this->addActions($config->customFileUploadDir, $uploadArray);
         $this->set('uploadNames', NULL);
     } else {
         // always allow a single upload file with same name
         if ($attachUpload) {
             $this->addActions($config->uploadDir, CRM_Core_BAO_File::uploadNames());
         } elseif ($imageUpload) {
             $this->addActions($config->imageUploadDir, array('uploadFile'));
         } else {
             $this->addActions();
         }
     }
 }
Example #27
0
 /**
  * Set default values for the form.
  * The default values are retrieved from the database.
  */
 public function setDefaultValues()
 {
     $mailingID = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE, NULL);
     $continue = CRM_Utils_Request::retrieve('continue', 'String', $this, FALSE, NULL);
     $defaults = array();
     if ($mailingID) {
         $mailing = new CRM_Mailing_DAO_Mailing();
         $mailing->id = $mailingID;
         $mailing->addSelect('name');
         $mailing->find(TRUE);
         $defaults['name'] = $mailing->name;
         if (!$continue) {
             $defaults['name'] = ts('Copy of %1', array(1 => $mailing->name));
         } else {
             // CRM-7590, reuse same mailing ID if we are continuing
             $this->set('mailing_id', $mailingID);
         }
         $dao = new CRM_Mailing_DAO_MailingGroup();
         $mailingGroups = array();
         $dao->mailing_id = $mailingID;
         $dao->find();
         while ($dao->fetch()) {
             $mailingGroups[$dao->entity_table][$dao->group_type][] = $dao->entity_id;
         }
         $defaults['includeGroups'] = $mailingGroups['civicrm_group']['Include'];
         $defaults['excludeGroups'] = CRM_Utils_Array::value('Exclude', $mailingGroups['civicrm_group']);
         $defaults['includeMailings'] = CRM_Utils_Array::value('Include', CRM_Utils_Array::value('civicrm_mailing', $mailingGroups));
         $defaults['excludeMailings'] = CRM_Utils_Array::value('Exclude', CRM_Utils_Array::value('civicrm_mailing', $mailingGroups));
     }
     return $defaults;
 }
Example #28
0
 /** 
  * Heart of the viewing process. The runner gets all the meta data for 
  * the contact and calls the appropriate type of page to view. 
  * 
  * @return void 
  * @access public 
  * 
  */
 function preProcess()
 {
     // Make sure case types have been configured for the component
     require_once 'CRM/Core/OptionGroup.php';
     $caseType = CRM_Core_OptionGroup::values('case_type');
     if (empty($caseType)) {
         $this->assign('notConfigured', 1);
         return;
     }
     $session =& CRM_Core_Session::singleton();
     $allCases = CRM_Utils_Request::retrieve('all', 'Positive', $session);
     CRM_Utils_System::setTitle(ts('CiviCase Dashboard'));
     $userID = $session->get('userID');
     if (!$allCases) {
         $this->assign('myCases', true);
     } else {
         $this->assign('myCases', false);
     }
     $this->assign('newClient', false);
     if (CRM_Core_Permission::check('add contacts')) {
         $this->assign('newClient', true);
     }
     require_once 'CRM/Case/BAO/Case.php';
     $summary = CRM_Case_BAO_Case::getCasesSummary($allCases, $userID);
     $upcoming = CRM_Case_BAO_Case::getCases($allCases, $userID, 'upcoming');
     $recent = CRM_Case_BAO_Case::getCases($allCases, $userID, 'recent');
     $this->assign('casesSummary', $summary);
     if (!empty($upcoming)) {
         $this->assign('upcomingCases', $upcoming);
     }
     if (!empty($recent)) {
         $this->assign('recentCases', $recent);
     }
 }
Example #29
0
 /**
  * Build all the data structures needed to build the form.
  *
  * @return void
  */
 public function preProcess()
 {
     $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
     if ($id) {
         $this->_contributionIds = array($id);
         $this->_componentClause = " civicrm_contribution.id IN ( {$id} ) ";
         $this->_single = TRUE;
         $this->assign('totalSelectedContributions', 1);
     } else {
         parent::preProcess();
     }
     // check that all the contribution ids have pending status
     $query = "\nSELECT count(*)\nFROM   civicrm_contribution\nWHERE  contribution_status_id != 1\nAND    {$this->_componentClause}";
     $count = CRM_Core_DAO::singleValueQuery($query);
     if ($count != 0) {
         CRM_Core_Error::statusBounce("Please select only online contributions with Completed status.");
     }
     // we have all the contribution ids, so now we get the contact ids
     parent::setContactIDs();
     $this->assign('single', $this->_single);
     $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
     $urlParams = 'force=1';
     if (CRM_Utils_Rule::qfKey($qfKey)) {
         $urlParams .= "&qfKey={$qfKey}";
     }
     $url = CRM_Utils_System::url('civicrm/contribute/search', $urlParams);
     $breadCrumb = array(array('url' => $url, 'title' => ts('Search Results')));
     CRM_Utils_System::appendBreadCrumb($breadCrumb);
     CRM_Utils_System::setTitle(ts('Print Contribution Receipts'));
 }
Example #30
0
 /**
  * called when action is update.
  *
  * @param int $groupId
  *
  * @return null
  */
 public function edit($groupId = NULL)
 {
     $this->assign('edit', $this->_edit);
     if (!$this->_edit) {
         return NULL;
     }
     $action = CRM_Utils_Request::retrieve('action', 'String', CRM_Core_DAO::$_nullObject, FALSE, 'browse');
     if ($action == CRM_Core_Action::DELETE) {
         $groupContactId = CRM_Utils_Request::retrieve('gcid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE);
         $status = CRM_Utils_Request::retrieve('st', 'String', CRM_Core_DAO::$_nullObject, TRUE);
         if (is_numeric($groupContactId) && $status) {
             CRM_Contact_Page_View_GroupContact::del($groupContactId, $status, $this->_contactId);
         }
         $url = CRM_Utils_System::url('civicrm/user', "reset=1&id={$this->_contactId}");
         CRM_Utils_System::redirect($url);
     }
     $controller = new CRM_Core_Controller_Simple('CRM_Contact_Form_GroupContact', ts("Contact's Groups"), CRM_Core_Action::ADD, FALSE, FALSE, TRUE, FALSE);
     $controller->setEmbedded(TRUE);
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext(CRM_Utils_System::url('civicrm/user', "reset=1&id={$this->_contactId}"), FALSE);
     $controller->reset();
     $controller->set('contactId', $this->_contactId);
     $controller->set('groupId', $groupId);
     $controller->set('context', 'user');
     $controller->set('onlyPublicGroups', $this->_onlyPublicGroups);
     $controller->process();
     $controller->run();
 }