Пример #1
0
 public function preProcess()
 {
     $session =& CRM_Core_Session::singleton();
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false);
     $this->_pageId = CRM_Utils_Request::retrieve('pageId', 'Positive', $this);
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     if ($this->_id) {
         $contactID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_PCP', $this->_id, 'contact_id');
     }
     $this->_contactID = isset($contactID) ? $contactID : $session->get('userID');
     if (!$this->_pageId) {
         $this->_pageId = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_PCP', $this->_id, 'contribution_page_id');
     }
     $config =& CRM_Core_Config::singleton();
     //redirect back to online Contribution page, we allow only logged in
     //user to configure the PCP account and Page in standalone installation.
     if ($config->userFramework == 'Standalone' && !$this->_contactID) {
         CRM_Core_Error::statusBounce(ts("You must login with your OpenID provider before you can create a Personal Campaign Page."), CRM_Utils_System::url('civicrm/contribute/transact', "reset=1&id={$this->_pageId}", false, null, false, true));
     }
     $this->_single = $this->get('single');
     if (!$this->_single) {
         $this->_single = $session->get('singleForm');
     }
     $this->set('action', $this->_action);
     $this->set('page_id', $this->_id);
     $this->set('contribution_page_id', $this->_pageId);
     // we do not want to display recently viewed items, so turn off
     $this->assign('displayRecent', false);
     if ($this->_single) {
         CRM_Utils_System::setTitle(ts('Update Contact Information'));
     }
 }
Пример #2
0
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, false);
     if ($id) {
         $this->_contributionIds = array($id);
         $this->_componentClause = " civicrm_contribution.id IN ( {$id} ) ";
         $this->_single = true;
         $this->assign('totalSelectedContributions', 1);
     } else {
         parent::preProcess();
     }
     // check that all the contribution ids have pending status
     $query = "\nSELECT count(*)\nFROM   civicrm_contribution\nWHERE  contribution_status_id != 2\nAND    {$this->_componentClause}";
     $count = CRM_Core_DAO::singleValueQuery($query, CRM_Core_DAO::$_nullArray);
     if ($count != 0) {
         CRM_Core_Error::statusBounce(ts('Please select only online contributions with Pending status.'));
     }
     // ensure that all contributions are generated online by pay later
     $query = "\nSELECT DISTINCT( source ) as source\nFROM   civicrm_contribution\nWHERE  {$this->_componentClause}";
     $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
     while ($dao->fetch()) {
         if (strpos($dao->source, ts('Online Contribution')) === false && strpos($dao->source, ts('Online Event Registration')) === false) {
             CRM_Core_Error::statusBounce("<strong>Update Pending Contribution Status</strong> can only be used for pending online contributions (made using the 'Pay Later' option). The Source for these contributions starts with 'Online ...'. Please de-select any offline contributions and try again.");
         }
     }
     // we have all the contribution ids, so now we get the contact ids
     parent::setContactIDs();
     $this->assign('single', $this->_single);
 }
Пример #3
0
 function run()
 {
     require_once 'CRM/Utils/Request.php';
     require_once 'CRM/Core/DAO.php';
     $eid = CRM_Utils_Request::retrieve('eid', 'Positive', $this, true);
     $fid = CRM_Utils_Request::retrieve('fid', 'Positive', $this, false);
     $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, true);
     $quest = CRM_Utils_Request::retrieve('quest', 'String', $this);
     $action = CRM_Utils_Request::retrieve('action', 'String', $this);
     require_once 'CRM/Core/BAO/File.php';
     list($path, $mimeType) = CRM_Core_BAO_File::path($id, $eid, null, $quest);
     if (!$path) {
         CRM_Core_Error::statusBounce('Could not retrieve the file');
     }
     $buffer = file_get_contents($path);
     if (!$buffer) {
         CRM_Core_Error::statusBounce('The file is either empty or you do not have permission to retrieve the file');
     }
     if ($action & CRM_Core_Action::DELETE) {
         if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', CRM_Core_DAO::$_nullObject)) {
             CRM_Core_BAO_File::delete($id, $eid, $fid);
             CRM_Core_Session::setStatus(ts('The attached file has been deleted.'));
             $session = CRM_Core_Session::singleton();
             $toUrl = $session->popUserContext();
             CRM_Utils_System::redirect($toUrl);
         } else {
             $wrapper = new CRM_Utils_Wrapper();
             return $wrapper->run('CRM_Custom_Form_DeleteFile', ts('Domain Information Page'), null);
         }
     } else {
         require_once 'CRM/Utils/File.php';
         CRM_Utils_System::download(CRM_Utils_File::cleanFileName(basename($path)), $mimeType, $buffer);
     }
 }
Пример #4
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();
 }
Пример #5
0
 /**
  * Pre-processing for the form.
  *
  * @throws \Exception
  */
 public function preProcess()
 {
     $this->setAction(CRM_Core_Action::UPDATE);
     $this->contributionRecurID = CRM_Utils_Request::retrieve('crid', 'Integer', $this, FALSE);
     if ($this->contributionRecurID) {
         $this->_paymentProcessor = CRM_Contribute_BAO_ContributionRecur::getPaymentProcessor($this->contributionRecurID);
         if (!$this->_paymentProcessor) {
             CRM_Core_Error::statusBounce(ts('There is no valid processor for this subscription so it cannot be edited.'));
         }
         $this->_paymentProcessorObj = $this->_paymentProcessor['object'];
         $this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->contributionRecurID);
     }
     $this->_coid = CRM_Utils_Request::retrieve('coid', 'Integer', $this, FALSE);
     if ($this->_coid) {
         $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'info');
         $this->_paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'obj');
         $this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_coid, 'contribution');
         $this->contributionRecurID = $this->_subscriptionDetails->recur_id;
     } elseif ($this->contributionRecurID) {
         $this->_coid = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $this->contributionRecurID, 'id', 'contribution_recur_id');
     }
     if (!$this->contributionRecurID || $this->_subscriptionDetails == CRM_Core_DAO::$_nullObject) {
         CRM_Core_Error::fatal('Required information missing.');
     }
     if ($this->_subscriptionDetails->membership_id && $this->_subscriptionDetails->auto_renew) {
         CRM_Core_Error::fatal(ts('You cannot update the subscription.'));
     }
     if (!CRM_Core_Permission::check('edit contributions')) {
         $userChecksum = CRM_Utils_Request::retrieve('cs', 'String', $this, FALSE);
         if (!CRM_Contact_BAO_Contact_Utils::validChecksum($this->_subscriptionDetails->contact_id, $userChecksum)) {
             CRM_Core_Error::fatal(ts('You do not have permission to update subscription.'));
         }
         $this->_selfService = TRUE;
     }
     $this->assign('self_service', $this->_selfService);
     $this->editableScheduleFields = $this->_paymentProcessorObj->getEditableRecurringScheduleFields();
     $changeHelpText = $this->_paymentProcessorObj->getRecurringScheduleUpdateHelpText();
     if (!in_array('amount', $this->editableScheduleFields)) {
         // Not sure if this is good behaviour - maintaining this existing behaviour for now.
         CRM_Core_Session::setStatus($changeHelpText, ts('Warning'), 'alert');
     } else {
         $this->assign('changeHelpText', $changeHelpText);
     }
     $alreadyHardCodedFields = array('amount', 'installments');
     foreach ($this->editableScheduleFields as $editableScheduleField) {
         if (!in_array($editableScheduleField, $alreadyHardCodedFields)) {
             $this->addField($editableScheduleField, array('entity' => 'ContributionRecur'));
         }
     }
     $this->assign('editableScheduleFields', array_diff($this->editableScheduleFields, $alreadyHardCodedFields));
     $this->assign('paymentProcessor', $this->_paymentProcessor);
     $this->assign('frequency_unit', $this->_subscriptionDetails->frequency_unit);
     $this->assign('frequency_interval', $this->_subscriptionDetails->frequency_interval);
     if ($this->_subscriptionDetails->contact_id) {
         list($this->_donorDisplayName, $this->_donorEmail) = CRM_Contact_BAO_Contact::getContactDetails($this->_subscriptionDetails->contact_id);
     }
     CRM_Utils_System::setTitle(ts('Update Recurring Contribution'));
     // Handle context redirection.
     CRM_Contribute_BAO_ContributionRecur::setSubscriptionContext();
 }
