Exemplo n.º 1
0
 /**
  * Validate incoming data. This function is intended to ensure that incoming data matches
  * It provides a form of pseudo-authentication - by checking the calling fn already knows
  * the correct contact id & contribution id (this can be problematic when that has changed in
  * the meantime for transactions that are delayed & contacts are merged in-between. e.g
  * Paypal allows you to resend Instant Payment Notifications if you, for example, moved site
  * and didn't update your IPN URL.
  *
  * @param array $input interpreted values from the values returned through the IPN
  * @param array $ids more interpreted values (ids) from the values returned through the IPN
  * @param array $objects an empty array that will be populated with loaded object
  * @param boolean $required boolean Return FALSE if the relevant objects don't exist
  * @param integer $paymentProcessorID Id of the payment processor ID in use
  * @return boolean
  */
 function validateData(&$input, &$ids, &$objects, $required = TRUE, $paymentProcessorID = NULL)
 {
     // make sure contact exists and is valid
     $contact = new CRM_Contact_BAO_Contact();
     $contact->id = $ids['contact'];
     if (!$contact->find(TRUE)) {
         CRM_Core_Error::debug_log_message("Could not find contact record: {$ids['contact']} in IPN request: " . print_r($input, TRUE));
         echo "Failure: Could not find contact record: {$ids['contact']}<p>";
         return FALSE;
     }
     // make sure contribution exists and is valid
     $contribution = new CRM_Contribute_BAO_Contribution();
     $contribution->id = $ids['contribution'];
     if (!$contribution->find(TRUE)) {
         CRM_Core_Error::debug_log_message("Could not find contribution record: {$contribution->id} in IPN request: " . print_r($input, TRUE));
         echo "Failure: Could not find contribution record for {$contribution->id}<p>";
         return FALSE;
     }
     $contribution->receive_date = CRM_Utils_Date::isoToMysql($contribution->receive_date);
     $objects['contact'] =& $contact;
     $objects['contribution'] =& $contribution;
     if (!$this->loadObjects($input, $ids, $objects, $required, $paymentProcessorID)) {
         return FALSE;
     }
     return TRUE;
 }
Exemplo n.º 2
0
 function preProcess()
 {
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
     $this->assign('contactId', $this->_contactId);
     $contact = new CRM_Contact_BAO_Contact();
     $contact->get('id', $this->_contactId);
     $this->_apiKey = $contact->api_key;
     $this->assign('apiKey', $this->_apiKey);
     // check logged in url permission
     CRM_Contact_Page_View::checkUserPermission($this);
     // set page title
     CRM_Contact_Page_View::setTitle($this->_contactId);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
     $this->assign('action', $this->_action);
     $isAdmin = CRM_Core_Permission::check('administer CiviCRM') && CRM_Core_Permission::check('edit all contacts');
     $session = CRM_Core_Session::singleton();
     $isMyself = $this->_contactId && $this->_contactId == $session->get('userID');
     $this->assign('isAdmin', $isAdmin);
     $this->assign('isMyself', $isMyself);
     $urlParam = 'reset=1&action=add&cid=' . $this->_contactId;
     if ($this->_apiKey) {
         $urlParam = 'reset=1&action=edit&cid=' . $this->_contactId;
     }
     $this->assign('addApiKeyUrl', CRM_Utils_System::url('civicrm/contact/apikey', $urlParam));
 }
Exemplo n.º 3
0
 /**
  * Run the page.
  *
  * This method is called after the page is created.
  */
 public function run()
 {
     // get the emails for this contact
     $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
     $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('labelColumn' => 'display_name'));
     $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id');
     $entityBlock = array('contact_id' => $contactId);
     $phones = CRM_Core_BAO_Phone::getValues($entityBlock);
     if (!empty($phones)) {
         foreach ($phones as $key => &$value) {
             $value['location_type'] = $locationTypes[$value['location_type_id']];
             $value['phone_type'] = $phoneTypes[$value['phone_type_id']];
         }
     }
     $contact = new CRM_Contact_BAO_Contact();
     $contact->id = $contactId;
     $contact->find(TRUE);
     $privacy = array();
     foreach (CRM_Contact_BAO_Contact::$_commPrefs as $name) {
         if (isset($contact->{$name})) {
             $privacy[$name] = $contact->{$name};
         }
     }
     $this->assign('contactId', $contactId);
     $this->assign('phone', $phones);
     $this->assign('privacy', $privacy);
     // check logged in user permission
     CRM_Contact_Page_View::checkUserPermission($this, $contactId);
     // finally call parent
     parent::run();
 }
