コード例 #1
0
/**
 * Output navigation script tag
 *
 * @param array $params
 *   - is_default: bool, true if this is normal/default instance of the menu (which may be subject to CIVICRM_DISABLE_DEFAULT_MENU)
 * @param CRM_Core_Smarty $smarty
 *   The Smarty object.
 *
 * @return string
 *   HTML
 */
function smarty_function_crmNavigationMenu($params, &$smarty)
{
    $config = CRM_Core_Config::singleton();
    //check if logged in user has access CiviCRM permission and build menu
    $buildNavigation = !CRM_Core_Config::isUpgradeMode() && CRM_Core_Permission::check('access CiviCRM');
    if (defined('CIVICRM_DISABLE_DEFAULT_MENU') && CRM_Utils_Array::value('is_default', $params, FALSE)) {
        $buildNavigation = FALSE;
    }
    if ($config->userFrameworkFrontend) {
        $buildNavigation = FALSE;
    }
    if ($buildNavigation) {
        $session = CRM_Core_Session::singleton();
        $contactID = $session->get('userID');
        if ($contactID) {
            // These params force the browser to refresh the js file when switching user, domain, or language
            // We don't put them as a query string because some browsers will refuse to cache a page with a ? in the url
            // @see CRM_Admin_Page_AJAX::getNavigationMenu
            $lang = $config->lcMessages;
            $domain = CRM_Core_Config::domainID();
            $key = CRM_Core_BAO_Navigation::getCacheKey($contactID);
            $src = CRM_Utils_System::url("civicrm/ajax/menujs/{$contactID}/{$lang}/{$domain}/{$key}");
            // CRM-15493 QFkey needed for quicksearch bar - must be unique on each page refresh so adding it directly to markup
            $qfKey = CRM_Core_Key::get('CRM_Contact_Controller_Search', TRUE);
            return '<script id="civicrm-navigation-menu" type="text/javascript" src="' . $src . '" data-qfkey=' . json_encode($qfKey) . '></script>';
        }
    }
    return '';
}
コード例 #2
0
ファイル: function.crmSigner.php プロジェクト: hguru/224Civi
/**
 * Generate a secure signature
 *
 * {code}
 * {crmSigner var=mySig extra=123}
 * var urlParams = ts={$mySig.ts}&extra={$mySig.extra}&sig={$mySig.signature}
 * {endcode}
 *
 * @param $params array with keys:
 *   - var: string, a smarty variable to generate
 *   - ts: int, the current time (if omitted, autogenerated)
 *   - any other vars are put into the signature (sorted)
 */
