/**
  * Browse all event templates.
  */
 public function browse()
 {
     //get all event templates.
     $allEventTemplates = array();
     $eventTemplate = new CRM_Event_DAO_Event();
     $eventTypes = CRM_Event_PseudoConstant::eventType();
     $participantRoles = CRM_Event_PseudoConstant::participantRole();
     $participantListings = CRM_Event_PseudoConstant::participantListing();
     //find all event templates.
     $eventTemplate->is_template = TRUE;
     $eventTemplate->find();
     while ($eventTemplate->fetch()) {
         CRM_Core_DAO::storeValues($eventTemplate, $allEventTemplates[$eventTemplate->id]);
         //get listing types.
         if ($eventTemplate->participant_listing_id) {
             $allEventTemplates[$eventTemplate->id]['participant_listing'] = $participantListings[$eventTemplate->participant_listing_id];
         }
         //get participant role
         if ($eventTemplate->default_role_id) {
             $allEventTemplates[$eventTemplate->id]['participant_role'] = $participantRoles[$eventTemplate->default_role_id];
         }
         //get event type.
         if (isset($eventTypes[$eventTemplate->event_type_id])) {
             $allEventTemplates[$eventTemplate->id]['event_type'] = $eventTypes[$eventTemplate->event_type_id];
         }
         //form all action links
         $action = array_sum(array_keys($this->links()));
         //add action links.
         $allEventTemplates[$eventTemplate->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $eventTemplate->id), ts('more'), FALSE, 'eventTemplate.manage.action', 'Event', $eventTemplate->id);
     }
     $this->assign('rows', $allEventTemplates);
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext(CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1&action=browse'));
 }
Exemple #2
0
 /**
  * Takes a bunch of params that are needed to match certain criteria and
  * retrieves the relevant objects. Typically the valid params are only
  * contact_id. We'll tweak this function to be more full featured over a period
  * of time. This is the inverse function of create. It also stores all the retrieved
  * values in the default array
  *
  * @param array $params   (reference ) an assoc array of name/value pairs
  * @param array $defaults (reference ) an assoc array to hold the flattened values
  *
  * @return object CRM_Event_BAO_ManageEvent object
  * @access public
  * @static
  */
 static function retrieve(&$params, &$defaults)
 {
     $event = new CRM_Event_DAO_Event();
     $event->copyValues($params);
     if ($event->find(true)) {
         CRM_Core_DAO::storeValues($event, $defaults);
         return $event;
     }
     return null;
 }
Exemple #3
0
 /**
  * Function get the import/export fields for contribution.
  *
  * @param bool $checkPermission
  *
  * @return array
  *   Associative array of contribution fields
  */
 public static function &getFields($checkPermission = TRUE)
 {
     $fields = array();
     $fields = array_merge($fields, CRM_Event_DAO_Event::import());
     $fields = array_merge($fields, self::getParticipantFields());
     $fields = array_merge($fields, CRM_Core_DAO_Discount::export());
     return $fields;
 }
Exemple #4
0
 static function &getFields()
 {
     $fields = array();
     require_once 'CRM/Event/DAO/Event.php';
     require_once 'CRM/Core/DAO/Discount.php';
     $fields = array_merge($fields, CRM_Event_DAO_Event::import());
     $fields = array_merge($fields, self::getParticipantFields());
     $fields = array_merge($fields, CRM_Core_DAO_Discount::export());
     return $fields;
 }
 /**
  * Combine all the exportable fields from the lower level objects.
  *
  * @param bool $checkPermission
  *
  * @return array
  *   array of exportable Fields
  */
 public static function &exportableFields($checkPermission = TRUE)
 {
     if (!self::$_exportableFields) {
         if (!self::$_exportableFields) {
             self::$_exportableFields = array();
         }
         $participantFields = CRM_Event_DAO_Participant::export();
         $eventFields = CRM_Event_DAO_Event::export();
         $noteField = array('participant_note' => array('title' => 'Participant Note', 'name' => 'participant_note', 'type' => CRM_Utils_Type::T_STRING));
         $participantStatus = array('participant_status' => array('title' => 'Participant Status', 'name' => 'participant_status', 'type' => CRM_Utils_Type::T_STRING));
         $participantRole = array('participant_role' => array('title' => 'Participant Role', 'name' => 'participant_role', 'type' => CRM_Utils_Type::T_STRING));
         $discountFields = CRM_Core_DAO_Discount::export();
         $fields = array_merge($participantFields, $participantStatus, $participantRole, $eventFields, $noteField, $discountFields);
         // add custom data
         $fields = array_merge($fields, CRM_Core_BAO_CustomField::getFieldsForImport('Participant', FALSE, FALSE, FALSE, $checkPermission));
         self::$_exportableFields = $fields;
     }
     return self::$_exportableFields;
 }
