2 define('CIVICRM_MYSQL_STRICT', 0);
3 if (isset($GLOBALS['_SERVER']['DM_SOURCEDIR'])) {
4 $sourceCheckoutDir = $GLOBALS['_SERVER']['DM_SOURCEDIR'];
7 $sourceCheckoutDir = $argv[1];
9 $sourceCheckoutDirLength = strlen($sourceCheckoutDir);
11 if (isset($GLOBALS['_SERVER']['DM_TMPDIR'])) {
12 $targetDir = $GLOBALS['_SERVER']['DM_TMPDIR'] . '/com_civicrm';
15 $targetDir = $argv[2];
17 $targetDirLength = strlen($targetDir);
19 if (isset($GLOBALS['_SERVER']['DM_VERSION'])) {
20 $version = $GLOBALS['_SERVER']['DM_VERSION'];
26 if (isset($GLOBALS['_SERVER']['DM_PKGTYPE'])) {
27 $pkgType = $GLOBALS['_SERVER']['DM_PKGTYPE'];
33 ini_set('include_path',
34 "{$sourceCheckoutDir}:{$sourceCheckoutDir}/packages:" . ini_get('include_path')
36 require_once "$sourceCheckoutDir/civicrm.config.php";
37 require_once 'Smarty/Smarty.class.php';
39 generateJoomlaConfig($version);
42 * This function creates destination directory
44 * @param $dir directory name to be created
47 * @internal param \mode $peram for that directory
49 function createDir($dir, $perm = 0755) {
51 echo "Outdir: $dir\n";
52 mkdir($dir, $perm, TRUE);
59 function generateJoomlaConfig($version) {
60 global $targetDir, $sourceCheckoutDir, $pkgType;
62 $smarty = new Smarty();
63 $smarty->template_dir
= $sourceCheckoutDir . '/xml/templates';
64 $smarty->compile_dir
= '/tmp/templates_c_u' . posix_geteuid();
65 createDir($smarty->compile_dir
);
67 $smarty->assign('CiviCRMVersion', $version);
68 $smarty->assign('creationDate', date('F d Y'));
69 $smarty->assign('pkgType', $pkgType);
71 $xml = $smarty->fetch('joomla.tpl');
73 $output = $targetDir . '/civicrm.xml';
74 $fd = fopen($output, "w");
78 require_once 'CRM/Core/Config.php';
79 $config = CRM_Core_Config
::singleton(FALSE);
81 require_once 'CRM/Core/Permission.php';
82 require_once 'CRM/Utils/String.php';
83 require_once 'CRM/Core/I18n.php';
84 $permissions = CRM_Core_Permission
::getCorePermissions(TRUE);
86 $crmFolderDir = $sourceCheckoutDir . DIRECTORY_SEPARATOR
. 'CRM';
88 require_once 'CRM/Core/Component.php';
89 $components = CRM_Core_Component
::getComponentsFromFile($crmFolderDir);
90 foreach ($components as $comp) {
91 $perm = $comp->getPermissions(FALSE, TRUE);
93 $info = $comp->getInfo();
94 foreach ($perm as $p => $attr) {
95 $title = $info['translatedName'] . ': ' . array_shift($attr);
96 array_unshift($attr, $title);
97 $permissions[$p] = $attr;
102 $perms_array = array();
103 foreach ($permissions as $perm => $attr) {
104 // give an empty string as default description
107 //order matters here, but we deal with that later
108 $perms_array[CRM_Utils_String
::munge(strtolower($perm))] = array(
109 'title' => array_shift($attr),
110 'description' => array_shift($attr),
113 $smarty->assign('permissions', $perms_array);
115 $output = $targetDir . '/admin/access.xml';
116 $xml = $smarty->fetch('access.tpl');
117 $fd = fopen($output, "w");