function smarty_function_crmSigner($params, &$smarty)
{
    $var = $params['var'];
    unset($params['var']);
    $params['ts'] = CRM_Utils_Time::getTimeRaw();
    $fields = array_keys($params);
    sort($fields);
    $signer = new CRM_Utils_Signer(CRM_Core_Key::privateKey(), $fields);
    $params['signature'] = $signer->sign($params);
    $smarty->assign($var, $params);
}
コード例 #3
0
 public static function registerProfileScripts()
 {
     static $loaded = FALSE;
     if ($loaded || CRM_Core_Resources::isAjaxMode()) {
         return;
     }
     $loaded = TRUE;
     CRM_Core_Resources::singleton()->addSettingsFactory(function () {
         return array('PseudoConstant' => array('locationType' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'), 'websiteType' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'), 'phoneType' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id')), 'initialProfileList' => civicrm_api('UFGroup', 'get', array('version' => 3, 'sequential' => 1, 'is_active' => 1, 'rowCount' => 1000)), 'contactSubTypes' => CRM_Contact_BAO_ContactType::subTypes(), 'profilePreviewKey' => CRM_Core_Key::get('CRM_UF_Form_Inline_Preview', TRUE));
     })->addScriptFile('civicrm', 'packages/backbone/json2.js', 100, 'html-header', FALSE)->addScriptFile('civicrm', 'packages/backbone/backbone.js', 120, 'html-header')->addScriptFile('civicrm', 'packages/backbone/backbone.marionette.js', 125, 'html-header', FALSE)->addScriptFile('civicrm', 'packages/backbone/backbone.collectionsubset.js', 125, 'html-header', FALSE)->addScriptFile('civicrm', 'packages/backbone-forms/distribution/backbone-forms.js', 130, 'html-header', FALSE)->addScriptFile('civicrm', 'packages/backbone-forms/distribution/adapters/backbone.bootstrap-modal.min.js', 140, 'html-header', FALSE)->addScriptFile('civicrm', 'packages/backbone-forms/distribution/editors/list.min.js', 140, 'html-header', FALSE)->addStyleFile('civicrm', 'packages/backbone-forms/distribution/templates/default.css', 140, 'html-header')->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header')->addStyleFile('civicrm', 'css/crm.designer.css', 140, 'html-header')->addScriptFile('civicrm', 'js/crm.backbone.js', 150)->addScriptFile('civicrm', 'js/model/crm.schema-mapped.js', 200)->addScriptFile('civicrm', 'js/model/crm.uf.js', 200)->addScriptFile('civicrm', 'js/model/crm.designer.js', 200)->addScriptFile('civicrm', 'js/model/crm.profile-selector.js', 200)->addScriptFile('civicrm', 'js/view/crm.designer.js', 200)->addScriptFile('civicrm', 'js/view/crm.profile-selector.js', 200)->addScriptFile('civicrm', 'js/jquery/jquery.crmProfileSelector.js', 250)->addScriptFile('civicrm', 'js/crm.designerapp.js', 250);
     CRM_Core_Region::instance('page-header')->add(array('template' => 'CRM/UF/Page/ProfileTemplates.tpl'));
 }
コード例 #4
0
ファイル: Key.php プロジェクト: kidaa30/yes
 /**
  * @return mixed|null|string
  */
 public static function sessionID()
 {
     if (!self::$_sessionID) {
         $session = CRM_Core_Session::singleton();
         self::$_sessionID = $session->get('qfSessionID');
         if (!self::$_sessionID) {
             self::$_sessionID = session_id();
             $session->set('qfSessionID', self::$_sessionID);
         }
     }
     return self::$_sessionID;
 }
コード例 #5
0
 /**
  * Register profile scripts.
  */
 public static function registerProfileScripts()
 {
     static $loaded = FALSE;
     if ($loaded || CRM_Core_Resources::isAjaxMode()) {
         return;
     }
     $loaded = TRUE;
     CRM_Core_Resources::singleton()->addSettingsFactory(function () {
         $ufGroups = civicrm_api3('UFGroup', 'get', array('sequential' => 1, 'is_active' => 1, 'options' => array('limit' => 0)));
         //CRM-16915 - insert 'module' param for the profile used by CiviEvent.
         if (CRM_Core_Permission::check('manage event profiles') && !CRM_Core_Permission::check('administer CiviCRM')) {
             foreach ($ufGroups['values'] as $key => $value) {
                 $ufJoin = CRM_Core_BAO_UFGroup::getUFJoinRecord($value['id']);
                 if (in_array('CiviEvent', $ufJoin) || in_array('CiviEvent_Additional', $ufJoin)) {
                     $ufGroups['values'][$key]['module'] = 'CiviEvent';
                 }
             }
         }
         return array('PseudoConstant' => array('locationType' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'), 'websiteType' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'), 'phoneType' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id')), 'initialProfileList' => $ufGroups, 'contactSubTypes' => CRM_Contact_BAO_ContactType::subTypes(), 'profilePreviewKey' => CRM_Core_Key::get('CRM_UF_Form_Inline_Preview', TRUE));
     })->addScriptFile('civicrm', 'packages/backbone/json2.js', 100, 'html-header', FALSE)->addScriptFile('civicrm', 'packages/backbone/backbone.js', 120, 'html-header')->addScriptFile('civicrm', 'packages/backbone/backbone.marionette.js', 125, 'html-header', FALSE)->addScriptFile('civicrm', 'packages/backbone/backbone.collectionsubset.js', 125, 'html-header', FALSE)->addScriptFile('civicrm', 'packages/backbone-forms/distribution/backbone-forms.js', 130, 'html-header', FALSE)->addScriptFile('civicrm', 'packages/backbone-forms/distribution/adapters/backbone.bootstrap-modal.min.js', 140, 'html-header', FALSE)->addScriptFile('civicrm', 'packages/backbone-forms/distribution/editors/list.min.js', 140, 'html-header', FALSE)->addStyleFile('civicrm', 'packages/backbone-forms/distribution/templates/default.css', 140, 'html-header')->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header')->addStyleFile('civicrm', 'css/crm.designer.css', 140, 'html-header')->addScriptFile('civicrm', 'js/crm.backbone.js', 150)->addScriptFile('civicrm', 'js/model/crm.schema-mapped.js', 200)->addScriptFile('civicrm', 'js/model/crm.uf.js', 200)->addScriptFile('civicrm', 'js/model/crm.designer.js', 200)->addScriptFile('civicrm', 'js/model/crm.profile-selector.js', 200)->addScriptFile('civicrm', 'js/view/crm.designer.js', 200)->addScriptFile('civicrm', 'js/view/crm.profile-selector.js', 200)->addScriptFile('civicrm', 'js/jquery/jquery.crmProfileSelector.js', 250)->addScriptFile('civicrm', 'js/crm.designerapp.js', 250);
     CRM_Core_Region::instance('page-header')->add(array('template' => 'CRM/UF/Page/ProfileTemplates.tpl'));
 }
コード例 #6
0
/**
 * Generate a CRM_Core_Key of a given name
 *
 * @param string $params params of the {crmKey} call, with the ‘name’ key holding the name of the key
 * @param object $smarty the Smarty object
 *
 * @return string the generated key
 */
function smarty_function_crmKey($params, &$smarty)
{
    require_once 'CRM/Core/Key.php';
    return CRM_Core_Key::get($params['name']);
}
コード例 #7
0
ファイル: AJAX.php プロジェクト: nielosz/civicrm-core
 public static function getCaseRoles()
 {
     $caseID = CRM_Utils_Type::escape($_GET['caseID'], 'Integer');
     $contactID = CRM_Utils_Type::escape($_GET['cid'], 'Integer');
     $params = CRM_Core_Page_AJAX::defaultSortAndPagerParams();
     $caseRelationships = CRM_Case_BAO_Case::getCaseRoles($contactID, $caseID);
     $caseTypeName = CRM_Case_BAO_Case::getCaseType($caseID, 'name');
     $xmlProcessor = new CRM_Case_XMLProcessor_Process();
     $caseRoles = $xmlProcessor->get($caseTypeName, 'CaseRoles');
     $hasAccessToAllCases = CRM_Core_Permission::check('access all cases and activities');
     $managerRoleId = $xmlProcessor->getCaseManagerRoleId($caseTypeName);
     foreach ($caseRelationships as $key => $value) {
         // This role has been filled
         unset($caseRoles[$value['relation_type']]);
         // mark original case relationships record to use on setting edit links below
         $caseRelationships[$key]['source'] = 'caseRel';
     }
     $caseRoles['client'] = CRM_Case_BAO_Case::getContactNames($caseID);
     // move/transform caseRoles array data to caseRelationships
     // for sorting and display
     // CRM-14466 added cid to the non-client array to avoid php notice
     foreach ($caseRoles as $id => $value) {
         if ($id != "client") {
             $rel = array();
             $rel['relation'] = $value;
             $rel['relation_type'] = $id;
             $rel['name'] = '(not assigned)';
             $rel['phone'] = '';
             $rel['email'] = '';
             $rel['source'] = 'caseRoles';
             $caseRelationships[] = $rel;
         } else {
             foreach ($value as $clientRole) {
                 $relClient = array();
                 $relClient['relation'] = 'Client';
                 $relClient['name'] = $clientRole['sort_name'];
                 $relClient['phone'] = $clientRole['phone'];
                 $relClient['email'] = $clientRole['email'];
                 $relClient['cid'] = $clientRole['contact_id'];
                 $relClient['source'] = 'contact';
                 $caseRelationships[] = $relClient;
             }
         }
     }
     // sort clientRelationships array using jquery call params
     foreach ($caseRelationships as $key => $row) {
         $sortArray[$key] = $row[$params['_raw_values']['sort'][0]];
     }
     $sort_type = "SORT_" . strtoupper($params['_raw_values']['order'][0]);
     array_multisort($sortArray, constant($sort_type), $caseRelationships);
     $relationships = array();
     // set user name, email and edit columns links
     foreach ($caseRelationships as $key => &$row) {
         $typeLabel = $row['relation'];
         // Add "<br />(Case Manager)" to label
         if ($row['relation_type'] == $managerRoleId) {
             $row['relation'] .= '<br />' . '(' . ts('Case Manager') . ')';
         }
         // view user links
         if (!empty($row['cid'])) {
             $row['name'] = '<a class="view-contact" title="' . ts('View Contact') . '" href=' . CRM_Utils_System::url('civicrm/contact/view', 'action=view&reset=1&cid=' . $row['cid']) . '>' . $row['name'] . '</a>';
         }
         // email column links/icon
         if ($row['email']) {
             $row['email'] = '<a class="crm-hover-button crm-popup" href="' . CRM_Utils_System::url('civicrm/activity/email/add', 'reset=1&action=add&atype=3&cid=' . $row['cid']) . '&caseid=' . $caseID . '" title="' . ts('Send an Email') . '"><i class="crm-i fa-envelope"></i></a>';
         }
         // edit links
         $row['actions'] = '';
         if ($hasAccessToAllCases) {
             $contactType = empty($row['relation_type']) ? '' : (string) CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', $row['relation_type'], 'contact_type_b');
             $contactType = $contactType == 'Contact' ? '' : $contactType;
             switch ($row['source']) {
                 case 'caseRel':
                     $row['actions'] = '<a href="#editCaseRoleDialog" title="' . ts('Reassign %1', array(1 => $typeLabel)) . '" class="crm-hover-button case-miniform" data-contact_type="' . $contactType . '" data-rel_type="' . $row['relation_type'] . '_' . $row['relationship_direction'] . '" data-cid="' . $row['cid'] . '" data-rel_id="' . $row['rel_id'] . '"data-key="' . CRM_Core_Key::get('civicrm/ajax/relation') . '">' . '<i class="crm-i fa-pencil"></i>' . '</a>' . '<a href="#deleteCaseRoleDialog" title="' . ts('Remove %1', array(1 => $typeLabel)) . '" class="crm-hover-button case-miniform" data-contact_type="' . $contactType . '" data-rel_type="' . $row['relation_type'] . '_' . $row['relationship_direction'] . '" data-cid="' . $row['cid'] . '" data-key="' . CRM_Core_Key::get('civicrm/ajax/delcaserole') . '">' . '<span class="icon delete-icon"></span>' . '</a>';
                     break;
                 case 'caseRoles':
                     $row['actions'] = '<a href="#editCaseRoleDialog" title="' . ts('Assign %1', array(1 => $typeLabel)) . '" class="crm-hover-button case-miniform" data-contact_type="' . $contactType . '" data-rel_type="' . $row['relation_type'] . '_b_a" data-key="' . CRM_Core_Key::get('civicrm/ajax/relation') . '">' . '<i class="crm-i fa-pencil"></i>' . '</a>';
                     break;
             }
         }
         unset($row['cid']);
         unset($row['relation_type']);
         unset($row['rel_id']);
         unset($row['client_id']);
         unset($row['source']);
         array_push($relationships, $row);
     }
     $params['total'] = count($relationships);
     $caseRelationshipsDT = array();
     $caseRelationshipsDT['data'] = $relationships;
     $caseRelationshipsDT['recordsTotal'] = $params['total'];
     $caseRelationshipsDT['recordsFiltered'] = $params['total'];
     CRM_Utils_JSON::output($caseRelationshipsDT);
 }
コード例 #8
0
ファイル: Controller.php プロジェクト: bhirsch/voipdev
 function key($name, $addSequence = false, $ignoreKey = false)
 {
     $config =& CRM_Core_Config::singleton();
     if ($ignoreKey || isset($config->keyDisable) && $config->keyDisable) {
         return null;
     }
     require_once 'CRM/Core/Key.php';
     $key = CRM_Utils_Array::value('qfKey', $_REQUEST, null);
     if (!$key) {
         $key = CRM_Core_Key::get($name, $addSequence);
     } else {
         $key = CRM_Core_Key::validate($key, $name, $addSequence);
     }
     if (!$key) {
         $msg = ts('We can\'t load the requested web page. This page requires cookies to be enabled in your browser settings. Please check this setting and enable cookies (if they are not enabled). Then try again. If this error persists, contact the site adminstrator for assistance.') . '<br /><br />' . ts('Error type: Could not find a valid key.');
         CRM_Core_Error::fatal($msg);
     }
     $this->_key = $key;
     return $key;
 }
コード例 #9
0
 static function checkMenuItem(&$item)
 {
     if (!array_key_exists('access_callback', $item)) {
         CRM_Core_Error::backtrace();
         CRM_Core_Error::fatal();
     }
     // if component_id is present, ensure it is enabled
     if (isset($item['component_id']) && $item['component_id']) {
         $config = CRM_Core_Config::singleton();
         if (is_array($config->enableComponentIDs) && in_array($item['component_id'], $config->enableComponentIDs)) {
             // continue with process
         } else {
             return FALSE;
         }
     }
     // the following is imitating drupal 6 code in includes/menu.inc
     if (empty($item['access_callback']) || is_numeric($item['access_callback'])) {
         return (bool) $item['access_callback'];
     }
     // check whether the following Ajax requests submitted the right key
     // FIXME: this should be integrated into ACLs proper
     if (CRM_Utils_Array::value('page_type', $item) == 3) {
         if (!CRM_Core_Key::validate($_REQUEST['key'], $item['path'])) {
             return FALSE;
         }
     }
     // check if callback is for checkMenu, if so optimize it
     if (is_array($item['access_callback']) && $item['access_callback'][0] == 'CRM_Core_Permission' && $item['access_callback'][1] == 'checkMenu') {
         $op = CRM_Utils_Array::value(1, $item['access_arguments'], 'and');
         return self::checkMenu($item['access_arguments'][0], $op);
     } else {
         return call_user_func_array($item['access_callback'], $item['access_arguments']);
     }
 }
コード例 #10
0
 /**
  * @param string $token
  *   A token supplied by the user.
  * @return bool
  *   TRUE if the token is valid for submitting attachments
  * @throws Exception
  */
 public static function checkToken($token)
 {
     list($signature, $ts) = explode(';;;', $token);
     $signer = new CRM_Utils_Signer(CRM_Core_Key::privateKey(), array('for', 'ts'));
     if (!is_numeric($ts) || CRM_Utils_Time::getTimeRaw() > $ts + self::ATTACHMENT_TOKEN_TTL) {
         return FALSE;
     }
     return $signer->validate($signature, array('for' => 'crmAttachment', 'ts' => $ts));
 }
コード例 #11
0
ファイル: AJAX.php プロジェクト: kcristiano/civicrm-core
 /**
  *  check the CMS username.
  */
 public static function checkUserName()
 {
     $signer = new CRM_Utils_Signer(CRM_Core_Key::privateKey(), array('for', 'ts'));
     $sig = CRM_Utils_Request::retrieve('sig', 'String', CRM_Core_DAO::$_nullObject);
     $for = CRM_Utils_Request::retrieve('for', 'String', CRM_Core_DAO::$_nullObject);
     if (CRM_Utils_Time::getTimeRaw() > $_REQUEST['ts'] + self::CHECK_USERNAME_TTL || $for != 'civicrm/ajax/cmsuser' || !$signer->validate($sig, $_REQUEST)) {
         $user = array('name' => 'error');
         CRM_Utils_JSON::output($user);
     }
     $config = CRM_Core_Config::singleton();
     $username = trim(CRM_Utils_Array::value('cms_name', $_REQUEST));
     $params = array('name' => $username);
     $errors = array();
     $config->userSystem->checkUserNameEmailExists($params, $errors);
     if (isset($errors['cms_name']) || isset($errors['name'])) {
         //user name is not available
         $user = array('name' => 'no');
         CRM_Utils_JSON::output($user);
     } else {
         //user name is available
         $user = array('name' => 'yes');
         CRM_Utils_JSON::output($user);
     }
     // Not reachable: JSON::output() above exits.
     CRM_Utils_System::civiExit();
 }
コード例 #12
0
 /**
  * Browse the listing
  *
  * @return void
  * @access public
  */
 function browse()
 {
     $dateFields = NULL;
     $cgcount = 0;
     $dateFieldsVals = NULL;
     if ($this->_pageViewType == 'profileDataView' && $this->_profileId) {
         $fields = CRM_Core_BAO_UFGroup::getFields($this->_profileId, FALSE, NULL, NULL, NULL, FALSE, NULL, FALSE, NULL, CRM_Core_Permission::EDIT);
         $multiRecordFields = array();
         $fieldIDs = NULL;
         $result = NULL;
         $multiRecordFieldsWithSummaryListing = CRM_Core_BAO_UFGroup::shiftMultiRecordFields($fields, $multiRecordFields, TRUE);
         $multiFieldId = CRM_Core_BAO_CustomField::getKeyID(key($multiRecordFields));
         $customGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $multiFieldId, 'custom_group_id');
         $reached = CRM_Core_BAO_CustomGroup::hasReachedMaxLimit($customGroupId, $this->_contactId);
         if (!$reached) {
             $this->assign('contactId', $this->_contactId);
             $this->assign('gid', $this->_profileId);
         }
         $this->assign('reachedMax', $reached);
         if ($multiRecordFieldsWithSummaryListing && !empty($multiRecordFieldsWithSummaryListing)) {
             $fieldIDs = array_keys($multiRecordFieldsWithSummaryListing);
         }
     } elseif ($this->_pageViewType == 'customDataView') {
         // require custom group id for _pageViewType of customDataView
         $customGroupId = $this->_customGroupId;
         $reached = CRM_Core_BAO_CustomGroup::hasReachedMaxLimit($customGroupId, $this->_contactId);
         if (!$reached) {
             $this->assign('contactId', $this->_contactId);
             $this->assign('customGroupId', $customGroupId);
             $this->assign('ctype', $this->_contactType);
         }
         $this->assign('reachedMax', $reached);
         // custom group info : this consists of the field title of group fields
         $groupDetail = CRM_Core_BAO_CustomGroup::getGroupDetail($customGroupId, NULL, CRM_Core_DAO::$_nullObject, TRUE);
         // field ids of fields in_selector for the custom group id provided
         $fieldIDs = array_keys($groupDetail[$customGroupId]['fields']);
         // field labels for headers
         $fieldLabels = $groupDetail[$customGroupId]['fields'];
         // from the above customGroupInfo we can get $this->_customGroupTitle
         $this->_customGroupTitle = $groupDetail[$customGroupId]['title'];
     }
     if ($fieldIDs && !empty($fieldIDs) && $this->_contactId) {
         $options = array();
         $returnProperities = array('html_type', 'data_type', 'date_format', 'time_format');
         foreach ($fieldIDs as $key => $fieldID) {
             $fieldIDs[$key] = !is_numeric($fieldID) ? CRM_Core_BAO_CustomField::getKeyID($fieldID) : $fieldID;
             $param = array('id' => $fieldIDs[$key]);
             $returnValues = array();
             CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $param, $returnValues, $returnProperities);
             if ($returnValues['data_type'] == 'Date') {
                 $dateFields[$fieldIDs[$key]] = 1;
             }
             $optionValuePairs = CRM_Core_BAO_CustomOption::getCustomOption($fieldIDs[$key]);
             if (!empty($optionValuePairs)) {
                 foreach ($optionValuePairs as $optionPairs) {
                     $options[$fieldIDs[$key]][$optionPairs['value']] = $optionPairs['label'];
                 }
             }
             $options[$fieldIDs[$key]]['attributes']['html_type'] = $returnValues['html_type'];
             $options[$fieldIDs[$key]]['attributes']['data_type'] = $returnValues['data_type'];
             $options[$fieldIDs[$key]]['attributes']['format'] = $options[$fieldIDs[$key]]['attributes']['date_format'] = CRM_Utils_Array::value('date_format', $returnValues);
             $options[$fieldIDs[$key]]['attributes']['time_format'] = CRM_Utils_Array::value('time_format', $returnValues);
         }
         // commonly used for both views i.e profile listing view (profileDataView) and custom data listing view (customDataView)
         $result = CRM_Core_BAO_CustomValueTable::getEntityValues($this->_contactId, NULL, $fieldIDs, TRUE);
         if ($this->_pageViewType == 'profileDataView') {
             if (!empty($fieldIDs)) {
                 //get the group info of multi rec fields in listing view
                 $fieldInput = $fieldIDs;
                 $fieldIdInput = $fieldIDs[0];
             } else {
                 //if no listing fields exist, take the group title for display
                 $nonListingFieldIds = array_keys($multiRecordFields);
                 $singleField = CRM_Core_BAO_CustomField::getKeyID($nonListingFieldIds[0]);
                 $fieldIdInput = $singleField;
                 $singleField = array($singleField);
                 $fieldInput = $singleField;
             }
             $customGroupInfo = CRM_Core_BAO_CustomGroup::getGroupTitles($fieldInput);
             $this->_customGroupTitle = $customGroupInfo[$fieldIdInput]['groupTitle'];
         }
         // $cgcount is defined before 'if' condition as enitiy may have no record
         // and $cgcount is used to build new record url
         $cgcount = 1;
         if ($result && !empty($result)) {
             $links = self::links();
             if ($this->_pageViewType == 'profileDataView') {
                 $pageCheckSum = $this->get('pageCheckSum');
                 if ($pageCheckSum) {
                     foreach ($links as $key => $link) {
                         $links[$key] = $link['qs'] . "&cs=%%cs%%";
                     }
                 }
             }
             $linkAction = array_sum(array_keys($this->links()));
             if ($reached) {
                 unset($links[CRM_Core_Action::COPY]);
             }
             $newCgCount = !$reached ? count($result) + 1 : NULL;
             foreach ($result as $recId => &$value) {
                 foreach ($value as $fieldId => &$val) {
                     if (is_numeric($fieldId)) {
                         $customValue =& $val;
                         if (!empty($dateFields) && array_key_exists($fieldId, $dateFields)) {
                             // formated date capture value capture
                             $dateFieldsVals[$fieldId][$recId] = CRM_Core_BAO_CustomField::getDisplayValue($customValue, $fieldId, $options);
                         } else {
                             // assign to $result
                             $customValue = CRM_Core_BAO_CustomField::getDisplayValue($customValue, $fieldId, $options);
                         }
                         if (!$customValue) {
                             $customValue = "";
                         }
                         $op = NULL;
                         if ($this->_pageViewType == 'profileDataView') {
                             $actionParams = array('recordId' => $recId, 'gid' => $this->_profileId, 'id' => $this->_contactId);
                             $op = 'profile.multiValue.row';
                         } else {
                             // different set of url params
                             $actionParams['gid'] = $actionParams['groupID'] = $this->_customGroupId;
                             $actionParams['cid'] = $actionParams['entityID'] = $this->_contactId;
                             $actionParams['recId'] = $recId;
                             $actionParams['type'] = $this->_contactType;
                             $actionParams['cgcount'] = $cgcount;
                             $actionParams['newCgCount'] = $newCgCount;
                             // DELETE action links
                             $deleteData = array('valueID' => $recId, 'groupID' => $this->_customGroupId, 'contactId' => $this->_contactId, 'key' => CRM_Core_Key::get('civicrm/ajax/customvalue'));
                             $links[CRM_Core_Action::DELETE]['url'] = '#';
                             $links[CRM_Core_Action::DELETE]['extra'] = ' data-delete_params="' . htmlspecialchars(json_encode($deleteData)) . '"';
                             $links[CRM_Core_Action::DELETE]['class'] = 'delete-custom-row';
                         }
                         if (!empty($pageCheckSum)) {
                             $actionParams['cs'] = $pageCheckSum;
                         }
                         $value['action'] = CRM_Core_Action::formLink($links, $linkAction, $actionParams, ts('more'), FALSE, $op, 'customValue', $fieldId);
                     }
                 }
                 $cgcount++;
             }
         }
     }
     $headers = array();
     if (!empty($fieldIDs)) {
         foreach ($fieldIDs as $fieldID) {
             $headers[$fieldID] = $this->_pageViewType == 'profileDataView' ? $customGroupInfo[$fieldID]['fieldLabel'] : $fieldLabels[$fieldID]['label'];
         }
     }
     $this->assign('dateFields', $dateFields);
     $this->assign('dateFieldsVals', $dateFieldsVals);
     $this->assign('cgcount', $cgcount);
     $this->assign('customGroupTitle', $this->_customGroupTitle);
     $this->assign('headers', $headers);
     $this->assign('records', $result);
 }