Exemple #6
0
 /**
  * Updates contacts affected by the option value passed.
  *
  * @param int $optionValueId
  *   The option value id.
  * @param int $action
  *   The action describing whether prefix/suffix was UPDATED or DELETED.
  *
  * @return bool
  */
 public static function updateRecords(&$optionValueId, $action)
 {
     //finding group name
     $optionValue = new CRM_Core_DAO_OptionValue();
     $optionValue->id = $optionValueId;
     $optionValue->find(TRUE);
     $optionGroup = new CRM_Core_DAO_OptionGroup();
     $optionGroup->id = $optionValue->option_group_id;
     $optionGroup->find(TRUE);
     // group name
     $gName = $optionGroup->name;
     // value
     $value = $optionValue->value;
     // get the proper group name & affected field name
     // todo: this may no longer be needed for individuals - check inputs
     $individuals = array('gender' => 'gender_id', 'individual_prefix' => 'prefix_id', 'individual_suffix' => 'suffix_id', 'communication_style' => 'communication_style_id');
     $contributions = array('payment_instrument' => 'payment_instrument_id');
     $activities = array('activity_type' => 'activity_type_id');
     $participant = array('participant_role' => 'role_id');
     $eventType = array('event_type' => 'event_type_id');
     $aclRole = array('acl_role' => 'acl_role_id');
     $all = array_merge($individuals, $contributions, $activities, $participant, $eventType, $aclRole);
     $fieldName = '';
     foreach ($all as $name => $id) {
         if ($gName == $name) {
             $fieldName = $id;
         }
     }
     if ($fieldName == '') {
         return TRUE;
     }
     if (array_key_exists($gName, $individuals)) {
         $contactDAO = new CRM_Contact_DAO_Contact();
         $contactDAO->{$fieldName} = $value;
         $contactDAO->find();
         while ($contactDAO->fetch()) {
             if ($action == CRM_Core_Action::DELETE) {
                 $contact = new CRM_Contact_DAO_Contact();
                 $contact->id = $contactDAO->id;
                 $contact->find(TRUE);
                 // make sure dates doesn't get reset
                 $contact->birth_date = CRM_Utils_Date::isoToMysql($contact->birth_date);
                 $contact->deceased_date = CRM_Utils_Date::isoToMysql($contact->deceased_date);
                 $contact->{$fieldName} = 'NULL';
                 $contact->save();
             }
         }
         return TRUE;
     }
     if (array_key_exists($gName, $contributions)) {
         $contribution = new CRM_Contribute_DAO_Contribution();
         $contribution->{$fieldName} = $value;
         $contribution->find();
         while ($contribution->fetch()) {
             if ($action == CRM_Core_Action::DELETE) {
                 $contribution->{$fieldName} = 'NULL';
                 $contribution->save();
             }
         }
         return TRUE;
     }
     if (array_key_exists($gName, $activities)) {
         $activity = new CRM_Activity_DAO_Activity();
         $activity->{$fieldName} = $value;
         $activity->find();
         while ($activity->fetch()) {
             $activity->delete();
         }
         return TRUE;
     }
     //delete participant role, type and event type option value
     if (array_key_exists($gName, $participant)) {
         $participantValue = new CRM_Event_DAO_Participant();
         $participantValue->{$fieldName} = $value;
         if ($participantValue->find(TRUE)) {
             return FALSE;
         }
         return TRUE;
     }
     //delete event type option value
     if (array_key_exists($gName, $eventType)) {
         $event = new CRM_Event_DAO_Event();
         $event->{$fieldName} = $value;
         if ($event->find(TRUE)) {
             return FALSE;
         }
         return TRUE;
     }
     //delete acl_role option value
     if (array_key_exists($gName, $aclRole)) {
         $entityRole = new CRM_ACL_DAO_EntityRole();
         $entityRole->{$fieldName} = $value;
         $aclDAO = new CRM_ACL_DAO_ACL();
         $aclDAO->entity_id = $value;
         if ($entityRole->find(TRUE) || $aclDAO->find(TRUE)) {
             return FALSE;
         }
         return TRUE;
     }
 }
 /**
  * The function returns the component(Event/Contribute..), given the google-order-no and merchant-private-data
  *
  * @param xml     $xml_response   response send by google in xml format
  * @param array   $privateData    contains the name value pair of <merchant-private-data>
  * @param int     $orderNo        <order-total> send by google
  * @param string  $root           root of xml-response
  *
  * @return array context of this call (test, module, payment processor id)
  * @static
  */
 static function getContext($xml_response, $privateData, $orderNo, $root)
 {
     require_once 'CRM/Contribute/DAO/Contribution.php';
     $isTest = NULL;
     $module = NULL;
     if ($root == 'new-order-notification') {
         $contributionID = $privateData['contributionID'];
         $contribution = new CRM_Contribute_DAO_Contribution();
         $contribution->id = $contributionID;
         if (!$contribution->find(TRUE)) {
             CRM_Core_Error::debug_log_message("Could not find contribution record: {$contributionID}");
             echo "Failure: Could not find contribution record for {$contributionID}<p>";
             exit;
         }
         if (stristr($contribution->source, ts('Online Contribution'))) {
             $module = 'Contribute';
         } elseif (stristr($contribution->source, ts('Online Event Registration'))) {
             $module = 'Event';
         }
         $isTest = $contribution->is_test;
     } else {
         $contribution = new CRM_Contribute_DAO_Contribution();
         $contribution->invoice_id = $orderNo;
         if (!$contribution->find(TRUE)) {
             CRM_Core_Error::debug_log_message("Could not find contribution record with invoice id: {$orderNo}");
             echo "Failure: Could not find contribution record with invoice id: {$orderNo} <p>";
             exit;
         }
         if (stristr($contribution->source, ts('Online Contribution'))) {
             $module = 'Contribute';
         } elseif (stristr($contribution->source, ts('Online Event Registration'))) {
             $module = 'Event';
         }
         $isTest = $contribution->is_test;
     }
     if ($contribution->contribution_status_id == 1) {
         //contribution already handled.
         exit;
     }
     if ($module == 'Contribute') {
         if (!$contribution->contribution_page_id) {
             CRM_Core_Error::debug_log_message("Could not find contribution page for contribution record: {$contributionID}");
             echo "Failure: Could not find contribution page for contribution record: {$contributionID}<p>";
             exit;
         }
         // get the payment processor id from contribution page
         $paymentProcessorID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $contribution->contribution_page_id, 'payment_processor_id');
     } else {
         if ($root == 'new-order-notification') {
             $eventID = $privateData['eventID'];
         } else {
             list($eventID, $participantID) = explode(CRM_Core_DAO::VALUE_SEPARATOR, $contribution->trxn_id);
         }
         if (!$eventID) {
             CRM_Core_Error::debug_log_message("Could not find event ID");
             echo "Failure: Could not find eventID<p>";
             exit;
         }
         // we are in event mode
         // make sure event exists and is valid
         require_once 'CRM/Event/DAO/Event.php';
         $event = new CRM_Event_DAO_Event();
         $event->id = $eventID;
         if (!$event->find(TRUE)) {
             CRM_Core_Error::debug_log_message("Could not find event: {$eventID}");
             echo "Failure: Could not find event: {$eventID}<p>";
             exit;
         }
         // get the payment processor id from contribution page
         $paymentProcessorID = $event->payment_processor_id;
     }
     if (!$paymentProcessorID) {
         CRM_Core_Error::debug_log_message("Could not find payment processor for contribution record: {$contributionID}");
         echo "Failure: Could not find payment processor for contribution record: {$contributionID}<p>";
         exit;
     }
     return array($isTest, $module, $paymentProcessorID);
 }