Пример #6
0
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     $this->_isTemplate = (bool) CRM_Utils_Request::retrieve('template', 'Integer', $this);
     $this->_id = CRM_Utils_Request::retrieve('id', 'Integer', $this);
     if ($this->_isTemplate) {
         CRM_Utils_System::setTitle(ts('New Vacancy Template'));
     }
     if ($this->_id) {
         if ($this->_isTemplate = CRM_Core_DAO::getFieldValue('CRM_HRRecruitment_DAO_HRVacancy', $this->_id, 'is_template')) {
             CRM_Utils_System::setTitle(ts('Edit Vacancy Template'));
         } else {
             CRM_Utils_System::setTitle(ts('Edit Vacancy'));
         }
     }
     $this->assign('isTemplate', $this->_isTemplate);
     $session = CRM_Core_Session::singleton();
     if ($this->_id) {
         $permission = CRM_HRRecruitment_BAO_HRVacancyPermission::checkVacancyPermission($this->_id, array("administer Vacancy", "administer CiviCRM"));
     } else {
         $permission = CRM_Core_Permission::checkAnyPerm(array("administer Vacancy", "administer CiviCRM"));
     }
     if (!$permission) {
         $session->pushUserContext(CRM_Utils_System::url('civicrm'));
         CRM_Core_Error::statusBounce(ts('You do not have the necessary permission to perform this action.'));
     }
     CRM_Core_Resources::singleton()->addScriptFile('org.civicrm.hrrecruitment', 'templates/CRM/HRRecruitment/Form/HRVacancy.js');
 }
Пример #7
0
 public function run()
 {
     $eid = CRM_Utils_Request::retrieve('eid', 'Positive', $this, TRUE);
     $fid = CRM_Utils_Request::retrieve('fid', 'Positive', $this, FALSE);
     $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
     $quest = CRM_Utils_Request::retrieve('quest', 'String', $this);
     $action = CRM_Utils_Request::retrieve('action', 'String', $this);
     list($path, $mimeType) = CRM_Core_BAO_File::path($id, $eid, NULL, $quest);
     if (!$path) {
         CRM_Core_Error::statusBounce('Could not retrieve the file');
     }
     $buffer = file_get_contents($path);
     if (!$buffer) {
         CRM_Core_Error::statusBounce('The file is either empty or you do not have permission to retrieve the file');
     }
     if ($action & CRM_Core_Action::DELETE) {
         if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', CRM_Core_DAO::$_nullObject)) {
             CRM_Core_BAO_File::deleteFileReferences($id, $eid, $fid);
             CRM_Core_Session::setStatus(ts('The attached file has been deleted.'), ts('Complete'), 'success');
             $session = CRM_Core_Session::singleton();
             $toUrl = $session->popUserContext();
             CRM_Utils_System::redirect($toUrl);
         }
     } else {
         CRM_Utils_System::download(CRM_Utils_File::cleanFileName(basename($path)), $mimeType, $buffer);
     }
 }
Пример #8
0
 /**
  * Build all the data structures needed to build the form.
  *
  * @return void
  */
 public function preProcess()
 {
     $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
     if ($id) {
         $this->_contributionIds = array($id);
         $this->_componentClause = " civicrm_contribution.id IN ( {$id} ) ";
         $this->_single = TRUE;
         $this->assign('totalSelectedContributions', 1);
     } else {
         parent::preProcess();
     }
     // check that all the contribution ids have pending status
     $query = "\nSELECT count(*)\nFROM   civicrm_contribution\nWHERE  contribution_status_id != 1\nAND    {$this->_componentClause}";
     $count = CRM_Core_DAO::singleValueQuery($query);
     if ($count != 0) {
         CRM_Core_Error::statusBounce("Please select only online contributions with Completed status.");
     }
     // we have all the contribution ids, so now we get the contact ids
     parent::setContactIDs();
     $this->assign('single', $this->_single);
     $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
     $urlParams = 'force=1';
     if (CRM_Utils_Rule::qfKey($qfKey)) {
         $urlParams .= "&qfKey={$qfKey}";
     }
     $url = CRM_Utils_System::url('civicrm/contribute/search', $urlParams);
     $breadCrumb = array(array('url' => $url, 'title' => ts('Search Results')));
     CRM_Utils_System::appendBreadCrumb($breadCrumb);
     CRM_Utils_System::setTitle(ts('Print Contribution Receipts'));
 }
Пример #9
0
 public function preProcess()
 {
     parent::preProcess();
     $this->_groupID = CRM_Utils_Request::retrieve('gid', 'Integer', $this, FALSE, NULL, 'REQUEST');
     // ensure that there is a destination, if not set the destination to the
     // referrer string
     if (!$this->controller->getDestination()) {
         $this->controller->setDestination(NULL, TRUE);
     }
     if ($this->_groupID) {
         $groupTypeCondition = CRM_Contact_BAO_Group::groupTypeCondition('Mailing');
         // make sure requested qroup is accessible and exists
         $query = "\nSELECT   title, description\n  FROM   civicrm_group\n WHERE   id={$this->_groupID}\n   AND   visibility != 'User and User Admin Only'\n   AND   {$groupTypeCondition}";
         $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray);
         if ($dao->fetch()) {
             $this->assign('groupName', $dao->title);
             CRM_Utils_System::setTitle(ts('Subscribe to Mailing List - %1', array(1 => $dao->title)));
         } else {
             CRM_Core_Error::statusBounce("The specified group is not configured for this action OR The group doesn't exist.");
         }
         $this->assign('single', TRUE);
     } else {
         $this->assign('single', FALSE);
         CRM_Utils_System::setTitle(ts('Mailing List Subscription'));
     }
 }
 /**
  * This function is called prior to building and submitting the form
  */
 function preProcess()
 {
     // check contact_id
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     if (empty($this->_contactId)) {
         CRM_Core_Error::statusBounce(ts('Could not get a contact id.'), NULL, ts('Lidmaatschap Wijziging - Contact'));
         // this also redirects to the default civicrm page
     }
     // check for permissions
     $session = CRM_Core_Session::singleton();
     if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
         CRM_Core_Error::statusBounce(ts('You do not have the necessary permission to edit this contact.'), NULL, ts('Lidmaatschap Wijziging - Contact'));
         // this also redirects to the default civicrm page
     }
     // get session
     $session = CRM_Core_Session::singleton();
     // get values
     $this->_configGroup = CRM_Lidmaatschapwijziging_ConfigGroup::singleton($this->_contactId);
     $this->_values = $this->_configGroup->getContact();
     // set display name
     $this->_display_name = $this->_values['display_name'];
     // set title
     CRM_Utils_System::setTitle('LidmaatschapWijziging - Group - ' . $this->_values['display_name']);
     // set contact id
     $this->_values['contact_id'] = $this->_contactId;
 }