コード例 #13
0
ファイル: Controller.php プロジェクト: hguru/224Civi
 function key($name, $addSequence = FALSE, $ignoreKey = FALSE)
 {
     $config = CRM_Core_Config::singleton();
     if ($ignoreKey || isset($config->keyDisable) && $config->keyDisable) {
         return NULL;
     }
     $key = CRM_Utils_Array::value('qfKey', $_REQUEST, NULL);
     if (!$key && $_SERVER['REQUEST_METHOD'] === 'GET') {
         $key = CRM_Core_Key::get($name, $addSequence);
     } else {
         $key = CRM_Core_Key::validate($key, $name, $addSequence);
     }
     if (!$key) {
         $this->invalidKey();
     }
     $this->_key = $key;
     return $key;
 }
コード例 #14
0
/**
 * Profile.GetAngularSettings API
 *
 * @param array $params
 * @return array API result descriptor
 * @see civicrm_api3_create_success
 * @see civicrm_api3_create_error
 * @throws API_Exception
 */
function civicrm_api3_profile_getangularsettings($params)
{
    $returnValues = array('PseudoConstant' => array('locationType' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'), 'websiteType' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'), 'phoneType' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id')), 'initialProfileList' => civicrm_api('UFGroup', 'get', array('version' => 3, 'sequential' => 1, 'is_active' => 1, 'rowCount' => 1000)), 'contactSubTypes' => CRM_Contact_BAO_ContactType::subTypes(), 'profilePreviewKey' => CRM_Core_Key::get('CRM_UF_Form_Inline_Preview', TRUE));
    return civicrm_api3_create_success($returnValues, $params, 'Profile', 'getangularsettings');
}
コード例 #15
0
 /**
  * Browse the listing.
  *
  * @return void
  */
 public function browse()
 {
     $dateFields = NULL;
     $cgcount = 0;
     $attributes = array();
     $dateFieldsVals = NULL;
     if ($this->_pageViewType == 'profileDataView' && $this->_profileId) {
         $fields = CRM_Core_BAO_UFGroup::getFields($this->_profileId, FALSE, NULL, NULL, NULL, FALSE, NULL, FALSE, NULL, CRM_Core_Permission::EDIT);
         $multiRecordFields = array();
         $fieldIDs = NULL;
         $result = NULL;
         $multiRecordFieldsWithSummaryListing = CRM_Core_BAO_UFGroup::shiftMultiRecordFields($fields, $multiRecordFields, TRUE);
         $multiFieldId = CRM_Core_BAO_CustomField::getKeyID(key($multiRecordFields));
         $customGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $multiFieldId, 'custom_group_id');
         $reached = CRM_Core_BAO_CustomGroup::hasReachedMaxLimit($customGroupId, $this->_contactId);
         if (!$reached) {
             $this->assign('contactId', $this->_contactId);
             $this->assign('gid', $this->_profileId);
         }
         $this->assign('reachedMax', $reached);
         if ($multiRecordFieldsWithSummaryListing && !empty($multiRecordFieldsWithSummaryListing)) {
             $fieldIDs = array_keys($multiRecordFieldsWithSummaryListing);
         }
     } elseif ($this->_pageViewType == 'customDataView') {
         // require custom group id for _pageViewType of customDataView
         $customGroupId = $this->_customGroupId;
         $reached = CRM_Core_BAO_CustomGroup::hasReachedMaxLimit($customGroupId, $this->_contactId);
         if (!$reached) {
             $this->assign('contactId', $this->_contactId);
             $this->assign('customGroupId', $customGroupId);
             $this->assign('ctype', $this->_contactType);
         }
         $this->assign('reachedMax', $reached);
         // custom group info : this consists of the field title of group fields
         $groupDetail = CRM_Core_BAO_CustomGroup::getGroupDetail($customGroupId, NULL, CRM_Core_DAO::$_nullObject, TRUE);
         // field ids of fields in_selector for the custom group id provided
         $fieldIDs = array_keys($groupDetail[$customGroupId]['fields']);
         // field labels for headers
         $fieldLabels = $groupDetail[$customGroupId]['fields'];
         // from the above customGroupInfo we can get $this->_customGroupTitle
         $this->_customGroupTitle = $groupDetail[$customGroupId]['title'];
     }
     if ($fieldIDs && !empty($fieldIDs) && $this->_contactId) {
         $options = array();
         $returnProperities = array('html_type', 'data_type', 'date_format', 'time_format', 'default_value', 'is_required');
         foreach ($fieldIDs as $key => $fieldID) {
             $fieldIDs[$key] = !is_numeric($fieldID) ? CRM_Core_BAO_CustomField::getKeyID($fieldID) : $fieldID;
             $param = array('id' => $fieldIDs[$key]);
             $returnValues = array();
             CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $param, $returnValues, $returnProperities);
             if ($returnValues['data_type'] == 'Date') {
                 $dateFields[$fieldIDs[$key]] = 1;
                 $actualPHPFormats = CRM_Core_SelectValues::datePluginToPHPFormats();
                 $dateFormat = (array) CRM_Utils_Array::value($returnValues['date_format'], $actualPHPFormats);
                 $timeFormat = CRM_Utils_Array::value('time_format', $returnValues);
             }
             $optionValuePairs = CRM_Core_BAO_CustomOption::getCustomOption($fieldIDs[$key]);
             if (!empty($optionValuePairs)) {
                 foreach ($optionValuePairs as $optionPairs) {
                     $options[$fieldIDs[$key]][$optionPairs['value']] = $optionPairs['label'];
                 }
             }
             $options[$fieldIDs[$key]]['attributes']['html_type'] = $returnValues['html_type'];
             $options[$fieldIDs[$key]]['attributes']['data_type'] = $returnValues['data_type'];
             $options[$fieldIDs[$key]]['attributes']['is_required'] = !empty($returnValues['is_required']);
             $options[$fieldIDs[$key]]['attributes']['default_value'] = CRM_Utils_Array::value('default_value', $returnValues);
             $options[$fieldIDs[$key]]['attributes']['format'] = $options[$fieldIDs[$key]]['attributes']['date_format'] = CRM_Utils_Array::value('date_format', $returnValues);
             $options[$fieldIDs[$key]]['attributes']['time_format'] = CRM_Utils_Array::value('time_format', $returnValues);
         }
         // commonly used for both views i.e profile listing view (profileDataView) and custom data listing view (customDataView)
         $result = CRM_Core_BAO_CustomValueTable::getEntityValues($this->_contactId, NULL, $fieldIDs, TRUE);
         if ($this->_pageViewType == 'profileDataView') {
             if (!empty($fieldIDs)) {
                 //get the group info of multi rec fields in listing view
                 $fieldInput = $fieldIDs;
                 $fieldIdInput = $fieldIDs[0];
             } else {
                 //if no listing fields exist, take the group title for display
                 $nonListingFieldIds = array_keys($multiRecordFields);
                 $singleField = CRM_Core_BAO_CustomField::getKeyID($nonListingFieldIds[0]);
                 $fieldIdInput = $singleField;
                 $singleField = array($singleField);
                 $fieldInput = $singleField;
             }
             $customGroupInfo = CRM_Core_BAO_CustomGroup::getGroupTitles($fieldInput);
             $this->_customGroupTitle = $customGroupInfo[$fieldIdInput]['groupTitle'];
         }
         // $cgcount is defined before 'if' condition as enitiy may have no record
         // and $cgcount is used to build new record url
         $cgcount = 1;
         if ($result && !empty($result)) {
             $links = self::links();
             if ($this->_pageViewType == 'profileDataView') {
                 $pageCheckSum = $this->get('pageCheckSum');
                 if ($pageCheckSum) {
                     foreach ($links as $key => $link) {
                         $links[$key] = $link['qs'] . "&cs=%%cs%%";
                     }
                 }
             }
             $linkAction = array_sum(array_keys($this->links()));
             if ($reached) {
                 unset($links[CRM_Core_Action::COPY]);
             }
             $newCgCount = !$reached ? count($result) + 1 : NULL;
             foreach ($result as $recId => &$value) {
                 foreach ($value as $fieldId => &$val) {
                     if (is_numeric($fieldId)) {
                         $customValue =& $val;
                         if (!empty($dateFields) && array_key_exists($fieldId, $dateFields)) {
                             // formated date capture value capture
                             $dateFieldsVals[$fieldId][$recId] = CRM_Core_BAO_CustomField::getDisplayValue($customValue, $fieldId, $options);
                             //set date and time format
                             switch ($timeFormat) {
                                 case 1:
                                     $dateFormat[1] = 'g:iA';
                                     break;
                                 case 2:
                                     $dateFormat[1] = 'G:i';
                                     break;
                                 default:
                                     // if time is not selected remove time from value
                                     $result[$recId][$fieldId] = substr($result[$recId][$fieldId], 0, 10);
                             }
                             $result[$recId][$fieldId] = CRM_Utils_Date::processDate($result[$recId][$fieldId], NULL, FALSE, implode(" ", $dateFormat));
                         } else {
                             // assign to $result
                             $customValue = CRM_Core_BAO_CustomField::getDisplayValue($customValue, $fieldId, $options);
                         }
                         // FIXME: getDisplayValue should always return a string so why is this necessary?
                         if (!$customValue && $customValue !== '0') {
                             $customValue = "";
                         }
                         // Set field attributes to support crmEditable
                         // Note that $fieldAttributes[data-type] actually refers to the html type not the sql data type
                         // TODO: Not all widget types and validation rules are supported by crmEditable so some fields will not be in-place editable
                         $fieldAttributes = array('class' => "crmf-custom_{$fieldId}_{$recId}");
                         $editable = FALSE;
                         if ($linkAction & CRM_Core_Action::UPDATE) {
                             $spec = $options[$fieldId]['attributes'];
                             switch ($spec['html_type']) {
                                 case 'Text':
                                     // Other data types like money would require some extra validation
                                     // FIXME: crmEditable currently does not support any validation rules :(
                                     $supportedDataTypes = array('Float', 'String', 'Int');
                                     $editable = in_array($spec['data_type'], $supportedDataTypes);
                                     break;
                                 case 'TextArea':
                                     $editable = TRUE;
                                     $fieldAttributes['data-type'] = 'textarea';
                                     break;
                                 case 'Radio':
                                 case 'Select':
                                 case 'Select Country':
                                 case 'Select State/Province':
                                     $editable = TRUE;
                                     $fieldAttributes['data-type'] = $spec['data_type'] == 'Boolean' ? 'boolean' : 'select';
                                     if (!$spec['is_required']) {
                                         $fieldAttributes['data-empty-option'] = ts('- none -');
                                     }
                                     break;
                             }
                         }
                         if ($editable) {
                             $fieldAttributes['class'] .= ' crm-editable';
                         }
                         $attributes[$fieldId][$recId] = $fieldAttributes;
                         $op = NULL;
                         if ($this->_pageViewType == 'profileDataView') {
                             $actionParams = array('recordId' => $recId, 'gid' => $this->_profileId, 'id' => $this->_contactId);
                             $op = 'profile.multiValue.row';
                         } else {
                             // different set of url params
                             $actionParams['gid'] = $actionParams['groupID'] = $this->_customGroupId;
                             $actionParams['cid'] = $actionParams['entityID'] = $this->_contactId;
                             $actionParams['recId'] = $recId;
                             $actionParams['type'] = $this->_contactType;
                             $actionParams['cgcount'] = $cgcount;
                             $actionParams['newCgCount'] = $newCgCount;
                             // DELETE action links
                             $deleteData = array('valueID' => $recId, 'groupID' => $this->_customGroupId, 'contactId' => $this->_contactId, 'key' => CRM_Core_Key::get('civicrm/ajax/customvalue'));
                             $links[CRM_Core_Action::DELETE]['url'] = '#';
                             $links[CRM_Core_Action::DELETE]['extra'] = ' data-delete_params="' . htmlspecialchars(json_encode($deleteData)) . '"';
                             $links[CRM_Core_Action::DELETE]['class'] = 'delete-custom-row';
                         }
                         if (!empty($pageCheckSum)) {
                             $actionParams['cs'] = $pageCheckSum;
                         }
                         $value['action'] = CRM_Core_Action::formLink($links, $linkAction, $actionParams, ts('more'), FALSE, $op, 'customValue', $fieldId);
                     }
                 }
                 $cgcount++;
             }
         }
     }
     $headers = array();
     if (!empty($fieldIDs)) {
         foreach ($fieldIDs as $fieldID) {
             $headers[$fieldID] = $this->_pageViewType == 'profileDataView' ? $customGroupInfo[$fieldID]['fieldLabel'] : $fieldLabels[$fieldID]['label'];
         }
     }
     $this->assign('dateFields', $dateFields);
     $this->assign('dateFieldsVals', $dateFieldsVals);
     $this->assign('cgcount', $cgcount);
     $this->assign('customGroupTitle', $this->_customGroupTitle);
     $this->assign('headers', $headers);
     $this->assign('records', $result);
     $this->assign('attributes', $attributes);
 }