Exemplo n.º 4
0
 /**
  * Run the page.
  *
  * This method is called after the page is created.
  */
 public function run()
 {
     // get the emails for this contact
     $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
     $locBlockNo = CRM_Utils_Request::retrieve('locno', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
     $addressId = CRM_Utils_Request::retrieve('aid', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, NULL, $_REQUEST);
     $address = array();
     if ($addressId > 0) {
         $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('labelColumn' => 'display_name'));
         $entityBlock = array('id' => $addressId);
         $address = CRM_Core_BAO_Address::getValues($entityBlock, FALSE, 'id');
         if (!empty($address)) {
             foreach ($address as $key => &$value) {
                 $value['location_type'] = $locationTypes[$value['location_type_id']];
             }
         }
     }
     // we just need current address block
     $currentAddressBlock['address'][$locBlockNo] = array_pop($address);
     if (!empty($currentAddressBlock['address'][$locBlockNo])) {
         // get contact name of shared contact names
         $sharedAddresses = array();
         $shareAddressContactNames = CRM_Contact_BAO_Contact_Utils::getAddressShareContactNames($currentAddressBlock['address']);
         foreach ($currentAddressBlock['address'] as $key => $addressValue) {
             if (!empty($addressValue['master_id']) && !$shareAddressContactNames[$addressValue['master_id']]['is_deleted']) {
                 $sharedAddresses[$key]['shared_address_display'] = array('address' => $addressValue['display'], 'name' => $shareAddressContactNames[$addressValue['master_id']]['name']);
             }
         }
         $idValue = $currentAddressBlock['address'][$locBlockNo]['id'];
         if (!empty($currentAddressBlock['address'][$locBlockNo]['master_id'])) {
             $idValue = $currentAddressBlock['address'][$locBlockNo]['master_id'];
         }
         // add custom data of type address
         $groupTree = CRM_Core_BAO_CustomGroup::getTree('Address', $this, $idValue);
         // we setting the prefix to dnc_ below so that we don't overwrite smarty's grouptree var.
         $currentAddressBlock['address'][$locBlockNo]['custom'] = CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, "dnc_");
         $this->assign("dnc_viewCustomData", NULL);
         $this->assign('add', $currentAddressBlock['address'][$locBlockNo]);
         $this->assign('sharedAddresses', $sharedAddresses);
     }
     $contact = new CRM_Contact_BAO_Contact();
     $contact->id = $contactId;
     $contact->find(TRUE);
     $privacy = array();
     foreach (CRM_Contact_BAO_Contact::$_commPrefs as $name) {
         if (isset($contact->{$name})) {
             $privacy[$name] = $contact->{$name};
         }
     }
     $this->assign('contactId', $contactId);
     $this->assign('locationIndex', $locBlockNo);
     $this->assign('addressId', $addressId);
     $this->assign('privacy', $privacy);
     // check logged in user permission
     CRM_Contact_Page_View::checkUserPermission($this, $contactId);
     // finally call parent
     parent::run();
 }
Exemplo n.º 5
0
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     parent::preProcess();
     $details = CRM_Booking_BAO_Booking::getBookingDetails($this->_id);
     $this->_values['slots'] = CRM_Utils_Array::value('slots', $details);
     $this->_values['sub_slots'] = CRM_Utils_Array::value('sub_slots', $details);
     $this->_values['adhoc_charges'] = CRM_Utils_Array::value('adhoc_charges', $details);
     $this->_values['cancellation_charges'] = CRM_Utils_Array::value('cancellation_charges', $details);
     $this->_values['contribution'] = CRM_Utils_Array::value('contribution', $details);
     $this->_values['sub_total'] = CRM_Utils_Array::value('total_amount', $this->_values) + CRM_Utils_Array::value('discount_amount', $this->_values);
     //total_amount has been deducted from discount
     $this->assign($this->_values);
     $displayName = CRM_Contact_BAO_Contact::displayName($this->_values['primary_contact_id']);
     $secondaryContactDisplayName = CRM_Contact_BAO_Contact::displayName(CRM_Utils_Array::value('secondary_contact_id', $this->_values));
     $this->assign('displayName', $displayName);
     $this->assign('secondaryContactDisplayName', $secondaryContactDisplayName);
     $this->assign('contact_id', $this->_cid);
     $params = array('option_group_name' => CRM_Booking_Utils_Constants::OPTION_BOOKING_STATUS, 'name' => CRM_Booking_Utils_Constants::OPTION_VALUE_CANCELLED);
     $result = civicrm_api3('OptionValue', 'get', $params);
     $this->_cancelStatusId = $cancelStatus = CRM_Utils_Array::value('value', CRM_Utils_Array::value($result['id'], $result['values']));
     if ($this->_values['status_id'] == $cancelStatus) {
         $this->assign('is_cancelled', TRUE);
     }
     // omitting contactImage from title for now since the summary overlay css doesn't work outside of our crm-container
     CRM_Utils_System::setTitle(ts('View Booking for') . ' ' . $displayName);
     self::registerScripts($this);
 }
Exemplo n.º 6
0
 /**
  * Run the page.
  *
  * This method is called after the page is created.
  *
  * @return void
  * @access public
  *
  */
 function run()
 {
     // get the callback, module and activity id
     $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
     $id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $dao = new CRM_Core_DAO_ActivityHistory();
     $dao->activity_id = $id;
     $dao->activity_type = ts('SMS Sent');
     if ($dao->find(TRUE)) {
         $cid = $dao->entity_id;
     }
     $dao = new CRM_SMS_DAO_History();
     $dao->id = $id;
     if ($dao->find(TRUE)) {
         $this->assign('fromName', CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $dao->contact_id, 'display_name'));
         $this->assign('toName', CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'display_name'));
         $this->assign('sentDate', $dao->sent_date);
         $this->assign('message', $dao->message);
         // get the display name and images for the contact
         list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($dao->contact_id);
         CRM_Utils_System::setTitle($contactImage . ' ' . $displayName);
         // also add the cid params to the Menu array
         CRM_Core_Menu::addParam('cid', $cid);
     }
     return parent::run();
 }
