当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Utils_String::munge方法代码示例

本文整理汇总了PHP中CRM_Utils_String::munge方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_String::munge方法的具体用法?PHP CRM_Utils_String::munge怎么用?PHP CRM_Utils_String::munge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Utils_String的用法示例。


在下文中一共展示了CRM_Utils_String::munge方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create

 /**
  * Takes an associative array and creates a price set object.
  *
  * @param array $params
  *   (reference) an assoc array of name/value pairs.
  *
  * @return CRM_Price_DAO_PriceSet
  */
 public static function create(&$params)
 {
     if (empty($params['id']) && empty($params['name'])) {
         $params['name'] = CRM_Utils_String::munge($params['title'], '_', 242);
     }
     $priceSetID = NULL;
     $validatePriceSet = TRUE;
     if (!empty($params['extends']) && is_array($params['extends'])) {
         if (!array_key_exists(CRM_Core_Component::getComponentID('CiviEvent'), $params['extends']) || !array_key_exists(CRM_Core_Component::getComponentID('CiviMember'), $params['extends'])) {
             $validatePriceSet = FALSE;
         }
         $params['extends'] = CRM_Utils_Array::implodePadded($params['extends']);
     } else {
         $priceSetID = CRM_Utils_Array::value('id', $params);
     }
     // CRM-16189
     if ($validatePriceSet && !empty($params['financial_type_id'])) {
         CRM_Financial_BAO_FinancialAccount::validateFinancialType($params['financial_type_id'], $priceSetID);
     }
     $priceSetBAO = new CRM_Price_BAO_PriceSet();
     $priceSetBAO->copyValues($params);
     if (self::eventPriceSetDomainID()) {
         $priceSetBAO->domain_id = CRM_Core_Config::domainID();
     }
     return $priceSetBAO->save();
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:34,代码来源:PriceSet.php

示例2: retrieve

 function retrieve($caseType)
 {
     require_once 'CRM/Utils/String.php';
     require_once 'CRM/Utils/Array.php';
     // trim all spaces from $caseType
     $caseType = str_replace('_', ' ', $caseType);
     $caseType = CRM_Utils_String::munge(ucwords($caseType), '', 0);
     if (!CRM_Utils_Array::value($caseType, self::$_xml)) {
         if (!self::$_xml) {
             self::$_xml = array();
         }
         // first check custom templates directory
         $fileName = null;
         $config = CRM_Core_Config::singleton();
         if (isset($config->customTemplateDir) && $config->customTemplateDir) {
             // check if the file exists in the custom templates directory
             $fileName = implode(DIRECTORY_SEPARATOR, array($config->customTemplateDir, 'CRM', 'Case', 'xml', 'configuration', "{$caseType}.xml"));
         }
         if (!$fileName || !file_exists($fileName)) {
             // check if file exists locally
             $fileName = implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), 'xml', 'configuration', "{$caseType}.xml"));
             if (!file_exists($fileName)) {
                 return false;
             }
         }
         // read xml file
         $dom = DomDocument::load($fileName);
         $dom->xinclude();
         self::$_xml[$caseType] = simplexml_import_dom($dom);
     }
     return self::$_xml[$caseType];
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:32,代码来源:XMLProcessor.php