コード例 #16
0
/**
 * Generate a CRM_Core_Key of a given name
 *
 * @param string $params params of the {crmKey} call, with the ‘name’ key holding the name of the key
 * @param object $smarty the Smarty object
 *
 * @return string the generated key
 */
function smarty_function_crmKey($params, &$smarty)
{
    return CRM_Core_Key::get($params['name'], CRM_Utils_Array::value('addSequence', $params, 0));
}
コード例 #17
0
ファイル: AJAX.php プロジェクト: hguru/224Civi
 /**
  *Function to check the CMS username
  *
  */
 public static function checkUserName()
 {
     $signer = new CRM_Utils_Signer(CRM_Core_Key::privateKey(), array('for', 'ts'));
     if (CRM_Utils_Time::getTimeRaw() > $_REQUEST['ts'] + self::CHECK_USERNAME_TTL || $_REQUEST['for'] != 'civicrm/ajax/cmsuser' || !$signer->validate($_REQUEST['sig'], $_REQUEST)) {
         $user = array('name' => 'error');
         echo json_encode($user);
         CRM_Utils_System::civiExit();
     }
     $config = CRM_Core_Config::singleton();
     $username = trim($_REQUEST['cms_name']);
     $params = array('name' => $username);
     $errors = array();
     $config->userSystem->checkUserNameEmailExists($params, $errors);
     if (isset($errors['cms_name']) || isset($errors['name'])) {
         //user name is not availble
         $user = array('name' => 'no');
         echo json_encode($user);
     } else {
         //user name is available
         $user = array('name' => 'yes');
         echo json_encode($user);
     }
     CRM_Utils_System::civiExit();
 }