Exemple #8
0
 /**
  * Function to delete the event
  *
  * @param int $id  event id
  *
  * @access public
  * @static
  *
  */
 static function del($id)
 {
     if (!$id) {
         return null;
     }
     require_once 'CRM/Utils/Hook.php';
     CRM_Utils_Hook::pre('delete', 'Event', $id, CRM_Core_DAO::$_nullArray);
     require_once 'CRM/Core/BAO/CustomGroup.php';
     $extends = array('event');
     $groupTree = CRM_Core_BAO_CustomGroup::getGroupDetail(null, null, $extends);
     foreach ($groupTree as $values) {
         $query = "DELETE FROM " . $values['table_name'] . " WHERE entity_id = " . $id;
         $params = array(1 => array($values['table_name'], 'string'), 2 => array($id, 'integer'));
         CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
     }
     $dependencies = array('CRM_Core_DAO_OptionGroup' => array('name' => 'civicrm_event.amount.' . $id), 'CRM_Core_DAO_UFJoin' => array('entity_id' => $id, 'entity_table' => 'civicrm_event'));
     require_once 'CRM/Core/BAO/OptionGroup.php';
     foreach ($dependencies as $daoName => $values) {
         require_once str_replace('_', DIRECTORY_SEPARATOR, $daoName) . ".php";
         eval('$dao = new ' . $daoName . '( );');
         if ($daoName == 'CRM_Core_DAO_OptionGroup') {
             $dao->name = $values['name'];
             $dao->find();
             while ($dao->fetch()) {
                 CRM_Core_BAO_OptionGroup::del($dao->id);
             }
         } else {
             foreach ($values as $fieldName => $fieldValue) {
                 $dao->{$fieldName} = $fieldValue;
             }
             $dao->find();
             while ($dao->fetch()) {
                 $dao->delete();
             }
         }
     }
     require_once 'CRM/Core/OptionGroup.php';
     CRM_Core_OptionGroup::deleteAssoc("civicrm_event.amount.{$id}.discount.%", "LIKE");
     // price set cleanup, CRM-5527
     require_once 'CRM/Price/BAO/Set.php';
     CRM_Price_BAO_Set::removeFrom('civicrm_event', $id);
     require_once 'CRM/Event/DAO/Event.php';
     $event = new CRM_Event_DAO_Event();
     $event->id = $id;
     if ($event->find(true)) {
         $locBlockId = $event->loc_block_id;
         $result = $event->delete();
         if (!is_null($locBlockId)) {
             self::deleteEventLocBlock($locBlockId, $id);
         }
         CRM_Utils_Hook::post('delete', 'Event', $id, $event);
         return $result;
     }
     return null;
 }
 /**
  * Function to delete the event
  *
  * @param int $id event id
  *
  * @return mixed|null
  * @access public
  * @static
  *
  */
 static function del($id)
 {
     if (!$id) {
         return NULL;
     }
     CRM_Utils_Hook::pre('delete', 'Event', $id, CRM_Core_DAO::$_nullArray);
     $extends = array('event');
     $groupTree = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, NULL, $extends);
     foreach ($groupTree as $values) {
         $query = "DELETE FROM " . $values['table_name'] . " WHERE entity_id = " . $id;
         $params = array(1 => array($values['table_name'], 'string'), 2 => array($id, 'integer'));
         CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
     }
     // price set cleanup, CRM-5527
     CRM_Price_BAO_PriceSet::removeFrom('civicrm_event', $id);
     $event = new CRM_Event_DAO_Event();
     $event->id = $id;
     if ($event->find(TRUE)) {
         $locBlockId = $event->loc_block_id;
         $result = $event->delete();
         if (!is_null($locBlockId)) {
             self::deleteEventLocBlock($locBlockId, $id);
         }
         CRM_Utils_Hook::post('delete', 'Event', $id, $event);
         return $result;
     }
     return NULL;
 }
 /**
  *
  * /**
  * The function returns the component(Event/Contribute..)and whether it is Test or not
  *
  * @param array $privateData
  *   Contains the name-value pairs of transaction related data.
  * @param int $orderNo
  *   <order-total> send by google.
  *
  * @return array
  *   context of this call (test, component, payment processor id)
  */
 public static function getContext($privateData, $orderNo)
 {
     $component = NULL;
     $isTest = NULL;
     $contributionID = $privateData['contributionID'];
     $contribution = new CRM_Contribute_DAO_Contribution();
     $contribution->id = $contributionID;
     if (!$contribution->find(TRUE)) {
         CRM_Core_Error::debug_log_message("Could not find contribution record: {$contributionID}");
         echo "Failure: Could not find contribution record for {$contributionID}<p>";
         exit;
     }
     if (stristr($contribution->source, 'Online Contribution')) {
         $component = 'contribute';
     } elseif (stristr($contribution->source, 'Online Event Registration')) {
         $component = 'event';
     }
     $isTest = $contribution->is_test;
     $duplicateTransaction = 0;
     if ($contribution->contribution_status_id == 1) {
         //contribution already handled. (some processors do two notifications so this could be valid)
         $duplicateTransaction = 1;
     }
     if ($component == 'contribute') {
         if (!$contribution->contribution_page_id) {
             CRM_Core_Error::debug_log_message("Could not find contribution page for contribution record: {$contributionID}");
             echo "Failure: Could not find contribution page for contribution record: {$contributionID}<p>";
             exit;
         }
     } else {
         $eventID = $privateData['eventID'];
         if (!$eventID) {
             CRM_Core_Error::debug_log_message("Could not find event ID");
             echo "Failure: Could not find eventID<p>";
             exit;
         }
         // we are in event mode
         // make sure event exists and is valid
         $event = new CRM_Event_DAO_Event();
         $event->id = $eventID;
         if (!$event->find(TRUE)) {
             CRM_Core_Error::debug_log_message("Could not find event: {$eventID}");
             echo "Failure: Could not find event: {$eventID}<p>";
             exit;
         }
     }
     return array($isTest, $component, $duplicateTransaction);
 }
