Пример #1
0
 /**
  * Load extension info an XML file.
  *
  * @param $file
  *
  * @throws CRM_Extension_Exception_ParseException
  * @return CRM_Extension_Info
  */
 public static function loadFromFile($file)
 {
     list($xml, $error) = CRM_Utils_XML::parseFile($file);
     if ($xml === FALSE) {
         throw new CRM_Extension_Exception_ParseException("Failed to parse info XML: {$error}");
     }
     $instance = new CRM_Extension_Info();
     $instance->parse($xml);
     return $instance;
 }
/**
 * 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);
}