コード例 #18
0
ファイル: AJAX.php プロジェクト: kidaa30/yes
 public static function getCaseRoles()
 {
     $caseID = CRM_Utils_Type::escape($_GET['caseID'], 'Integer');
     $contactID = CRM_Utils_Type::escape($_GET['cid'], 'Integer');
     $sortMapper = array(0 => 'relation', 1 => 'name', 2 => 'phone', 3 => 'email', 4 => 'actions');
     $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) : 'relation';
     $sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc';
     $params = $_POST;
     if ($sort && $sortOrder) {
         $sortSQL = $sort . ' ' . $sortOrder;
     }
     $caseRelationships = CRM_Case_BAO_Case::getCaseRoles($contactID, $caseID);
     $caseTypeName = CRM_Case_BAO_Case::getCaseType($caseID, 'name');
     $xmlProcessor = new CRM_Case_XMLProcessor_Process();
     $caseRoles = $xmlProcessor->get($caseTypeName, 'CaseRoles');
     $hasAccessToAllCases = CRM_Core_Permission::check('access all cases and activities');
     $managerRoleId = $xmlProcessor->getCaseManagerRoleId($caseTypeName);
     if (!empty($managerRoleId)) {
         $caseRoles[$managerRoleId] = $caseRoles[$managerRoleId] . '<br />' . '(' . ts('Case Manager') . ')';
     }
     foreach ($caseRelationships as $key => $value) {
         //calculate roles that don't have relationships
         if (!empty($caseRoles[$value['relation_type']])) {
             //keep naming from careRoles array
             $caseRelationships[$key]['relation'] = $caseRoles[$value['relation_type']];
             unset($caseRoles[$value['relation_type']]);
         }
         // mark orginal case relationships record to use on setting edit links below
         $caseRelationships[$key]['source'] = 'caseRel';
     }
     $caseRoles['client'] = CRM_Case_BAO_Case::getContactNames($caseID);
     // move/transform caseRoles array data to caseRelationships
     // for sorting and display
     // CRM-14466 added cid to the non-client array to avoid php notice
     foreach ($caseRoles as $id => $value) {
         if ($id != "client") {
             $rel = array();
             $rel['relation'] = $value;
             $rel['relation_type'] = $id;
             $rel['name'] = '(not assigned)';
             $rel['phone'] = '';
             $rel['email'] = '';
             $rel['source'] = 'caseRoles';
             $caseRelationships[] = $rel;
         } else {
             foreach ($value as $clientRole) {
                 $relClient = array();
                 $relClient['relation'] = 'Client';
                 $relClient['name'] = $clientRole['sort_name'];
                 $relClient['phone'] = $clientRole['phone'];
                 $relClient['email'] = $clientRole['email'];
                 $relClient['cid'] = $clientRole['contact_id'];
                 $relClient['source'] = 'contact';
                 $caseRelationships[] = $relClient;
             }
         }
     }
     // sort clientRelationships array using jquery call params
     foreach ($caseRelationships as $key => $row) {
         $sortArray[$key] = $row[$sort];
     }
     $sort_type = "SORT_" . strtoupper($sortOrder);
     array_multisort($sortArray, constant($sort_type), $caseRelationships);
     //limit rows display
     $allCaseRelationships = $caseRelationships;
     $caseRelationships = array_slice($allCaseRelationships, $offset, $rowCount, TRUE);
     // set user name, email and edit columns links
     // idx will count number of current row / needed by edit links
     $idx = 1;
     foreach ($caseRelationships as &$row) {
         // Get rid of the "<br />(Case Manager)" from label
         list($typeLabel) = explode('<', $row['relation']);
         // view user links
         if (!empty($row['cid'])) {
             $row['name'] = '<a class="view-contact" title="' . ts('View Contact') . '" href=' . CRM_Utils_System::url('civicrm/contact/view', 'action=view&reset=1&cid=' . $row['cid']) . '>' . $row['name'] . '</a>';
         }
         // email column links/icon
         if ($row['email']) {
             $row['email'] = '<a class="crm-hover-button crm-popup" href="' . CRM_Utils_System::url('civicrm/activity/email/add', 'reset=1&action=add&atype=3&cid=' . $row['cid']) . '&caseid=' . $caseID . '" title="' . ts('Send an Email') . '"><span class="icon ui-icon-mail-closed"></span></a>';
         }
         // edit links
         $row['actions'] = '';
         if ($hasAccessToAllCases) {
             $contactType = empty($row['relation_type']) ? '' : (string) CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', $row['relation_type'], 'contact_type_b');
             $contactType = $contactType == 'Contact' ? '' : $contactType;
             switch ($row['source']) {
                 case 'caseRel':
                     $row['actions'] = '<a href="#editCaseRoleDialog" title="' . ts('Reassign %1', array(1 => $typeLabel)) . '" class="crm-hover-button case-miniform" data-contact_type="' . $contactType . '" data-rel_type="' . $row['relation_type'] . '" data-rel_id="' . $row['rel_id'] . '"data-key="' . CRM_Core_Key::get('civicrm/ajax/relation') . '">' . '<span class="icon ui-icon-pencil"></span>' . '</a>' . '<a href="#deleteCaseRoleDialog" title="' . ts('Remove %1', array(1 => $typeLabel)) . '" class="crm-hover-button case-miniform" data-contact_type="' . $contactType . '" data-rel_type="' . $row['relation_type'] . '" data-key="' . CRM_Core_Key::get('civicrm/ajax/delcaserole') . '">' . '<span class="icon delete-icon"></span>' . '</a>';
                     break;
                 case 'caseRoles':
                     $row['actions'] = '<a href="#editCaseRoleDialog" title="' . ts('Assign %1', array(1 => $typeLabel)) . '" class="crm-hover-button case-miniform" data-contact_type="' . $contactType . '" data-rel_type="' . $row['relation_type'] . '" data-key="' . CRM_Core_Key::get('civicrm/ajax/relation') . '">' . '<span class="icon ui-icon-pencil"></span>' . '</a>';
                     break;
             }
         }
         $idx++;
     }
     $iFilteredTotal = $iTotal = $params['total'] = count($allCaseRelationships);
     $selectorElements = array('relation', 'name', 'phone', 'email', 'actions');
     header('Content-Type: application/json');
     echo CRM_Utils_JSON::encodeDataTableSelector($caseRelationships, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
     CRM_Utils_System::civiExit();
 }
