Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
fe108173 | 2 | define('CIVICRM_MYSQL_STRICT', 0); |
6a488035 TO |
3 | if (isset($GLOBALS['_SERVER']['DM_SOURCEDIR'])) { |
4 | $sourceCheckoutDir = $GLOBALS['_SERVER']['DM_SOURCEDIR']; | |
5 | } | |
6 | else { | |
7 | $sourceCheckoutDir = $argv[1]; | |
8 | } | |
9 | $sourceCheckoutDirLength = strlen($sourceCheckoutDir); | |
10 | ||
11 | if (isset($GLOBALS['_SERVER']['DM_TMPDIR'])) { | |
12 | $targetDir = $GLOBALS['_SERVER']['DM_TMPDIR'] . '/com_civicrm'; | |
13 | } | |
14 | else { | |
15 | $targetDir = $argv[2]; | |
16 | } | |
17 | $targetDirLength = strlen($targetDir); | |
18 | ||
19 | if (isset($GLOBALS['_SERVER']['DM_VERSION'])) { | |
20 | $version = $GLOBALS['_SERVER']['DM_VERSION']; | |
21 | } | |
22 | else { | |
23 | $version = $argv[3]; | |
24 | } | |
25 | ||
26 | if (isset($GLOBALS['_SERVER']['DM_PKGTYPE'])) { | |
27 | $pkgType = $GLOBALS['_SERVER']['DM_PKGTYPE']; | |
28 | } | |
29 | else { | |
30 | $pkgType = $argv[4]; | |
31 | } | |
32 | ||
33 | ini_set('include_path', | |
34 | "{$sourceCheckoutDir}:{$sourceCheckoutDir}/packages:" . ini_get('include_path') | |
35 | ); | |
36 | require_once "$sourceCheckoutDir/civicrm.config.php"; | |
37 | require_once 'Smarty/Smarty.class.php'; | |
38 | ||
39 | generateJoomlaConfig($version); | |
40 | ||
41 | /** | |
42 | * This function creates destination directory | |
43 | * | |
44 | * @param $dir directory name to be created | |
2a6da8d7 | 45 | * @param int $perm |
6a488035 | 46 | * |
2a6da8d7 | 47 | * @internal param \mode $peram for that directory |
6a488035 TO |
48 | */ |
49 | function createDir($dir, $perm = 0755) { | |
50 | if (!is_dir($dir)) { | |
51 | echo "Outdir: $dir\n"; | |
52 | mkdir($dir, $perm, TRUE); | |
53 | } | |
54 | } | |
55 | ||
627456b5 EM |
56 | /** |
57 | * @param $version | |
58 | */ | |
6a488035 TO |
59 | function generateJoomlaConfig($version) { |
60 | global $targetDir, $sourceCheckoutDir, $pkgType; | |
61 | ||
62 | $smarty = new Smarty(); | |
63 | $smarty->template_dir = $sourceCheckoutDir . '/xml/templates'; | |
90902f77 | 64 | $smarty->compile_dir = '/tmp/templates_c_u' . posix_geteuid(); |
6a488035 TO |
65 | createDir($smarty->compile_dir); |
66 | ||
67 | $smarty->assign('CiviCRMVersion', $version); | |
68 | $smarty->assign('creationDate', date('F d Y')); | |
69 | $smarty->assign('pkgType', $pkgType); | |
70 | ||
71 | $xml = $smarty->fetch('joomla.tpl'); | |
72 | ||
73 | $output = $targetDir . '/civicrm.xml'; | |
74 | $fd = fopen($output, "w"); | |
389bcebf | 75 | fwrite($fd, $xml); |
6a488035 TO |
76 | fclose($fd); |
77 | ||
78 | require_once 'CRM/Core/Config.php'; | |
79 | $config = CRM_Core_Config::singleton(FALSE); | |
80 | ||
81 | require_once 'CRM/Core/Permission.php'; | |
82 | require_once 'CRM/Utils/String.php'; | |
83 | $permissions = CRM_Core_Permission::getCorePermissions(); | |
84 | ||
85 | $crmFolderDir = $sourceCheckoutDir . DIRECTORY_SEPARATOR . 'CRM'; | |
86 | ||
87 | require_once 'CRM/Core/Component.php'; | |
88 | $components = CRM_Core_Component::getComponentsFromFile($crmFolderDir); | |
89 | foreach ($components as $comp) { | |
90 | $perm = $comp->getPermissions(); | |
91 | if ($perm) { | |
92 | $info = $comp->getInfo(); | |
93 | foreach ($perm as $p) { | |
94 | $permissions[$p] = $info['translatedName'] . ': ' . $p; | |
95 | } | |
96 | } | |
97 | } | |
98 | ||
99 | $perms_array = array(); | |
100 | foreach ($permissions as $perm => $title) { | |
101 | //order matters here, but we deal with that later | |
102 | $perms_array[CRM_Utils_String::munge(strtolower($perm))] = $title; | |
103 | } | |
104 | $smarty->assign('permissions', $perms_array); | |
105 | ||
106 | $output = $targetDir . '/admin/access.xml'; | |
107 | $xml = $smarty->fetch('access.tpl'); | |
108 | $fd = fopen($output, "w"); | |
389bcebf | 109 | fwrite($fd, $xml); |
6a488035 TO |
110 | fclose($fd); |
111 | } |