PageRenderTime 85ms CodeModel.GetById 42ms RepoModel.GetById 1ms app.codeStats 0ms

/manager/actions/mutate_module.dynamic.php

https://github.com/good-web-master/modx.evo.custom
PHP | 553 lines | 497 code | 43 blank | 13 comment | 103 complexity | f5c6beb2840a3b97c78a4e39a51fcef9 MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0, GPL-2.0, MIT, BSD-3-Clause
  1. <?php
  2. if(IN_MANAGER_MODE!='true') die('<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the MODx Content Manager instead of accessing this file directly.');
  3. switch ((int) $_REQUEST['a']) {
  4. case 107:
  5. if(!$modx->hasPermission('new_module')) {
  6. $e->setError(3);
  7. $e->dumpError();
  8. }
  9. break;
  10. case 108:
  11. if(!$modx->hasPermission('edit_module')) {
  12. $e->setError(3);
  13. $e->dumpError();
  14. }
  15. break;
  16. default:
  17. $e->setError(3);
  18. $e->dumpError();
  19. }
  20. if (isset($_REQUEST['id']))
  21. $id = (int)$_REQUEST['id'];
  22. else $id = 0;
  23. if ($manager_theme)
  24. $manager_theme .= '/';
  25. else $manager_theme = '';
  26. // Get table names (alphabetical)
  27. $tbl_active_users = $modx->getFullTableName('active_users');
  28. $tbl_membergroup_names = $modx->getFullTableName('membergroup_names');
  29. $tbl_site_content = $modx->getFullTableName('site_content');
  30. $tbl_site_htmlsnippets = $modx->getFullTableName('site_htmlsnippets');
  31. $tbl_site_module_access = $modx->getFullTableName('site_module_access');
  32. $tbl_site_module_depobj = $modx->getFullTableName('site_module_depobj');
  33. $tbl_site_modules = $modx->getFullTableName('site_modules');
  34. $tbl_site_plugins = $modx->getFullTableName('site_plugins');
  35. $tbl_site_snippets = $modx->getFullTableName('site_snippets');
  36. $tbl_site_templates = $modx->getFullTableName('site_templates');
  37. $tbl_site_tmplvars = $modx->getFullTableName('site_tmplvars');
  38. // create globally unique identifiers (guid)
  39. function createGUID(){
  40. srand((double)microtime()*1000000);
  41. $r = rand() ;
  42. $u = uniqid(getmypid() . $r . (double)microtime()*1000000,1);
  43. $m = md5 ($u);
  44. return $m;
  45. }
  46. // Check to see the editor isn't locked
  47. $sql = 'SELECT internalKey, username FROM '.$tbl_active_users.' WHERE action=108 AND id=\''.$id.'\'';
  48. $rs = mysql_query($sql);
  49. $limit = mysql_num_rows($rs);
  50. if ($limit > 1) {
  51. for ($i = 0; $i < $limit; $i++) {
  52. $lock = mysql_fetch_assoc($rs);
  53. if ($lock['internalKey'] != $modx->getLoginUserID()) {
  54. $msg = sprintf($_lang['lock_msg'], $lock['username'], 'module');
  55. $e->setError(5, $msg);
  56. $e->dumpError();
  57. }
  58. }
  59. }
  60. // end check for lock
  61. // make sure the id's a number
  62. if (!is_numeric($id)) {
  63. echo 'Passed ID is NaN!';
  64. exit;
  65. }
  66. if (isset($_GET['id'])) {
  67. $sql = 'SELECT * FROM '.$tbl_site_modules.' WHERE id=\''.$id.'\'';
  68. $rs = mysql_query($sql);
  69. $limit = mysql_num_rows($rs);
  70. if ($limit > 1) {
  71. echo '<p>Multiple modules sharing same unique id. Not good.<p>';
  72. exit;
  73. }
  74. if ($limit < 1) {
  75. echo '<p>No record found for id: '.$id.'.</p>';
  76. exit;
  77. }
  78. $content = mysql_fetch_assoc($rs);
  79. $_SESSION['itemname'] = $content['name'];
  80. if ($content['locked'] == 1 && $_SESSION['mgrRole'] != 1) {
  81. $e->setError(3);
  82. $e->dumpError();
  83. }
  84. } else {
  85. $_SESSION['itemname'] = 'New Module';
  86. $content['wrap'] = '1';
  87. }
  88. ?>
  89. <script type="text/javascript">
  90. function loadDependencies() {
  91. if (documentDirty) {
  92. if (!confirm("<?php echo $_lang['confirm_load_depends']?>")) {
  93. return;
  94. }
  95. }
  96. documentDirty = false;
  97. window.location.href="index.php?id=<?php echo $_REQUEST['id']?>&a=113";
  98. };
  99. function duplicaterecord() {
  100. if(confirm("<?php echo $_lang['confirm_duplicate_record']?>")==true) {
  101. documentDirty=false;
  102. document.location.href="index.php?id=<?php echo $_REQUEST['id']?>&a=111";
  103. }
  104. }
  105. function deletedocument() {
  106. if(confirm("<?php echo $_lang['confirm_delete_module']?>")==true) {
  107. documentDirty=false;
  108. document.location.href="index.php?id=" + document.mutate.id.value + "&a=110";
  109. }
  110. }
  111. function setTextWrap(ctrl,b) {
  112. if(!ctrl) return;
  113. ctrl.wrap = (b)? "soft":"off";
  114. }
  115. // Current Params
  116. var currentParams = {};
  117. function showParameters(ctrl) {
  118. var c,p,df,cp;
  119. var ar,desc,value,key,dt;
  120. currentParams = {}; // reset;
  121. if (ctrl) {
  122. f = ctrl.form;
  123. } else {
  124. f= document.forms['mutate'];
  125. if(!f) return;
  126. }
  127. // setup parameters
  128. tr = (document.getElementById) ? document.getElementById('displayparamrow'):document.all['displayparamrow'];
  129. dp = (f.properties.value) ? f.properties.value.split("&"):"";
  130. if(!dp) tr.style.display='none';
  131. else {
  132. t='<table style="margin-bottom:3px;margin-left:14px;background-color:#EEEEEE" cellpadding="2" cellspacing="1"><thead><tr><td><?php echo $_lang['parameter']?></td><td><?php echo $_lang['value']?></td></tr></thead>';
  133. for(p = 0; p < dp.length; p++) {
  134. dp[p]=(dp[p]+'').replace(/^\s|\s$/,""); // trim
  135. ar = dp[p].split("=");
  136. key = ar[0]; // param
  137. ar = (ar[1]+'').split(";");
  138. desc = ar[0]; // description
  139. dt = ar[1]; // data type
  140. value = decode((ar[2])? ar[2]:'');
  141. // store values for later retrieval
  142. if (key && dt=='list') currentParams[key] = [desc,dt,value,ar[3]];
  143. else if (key) currentParams[key] = [desc,dt,value];
  144. if (dt) {
  145. switch(dt) {
  146. case 'int':
  147. c = '<input type="text" name="prop_'+key+'" value="'+value+'" size="30" onchange="setParameter(\''+key+'\',\''+dt+'\',this)" />';
  148. break;
  149. case 'menu':
  150. value = ar[3];
  151. c = '<select name="prop_'+key+'" style="width:168px" onchange="setParameter(\''+key+'\',\''+dt+'\',this)">';
  152. ls = (ar[2]+'').split(",");
  153. if(currentParams[key]==ar[2]) currentParams[key] = ls[0]; // use first list item as default
  154. for(i=0;i<ls.length;i++) {
  155. c += '<option value="'+ls[i]+'"'+((ls[i]==value)? ' selected="selected"':'')+'>'+ls[i]+'</option>';
  156. }
  157. c += '</select>';
  158. break;
  159. case 'list':
  160. value = ar[3];
  161. ls = (ar[2]+'').split(",");
  162. if(currentParams[key]==ar[2]) currentParams[key] = ls[0]; // use first list item as default
  163. c = '<select name="prop_'+key+'" size="'+ls.length+'" style="width:168px" onchange="setParameter(\''+key+'\',\''+dt+'\',this)">';
  164. for(i=0;i<ls.length;i++) {
  165. c += '<option value="'+ls[i]+'"'+((ls[i]==value)? ' selected="selected"':'')+'>'+ls[i]+'</option>';
  166. }
  167. c += '</select>';
  168. break;
  169. case 'list-multi':
  170. value = (ar[3]+'').replace(/^\s|\s$/,"");
  171. arrValue = value.split(",")
  172. ls = (ar[2]+'').split(",");
  173. if(currentParams[key]==ar[2]) currentParams[key] = ls[0]; // use first list item as default
  174. c = '<select name="prop_'+key+'" size="'+ls.length+'" multiple="multiple" style="width:168px" onchange="setParameter(\''+key+'\',\''+dt+'\',this)">';
  175. for(i=0;i<ls.length;i++) {
  176. if(arrValue.length) {
  177. for(j=0;j<arrValue.length;j++) {
  178. if(ls[i]==arrValue[j]) {
  179. c += '<option value="'+ls[i]+'" selected="selected">'+ls[i]+'</option>';
  180. } else {
  181. c += '<option value="'+ls[i]+'">'+ls[i]+'</option>';
  182. }
  183. }
  184. } else {
  185. c += '<option value="'+ls[i]+'">'+ls[i]+'</option>';
  186. }
  187. }
  188. c += '</select>';
  189. break;
  190. case 'textarea':
  191. c = '<textarea class="phptextarea" name="prop_'+key+'" cols="50" rows="4" onchange="setParameter(\''+key+'\',\''+dt+'\',this)">'+value+'</textarea>';
  192. break;
  193. default: // string
  194. c = '<input type="text" name="prop_'+key+'" value="'+value+'" size="30" onchange="setParameter(\''+key+'\',\''+dt+'\',this)" />';
  195. break;
  196. }
  197. t +='<tr><td bgcolor="#FFFFFF">'+desc+'</td><td bgcolor="#FFFFFF">'+c+'</td></tr>';
  198. };
  199. }
  200. t+='</table>';
  201. td = (document.getElementById) ? document.getElementById('displayparams'):document.all['displayparams'];
  202. td.innerHTML = t;
  203. tr.style.display='';
  204. }
  205. implodeParameters();
  206. }
  207. function setParameter(key,dt,ctrl) {
  208. var v;
  209. if(!ctrl) return null;
  210. switch (dt) {
  211. case 'int':
  212. ctrl.value = parseInt(ctrl.value);
  213. if(isNaN(ctrl.value)) ctrl.value = 0;
  214. v = ctrl.value;
  215. break;
  216. case 'menu':
  217. v = ctrl.options[ctrl.selectedIndex].value;
  218. currentParams[key][3] = v;
  219. implodeParameters();
  220. return;
  221. break;
  222. case 'list':
  223. v = ctrl.options[ctrl.selectedIndex].value;
  224. currentParams[key][3] = v;
  225. implodeParameters();
  226. return;
  227. break;
  228. case 'list-multi':
  229. var arrValues = new Array;
  230. for(var i=0; i < ctrl.options.length; i++) {
  231. if(ctrl.options[i].selected) {
  232. arrValues.push(ctrl.options[i].value);
  233. }
  234. }
  235. currentParams[key][3] = arrValues.toString();
  236. implodeParameters();
  237. return;
  238. break;
  239. default:
  240. v = ctrl.value+'';
  241. break;
  242. }
  243. currentParams[key][2] = v;
  244. implodeParameters();
  245. }
  246. // implode parameters
  247. function implodeParameters() {
  248. var v, p, s='';
  249. for(p in currentParams) {
  250. if(currentParams[p]) {
  251. v = currentParams[p].join(";");
  252. if(s && v) s+=' ';
  253. if(v) s += '&'+p+'='+ v;
  254. }
  255. }
  256. document.forms['mutate'].properties.value = s;
  257. }
  258. function encode(s) {
  259. s=s+'';
  260. s = s.replace(/\=/g,'%3D'); // =
  261. s = s.replace(/\&/g,'%26'); // &
  262. return s;
  263. }
  264. function decode(s) {
  265. s=s+'';
  266. s = s.replace(/\%3D/g,'='); // =
  267. s = s.replace(/\%26/g,'&'); // &
  268. return s;
  269. }
  270. // Resource browser
  271. function OpenServerBrowser(url, width, height ) {
  272. var iLeft = (screen.width - width) / 2 ;
  273. var iTop = (screen.height - height) / 2 ;
  274. var sOptions = "toolbar=no,status=no,resizable=yes,dependent=yes" ;
  275. sOptions += ",width=" + width ;
  276. sOptions += ",height=" + height ;
  277. sOptions += ",left=" + iLeft ;
  278. sOptions += ",top=" + iTop ;
  279. var oWindow = window.open( url, "FCKBrowseWindow", sOptions ) ;
  280. }
  281. function BrowseServer() {
  282. var w = screen.width * 0.7;
  283. var h = screen.height * 0.7;
  284. OpenServerBrowser("<?php echo $base_url?>manager/media/browser/mcpuk/browser.html?Type=images&Connector=<?php echo $base_url?>manager/media/browser/mcpuk/connectors/php/connector.php&ServerPath=<?php echo $base_url?>", w, h);
  285. }
  286. function SetUrl(url, width, height, alt) {
  287. document.mutate.icon.value = url;
  288. }
  289. </script>
  290. <script type="text/javascript" src="media/script/tabpane.js"></script>
  291. <link rel="stylesheet" type="text/css" href="media/style/<?php echo $manager_theme?>style.css?<?php echo $theme_refresher?>" />
  292. <form name="mutate" id="mutate" class="module" method="post" action="index.php?a=109">
  293. <?php
  294. // invoke OnModFormPrerender event
  295. $evtOut = $modx->invokeEvent('OnModFormPrerender', array('id' => $id));
  296. if(is_array($evtOut)) echo implode('',$evtOut);
  297. ?>
  298. <input type="hidden" name="id" value="<?php echo $content['id']?>">
  299. <input type="hidden" name="mode" value="<?php echo $_GET['a']?>">
  300. <h1><?php echo $_lang['module_title']?></h1>
  301. <div id="actions">
  302. <ul class="actionButtons">
  303. <li id="Button1">
  304. <a href="#" onclick="documentDirty=false; document.mutate.save.click();">
  305. <img src="<?php echo $_style["icons_save"]?>" /> <?php echo $_lang['save']?>
  306. </a>
  307. <span class="and"> + </span>
  308. <select id="stay" name="stay">
  309. <?php if ($modx->hasPermission('new_module')) { ?>
  310. <option id="stay1" value="1" <?php echo $_REQUEST['stay']=='1' ? ' selected=""' : ''?> ><?php echo $_lang['stay_new']?></option>
  311. <?php } ?>
  312. <option id="stay2" value="2" <?php echo $_REQUEST['stay']=='2' ? ' selected="selected"' : ''?> ><?php echo $_lang['stay']?></option>
  313. <option id="stay3" value="" <?php echo $_REQUEST['stay']=='' ? ' selected=""' : ''?> ><?php echo $_lang['close']?></option>
  314. </select>
  315. </li>
  316. <?php
  317. if ($_REQUEST['a'] == '108') { ?>
  318. <li id="Button2" class="disabled"><a href="#" onclick="deletedocument();"><img src="<?php echo $_style["icons_delete_document"]?>" /> <?php echo $_lang['delete']?></a></li>
  319. <?php } else { ?>
  320. <li id="Button2"><a href="#" onclick="deletedocument();"><img src="<?php echo $_style["icons_delete_document"]?>" /> <?php echo $_lang['delete']?></a></li>
  321. <?php } ?>
  322. <li id="Button5"><a href="#" onclick="documentDirty=false;document.location.href='index.php?a=106';"><img src="<?php echo $_style["icons_cancel"] ?>" /> <?php echo $_lang['cancel']?></a></li>
  323. <?php // In Place for future extraction of actionbar
  324. if ($_REQUEST['a'] == '27') { ?>
  325. <li id="Button6"><a href="#" onclick="window.open('<?php echo $modx->makeUrl($id); ?>','previeWin');"><img src="<?php echo $_style["icons_preview"]?>" /> <?php echo $_lang['preview']?></a></li>
  326. <?php } ?>
  327. </ul>
  328. </div>
  329. <!-- end #actions -->
  330. <div class="sectionHeader"><?php echo $_lang['module_title']?></div>
  331. <div class="sectionBody"><p><img class="icon" src="media/style/<?php echo $manager_theme?>images/icons/modules.gif" alt="." width="32" height="32" style="vertical-align:middle;text-align:left;" /> <?php echo $_lang['module_msg']?></p>
  332. <div class="tab-pane" id="modulePane">
  333. <script type="text/javascript">
  334. tpModule = new WebFXTabPane( document.getElementById( "modulePane"), <?php echo $modx->config['remember_last_tab'] == 1 ? 'true' : 'false'; ?> );
  335. </script>
  336. <!-- General -->
  337. <div class="tab-page" id="tabModule">
  338. <h2 class="tab"><?php echo $_lang['settings_general']?></h2>
  339. <script type="text/javascript">tpModule.addTabPage( document.getElementById( "tabModule" ) );</script>
  340. <table border="0" cellspacing="0" cellpadding="1">
  341. <tr><td align="left"><?php echo $_lang['module_name']?>:</td>
  342. <td align="left"><span style="font-family:'Courier New', Courier, mono">&nbsp;&nbsp;</span><input name="name" type="text" maxlength="100" value="<?php echo htmlspecialchars($content['name'])?>" class="inputBox" style="width:150px;" onchange="documentDirty=true;"><span style="font-family:'Courier New', Courier, mono">&nbsp;</span><span class="warning" id="savingMessage">&nbsp;</span></td></tr>
  343. <tr><td align="left"><?php echo $_lang['module_desc']?>:&nbsp;&nbsp;</td>
  344. <td align="left"><span style="font-family:'Courier New', Courier, mono">&nbsp;&nbsp;</span><input name="description" type="text" maxlength="255" value="<?php echo $content['description']?>" class="inputBox" onchange="documentDirty=true;"></td></tr>
  345. <tr><td align="left"><?php echo $_lang['icon']?> <span class="comment">(32x32)</span>:&nbsp;&nbsp;</td>
  346. <td align="left"><span style="font-family:'Courier New', Courier, mono">&nbsp;&nbsp;</span><input onchange="documentDirty=true;" type="text" maxlength="255" style="width: 235px;" name="icon" value="<?php echo $content['icon']?>" /> <input type="button" value="<?php echo $_lang['insert']?>" onclick="BrowseServer();" /></td></tr>
  347. <tr><td align="left"><?php echo $_lang['existing_category']?>:&nbsp;&nbsp;</td>
  348. <td align="left"><span style="font-family:'Courier New', Courier, mono">&nbsp;&nbsp;</span>
  349. <select name="categoryid" onchange="documentDirty=true;">
  350. <option>&nbsp;</option>
  351. <?php
  352. include_once "categories.inc.php";
  353. $ds = getCategories();
  354. if ($ds) {
  355. foreach($ds as $n => $v) {
  356. echo "\t\t\t".'<option value="'.$v['id'].'"'.($content['category'] == $v['id'] ? ' selected="selected"' : '').'>'.htmlspecialchars($v['category'])."</option>\n";
  357. }
  358. }
  359. ?>
  360. </select></td></tr>
  361. <tr><td align="left" valign="top" style="padding-top:5px;"><?php echo $_lang['new_category']?>:</td>
  362. <td align="left" valign="top" style="padding-top:5px;"><span style="font-family:'Courier New', Courier, mono">&nbsp;&nbsp;</span><input name="newcategory" type="text" maxlength="45" value="" class="inputBox" onchange="documentDirty=true;"></td></tr>
  363. <tr><td align="left"><input name="enable_resource" title="<?php echo $_lang['enable_resource']?>" type="checkbox"<?php echo $content['enable_resource']==1 ? ' checked="checked"' : ''?> class="inputBox" onclick="documentDirty=true;" /> <span style="cursor:pointer" onclick="document.mutate.enable_resource.click();" title="<?php echo $_lang['enable_resource']?>"><?php echo $_lang["element"]?></span>:</td>
  364. <td align="left"><span style="font-family:'Courier New', Courier, mono">&nbsp;&nbsp;</span><input name="sourcefile" type="text" maxlength="255" value="<?php echo $content['sourcefile']?>" class="inputBox" onchange="documentDirty=true;" /></td></tr>
  365. <tr><td align="left" valign="top" colspan="2"><input name="disabled" type="checkbox" <?php echo $content['disabled'] == 1 ? 'checked="checked"' : ''?> value="on" class="inputBox" />
  366. <span style="cursor:pointer" onclick="document.mutate.disabled.click();"><?php echo $content['disabled'] == 1 ? '<span class="warning">'.$_lang['module_disabled'].'</span>' : $_lang['module_disabled']?></span></td></tr>
  367. <tr><td align="left" valign="top" colspan="2"><input name="locked" type="checkbox"<?php echo $content['locked'] == 1 ? ' checked="checked"' : ''?> class="inputBox" />
  368. <span style="cursor:pointer" onclick="document.mutate.locked.click();"><?php echo $_lang['lock_module']?></span> <span class="comment"><?php echo $_lang['lock_module_msg']?></span></td></tr>
  369. </table>
  370. <!-- PHP text editor start -->
  371. <div style="width:100%; position:relative">
  372. <div style="padding:1px; width:100%; height:16px; background-color:#eeeeee; border-top:1px solid #e0e0e0; margin-top:5px">
  373. <span style="float:left; color:#707070; font-weight:bold; padding:3px">&nbsp;<?php echo $_lang['module_code']?></span>
  374. <span style="float:right; color:#707070"><?php echo $_lang['wrap_lines']?><input name="wrap" type="checkbox"<?php echo $content['wrap']== 1 ? ' checked="checked"' : ''?> class="inputBox" onclick="setTextWrap(document.mutate.post,this.checked)" /></span>
  375. </div>
  376. <textarea dir="ltr" class="phptextarea" name="post" style="width:100%; height:370px;" wrap="<?php echo $content['wrap']== 1 ? 'soft' : 'off'?>" onchange="documentDirty=true;"><?php echo htmlspecialchars($content['modulecode'])?></textarea>
  377. </div>
  378. <!-- PHP text editor end -->
  379. </div>
  380. <!-- Configuration -->
  381. <div class="tab-page" id="tabConfig">
  382. <h2 class="tab"><?php echo $_lang['settings_config']?></h2>
  383. <script type="text/javascript">tpModule.addTabPage( document.getElementById( "tabConfig" ) );</script>
  384. <table width="90%" border="0" cellspacing="0" cellpadding="0">
  385. <tr><td align="left" valign="top"><?php echo $_lang['guid']?>:</td>
  386. <td align="left" valign="top"><span style="font-family:'Courier New', Courier, mono">&nbsp;&nbsp;</span><input name="guid" type="text" maxlength="32" value="<?php echo (int) $_REQUEST['a'] == 107 ? createGUID() : $content['guid']?>" class="inputBox" onchange="documentDirty=true;" /><br /><br /></td></tr>
  387. <tr><td align="left" valign="top"><input name="enable_sharedparams" type="checkbox"<?php echo $content['enable_sharedparams']==1 ? ' checked="checked"' : ''?> class="inputBox" onclick="documentDirty=true;" /> <span style="cursor:pointer" onclick="document.mutate.enable_sharedparams.click();"><?php echo $_lang['enable_sharedparams']?>:</span></td>
  388. <td align="left" valign="top"><span style="font-family:'Courier New', Courier, mono">&nbsp;&nbsp;</span><span ><span class="comment"><?php echo $_lang['enable_sharedparams_msg']?></span></span><br /><br /></td></tr>
  389. <tr><td align="left" valign="top"><?php echo $_lang['module_config']?>:</td>
  390. <td align="left" valign="top"><span style="font-family:'Courier New', Courier, mono">&nbsp;&nbsp;</span><input name="properties" type="text" maxlength="65535" value="<?php echo $content['properties']?>" class="inputBox phptextarea" style="width:280px;" onchange="showParameters(this);documentDirty=true;" /><input type="button" value="<?php echo $_lang['update_params'] ?>" style="width:16px; margin-left:2px;" title="<?php echo $_lang['update_params']?>" /></td></tr>
  391. <tr id="displayparamrow"><td valign="top" align="left">&nbsp;</td>
  392. <td align="left" id="displayparams">&nbsp;</td></tr>
  393. </table>
  394. </div>
  395. <?php if ($_REQUEST['a'] == '108') { ?>
  396. <!-- Dependencies -->
  397. <div class="tab-page" id="tabDepend">
  398. <h2 class="tab"><?php echo $_lang['settings_dependencies']?></h2>
  399. <script type="text/javascript">tpModule.addTabPage( document.getElementById( "tabDepend" ) );</script>
  400. <table width="95%" border="0" cellspacing="0" cellpadding="0">
  401. <tr><td align="left" valign="top"><p><?php echo $_lang['module_viewdepend_msg']?><br /><br />
  402. <a class="searchtoolbarbtn" href="#" style="float:left" onclick="loadDependencies();return false;"><img src="<?php echo $_style["icons_save"]?>" align="absmiddle" /> <?php echo $_lang['manage_depends']?></a><br /><br /></p></td></tr>
  403. <tr><td valign="top" align="left">
  404. <?php
  405. $sql = 'SELECT smd.id, COALESCE(ss.name,st.templatename,sv.name,sc.name,sp.name,sd.pagetitle) AS `name`, '.
  406. 'CASE smd.type'.
  407. ' WHEN 10 THEN \'Chunk\''.
  408. ' WHEN 20 THEN \'Document\''.
  409. ' WHEN 30 THEN \'Plugin\''.
  410. ' WHEN 40 THEN \'Snippet\''.
  411. ' WHEN 50 THEN \'Template\''.
  412. ' WHEN 60 THEN \'TV\''.
  413. 'END AS `type` '.
  414. 'FROM '.$tbl_site_module_depobj.' AS smd '.
  415. 'LEFT JOIN '.$tbl_site_htmlsnippets.' AS sc ON sc.id = smd.resource AND smd.type = 10 '.
  416. 'LEFT JOIN '.$tbl_site_content.' AS sd ON sd.id = smd.resource AND smd.type = 20 '.
  417. 'LEFT JOIN '.$tbl_site_plugins.' AS sp ON sp.id = smd.resource AND smd.type = 30 '.
  418. 'LEFT JOIN '.$tbl_site_snippets.' AS ss ON ss.id = smd.resource AND smd.type = 40 '.
  419. 'LEFT JOIN '.$tbl_site_templates.' AS st ON st.id = smd.resource AND smd.type = 50 '.
  420. 'LEFT JOIN '.$tbl_site_tmplvars.' AS sv ON sv.id = smd.resource AND smd.type = 60 '.
  421. 'WHERE smd.module=\''.$id.'\' ORDER BY smd.type,name';
  422. $ds = $modx->dbQuery($sql);
  423. if (!$ds) {
  424. echo "An error occured while loading module dependencies.";
  425. } else {
  426. include_once $base_path."manager/includes/controls/datagrid.class.php";
  427. $grd = new DataGrid('', $ds, 0); // set page size to 0 t show all items
  428. $grd->noRecordMsg = $_lang['no_records_found'];
  429. $grd->cssClass = 'grid';
  430. $grd->columnHeaderClass = 'gridHeader';
  431. $grd->itemClass = 'gridItem';
  432. $grd->altItemClass = 'gridAltItem';
  433. $grd->columns = $_lang['element_name']." ,".$_lang['type'];
  434. $grd->fields = "name,type";
  435. echo $grd->render();
  436. } ?>
  437. </td></tr>
  438. </table>
  439. </div>
  440. <?php } ?>
  441. </div>
  442. </div>
  443. <?php
  444. if ($use_udperms == 1) {
  445. // fetch user access permissions for the module
  446. $groupsarray = array();
  447. $sql = 'SELECT * FROM '.$tbl_site_module_access.' WHERE module=\''.$id.'\'';
  448. $rs = mysql_query($sql);
  449. $limit = mysql_num_rows($rs);
  450. for ($i = 0; $i < $limit; $i++) {
  451. $currentgroup = mysql_fetch_assoc($rs);
  452. $groupsarray[$i] = $currentgroup['usergroup'];
  453. }
  454. if($modx->hasPermission('access_permissions')) { ?>
  455. <!-- User Group Access Permissions -->
  456. <div class="sectionHeader"><?php echo $_lang['group_access_permissions']?></div>
  457. <div class="sectionBody">
  458. <script type="text/javascript">
  459. function makePublic(b) {
  460. var notPublic=false;
  461. var f=document.forms['mutate'];
  462. var chkpub = f['chkallgroups'];
  463. var chks = f['usrgroups[]'];
  464. if (!chks && chkpub) {
  465. chkpub.checked=true;
  466. return false;
  467. } else if (!b && chkpub) {
  468. if(!chks.length) notPublic=chks.checked;
  469. else for(i=0;i<chks.length;i++) if(chks[i].checked) notPublic=true;
  470. chkpub.checked=!notPublic;
  471. } else {
  472. if(!chks.length) chks.checked = (b) ? false : chks.checked;
  473. else for(i=0;i<chks.length;i++) if (b) chks[i].checked=false;
  474. chkpub.checked=true;
  475. }
  476. }
  477. </script>
  478. <p><?php echo $_lang['module_group_access_msg']?></p>
  479. <?php
  480. }
  481. $chk = '';
  482. $sql = "SELECT name, id FROM ".$tbl_membergroup_names;
  483. $rs = mysql_query($sql);
  484. $limit = mysql_num_rows($rs);
  485. for ($i = 0; $i < $limit; $i++) {
  486. $row = mysql_fetch_assoc($rs);
  487. $groupsarray = is_numeric($id) && $id > 0 ? $groupsarray : array();
  488. $checked = in_array($row['id'], $groupsarray);
  489. if($modx->hasPermission('access_permissions')) {
  490. if ($checked) $notPublic = true;
  491. $chks .= '<input type="checkbox" name="usrgroups[]" value="'.$row['id'].'"'.($checked ? ' checked="checked"' : '').' onclick="makePublic(false)" />'.$row['name']."<br />\n";
  492. } else {
  493. if ($checked) $chks = '<input type="hidden" name="usrgroups[]" value="'.$row['id'].'" />' . "\n" . $chks;
  494. }
  495. }
  496. if($modx->hasPermission('access_permissions')) {
  497. $chks = '<input type="checkbox" name="chkallgroups"'.(!$notPublic ? ' checked="checked"' : '').' onclick="makePublic(true)" /><span class="warning">'.$_lang['all_usr_groups'].'</span><br />' . "\n" . $chks;
  498. }
  499. echo $chks;
  500. ?>
  501. </div>
  502. <?php } ?>
  503. <input type="submit" name="save" style="display:none;">
  504. <?php
  505. // invoke OnModFormRender event
  506. $evtOut = $modx->invokeEvent('OnModFormRender', array('id' => $id));
  507. if(is_array($evtOut)) echo implode('',$evtOut);
  508. ?>
  509. </form>
  510. <script type="text/javascript">setTimeout('showParameters();',10);</script>