コード例 #19
0
ファイル: Controller.php プロジェクト: ksecor/civicrm
 function key($name, $addSequence = false, $ignoreKey = false)
 {
     $config =& CRM_Core_Config::singleton();
     if ($ignoreKey || isset($config->keyDisable) && $config->keyDisable) {
         return null;
     }
     require_once 'CRM/Core/Key.php';
     $key = CRM_Utils_Array::value('qfKey', $_REQUEST, null);
     if (!$key) {
         $key = CRM_Core_Key::get($name, $addSequence);
     } else {
         $key = CRM_Core_Key::validate($key, $name, $addSequence);
     }
     if (!$key) {
         CRM_Core_Error::fatal('Could not find valid Key');
     }
     $this->_key = $key;
     return $key;
 }
コード例 #20
0
ファイル: Weight.php プロジェクト: nganivet/civicrm-core
 public static function fixOrder()
 {
     $signature = CRM_Utils_Request::retrieve('_sgn', 'String', CRM_Core_DAO::$_nullObject);
     $signer = new CRM_Utils_Signer(CRM_Core_Key::privateKey(), self::$SIGNABLE_FIELDS);
     // Validate $_GET values b/c subsequent code reads $_GET (via CRM_Utils_Request::retrieve)
     if (!$signer->validate($signature, $_GET)) {
         CRM_Core_Error::fatal('Request signature is invalid');
     }
     // Note: Ensure this list matches self::$SIGNABLE_FIELDS
     $daoName = CRM_Utils_Request::retrieve('dao', 'String', CRM_Core_DAO::$_nullObject);
     $id = CRM_Utils_Request::retrieve('id', 'Integer', CRM_Core_DAO::$_nullObject);
     $idName = CRM_Utils_Request::retrieve('idName', 'String', CRM_Core_DAO::$_nullObject);
     $url = CRM_Utils_Request::retrieve('url', 'String', CRM_Core_DAO::$_nullObject);
     $filter = CRM_Utils_Request::retrieve('filter', 'String', CRM_Core_DAO::$_nullObject);
     $src = CRM_Utils_Request::retrieve('src', 'Integer', CRM_Core_DAO::$_nullObject);
     $dst = CRM_Utils_Request::retrieve('dst', 'Integer', CRM_Core_DAO::$_nullObject);
     $dir = CRM_Utils_Request::retrieve('dir', 'String', CRM_Core_DAO::$_nullObject);
     $object = new $daoName();
     $srcWeight = CRM_Core_DAO::getFieldValue($daoName, $src, 'weight', $idName);
     $dstWeight = CRM_Core_DAO::getFieldValue($daoName, $dst, 'weight', $idName);
     if ($srcWeight == $dstWeight) {
         self::fixOrderOutput($url);
     }
     $tableName = $object->tableName();
     $query = "UPDATE {$tableName} SET weight = %1 WHERE {$idName} = %2";
     $params = array(1 => array($dstWeight, 'Integer'), 2 => array($src, 'Integer'));
     CRM_Core_DAO::executeQuery($query, $params);
     if ($dir == 'swap') {
         $params = array(1 => array($srcWeight, 'Integer'), 2 => array($dst, 'Integer'));
         CRM_Core_DAO::executeQuery($query, $params);
     } elseif ($dir == 'first') {
         // increment the rest by one
         $query = "UPDATE {$tableName} SET weight = weight + 1 WHERE {$idName} != %1 AND weight < %2";
         if ($filter) {
             $query .= " AND {$filter}";
         }
         $params = array(1 => array($src, 'Integer'), 2 => array($srcWeight, 'Integer'));
         CRM_Core_DAO::executeQuery($query, $params);
     } elseif ($dir == 'last') {
         // increment the rest by one
         $query = "UPDATE {$tableName} SET weight = weight - 1 WHERE {$idName} != %1 AND weight > %2";
         if ($filter) {
             $query .= " AND {$filter}";
         }
         $params = array(1 => array($src, 'Integer'), 2 => array($srcWeight, 'Integer'));
         CRM_Core_DAO::executeQuery($query, $params);
     }
     self::fixOrderOutput($url);
 }
コード例 #21
0
ファイル: Rule.php プロジェクト: archcidburnziso/civicrm-core
 static function qfKey($key)
 {
     return $key ? CRM_Core_Key::valid($key) : FALSE;
 }