Exemplo n.º 7
0
 function setDefaultValues()
 {
     // check if the user is registered and we have a contact ID
     $session =& CRM_Core_Session::singleton();
     $contactID = $session->get('userID');
     if ($contactID) {
         $options = array();
         $fields = array();
         foreach ($this->_fields as $name => $dontCare) {
             $fields[$name] = 1;
         }
         $fields['state_province'] = $fields['country'] = $fields['email'] = 1;
         $contact =& CRM_Contact_BAO_Contact::contactDetails($contactID, $options, $fields);
         foreach ($fields as $name => $dontCare) {
             if ($contact->{$name}) {
                 if (substr($name, 0, 7) == 'custom_') {
                     $id = substr($name, 7);
                     $this->_defaults[$name] = CRM_Core_BAO_CustomField::getDefaultValue($contact->{$name}, $id, $options);
                 } else {
                     $this->_defaults[$name] = $contact->{$name};
                 }
             }
         }
     }
     // hack to simplify credit card entry for testing
     /**
             $this->_defaults['credit_card_type']     = 'Visa';
             $this->_defaults['credit_card_number']   = '4807731747657838';
             $this->_defaults['cvv2']                 = '000';
             $this->_defaults['credit_card_exp_date'] = array( 'Y' => '2008', 'M' => '01' );
             **/
     return $this->_defaults;
 }
Exemplo n.º 8
0
 /**  
  * Function to set variables up before form is built  
  *                                                            
  * @return void  
  * @access public  
  */
 public function preProcess()
 {
     $this->_contactID = $this->get('cid');
     $this->_caseID = $this->get('id');
     $this->assign('caseID', $this->_caseID);
     $this->assign('contactID', $this->_contactID);
     //retrieve details about case
     $params = array('id' => $this->_caseID);
     $returnProperties = array('case_type_id', 'subject', 'status_id', 'start_date');
     CRM_Core_DAO::commonRetrieve('CRM_Case_BAO_Case', $params, $values, $returnProperties);
     $values['case_type_id'] = explode(CRM_Case_BAO_Case::VALUE_SEPERATOR, CRM_Utils_Array::value('case_type_id', $values));
     $statuses = CRM_Case_PseudoConstant::caseStatus();
     $caseTypeName = CRM_Case_PseudoConstant::caseTypeName($this->_caseID);
     $caseType = CRM_Core_OptionGroup::getLabel('case_type', $caseTypeName['id']);
     $this->_caseDetails = array('case_type' => $caseType, 'case_status' => $statuses[$values['case_status_id']], 'case_subject' => CRM_Utils_Array::value('subject', $values), 'case_start_date' => $values['case_start_date']);
     $this->_caseType = $caseTypeName['name'];
     $this->assign('caseDetails', $this->_caseDetails);
     $newActivityUrl = CRM_Utils_System::url('civicrm/case/activity', "action=add&reset=1&cid={$this->_contactID}&caseid={$this->_caseID}&atype=", false, null, false);
     $this->assign('newActivityUrl', $newActivityUrl);
     $reportUrl = CRM_Utils_System::url('civicrm/case/report', "reset=1&cid={$this->_contactID}&caseid={$this->_caseID}&asn=", false, null, false);
     $this->assign('reportUrl', $reportUrl);
     // add to recently viewed
     require_once 'CRM/Utils/Recent.php';
     require_once 'CRM/Contact/BAO/Contact.php';
     $url = CRM_Utils_System::url('civicrm/contact/view/case', "action=view&reset=1&id={$this->_caseID}&cid={$this->_contactID}&context=home");
     $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactID);
     $this->assign('displayName', $displayName);
     $title = $displayName . ' - ' . $caseType;
     // add the recently created case
     CRM_Utils_Recent::add($title, $url, $this->_caseID, 'Case', $this->_contactID, null);
 }
Exemplo n.º 9
0
 function fileDisplay()
 {
     // Display evidence file
     $postParams = $_POST;
     $fileID = CRM_Core_BAO_File::getEntityFile($postParams['entityTable'], $postParams['entityID']);
     if ($fileID) {
         foreach ($fileID as $k => $v) {
             $fileType = $v['mime_type'];
             $fid = $v['fileID'];
             $eid = $postParams['entityID'];
             if ($fileType == 'image/jpeg' || $fileType == 'image/pjpeg' || $fileType == 'image/gif' || $fileType == 'image/x-png' || $fileType == 'image/png') {
                 list($path) = CRM_Core_BAO_File::path($fid, $eid, NULL, NULL);
                 list($imageWidth, $imageHeight) = getimagesize($path);
                 list($imageThumbWidth, $imageThumbHeight) = CRM_Contact_BAO_Contact::getThumbSize($imageWidth, $imageHeight);
                 $url = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fid}&eid={$eid}", FALSE, NULL, TRUE, TRUE);
                 $file_url = "\n              <a href=\"{$url}\" class='crm-image-popup'>\n              <img src=\"{$url}\" width={$imageThumbWidth} height={$imageThumbHeight}/>\n              </a>";
                 // for non image files
             } else {
                 $uri = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_File', $fid, 'uri');
                 $url = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fid}&eid={$eid}");
                 $file_url = "<a href=\"{$url}\">{$uri}</a>";
             }
             if (isset($fid)) {
                 $deleteurl = "<div class=file-delete><a class='action-item crm-hover-button' href='javascript:void(0)' id=file_{$fid}>Delete Attached File</a></div>";
                 echo "<div id='del_{$fid}'>{$file_url}{$deleteurl}</div>";
             }
         }
     }
     CRM_Utils_System::civiExit();
 }
