/** * 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(); }
/** * Function to list participations for the UF user * * return null * @access public */ function listParticipations() { $controller = new CRM_Core_Controller_Simple('CRM_Event_Form_Search', ts('Events'), NULL); $controller->setEmbedded(TRUE); $controller->reset(); $controller->set('context', 'user'); $controller->set('cid', $this->_contactId); $controller->set('force', 1); $controller->process(); $controller->run(); }
/** * This function is called when action is browse * * return null * @access public */ function browse() { $controller = new CRM_Core_Controller_Simple('CRM_Tag_Form_Tag', ts('Contact Tags'), $this->_action); $controller->setEmbedded(TRUE); // set the userContext stack $session = CRM_Core_Session::singleton(); $session->pushUserContext(CRM_Utils_System::url('civicrm/contact/view', 'action=browse&selectedChild=tag'), FALSE); $controller->reset(); $controller->set('contactId', $this->_contactId); $controller->process(); $controller->run(); }
/** * This function is called when action is update * * @param int $groupID group id * * return null * @access public */ function edit($groupId = NULL) { $controller = new CRM_Core_Controller_Simple('CRM_Contact_Form_GroupContact', ts('Contact\'s Groups'), $this->_action); $controller->setEmbedded(TRUE); // set the userContext stack $session = CRM_Core_Session::singleton(); $session->pushUserContext(CRM_Utils_System::url('civicrm/contact/view', "action=browse&selectedChild=group&cid={$this->_contactId}"), FALSE); $controller->reset(); $controller->set('contactId', $this->_contactId); $controller->set('groupId', $groupId); $controller->process(); $controller->run(); }
/** * This function is the main function that is called when the page loads, * it decides the which action has to be taken for the page. * * return null * @access public */ function run() { $this->preProcess(); $controller = new CRM_Core_Controller_Simple('CRM_Grant_Form_Search', ts('grants'), NULL); $controller->setEmbedded(TRUE); $controller->reset(); $controller->set('limit', 10); $controller->set('force', 1); $controller->set('context', 'dashboard'); $controller->process(); $controller->run(); return parent::run(); }
/** * This function is called when action is update or new * * return null * @access public */ function edit() { $controller = new CRM_Core_Controller_Simple('CRM_Contact_Form_APIKey', ts('API Key'), $this->_action); $controller->setEmbedded(TRUE); // set the userContext stack $session = CRM_Core_Session::singleton(); $url = CRM_Utils_System::url('civicrm/contact/view/apikey', 'action=browse&selectedChild=apikey&cid=' . $this->_contactId); $session->pushUserContext($url); $controller->reset(); $controller->set('contactId', $this->_contactId); $controller->process(); $controller->run(); }
/** * This function is called when action is browse * * return null * @access public */ function browse() { $controller = new CRM_Core_Controller_Simple('CRM_Event_Form_Search', ts('Events'), $this->_action); $controller->setEmbedded(TRUE); $controller->reset(); $controller->set('cid', $this->_contactId); $controller->set('context', 'participant'); $controller->process(); $controller->run(); if ($this->_contactId) { $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId); $this->assign('displayName', $displayName); } }
/** * Function to list participations for the UF user * * return null * @access public */ function listActivities() { $controller = new CRM_Core_Controller_Simple('CRM_Activity_Form_Search', ts('Activities'), NULL, FALSE, FALSE, TRUE, FALSE); $controller->setEmbedded(TRUE); $controller->reset(); $controller->set('context', 'user'); $controller->set('cid', $this->_contactId); $controller->set('status', array(1 => 'on', 7 => 'on')); $controller->set('activity_role', 2); $controller->set('force', 1); $controller->process(); $controller->run(); return; }
/** * This function is called when action is browse * * return null * @access public */ function browse() { require_once 'CRM/Contribute/BAO/Contribution.php'; // add annual contribution $annual = array(); list($annual['count'], $annual['amount'], $annual['avg']) = CRM_Contribute_BAO_Contribution::annual($this->_contactId); $this->assign('annual', $annual); $controller = new CRM_Core_Controller_Simple('CRM_Contribute_Form_Search', ts('Contributions'), $this->_action); $controller->setEmbedded(true); $controller->reset(); $controller->set('cid', $this->_contactId); $controller->set('id', $this->_id); $controller->set('context', 'contribution'); $controller->process(); $controller->run(); //add honor block // form all action links $action = array_sum(array_keys($this->honorLinks())); $params = array(); $params = CRM_Contribute_BAO_Contribution::getHonorContacts($this->_contactId); if (!empty($params)) { foreach ($params as $ids => $honorId) { $params[$ids]['action'] = CRM_Core_Action::formLink(self::honorLinks(), $action, array('cid' => $honorId['honorId'], 'id' => $ids, 'cxt' => 'contribution', 'contributionType' => $honorId['type_id'], 'honorId' => $this->_contactId)); } // assign vars to templates $this->assign('action', $this->_action); $this->assign('honorRows', $params); $this->assign('honor', true); } //enable/disable soft credit records for test contribution $isTest = 0; if (CRM_Utils_Request::retrieve('isTest', 'Positive', $this)) { $isTest = 1; } $this->assign('isTest', $isTest); $softCreditList = CRM_Contribute_BAO_Contribution::getSoftContributionList($this->_contactId, $isTest); if (!empty($softCreditList)) { $softCreditTotals = array(); list($softCreditTotals['amount'], $softCreditTotals['avg'], $softCreditTotals['currency']) = CRM_Contribute_BAO_Contribution::getSoftContributionTotals($this->_contactId, $isTest); $this->assign('softCredit', true); $this->assign('softCreditRows', $softCreditList); $this->assign('softCreditTotals', $softCreditTotals); } if ($this->_contactId) { require_once 'CRM/Contact/BAO/Contact.php'; $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId); $this->assign('displayName', $displayName); } }
/** * This function is called when action is browse * * return null * @access public */ function browse() { $controller = new CRM_Core_Controller_Simple('CRM_Grant_Form_Search', ts('Grants'), $this->_action); $controller->setEmbedded(TRUE); $controller->reset(); $controller->set('cid', $this->_contactId); $controller->set('context', 'grant'); $controller->process(); $controller->run(); if ($this->_contactId) { $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId); $this->assign('displayName', $displayName); $this->ajaxResponse['tabCount'] = CRM_Contact_BAO_Contact::getCountComponent('grant', $this->_contactId); } }
/** * This function is called when action is browse * * return null * @access public */ function browse() { $controller = new CRM_Core_Controller_Simple('CRM_Pledge_Form_Search', ts('Pledges'), $this->_action); $controller->setEmbedded(true); $controller->reset(); $controller->set('cid', $this->_contactId); $controller->set('context', 'pledge'); $controller->process(); $controller->run(); if ($this->_contactId) { require_once 'CRM/Contact/BAO/Contact.php'; $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId); $this->assign('displayName', $displayName); } }
/** * List participations for the UF user. * * @return bool */ public function listActivities() { $controller = new CRM_Core_Controller_Simple('CRM_Activity_Form_Search', ts('Activities'), NULL, FALSE, FALSE, TRUE, FALSE); $controller->setEmbedded(TRUE); $controller->reset(); $controller->set('context', 'user'); $controller->set('cid', $this->_contactId); // Limit to status "Scheduled" and "Available" $controller->set('status', array('IN' => array(1, 7))); $controller->set('activity_role', 2); $controller->set('force', 1); $controller->process(); $controller->run(); return FALSE; }
/** * This function is called when action is browse * * return null * @access public */ function browse() { $controller = new CRM_Core_Controller_Simple('CRM_Booking_Form_Search', ts('Booking'), $this->_action); $controller->setEmbedded(TRUE); $controller->reset(); $controller->set('cid', $this->_contactId); $controller->set('context', 'booking'); $controller->process(); $controller->run(); if ($this->_contactId) { $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId); $this->assign('displayName', $displayName); } $bookings = CRM_Booking_BAO_Booking::getContactAssociatedBooking($this->_contactId); $this->assign('associatedBooking', $bookings); }
/** * This function is called when action is browse * * return null * @access public */ function browse() { $controller = new CRM_Core_Controller_Simple('CRM_Event_Form_Search', ts('Events'), $this->_action); $controller->setEmbedded(TRUE); $controller->reset(); $controller->set('cid', $this->_contactId); $controller->set('context', 'participant'); $controller->process(); $controller->run(); if ($this->_contactId) { $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId); $this->assign('displayName', $displayName); $this->ajaxResponse['tabCount'] = CRM_Contact_BAO_Contact::getCountComponent('participant', $this->_contactId); // Refresh other tabs with related data $this->ajaxResponse['updateTabs'] = array('#tab_contribute' => CRM_Contact_BAO_Contact::getCountComponent('contribution', $this->_contactId), '#tab_activity' => CRM_Contact_BAO_Contact::getCountComponent('activity', $this->_contactId)); } }
/** * called when action is browse. */ public function listPledges() { $controller = new CRM_Core_Controller_Simple('CRM_Pledge_Form_Search', ts('Pledges'), NULL, FALSE, FALSE, TRUE, FALSE); $controller->setEmbedded(TRUE); $controller->reset(); $controller->set('limit', 12); $controller->set('cid', $this->_contactId); $controller->set('context', 'user'); $controller->set('force', 1); $controller->process(); $controller->run(); // add honor block. $honorParams = array(); $honorParams = CRM_Pledge_BAO_Pledge::getHonorContacts($this->_contactId); if (!empty($honorParams)) { // assign vars to templates $this->assign('pledgeHonorRows', $honorParams); $this->assign('pledgeHonor', TRUE); } $session = CRM_Core_Session::singleton(); $loggedUserID = $session->get('userID'); $this->assign('loggedUserID', $loggedUserID); }
/** * Get the html for the form that represents this particular group. * * @param int $userID * The user id that we are actually editing. * @param string $title * The title of the group we are interested in. * @param int $action * The action of the form. * @param bool $register * Is this the registration form. * @param bool $reset * Should we reset the form?. * @param int $profileID * Do we have the profile ID?. * * @param bool $doNotProcess * @param null $ctype * * @return string * the html for the form on success, otherwise empty string */ public static function getEditHTML($userID, $title, $action = NULL, $register = FALSE, $reset = FALSE, $profileID = NULL, $doNotProcess = FALSE, $ctype = NULL) { if ($register) { $controller = new CRM_Core_Controller_Simple('CRM_Profile_Form_Dynamic', ts('Dynamic Form Creator'), $action); if ($reset || $doNotProcess) { // hack to make sure we do not process this form $oldQFDefault = CRM_Utils_Array::value('_qf_default', $_POST); unset($_POST['_qf_default']); unset($_REQUEST['_qf_default']); if ($reset) { $controller->reset(); } } $controller->set('id', $userID); $controller->set('register', 1); $controller->set('skipPermission', 1); $controller->set('ctype', $ctype); $controller->process(); if ($doNotProcess || !empty($_POST)) { $controller->validate(); } $controller->setEmbedded(TRUE); //CRM-5839 - though we want to process form, get the control back. $controller->setSkipRedirection($doNotProcess ? FALSE : TRUE); $controller->run(); // we are done processing so restore the POST/REQUEST vars if (($reset || $doNotProcess) && $oldQFDefault) { $_POST['_qf_default'] = $_REQUEST['_qf_default'] = $oldQFDefault; } $template = CRM_Core_Smarty::singleton(); // Hide CRM error messages if they are displayed using drupal form_set_error. if (!empty($_POST)) { $template->assign('suppressForm', TRUE); } return trim($template->fetch('CRM/Profile/Form/Dynamic.tpl')); } else { if (!$profileID) { // make sure we have a valid group $group = new CRM_Core_DAO_UFGroup(); $group->title = $title; if ($group->find(TRUE)) { $profileID = $group->id; } } if ($profileID) { // make sure profileID and ctype match if ctype exists if ($ctype) { $profileType = CRM_Core_BAO_UFField::getProfileType($profileID); if (CRM_Contact_BAO_ContactType::isaSubType($profileType)) { $profileType = CRM_Contact_BAO_ContactType::getBasicType($profileType); } if ($profileType != 'Contact' && $profileType != $ctype) { return NULL; } } $controller = new CRM_Core_Controller_Simple('CRM_Profile_Form_Dynamic', ts('Dynamic Form Creator'), $action); if ($reset) { $controller->reset(); } $controller->set('gid', $profileID); $controller->set('id', $userID); $controller->set('register', 0); $controller->set('skipPermission', 1); if ($ctype) { $controller->set('ctype', $ctype); } $controller->process(); $controller->setEmbedded(TRUE); //CRM-5846 - give the control back to drupal. $controller->setSkipRedirection($doNotProcess ? FALSE : TRUE); $controller->run(); $template = CRM_Core_Smarty::singleton(); // Hide CRM error messages if they are displayed using drupal form_set_error. if (!empty($_POST) && CRM_Core_Config::singleton()->userFramework == 'Drupal') { if (arg(0) == 'user' || arg(0) == 'admin' && arg(1) == 'people') { $template->assign('suppressForm', TRUE); } } $templateFile = "CRM/Profile/Form/{$profileID}/Dynamic.tpl"; if (!$template->template_exists($templateFile)) { $templateFile = 'CRM/Profile/Form/Dynamic.tpl'; } return trim($template->fetch($templateFile)); } else { $userEmail = CRM_Contact_BAO_Contact_Location::getEmailDetails($userID); // if post not empty then only proceed if (!empty($_POST)) { // get the new email $config = CRM_Core_Config::singleton(); $email = CRM_Utils_Array::value('mail', $_POST); if (CRM_Utils_Rule::email($email) && $email != $userEmail[1]) { CRM_Core_BAO_UFMatch::updateContactEmail($userID, $email); } } } } return ''; }
/** * This function is used for the to show the associated * contribution for the membership * @form array $form (ref.) an assoc array of name/value pairs * return null * @access public */ function associatedContribution($contactId = NULL, $membershipId = NULL) { if (!$contactId) { $contactId = $this->_contactId; } if (!$membershipId) { $membershipId = $this->_id; } // retrieive membership contributions if the $membershipId is set if (CRM_Core_Permission::access('CiviContribute') && $membershipId) { $this->assign('accessContribution', TRUE); $controller = new CRM_Core_Controller_Simple('CRM_Contribute_Form_Search', ts('Contributions'), NULL); $controller->setEmbedded(TRUE); $controller->reset(); $controller->set('force', 1); $controller->set('cid', $contactId); $controller->set('memberId', $membershipId); $controller->set('context', 'contribution'); $controller->process(); $controller->run(); } else { $this->assign('accessContribution', FALSE); } }
/** * This function is called when action is browse * * return null * @access public */ function browse() { // add annual contribution $annual = array(); list($annual['count'], $annual['amount'], $annual['avg']) = CRM_Contribute_BAO_Contribution::annual($this->_contactId); $this->assign('annual', $annual); $controller = new CRM_Core_Controller_Simple('CRM_Contribute_Form_Search', ts('Contributions'), $this->_action); $controller->setEmbedded(TRUE); $controller->reset(); $controller->set('cid', $this->_contactId); $controller->set('crid', $this->_crid); $controller->set('context', 'contribution'); $controller->process(); $controller->run(); // add recurring block $action = array_sum(array_keys($this->recurLinks())); $params = CRM_Contribute_BAO_ContributionRecur::getRecurContributions($this->_contactId); if (!empty($params)) { foreach ($params as $ids => $recur) { $action = array_sum(array_keys($this->recurLinks($ids))); // no action allowed if it's not active $params[$ids]['is_active'] = $recur['contribution_status_id'] != 3; if ($params[$ids]['is_active']) { $details = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($params[$ids]['id'], 'recur'); $hideUpdate = $details->membership_id & $details->auto_renew; if ($hideUpdate) { $action -= CRM_Core_Action::UPDATE; } $params[$ids]['action'] = CRM_Core_Action::formLink(self::recurLinks($ids), $action, array('cid' => $this->_contactId, 'crid' => $ids, 'cxt' => 'contribution')); } } // assign vars to templates $this->assign('action', $this->_action); $this->assign('recurRows', $params); $this->assign('recur', TRUE); } //add honor block // form all action links $action = array_sum(array_keys($this->honorLinks())); $params = array(); $params = CRM_Contribute_BAO_Contribution::getHonorContacts($this->_contactId); if (!empty($params)) { foreach ($params as $ids => $honorId) { $params[$ids]['action'] = CRM_Core_Action::formLink(self::honorLinks(), $action, array('cid' => $honorId['honorId'], 'id' => $ids, 'cxt' => 'contribution', 'contributionType' => $honorId['type_id'], 'honorId' => $this->_contactId)); } // assign vars to templates $this->assign('action', $this->_action); $this->assign('honorRows', $params); $this->assign('honor', TRUE); } //enable/disable soft credit records for test contribution $isTest = 0; if (CRM_Utils_Request::retrieve('isTest', 'Positive', $this)) { $isTest = 1; } $this->assign('isTest', $isTest); $softCreditList = CRM_Contribute_BAO_Contribution::getSoftContributionList($this->_contactId, $isTest); if (!empty($softCreditList)) { $softCreditTotals = array(); list($softCreditTotals['amount'], $softCreditTotals['avg'], $softCreditTotals['currency']) = CRM_Contribute_BAO_Contribution::getSoftContributionTotals($this->_contactId, $isTest); $this->assign('softCredit', TRUE); $this->assign('softCreditRows', $softCreditList); $this->assign('softCreditTotals', $softCreditTotals); } if ($this->_contactId) { $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId); $this->assign('displayName', $displayName); } }
/** * This function is called when action is browse * * return null * @access public */ function listContribution() { $controller = new CRM_Core_Controller_Simple('CRM_Contribute_Form_Search', ts('Contributions'), null); $controller->setEmbedded(true); $controller->reset(); $controller->set('limit', 12); $controller->set('cid', $this->_contactId); $controller->set('context', 'user'); $controller->set('force', 1); $controller->process(); $controller->run(); //add honor block require_once 'CRM/Contribute/BAO/Contribution.php'; $params = array(); $params = CRM_Contribute_BAO_Contribution::getHonorContacts($this->_contactId); if (!empty($params)) { // assign vars to templates $this->assign('honorRows', $params); $this->assign('honor', true); } require_once 'CRM/Contribute/Form/ContributionBase.php'; require_once 'CRM/Contribute/BAO/ContributionRecur.php'; $recur = new CRM_Contribute_DAO_ContributionRecur(); $recur->contact_id = $this->_contactId; $recur->is_test = 0; $recur->find(); $config = CRM_Core_Config::singleton(); $recurStatus = CRM_Contribute_PseudoConstant::contributionStatus(); require_once 'CRM/Core/Payment.php'; require_once 'api/v2/utils.php'; $recurRow = array(); $recurIDs = array(); while ($recur->fetch()) { $mode = $recur->is_test ? 'test' : 'live'; $paymentProcessor = CRM_Contribute_BAO_ContributionRecur::getPaymentProcessor($recur->id, $mode); if (!$paymentProcessor) { continue; } // note that we are passing a CRM_Core_Page object ($this) as if it were a form here: $paymentObject =& CRM_Core_Payment::singleton($mode, $paymentProcessor, $this); _civicrm_object_to_array($recur, $values); $values['cancelSubscriptionUrl'] = $paymentObject->cancelSubscriptionURL(); $values['recur_status'] = $recurStatus[$values['contribution_status_id']]; $recurRow[$values['id']] = $values; $recurIDs[] = $values['id']; //reset $paymentObject for checking other paymenet processor //recurring url $paymentObject = null; } if (is_array($recurIDs) && !empty($recurIDs)) { $getCount = CRM_Contribute_BAO_ContributionRecur::getCount($recurIDs); foreach ($getCount as $key => $val) { $recurRow[$key]['completed'] = $val; $recurRow[$key]['link'] = CRM_Utils_System::url('civicrm/contribute/search', "reset=1&force=1&recur={$key}"); } } $this->assign('recurRows', $recurRow); if (!empty($recurRow)) { $this->assign('recur', true); } else { $this->assign('recur', false); } }
/** * used for the to show the associated. * contribution for the membership * * @param int $contactId * @param int $membershipId */ public static function associatedContribution($contactId = NULL, $membershipId = NULL) { $controller = new CRM_Core_Controller_Simple('CRM_Contribute_Form_Search', ts('Contributions'), NULL, FALSE, FALSE, TRUE); $controller->setEmbedded(TRUE); $controller->reset(); $controller->set('force', 1); $controller->set('cid', $contactId); $controller->set('memberId', $membershipId); $controller->set('context', 'contribution'); $controller->process(); $controller->run(); }
/** * Called when action is browse. */ public function browse() { $controller = new CRM_Core_Controller_Simple('CRM_Case_Form_Search', ts('Case'), CRM_Core_Action::BROWSE); $controller->setEmbedded(TRUE); $controller->reset(); $controller->set('limit', 20); $controller->set('force', 1); $controller->set('context', 'case'); $controller->process(); $controller->run(); if ($this->_contactId) { $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId); $this->assign('displayName', $displayName); $this->ajaxResponse['tabCount'] = CRM_Contact_BAO_Contact::getCountComponent('case', $this->_contactId); } }
/** * This function is called when action is browse * * return null * @access public */ function browse() { $controller = new CRM_Core_Controller_Simple('CRM_Case_Form_Search', ts('Case'), NULL); $controller->setEmbedded(TRUE); $controller->reset(); $controller->set('limit', 20); $controller->set('force', 1); $controller->set('context', 'case'); $controller->process(); $controller->run(); if ($this->_contactId) { $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId); $this->assign('displayName', $displayName); } }
/** * This function is called when action is update or new * * return null * @access public */ function edit() { $controller = new CRM_Core_Controller_Simple('CRM_Note_Form_Note', ts('Contact Notes'), $this->_action); $controller->setEmbedded(TRUE); // set the userContext stack $session = CRM_Core_Session::singleton(); $url = CRM_Utils_System::url('civicrm/contact/view', 'action=browse&selectedChild=note&cid=' . $this->_contactId); $session->pushUserContext($url); if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', CRM_Core_DAO::$_nullObject)) { CRM_Core_BAO_Note::del($this->_id); CRM_Utils_System::redirect($url); } $controller->reset(); $controller->set('entityTable', 'civicrm_contact'); $controller->set('entityId', $this->_contactId); $controller->set('id', $this->_id); $controller->process(); $controller->run(); }
/** * get the html for the form that represents this particular group * * @param int $userID the user id that we are actually editing * @param string $title the title of the group we are interested in * @param int $action the action of the form * @param boolean $register is this the registration form * @param boolean $reset should we reset the form? * @param int $profileID do we have the profile ID? * * @return string the html for the form on success, otherwise empty string * @static * @access public */ static function getEditHTML($userID, $title, $action = null, $register = false, $reset = false, $profileID = null, $doNotProcess = false, $ctype = null) { require_once "CRM/Core/Controller/Simple.php"; $session = CRM_Core_Session::singleton(); if ($register) { $controller = new CRM_Core_Controller_Simple('CRM_Profile_Form_Dynamic', ts('Dynamic Form Creator'), $action); if ($reset || $doNotProcess) { // hack to make sure we do not process this form $oldQFDefault = CRM_Utils_Array::value('_qf_default', $_POST); unset($_POST['_qf_default']); unset($_REQUEST['_qf_default']); if ($reset) { $controller->reset(); } } $controller->set('id', $userID); $controller->set('register', 1); $controller->set('skipPermission', 1); $controller->set('ctype', $ctype); $controller->process(); if ($doNotProcess) { $controller->validate(); } $controller->setEmbedded(true); //CRM-5839 - though we want to process form, get the control back. $controller->setSkipRedirection($doNotProcess ? false : true); $controller->run(); // we are done processing so restore the POST/REQUEST vars if (($reset || $doNotProcess) && $oldQFDefault) { $_POST['_qf_default'] = $_REQUEST['_qf_default'] = $oldQFDefault; } $template = CRM_Core_Smarty::singleton(); return trim($template->fetch('CRM/Profile/Form/Dynamic.tpl')); } else { if (!$profileID) { // make sure we have a valid group $group = new CRM_Core_DAO_UFGroup(); $group->title = $title; if ($group->find(true)) { $profileID = $group->id; } } if ($profileID) { // make sure profileID and ctype match if ctype exists if ($ctype) { require_once 'CRM/Core/BAO/UFField.php'; $profileType = CRM_Core_BAO_UFField::getProfileType($profileID); if (CRM_Contact_BAO_ContactType::isaSubType($profileType)) { $profileType = CRM_Contact_BAO_ContactType::getBasicType($profileType); } if ($profileType != 'Contact' && $profileType != $ctype) { return null; } } $controller = new CRM_Core_Controller_Simple('CRM_Profile_Form_Dynamic', ts('Dynamic Form Creator'), $action); if ($reset) { $controller->reset(); } $controller->set('gid', $profileID); $controller->set('id', $userID); $controller->set('register', 0); $controller->set('skipPermission', 1); if ($ctype) { $controller->set('ctype', $ctype); } $controller->process(); $controller->setEmbedded(true); //CRM-5846 - give the control back to drupal. $controller->setSkipRedirection($doNotProcess ? false : true); $controller->run(); $template = CRM_Core_Smarty::singleton(); $templateFile = "CRM/Profile/Form/{$profileID}/Dynamic.tpl"; if (!$template->template_exists($templateFile)) { $templateFile = "CRM/Profile/Form/Dynamic.tpl"; } return trim($template->fetch($templateFile)); } else { require_once 'CRM/Contact/BAO/Contact/Location.php'; $userEmail = CRM_Contact_BAO_Contact_Location::getEmailDetails($userID); // if post not empty then only proceed if (!empty($_POST)) { // get the new email $config = CRM_Core_Config::singleton(); $email = CRM_Utils_Array::value('mail', $_POST); if (CRM_Utils_Rule::email($email) && $email != $userEmail[1]) { require_once 'CRM/Core/BAO/UFMatch.php'; CRM_Core_BAO_UFMatch::updateContactEmail($userID, $email); } } } } return ''; }
/** * called when action is browse. * */ public function browse() { // add annual contribution $annual = array(); list($annual['count'], $annual['amount'], $annual['avg']) = CRM_Contribute_BAO_Contribution::annual($this->_contactId); $this->assign('annual', $annual); $controller = new CRM_Core_Controller_Simple('CRM_Contribute_Form_Search', ts('Contributions'), $this->_action, FALSE, FALSE, TRUE); $controller->setEmbedded(TRUE); $controller->reset(); $controller->set('cid', $this->_contactId); $controller->set('crid', $this->_crid); $controller->set('context', 'contribution'); $controller->set('limit', 50); $controller->process(); $controller->run(); // add recurring block $action = array_sum(array_keys($this->recurLinks())); $params = CRM_Contribute_BAO_ContributionRecur::getRecurContributions($this->_contactId); // Get all backoffice payment processors $backOfficePaymentProcessors = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors(array('BackOffice')); if (!empty($params)) { foreach ($params as $ids => $recur) { $action = array_sum(array_keys($this->recurLinks($ids))); // no action allowed if it's not active $params[$ids]['is_active'] = $recur['contribution_status_id'] != 3; // Get payment processor name $paymentProcessorDetails = CRM_Financial_BAO_PaymentProcessor::getPayment($params[$ids]['payment_processor_id'], 'live'); $params[$ids]['payment_processor_name'] = $paymentProcessorDetails['name']; $details = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($params[$ids]['id'], 'recur'); $hideUpdate = $details->membership_id & $details->auto_renew; if ($hideUpdate) { $action -= CRM_Core_Action::UPDATE; } $links = self::recurLinks($ids); // Disable Edit/Delete link if no back office support if (!array_key_exists($recur['payment_processor_id'], $backOfficePaymentProcessors)) { unset($links[2]); unset($links[8]); } // Remove cancel link for already cancelled recurring records if ($recur['contribution_status_id'] == 3) { unset($links[64]); } $params[$ids]['action'] = CRM_Core_Action::formLink($links, $action, array('cid' => $this->_contactId, 'crid' => $ids, 'cxt' => 'contribution'), ts('more'), FALSE, 'contribution.selector.recurring', 'Contribution', $ids); } // assign vars to templates $this->assign('action', $this->_action); $this->assign('recurRows', $params); $this->assign('recur', TRUE); } //enable/disable soft credit records for test contribution $isTest = 0; if (CRM_Utils_Request::retrieve('isTest', 'Positive', $this)) { $isTest = 1; } $this->assign('isTest', $isTest); $softCreditList = CRM_Contribute_BAO_ContributionSoft::getSoftContributionList($this->_contactId, NULL, $isTest); if (!empty($softCreditList)) { $softCreditTotals = array(); list($softCreditTotals['amount'], $softCreditTotals['avg'], $softCreditTotals['currency']) = CRM_Contribute_BAO_ContributionSoft::getSoftContributionTotals($this->_contactId, $isTest); $this->assign('softCredit', TRUE); $this->assign('softCreditRows', $softCreditList); $this->assign('softCreditTotals', $softCreditTotals); } if ($this->_contactId) { $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId); $this->assign('displayName', $displayName); $this->ajaxResponse['tabCount'] = CRM_Contribute_BAO_ContributionRecur::contributionRecurCount($this->_contactId); } }
/** * This function is for profile mode (standalone html form ) for uf group * * @return void * @access public */ function profile() { $config = CRM_Core_Config::singleton(); // reassign resource base to be the full url, CRM-4660 $config->resourceBase = $config->userFrameworkResourceURL; $config->useFrameworkRelativeBase = $config->userFrameworkBaseURL; $gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this, FALSE, 0, 'GET'); $controller = new CRM_Core_Controller_Simple('CRM_Profile_Form_Edit', ts('Create'), CRM_Core_Action::ADD, FALSE, FALSE, TRUE); $controller->reset(); $controller->process(); $controller->set('gid', $gid); $controller->setEmbedded(TRUE); $controller->run(); $template = CRM_Core_Smarty::singleton(); $template->assign('gid', $gid); $template->assign('tplFile', 'CRM/Profile/Form/Edit.tpl'); $profile = trim($template->fetch('CRM/Form/default.tpl')); // not sure how to circumvent our own navigation system to generate the right form url $urlReplaceWith = 'civicrm/profile/create&gid=' . $gid . '&reset=1'; if ($config->userSystem->is_drupal && $config->cleanURL) { $urlReplaceWith = 'civicrm/profile/create?gid=' . $gid . '&reset=1'; } $profile = str_replace('civicrm/admin/uf/group', $urlReplaceWith, $profile); // FIXME: (CRM-3587) hack to make standalone profile work // in wordpress and joomla without administrator login if ($config->userFramework == 'Joomla') { $profile = str_replace('/administrator/', '/index.php', $profile); } elseif ($config->userFramework == 'WordPress') { $profile = str_replace('/wp-admin/admin.php', '/index.php', $profile); } // add jquery files $profile = CRM_Utils_String::addJqueryFiles($profile); $this->assign('profile', htmlentities($profile, ENT_NOQUOTES, 'UTF-8')); //get the title of uf group if ($gid) { $title = CRM_Core_BAO_UFGroup::getTitle($gid); $this->_title = $title; } else { $title = 'Profile Form'; } $this->assign('title', $title); $this->assign('action', CRM_Core_Action::PROFILE); $this->assign('isForm', 0); }
/** * called when action is browse. */ public function listContribution() { $controller = new CRM_Core_Controller_Simple('CRM_Contribute_Form_Search', ts('Contributions'), NULL, FALSE, FALSE, TRUE, FALSE); $controller->setEmbedded(TRUE); $controller->reset(); $controller->set('limit', 12); $controller->set('cid', $this->_contactId); $controller->set('context', 'user'); $controller->set('force', 1); $controller->process(); $controller->run(); //add honor block $params = CRM_Contribute_BAO_Contribution::getHonorContacts($this->_contactId); if (!empty($params)) { // assign vars to templates $this->assign('honorRows', $params); $this->assign('honor', TRUE); } $recur = new CRM_Contribute_DAO_ContributionRecur(); $recur->contact_id = $this->_contactId; $recur->is_test = 0; $recur->find(); $config = CRM_Core_Config::singleton(); $recurStatus = CRM_Contribute_PseudoConstant::contributionStatus(); $recurRow = array(); $recurIDs = array(); while ($recur->fetch()) { $mode = $recur->is_test ? 'test' : 'live'; $paymentProcessor = CRM_Contribute_BAO_ContributionRecur::getPaymentProcessor($recur->id, $mode); if (!$paymentProcessor) { continue; } require_once 'api/v3/utils.php'; //@todo calling api functions directly is not supported _civicrm_api3_object_to_array($recur, $values); $values['recur_status'] = $recurStatus[$values['contribution_status_id']]; $recurRow[$values['id']] = $values; $action = array_sum(array_keys(CRM_Contribute_Page_Tab::recurLinks($recur->id, 'dashboard'))); $details = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($recur->id, 'recur'); $hideUpdate = $details->membership_id & $details->auto_renew; if ($hideUpdate) { $action -= CRM_Core_Action::UPDATE; } $recurRow[$values['id']]['action'] = CRM_Core_Action::formLink(CRM_Contribute_Page_Tab::recurLinks($recur->id, 'dashboard'), $action, array('cid' => $this->_contactId, 'crid' => $values['id'], 'cxt' => 'contribution'), ts('more'), FALSE, 'contribution.dashboard.recurring', 'Contribution', $values['id']); $recurIDs[] = $values['id']; //reset $paymentObject for checking other paymenet processor //recurring url $paymentObject = NULL; } if (is_array($recurIDs) && !empty($recurIDs)) { $getCount = CRM_Contribute_BAO_ContributionRecur::getCount($recurIDs); foreach ($getCount as $key => $val) { $recurRow[$key]['completed'] = $val; $recurRow[$key]['link'] = CRM_Utils_System::url('civicrm/contribute/search', "reset=1&force=1&recur={$key}"); } } $this->assign('recurRows', $recurRow); if (!empty($recurRow)) { $this->assign('recur', TRUE); } else { $this->assign('recur', FALSE); } }
/** * This function is called when action is browse * * return null * @access public */ function browse() { CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); // add annual contribution $annual = array(); list($annual['count'], $annual['amount'], $annual['avg']) = CRM_Contribute_BAO_Contribution::annual($this->_contactId); $this->assign('annual', $annual); $controller = new CRM_Core_Controller_Simple('CRM_Contribute_Form_Search', ts('Contributions'), $this->_action, FALSE, FALSE, TRUE); $controller->setEmbedded(TRUE); $controller->reset(); $controller->set('cid', $this->_contactId); $controller->set('crid', $this->_crid); $controller->set('context', 'Search'); $controller->set('limit', 50); $controller->process(); $controller->run(); // add recurring block $action = array_sum(array_keys($this->recurLinks())); $params = CRM_Contribute_BAO_ContributionRecur::getRecurContributions($this->_contactId); if (!empty($params)) { foreach ($params as $ids => $recur) { $action = array_sum(array_keys($this->recurLinks($ids))); // no action allowed if it's not active $params[$ids]['is_active'] = $recur['contribution_status_id'] != 3; if ($params[$ids]['is_active']) { $details = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($params[$ids]['id'], 'recur'); $hideUpdate = $details->membership_id & $details->auto_renew; if ($hideUpdate) { $action -= CRM_Core_Action::UPDATE; } $params[$ids]['action'] = CRM_Core_Action::formLink(self::recurLinks($ids), $action, array('cid' => $this->_contactId, 'crid' => $ids, 'cxt' => 'contribution'), ts('more'), FALSE, 'contribution.selector.recurring', 'Contribution', $ids); } } // assign vars to templates $this->assign('action', $this->_action); $this->assign('recurRows', $params); $this->assign('recur', TRUE); } //enable/disable soft credit records for test contribution $isTest = 0; if (CRM_Utils_Request::retrieve('isTest', 'Positive', $this)) { $isTest = 1; } $this->assign('isTest', $isTest); $softCreditList = CRM_Contribute_BAO_ContributionSoft::getSoftContributionList($this->_contactId, $isTest); if (!empty($softCreditList)) { $softCreditTotals = array(); list($softCreditTotals['amount'], $softCreditTotals['avg'], $softCreditTotals['currency']) = CRM_Contribute_BAO_ContributionSoft::getSoftContributionTotals($this->_contactId, $isTest); $this->assign('softCredit', TRUE); $this->assign('softCreditRows', $softCreditList); $this->assign('softCreditTotals', $softCreditTotals); } if ($this->_contactId) { $displayName = CRM_Contact_BAO_Contact::displayName($this->_contactId); $this->assign('displayName', $displayName); $this->ajaxResponse['tabCount'] = CRM_Contact_BAO_Contact::getCountComponent('contribution', $this->_contactId); } }
/** * This function is the main function that is called when the page loads, * it decides the which action has to be taken for the page. * * return null * @access public */ function run() { $this->preProcess(); $controller = new CRM_Core_Controller_Simple('CRM_Pledge_Form_Search', ts('Pledge'), null); $controller->setEmbedded(true); $controller->reset(); $controller->set('limit', 10); $controller->set('force', 1); $controller->set('context', 'dashboard'); $controller->process(); $controller->run(); return parent::run(); }