Exemple #11
0
 /**
  * Delete the price set.
  *
  * @param int $id
  *   Price Set id.
  *
  * @return bool
  *   false if fields exist for this set, true if the
  *   set could be deleted
  *
  */
 public static function deleteSet($id)
 {
     // remove from all inactive forms
     $usedBy = self::getUsedBy($id);
     if (isset($usedBy['civicrm_event'])) {
         foreach ($usedBy['civicrm_event'] as $eventId => $unused) {
             $eventDAO = new CRM_Event_DAO_Event();
             $eventDAO->id = $eventId;
             $eventDAO->find();
             while ($eventDAO->fetch()) {
                 self::removeFrom('civicrm_event', $eventDAO->id);
             }
         }
     }
     // delete price fields
     $priceField = new CRM_Price_DAO_PriceField();
     $priceField->price_set_id = $id;
     $priceField->find();
     while ($priceField->fetch()) {
         // delete options first
         CRM_Price_BAO_PriceField::deleteField($priceField->id);
     }
     $set = new CRM_Price_DAO_PriceSet();
     $set->id = $id;
     return $set->delete();
 }
 /**
  * Testing Event Generation through Entity Recursion.
  */
 public function testEventGeneration()
 {
     //Event set initial params
     $daoEvent = new CRM_Event_DAO_Event();
     $daoEvent->title = 'Test event for Recurring Entity';
     $daoEvent->event_type_id = 3;
     $daoEvent->is_public = 1;
     $daoEvent->start_date = date('YmdHis', strtotime('2014-10-26 10:30:00'));
     $daoEvent->end_date = date('YmdHis', strtotime('2014-10-28 10:30:00'));
     $daoEvent->created_date = date('YmdHis');
     $daoEvent->is_active = 1;
     $daoEvent->save();
     $this->assertDBNotNull('CRM_Event_DAO_Event', $daoEvent->id, 'id', 'id', 'Check DB if event was created');
     //Create tell a friend for event
     $daoTellAFriend = new CRM_Friend_DAO_Friend();
     $daoTellAFriend->entity_table = 'civicrm_event';
     $daoTellAFriend->entity_id = $daoEvent->id;
     // join with event
     $daoTellAFriend->title = 'Testing tell a friend';
     $daoTellAFriend->is_active = 1;
     $daoTellAFriend->save();
     $this->assertDBNotNull('CRM_Friend_DAO_Friend', $daoTellAFriend->id, 'id', 'id', 'Check DB if tell a friend was created');
     // time to use recursion
     $recursion = new CRM_Core_BAO_RecurringEntity();
     $recursion->entity_id = $daoEvent->id;
     $recursion->entity_table = 'civicrm_event';
     $recursion->dateColumns = array('start_date');
     $recursion->schedule = array('entity_value' => $daoEvent->id, 'start_action_date' => $daoEvent->start_date, 'start_action_condition' => 'monday', 'repetition_frequency_unit' => 'week', 'repetition_frequency_interval' => 1, 'start_action_offset' => 4, 'used_for' => 'event');
     $recursion->linkedEntities = array(array('table' => 'civicrm_tell_friend', 'findCriteria' => array('entity_id' => $recursion->entity_id, 'entity_table' => 'civicrm_event'), 'linkedColumns' => array('entity_id'), 'isRecurringEntityRecord' => TRUE));
     $interval = $recursion->getInterval($daoEvent->start_date, $daoEvent->end_date);
     $recursion->intervalDateColumns = array('end_date' => $interval);
     $generatedEntities = $recursion->generate();
     $this->assertArrayHasKey('civicrm_event', $generatedEntities, 'Check if generatedEntities has civicrm_event as required key');
     $expectedDates = array('20141027103000' => '20141029103000', '20141103103000' => '20141105103000', '20141110103000' => '20141112103000', '20141117103000' => '20141119103000');
     $this->assertCount($recursion->schedule['start_action_offset'], $generatedEntities['civicrm_event'], 'Check if the number of events created are right');
     $actualDates = array();
     foreach ($generatedEntities['civicrm_event'] as $key => $val) {
         $this->assertDBNotNull('CRM_Event_DAO_Event', $val, 'id', 'id', 'Check if repeating events were created.');
         $startDate = date('YmdHis', strtotime(CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $val, 'start_date', 'id')));
         $endDate = date('YmdHis', strtotime(CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $val, 'end_date', 'id')));
         $actualDates[$startDate] = $endDate;
     }
     $resultDates = array_diff($actualDates, $expectedDates);
     $this->assertEquals(0, count($resultDates), "Check if all the value in expected array matches actual array");
     foreach ($generatedEntities['civicrm_tell_friend'] as $key => $val) {
         $this->assertDBNotNull('CRM_Friend_DAO_Friend', $val, 'id', 'id', 'Check if friends were created in loop');
         $this->assertDBCompareValue('CRM_Friend_DAO_Friend', $val, 'entity_id', 'id', $generatedEntities['civicrm_event'][$key], 'Check DB if correct FK was maintained with event for Friend');
     }
     $this->assertCount($recursion->schedule['start_action_offset'], $generatedEntities['civicrm_tell_friend'], 'Check if the number of tell a friend records are right');
     // set mode to ALL, i.e any change to changing event affects all related recurring activities
     $recursion->mode(3);
     $daoEvent->find(TRUE);
     $daoEvent->title = 'Event Changed';
     $daoEvent->save();
     // check if other events were affected
     foreach ($generatedEntities['civicrm_event'] as $entityID) {
         $this->assertDBCompareValue('CRM_Event_DAO_Event', $entityID, 'title', 'id', 'Event Changed', 'Check if title was updated');
     }
     end($generatedEntities['civicrm_event']);
     $key = key($generatedEntities['civicrm_event']);
     end($generatedEntities['civicrm_tell_friend']);
     $actKey = key($generatedEntities['civicrm_tell_friend']);
     //Check if both(event/tell a friend) keys are same
     $this->assertEquals($key, $actKey, "Check if both the keys are same");
     //Cross check event exists before we test deletion
     $searchParamsEventBeforeDelete = array('entity_id' => $generatedEntities['civicrm_event'][$key], 'entity_table' => 'civicrm_event');
     $expectedValuesEventBeforeDelete = array('entity_id' => $generatedEntities['civicrm_event'][$key], 'entity_table' => 'civicrm_event');
     $this->assertDBCompareValues('CRM_Core_DAO_RecurringEntity', $searchParamsEventBeforeDelete, $expectedValuesEventBeforeDelete);
     //Cross check event exists before we test deletion
     $searchParamsTellAFriendBeforeDelete = array('entity_id' => $generatedEntities['civicrm_tell_friend'][$actKey], 'entity_table' => 'civicrm_tell_friend');
     $expectedValuesTellAFriendBeforeDelete = array('entity_id' => $generatedEntities['civicrm_tell_friend'][$actKey], 'entity_table' => 'civicrm_tell_friend');
     $this->assertDBCompareValues('CRM_Core_DAO_RecurringEntity', $searchParamsTellAFriendBeforeDelete, $expectedValuesTellAFriendBeforeDelete);
     //Delete an event from recurring set and respective linked entity should be deleted from civicrm_recurring_entity_table
     $daoRecurEvent = new CRM_Event_DAO_Event();
     $daoRecurEvent->id = $generatedEntities['civicrm_event'][$key];
     if ($daoRecurEvent->find(TRUE)) {
         $daoRecurEvent->delete();
         $daoRecurEvent->free();
     }
     //Check if this event_id was deleted
     $this->assertDBNull('CRM_Event_DAO_Event', $generatedEntities['civicrm_event'][$key], 'id', 'id', 'Check if event was deleted');
     $searchParams = array('entity_id' => $generatedEntities['civicrm_event'][$key], 'entity_table' => 'civicrm_event');
     $compareParams = array();
     $this->assertDBCompareValues('CRM_Core_DAO_RecurringEntity', $searchParams, $compareParams);
     //Find tell_a_friend id if that was deleted from civicrm
     $searchActParams = array('entity_id' => $generatedEntities['civicrm_tell_friend'][$actKey], 'entity_table' => 'civicrm_tell_friend');
     $compareActParams = array();
     $this->assertDBCompareValues('CRM_Friend_DAO_Friend', $searchActParams, $compareActParams);
 }
 /**
  * The function returns whether this transaction has already been handled.
  *
  * @param string @component
  *   event/contribute
  * @param array $post_data_exp
  *   Contains the name-value pairs of transaction response data.
  * @param string $dt_trxn_id
  *   Transaction ID from DT response.
  *
  * @return boolean
  *   Has this transaction been handled?  TRUE/FALSE.
  * @static
  */
 static function getContext($component, $post_data_exp, $dt_trxn_id)
 {
     require_once 'CRM/Contribute/DAO/Contribution.php';
     $contributionID = $post_data_exp['contributionID'];
     $contribution = new CRM_Contribute_DAO_Contribution();
     $contribution->id = $contributionID;
     /*
      * @TODO For recurring?
      * if(new contrib)
      * $contribution->invoice_id = $dt_trxn_id;
      */
     if (!$contribution->find(TRUE)) {
         CRM_Core_Error::debug_log_message("Could not find contribution record: {$contributionID}");
         print "Failure: Could not find contribution record for {$contributionID}<p>";
         exit;
     }
     $duplicate_transaction = FALSE;
     if ($contribution->contribution_status_id == 1) {
         //  Contribution already handled.
         $duplicate_transaction = TRUE;
     }
     if ($component == 'contribute') {
         if (empty($contribution->contribution_page_id)) {
             CRM_Core_Error::debug_log_message("Could not find contribution page for contribution record: {$contributionID}");
             print "Failure: Could not find contribution page for contribution record: {$contributionID}<p>";
             exit;
         }
     } else {
         if (!empty($post_data_exp['eventID'])) {
             require_once 'CRM/Event/DAO/Event.php';
             $eventID = $post_data_exp['eventID'];
             // Make sure event exists and is valid.
             $event = new CRM_Event_DAO_Event();
             $event->id = $eventID;
             if (!$event->find(TRUE)) {
                 CRM_Core_Error::debug_log_message("Could not find event: {$eventID}");
                 print "Failure: Could not find event: {$eventID}<p>";
                 exit;
             }
         } else {
             CRM_Core_Error::debug_log_message("Could not find event ID");
             print "Failure: Could not find eventID<p>";
             exit;
         }
     }
     return $duplicate_transaction;
 }