Exemplo n.º 10
0
 function run()
 {
     $contactID = CRM_Utils_Request::retrieve('cid', 'Integer');
     if (!empty($contactID)) {
         if (!self::checkPermissions($contactID, 'viewWidget')) {
             CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm'));
             CRM_Core_Error::statusBounce(ts('You do not have permission to access this page'));
         }
         CRM_Utils_System::setTitle(ts('Absences for %1', array(1 => CRM_Contact_BAO_Contact::displayName($contactID))));
         self::registerResources($contactID);
     } else {
         $session = CRM_Core_Session::singleton();
         if (is_numeric($session->get('userID'))) {
             if (!self::checkPermissions($session->get('userID'), 'viewWidget')) {
                 CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm'));
                 CRM_Core_Error::statusBounce(ts('You do not have permission to access this page'));
             }
             CRM_Utils_System::setTitle(ts('My Absences'));
             self::registerResources($session->get('userID'));
         } else {
             throw new CRM_Core_Exception("Failed to determine contact ID");
         }
     }
     parent::run();
 }
Exemplo n.º 11
0
 /**
  * @inheritDoc
  */
 public function createUser(&$params, $mail)
 {
     $baseDir = JPATH_SITE;
     require_once $baseDir . '/components/com_users/models/registration.php';
     $userParams = JComponentHelper::getParams('com_users');
     $model = new UsersModelRegistration();
     $ufID = NULL;
     // get the default usertype
     $userType = $userParams->get('new_usertype');
     if (!$userType) {
         $userType = 2;
     }
     if (isset($params['name'])) {
         $fullname = trim($params['name']);
     } elseif (isset($params['contactID'])) {
         $fullname = trim(CRM_Contact_BAO_Contact::displayName($params['contactID']));
     } else {
         $fullname = trim($params['cms_name']);
     }
     // Prepare the values for a new Joomla user.
     $values = array();
     $values['name'] = $fullname;
     $values['username'] = trim($params['cms_name']);
     $values['password1'] = $values['password2'] = $params['cms_pass'];
     $values['email1'] = $values['email2'] = trim($params[$mail]);
     $lang = JFactory::getLanguage();
     $lang->load('com_users', $baseDir);
     $register = $model->register($values);
     $ufID = JUserHelper::getUserId($values['username']);
     return $ufID;
 }
Exemplo n.º 12
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);
 }
Exemplo n.º 13
0
 /**
  * Run the page.
  *
  * This method is called after the page is created.
  *
  * @return void
  * @access public
  *
  */
 function run()
 {
     // get the callback, module and activity id
     $action = CRM_Utils_Request::retrieve('action', $this, false, 'browse');
     $id = CRM_Utils_Request::retrieve('id', $this);
     $dao =& new CRM_Core_DAO_ActivityHistory();
     $dao->activity_id = $id;
     $dao->activity_type = ts('SMS Sent');
     if ($dao->find(true)) {
         $cid = $dao->entity_id;
     }
     require_once 'CRM/SMS/DAO/History.php';
     $dao =& new CRM_SMS_DAO_History();
     $dao->id = $id;
     if ($dao->find(true)) {
         $this->assign('fromName', CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $dao->contact_id, 'display_name'));
         $this->assign('toName', CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'display_name'));
         $this->assign('sentDate', $dao->sent_date);
         $this->assign('message', $dao->message);
         // get the display name and images for the contact
         list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($dao->contact_id);
         CRM_Utils_System::setTitle($contactImage . ' ' . $displayName);
         require_once 'CRM/Utils/Menu.php';
         // also add the cid params to the Menu array
         CRM_Utils_Menu::addParam('cid', $cid);
         // create menus ..
         $startWeight = CRM_Utils_Menu::getMaxWeight('civicrm/contact/view');
         $startWeight++;
         require_once 'CRM/Core/BAO/CustomGroup.php';
         CRM_Core_BAO_CustomGroup::addMenuTabs(CRM_Contact_BAO_Contact::getContactType($cid), 'civicrm/contact/view/cd', $startWeight);
     }
     parent::run();
 }
 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);
 }