Пример #11
0
 /**
  * Process the form submission.
  *
  * @return void
  */
 public function postProcess()
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         $errors = CRM_Financial_BAO_FinancialType::del($this->_id);
         if (!empty($errors)) {
             CRM_Core_Error::statusBounce($errors['error_message'], CRM_Utils_System::url('civicrm/admin/financial/financialType', "reset=1&action=browse"), ts('Cannot Delete'));
         }
         CRM_Core_Session::setStatus(ts('Selected financial type has been deleted.'), ts('Record Deleted'), 'success');
     } else {
         $params = $ids = array();
         // store the submitted values in an array
         $params = $this->exportValues();
         if ($this->_action & CRM_Core_Action::UPDATE) {
             $ids['financialType'] = $this->_id;
         }
         $financialType = CRM_Financial_BAO_FinancialType::add($params, $ids);
         if ($this->_action & CRM_Core_Action::UPDATE) {
             $url = CRM_Utils_System::url('civicrm/admin/financial/financialType', 'reset=1&action=browse');
             CRM_Core_Session::setStatus(ts('The financial type "%1" has been updated.', array(1 => $financialType->name)), ts('Saved'), 'success');
         } else {
             $url = CRM_Utils_System::url('civicrm/admin/financial/financialType/accounts', 'reset=1&action=browse&aid=' . $financialType->id);
             $statusArray = array(1 => $financialType->name, 2 => $financialType->name, 3 => CRM_Utils_Array::value(0, $financialType->titles), 4 => CRM_Utils_Array::value(1, $financialType->titles), 5 => CRM_Utils_Array::value(2, $financialType->titles));
             if (empty($financialType->titles)) {
                 $text = ts('Your Financial "%1" Type has been created and assigned to an existing financial account with the same title. You should review the assigned account and determine whether additional account relationships are needed.', $statusArray);
             } else {
                 $text = ts('Your Financial "%1" Type has been created, along with a corresponding income account "%2". That income account, along with standard financial accounts "%3", "%4" and "%5" have been linked to the financial type. You may edit or replace those relationships here.', $statusArray);
             }
             CRM_Core_Session::setStatus($text, ts('Saved'), 'success', array('expires' => 0));
         }
         $session = CRM_Core_Session::singleton();
         $session->replaceUserContext($url);
     }
 }
Пример #12
0
 /**
  * run this page (figure out the action needed and perform it).
  *
  * @return void
  */
 function run()
 {
     $instanceId = CRM_Report_Utils_Report::getInstanceID();
     $action = CRM_Utils_Request::retrieve('action', 'String', $this);
     $optionVal = CRM_Report_Utils_Report::getValueFromUrl($instanceId);
     $reportUrl = CRM_Utils_System::url('civicrm/report/list', "reset=1");
     if ($action & CRM_Core_Action::DELETE) {
         if (!CRM_Core_Permission::check('administer Reports')) {
             $statusMessage = ts('Your do not have permission to Delete Report.');
             CRM_Core_Error::statusBounce($statusMessage, $reportUrl);
         }
         CRM_Report_BAO_Instance::delete($instanceId);
         CRM_Core_Session::setStatus(ts('Selected Instance has been deleted.'));
     } else {
         require_once 'CRM/Core/OptionGroup.php';
         $templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', "{$optionVal}", 'value');
         if (strstr($templateInfo['name'], '_Form')) {
             $instanceInfo = array();
             CRM_Report_BAO_Instance::retrieve(array('id' => $instanceId), $instanceInfo);
             if (!empty($instanceInfo['title'])) {
                 CRM_Utils_System::setTitle($instanceInfo['title']);
                 $this->assign('reportTitle', $instanceInfo['title']);
             } else {
                 CRM_Utils_System::setTitle($templateInfo['label']);
                 $this->assign('reportTitle', $templateInfo['label']);
             }
             $wrapper =& new CRM_Utils_Wrapper();
             return $wrapper->run($templateInfo['name'], null, null);
         }
         CRM_Core_Session::setStatus(ts('Could not find template for the instance.'));
     }
     return CRM_Utils_System::redirect($reportUrl);
 }
 /**
  * This function is called prior to building and submitting the form
  */
 function preProcess()
 {
     // check contact_id
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     if (empty($this->_contactId)) {
         CRM_Core_Error::statusBounce(ts('Could not get a contact id.'), NULL, ts('Lidmaatschap Wijziging - Contact'));
         // this also redirects to the default civicrm page
     }
     // check for permissions
     $session = CRM_Core_Session::singleton();
     if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
         CRM_Core_Error::statusBounce(ts('You do not have the necessary permission to edit this contact.'), NULL, ts('Lidmaatschap Wijziging - Contact'));
         // this also redirects to the default civicrm page
     }
     // get request
     $this->_request = CRM_Utils_Request::retrieve('request', 'String', $this, FALSE, 'choose');
     // get session
     $session = CRM_Core_Session::singleton();
     // get values
     $this->_configRelationship = CRM_Lidmaatschapwijziging_ConfigRelationship::singleton($this->_contactId);
     $this->_values = $this->_configRelationship->getContact();
     // set contact id
     $this->_values['contact_id'] = $this->_contactId;
     // set display name
     $this->_display_name = $this->_values['display_name'];
     // set request
     $this->_values['request'] = $this->_request;
     // set title
     CRM_Utils_System::setTitle('LidmaatschapWijziging - Relatie - ' . $this->_values['display_name']);
     // request
     if ('empty' == $this->_request) {
     }
     if ('choose' == $this->_request) {
         // if there is no relatiosnhips then the options are empty, we
         // show a message that there are no memebrships and a submit butten to
         // go to the relationship, first we redirect them to request empty
         $relationships = $this->_configRelationship->getRelationships();
         if (empty($relationships)) {
             // redirect user
             $url = CRM_Utils_System::url('civicrm/lidmaatschapwijziging/relationship', 'reset=1&request=empty&cid=' . $this->_contactId);
             CRM_Utils_System::redirect($url);
         }
     }
     if ('update' == $this->_request) {
         // get relationship id
         $this->_relationshipId = CRM_Utils_Request::retrieve('relationship_id', 'Positive', $this);
         $this->_values['relationship_id'] = $this->_relationshipId;
         // get relationship
         $this->_values = array_merge($this->_values, $this->_configRelationship->getRelationship($this->_relationshipId));
         if (!empty($this->_values['contact_a']['display_name'])) {
             $this->assign('sort_name_a', $this->_values['contact_a']['display_name']);
         }
         if (!empty($this->_values['contact_b']['display_name'])) {
             $this->assign('sort_name_b', $this->_values['contact_b']['display_name']);
         }
         // note
         $this->_values['note_id'] = $this->_values['notes']['id'];
         $this->_values['note'] = $this->_values['notes']['note'];
     }
 }
Пример #14
0
 /**
  * Pre processing work done here.
  *
  * gets session variables for group or field id
  *
  * @return void
  */
 public function preProcess()
 {
     // get the controller vars
     $this->_groupId = $this->get('groupId');
     $this->_fieldId = $this->get('fieldId');
     if ($this->_fieldId) {
         // field preview
         $defaults = array();
         $params = array('id' => $this->_fieldId);
         $fieldDAO = new CRM_Core_DAO_CustomField();
         CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $params, $defaults);
         if (!empty($defaults['is_view'])) {
             CRM_Core_Error::statusBounce(ts('This field is view only so it will not display on edit form.'));
         } elseif (CRM_Utils_Array::value('is_active', $defaults) == 0) {
             CRM_Core_Error::statusBounce(ts('This field is inactive so it will not display on edit form.'));
         }
         $groupTree = array();
         $groupTree[$this->_groupId]['id'] = 0;
         $groupTree[$this->_groupId]['fields'] = array();
         $groupTree[$this->_groupId]['fields'][$this->_fieldId] = $defaults;
         $this->_groupTree = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, 1, $this);
         $this->assign('preview_type', 'field');
     } else {
         $groupTree = CRM_Core_BAO_CustomGroup::getGroupDetail($this->_groupId);
         $this->_groupTree = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, TRUE, $this);
         $this->assign('preview_type', 'group');
     }
 }