Exemple #14
0
 /**
  * returns the list of fields that can be exported
  *
  * @access public
  * return array
  */
 function &export($prefix = false)
 {
     if (!self::$_export) {
         self::$_export = array();
         $fields =& self::fields();
         foreach ($fields as $name => $field) {
             if (CRM_Utils_Array::value('export', $field)) {
                 if ($prefix) {
                     self::$_export['event'] =& $fields[$name];
                 } else {
                     self::$_export[$name] =& $fields[$name];
                 }
             }
         }
     }
     return self::$_export;
 }
 /**  
 
 /**  
 * The function returns the component(Event/Contribute..)and whether it is Test or not
 *  
 * @param array   $privateData    contains the name-value pairs of transaction related data
 * @param int     $orderNo        <order-total> send by google
 *  
 * @return array context of this call (test, component, payment processor id)
 * @static  
 */
 static function getContext($privateData, $orderNo)
 {
     require_once 'CRM/Contribute/DAO/Contribution.php';
     $component = null;
     $isTest = null;
     $contributionID = $privateData['contributionID'];
     $contribution = new CRM_Contribute_DAO_Contribution();
     $contribution->id = $contributionID;
     if (!$contribution->find(true)) {
         CRM_Core_Error::debug_log_message("Could not find contribution record: {$contributionID}");
         echo "Failure: Could not find contribution record for {$contributionID}<p>";
         exit;
     }
     if (stristr($contribution->source, 'Online Contribution')) {
         $component = 'contribute';
     } elseif (stristr($contribution->source, 'Online Event Registration')) {
         $component = 'event';
     }
     $isTest = $contribution->is_test;
     $duplicateTransaction = 0;
     if ($contribution->contribution_status_id == 1) {
         //contribution already handled. (some processors do two notifications so this could be valid)
         $duplicateTransaction = 1;
     }
     if ($component == 'contribute') {
         if (!$contribution->contribution_page_id) {
             CRM_Core_Error::debug_log_message("Could not find contribution page for contribution record: {$contributionID}");
             echo "Failure: Could not find contribution page for contribution record: {$contributionID}<p>";
             exit;
         }
         // get the payment processor id from contribution page
         $paymentProcessorID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $contribution->contribution_page_id, 'payment_processor_id');
     } else {
         $eventID = $privateData['eventID'];
         if (!$eventID) {
             CRM_Core_Error::debug_log_message("Could not find event ID");
             echo "Failure: Could not find eventID<p>";
             exit;
         }
         // we are in event mode
         // make sure event exists and is valid
         require_once 'CRM/Event/DAO/Event.php';
         $event = new CRM_Event_DAO_Event();
         $event->id = $eventID;
         if (!$event->find(true)) {
             CRM_Core_Error::debug_log_message("Could not find event: {$eventID}");
             echo "Failure: Could not find event: {$eventID}<p>";
             exit;
         }
         // get the payment processor id from contribution page
         $paymentProcessorID = $event->payment_processor_id;
     }
     if (!$paymentProcessorID) {
         CRM_Core_Error::debug_log_message("Could not find payment processor for contribution record: {$contributionID}");
         echo "Failure: Could not find payment processor for contribution record: {$contributionID}<p>";
         exit;
     }
     return array($isTest, $component, $paymentProcessorID, $duplicateTransaction);
 }