Exemplo n.º 15
0
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     $this->_caseId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $context = CRM_Utils_Request::retrieve('context', 'String', $this);
     //get current client name.
     require_once 'CRM/Contact/BAO/Contact.php';
     $this->assign('currentClientName', CRM_Contact_BAO_Contact::displayName($this->_contactId));
     //set the context.
     $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&force=1&cid={$this->_contactId}&selectedChild=case");
     if ($context == 'search') {
         $qfKey = CRM_Utils_Request::retrieve('key', 'String', $this);
         //validate the qfKey
         require_once 'CRM/Utils/Rule.php';
         $urlParams = 'force=1';
         if (CRM_Utils_Rule::qfKey($qfKey)) {
             $urlParams .= "&qfKey={$qfKey}";
         }
         $url = CRM_Utils_System::url('civicrm/case/search', $urlParams);
     } else {
         if ($context == 'dashboard') {
             $url = CRM_Utils_System::url('civicrm/case', 'reset=1');
         }
     }
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext($url);
 }
Exemplo n.º 16
0
 /**
  * Check method create()
  */
 public function testCreate()
 {
     $firstName = 'Shane';
     $lastName = 'Whatson';
     $params = array('first_name' => $firstName, 'last_name' => $lastName, 'contact_type' => 'Individual');
     $contact = CRM_Contact_BAO_Contact::add($params);
     $price = 100.0;
     $cParams = array('contact_id' => $contact->id, 'total_amount' => $price, 'financial_type_id' => 1, 'is_active' => 1, 'skipLineItem' => 1);
     $defaults = array();
     $contribution = CRM_Contribute_BAO_Contribution::add($cParams, $defaults);
     $lParams = array('entity_id' => $contribution->id, 'entity_table' => 'civicrm_contribution', 'price_field_id' => 1, 'qty' => 1, 'label' => 'Contribution Amount', 'unit_price' => $price, 'line_total' => $price, 'price_field_value_id' => 1, 'financial_type_id' => 1);
     $lineItem = CRM_Price_BAO_LineItem::create($lParams);
     $fParams = array('contact_id' => $contact->id, 'description' => 'Contribution Amount', 'amount' => $price, 'financial_account_id' => 1, 'status_id' => 1, 'transaction_date' => date('YmdHis'), 'entity_id' => $lineItem->id, 'entity_table' => 'civicrm_line_item');
     CRM_Financial_BAO_FinancialItem::create($fParams);
     $entityTrxn = new CRM_Financial_DAO_EntityFinancialTrxn();
     $entityTrxn->entity_table = 'civicrm_contribution';
     $entityTrxn->entity_id = $contribution->id;
     $entityTrxn->amount = $price;
     if ($entityTrxn->find(TRUE)) {
         $entityId = $entityTrxn->entity_id;
     }
     $result = $this->assertDBNotNull('CRM_Financial_DAO_FinancialItem', $lineItem->id, 'amount', 'entity_id', 'Database check on added financial item record.');
     $this->assertEquals($result, $price, 'Verify Amount for Financial Item');
     $entityResult = $this->assertDBNotNull('CRM_Financial_DAO_EntityFinancialTrxn', $entityId, 'amount', 'entity_id', 'Database check on added entity financial trxn record.');
     $this->assertEquals($entityResult, $price, 'Verify Amount for Financial Item');
 }
Exemplo n.º 17
0
 /**
  * Run the page.
  *
  * This method is called after the page is created.
  */
 public function run()
 {
     // get the emails for this contact
     $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
     $cgId = CRM_Utils_Request::retrieve('groupID', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST);
     $customRecId = CRM_Utils_Request::retrieve('customRecId', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, 1, $_REQUEST);
     $cgcount = CRM_Utils_Request::retrieve('cgcount', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, 1, $_REQUEST);
     //custom groups Inline
     $entityType = CRM_Contact_BAO_Contact::getContactType($contactId);
     $entitySubType = CRM_Contact_BAO_Contact::getContactSubType($contactId);
     $groupTree =& CRM_Core_BAO_CustomGroup::getTree($entityType, $this, $contactId, $cgId, $entitySubType);
     $details = CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, NULL, $contactId);
     //get the fields of single custom group record
     if ($customRecId == 1) {
         $fields = reset($details[$cgId]);
     } else {
         $fields = CRM_Utils_Array::value($customRecId, $details[$cgId]);
     }
     $this->assign('cgcount', $cgcount);
     $this->assign('customRecId', $customRecId);
     $this->assign('contactId', $contactId);
     $this->assign('customGroupId', $cgId);
     $this->assign_by_ref('cd_edit', $fields);
     // check logged in user permission
     CRM_Contact_Page_View::checkUserPermission($this, $contactId);
     // finally call parent
     parent::run();
 }
