2 if (isset($GLOBALS['_SERVER']['DM_SOURCEDIR'])) {
3 $sourceCheckoutDir = $GLOBALS['_SERVER']['DM_SOURCEDIR'];
6 $sourceCheckoutDir = $argv[1];
8 $sourceCheckoutDirLength = strlen($sourceCheckoutDir);
10 if (isset($GLOBALS['_SERVER']['DM_TMPDIR'])) {
11 $targetDir = $GLOBALS['_SERVER']['DM_TMPDIR'] . '/com_civicrm';
14 $targetDir = $argv[2];
16 $targetDirLength = strlen($targetDir);
18 if (isset($GLOBALS['_SERVER']['DM_VERSION'])) {
19 $version = $GLOBALS['_SERVER']['DM_VERSION'];
25 if (isset($GLOBALS['_SERVER']['DM_PKGTYPE'])) {
26 $pkgType = $GLOBALS['_SERVER']['DM_PKGTYPE'];
32 ini_set('include_path',
33 "{$sourceCheckoutDir}:{$sourceCheckoutDir}/packages:" . ini_get('include_path')
35 require_once "$sourceCheckoutDir/civicrm.config.php";
36 require_once 'Smarty/Smarty.class.php';
38 generateJoomlaConfig($version);
41 * This function creates destination directory
43 * @param $dir directory name to be created
44 * @param $peram mode for that directory
47 function createDir($dir, $perm = 0755) {
49 echo "Outdir: $dir\n";
50 mkdir($dir, $perm, TRUE);
54 function generateJoomlaConfig($version) {
55 global $targetDir, $sourceCheckoutDir, $pkgType;
57 $smarty = new Smarty();
58 $smarty->template_dir
= $sourceCheckoutDir . '/xml/templates';
59 $smarty->compile_dir
= '/tmp/templates_c_u' . posix_geteuid();
60 createDir($smarty->compile_dir
);
62 $smarty->assign('CiviCRMVersion', $version);
63 $smarty->assign('creationDate', date('F d Y'));
64 $smarty->assign('pkgType', $pkgType);
66 $xml = $smarty->fetch('joomla.tpl');
68 $output = $targetDir . '/civicrm.xml';
69 $fd = fopen($output, "w");
73 require_once 'CRM/Core/Config.php';
74 $config = CRM_Core_Config
::singleton(FALSE);
76 require_once 'CRM/Core/Permission.php';
77 require_once 'CRM/Utils/String.php';
78 $permissions = CRM_Core_Permission
::getCorePermissions();
80 $crmFolderDir = $sourceCheckoutDir . DIRECTORY_SEPARATOR
. 'CRM';
82 require_once 'CRM/Core/Component.php';
83 $components = CRM_Core_Component
::getComponentsFromFile($crmFolderDir);
84 foreach ($components as $comp) {
85 $perm = $comp->getPermissions();
87 $info = $comp->getInfo();
88 foreach ($perm as $p) {
89 $permissions[$p] = $info['translatedName'] . ': ' . $p;
94 $perms_array = array();
95 foreach ($permissions as $perm => $title) {
96 //order matters here, but we deal with that later
97 $perms_array[CRM_Utils_String
::munge(strtolower($perm))] = $title;
99 $smarty->assign('permissions', $perms_array);
101 $output = $targetDir . '/admin/access.xml';
102 $xml = $smarty->fetch('access.tpl');
103 $fd = fopen($output, "w");