Exemple #16
0
 function loadObjects(&$input, &$ids, &$objects, $required)
 {
     $contribution =& $objects['contribution'];
     $objects['membership'] = null;
     $objects['contributionRecur'] = null;
     $objects['contributionType'] = null;
     $objects['event'] = null;
     $objects['participant'] = null;
     $objects['pledge_payment'] = null;
     require_once 'CRM/Contribute/DAO/ContributionType.php';
     $contributionType = new CRM_Contribute_DAO_ContributionType();
     $contributionType->id = $contribution->contribution_type_id;
     if (!$contributionType->find(true)) {
         CRM_Core_Error::debug_log_message("Could not find contribution type record: {$contributionTypeID}");
         echo "Failure: Could not find contribution type record for {$contributionTypeID}<p>";
         return false;
     }
     $objects['contributionType'] = $contributionType;
     $paymentProcessorID = null;
     if ($input['component'] == 'contribute') {
         // retrieve the other optional objects first so
         // stuff down the line can use this info and do things
         // CRM-6056
         if (isset($ids['membership'])) {
             require_once 'CRM/Member/DAO/Membership.php';
             $membership = new CRM_Member_DAO_Membership();
             $membership->id = $ids['membership'];
             if (!$membership->find(true)) {
                 CRM_Core_Error::debug_log_message("Could not find membership record: {$membershipID}");
                 echo "Failure: Could not find membership record: {$membershipID}<p>";
                 return false;
             }
             $membership->join_date = CRM_Utils_Date::isoToMysql($membership->join_date);
             $membership->start_date = CRM_Utils_Date::isoToMysql($membership->start_date);
             $membership->end_date = CRM_Utils_Date::isoToMysql($membership->end_date);
             $membership->reminder_date = CRM_Utils_Date::isoToMysql($membership->reminder_date);
             $objects['membership'] =& $membership;
         }
         if (isset($ids['pledge_payment'])) {
             require_once 'CRM/Pledge/DAO/Payment.php';
             $objects['pledge_payment'] = array();
             foreach ($ids['pledge_payment'] as $key => $paymentID) {
                 $payment = new CRM_Pledge_DAO_Payment();
                 $payment->id = $paymentID;
                 if (!$payment->find(true)) {
                     CRM_Core_Error::debug_log_message("Could not find pledge payment record: {$pledge_paymentID}");
                     echo "Failure: Could not find pledge payment record: {$pledge_paymentID}<p>";
                     return false;
                 }
                 $objects['pledge_payment'][] = $payment;
             }
         }
         if (isset($ids['contributionRecur'])) {
             require_once 'CRM/Contribute/DAO/ContributionRecur.php';
             $recur = new CRM_Contribute_DAO_ContributionRecur();
             $recur->id = $ids['contributionRecur'];
             if (!$recur->find(true)) {
                 CRM_Core_Error::debug_log_message("Could not find recur record: {$contributionRecurID}");
                 echo "Failure: Could not find recur record: {$contributionRecurID}<p>";
                 return false;
             }
             $objects['contributionRecur'] =& $recur;
             //get payment processor id from recur object.
             $paymentProcessorID = $recur->payment_processor_id;
         }
         //for normal contribution get the payment processor id.
         if (!$paymentProcessorID) {
             if ($contribution->contribution_page_id) {
                 // get the payment processor id from contribution page
                 $paymentProcessorID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $contribution->contribution_page_id, 'payment_processor_id');
             }
             //fail to load payment processor id.
             if (!$paymentProcessorID && !$contribution->contribution_page_id && !CRM_Utils_Array::value('pledge_payment', $ids)) {
                 $loadObjectSuccess = true;
                 if ($required) {
                     $loadObjectSuccess = false;
                     CRM_Core_Error::debug_log_message("Could not find contribution page for contribution record: {$contributionID}");
                     echo "Failure: Could not find contribution page for contribution record: {$contributionID}<p>";
                 }
                 return $loadObjectSuccess;
             }
         }
     } else {
         // we are in event mode
         // make sure event exists and is valid
         require_once 'CRM/Event/DAO/Event.php';
         $event = new CRM_Event_DAO_Event();
         $event->id = $ids['event'];
         if ($ids['event'] && !$event->find(true)) {
             CRM_Core_Error::debug_log_message("Could not find event: {$eventID}");
             echo "Failure: Could not find event: {$eventID}<p>";
             return false;
         }
         $objects['event'] =& $event;
         require_once 'CRM/Event/DAO/Participant.php';
         $participant = new CRM_Event_DAO_Participant();
         $participant->id = $ids['participant'];
         if ($ids['participant'] && !$participant->find(true)) {
             CRM_Core_Error::debug_log_message("Could not find participant: {$participantID}");
             echo "Failure: Could not find participant: {$participantID}<p>";
             return false;
         }
         $participant->register_date = CRM_Utils_Date::isoToMysql($participant->register_date);
         $objects['participant'] =& $participant;
         if (!$paymentProcessorID) {
             $paymentProcessorID = $objects['event']->payment_processor_id;
         }
     }
     $loadObjectSuccess = true;
     if ($paymentProcessorID) {
         require_once 'CRM/Core/BAO/PaymentProcessor.php';
         $paymentProcessor = CRM_Core_BAO_PaymentProcessor::getPayment($paymentProcessorID, $contribution->is_test ? 'test' : 'live');
         $ids['paymentProcessor'] = $paymentProcessorID;
         $objects['paymentProcessor'] =& $paymentProcessor;
     } else {
         if ($required) {
             $loadObjectSuccess = false;
             CRM_Core_Error::debug_log_message("Could not find payment processor for contribution record: {$contributionID}");
             echo "Failure: Could not find payment processor for contribution record: {$contributionID}<p>";
         }
     }
     return $loadObjectSuccess;
 }