Пример #15
0
 /**
  * Build all the data structures needed to build the form.
  */
 public function preProcess()
 {
     // reset action from the session
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'update');
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
     $rcid = CRM_Utils_Request::retrieve('rcid', 'Positive', $this);
     $rcid = $rcid ? "&id={$rcid}" : '';
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext(CRM_Utils_System::url('civicrm/user', "reset=1{$rcid}"));
     if ($this->_contactId) {
         $contact = new CRM_Contact_DAO_Contact();
         $contact->id = $this->_contactId;
         if (!$contact->find(TRUE)) {
             CRM_Core_Error::statusBounce(ts('contact does not exist: %1', array(1 => $this->_contactId)));
         }
         $this->_contactType = $contact->contact_type;
         // check for permissions
         if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
             CRM_Core_Error::statusBounce(ts('You do not have the necessary permission to edit this contact.'));
         }
         list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($this->_contactId);
         CRM_Utils_System::setTitle($displayName, $contactImage . ' ' . $displayName);
     } else {
         CRM_Core_Error::statusBounce(ts('Could not get a contact_id and/or contact_type'));
     }
 }
Пример #16
0
 /**
  * @param object $controller
  * @param const|int $action
  */
 public function __construct($controller, $action = CRM_Core_Action::NONE)
 {
     parent::__construct($controller, $action);
     $cart = CRM_Event_Cart_BAO_Cart::find_or_create_for_current_session();
     $cart->load_associations();
     if ($cart->is_empty()) {
         CRM_Core_Error::statusBounce(ts("You don't have any events in you cart. Please add some events."), CRM_Utils_System::url('civicrm/event'));
     }
     $pages = array();
     $is_monetary = FALSE;
     $is_conference = FALSE;
     foreach ($cart->events_in_carts as $event_in_cart) {
         if ($event_in_cart->event->is_monetary) {
             $is_monetary = TRUE;
         }
     }
     $pages["CRM_Event_Cart_Form_Checkout_ParticipantsAndPrices"] = NULL;
     foreach ($cart->events_in_carts as $event_in_cart) {
         if ($event_in_cart->is_parent_event()) {
             foreach ($event_in_cart->participants as $participant) {
                 $pages["CRM_Event_Cart_Form_Checkout_ConferenceEvents_{$event_in_cart->event_id}_{$participant->id}"] = array('className' => 'CRM_Event_Cart_Form_Checkout_ConferenceEvents', 'title' => "Select {$event_in_cart->event->title} Events For {$participant->email}");
             }
         }
     }
     $pages["CRM_Event_Cart_Form_Checkout_Payment"] = NULL;
     $pages["CRM_Event_Cart_Form_Checkout_ThankYou"] = NULL;
     $this->addSequentialPages($pages, $action);
 }
Пример #17
0
 /**
  * Function to set variables up before form is built
  *
  * @return void
  * @access public
  */
 public function preProcess()
 {
     $this->_id = $this->get('id');
     $this->_cid = $this->get('cid');
     $params = array('id' => $this->_id);
     CRM_Booking_BAO_Booking::retrieve($params, $this->_values);
     if (empty($this->_values)) {
         CRM_Core_Error::statusBounce(ts('The requested booking record does not exist (possibly the record was deleted).'));
     }
     $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->_action != CRM_Core_Action::DELETE & $this->_action != CRM_Core_Action::VIEW)) {
         $bookingPayment = civicrm_api3('BookingPayment', 'get', array('booking_id' => $this->_id));
         if ($bookingPayment['count'] > 0) {
             CRM_Core_Error::statusBounce(ts('The requested booking record has already been cancelled'));
         }
     }
     $this->_values['payment_status'] = CRM_Booking_BAO_Booking::getPaymentStatus($this->_id);
     $paymentStatus = $this->_values['payment_status'];
     $this->assign('booking', $this->_values);
     //ResoveDefault
     CRM_Booking_BAO_Booking::resolveDefaults($this->_values);
     $title = $this->_values['title'];
     CRM_Utils_System::setTitle(ts('Update Booking') . " - {$title}");
     //get contribution record
     $this->associatedContribution($this->_id);
 }
 /**
  * This function is called prior to building and submitting the form
  */
 function preProcess()
 {
     // check contact_id
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     if (empty($this->_contactId)) {
         CRM_Core_Error::statusBounce(ts('Could not get a contact id.'), NULL, ts('Lidmaatschap Wijziging - Contact'));
         // this also redirects to the default civicrm page
     }
     // check for edit permission
     if (!CRM_Core_Permission::checkActionPermission('CiviMember', 'update')) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page'));
     }
     // get request
     $this->_request = CRM_Utils_Request::retrieve('request', 'String', $this, FALSE, 'choose');
     // get session
     $session = CRM_Core_Session::singleton();
     // get values
     $this->_configMembership = CRM_Lidmaatschapwijziging_ConfigMembership::singleton($this->_contactId);
     $this->_values = $this->_configMembership->getContact();
     // set display name
     $this->_display_name = $this->_values['display_name'];
     // set contact id
     $this->_values['contact_id'] = $this->_contactId;
     // set request
     $this->_values['request'] = $this->_request;
     // set title
     CRM_Utils_System::setTitle('LidmaatschapWijziging - Lidmaatschap - ' . $this->_values['display_name']);
     // request
     if ('empty' == $this->_request) {
     }
     if ('choose' == $this->_request) {
         // if there is no memberships then the options are empty, we
         // show a message that there are no memebrships and a submit butten to
         // go to the relationship, first we redirect them to request empty
         $memberships = $this->_configMembership->getMemberships();
         if (empty($memberships)) {
             // redirect user
             $url = CRM_Utils_System::url('civicrm/lidmaatschapwijziging/membership', 'reset=1&request=empty&cid=' . $this->_contactId);
             CRM_Utils_System::redirect($url);
         }
     }
     if ('update' == $this->_request) {
         // get membership id
         $this->_membershipId = CRM_Utils_Request::retrieve('membership_id', 'Positive', $this);
         $this->_values['membership_id'] = $this->_membershipId;
         // get membership
         $membership = $this->_configMembership->getMembership($this->_membershipId);
         $this->_values = array_merge($this->_values, $membership);
         // get source, source is overritten by the contact source and not the membership source, i
         // override it here
         $this->_values['source'] = $membership['source'];
         // This is diffrent from the LidmaatschapWijzigingContact because the custom field values are already send with the membership
         // We have to set the _values of the custom field like huppeldepup and not custom_35, so we
         // loop through the custom field and change the custom_35 values to huppeldepup
         foreach ($this->_configMembership->getMembershipCustomFields() as $key => $field) {
             $this->_values[$field['name']] = $this->_values['custom_' . $field['id']];
         }
     }
 }