コード例 #22
0
 /**
  * This function for building custom fields
  *
  * @param object  $qf             form object (reference)
  * @param string  $elementName    name of the custom field
  * @param boolean $inactiveNeeded
  * @param boolean $userRequired   true if required else false
  * @param boolean $search         true if used for search else false
  * @param string  $label          label for custom field
  *
  * @access public
  * @static
  */
 public static function addQuickFormElement(&$qf, $elementName, $fieldId, $inactiveNeeded = FALSE, $useRequired = TRUE, $search = FALSE, $label = NULL)
 {
     // we use $_POST directly, since we dont want to use session memory, CRM-4677
     if (isset($_POST['_qf_Relationship_refresh']) && ($_POST['_qf_Relationship_refresh'] == 'Search' || $_POST['_qf_Relationship_refresh'] == 'Search Again')) {
         $useRequired = FALSE;
     }
     $field = self::getFieldObject($fieldId);
     // Custom field HTML should indicate group+field name
     $groupName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $field->custom_group_id);
     $dataCrmCustomVal = $groupName . ':' . $field->name;
     $dataCrmCustomAttr = 'data-crm-custom="' . $dataCrmCustomVal . '"';
     $field->attributes .= $dataCrmCustomAttr;
     // Fixed for Issue CRM-2183
     if ($field->html_type == 'TextArea' && $search) {
         $field->html_type = 'Text';
     }
     if (!isset($label)) {
         $label = $field->label;
     }
     /**
      * at some point in time we might want to split the below into small functions
      **/
     switch ($field->html_type) {
         case 'Text':
             if ($field->is_search_range && $search) {
                 $qf->add('text', $elementName . '_from', $label . ' ' . ts('From'), $field->attributes);
                 $qf->add('text', $elementName . '_to', ts('To'), $field->attributes);
             } else {
                 $element =& $qf->add(strtolower($field->html_type), $elementName, $label, $field->attributes, $useRequired && !$search);
             }
             break;
         case 'TextArea':
             $attributes = $dataCrmCustomAttr;
             if ($field->note_rows) {
                 $attributes .= 'rows=' . $field->note_rows;
             } else {
                 $attributes .= 'rows=4';
             }
             if ($field->note_columns) {
                 $attributes .= ' cols=' . $field->note_columns;
             } else {
                 $attributes .= ' cols=60';
             }
             if ($field->text_length) {
                 $attributes .= ' maxlength=' . $field->text_length;
             }
             $element =& $qf->add(strtolower($field->html_type), $elementName, $label, $attributes, $useRequired && !$search);
             break;
         case 'Select Date':
             if ($field->is_search_range && $search) {
                 $qf->addDate($elementName . '_from', $label . ' - ' . ts('From'), FALSE, array('format' => $field->date_format, 'timeFormat' => $field->time_format, 'startOffset' => $field->start_date_years, 'endOffset' => $field->end_date_years, 'data-crm-custom' => $dataCrmCustomVal));
                 $qf->addDate($elementName . '_to', ts('To'), FALSE, array('format' => $field->date_format, 'timeFormat' => $field->time_format, 'startOffset' => $field->start_date_years, 'endOffset' => $field->end_date_years, 'data-crm-custom' => $dataCrmCustomVal));
             } else {
                 $required = $useRequired && !$search;
                 $qf->addDate($elementName, $label, $required, array('format' => $field->date_format, 'timeFormat' => $field->time_format, 'startOffset' => $field->start_date_years, 'endOffset' => $field->end_date_years, 'data-crm-custom' => $dataCrmCustomVal));
             }
             break;
         case 'Radio':
             $choice = array();
             if ($field->data_type != 'Boolean') {
                 $customOption =& CRM_Core_BAO_CustomOption::valuesByID($field->id, $field->option_group_id);
                 foreach ($customOption as $v => $l) {
                     $choice[] = $qf->createElement('radio', NULL, '', $l, (string) $v, $field->attributes);
                 }
                 $qf->addGroup($choice, $elementName, $label);
             } else {
                 $choice[] = $qf->createElement('radio', NULL, '', ts('Yes'), '1', $field->attributes);
                 $choice[] = $qf->createElement('radio', NULL, '', ts('No'), '0', $field->attributes);
                 $qf->addGroup($choice, $elementName, $label);
             }
             if ($useRequired && !$search) {
                 $qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required');
             }
             break;
         case 'Select':
             $selectOption =& CRM_Core_BAO_CustomOption::valuesByID($field->id, $field->option_group_id);
             $qf->add('select', $elementName, $label, array('' => ts('- select -')) + $selectOption, $useRequired && !$search, $dataCrmCustomAttr);
             break;
             //added for select multiple
         //added for select multiple
         case 'AdvMulti-Select':
             $selectOption =& CRM_Core_BAO_CustomOption::valuesByID($field->id, $field->option_group_id);
             if ($search && count($selectOption) > 1) {
                 $selectOption['CiviCRM_OP_OR'] = ts('Select to match ANY; unselect to match ALL');
             }
             $include =& $qf->addElement('advmultiselect', $elementName, $label, $selectOption, array('size' => 5, 'style' => '', 'class' => 'advmultiselect', 'data-crm-custom' => $dataCrmCustomVal));
             $include->setButtonAttributes('add', array('value' => ts('Add >>')));
             $include->setButtonAttributes('remove', array('value' => ts('<< Remove')));
             if ($useRequired && !$search) {
                 $qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required');
             }
             break;
         case 'Multi-Select':
             $selectOption =& CRM_Core_BAO_CustomOption::valuesByID($field->id, $field->option_group_id);
             if ($search && count($selectOption) > 1) {
                 $selectOption['CiviCRM_OP_OR'] = ts('Select to match ANY; unselect to match ALL');
             }
             $qf->addElement('select', $elementName, $label, $selectOption, array('size' => '5', 'multiple', 'data-crm-custom' => $dataCrmCustomVal));
             if ($useRequired && !$search) {
                 $qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required');
             }
             break;
         case 'CheckBox':
             $customOption = CRM_Core_BAO_CustomOption::valuesByID($field->id, $field->option_group_id);
             $check = array();
             foreach ($customOption as $v => $l) {
                 $check[] =& $qf->addElement('advcheckbox', $v, NULL, $l, array('data-crm-custom' => $dataCrmCustomVal));
             }
             if ($search && count($check) > 1) {
                 $check[] =& $qf->addElement('advcheckbox', 'CiviCRM_OP_OR', NULL, ts('Check to match ANY; uncheck to match ALL'), array('data-crm-custom' => $dataCrmCustomVal));
             }
             $qf->addGroup($check, $elementName, $label);
             if ($useRequired && !$search) {
                 $qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required');
             }
             break;
         case 'File':
             // we should not build upload file in search mode
             if ($search) {
                 return;
             }
             $qf->add(strtolower($field->html_type), $elementName, $label, $field->attributes, $useRequired && !$search);
             $qf->addUploadElement($elementName);
             break;
         case 'Select State/Province':
             //Add State
             $stateOption = array('' => ts('- select -')) + CRM_Core_PseudoConstant::stateProvince();
             $qf->add('select', $elementName, $label, $stateOption, $useRequired && !$search, $dataCrmCustomAttr);
             break;
         case 'Multi-Select State/Province':
             //Add Multi-select State/Province
             $stateOption = CRM_Core_PseudoConstant::stateProvince();
             $qf->addElement('select', $elementName, $label, $stateOption, array('size' => '5', 'multiple', 'data-crm-custom' => $dataCrmCustomVal));
             if ($useRequired && !$search) {
                 $qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required');
             }
             break;
         case 'Select Country':
             //Add Country
             $countryOption = array('' => ts('- select -')) + CRM_Core_PseudoConstant::country();
             $qf->add('select', $elementName, $label, $countryOption, $useRequired && !$search, $dataCrmCustomAttr);
             break;
         case 'Multi-Select Country':
             //Add Country
             $countryOption = CRM_Core_PseudoConstant::country();
             $qf->addElement('select', $elementName, $label, $countryOption, array('size' => '5', 'multiple', 'data-crm-custom' => $dataCrmCustomVal));
             if ($useRequired && !$search) {
                 $qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required');
             }
             break;
         case 'RichTextEditor':
             $attributes = array('rows' => $field->note_rows, 'cols' => $field->note_columns, 'data-crm-custom' => $dataCrmCustomVal);
             if ($field->text_length) {
                 $attributes['maxlength'] = $field->text_length;
             }
             $qf->addWysiwyg($elementName, $label, $attributes, $search);
             break;
         case 'Autocomplete-Select':
             $qf->add('text', $elementName, $label, $field->attributes, $useRequired && !$search);
             $hiddenEleName = $elementName . '_id';
             if (substr($elementName, -1) == ']') {
                 $hiddenEleName = substr($elementName, 0, -1) . '_id]';
             }
             $qf->addElement('hidden', $hiddenEleName, '', array('id' => str_replace(array(']', '['), array('', '_'), $hiddenEleName)));
             static $customUrls = array();
             if ($field->data_type == 'ContactReference') {
                 //$urlParams = "className=CRM_Contact_Page_AJAX&fnName=getContactList&json=1&reset=1&context=customfield&id={$field->id}";
                 $urlParams = "context=customfield&id={$field->id}";
                 $customUrls[$elementName] = CRM_Utils_System::url('civicrm/ajax/contactref', $urlParams, FALSE, NULL, FALSE);
                 $actualElementValue = $qf->getSubmitValue($hiddenEleName);
                 $qf->addRule($elementName, ts('Select a valid contact for %1.', array(1 => $label)), 'validContact', $actualElementValue);
             } else {
                 $signer = new CRM_Utils_Signer(CRM_Core_Key::privateKey(), array('cfid', 'ogid', 'sigts'));
                 $signParams = array('reset' => 1, 'sigts' => CRM_Utils_Time::getTimeRaw(), 'ogid' => $field->option_group_id, 'cfid' => $field->id);
                 $signParams['sig'] = $signer->sign($signParams);
                 $customUrls[$elementName] = CRM_Utils_System::url('civicrm/ajax/auto', $signParams, FALSE, NULL, FALSE);
                 $qf->addRule($elementName, ts('Select a valid value for %1.', array(1 => $label)), 'autocomplete', array('fieldID' => $field->id, 'optionGroupID' => $field->option_group_id));
             }
             $qf->assign('customUrls', $customUrls);
             break;
     }
     switch ($field->data_type) {
         case 'Int':
             // integers will have numeric rule applied to them.
             if ($field->is_search_range && $search) {
                 $qf->addRule($elementName . '_from', ts('%1 From must be an integer (whole number).', array(1 => $label)), 'integer');
                 $qf->addRule($elementName . '_to', ts('%1 To must be an integer (whole number).', array(1 => $label)), 'integer');
             } else {
                 $qf->addRule($elementName, ts('%1 must be an integer (whole number).', array(1 => $label)), 'integer');
             }
             break;
         case 'Float':
             if ($field->is_search_range && $search) {
                 $qf->addRule($elementName . '_from', ts('%1 From must be a number (with or without decimal point).', array(1 => $label)), 'numeric');
                 $qf->addRule($elementName . '_to', ts('%1 To must be a number (with or without decimal point).', array(1 => $label)), 'numeric');
             } else {
                 $qf->addRule($elementName, ts('%1 must be a number (with or without decimal point).', array(1 => $label)), 'numeric');
             }
             break;
         case 'Money':
             if ($field->is_search_range && $search) {
                 $qf->addRule($elementName . '_from', ts('%1 From must in proper money format. (decimal point/comma/space is allowed).', array(1 => $label)), 'money');
                 $qf->addRule($elementName . '_to', ts('%1 To must in proper money format. (decimal point/comma/space is allowed).', array(1 => $label)), 'money');
             } else {
                 $qf->addRule($elementName, ts('%1 must be in proper money format. (decimal point/comma/space is allowed).', array(1 => $label)), 'money');
             }
             break;
         case 'Link':
             $qf->add('text', $elementName, $label, array('onfocus' => "if (!this.value) {  this.value='http://';} else return false", 'onblur' => "if ( this.value == 'http://') {  this.value='';} else return false", 'data-crm-custom' => $dataCrmCustomVal), $useRequired && !$search);
             $qf->addRule($elementName, ts('Enter a valid Website.'), 'wikiURL');
             break;
     }
     if ($field->is_view && !$search) {
         $qf->freeze($elementName);
     }
 }
