3 $sourceCheckoutDir = $GLOBALS['_SERVER']['DM_SOURCEDIR'] ??
$argv[1];
4 $targetDir = $GLOBALS['_SERVER']['DM_TMPDIR'] . '/com_civicrm' ??
$argv[2];
5 $version = $GLOBALS['_SERVER']['DM_VERSION'] ??
$argv[3];
6 $pkgType = $GLOBALS['_SERVER']['DM_PKGTYPE'] ??
$argv[4];
8 ini_set('include_path',
9 "{$sourceCheckoutDir}:{$sourceCheckoutDir}/packages:" . ini_get('include_path')
12 define('CIVICRM_UF', 'Joomla');
13 $GLOBALS['civicrm_root'] = $sourceCheckoutDir;
14 require_once $sourceCheckoutDir . '/CRM/Core/ClassLoader.php';
15 CRM_Core_ClassLoader
::singleton()->register();
17 require_once 'Smarty/Smarty.class.php';
19 generateJoomlaConfig($version);
22 * This function creates destination directory
24 * @param $dir directory name to be created
27 * @internal param \mode $peram for that directory
29 function createDir($dir, $perm = 0755) {
31 echo "Outdir: $dir\n";
32 mkdir($dir, $perm, TRUE);
39 function generateJoomlaConfig($version) {
40 global $targetDir, $sourceCheckoutDir, $pkgType;
42 $smarty = new Smarty();
43 $smarty->template_dir
= $sourceCheckoutDir . '/xml/templates';
44 $smarty->compile_dir
= '/tmp/templates_c_u' . posix_geteuid();
45 createDir($smarty->compile_dir
);
47 $smarty->assign('CiviCRMVersion', $version);
48 $smarty->assign('creationDate', date('F d Y'));
49 $smarty->assign('pkgType', $pkgType);
51 $xml = $smarty->fetch('joomla.tpl');
53 $output = $targetDir . '/civicrm.xml';
54 $fd = fopen($output, "w");
58 require_once 'CRM/Core/Config.php';
59 $config = CRM_Core_Config
::singleton(FALSE);
61 require_once 'CRM/Core/Permission.php';
62 require_once 'CRM/Utils/String.php';
63 require_once 'CRM/Core/I18n.php';
64 $permissions = CRM_Core_Permission
::getCorePermissions();
66 $crmFolderDir = $sourceCheckoutDir . DIRECTORY_SEPARATOR
. 'CRM';
68 // @todo call getCoreAndComponentPermissions instead and let that
69 // do the work of these next 15-20 lines.
70 require_once 'CRM/Core/Component.php';
71 $components = CRM_Core_Component
::getComponentsFromFile($crmFolderDir);
72 foreach ($components as $comp) {
73 $perm = $comp->getPermissions(FALSE, TRUE);
75 $info = $comp->getInfo();
76 foreach ($perm as $p => $attr) {
77 $title = $info['translatedName'] . ': ' . array_shift($attr);
78 array_unshift($attr, $title);
79 $permissions[$p] = $attr;
84 $perms_array = array();
85 foreach ($permissions as $perm => $attr) {
86 // give an empty string as default description
89 //order matters here, but we deal with that later
90 $perms_array[CRM_Utils_String
::munge(strtolower($perm))] = array(
91 'title' => array_shift($attr),
92 'description' => array_shift($attr),
95 $smarty->assign('permissions', $perms_array);
97 $output = $targetDir . '/admin/access.xml';
98 $xml = $smarty->fetch('access.tpl');
99 $fd = fopen($output, "w");