示例3: formRule

 static function formRule($fields)
 {
     $errors = array();
     require_once 'api/api.php';
     $apiRequest = array();
     $apiRequest['entity'] = CRM_Utils_String::munge($fields['api_entity']);
     $apiRequest['action'] = CRM_Utils_String::munge($fields['api_action']);
     $apiRequest['version'] = substr($fields['api_prefix'], -1);
     // ie. civicrm_api3
     $apiRequest += _civicrm_api_resolve($apiRequest);
     // look up function, file, is_generic
     if (!$apiRequest['function']) {
         $errors['api_action'] = ts('Given API command is not defined.');
     }
     // CRM-9868- don't allow Enabled (is_active) for jobs that should never be run automatically via execute action or runjobs url
     if (($fields['api_action'] == 'process_membership_reminder_date' || $fields['api_action'] == 'update_greeting') && CRM_Utils_Array::value('is_active', $fields) == 1) {
         // pass "wiki" as 6th param to docURL2 if you are linking to a page in wiki.civicrm.org
         $docLink = CRM_Utils_System::docURL2("Managing Scheduled Jobs", NULL, NULL, NULL, NULL, "wiki");
         $errors['is_active'] = ts('You can not save this Scheduled Job as Active with the specified api action (%2). That action should not be run regularly - it should only be run manually for special conditions. %1', array(1 => $docLink, 2 => $fields['api_action']));
     }
     if (!empty($errors)) {
         return $errors;
     }
     return empty($errors) ? TRUE : $errors;
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:25,代码来源:Job.php

示例4: check

 /**
  * given a permission string, check for access requirements
  *
  * @param string $str the permission to check
  *
  * @return boolean true if yes, else false
  * @access public
  */
 function check($str)
 {
     // Generic cms 'administer users' role tranlates to 'administrator' WordPress role
     $str = $this->translatePermission($str, 'WordPress', array('administer users' => 'administrator'));
     if ($str == CRM_Core_Permission::ALWAYS_DENY_PERMISSION) {
         return FALSE;
     }
     if ($str == CRM_Core_Permission::ALWAYS_ALLOW_PERMISSION) {
         return TRUE;
     }
     // for administrators give them all permissions
     if (!function_exists('current_user_can')) {
         return TRUE;
     }
     if (current_user_can('super admin') || current_user_can('administrator')) {
         return TRUE;
     }
     // Make string lowercase and convert spaces into underscore
     $str = CRM_Utils_String::munge(strtolower($str));
     if (is_user_logged_in()) {
         // Check whether the logged in user has the capabilitity
         if (current_user_can($str)) {
             return TRUE;
         }
     } else {
         //check the capabilities of Anonymous user)
         $roleObj = new WP_Roles();
         if ($roleObj->get_role('anonymous_user') != NULL && array_key_exists($str, $roleObj->get_role('anonymous_user')->capabilities)) {
             return TRUE;
         }
     }
     return FALSE;
 }
开发者ID:hguru,项目名称:224Civi,代码行数:41,代码来源:WordPress.php

示例5: mungeCaseType

 public static function mungeCaseType($caseType)
 {
     // trim all spaces from $caseType
     $caseType = str_replace('_', ' ', $caseType);
     $caseType = CRM_Utils_String::munge(ucwords($caseType), '', 0);
     return $caseType;
 }
开发者ID:hguru,项目名称:224Civi,代码行数:7,代码来源:XMLProcessor.php

示例6: hrjobcontract_civicrm_uninstall

/**
 * Implementation of hook_civicrm_uninstall
 *
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_uninstall
 */
function hrjobcontract_civicrm_uninstall()
{
    $subTypeInfo = CRM_Contact_BAO_ContactType::subTypeInfo('Organization');
    $sub_type_name = array('Health Insurance Provider', 'Life Insurance Provider');
    foreach ($sub_type_name as $sub_type_name) {
        $subTypeName = ucfirst(CRM_Utils_String::munge($sub_type_name));
        $orid = array_key_exists($subTypeName, $subTypeInfo);
        if ($orid) {
            $id = $subTypeInfo[$subTypeName]['id'];
            CRM_Contact_BAO_ContactType::del($id);
        }
    }
    $jobContractMenu = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'job_contracts', 'id', 'name');
    if (!empty($jobContractMenu)) {
        CRM_Core_BAO_Navigation::processDelete($jobContractMenu);
    }
    CRM_Core_DAO::executeQuery("DELETE FROM civicrm_navigation WHERE name IN ('job_contracts', 'import_export_job_contracts', 'jobImport', 'hoursType', 'pay_scale','hours_location', 'hrjc_contact_type', 'hrjc_location', 'hrjc_pay_cycle', 'hrjc_benefit_name', 'hrjc_benefit_type', 'hrjc_deduction_name', 'hrjc_deduction_type', 'hrjc_health_provider', 'hrjc_life_provider', 'hrjc_pension_type', 'hrjc_revision_change_reason')");
    CRM_Core_BAO_Navigation::resetNavigation();
    //delete custom groups and field
    $customGroup = civicrm_api3('CustomGroup', 'get', array('name' => "HRJobContract_Summary"));
    $customGroupData = CRM_Utils_Array::first($customGroup['values']);
    if (!empty($customGroupData['id'])) {
        civicrm_api3('CustomGroup', 'delete', array('id' => $customGroupData['id']));
    }
    $customGroup = civicrm_api3('CustomGroup', 'get', array('name' => "HRJobContract_Summary"));
    $customGroupData = CRM_Utils_Array::first($customGroup['values']);
    if (!empty($customGroupData['id'])) {
        civicrm_api3('CustomGroup', 'delete', array('id' => $customGroupData['id']));
    }
    //delete all option group and values
    CRM_Core_DAO::executeQuery("DELETE FROM civicrm_option_group WHERE name IN ('job_contracts', 'hoursType', 'pay_scale','hours_location', 'hrjc_contact_type', 'hrjc_location', 'hrjc_pay_cycle', 'hrjc_benefit_name', 'hrjc_benefit_type', 'hrjc_deduction_name', 'hrjc_deduction_type', 'hrjc_health_provider', 'hrjc_life_provider', 'hrjc_pension_type', 'hrjc_revision_change_reason', 'hrjc_contract_type', 'hrjc_level_type', 'hrjc_department', 'hrjc_hours_type', 'hrjc_pay_grade', 'hrjc_health_provider', 'hrjc_life_provider', 'hrjc_location', 'hrjc_pension_type', 'hrjc_region', 'hrjc_pay_scale')");
    //delete job contract files to entities relations
    CRM_Core_DAO::executeQuery("DELETE FROM civicrm_entity_file WHERE entity_table LIKE 'civicrm_hrjobcontract_%'");
    return _hrjobcontract_civix_civicrm_uninstall();
}
开发者ID:JoeMurray,项目名称:civihr,代码行数:40,代码来源:hrjobcontract.php

