static function getCaseActivity() { $caseID = CRM_Utils_Type::escape($_GET['caseID'], 'Integer'); $contactID = CRM_Utils_Type::escape($_GET['cid'], 'Integer'); $userID = CRM_Utils_Type::escape($_GET['userID'], 'Integer'); $context = CRM_Utils_Type::escape(CRM_Utils_Array::value('context', $_GET), 'String'); $sortMapper = array(0 => 'display_date', 1 => 'ca.subject', 2 => 'ca.activity_type_id', 3 => 'acc.sort_name', 4 => 'cc.sort_name', 5 => 'ca.status_id'); $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer'); $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0; $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25; $sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : null; $sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc'; $params = $_POST; if ($sort && $sortOrder) { $params['sortname'] = $sort; $params['sortorder'] = $sortOrder; } $params['page'] = $offset / $rowCount + 1; $params['rp'] = $rowCount; // get the activities related to given case require_once "CRM/Case/BAO/Case.php"; $activities = CRM_Case_BAO_Case::getCaseActivity($caseID, $params, $contactID, $context, $userID); require_once "CRM/Utils/JSON.php"; $iFilteredTotal = $iTotal = $params['total']; $selectorElements = array('display_date', 'subject', 'type', 'with_contacts', 'reporter', 'status', 'links', 'class'); echo CRM_Utils_JSON::encodeDataTableSelector($activities, $sEcho, $iTotal, $iFilteredTotal, $selectorElements); CRM_Utils_System::civiExit(); }
/** * Function to retrieve contact mailings */ public static function getContactMailings() { $contactID = CRM_Utils_Type::escape($_GET['contact_id'], 'Integer'); $sortMapper = array(0 => 'subject', 1 => 'creator_name', 2 => '', 3 => 'start_date', 4 => '', 5 => 'links'); $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer'); $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0; $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25; $sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : NULL; $sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc'; $params = $_POST; if ($sort && $sortOrder) { $params['sortBy'] = $sort . ' ' . $sortOrder; } $params['page'] = $offset / $rowCount + 1; $params['rp'] = $rowCount; $params['contact_id'] = $contactID; $params['context'] = $context; // get the contact mailings $mailings = CRM_Mailing_BAO_Mailing::getContactMailingSelector($params); $iFilteredTotal = $iTotal = $params['total']; $selectorElements = array('subject', 'mailing_creator', 'recipients', 'start_date', 'openstats', 'links'); header('Content-Type: application/json'); echo CRM_Utils_JSON::encodeDataTableSelector($mailings, $sEcho, $iTotal, $iFilteredTotal, $selectorElements); CRM_Utils_System::civiExit(); }
/** * Function to setDefaults according to membership type */ function getMemberTypeDefaults($config) { if (!$_POST['mtype']) { $details['name'] = ''; $details['auto_renew'] = ''; $details['total_amount'] = ''; echo json_encode($details); CRM_Utils_System::civiExit(); } $memType = CRM_Utils_Type::escape($_POST['mtype'], 'Integer'); $query = "SELECT name, minimum_fee AS total_amount, financial_type_id, auto_renew\nFROM civicrm_membership_type\nWHERE id = %1"; $dao = CRM_Core_DAO::executeQuery($query, array(1 => array($memType, 'Positive'))); $properties = array('financial_type_id', 'total_amount', 'name', 'auto_renew'); while ($dao->fetch()) { foreach ($properties as $property) { $details[$property] = $dao->{$property}; } } $details['total_amount_numeric'] = $details['total_amount']; // fix the display of the monetary value, CRM-4038 $details['total_amount'] = CRM_Utils_Money::format($details['total_amount'], NULL, '%a'); $options = array(ts('No auto-renew option'), ts('Give option, but not required'), ts('Auto-renew required ')); $details['auto_renew'] = CRM_Utils_Array::value('auto_renew', $options[$details]); echo json_encode($details); CRM_Utils_System::civiExit(); }
/** * Build the form object. */ public function buildQuickForm() { parent::buildQuickForm(); if ($this->_action & CRM_Core_Action::DELETE) { return; } CRM_Utils_System::setTitle(ts('Dropdown Options')); $this->applyFilter('__ALL__', 'trim'); $this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionGroup', 'name'), TRUE); $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array('CRM_Core_DAO_OptionGroup', $this->_id)); $this->add('text', 'title', ts('Group Title'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionGroup', 'title')); $this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionGroup', 'description')); $this->addSelect('data_type', array('options' => CRM_Utils_Type::dataTypes()), TRUE); $element = $this->add('checkbox', 'is_active', ts('Enabled?')); if ($this->_action & CRM_Core_Action::UPDATE) { if (in_array($this->_values['name'], array('encounter_medium', 'case_type', 'case_status'))) { static $caseCount = NULL; if (!isset($caseCount)) { $caseCount = CRM_Case_BAO_Case::caseCount(NULL, FALSE); } if ($caseCount > 0) { $element->freeze(); } } if (!empty($this->_values['is_reserved'])) { $this->freeze(array('name', 'is_active')); } } $this->assign('id', $this->_id); }
/** * Retrieve records. */ public static function getBatchList() { $sortMapper = array(0 => 'batch.title', 1 => 'batch.type_id', 2 => '', 3 => 'batch.total', 4 => 'batch.status_id', 5 => ''); $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer'); $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0; $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25; $sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : NULL; $sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc'; $context = isset($_REQUEST['context']) ? CRM_Utils_Type::escape($_REQUEST['context'], 'String') : NULL; $params = $_REQUEST; if ($sort && $sortOrder) { $params['sortBy'] = $sort . ' ' . $sortOrder; } $params['page'] = $offset / $rowCount + 1; $params['rp'] = $rowCount; if ($context != 'financialBatch') { // data entry status batches $params['status_id'] = CRM_Core_OptionGroup::getValue('batch_status', 'Data Entry', 'name'); } $params['context'] = $context; // get batch list $batches = CRM_Batch_BAO_Batch::getBatchListSelector($params); $iFilteredTotal = $iTotal = $params['total']; if ($context == 'financialBatch') { $selectorElements = array('check', 'batch_name', 'payment_instrument', 'item_count', 'total', 'status', 'created_by', 'links'); } else { $selectorElements = array('batch_name', 'type', 'item_count', 'total', 'status', 'created_by', 'links'); } CRM_Utils_System::setHttpHeader('Content-Type', 'application/json'); echo CRM_Utils_JSON::encodeDataTableSelector($batches, $sEcho, $iTotal, $iFilteredTotal, $selectorElements); CRM_Utils_System::civiExit(); }
/** * Function for building Pledge Name combo box */ function pledgeName(&$config) { $getRecords = FALSE; if (isset($_GET['name']) && $_GET['name']) { $name = CRM_Utils_Type::escape($_GET['name'], 'String'); $name = str_replace('*', '%', $name); $whereClause = "p.creator_pledge_desc LIKE '%{$name}%' "; $getRecords = TRUE; } if (isset($_GET['id']) && is_numeric($_GET['id'])) { $pledgeId = CRM_Utils_Type::escape($_GET['id'], 'Integer'); $whereClause = "p.id = {$pledgeId} "; $getRecords = TRUE; } if ($getRecords) { $query = "\nSELECT p.creator_pledge_desc, p.id\nFROM civicrm_pb_pledge p\nWHERE {$whereClause}\n"; $dao = CRM_Core_DAO::executeQuery($query); $elements = array(); while ($dao->fetch()) { $elements[] = array('name' => $dao->creator_pledge_desc, 'value' => $dao->id); } } if (empty($elements)) { $name = $_GET['name']; if (!$name && isset($_GET['id'])) { $name = $_GET['id']; } $elements[] = array('name' => trim($name, '*'), 'value' => trim($name, '*')); } echo CRM_Utils_JSON::encode($elements, 'value'); CRM_Utils_System::civiExit(); }
/** * @return array */ public function checkOptionGroupValues() { $messages = array(); $problemValues = array(); $optionGroups = civicrm_api3('OptionGroup', 'get', array('sequential' => 1, 'data_type' => array('IS NOT NULL' => 1), 'options' => array('limit' => 0))); if ($optionGroups['count'] > 0) { foreach ($optionGroups['values'] as $optionGroup) { $values = CRM_Core_BAO_OptionValue::getOptionValuesArray($optionGroup['id']); if (count($values) > 0) { foreach ($values as $value) { $validate = CRM_Utils_Type::validate($value['value'], $optionGroup['data_type'], FALSE); if (!$validate) { $problemValues[] = array('group_name' => $optionGroup['title'], 'value_name' => $value['label']); } } } } } if (!empty($problemValues)) { $strings = ''; foreach ($problemValues as $problemValue) { $strings .= ts('<tr><td> "%1" </td><td> "%2" </td></tr>', array(1 => $problemValue['group_name'], 2 => $problemValue['value_name'])); } $messages[] = new CRM_Utils_Check_Message(__FUNCTION__, ts('The Following Option Values contain value fields that do not match the Data Type of the Option Group</p> <p><table><tbody><th>Option Group</th><th>Option Value</th></tbody><tbody>') . $strings . ts('</tbody></table></p>'), ts('Option Values with problematic Values'), \Psr\Log\LogLevel::NOTICE, 'fa-server'); } return $messages; }
/** * FIXME: we should make this method like getLocBlock() OR use the same method and * remove this one. * * Function to obtain the location of given contact-id. * This method is used by on-behalf-of form to dynamically generate poulate the * location field values for selected permissioned contact. */ function getPermissionedLocation() { $cid = CRM_Utils_Type::escape($_GET['cid'], 'Integer'); require_once 'CRM/Core/BAO/Location.php'; $entityBlock = array('contact_id' => $cid); $location =& CRM_Core_BAO_Location::getValues($entityBlock); $config =& CRM_Core_Config::singleton(); $addressSequence = array_flip($config->addressSequence()); $elements = array("phone_1_phone" => $location['phone'][1]['phone'], "email_1_email" => $location['email'][1]['email']); if (array_key_exists('street_address', $addressSequence)) { $elements["address_1_street_address"] = $location['address'][1]['street_address']; } if (array_key_exists('supplemental_address_1', $addressSequence)) { $elements['address_1_supplemental_address_1'] = $location['address'][1]['supplemental_address_1']; } if (array_key_exists('supplemental_address_2', $addressSequence)) { $elements['address_1_supplemental_address_2'] = $location['address'][1]['supplemental_address_2']; } if (array_key_exists('city', $addressSequence)) { $elements['address_1_city'] = $location['address'][1]['city']; } if (array_key_exists('postal_code', $addressSequence)) { $elements['address_1_postal_code'] = $location['address'][1]['postal_code']; $elements['address_1_postal_code_suffix'] = $location['address'][1]['postal_code_suffix']; } if (array_key_exists('country', $addressSequence)) { $elements['address_1_country_id'] = $location['address'][1]['country_id']; } if (array_key_exists('state_province', $addressSequence)) { $elements['address_1_state_province_id'] = $location['address'][1]['state_province_id']; } echo json_encode($elements); exit; }
/** * Function to set variables up before form is built * * @return void * @access public */ public function preProcess() { $this->_aid = CRM_Utils_Request::retrieve('aid', 'Positive', $this); $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); if (!$this->_id && $this->_action & CRM_Core_Action::UPDATE) { $this->_id = CRM_Utils_Type::escape($this->_id, 'Positive'); } $url = CRM_Utils_System::url('civicrm/admin/financial/financialType/accounts', "reset=1&action=browse&aid={$this->_aid}"); $this->_BAOName = 'CRM_Financial_BAO_FinancialTypeAccount'; if ($this->_aid && $this->_action & CRM_Core_Action::ADD) { $this->_title = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $this->_aid, 'name'); CRM_Utils_System::setTitle($this->_title . ' - ' . ts('Financial Accounts')); $session = CRM_Core_Session::singleton(); $session->pushUserContext($url); } // CRM-12492 if (!($this->_action & CRM_Core_Action::ADD)) { $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' ")); $accountRelationship = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_EntityFinancialAccount', $this->_id, 'account_relationship'); if ($accountRelationship == $relationTypeId) { $this->_isARFlag = TRUE; if ($this->_action & CRM_Core_Action::DELETE) { CRM_Core_Session::setStatus(ts("Selected financial type account with 'Accounts Receivable Account is' account relationship cannot be deleted."), '', 'error'); CRM_Utils_System::redirect($url); } } } if ($this->_id) { $financialAccount = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_EntityFinancialAccount', $this->_id, 'financial_account_id'); $fieldTitle = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialAccount', $financialAccount, 'name'); CRM_Utils_System::setTitle($fieldTitle . ' - ' . ts('Financial Type Accounts')); } $breadCrumb = array(array('title' => ts('Financial Type Accounts'), 'url' => $url)); CRM_Utils_System::appendBreadCrumb($breadCrumb); }
/** * Build all the data structures needed to build the form. */ public function preProcess() { $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); // this mean it's a batch action if (!$this->_id) { if (!empty($_GET['batch_id'])) { // validate batch ids $batchIds = explode(',', $_GET['batch_id']); foreach ($batchIds as $batchId) { CRM_Utils_Type::validate($batchId, 'Positive'); } $this->_batchIds = $_GET['batch_id']; $this->set('batchIds', $this->_batchIds); } else { $this->_batchIds = $this->get('batchIds'); } if (!empty($_GET['export_format']) && in_array($_GET['export_format'], array('IIF', 'CSV'))) { $this->_exportFormat = $_GET['export_format']; } } else { $this->_batchIds = $this->_id; } $allBatchStatus = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id'); $this->_exportStatusId = CRM_Utils_Array::key('Exported', $allBatchStatus); // check if batch status is valid, do not allow exported batches to export again $batchStatus = CRM_Batch_BAO_Batch::getBatchStatuses($this->_batchIds); foreach ($batchStatus as $batchStatusId) { if ($batchStatusId == $this->_exportStatusId) { CRM_Core_Error::fatal(ts('You cannot exported the batches which were exported earlier.')); } } $session = CRM_Core_Session::singleton(); $session->replaceUserContext(CRM_Utils_System::url('civicrm/financial/financialbatches', "reset=1&batchStatus={$this->_exportStatusId}")); }
/** * Function for Case Subject combo box */ function caseSubject(&$config) { require_once 'CRM/Utils/Type.php'; $whereclause = $caseIdClause = null; if (isset($_GET['name'])) { $name = CRM_Utils_Type::escape($_GET['name'], 'String'); $name = str_replace('*', '%', $name); $whereclause = "civicrm_case.subject LIKE '%{$name}'"; } if (isset($_GET['id'])) { $caseId = CRM_Utils_Type::escape($_GET['id'], 'Integer'); $caseIdClause = " AND civicrm_case.id = {$caseId}"; } $elements = array(); if ($name || $caseIdClause) { if (is_numeric($_GET['c'])) { $contactID = CRM_Utils_Type::escape($_GET['c'], 'Integer'); if ($contactID) { $clause = "civicrm_case_contact.contact_id = {$contactID}"; $whereclause = $whereclause ? $whereclause . " AND " . $clause : $clause; } } $query = "\nSELECT distinct(civicrm_case.subject) as subject, civicrm_case.id as id\nFROM civicrm_case\nLEFT JOIN civicrm_case_contact ON civicrm_case_contact.case_id = civicrm_case.id\nWHERE {$whereclause} {$caseIdClause}\nORDER BY subject"; $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { $elements[] = array('name' => $dao->subject, 'id' => $dao->id); } } if (empty($elements)) { $name = str_replace('%', '', $name); $elements[] = array('name' => $name, 'id' => $name); } require_once "CRM/Utils/JSON.php"; echo CRM_Utils_JSON::encode($elements); }
public static function updateMode() { $finalResult = array(); if (CRM_Utils_Array::value('mode', $_REQUEST) && CRM_Utils_Array::value('entityId', $_REQUEST) && CRM_Utils_Array::value('entityTable', $_REQUEST)) { $mode = CRM_Utils_Type::escape($_REQUEST['mode'], 'Integer'); $entityId = CRM_Utils_Type::escape($_REQUEST['entityId'], 'Integer'); $entityTable = CRM_Utils_Type::escape($_REQUEST['entityTable'], 'String'); if (!empty($_REQUEST['linkedEntityTable'])) { $result = CRM_Core_BAO_RecurringEntity::updateModeLinkedEntity($entityId, $_REQUEST['linkedEntityTable'], $entityTable); } $dao = new CRM_Core_DAO_RecurringEntity(); if (!empty($result)) { $dao->entity_id = $result['entityId']; $dao->entity_table = $result['entityTable']; } else { $dao->entity_id = $entityId; $dao->entity_table = $entityTable; } if ($dao->find(TRUE)) { $dao->mode = $mode; $dao->save(); $finalResult['status'] = 'Done'; } else { $finalResult['status'] = 'Error'; } } CRM_Utils_JSON::output($finalResult); }
static function getTypedValue($name, $type) { $value = CRM_Utils_Array::value($name, $_GET); if ($value === null) { return null; } return CRM_Utils_Type::escape($value, CRM_Utils_Type::typeToString($type), false); }
/** * @param string $name * @param $type * * @return mixed|null */ public static function getTypedValue($name, $type) { $value = CRM_Utils_Array::value($name, $_GET); if ($value === NULL) { return NULL; } return CRM_Utils_Type::escape($value, CRM_Utils_Type::typeToString($type), FALSE); }
/** * @param string $name of variable to return * @param string $type data type * - String * - Integer * @param string $location - deprecated * @param boolean $abort abort if empty * @return Ambigous <mixed, NULL, value, unknown, array, number> */ function retrieve($name, $type, $abort = TRUE) { $value = CRM_Utils_Type::validate(CRM_Utils_Array::value($name, $this->_inputParameters), $type, FALSE); if ($abort && $value === NULL) { throw new CRM_Core_Exception("Could not find an entry for {$name}"); } return $value; }
/** * Function to setDefaults according to Pledge Id * for batch entry pledges */ public function getPledgeDefaults() { $details = array(); if (!empty($_POST['pid'])) { $pledgeID = CRM_Utils_Type::escape($_POST['pid'], 'Integer'); $details = CRM_Pledge_BAO_PledgePayment::getOldestPledgePayment($pledgeID); } CRM_Utils_JSON::output($details); }
/** * Extrac the extension and suite from the request path * * @return array */ function getRequestExtAndSuite() { $config = CRM_Core_Config::singleton(); $arg = explode('/', $_GET[$config->userFrameworkURLVar]); if ($arg[1] == 'dev' && CRM_Utils_Array::value(2, $arg) == 'qunit' && isset($arg[3]) && isset($arg[4])) { return array(trim(CRM_Utils_Type::escape($arg[3], 'String'), '/'), trim(CRM_Utils_Type::escape($arg[4], 'String'), '/')); } else { return array(NULL, NULL); } }
/** * Function to setDefaults according to Pledge Id * for batch entry pledges */ public function getPledgeDefaults() { $details = array(); if (!empty($_POST['pid'])) { $pledgeID = CRM_Utils_Type::escape($_POST['pid'], 'Integer'); $details = CRM_Pledge_BAO_PledgePayment::getOldestPledgePayment($pledgeID); } echo json_encode($details); CRM_Utils_System::civiExit(); }
/** * @param string $name * @param $type * @param bool $abort * * @return mixed */ public function retrieve($name, $type, $abort = TRUE) { static $store = NULL; $value = CRM_Utils_Type::validate(CRM_Utils_Array::value($name, $this->_inputParameters), $type, FALSE); if ($abort && $value === NULL) { CRM_Core_Error::debug_log_message("Could not find an entry for {$name}"); echo "Failure: Missing Parameter<p>" . CRM_Utils_Type::escape($name, 'String'); exit; } return $value; }
/** * 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; }
/** * @param $mailingID * @param null $offset * @param null $limit * * @return Object */ static function mailingQuery($mailingID, $offset = NULL, $limit = NULL) { $limitString = NULL; if ($limit && $offset !== NULL) { $offset = CRM_Utils_Type::escape($offset, 'Int'); $limit = CRM_Utils_Type::escape($limit, 'Int'); $limitString = "LIMIT {$offset}, {$limit}"; } $sql = "\nSELECT contact_id, email_id, phone_id\nFROM civicrm_mailing_recipients\nWHERE mailing_id = %1\n {$limitString}\n"; $params = array(1 => array($mailingID, 'Integer')); return CRM_Core_DAO::executeQuery($sql, $params); }
/** * Function to fetch the template text/html messages */ function template() { $templateId = CRM_Utils_Type::escape($_POST['tid'], 'Integer'); $messageTemplate = new CRM_Core_DAO_MessageTemplates(); $messageTemplate->id = $templateId; $messageTemplate->selectAdd(); $messageTemplate->selectAdd('msg_text, msg_html, msg_subject, pdf_format_id'); $messageTemplate->find(TRUE); $messages = array('subject' => $messageTemplate->msg_subject, 'msg_text' => $messageTemplate->msg_text, 'msg_html' => $messageTemplate->msg_html, 'pdf_format_id' => $messageTemplate->pdf_format_id); echo json_encode($messages); CRM_Utils_System::civiExit(); }
/** * Function to setDefaults according to membership type */ function getMemberTypeDefaults($config) { require_once 'CRM/Utils/Type.php'; $memType = CRM_Utils_Type::escape($_POST['mtype'], 'Integer'); $contributionType = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $memType, 'contribution_type_id'); $totalAmount = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $memType, 'minimum_fee'); // fix the display of the monetary value, CRM-4038 require_once 'CRM/Utils/Money.php'; $totalAmount = CRM_Utils_Money::format($totalAmount, null, '%a'); $details = array('contribution_type_id' => $contributionType, 'total_amount' => $totalAmount); echo json_encode($details); CRM_Utils_System::civiExit(); }
/** * Function to fetch the template text/html messages */ function template() { require_once 'CRM/Utils/Type.php'; $templateId = CRM_Utils_Type::escape($_POST['tid'], 'Integer'); require_once "CRM/Core/DAO/MessageTemplates.php"; $messageTemplate = new CRM_Core_DAO_MessageTemplates(); $messageTemplate->id = $templateId; $messageTemplate->selectAdd(); $messageTemplate->selectAdd('msg_text, msg_html, msg_subject'); $messageTemplate->find(true); $messages = array('subject' => $messageTemplate->msg_subject, 'msg_text' => $messageTemplate->msg_text, 'msg_html' => $messageTemplate->msg_html); echo json_encode($messages); CRM_Utils_System::civiExit(); }
/** * Function for building EventFee combo box */ function eventFee() { $name = trim(CRM_Utils_Type::escape($_GET['s'], 'String')); if (!$name) { $name = '%'; } $whereClause = "cv.label LIKE '{$name}%' "; $query = "SELECT DISTINCT (\ncv.label\n), cv.id\nFROM civicrm_price_field_value cv\nLEFT JOIN civicrm_price_field cf ON cv.price_field_id = cf.id\nLEFT JOIN civicrm_price_set_entity ce ON ce.price_set_id = cf.price_set_id\nWHERE ce.entity_table = 'civicrm_event' AND {$whereClause} \nGROUP BY cv.label"; $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { echo $elements = "{$dao->label}|{$dao->id}\n"; } CRM_Utils_System::civiExit(); }
/** * Get list of groups. * * @return array */ public static function getGroupList() { $params = $_REQUEST; if (isset($params['parent_id'])) { // requesting child groups for a given parent $params['page'] = 1; $params['rp'] = 0; $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); CRM_Utils_JSON::output($groups); } else { $sortMapper = array(0 => 'groups.title', 1 => 'count', 2 => 'createdBy.sort_name', 3 => '', 4 => 'groups.group_type', 5 => 'groups.visibility'); $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer'); $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0; $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25; $sort = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : NULL; $sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc'; if ($sort && $sortOrder) { $params['sortBy'] = $sort . ' ' . $sortOrder; } $params['page'] = $offset / $rowCount + 1; $params['rp'] = $rowCount; // get group list $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); // if no groups found with parent-child hierarchy and logged in user say can view child groups only (an ACL case), // go ahead with flat hierarchy, CRM-12225 if (empty($groups)) { $groupsAccessible = CRM_Core_PseudoConstant::group(); $parentsOnly = CRM_Utils_Array::value('parentsOnly', $params); if (!empty($groupsAccessible) && $parentsOnly) { // recompute group list with flat hierarchy $params['parentsOnly'] = 0; $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); } } $iFilteredTotal = $iTotal = $params['total']; $selectorElements = array('group_name', 'count', 'created_by', 'group_description', 'group_type', 'visibility', 'org_info', 'links', 'class'); if (empty($params['showOrgInfo'])) { unset($selectorElements[6]); } //add setting so this can be tested by unit test //@todo - ideally the portion of this that retrieves the groups should be extracted into a function separate // from the one which deals with web inputs & outputs so we have a properly testable & re-usable function if (!empty($params['is_unit_test'])) { return array($groups, $iFilteredTotal); } CRM_Utils_System::setHttpHeader('Content-Type', 'application/json'); echo CRM_Utils_JSON::encodeDataTableSelector($groups, $sEcho, $iTotal, $iFilteredTotal, $selectorElements); CRM_Utils_System::civiExit(); } }
/** * Get list of options. * */ public static function getOptionList() { $params = $_REQUEST; $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer'); $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0; $rowCount = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25; $params['page'] = $offset / $rowCount + 1; $params['rp'] = $rowCount; $options = CRM_Core_BAO_CustomOption::getOptionListSelector($params); $iFilteredTotal = $iTotal = $params['total']; $selectorElements = array('label', 'value', 'is_default', 'is_active', 'links', 'class'); CRM_Utils_System::setHttpHeader('Content-Type', 'application/json'); echo CRM_Utils_JSON::encodeDataTableSelector($options, $sEcho, $iTotal, $iFilteredTotal, $selectorElements); CRM_Utils_System::civiExit(); }
/** * Retrieve a value from the bag. * * @param string $key * @param string|null $type * @param mixed $default * @return mixed * @throws API_Exception */ public function get($key, $type = NULL, $default = NULL) { if (!array_key_exists($key, $this->data)) { return $default; } if (!$type) { return $this->data[$key]; } $r = CRM_Utils_Type::validate($this->data[$key], $type); if ($r !== NULL) { return $r; } else { throw new \API_Exception(ts("Could not find valid value for %1 (%2)", array(1 => $key, 2 => $type))); } }
/** * Building EventFee combo box. * FIXME: This ajax callback could be eliminated in favor of an entityRef field but the priceFieldValue api doesn't currently support filtering on entity_table */ public function eventFee() { $name = trim(CRM_Utils_Type::escape($_GET['term'], 'String')); if (!$name) { $name = '%'; } $whereClause = "cv.label LIKE '{$name}%' "; $query = "SELECT DISTINCT (\ncv.label\n), cv.id\nFROM civicrm_price_field_value cv\nLEFT JOIN civicrm_price_field cf ON cv.price_field_id = cf.id\nLEFT JOIN civicrm_price_set_entity ce ON ce.price_set_id = cf.price_set_id\nWHERE ce.entity_table = 'civicrm_event' AND {$whereClause}\nGROUP BY cv.label"; $dao = CRM_Core_DAO::executeQuery($query); $results = array(); while ($dao->fetch()) { $results[] = array('id' => $dao->id, 'text' => $dao->label); } CRM_Utils_JSON::output($results); }
/** * Function for building EventFee combo box */ function eventFee() { require_once 'CRM/Utils/Type.php'; $name = trim(CRM_Utils_Type::escape($_GET['s'], 'String')); if (!$name) { $name = '%'; } $whereClause = "cv.label LIKE '{$name}%' "; $query = "\nSELECT distinct(cv.label), cv.id\nFROM civicrm_option_value cv, civicrm_option_group cg\nWHERE cg.name LIKE 'civicrm_event.amount%'\n AND cg.id = cv.option_group_id AND {$whereClause}\n GROUP BY cv.label\n"; $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { echo $elements = "{$dao->label}|{$dao->id}\n"; } CRM_Utils_System::civiExit(); }