Пример #19
0
 /**
  * Build form.
  *
  * @param CRM_Core_Form $form
  */
 public static function buildForm(&$form)
 {
     // We should not build form elements in dashlet mode.
     if ($form->_section) {
         return;
     }
     // Check role based permission.
     $instanceID = $form->getVar('_id');
     if ($instanceID && !CRM_Report_Utils_Report::isInstanceGroupRoleAllowed($instanceID)) {
         $url = CRM_Utils_System::url('civicrm/report/list', 'reset=1');
         CRM_Core_Error::statusBounce(ts('You do not have permission to access this report.'), $url);
     }
     $attributes = CRM_Core_DAO::getAttribute('CRM_Report_DAO_ReportInstance');
     $form->add('text', 'title', ts('Report Title'), $attributes['title']);
     $form->add('text', 'description', ts('Report Description'), $attributes['description']);
     $form->add('text', 'email_subject', ts('Subject'), $attributes['email_subject']);
     $form->add('text', 'email_to', ts('To'), $attributes['email_to']);
     $form->add('text', 'email_cc', ts('CC'), $attributes['email_subject']);
     $form->add('number', 'row_count', ts('Limit Dashboard Results'), array('class' => 'four', 'min' => 1));
     $form->add('textarea', 'report_header', ts('Report Header'), $attributes['header']);
     $form->add('textarea', 'report_footer', ts('Report Footer'), $attributes['footer']);
     $form->addElement('checkbox', 'is_navigation', ts('Include Report in Navigation Menu?'), NULL, array('onclick' => "return showHideByValue('is_navigation','','navigation_menu','table-row','radio',false);"));
     $form->addElement('select', 'view_mode', ts('Configure link to...'), array('view' => ts('View Results'), 'criteria' => ts('Show Criteria')));
     $form->addElement('checkbox', 'addToDashboard', ts('Available for Dashboard?'));
     $form->add('number', 'cache_minutes', ts('Cache dashlet for'), array('class' => 'four', 'min' => 1));
     $form->addElement('checkbox', 'add_to_my_reports', ts('Add to My Reports?'), NULL);
     $form->addElement('checkbox', 'is_reserved', ts('Reserved Report?'));
     if (!CRM_Core_Permission::check('administer reserved reports')) {
         $form->freeze('is_reserved');
     }
     $config = CRM_Core_Config::singleton();
     if ($config->userFramework != 'Joomla' || $config->userFramework != 'WordPress') {
         $form->addElement('select', 'permission', ts('Permission'), array('0' => ts('Everyone (includes anonymous)')) + CRM_Core_Permission::basicPermissions());
         // prepare user_roles to save as names not as ids
         if (function_exists('user_roles')) {
             $user_roles_array = user_roles();
             foreach ($user_roles_array as $key => $value) {
                 $user_roles[$value] = $value;
             }
             $grouprole =& $form->addElement('advmultiselect', 'grouprole', ts('ACL Group/Role'), $user_roles, array('size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect'));
             $grouprole->setButtonAttributes('add', array('value' => ts('Add >>')));
             $grouprole->setButtonAttributes('remove', array('value' => ts('<< Remove')));
         }
     }
     // navigation field
     $parentMenu = CRM_Core_BAO_Navigation::getNavigationList();
     $form->add('select', 'parent_id', ts('Parent Menu'), array('' => ts('- select -')) + $parentMenu);
     // For now we only providing drilldown for one primary detail report only. In future this could be multiple reports
     foreach ($form->_drilldownReport as $reportUrl => $drillLabel) {
         $instanceList = CRM_Report_Utils_Report::getInstanceList($reportUrl);
         if (count($instanceList) > 1) {
             $form->add('select', 'drilldown_id', $drillLabel, array('' => ts('- select -')) + $instanceList);
         }
         break;
     }
     $form->addButtons(array(array('type' => 'submit', 'name' => ts('Save Report'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
     $form->addFormRule(array('CRM_Report_Form_Instance', 'formRule'), $form);
 }
Пример #20
0
 /**
  * Run this page (figure out the action needed and perform it).
  */
 public function run()
 {
     $instanceId = CRM_Report_Utils_Report::getInstanceID();
     if (!$instanceId) {
         $instanceId = CRM_Report_Utils_Report::getInstanceIDForPath();
     }
     if (is_numeric($instanceId)) {
         $instanceURL = CRM_Utils_System::url("civicrm/report/instance/{$instanceId}", 'reset=1');
         CRM_Core_Session::singleton()->replaceUserContext($instanceURL);
     }
     $action = CRM_Utils_Request::retrieve('action', 'String', $this);
     $optionVal = CRM_Report_Utils_Report::getValueFromUrl($instanceId);
     $reportUrl = CRM_Utils_System::url('civicrm/report/list', "reset=1");
     if ($action & CRM_Core_Action::DELETE) {
         if (!CRM_Core_Permission::check('administer Reports')) {
             $statusMessage = ts('You do not have permission to Delete Report.');
             CRM_Core_Error::statusBounce($statusMessage, $reportUrl);
         }
         $navId = CRM_Core_DAO::getFieldValue('CRM_Report_DAO_ReportInstance', $instanceId, 'navigation_id', 'id');
         CRM_Report_BAO_ReportInstance::del($instanceId);
         //delete navigation if exists
         if ($navId) {
             CRM_Core_BAO_Navigation::processDelete($navId);
             CRM_Core_BAO_Navigation::resetNavigation();
         }
         CRM_Core_Session::setStatus(ts('Selected report has been deleted.'), ts('Deleted'), 'success');
     } else {
         $templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', "{$optionVal}", 'value');
         if (empty($templateInfo)) {
             CRM_Core_Error::statusBounce('You have tried to access a report that does not exist.');
         }
         $extKey = strpos($templateInfo['name'], '.');
         $reportClass = NULL;
         if ($extKey !== FALSE) {
             $ext = CRM_Extension_System::singleton()->getMapper();
             $reportClass = $ext->keyToClass($templateInfo['name'], 'report');
             $templateInfo['name'] = $reportClass;
         }
         if (strstr($templateInfo['name'], '_Form') || !is_null($reportClass)) {
             $instanceInfo = array();
             CRM_Report_BAO_ReportInstance::retrieve(array('id' => $instanceId), $instanceInfo);
             if (!empty($instanceInfo['title'])) {
                 CRM_Utils_System::setTitle($instanceInfo['title']);
                 $this->assign('reportTitle', $instanceInfo['title']);
             } else {
                 CRM_Utils_System::setTitle($templateInfo['label']);
                 $this->assign('reportTitle', $templateInfo['label']);
             }
             $wrapper = new CRM_Utils_Wrapper();
             return $wrapper->run($templateInfo['name'], NULL, NULL);
         }
         CRM_Core_Session::setStatus(ts('Could not find template for the instance.'), ts('Template Not Found'), 'error');
     }
     return CRM_Utils_System::redirect($reportUrl);
 }
Пример #21
0
 /**
  * This is some kind of special-purpose router/front-controller for the various profile URLs.
  *
  * @param $args array this array contains the arguments of the url
  *
  * @return string|void
  * @static
  * @access public
  */
 function run($args = NULL)
 {
     if ($args[1] !== 'profile') {
         return;
     }
     $secondArg = CRM_Utils_Array::value(2, $args, '');
     if ($secondArg == 'map') {
         $controller = new CRM_Core_Controller_Simple('CRM_Contact_Form_Task_Map', ts('Map Contact'), NULL, FALSE, FALSE, TRUE);
         $gids = explode(',', CRM_Utils_Request::retrieve('gid', 'String', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET'));
         if (count($gids) > 1) {
             foreach ($gids as $pfId) {
                 $profileIds[] = CRM_Utils_Type::escape($pfId, 'Positive');
             }
             $controller->set('gid', $profileIds[0]);
             $profileGID = $profileIds[0];
         } else {
             $profileGID = CRM_Utils_Request::retrieve('gid', 'Integer', $controller, TRUE);
         }
         // make sure that this profile enables mapping
         // CRM-8609
         $isMap = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $profileGID, 'is_map');
         if (!$isMap) {
             CRM_Core_Error::statusBounce(ts('This profile does not have the map feature turned on.'));
         }
         $profileView = CRM_Utils_Request::retrieve('pv', 'Integer', $controller, FALSE);
         // set the userContext stack
         $session = CRM_Core_Session::singleton();
         if ($profileView) {
             $session->pushUserContext(CRM_Utils_System::url('civicrm/profile/view'));
         } else {
             $session->pushUserContext(CRM_Utils_System::url('civicrm/profile', 'force=1'));
         }
         $controller->set('profileGID', $profileGID);
         $controller->process();
         return $controller->run();
     }
     if ($secondArg == 'edit' || $secondArg == 'create') {
         if ($secondArg == 'edit') {
             $controller = new CRM_Core_Controller_Simple('CRM_Profile_Form_Edit', ts('Create Profile'), CRM_Core_Action::UPDATE, FALSE, FALSE, TRUE);
             $controller->set('edit', 1);
             $controller->process();
             return $controller->run();
         } else {
             $wrapper = new CRM_Utils_Wrapper();
             return $wrapper->run('CRM_Profile_Form_Edit', ts('Create Profile'), array('mode' => CRM_Core_Action::ADD, 'ignoreKey' => TRUE));
         }
     }
     if ($secondArg == 'view' || empty($secondArg)) {
         $page = new CRM_Profile_Page_Listings();
         return $page->run();
     }
     CRM_Utils_System::permissionDenied();
     return;
 }
Пример #22
0
 /**  
  * Function to set variables up before form is built  
  *                                                            
  * @return void  
  * @access public  
  */
 public function preProcess()
 {
     require_once 'CRM/Event/BAO/Participant.php';
     $values = $ids = array();
     $participantID = CRM_Utils_Request::retrieve('id', 'Positive', $this, true);
     $contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, true);
     $params = array('id' => $participantID);
     CRM_Event_BAO_Participant::getValues($params, $values, $ids);
     if (empty($values)) {
         require_once 'CRM/Core/Error.php';
         CRM_Core_Error::statusBounce(ts('The requested participant record does not exist (possibly the record was deleted).'));
     }
     CRM_Event_BAO_Participant::resolveDefaults($values[$participantID]);
     if (CRM_Utils_Array::value('fee_level', $values[$participantID])) {
         CRM_Event_BAO_Participant::fixEventLevel($values[$participantID]['fee_level']);
     }
     if ($values[$participantID]['is_test']) {
         $values[$participantID]['status'] .= ' (test) ';
     }
     // Get Note
     $noteValue = CRM_Core_BAO_Note::getNote($participantID, 'civicrm_participant');
     $values[$participantID]['note'] = array_values($noteValue);
     require_once 'CRM/Price/BAO/LineItem.php';
     // Get Line Items
     $lineItem = CRM_Price_BAO_LineItem::getLineItems($participantID);
     if (!CRM_Utils_System::isNull($lineItem)) {
         $values[$participantID]['lineItem'][] = $lineItem;
     }
     $values[$participantID]['totalAmount'] = $values[$participantID]['fee_amount'];
     // get the option value for custom data type
     $roleCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantRole', 'name');
     $eventNameCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventName', 'name');
     $eventTypeCustomDataTypeID = CRM_Core_OptionGroup::getValue('custom_data_type', 'ParticipantEventType', 'name');
     $roleGroupTree =& CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, null, $values[$participantID]['role_id'], $roleCustomDataTypeID);
     $eventGroupTree =& CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, null, $values[$participantID]['event_id'], $eventNameCustomDataTypeID);
     $eventTypeID = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Event", $values[$participantID]['event_id'], 'event_type_id', 'id');
     $eventTypeGroupTree =& CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID, null, $eventTypeID, $eventTypeCustomDataTypeID);
     $groupTree = CRM_Utils_Array::crmArrayMerge($roleGroupTree, $eventGroupTree);
     $groupTree = CRM_Utils_Array::crmArrayMerge($groupTree, $eventTypeGroupTree);
     $groupTree = CRM_Utils_Array::crmArrayMerge($groupTree, CRM_Core_BAO_CustomGroup::getTree('Participant', $this, $participantID));
     CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
     $this->assign($values[$participantID]);
     // add viewed participant to recent items list
     require_once 'CRM/Utils/Recent.php';
     require_once 'CRM/Contact/BAO/Contact.php';
     $url = CRM_Utils_System::url('civicrm/contact/view/participant', "action=view&reset=1&id={$values[$participantID]['id']}&cid={$values[$participantID]['contact_id']}&context=home");
     $participantRoles = CRM_Event_PseudoConstant::participantRole();
     $eventTitle = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $values[$participantID]['event_id'], 'title');
     $displayName = CRM_Contact_BAO_Contact::displayName($contactID);
     $this->assign('displayName', $displayName);
     $title = $displayName . ' (' . $participantRoles[$values[$participantID]['role_id']] . ' - ' . $eventTitle . ')';
     // add Participant to Recent Items
     CRM_Utils_Recent::add($title, $url, $values[$participantID]['id'], 'Participant', $values[$participantID]['contact_id'], null);
 }
 /**
  * This function is called prior to building and submitting the form
  */
 function preProcess()
 {
     // check contact_id
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     if (empty($this->_contactId)) {
         CRM_Core_Error::statusBounce(ts('Could not get a contact id.'), NULL, ts('Lidmaatschap Wijziging - Contact'));
         // this also redirects to the default civicrm page
     }
     // check for permissions
     $session = CRM_Core_Session::singleton();
     if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
         CRM_Core_Error::statusBounce(ts('You do not have the necessary permission to edit this contact.'), NULL, ts('Lidmaatschap Wijziging - Contact'));
         // this also redirects to the default civicrm page
     }
     // get session
     $session = CRM_Core_Session::singleton();
     // redirect user after postProcess
     //$urlParams = 'reset=1&cid=' . $this->_contactId;
     //$session->pushUserContext(CRM_Utils_System::url('civicrm/lidmaatschapwijziging/contact', $urlParams));
     // get values
     $this->_configContact = CRM_Lidmaatschapwijziging_ConfigContact::singleton($this->_contactId);
     $this->_values = $this->_configContact->getContact();
     // set display name
     $this->_display_name = $this->_values['display_name'];
     // set title
     CRM_Utils_System::setTitle('LidmaatschapWijziging - Contact - ' . $this->_values['display_name']);
     // set contact id
     $this->_values['contact_id'] = $this->_contactId;
     // change the default name like huppeldepup_35 to huppeldepup, this
     // ensures the we can use the know names for custom fields in the template like
     // huppeldepup and not the column_names like huppeldepup_35
     $values = $this->_configContact->getVnvInfoCustomValues();
     // set vnvn info id, is neede for update or insert in the postProccess
     if (isset($values['id']) and !empty($values['id'])) {
         $this->_vnvinfoId = $values['id'];
     }
     foreach ($this->_configContact->getVnvInfoCustomFields() as $key => $field) {
         $this->_values[$field['name']] = $values[$field['column_name']];
     }
     $values = $this->_configContact->getWerkgeverCustomValues();
     // set werkgever id, is neede for update or insert in the postProccess
     if (isset($values['id']) and !empty($values['id'])) {
         $this->_werkgeverId = $values['id'];
     }
     foreach ($this->_configContact->getWerkgeverCustomFields() as $key => $field) {
         $this->_values[$field['name']] = $values[$field['column_name']];
     }
     $currentEmployer = CRM_Contact_BAO_Relationship::getCurrentEmployer(array($this->_contactId));
     $defaults['current_employer_id'] = CRM_Utils_Array::value('org_id', $currentEmployer[$this->_contactId]);
     // assign values needed for the template
     $this->assign('contactId', $this->_contactId);
     $this->assign('employerDataURL', '/civicrm/ajax/rest?className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&context=contact&org=1&employee_id=' . $this->_contactId);
     $this->assign('currentEmployer', $this->_values['employer_id']);
 }