Exemplo n.º 18
0
 /**
  * combine all the importable fields from the lower levels object
  *
  * The ordering is important, since currently we do not have a weight
  * scheme. Adding weight is super important
  *
  * @param int     $contactType     contact Type
  * @param boolean $status          status is used to manipulate first title
  * @param boolean $showAll         if true returns all fields (includes disabled fields)
  * @param boolean $isProfile       if its profile mode
  * @param boolean $checkPermission if false, do not include permissioning clause (for custom data)
  *
  * @return array array of importable Fields
  * @access public
  * @static
  */
 static function &importableFields($contactType = 'Individual', $status = FALSE, $showAll = FALSE, $isProfile = FALSE, $checkPermission = TRUE, $withMultiCustomFields = FALSE)
 {
     $contactType = 'Individual';
     $fields = CRM_Hrjobcontract_DAO_HRJobContract::import();
     $tmpContactField = $contactFields = array();
     $contactFields = array();
     $contactFields = CRM_Contact_BAO_Contact::importableFields($contactType, NULL);
     // Using new Dedupe rule.
     $ruleParams = array('contact_type' => $contactType, 'used' => 'Unsupervised');
     $fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams);
     if (is_array($fieldsArray)) {
         foreach ($fieldsArray as $value) {
             $customFieldId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $value, 'id', 'column_name');
             $value = $customFieldId ? 'custom_' . $customFieldId : $value;
             $tmpContactField[trim($value)] = CRM_Utils_Array::value(trim($value), $contactFields);
             if (!$status) {
                 $title = $tmpContactField[trim($value)]['title'] . ' (match to contact)';
             } else {
                 $title = $tmpContactField[trim($value)]['title'];
             }
             $tmpContactField[trim($value)]['title'] = $title;
         }
     }
     $extIdentifier = CRM_Utils_Array::value('external_identifier', $contactFields);
     if ($extIdentifier) {
         $tmpContactField['external_identifier'] = $extIdentifier;
         $tmpContactField['external_identifier']['title'] = CRM_Utils_Array::value('title', $extIdentifier) . ' (match to contact)';
     }
     $fields = array_merge($fields, $tmpContactField);
     self::$_importableFields = $fields;
     return self::$_importableFields;
     //$fields;
 }
Exemplo n.º 19
0
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, false);
     if ($cid) {
         // not sure why this is needed :(
         // also add the cid params to the Menu array
         CRM_Core_Menu::addParam('cid', $cid);
         // create menus ..
         $startWeight = CRM_Core_Menu::getMaxWeight('civicrm/contact/view');
         $startWeight++;
         CRM_Core_BAO_CustomGroup::addMenuTabs(CRM_Contact_BAO_Contact::getContactType($cid), 'civicrm/contact/view/cd', $startWeight);
         $this->_contactIds = array($cid);
         $this->_single = true;
         $smsNumbers = CRM_Contact_BAO_Contact::allPhones($cid, 'Mobile');
         $this->_emails = array();
         $toName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'display_name');
         foreach ($smsNumbers as $number => $item) {
             $this->_smsNumbers[$number] = '"' . $toName . '" <' . $number . '> ' . $item['locationType'];
             if ($item['is_primary']) {
                 $this->_smsNumbers[$number] .= ' ' . ts('(preferred)');
             }
             $this->_smsNumbers[$number] = htmlspecialchars($this->_emails[$email]);
         }
     } else {
         parent::preProcess();
     }
     $this->assign('single', $this->_single);
 }
