Changeset 15347 for trunk/administration
- Timestamp:
- 07/14/11 03:07:34 (11 months ago)
- File:
-
- 1 edited
-
trunk/administration/memb_levels.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/administration/memb_levels.php
r15331 r15347 100 100 $_page_cont[$iNameIndex] = array( 101 101 'page_code_settings' => PageCodeSettings($mixedResultSettings), 102 'page_code_create' => PageCodeCreate( ),102 'page_code_create' => PageCodeCreate(bx_get('action') !== false && bx_get('action') == 'edit' ? $iLevelId : 0), 103 103 'page_code_available' => PageCodeAvailable($mixedResultAvailable), 104 104 'page_code_actions' => bx_get('action') !== false && bx_get('action') == 'actions' && $iLevelId > 0 ? PageCodeActions($iLevelId, $mixedResultActions) : "", … … 115 115 return DesignBoxAdmin(_t('_adm_box_cpt_mlevel_settings'), $sResult); 116 116 } 117 function PageCodeCreate() { 117 function PageCodeCreate($iLevelId = 0) { 118 $sSubmitUrl = $GLOBALS['site']['url_admin'] . 'memb_levels.php'; 119 120 $aLevel = array(); 121 if(($bEdit = $iLevelId != 0) === true) 122 $aLevel = $GLOBALS['MySQL']->getRow("SELECT `Name` AS `Name`, `Description` AS `Description`, `Order` AS `Order` FROM `sys_acl_levels` WHERE `ID`='" . $iLevelId . "' LIMIT 1"); 123 118 124 $aForm = array( 119 125 'form_attrs' => array( 120 126 'id' => 'adm-mlevels-create', 121 'action' => $ GLOBALS['site']['url_admin'] . 'memb_levels.php',127 'action' => $sSubmitUrl, 122 128 'method' => 'post', 123 129 'enctype' => 'multipart/form-data', … … 129 135 'uri' => '', 130 136 'uri_title' => '', 131 'submit_name' => ' submit'137 'submit_name' => 'Submit' 132 138 ), 133 139 ), 134 'inputs' => array ( 140 'inputs' => array ( 135 141 'Active' => array( 136 142 'type' => 'hidden', … … 159 165 'Name' => array( 160 166 'type' => 'text', 161 'name' => ' name',167 'name' => 'Name', 162 168 'caption' => _t('_adm_txt_mlevels_name'), 163 'value' => '',169 'value' => isset($aLevel['Name']) ? $aLevel['Name'] : '', 164 170 'db' => array ( 165 171 'pass' => 'Xss', … … 184 190 'Description' => array( 185 191 'type' => 'textarea', 186 'name' => ' description',192 'name' => 'Description', 187 193 'caption' => _t('_adm_txt_mlevels_description'), 188 'value' => '',194 'value' => isset($aLevel['Description']) ? $aLevel['Description'] : '', 189 195 'db' => array ( 190 196 'pass' => 'XssHtml', 191 197 ), 192 198 ), 193 'submit' => array( 199 'Order' => array( 200 'type' => 'text', 201 'name' => 'Order', 202 'caption' => _t('_adm_txt_mlevels_order'), 203 'value' => isset($aLevel['Order']) ? $aLevel['Order'] : 0, 204 'db' => array ( 205 'pass' => 'Int', 206 ), 207 'checker' => array ( 208 'func' => 'preg', 209 'params' => array('/^[1-9][0-9]*$/'), 210 'error' => _t('_adm_txt_mlevels_order_err'), 211 ), 212 ), 213 'Submit' => array( 194 214 'type' => 'submit', 195 'name' => ' submit',215 'name' => 'Submit', 196 216 'value' => _t('_adm_btn_mlevels_add'), 197 ), 217 ), 198 218 ) 199 219 ); 220 221 //--- Convert Add to Edit 222 if($bEdit) { 223 unset($aForm['inputs']['Active']); 224 unset($aForm['inputs']['Purchasable']); 225 unset($aForm['inputs']['Removable']); 226 unset($aForm['inputs']['Icon']); 227 228 $aForm['form_attrs']['action'] .= '?action=edit&level=' . $iLevelId; 229 $aForm['inputs']['Submit']['value'] = _t('_adm_btn_mlevels_save'); 230 $aForm['inputs']['ID'] = array( 231 'type' => 'hidden', 232 'name' => 'ID', 233 'value' => $iLevelId, 234 'db' => array ( 235 'pass' => 'Int', 236 ) 237 ); 238 } 239 200 240 $oForm = new BxTemplFormView($aForm); 201 241 $oForm->initChecker(); 202 242 203 $bFile = true; 204 $sFilePath = BX_DIRECTORY_PATH_ROOT . 'media/images/membership/'; 205 $sFileName = time(); 206 $sFileExt = ''; 207 if($oForm->isSubmittedAndValid() && $bFile = (isImage($_FILES['Icon']['type'], $sFileExt) && !empty($_FILES['Icon']['tmp_name']) && move_uploaded_file($_FILES['Icon']['tmp_name'], $sFilePath . $sFileName . '.' . $sFileExt))) { 208 $sPath = $sFilePath . $sFileName . '.' . $sFileExt; 209 imageResize($sPath, $sPath, 110, 110); 210 211 $iId = (int)$oForm->insert(array('Icon' => $sFileName . '.' . $sFileExt)); 212 if($iId != 0) 213 addStringToLanguage("_adm_txt_mp_" . strtolower(bx_get('name')), bx_get('name')); 214 215 header('Location: ' . $oForm->aFormAttrs['action']); 216 } else { 217 if(!$bFile) 218 $oForm->aInputs['Icon']['error'] = $oForm->aInputs['Icon']['checker']['error']; 219 220 return DesignBoxAdmin(_t('_adm_box_cpt_mlevel_create'), $GLOBALS['oAdmTemplate']->parseHtmlByName('design_box_content.html', array('content' => $oForm->getCode()))); 243 if($oForm->isSubmittedAndValid()) { 244 //--- Add new level 245 if(!$bEdit) { 246 $sFilePath = BX_DIRECTORY_PATH_ROOT . 'media/images/membership/'; 247 $sFileName = time(); 248 $sFileExt = ''; 249 250 if(isImage($_FILES['Icon']['type'], $sFileExt) && !empty($_FILES['Icon']['tmp_name']) && move_uploaded_file($_FILES['Icon']['tmp_name'], $sFilePath . $sFileName . '.' . $sFileExt)) { 251 $sPath = $sFilePath . $sFileName . '.' . $sFileExt; 252 imageResize($sPath, $sPath, 110, 110); 253 254 $iId = (int)$oForm->insert(array('Icon' => $sFileName . '.' . $sFileExt)); 255 if($iId != 0) { 256 $sName = $oForm->getCleanValue('Name'); 257 addStringToLanguage('_adm_txt_mp_' . strtolower($sName), $sName); 258 } 259 260 header('Location: ' . $sSubmitUrl); 261 exit; 262 } 263 else 264 $oForm->aInputs['Icon']['error'] = $oForm->aInputs['Icon']['checker']['error']; 265 } 266 //--- Edit existing level 267 else { 268 $bResult = $oForm->update($iLevelId); 269 if($bResult !== false) { 270 deleteStringFromLanguage('_adm_txt_mp_' . strtolower($aLevel['Name'])); 271 272 $sName = $oForm->getCleanValue('Name'); 273 addStringToLanguage('_adm_txt_mp_' . strtolower($sName), $sName); 274 } 275 276 header('Location: ' . $sSubmitUrl); 277 exit; 278 } 221 279 } 280 281 return DesignBoxAdmin(_t(!$bEdit ? '_adm_box_cpt_mlevel_create' : '_adm_box_cpt_mlevel_edit'), $GLOBALS['oAdmTemplate']->parseHtmlByName('design_box_content.html', array('content' => $oForm->getCode()))); 222 282 } 223 283 function PageCodeAvailable($mixedResult) {
Note: See TracChangeset
for help on using the changeset viewer.