コード例 #23
0
ファイル: File.php プロジェクト: hguru/224Civi
 /**
  * function to delete a file attachment from an entity table / entity ID
  *
  * @static
  * @access public
  */
 static function deleteAttachment()
 {
     $params = array();
     $params['entityTable'] = CRM_Utils_Request::retrieve('entityTable', 'String', CRM_Core_DAO::$_nullObject, TRUE);
     $params['entityID'] = CRM_Utils_Request::retrieve('entityID', 'Positive', CRM_Core_DAO::$_nullObject, TRUE);
     $params['fileID'] = CRM_Utils_Request::retrieve('fileID', 'Positive', CRM_Core_DAO::$_nullObject, TRUE);
     $signature = CRM_Utils_Request::retrieve('_sgn', 'String', CRM_Core_DAO::$_nullObject, TRUE);
     $signer = new CRM_Utils_Signer(CRM_Core_Key::privateKey(), self::$_signableFields);
     if (!$signer->validate($signature, $params)) {
         CRM_Core_Error::fatal('Request signature is invalid');
     }
     CRM_Core_BAO_File::deleteEntityFile($params['entityTable'], $params['entityID'], NULL, $params['fileID']);
 }
コード例 #24
0
ファイル: Export.php プロジェクト: bhirsch/voipdev
 /**
  * handle the export case. this is a hack, so please fix soon
  *
  * @param $args array this array contains the arguments of the url
  *
  * @static
  * @access public
  */
 static function invoke($args)
 {
     // FIXME:  2005-06-22 15:17:33 by Brian McFee <*****@*****.**>
     // This function is a dirty, dirty hack.  It should live in its own
     // file.
     $session =& CRM_Core_Session::singleton();
     $type = $_GET['type'];
     if ($type == 1) {
         $varName = 'errors';
         $saveFileName = 'Import_Errors.csv';
     } else {
         if ($type == 2) {
             $varName = 'conflicts';
             $saveFileName = 'Import_Conflicts.csv';
         } else {
             if ($type == 3) {
                 $varName = 'duplicates';
                 $saveFileName = 'Import_Duplicates.csv';
             } else {
                 if ($type == 4) {
                     $varName = 'mismatch';
                     $saveFileName = 'Import_Mismatch.csv';
                 } else {
                     if ($type == 5) {
                         $varName = 'pledgePaymentErrors';
                         $saveFileName = 'Import_Pledge_Payment_Errors.csv';
                     } else {
                         if ($type == 6) {
                             $varName = 'softCreditErrors';
                             $saveFileName = 'Import_Soft_Credit_Errors.csv';
                         } else {
                             /* FIXME we should have an error here */
                             return;
                         }
                     }
                 }
             }
         }
     }
     // FIXME: a hack until we have common import
     // mechanisms for contacts and contributions
     $realm = CRM_Utils_Array::value('realm', $_GET);
     if ($realm == 'contribution') {
         $controller = 'CRM_Contribute_Import_Controller';
     } else {
         if ($realm == 'membership') {
             $controller = 'CRM_Member_Import_Controller';
         } else {
             if ($realm == 'event') {
                 $controller = 'CRM_Event_Import_Controller';
             } else {
                 if ($realm == 'activity') {
                     $controller = 'CRM_Activity_Import_Controller';
                 } else {
                     $controller = 'CRM_Import_Controller';
                 }
             }
         }
     }
     require_once 'CRM/Core/Key.php';
     $qfKey = CRM_Core_Key::get($controller);
     $fileName = $session->get($varName . 'FileName', "{$controller}_{$qfKey}");
     $config =& CRM_Core_Config::singleton();
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     header('Content-Description: File Transfer');
     header('Content-Type: text/csv');
     header('Content-Length: ' . filesize($fileName));
     header('Content-Disposition: attachment; filename=' . $saveFileName);
     readfile($fileName);
     exit;
 }
コード例 #25
0
ファイル: Tab.php プロジェクト: archcidburnziso/civicrm-core
 function setContext()
 {
     $qfKey = CRM_Utils_Request::retrieve('key', 'String', $this);
     $context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'search');
     $compContext = CRM_Utils_Request::retrieve('compContext', 'String', $this);
     //swap the context.
     if ($context == 'search' && $compContext) {
         $context = $compContext;
     } else {
         $compContext = NULL;
     }
     // make sure we dont get tricked with a bad key
     // so check format
     if (!CRM_Core_Key::valid($qfKey)) {
         $qfKey = NULL;
     }
     $session = CRM_Core_Session::singleton();
     switch ($context) {
         case 'user':
             $url = CRM_Utils_System::url('civicrm/user', 'reset=1');
             break;
         case 'dashboard':
             $url = CRM_Utils_System::url('civicrm/contribute', 'reset=1');
             break;
         case 'pledgeDashboard':
             $url = CRM_Utils_System::url('civicrm/pledge', 'reset=1');
             break;
         case 'contribution':
             $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&force=1&cid={$this->_contactId}&selectedChild=contribute");
             break;
         case 'search':
         case 'advanced':
             $extraParams = "force=1";
             if ($qfKey) {
                 $extraParams .= "&qfKey={$qfKey}";
             }
             $this->assign('searchKey', $qfKey);
             if ($context == 'advanced') {
                 $url = CRM_Utils_System::url('civicrm/contact/search/advanced', $extraParams);
             } else {
                 $url = CRM_Utils_System::url('civicrm/contribute/search', $extraParams);
             }
             break;
         case 'home':
             $url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
             break;
         case 'activity':
             $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&force=1&cid={$this->_contactId}&selectedChild=activity");
             break;
         case 'member':
         case 'membership':
             $componentId = CRM_Utils_Request::retrieve('compId', 'Positive', $this);
             $componentAction = CRM_Utils_Request::retrieve('compAction', 'Integer', $this);
             $context = 'membership';
             $searchKey = NULL;
             if ($compContext) {
                 $context = 'search';
                 if ($qfKey) {
                     $searchKey = "&key={$qfKey}";
                 }
                 $compContext = "&compContext={$compContext}";
             }
             if ($componentAction & CRM_Core_Action::VIEW) {
                 $action = 'view';
             } else {
                 $action = 'update';
             }
             $url = CRM_Utils_System::url('civicrm/contact/view/membership', "reset=1&action={$action}&id={$componentId}&cid={$this->_contactId}&context={$context}&selectedChild=member{$searchKey}{$compContext}");
             break;
         case 'participant':
             $componentId = CRM_Utils_Request::retrieve('compId', 'Positive', $this);
             $componentAction = CRM_Utils_Request::retrieve('compAction', 'Integer', $this);
             $context = 'participant';
             $searchKey = NULL;
             if ($compContext) {
                 $context = 'search';
                 if ($qfKey) {
                     $searchKey = "&key={$qfKey}";
                 }
                 $compContext = "&compContext={$compContext}";
             }
             if ($componentAction == CRM_Core_Action::VIEW) {
                 $action = 'view';
             } else {
                 $action = 'update';
             }
             $url = CRM_Utils_System::url('civicrm/contact/view/participant', "reset=1&action={$action}&id={$componentId}&cid={$this->_contactId}&context={$context}&selectedChild=event{$searchKey}{$compContext}");
             break;
         case 'pledge':
             $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&force=1&cid={$this->_contactId}&selectedChild=pledge");
             break;
         case 'standalone':
             $url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
             break;
         case 'fulltext':
             $keyName = '&qfKey';
             $urlParams = 'force=1';
             $urlString = 'civicrm/contact/search/custom';
             if ($this->_action == CRM_Core_Action::UPDATE) {
                 if ($this->_contactId) {
                     $urlParams .= '&cid=' . $this->_contactId;
                 }
                 $keyName = '&key';
                 $urlParams .= '&context=fulltext&action=view';
                 $urlString = 'civicrm/contact/view/contribution';
             }
             if ($qfKey) {
                 $urlParams .= "{$keyName}={$qfKey}";
             }
             $this->assign('searchKey', $qfKey);
             $url = CRM_Utils_System::url($urlString, $urlParams);
             break;
         default:
             $cid = NULL;
             if ($this->_contactId) {
                 $cid = '&cid=' . $this->_contactId;
             }
             $url = CRM_Utils_System::url('civicrm/contribute/search', 'reset=1&force=1' . $cid);
             break;
     }
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext($url);
 }
コード例 #26
0
ファイル: Rule.php プロジェクト: hampelm/Ginsberg-CiviDemo
 static function qfKey($key)
 {
     require_once 'CRM/Core/Key.php';
     return $key ? CRM_Core_Key::valid($key) : false;
 }
コード例 #27
0
ファイル: Stat.php プロジェクト: WeMoveEU/speakcivi
 private static function setData($description)
 {
     return array(self::COL_SID => CRM_Core_Key::sessionID(), self::COL_DESC => $description, self::COL_SEC => microtime(true));
 }
コード例 #28
0
 function key($name, $addSequence = false, $ignoreKey = false)
 {
     $config = CRM_Core_Config::singleton();
     if ($ignoreKey || isset($config->keyDisable) && $config->keyDisable) {
         return null;
     }
     require_once 'CRM/Core/Key.php';
     $key = CRM_Utils_Array::value('qfKey', $_REQUEST, null);
     if (!$key) {
         $key = CRM_Core_Key::get($name, $addSequence);
     } else {
         $key = CRM_Core_Key::validate($key, $name, $addSequence);
     }
     if (!$key) {
         $msg = ts('We can\'t load the requested web page. This page requires cookies to be enabled in your browser settings. Please check this setting and enable cookies (if they are not enabled). Then try again. If this error persists, contact the site adminstrator for assistance.') . '<br /><br />' . ts('Site Administrators: This error may indicate that users are accessing this page using a domain or URL other than the configured Base URL. EXAMPLE: Base URL is http://example.org, but some users are accessing the page via http://www.example.org or a domain alias like http://myotherexample.org.') . '<br /><br />' . ts('Error type: Could not find a valid session key.');
         CRM_Core_Error::fatal($msg);
     }
     $this->_key = $key;
     return $key;
 }