Exemplo n.º 20
0
 /**
  * Build the form object.
  *
  * @return void
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     $this->setPageTitle(ts('Financial Batch'));
     if (isset($this->_id)) {
         $this->_title = CRM_Core_DAO::getFieldValue('CRM_Batch_DAO_Batch', $this->_id, 'title');
         CRM_Utils_System::setTitle($this->_title . ' - ' . ts('Accounting Batch'));
         $this->assign('batchTitle', $this->_title);
         $contactID = CRM_Core_DAO::getFieldValue('CRM_Batch_DAO_Batch', $this->_id, 'created_id');
         $contactName = CRM_Contact_BAO_Contact::displayName($contactID);
         $this->assign('contactName', $contactName);
     }
     $this->applyFilter('__ALL__', 'trim');
     $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'next', 'name' => ts('Save and New'), 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel'))));
     if ($this->_action & CRM_Core_Action::UPDATE && $this->_id) {
         $batchStatus = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id');
         //unset exported status
         $exportedStatusId = CRM_Utils_Array::key('Exported', $batchStatus);
         unset($batchStatus[$exportedStatusId]);
         $this->add('select', 'status_id', ts('Batch Status'), array('' => ts('- select -')) + $batchStatus, TRUE);
         $this->freeze(array('status_id'));
     }
     $attributes = CRM_Core_DAO::getAttribute('CRM_Batch_DAO_Batch');
     $this->add('text', 'title', ts('Batch Name'), $attributes['name'], TRUE);
     $this->add('textarea', 'description', ts('Description'), $attributes['description']);
     $this->add('select', 'payment_instrument_id', ts('Payment Method'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), FALSE);
     $this->add('text', 'total', ts('Total Amount'), $attributes['total']);
     $this->add('text', 'item_count', ts('Number of Transactions'), $attributes['item_count']);
     $this->addFormRule(array('CRM_Financial_Form_FinancialBatch', 'formRule'), $this);
 }
 function testFindByContactIdNoSyncSettings()
 {
     $params = CRM_CiviMailchimp_UtilsTest::sampleContactParams();
     $contact = CRM_Contact_BAO_Contact::create($params);
     $mailchimp_sync_settings = CRM_CiviMailchimp_BAO_SyncSettings::findByContactId($contact->id);
     $this->assertEmpty($mailchimp_sync_settings);
 }
Exemplo n.º 22
0
 function buildLineItems()
 {
     foreach ($this->cart->events_in_carts as $event_in_cart) {
         $event_in_cart->load_location();
     }
     $line_items = $this->get('line_items');
     foreach ($line_items as $line_item) {
         $event_in_cart = $this->cart->get_event_in_cart_by_event_id($line_item['event_id']);
         $not_waiting_participants = array();
         foreach ($event_in_cart->not_waiting_participants() as $participant) {
             $not_waiting_participants[] = array('display_name' => CRM_Contact_BAO_Contact::displayName($participant->contact_id));
         }
         $waiting_participants = array();
         foreach ($event_in_cart->waiting_participants() as $participant) {
             $waiting_participants[] = array('display_name' => CRM_Contact_BAO_Contact::displayName($participant->contact_id));
         }
         $line_item['event'] = $event_in_cart->event;
         $line_item['num_participants'] = count($not_waiting_participants);
         $line_item['participants'] = $not_waiting_participants;
         $line_item['num_waiting_participants'] = count($waiting_participants);
         $line_item['waiting_participants'] = $waiting_participants;
         $line_item['location'] = $event_in_cart->location;
         $line_item['class'] = $event_in_cart->event->parent_event_id ? 'subevent' : NULL;
         $this->sub_total += $line_item['amount'];
         $this->line_items[] = $line_item;
     }
     $this->assign('line_items', $this->line_items);
 }
Exemplo n.º 23
0
 /**
  * View details of a relationship
  *
  * @return void
  *
  * @access public
  */
 function view()
 {
     require_once 'CRM/Core/DAO.php';
     $viewRelationship = CRM_Contact_BAO_Relationship::getRelationship($this->_contactId, null, null, null, $this->_id);
     //To check whether selected contact is a contact_id_a in
     //relationship type 'a_b' in relationship table, if yes then
     //revert the permissionship text in template
     $relationship =& new CRM_Contact_DAO_Relationship();
     $relationship->id = $viewRelationship[$this->_id]['id'];
     if ($relationship->find(true)) {
         if ($viewRelationship[$this->_id]['rtype'] == 'a_b' && $this->_contactId == $relationship->contact_id_a) {
             $this->assign("is_contact_id_a", true);
         }
     }
     $relType = $viewRelationship[$this->_id]['civicrm_relationship_type_id'];
     $this->assign('viewRelationship', $viewRelationship);
     $viewNote = CRM_Core_BAO_Note::getNote($this->_id);
     $this->assign('viewNote', $viewNote);
     $groupTree =& CRM_Core_BAO_CustomGroup::getTree('Relationship', $this, $this->_id, 0, $relType);
     CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
     // add viewed contribution to recent items list
     require_once 'CRM/Utils/Recent.php';
     $url = CRM_Utils_System::url('civicrm/contact/view/rel', "action=view&reset=1&id={$viewRelationship[$this->_id]['id']}&cid={$this->_contactId}&context=home");
     $title = CRM_Contact_BAO_Contact::displayName($this->_contactId) . ' (' . $viewRelationship[$this->_id]['relation'] . ' ' . CRM_Contact_BAO_Contact::displayName($viewRelationship[$this->_id]['cid']) . ')';
     // add the recently viewed Relationship
     CRM_Utils_Recent::add($title, $url, $viewRelationship[$this->_id]['id'], 'Relationship', $this->_contactId, null);
 }
 function addContactTokens($contact_id, $variable_name)
 {
     if (empty($contact_id)) {
         return;
     }
     // use the API to load a extensive contact information bulk
     $contact = civicrm_api('Contact', 'getsingle', array('id' => $contact_id, 'version' => 3));
     // ... add some missing fields
     $bao = new CRM_Contact_BAO_Contact();
     $bao->get('id', $contact_id);
     $contact['postal_greeting_display'] = $bao->postal_greeting_display;
     $contact['email_greeting_display'] = $bao->email_greeting_display;
     $contact['addressee_display'] = $bao->addressee_display;
     if (empty($contact['is_error'])) {
         $this->assign($variable_name, $contact);
     }
 }
 function testMailchimpWebhookSubscribeNewContact()
 {
     $sync_settings = CRM_CiviMailchimp_BAO_SyncSettingsTest::createTestGroupAndSyncSettings('test_group_mailchimp_webhook_subscribe_new_contact');
     $sample_data = self::sampleRequestSubscribeOrProfileUpdate();
     CRM_CiviMailchimp_Page_Webhook::mailchimpWebhookSubscribe($sample_data);
     $new_contact = CRM_Contact_BAO_Contact::matchContactOnEmail($sample_data['email']);
     $this->assertTrue(CRM_Contact_BAO_GroupContact::isContactInGroup($new_contact->contact_id, $sync_settings->civicrm_group_id));
 }
 /**
  * Method processAction to execute the action
  *
  * @param CRM_Civirules_TriggerData_TriggerData $triggerData
  * @access public
  *
  */
 public function processAction(CRM_Civirules_TriggerData_TriggerData $triggerData)
 {
     $contactId = $triggerData->getContactId();
     //we cannot delete domain contacts
     if (CRM_Contact_BAO_Contact::checkDomainContact($contactId)) {
         return;
     }
     CRM_Contact_BAO_Contact::deleteContact($contactId);
 }