Пример #24
0
 function where($includeContactIDs = false)
 {
     $params = array();
     $low = CRM_Utils_Array::value('postal_code_low', $this->_formValues);
     $high = CRM_Utils_Array::value('postal_code_high', $this->_formValues);
     if ($low == null || $high == null) {
         CRM_Core_Error::statusBounce(ts('Please provide start and end postal codes'), CRM_Utils_System::url('civicrm/contact/search/custom', "reset=1&csid={$this->_formValues['customSearchID']}", false, null, false, true));
     }
     $where = "ROUND(address.postal_code) >= %1 AND ROUND(address.postal_code) <= %2";
     $params = array(1 => array(trim($low), 'Integer'), 2 => array(trim($high), 'Integer'));
     return $this->whereClause($where, $params);
 }
Пример #25
0
 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     $this->setPageTitle($this->_isTagSet ? ts('Tag Set') : ts('Tag'));
     if ($this->_action == CRM_Core_Action::DELETE) {
         if ($this->_id && ($tag = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $this->_id, 'name', 'parent_id'))) {
             $url = CRM_Utils_System::url('civicrm/admin/tag', "reset=1");
             CRM_Core_Error::statusBounce(ts("This tag cannot be deleted. You must delete all its child tags ('%1', etc) prior to deleting this tag.", array(1 => $tag)), $url);
         }
         if ($this->_values['is_reserved'] == 1 && !CRM_Core_Permission::check('administer reserved tags')) {
             CRM_Core_Error::statusBounce(ts("You do not have sufficient permission to delete this reserved tag."));
         }
     } else {
         $this->_isTagSet = CRM_Utils_Request::retrieve('tagset', 'Positive', $this);
         if (!$this->_isTagSet && $this->_id && CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $this->_id, 'is_tagset')) {
             $this->_isTagSet = TRUE;
         }
         $allTag = array('' => ts('- select -')) + CRM_Core_BAO_Tag::getTagsNotInTagset();
         if ($this->_id) {
             unset($allTag[$this->_id]);
         }
         if (!$this->_isTagSet) {
             $this->add('select', 'parent_id', ts('Parent Tag'), $allTag, FALSE, array('class' => 'crm-select2'));
             // Tagsets are not selectable by definition so only include the selectable field if NOT a tagset.
             $selectable = $this->add('checkbox', 'is_selectable', ts('Selectable?'));
             // Selectable should be checked by default when creating a new tag
             if ($this->_action == CRM_Core_Action::ADD) {
                 $selectable->setValue(1);
             }
         }
         $this->assign('isTagSet', $this->_isTagSet);
         $this->applyFilter('__ALL__', 'trim');
         $this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Tag', 'name'), TRUE);
         $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array('CRM_Core_DAO_Tag', $this->_id));
         $this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Tag', 'description'));
         $isReserved = $this->add('checkbox', 'is_reserved', ts('Reserved?'));
         $usedFor = $this->addSelect('used_for', array('multiple' => TRUE, 'option_url' => NULL));
         if ($this->_id && CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $this->_id, 'parent_id')) {
             $usedFor->freeze();
         }
         $adminTagset = TRUE;
         if (!CRM_Core_Permission::check('administer Tagsets')) {
             $adminTagset = FALSE;
         }
         $this->assign('adminTagset', $adminTagset);
         $adminReservedTags = TRUE;
         if (!CRM_Core_Permission::check('administer reserved tags')) {
             $isReserved->freeze();
             $adminReservedTags = FALSE;
         }
         $this->assign('adminReservedTags', $adminReservedTags);
     }
     parent::buildQuickForm();
 }
