Пример #1
0
 /**
  * @param string $caseType
  * @return SimpleXMLElement|FALSE
  */
 public function retrieve($caseType)
 {
     // check if xml definition is defined in db
     $definition = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_CaseType', $caseType, 'definition', 'name');
     if (!empty($definition)) {
         list($xml, $error) = CRM_Utils_XML::parseString($definition);
         if (!$xml) {
             throw new CRM_Core_Exception("Failed to parse CaseType XML: {$error}");
         }
         return $xml;
     }
     // TODO In 4.6 or 5.0, remove support for weird machine-names
     //if (!CRM_Case_BAO_CaseType::isValidName($caseType)) {
     //  // perhaps caller provider a the label instead of the name?
     //  throw new CRM_Core_Exception("Cannot load caseType with malformed name [$caseType]");
     //}
     if (!CRM_Utils_Array::value($caseType, $this->xml)) {
         $fileXml = $this->retrieveFile($caseType);
         if ($fileXml) {
             $this->xml[$caseType] = $fileXml;
         } else {
             return FALSE;
         }
     }
     return $this->xml[$caseType];
 }
Пример #2
0
 /**
  * Copy attributes from an XML document to $this
  *
  * @param SimpleXMLElement $info
  * @return void
  */
 public function parse($info)
 {
     $this->key = (string) $info->attributes()->key;
     $this->type = (string) $info->attributes()->type;
     $this->file = (string) $info->file;
     $this->label = (string) $info->name;
     // Convert first level variables to CRM_Core_Extension properties
     // and deeper into arrays. An exception for URLS section, since
     // we want them in special format.
     foreach ($info as $attr => $val) {
         if (count($val->children()) == 0) {
             $this->{$attr} = (string) $val;
         } elseif ($attr === 'urls') {
             $this->urls = array();
             foreach ($val->url as $url) {
                 $urlAttr = (string) $url->attributes()->desc;
                 $this->urls[$urlAttr] = (string) $url;
             }
             ksort($this->urls);
         } else {
             $this->{$attr} = CRM_Utils_XML::xmlObjToArray($val);
         }
     }
 }
/**
 * Initialise the extension
 */
function simplemail_civicrm_init()
{
    define('SM_SESSION_SCOPE_PREFIX', 'SimpleMail_');
    /**
     * The value of the option value for name 'mailing_category', part of the option group 'group_type'
     */
    define('SM_MAILING_CATEGORY_GROUP_TYPE_VALUE', 'mailing_category');
    // Permission
    define('SM_PERMISSION_ACCESS', 'access CiviSimpleMail');
    define('SM_PERMISSION_EDIT', 'edit CiviSimpleMail');
    define('SM_PERMISSION_DELETE', 'delete CiviSimpleMail');
    define('SM_PERMISSION_ACCESS_ADMIN', 'access admin CiviSimpleMail');
    define('SM_PERMISSION_ACCESS_LEGACY', 'access LegacyMailUi');
    define('SM_PERMISSION_MANAGE_ALL', 'manage all CiviSimpleMail mails');
    define('SM_PERMISSION_ADD_GROUPS', 'add groups to new CiviSimpleMail mails');
    /** @var SimpleXMLElement[] $infoXml */
    $infoXml = CRM_Utils_XML::parseFile(simplemail_civicrm_getExtensionDir() . 'info.xml');
    foreach ($infoXml as $element) {
        if ($element instanceof SimpleXMLElement && $element->getName() == 'extension') {
            $attributes = $element->attributes();
            /**
             * Name of the extension
             */
            define('SM_EXT_NAME', (string) $element->name);
            /**
             * Key of the extension (also the name of the extension's directory)
             */
            define('SM_EXT_KEY', (string) $attributes['key']);
            /**
             * Path to the assets directory
             */
            define('SM_ASSETS_URL', simplemail_civicrm_getExtensionUrl() . '/assets');
        }
    }
    /**
     * Whether emails should have SSL linked content or not
     * Generally set this to false because SSL linked content can break mail clients
     */
    define('SM_CONTENT_SSL', false);
}