Exemplo n.º 27
0
 /**
  * Given an array of contributionIDs, add them to a batch
  *
  * @param array  $contributionIDs (reference ) the array of contribution ids to be added
  * @param int    $batchID - the batchID to be added to
  *
  * @return array             (total, added, notAdded) ids of contributions added to the batch
  * @access public
  * @static
  */
 static function addContributionToBatch($contributionIDs, $batchID)
 {
     $date = date('YmdHis');
     $contributionsAdded = array();
     $contributionsNotAdded = array();
     require_once "GiftAid/Utils/GiftAid.php";
     require_once "CRM/Contribute/BAO/Contribution.php";
     require_once 'CRM/Core/DAO/EntityBatch.php';
     require_once "CRM/Core/BAO/Address.php";
     require_once "CRM/Contact/BAO/Contact.php";
     require_once "CRM/Utils/Address.php";
     $charityColumnExists = CRM_Core_DAO::checkFieldExists('civicrm_value_gift_aid_submission', 'charity');
     foreach ($contributionIDs as $contributionID) {
         $batchContribution =& new CRM_Core_DAO_EntityBatch();
         $batchContribution->entity_table = 'civicrm_contribution';
         $batchContribution->entity_id = $contributionID;
         // check if the selected contribution id already in a batch
         // if not, add to batchContribution else keep the count of contributions that are not added
         if ($batchContribution->find(true)) {
             $contributionsNotAdded[] = $contributionID;
             continue;
         }
         // get additional info
         // get contribution details from Contribution using contribution id
         $params = array('id' => $contributionID);
         CRM_Contribute_BAO_Contribution::retrieve($params, $contribution, $ids);
         $contactId = $contribution['contact_id'];
         // check if contribution is valid for gift aid
         if (GiftAid_Utils_GiftAid::isEligibleForGiftAid($contactId, $contribution['receive_date'], $contributionID)) {
             $batchContribution->batch_id = $batchID;
             $batchContribution->save();
             // get display name
             $displayName = CRM_Contact_BAO_Contact::displayName($contactId);
             // get Address & Postal Code from Address
             $params = array('contact_id' => $contactId, 'is_primary' => 1);
             $address = CRM_Core_BAO_Address::getValues($params);
             $address = $address[1];
             //adds all address lines to the report
             $fullFormatedAddress = CRM_Utils_Address::format($address);
             // get gift aid amount
             $giftAidAmount = self::_calculateGiftAidAmt($contribution['total_amount']);
             // FIXME: check if there is customTable method
             $query = "\nINSERT INTO civicrm_value_gift_aid_submission \n(entity_id, eligible_for_gift_aid, name, address, post_code, amount, gift_aid_amount) \nVALUES \n  ( %1, 1, %2, %3, %4, %5, %6 )\nON DUPLICATE KEY UPDATE \nname      = %2, \naddress   = %3,\npost_code = %4,\namount    = %5,\ngift_aid_amount = %6\n";
             $sqlParams = array(1 => array($contributionID, 'Integer'), 2 => array($displayName, 'String'), 3 => array($fullFormatedAddress, 'String'), 4 => array($address['postal_code'], 'String'), 5 => array($contribution['total_amount'], 'Money'), 6 => array($giftAidAmount, 'Money'));
             CRM_Core_DAO::executeQuery($query, $sqlParams);
             $contributionsAdded[] = $contributionID;
         } else {
             $contributionsNotAdded[] = $contributionID;
         }
     }
     if (!empty($contributionsAdded)) {
         // if there is any extra work required to be done for contributions that are batched,
         // should be done via hook
         GiftAid_Utils_Hook::batchContributions($batchID, $contributionsAdded);
     }
     return array(count($contributionIDs), count($contributionsAdded), count($contributionsNotAdded));
 }
 public function preProcess()
 {
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
     $this->assign('contactId', $this->_contactId);
     $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId);
     $this->assign('displayName', $displayName);
     // check logged in url permission
     CRM_Contact_Page_View::checkUserPermission($this);
 }
Exemplo n.º 29
0
 public function preProcess()
 {
     $params = $defaults = $ids = array();
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
     $params['id'] = $params['contact_id'] = $this->_contactId;
     $contact = CRM_Contact_BAO_Contact::retrieve($params, $defaults, $ids);
     $this->_displayName = $contact->display_name;
     $this->_email = $contact->email;
     CRM_Utils_System::setTitle(ts('Create User Record for %1', array(1 => $this->_displayName)));
 }
Exemplo n.º 30
0
 /**
  * Call preprocess.
  */
 public function preProcess()
 {
     parent::preProcess();
     $this->_groupID = CRM_Utils_Request::retrieve('groupID', 'Positive', $this, TRUE, NULL, $_REQUEST);
     $this->assign('customGroupId', $this->_groupID);
     $customRecId = CRM_Utils_Request::retrieve('customRecId', 'Positive', $this, FALSE, 1, $_REQUEST);
     $cgcount = CRM_Utils_Request::retrieve('cgcount', 'Positive', $this, FALSE, 1, $_REQUEST);
     $subType = CRM_Contact_BAO_Contact::getContactSubType($this->_contactId, ',');
     CRM_Custom_Form_CustomData::preProcess($this, NULL, $subType, $cgcount, $this->_contactType, $this->_contactId);
 }