![]() |
|---|
| [ Index ] |
Source Code Reference for V1.00 |
[Summary view] [Print] [Text view]
1 <?php /* $Id: configure.php 40 2008-02-11 12:11:44Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/projectdesigner/configure.php $ */ 2 if (!defined('W2P_BASE_DIR')) { 3 die('You should not access this file directly.'); 4 } 5 /* This file will write a php config file to be included during execution of 6 * all Project designer files which require the configuration options. */ 7 global $m; 8 9 // Deny all but system admins 10 if (getDenyEdit('system')) { 11 $AppUI->redirect('m=public&a=access_denied'); 12 } 13 14 $utypes = w2PgetSysVal('UserType'); 15 16 $CONFIG_FILE = W2P_BASE_DIR . '/modules/projectdesigner/config.php'; 17 18 $AppUI->savePlace(); 19 20 //define user type list 21 $user_types = arrayMerge($utypes, array('9' => $AppUI->_('None'))); 22 23 $config_options = array('heading1' => $AppUI->_('General Options'), 'show_task_descriptions' => array('description' => $AppUI->_('Show Full Task Description Column'), 'value' => '1', 'type' => 'radio', 'buttons' => array(1 => $AppUI->_('Yes'), 0 => $AppUI->_('No'))), 'chars_task_descriptions' => array('description' => $AppUI->_('Description Length on Tooltip'), 'value' => '200', 'type' => 'text'), ); 24 25 //if this is a submitted page, overwrite the config file. 26 if (w2PgetParam($_POST, 'Save', '') != '') { 27 28 if (is_writable($CONFIG_FILE)) { 29 if (!$handle = fopen($CONFIG_FILE, 'w')) { 30 $AppUI->setMsg($CONFIG_FILE . ' ' . $AppUI->_('cannot be opened'), UI_MSG_ERROR); 31 exit; 32 } 33 34 if (fwrite($handle, "<?php //Do not edit this file by hand, it will be overwritten by the configuration utility. \n") === false) { 35 $AppUI->setMsg($CONFIG_FILE . ' ' . $AppUI->_('cannot be written to'), UI_MSG_ERROR); 36 exit; 37 } else { 38 foreach ($config_options as $key => $value) { 39 if (substr($key, 0, 7) == 'heading') 40 continue; 41 42 $val = ''; 43 switch ($value['type']) { 44 case 'checkbox': 45 $val = isset($_POST[$key]) ? '1': 46 '0'; 47 break; 48 case 'text': 49 $val = isset($_POST[$key]) ? $_POST[$key]: 50 ''; 51 break; 52 case 'longtext': 53 $val = isset($_POST[$key]) ? $_POST[$key]: 54 ''; 55 break; 56 case 'select': 57 $val = isset($_POST[$key]) ? $_POST[$key]: 58 '0'; 59 break; 60 case 'radio': 61 $val = $_POST[$key]; 62 break; 63 default: 64 break; 65 } 66 67 fwrite($handle, "\$PROJDESIGN_CONFIG['" . $key . "'] = '" . $val . "';\n"); 68 } 69 70 fwrite($handle, "?>\n"); 71 $AppUI->setMsg($CONFIG_FILE . ' ' . $AppUI->_('has been successfully updated'), UI_MSG_OK); 72 fclose($handle); 73 require ($CONFIG_FILE); 74 } 75 } else { 76 $AppUI->setMsg($CONFIG_FILE . ' ' . $AppUI->_('is not writable'), UI_MSG_ERROR); 77 } 78 } elseif (w2PgetParam($_POST, $AppUI->_('Cancel'), '') != '') { 79 $AppUI->redirect('m=system&a=viewmods'); 80 } 81 82 //$PROJDESIGN_CONFIG = array(); 83 include ($CONFIG_FILE); 84 85 //Read the current config values from the config file and update the array. 86 foreach ($config_options as $key => $value) { 87 if (isset($PROJDESIGN_CONFIG[$key])) { 88 89 $config_options[$key]['value'] = $PROJDESIGN_CONFIG[$key]; 90 } 91 } 92 93 // setup the title block 94 $titleBlock = new CTitleBlock('Project Designer Module Configuration', 'projectdesigner.png', $m, $m . '.' . $a); 95 $titleBlock->addCrumb('?m=system', 'System Admin'); 96 $titleBlock->addCrumb('?m=system&a=viewmods', 'Modules'); 97 $titleBlock->show(); 98 99 ?> 100 101 <form method="post"> 102 <table class="std"> 103 <?php 104 foreach ($config_options as $key => $value) { 105 ?> 106 <tr> 107 <?php 108 // the key starts with hr, then just display the value 109 if (substr($key, 0, 7) == 'heading') { ?> 110 <th align="center" colspan="2"><?php echo $value?></th> 111 <?php } else { ?> 112 <td align="right"><?php echo $value['description']?></td> 113 <td><?php 114 switch ($value['type']) { 115 case 'checkbox': ?> 116 <input type="checkbox" name="<?=$key?>" <?php echo $value['value']?"checked=\"checked\"":""?> /> 117 <?php 118 break; 119 case 'text': ?> 120 <input type="text" name="<?=$key?>" style="<?php echo $value['style']?>" value="<?php echo $value['value']?>" /> 121 <?php 122 break; 123 case 'longtext': ?> 124 <input type="text" size="70" name="<?=$key?>" style="<?php echo $value['style']?>" value="<?php echo $value['value']?>" /> 125 <?php 126 break; 127 case 'select': 128 print arraySelect($value["list"], $key, 'class="text" size="1" id="' . $key . '" ' . $value["events"], $value["value"]); 129 break; 130 case 'radio': 131 foreach ($value['buttons'] as $v => $n) { ?> 132 <label><input type="radio" name="<?php echo $key; ?>" id="<?php echo $key; ?>" value="<?php echo $v; ?>" <?php echo (($value['value'] == $v) ? 'checked="checked"' : ''); ?> <?php echo $value['events']; ?> /> <?php echo $n; ?></label> 133 <?php } 134 break; 135 default: 136 break; 137 } 138 ?></td> 139 <?php 140 } 141 ?> 142 </tr> 143 <?php 144 } 145 ?> 146 <tr> 147 <td colspan="2" align="right"><input type="Submit" name="Cancel" value="<?php echo $AppUI->_('back')?>" /><input type="Submit" name="Save" value="<?php echo $AppUI->_('save')?>" /></td> 148 </tr> 149 </table> 150 </form>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Fri Jan 9 03:00:02 2009 | Cross-referenced by PHPXref 0.7 |