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 | |
45 | * @param $peram mode for that directory | |
46 | * | |
47 | */ | |
48 | function createDir($dir, $perm = 0755) { | |
49 | if (!is_dir($dir)) { | |
50 | echo "Outdir: $dir\n"; | |
51 | mkdir($dir, $perm, TRUE); | |
52 | } | |
53 | } | |
54 | ||
55 | function generateJoomlaConfig($version) { | |
56 | global $targetDir, $sourceCheckoutDir, $pkgType; | |
57 | ||
58 | $smarty = new Smarty(); | |
59 | $smarty->template_dir = $sourceCheckoutDir . '/xml/templates'; | |
90902f77 | 60 | $smarty->compile_dir = '/tmp/templates_c_u' . posix_geteuid(); |
6a488035 TO |
61 | createDir($smarty->compile_dir); |
62 | ||
63 | $smarty->assign('CiviCRMVersion', $version); | |
64 | $smarty->assign('creationDate', date('F d Y')); | |
65 | $smarty->assign('pkgType', $pkgType); | |
66 | ||
67 | $xml = $smarty->fetch('joomla.tpl'); | |
68 | ||
69 | $output = $targetDir . '/civicrm.xml'; | |
70 | $fd = fopen($output, "w"); | |
71 | fputs($fd, $xml); | |
72 | fclose($fd); | |
73 | ||
74 | require_once 'CRM/Core/Config.php'; | |
75 | $config = CRM_Core_Config::singleton(FALSE); | |
76 | ||
77 | require_once 'CRM/Core/Permission.php'; | |
78 | require_once 'CRM/Utils/String.php'; | |
79 | $permissions = CRM_Core_Permission::getCorePermissions(); | |
80 | ||
81 | $crmFolderDir = $sourceCheckoutDir . DIRECTORY_SEPARATOR . 'CRM'; | |
82 | ||
83 | require_once 'CRM/Core/Component.php'; | |
84 | $components = CRM_Core_Component::getComponentsFromFile($crmFolderDir); | |
85 | foreach ($components as $comp) { | |
86 | $perm = $comp->getPermissions(); | |
87 | if ($perm) { | |
88 | $info = $comp->getInfo(); | |
89 | foreach ($perm as $p) { | |
90 | $permissions[$p] = $info['translatedName'] . ': ' . $p; | |
91 | } | |
92 | } | |
93 | } | |
94 | ||
95 | $perms_array = array(); | |
96 | foreach ($permissions as $perm => $title) { | |
97 | //order matters here, but we deal with that later | |
98 | $perms_array[CRM_Utils_String::munge(strtolower($perm))] = $title; | |
99 | } | |
100 | $smarty->assign('permissions', $perms_array); | |
101 | ||
102 | $output = $targetDir . '/admin/access.xml'; | |
103 | $xml = $smarty->fetch('access.tpl'); | |
104 | $fd = fopen($output, "w"); | |
105 | fputs($fd, $xml); | |
106 | fclose($fd); | |
107 | } | |
108 |