Пример #26
0
 /**
  * Set variables up before form is built.
  */
 public function preProcess()
 {
     parent::preProcess();
     $this->_paymentProcessors = $this->get('paymentProcessors');
     $this->preProcessPaymentOptions();
     if (!empty($this->_ccid)) {
         $payment = CRM_Contribute_BAO_Contribution::getPaymentInfo($this->_ccid, 'contribution');
         //bounce if the contribution is not pending.
         if (empty($payment['balance'])) {
             CRM_Core_Error::statusBounce(ts("Returning since contribution has already been handled."));
         }
         if (!empty($payment['total'])) {
             $this->_pendingAmount = $payment['total'];
             $this->assign('pendingAmount', $this->_pendingAmount);
         }
         $lineItems = CRM_Price_BAO_LineItem::getLineItemsByContributionID($this->_ccid);
         foreach (array_keys($lineItems) as $id) {
             $lineItems[$id]['id'] = $id;
         }
         $itemId = key($lineItems);
         if ($itemId && !empty($lineItems[$itemId]['price_field_id'])) {
             $this->_priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $lineItems[$itemId]['price_field_id'], 'price_set_id');
         }
         if (!empty($lineItems[$itemId]['price_field_id'])) {
             $this->_lineItem[$this->_priceSetId] = $lineItems;
         }
         $isQuickConfig = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config');
         $this->assign('lineItem', $this->_lineItem);
         $this->assign('is_quick_config', $isQuickConfig);
         $this->assign('priceSetID', $this->_priceSetId);
     }
     // Make the contributionPageID available to the template
     $this->assign('contributionPageID', $this->_id);
     $this->assign('ccid', $this->_ccid);
     $this->assign('isShare', CRM_Utils_Array::value('is_share', $this->_values));
     $this->assign('isConfirmEnabled', CRM_Utils_Array::value('is_confirm_enabled', $this->_values));
     $this->assign('reset', CRM_Utils_Request::retrieve('reset', 'Boolean', CRM_Core_DAO::$_nullObject));
     $this->assign('mainDisplay', CRM_Utils_Request::retrieve('_qf_Main_display', 'Boolean', CRM_Core_DAO::$_nullObject));
     if (!empty($this->_pcpInfo['id']) && !empty($this->_pcpInfo['intro_text'])) {
         $this->assign('intro_text', $this->_pcpInfo['intro_text']);
     } elseif (!empty($this->_values['intro_text'])) {
         $this->assign('intro_text', $this->_values['intro_text']);
     }
     $qParams = "reset=1&amp;id={$this->_id}";
     if ($pcpId = CRM_Utils_Array::value('pcp_id', $this->_pcpInfo)) {
         $qParams .= "&amp;pcpId={$pcpId}";
     }
     $this->assign('qParams', $qParams);
     if (!empty($this->_values['footer_text'])) {
         $this->assign('footer_text', $this->_values['footer_text']);
     }
 }
Пример #27
0
 /**
  * run this page (figure out the action needed and perform it).
  *
  * @return void
  */
 function run()
 {
     $instanceId = CRM_Report_Utils_Report::getInstanceID();
     if (!$instanceId) {
         $instanceId = CRM_Report_Utils_Report::getInstanceIDForPath();
     }
     $action = CRM_Utils_Request::retrieve('action', 'String', $this);
     $optionVal = CRM_Report_Utils_Report::getValueFromUrl($instanceId);
     $reportUrl = CRM_Utils_System::url('civicrm/report/list', "reset=1");
     if ($action & CRM_Core_Action::DELETE) {
         if (!CRM_Core_Permission::check('administer Reports')) {
             $statusMessage = ts('Your do not have permission to Delete Report.');
             CRM_Core_Error::statusBounce($statusMessage, $reportUrl);
         }
         $navId = CRM_Core_DAO::getFieldValue('CRM_Report_DAO_Instance', $instanceId, 'navigation_id', 'id');
         CRM_Report_BAO_Instance::delete($instanceId);
         //delete navigation if exists
         if ($navId) {
             require_once 'CRM/Core/BAO/Navigation.php';
             CRM_Core_BAO_Navigation::processDelete($navId);
             CRM_Core_BAO_Navigation::resetNavigation();
         }
         CRM_Core_Session::setStatus(ts('Selected Instance has been deleted.'));
     } else {
         require_once 'CRM/Core/OptionGroup.php';
         $templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', "{$optionVal}", 'value');
         $extKey = strpos($templateInfo['name'], '.');
         $reportClass = null;
         if ($extKey !== FALSE) {
             require_once 'CRM/Core/Extensions.php';
             $ext = new CRM_Core_Extensions();
             $reportClass = $ext->keyToClass($templateInfo['name'], 'report');
             $templateInfo['name'] = $reportClass;
         }
         if (strstr($templateInfo['name'], '_Form') || !is_null($reportClass)) {
             $instanceInfo = array();
             CRM_Report_BAO_Instance::retrieve(array('id' => $instanceId), $instanceInfo);
             if (!empty($instanceInfo['title'])) {
                 CRM_Utils_System::setTitle($instanceInfo['title']);
                 $this->assign('reportTitle', $instanceInfo['title']);
             } else {
                 CRM_Utils_System::setTitle($templateInfo['label']);
                 $this->assign('reportTitle', $templateInfo['label']);
             }
             $wrapper = new CRM_Utils_Wrapper();
             return $wrapper->run($templateInfo['name'], null, null);
         }
         CRM_Core_Session::setStatus(ts('Could not find template for the instance.'));
     }
     return CRM_Utils_System::redirect($reportUrl);
 }