示例7: civicrm_api3_generic_setValue

/**
 * params must contain at least id=xx & {one of the fields from getfields}=value
 */
function civicrm_api3_generic_setValue($apiRequest)
{
    $entity = $apiRequest['entity'];
    $params = $apiRequest['params'];
    // we can't use _spec, doesn't work with generic
    civicrm_api3_verify_mandatory($params, NULL, array('id', 'field', 'value'));
    $id = $params['id'];
    if (!is_numeric($id)) {
        return civicrm_api3_create_error(ts('Please enter a number'), array('error_code' => 'NaN', 'field' => "id"));
    }
    $field = CRM_Utils_String::munge($params['field']);
    $value = $params['value'];
    $fields = civicrm_api($entity, 'getFields', array("version" => 3, "sequential"));
    // getfields error, shouldn't happen.
    if ($fields['is_error']) {
        return $fields;
    }
    $fields = $fields['values'];
    if (!array_key_exists($field, $fields)) {
        return civicrm_api3_create_error("Param 'field' ({$field}) is invalid. must be an existing field", array("error_code" => "invalid_field", "fields" => array_keys($fields)));
    }
    $def = $fields[$field];
    if (array_key_exists('required', $def) && empty($value)) {
        return civicrm_api3_create_error(ts("This can't be empty, please provide a value"), array("error_code" => "required", "field" => $field));
    }
    switch ($def['type']) {
        case 1:
            //int
            if (!is_numeric($value)) {
                return civicrm_api3_create_error("Param '{$field}' must be a number", array('error_code' => 'NaN'));
            }
        case 2:
            //string
            require_once "CRM/Utils/Rule.php";
            if (!CRM_Utils_Rule::xssString($value)) {
                return civicrm_api3_create_error(ts('Illegal characters in input (potential scripting attack)'), array('error_code' => 'XSS'));
            }
            if (array_key_exists('maxlength', $def)) {
                $value = substr($value, 0, $def['maxlength']);
            }
            break;
        case 16:
            //boolean
            $value = (bool) $value;
            break;
        case 4:
            //date
        //date
        default:
            return civicrm_api3_create_error("Param '{$field}' is of a type not managed yet. Join the API team and help us implement it", array('error_code' => 'NOT_IMPLEMENTED'));
    }
    if (CRM_Core_DAO::setFieldValue(_civicrm_api3_get_DAO($entity), $id, $field, $value)) {
        $entity = array('id' => $id, $field => $value);
        CRM_Utils_Hook::post('edit', $entity, $id, $entity);
        return civicrm_api3_create_success($entity);
    } else {
        return civicrm_api3_create_error("error assigning {$field}={$value} for {$entity} (id={$id})");
    }
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:62,代码来源:Setvalue.php

示例8: civicrm_api3_action_schedule_create

/**
 * Create a new ActionSchedule.
 *
 * @param array $params
 *
 * @return array
 */
function civicrm_api3_action_schedule_create($params)
{
    civicrm_api3_verify_one_mandatory($params, NULL, array('start_action_date', 'absolute_date'));
    if (!array_key_exists('name', $params) && !array_key_exists('id', $params)) {
        $params['name'] = CRM_Utils_String::munge($params['title']);
    }
    return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'ActionSchedule');
}
开发者ID:utkarshsharma,项目名称:civicrm-core,代码行数:15,代码来源:ActionSchedule.php