Пример #28
0
 function preProcess()
 {
     $this->_entityTable = $this->get('entityTable');
     $this->_entityId = $this->get('entityId');
     $this->_id = $this->get('id');
     $this->_parentId = CRM_Utils_Array::value('parentId', $_GET, 0);
     if ($this->_parentId) {
         $this->assign('parentId', $this->_parentId);
     }
     if ($this->_id && CRM_Core_BAO_Note::getNotePrivacyHidden($this->_id)) {
         CRM_Core_Error::statusBounce(ts('You do not have access to this note.'));
     }
     $this->setPageTitle($this->_parentId ? ts('Comment') : ts('Note'));
 }
Пример #29
0
 /**
  * Set up variables to build the form.
  *
  * @return void
  * @acess protected
  */
 public function preProcess()
 {
     // TODO: quit if user can't access any registration groups (remove from nav menu?)
     // CRM_Core_Error::statusBounce(ts("You do not have sufficient permission to change settings for this reserved group."));
     $this->_id = $this->get('id');
     if ($this->_id) {
         $breadCrumb = array(array('title' => ts('Manage Teams'), 'url' => CRM_Utils_System::url('civicrm/tournament/team', 'reset=1')));
         CRM_Utils_System::appendBreadCrumb($breadCrumb);
         $this->_groupValues = array();
         $params = array('id' => $this->_id);
         $this->_group = CRM_Contact_BAO_Group::retrieve($params, $this->_groupValues);
         $this->_title = $this->_groupValues['title'];
     }
     $this->assign('action', $this->_action);
     $this->assign('showBlockJS', TRUE);
     if ($this->_action == CRM_Core_Action::DELETE) {
         if (isset($this->_id)) {
             $this->assign('title', $this->_title);
             $this->assign('count', CRM_Contact_BAO_Group::memberCount($this->_id));
             CRM_Utils_System::setTitle(ts('Confirm Group Delete'));
         }
         if ($this->_groupValues['is_reserved'] == 1 && !CRM_Core_Permission::check('administer reserved groups')) {
             CRM_Core_Error::statusBounce(ts("You do not have sufficient permission to delete this reserved group."));
         }
     } else {
         if ($this->_groupValues['is_reserved'] == 1 && !CRM_Core_Permission::check('administer reserved groups')) {
             CRM_Core_Error::statusBounce(ts("You do not have sufficient permission to change settings for this reserved group."));
         }
         if (isset($this->_id)) {
             $groupValues = array('id' => $this->_id, 'title' => $this->_title, 'saved_search_id' => isset($this->_groupValues['saved_search_id']) ? $this->_groupValues['saved_search_id'] : '');
             if (isset($this->_groupValues['saved_search_id'])) {
                 $groupValues['mapping_id'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_groupValues['saved_search_id'], 'mapping_id');
                 $groupValues['search_custom_id'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_groupValues['saved_search_id'], 'search_custom_id');
             }
             if (!empty($this->_groupValues['created_id'])) {
                 $groupValues['created_by'] = CRM_Core_DAO::getFieldValue("CRM_Contact_DAO_Contact", $this->_groupValues['created_id'], 'sort_name', 'id');
             }
             if (!empty($this->_groupValues['modified_id'])) {
                 $groupValues['modified_by'] = CRM_Core_DAO::getFieldValue("CRM_Contact_DAO_Contact", $this->_groupValues['modified_id'], 'sort_name', 'id');
             }
             $this->assign_by_ref('group', $groupValues);
             CRM_Utils_System::setTitle(ts('Team Settings: %1', array(1 => $this->_title)));
         }
         $session = CRM_Core_Session::singleton();
         $session->pushUserContext(CRM_Utils_System::url('civicrm/tournament/team', 'reset=1'));
     }
     //build custom data
     CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, 1, 'Group', $this->_id);
 }
Пример #30
0
 public function preProcess()
 {
     if (!CRM_Core_Permission::check('administer payment processors')) {
         CRM_Core_Error::statusBounce('The \'administer payment processors\' permission is required to add or edit a payment processor.');
     }
     parent::preProcess();
     CRM_Utils_System::setTitle(ts('Settings - Payment Processor'));
     // get the payment processor meta information
     if ($this->_id) {
         $this->_ppType = CRM_Utils_Request::retrieve('pp', 'String', $this, FALSE, NULL);
         if (!$this->_ppType) {
             $this->_ppType = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_PaymentProcessor', $this->_id, 'payment_processor_type_id');
         }
         $this->set('pp', $this->_ppType);
     } else {
         $this->_ppType = CRM_Utils_Request::retrieve('pp', 'String', $this, TRUE, NULL);
     }
     $this->assign('ppType', $this->_ppType);
     $ppTypeName = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_PaymentProcessorType', $this->_ppType, 'name');
     $this->assign('ppTypeName', $ppTypeName);
     $this->_ppDAO = new CRM_Financial_DAO_PaymentProcessorType();
     $this->_ppDAO->id = $this->_ppType;
     if (!$this->_ppDAO->find(TRUE)) {
         CRM_Core_Error::fatal(ts('Could not find payment processor meta information'));
     }
     if ($this->_id) {
         $refreshURL = CRM_Utils_System::url('civicrm/admin/paymentProcessor', "reset=1&action=update&id={$this->_id}", FALSE, NULL, FALSE);
     } else {
         $refreshURL = CRM_Utils_System::url('civicrm/admin/paymentProcessor', "reset=1&action=add", FALSE, NULL, FALSE);
     }
     //CRM-4129
     $destination = CRM_Utils_Request::retrieve('civicrmDestination', 'String', $this);
     if ($destination) {
         $destination = urlencode($destination);
         $refreshURL .= "&civicrmDestination={$destination}";
     }
     $this->assign('refreshURL', $refreshURL);
     $this->assign('is_recur', $this->_ppDAO->is_recur);
     $this->_fields = array(array('name' => 'user_name', 'label' => $this->_ppDAO->user_name_label), array('name' => 'password', 'label' => $this->_ppDAO->password_label), array('name' => 'signature', 'label' => $this->_ppDAO->signature_label), array('name' => 'subject', 'label' => $this->_ppDAO->subject_label), array('name' => 'url_site', 'label' => ts('Site URL'), 'rule' => 'url', 'msg' => ts('Enter a valid URL')));
     if ($this->_ppDAO->is_recur) {
         $this->_fields[] = array('name' => 'url_recur', 'label' => ts('Recurring Payments URL'), 'rule' => 'url', 'msg' => ts('Enter a valid URL'));
     }
     if (!empty($this->_ppDAO->url_button_default)) {
         $this->_fields[] = array('name' => 'url_button', 'label' => ts('Button URL'), 'rule' => 'url', 'msg' => ts('Enter a valid URL'));
     }
     if (!empty($this->_ppDAO->url_api_default)) {
         $this->_fields[] = array('name' => 'url_api', 'label' => ts('API URL'), 'rule' => 'url', 'msg' => ts('Enter a valid URL'));
     }
 }