示例9: titleToVar

 /**
  * Convert a display name into a potential variable
  * name that we could use in forms/code
  * 
  * @param  name    Name of the string
  * @return string  An equivalent variable name
  *
  * @access public
  * @return string (or null)
  * @static
  */
 function titleToVar($title)
 {
     if (!CRM_Utils_Rule::title($title)) {
         return null;
     }
     $variable = CRM_Utils_String::munge($title);
     if (CRM_Utils_Rule::variable($variable)) {
         return $variable;
     }
     return null;
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:22,代码来源:String.php

示例10: civicrm_api3_contact_type_create

/**
 * create/update contact_type
 *
 * This API is used to create new contact_type or update any of the existing
 * In case of updating existing contact_type, id of that particular contact_type must
 * be in $params array.
 *
 * @param array $params  (referance) Associative array of property
 *                       name/value pairs to insert in new 'contact_type'
 *
 * @return array   contact_type array
 *
 * @access public
 */
function civicrm_api3_contact_type_create($params)
{
    civicrm_api3_verify_mandatory($params, _civicrm_api3_get_DAO(__FUNCTION__), array('name', 'parent_id'));
    if (!array_key_exists('label', $params)) {
        $params['label'] = $params['name'];
    }
    if (!array_key_exists('is_active', $params)) {
        $params['is_active'] = TRUE;
    }
    $params['name'] = CRM_Utils_String::munge($params['name']);
    return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
开发者ID:hguru,项目名称:224Civi,代码行数:26,代码来源:ContactType.php

示例11: create

 /**
  * takes an associative array and creates a price set object
  *
  * @param array $params (reference) an assoc array of name/value pairs
  *
  * @return object CRM_Price_DAO_PriceSet object
  * @access public
  * @static
  */
 static function create(&$params)
 {
     if (empty($params['id']) && empty($params['name'])) {
         $params['name'] = CRM_Utils_String::munge($params['title'], '_', 242);
     }
     $priceSetBAO = new CRM_Price_BAO_PriceSet();
     $priceSetBAO->copyValues($params);
     if (self::eventPriceSetDomainID()) {
         $priceSetBAO->domain_id = CRM_Core_Config::domainID();
     }
     return $priceSetBAO->save();
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:21,代码来源:PriceSet.php

示例12: createGroup

 function createGroup($group, $extends = null, $isMultiple = false)
 {
     if (empty($group)) {
         $group = array('title' => 'Test_Group', 'name' => 'test_group', 'extends' => $extends, 'style' => 'Inline', 'is_multiple' => $isMultiple, 'is_active' => 1);
     }
     require_once 'CRM/Core/BAO/CustomGroup.php';
     require_once 'CRM/Utils/String.php';
     $customGroupBAO =& new CRM_Core_BAO_CustomGroup();
     $customGroupBAO->copyValues($group);
     $customGroup = $customGroupBAO->save();
     $customGroup->table_name = "civicrm_value_" . strtolower(CRM_Utils_String::munge($group['title'], '_', 32));
     $customGroup->table_name = $customGroup->table_name . '_' . $customGroup->id;
     $customGroup = $customGroupBAO->save();
     $customTable = CRM_Core_BAO_CustomGroup::createTable($customGroup);
     return $customGroup;
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:16,代码来源:Custom.php

示例13: HTML_QuickForm_radio

 /**
  * Class constructor
  * 
  * @param     string    Input field name attribute
  * @param     mixed     Label(s) for a field
  * @param     string    Text to display near the radio
  * @param     string    Input field value
  * @param     mixed     Either a typical HTML attribute string or an associative array
  * @since     1.0
  * @access    public
  * @return    void
  */
 function HTML_QuickForm_radio($elementName = null, $elementLabel = null, $text = null, $value = null, $attributes = null)
 {
     $this->HTML_QuickForm_element($elementName, $elementLabel, $attributes);
     if (isset($value)) {
         $this->setValue($value);
     }
     $this->_persistantFreeze = true;
     $this->setType('radio');
     $this->_text = $text;
     // $this->_generateId();
     if (!$this->getAttribute('id')) {
         //hack to add 'id' for checkbox
         static $idTextStr = 1;
         $this->updateAttributes(array('id' => CRM_Utils_String::munge("CIVICRM_QFID_{$value}_{$idTextStr}")));
         $idTextStr++;
     }
 }
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:29,代码来源:radio.php

示例14: formRule

 static function formRule($fields)
 {
     $errors = array();
     require_once 'api/api.php';
     $apiRequest = array();
     $apiRequest['entity'] = CRM_Utils_String::munge($fields['api_entity']);
     $apiRequest['action'] = CRM_Utils_String::munge($fields['api_action']);
     $apiRequest['version'] = 3;
     $apiRequest += _civicrm_api_resolve($apiRequest);
     // look up function, file, is_generic
     if (!$apiRequest['function']) {
         $errors['api_action'] = ts('Given API command is not defined.');
     }
     if (!empty($errors)) {
         return $errors;
     }
     return empty($errors) ? TRUE : $errors;
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:18,代码来源:Job.php

示例15: translateJoomlaPermission

 /**
  * @param string $name e.g. "administer CiviCRM", "cms:access user record", "Drupal:administer content", "Joomla:example.action:com_some_asset"
  * @return ALWAYS_DENY_PERMISSION|ALWAYS_ALLOW_PERMISSION|array(0 => $joomlaAction, 1 => $joomlaAsset)
  */
 function translateJoomlaPermission($perm)
 {
     if ($perm === CRM_Core_Permission::ALWAYS_DENY_PERMISSION || $perm === CRM_Core_Permission::ALWAYS_ALLOW_PERMISSION) {
         return $perm;
     }
     list($civiPrefix, $name) = CRM_Utils_String::parsePrefix(':', $perm, NULL);
     switch ($civiPrefix) {
         case 'Joomla':
             return explode(':', $name);
         case 'cms':
             // FIXME: This needn't be DENY, but we don't currently have any translations.
             return CRM_Core_Permission::ALWAYS_DENY_PERMISSION;
         case NULL:
             return array('civicrm.' . CRM_Utils_String::munge(strtolower($name)), 'com_civicrm');
         default:
             return CRM_Core_Permission::ALWAYS_DENY_PERMISSION;
     }
 }
开发者ID:hguru,项目名称:224Civi,代码行数:22,代码来源:Joomla.php


注:本文中的CRM_Utils_String::munge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。