| Conditions | 32 |
| Paths | 436 |
| Total Lines | 362 |
| Code Lines | 236 |
| Lines | 25 |
| Ratio | 6.91 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 204 | function editDepartment() |
||
| 205 | { |
||
| 206 | $_xhelpSession = Session::singleton(); |
||
| 207 | global $imagearray, $xoopsModule, $limit, $start, $xoopsModuleConfig; |
||
| 208 | $module_id = $xoopsModule->getVar('mid'); |
||
| 209 | $displayName =& $xoopsModuleConfig['xhelp_displayName']; // Determines if username or real name is displayed |
||
| 210 | |||
| 211 | $_xhelpSession->set("xhelp_return_page", substr(strstr($_SERVER['REQUEST_URI'], 'admin/'), 6)); |
||
| 212 | |||
| 213 | View Code Duplication | if(isset($_REQUEST["deptid"])){ |
|
| 214 | $deptID = $_REQUEST['deptid']; |
||
| 215 | } else { |
||
| 216 | redirect_header(XHELP_ADMIN_URL."/department.php?op=manageDepartments", 3, _AM_XHELP_MSG_NO_DEPTID); |
||
| 217 | } |
||
| 218 | |||
| 219 | $hDepartments =& xhelpGetHandler('department'); |
||
| 220 | $hGroups =& xoops_gethandler('group'); |
||
| 221 | $hGroupPerm =& xoops_gethandler('groupperm'); |
||
| 222 | |||
| 223 | if(isset($_POST['updateDept'])){ |
||
| 224 | $groups = (isset($_POST['groups']) ? $_POST['groups'] : array()); |
||
| 225 | |||
| 226 | $hasErrors = false; |
||
| 227 | //Department Name supplied? |
||
| 228 | if (trim($_POST['newDept']) == '') { |
||
| 229 | $hasErrors = true; |
||
| 230 | $errors['newDept'][] = _AM_XHELP_MESSAGE_NO_DEPT; |
||
| 231 | } else { |
||
| 232 | |||
| 233 | //Department Name unique? |
||
| 234 | $crit = new CriteriaCompo(new Criteria('department', $_POST['newDept'])); |
||
| 235 | $crit->add(new Criteria('id', $deptID, '!=')); |
||
| 236 | View Code Duplication | if($existingDepts = $hDepartments->getCount($crit)){ |
|
| 237 | $hasErrors = true; |
||
| 238 | $errors['newDept'][] = _XHELP_MESSAGE_DEPT_EXISTS; |
||
| 239 | |||
| 240 | } |
||
| 241 | } |
||
| 242 | |||
| 243 | if ($hasErrors) { |
||
| 244 | $session =& Session::singleton(); |
||
| 245 | //Store existing dept info in session, reload addition page |
||
| 246 | $aDept = array(); |
||
| 247 | $aDept['newDept'] = $_POST['newDept']; |
||
| 248 | $aDept['groups'] = $groups; |
||
| 249 | $session->set("xhelp_editDepartment_$deptID", $aDept); |
||
| 250 | $session->set("xhelp_editDepartmentErrors_$deptID", $errors); |
||
| 251 | header('Location: '. xhelpMakeURI(XHELP_ADMIN_URL.'/department.php', array('op'=>'editDepartment', 'deptid'=>$deptID), false)); |
||
| 252 | exit(); |
||
| 253 | } |
||
| 254 | |||
| 255 | $dept =& $hDepartments->get($deptID); |
||
| 256 | |||
| 257 | $oldDept = $dept; |
||
| 258 | $groups = $_POST['groups']; |
||
| 259 | |||
| 260 | // Need to remove old group permissions first |
||
| 261 | $crit = new CriteriaCompo(new Criteria('gperm_modid', $module_id)); |
||
| 262 | $crit->add(new Criteria('gperm_itemid', $deptID)); |
||
| 263 | $crit->add(new Criteria('gperm_name', _XHELP_GROUP_PERM_DEPT)); |
||
| 264 | $hGroupPerm->deleteAll($crit); |
||
| 265 | |||
| 266 | foreach($groups as $group){ // Add new group permissions |
||
| 267 | $hGroupPerm->addRight(_XHELP_GROUP_PERM_DEPT, $deptID, $group, $module_id); |
||
| 268 | } |
||
| 269 | |||
| 270 | $dept->setVar('department', $_POST['newDept']); |
||
| 271 | |||
| 272 | if($hDepartments->insert($dept)){ |
||
| 273 | $message = _XHELP_MESSAGE_UPDATE_DEPT; |
||
| 274 | |||
| 275 | // Update default dept |
||
| 276 | if(isset($_POST['defaultDept']) && ($_POST['defaultDept'] == 1)){ |
||
| 277 | xhelpSetMeta("default_department", $dept->getVar('id')); |
||
| 278 | View Code Duplication | } else { |
|
| 279 | $depts =& $hDepartments->getObjects(); |
||
| 280 | $aDepts = array(); |
||
| 281 | foreach($depts as $dpt){ |
||
| 282 | $aDepts[] = $dpt->getVar('id'); |
||
| 283 | } |
||
| 284 | xhelpSetMeta("default_department", $aDepts[0]); |
||
| 285 | } |
||
| 286 | |||
| 287 | // Edit configoption for department |
||
| 288 | $hConfigOption =& xoops_gethandler('configoption'); |
||
| 289 | $crit = new CriteriaCompo(new Criteria('confop_name', $oldDept->getVar('department'))); |
||
| 290 | $crit->add(new Criteria('confop_value', $oldDept->getVar('id'))); |
||
| 291 | $confOption =& $hConfigOption->getObjects($crit); |
||
| 292 | |||
| 293 | if(count($confOption) > 0){ |
||
| 294 | $confOption[0]->setVar('confop_name', $dept->getVar('department')); |
||
| 295 | |||
| 296 | if(!$hConfigOption->insert($confOption[0])){ |
||
| 297 | redirect_header(XHELP_ADMIN_URL."/department.php?op=manageDepartments", 3, _AM_XHELP_MSG_UPDATE_CONFIG_ERR); |
||
| 298 | } |
||
| 299 | } |
||
| 300 | _clearEditSessionVars($deptID); |
||
| 301 | header("Location: ".XHELP_ADMIN_URL."/department.php?op=manageDepartments"); |
||
| 302 | } else { |
||
| 303 | $message = _XHELP_MESSAGE_UPDATE_DEPT_ERROR . $dept->getHtmlErrors(); |
||
| 304 | redirect_header(XHELP_ADMIN_URL."/department.php?op=manageDepartments", 3, $message); |
||
| 305 | } |
||
| 306 | |||
| 307 | } else { |
||
| 308 | xoops_cp_header(); |
||
| 309 | //echo $oAdminButton->renderButtons('manDept'); |
||
| 310 | |||
| 311 | $dept =& $hDepartments->get($deptID); |
||
| 312 | |||
| 313 | $session =& Session::singleton(); |
||
| 314 | $sess_dept = $session->get("xhelp_editDepartment_$deptID"); |
||
| 315 | $sess_errors = $session->get("xhelp_editDepartmentErrors_$deptID"); |
||
| 316 | |||
| 317 | //Display any form errors |
||
| 318 | if (! $sess_errors === false) { |
||
| 319 | xhelpRenderErrors($sess_errors, xhelpMakeURI(XHELP_ADMIN_URL.'/department.php', array('op'=>'clearEditSession', 'deptid'=>$deptID))); |
||
| 320 | } |
||
| 321 | |||
| 322 | $indexAdmin = new ModuleAdmin(); |
||
| 323 | echo $indexAdmin->addNavigation('department.php?op=editDepartment'); |
||
| 324 | |||
| 325 | // Get list of groups with permission |
||
| 326 | $crit = new CriteriaCompo(new Criteria('gperm_modid', $module_id)); |
||
| 327 | $crit->add(new Criteria('gperm_itemid', $deptID)); |
||
| 328 | $crit->add(new Criteria('gperm_name', _XHELP_GROUP_PERM_DEPT)); |
||
| 329 | $group_perms =& $hGroupPerm->getObjects($crit); |
||
| 330 | |||
| 331 | $aPerms = array(); // Put group_perms in usable format |
||
| 332 | foreach($group_perms as $perm){ |
||
| 333 | $aPerms[$perm->getVar('gperm_groupid')] = $perm->getVar('gperm_groupid'); |
||
| 334 | } |
||
| 335 | |||
| 336 | View Code Duplication | if (! $sess_dept === false) { |
|
| 337 | $fld_newDept = $sess_dept['newDept']; |
||
| 338 | $fld_groups = $sess_dept['groups']; |
||
| 339 | } else { |
||
| 340 | $fld_newDept = $dept->getVar('department'); |
||
| 341 | $fld_groups = $aPerms; |
||
| 342 | } |
||
| 343 | |||
| 344 | // Get list of all groups |
||
| 345 | $crit = new Criteria('', ''); |
||
| 346 | $crit->setSort('name'); |
||
| 347 | $crit->setOrder('ASC'); |
||
| 348 | $groups =& $hGroups->getObjects($crit, true); |
||
| 349 | |||
| 350 | $aGroups = array(); |
||
| 351 | foreach($groups as $group_id=>$group){ |
||
| 352 | $aGroups[$group_id] = $group->getVar('name'); |
||
| 353 | } |
||
| 354 | asort($aGroups); // Set groups in alphabetical order |
||
| 355 | |||
| 356 | echo '<script type="text/javascript" src="'.XOOPS_URL.'/modules/xhelp/include/functions.js"></script>'; |
||
| 357 | $form = new xhelpForm(_AM_XHELP_EDIT_DEPARTMENT, 'edit_dept', xhelpMakeURI(XHELP_ADMIN_URL.'/department.php', array('op'=>'editDepartment', 'deptid' => $deptID))); |
||
| 358 | $dept_name = new XoopsFormText(_AM_XHELP_TEXT_EDIT_DEPT, 'newDept', 20, 35, $fld_newDept); |
||
| 359 | $group_select = new XoopsFormSelect(_AM_XHELP_TEXT_EDIT_DEPT_PERMS, 'groups', $fld_groups, 6, true); |
||
| 360 | $group_select->addOptionArray($aGroups); |
||
| 361 | $defaultDeptID = xhelpGetMeta("default_department"); |
||
| 362 | $defaultDept = new xhelpFormCheckbox(_AM_XHELP_TEXT_DEFAULT_DEPT, 'defaultDept', (($defaultDeptID == $deptID) ? 1 : 0), 'defaultDept'); |
||
| 363 | $defaultDept->addOption(1, ""); |
||
| 364 | $btn_tray = new XoopsFormElementTray(''); |
||
| 365 | $btn_tray->addElement(new XoopsFormButton('', 'updateDept', _AM_XHELP_BUTTON_SUBMIT, 'submit')); |
||
| 366 | $form->addElement($dept_name); |
||
| 367 | $form->addElement($group_select); |
||
| 368 | $form->addElement($defaultDept); |
||
| 369 | $form->addElement($btn_tray); |
||
| 370 | $form->setLabelWidth('20%'); |
||
| 371 | echo $form->render(); |
||
| 372 | |||
| 373 | // Get dept staff members |
||
| 374 | $hMembership =& xhelpGetHandler('membership'); |
||
| 375 | $hMember =& xoops_gethandler('member'); |
||
| 376 | $hStaffRole =& xhelpGetHandler('staffRole'); |
||
| 377 | $hRole =& xhelpGetHandler('role'); |
||
| 378 | |||
| 379 | $staff = $hMembership->membershipByDept($deptID, $limit, $start); |
||
| 380 | $crit = new Criteria('j.department', $deptID); |
||
| 381 | $staffCount =& $hMembership->getCount($crit); |
||
| 382 | $roles =& $hRole->getObjects(null, true); |
||
| 383 | |||
| 384 | echo "<form action='".XHELP_ADMIN_URL."/department.php?op=deleteStaffDept&deptid=".$deptID."' method='post'>"; |
||
| 385 | echo "<table width='100%' cellspacing='1' class='outer'> |
||
| 386 | <tr><th colspan='".(3+count($roles))."'><label>". _AM_XHELP_MANAGE_STAFF ."</label></th></tr>"; |
||
| 387 | |||
| 388 | if($staffCount > 0){ |
||
| 389 | $aStaff = array(); |
||
| 390 | foreach($staff as $stf){ |
||
| 391 | $aStaff[$stf->getVar('uid')] = $stf->getVar('uid'); // Get array of staff uid |
||
| 392 | } |
||
| 393 | |||
| 394 | // Get user list |
||
| 395 | $crit = new Criteria('uid', "(". implode($aStaff, ',') .")", "IN"); |
||
| 396 | //$members =& $hMember->getUserList($crit); |
||
| 397 | $members =& xhelpGetUsers($crit, $displayName); |
||
| 398 | |||
| 399 | // Get staff roles |
||
| 400 | $crit = new CriteriaCompo(new Criteria('uid', "(". implode($aStaff, ',') .")", "IN")); |
||
| 401 | $crit->add(new Criteria('deptid', $deptID)); |
||
| 402 | $staffRoles =& $hStaffRole->getObjects($crit); |
||
| 403 | unset($aStaff); |
||
| 404 | |||
| 405 | $staffInfo = array(); |
||
| 406 | foreach($staff as $stf){ |
||
| 407 | $staff_uid = $stf->getVar('uid'); |
||
| 408 | $staffInfo[$staff_uid]['uname'] = $members[$staff_uid]; |
||
| 409 | $aRoles = array(); |
||
| 410 | foreach($staffRoles as $role){ |
||
| 411 | $role_id = $role->getVar('roleid'); |
||
| 412 | if($role->getVar('uid') == $staff_uid){ |
||
| 413 | $aRoles[$role_id] = $roles[$role_id]->getVar('name'); |
||
| 414 | } |
||
| 415 | $staffInfo[$staff_uid]['roles'] = implode($aRoles, ', '); |
||
| 416 | } |
||
| 417 | } |
||
| 418 | $nav = new XoopsPageNav($staffCount, $limit, $start, 'start', "op=editDepartment&deptid=$deptID&limit=$limit"); |
||
| 419 | |||
| 420 | echo "<tr class='head'><td rowspan='2'>"._AM_XHELP_TEXT_ID."</td><td rowspan='2'>"._AM_XHELP_TEXT_USER."</td><td colspan='".count($roles)."'>"._AM_XHELP_TEXT_ROLES."</td><td rowspan='2'>"._AM_XHELP_TEXT_ACTIONS."</td></tr>"; |
||
| 421 | echo "<tr class='head'>"; |
||
| 422 | foreach ($roles as $thisrole) echo "<td>".$thisrole->getVar('name')."</td>"; |
||
| 423 | echo "</tr>"; |
||
| 424 | foreach($staffInfo as $uid=>$staff){ |
||
| 425 | echo "<tr class='even'> |
||
| 426 | <td><input type='checkbox' name='staff[]' value='".$uid."' />".$uid."</td> |
||
| 427 | <td>".$staff['uname']."</td>"; |
||
| 428 | foreach ($roles as $thisrole) { |
||
| 429 | echo "<td><img src='".XHELP_BASE_URL."/images/"; |
||
| 430 | echo (in_array($thisrole->getVar('name'),explode(', ',$staff['roles']))) ? "on.png" : "off.png"; |
||
| 431 | echo "' /></td>"; |
||
| 432 | } |
||
| 433 | echo " <td> |
||
| 434 | <a href='".XHELP_ADMIN_URL."/staff.php?op=editStaff&uid=".$uid."'><img src='".XOOPS_URL."/modules/xhelp/images/button_edit.png' title='"._AM_XHELP_TEXT_EDIT."' name='editStaff' /></a> |
||
| 435 | <a href='".XHELP_ADMIN_URL."/department.php?op=deleteStaffDept&uid=".$uid."&deptid=".$deptID."'><img src='".XOOPS_URL."/modules/xhelp/images/button_delete.png' title='"._AM_XHELP_TEXT_DELETE_STAFF_DEPT."' name='deleteStaffDept' /></a> |
||
| 436 | </td> |
||
| 437 | </tr>"; |
||
| 438 | } |
||
| 439 | echo "<tr> |
||
| 440 | <td class='foot' colspan='".(3+count($roles))."'> |
||
| 441 | <input type='checkbox' name='checkallRoles' value='0' onclick='selectAll(this.form,\"staff[]\",this.checked);' /> |
||
| 442 | <input type='submit' name='deleteStaff' id='deleteStaff' value='"._AM_XHELP_BUTTON_DELETE."' /> |
||
| 443 | </td> |
||
| 444 | </tr>"; |
||
| 445 | echo "</table></form>"; |
||
| 446 | echo "<div id='staff_nav'>".$nav->renderNav()."</div>"; |
||
| 447 | } else { |
||
| 448 | echo "</table></form>"; |
||
| 449 | } |
||
| 450 | |||
| 451 | //now do the list of servers |
||
| 452 | $hDeptServers =& xhelpGetHandler('departmentMailBox'); |
||
| 453 | $deptServers =& $hDeptServers->getByDepartment($deptID); |
||
| 454 | //iterate |
||
| 455 | if (count($deptServers) > 0) { |
||
| 456 | echo "<br /><table width='100%' cellspacing='1' class='outer'> |
||
| 457 | <tr> |
||
| 458 | <th colspan='5'><label>". _AM_XHELP_DEPARTMENT_SERVERS ."</label></th> |
||
| 459 | </tr> |
||
| 460 | <tr> |
||
| 461 | <td class='head' width='20%'><label>". _AM_XHELP_DEPARTMENT_SERVERS_EMAIL ."</label></td> |
||
| 462 | <td class='head'><label>". _AM_XHELP_DEPARTMENT_SERVERS_TYPE ."</label></td> |
||
| 463 | <td class='head'><label>". _AM_XHELP_DEPARTMENT_SERVERS_SERVERNAME ."</label></td> |
||
| 464 | <td class='head'><label>". _AM_XHELP_DEPARTMENT_SERVERS_PORT ."</label></td> |
||
| 465 | <td class='head'><label>". _AM_XHELP_DEPARTMENT_SERVERS_ACTION ."</label></td> |
||
| 466 | </tr>"; |
||
| 467 | $i = 0; |
||
| 468 | foreach($deptServers as $server){ |
||
| 469 | if ($server->getVar('active')) { |
||
| 470 | $activ_link = '".XHELP_ADMIN_URL."/department.php?op=activateMailbox&setstate=0&id='. $server->getVar('id'); |
||
| 471 | $activ_img = $imagearray['online']; |
||
| 472 | $activ_title = _AM_XHELP_MESSAGE_DEACTIVATE; |
||
| 473 | } else { |
||
| 474 | $activ_link = '".XHELP_ADMIN_URL."/department.php?op=activateMailbox&setstate=1&id='. $server->getVar('id'); |
||
| 475 | $activ_img = $imagearray['offline']; |
||
| 476 | $activ_title = _AM_XHELP_MESSAGE_ACTIVATE; |
||
| 477 | } |
||
| 478 | |||
| 479 | echo '<tr class="even"> |
||
| 480 | <td>'.$server->getVar('emailaddress').'</td> |
||
| 481 | <td>'.xhelpGetMBoxType($server->getVar('mboxtype')).'</td> |
||
| 482 | <td>'.$server->getVar('server').'</td> |
||
| 483 | <td>'.$server->getVar('serverport').'</td> |
||
| 484 | <td> <a href="'. $activ_link.'" title="'. $activ_title.'">'. $activ_img.'</a> |
||
| 485 | <a href="'.XHELP_ADMIN_URL.'/department.php?op=EditDepartmentServer&id='.$server->GetVar('id').'">'.$imagearray['editimg'].'</a> |
||
| 486 | <a href="'.XHELP_ADMIN_URL.'/department.php?op=DeleteDepartmentServer&id='.$server->GetVar('id').'">'.$imagearray['deleteimg'].'</a> |
||
| 487 | |||
| 488 | </td> |
||
| 489 | </tr>'; |
||
| 490 | } |
||
| 491 | echo '</table>'; |
||
| 492 | } |
||
| 493 | //finally add Mailbox form |
||
| 494 | echo "<br /><br />"; |
||
| 495 | |||
| 496 | $formElements = array('type_select', 'server_text', 'port_text', 'username_text', 'pass_text', 'priority_radio', |
||
| 497 | 'email_text', 'btn_tray'); |
||
| 498 | $form = new xhelpForm(_AM_XHELP_DEPARTMENT_ADD_SERVER, 'add_server', xhelpMakeURI(XHELP_ADMIN_URL.'/department.php', array('op'=>'AddDepartmentServer', 'id' => $deptID))); |
||
| 499 | |||
| 500 | $type_select = new XoopsFormSelect(_AM_XHELP_DEPARTMENT_SERVERS_TYPE, 'mboxtype'); |
||
| 501 | $type_select->setExtra("id='mboxtype'"); |
||
| 502 | $type_select->addOption(_XHELP_MAILBOXTYPE_POP3, _AM_XHELP_MBOX_POP3); |
||
| 503 | |||
| 504 | $server_text = new XoopsFormText(_AM_XHELP_DEPARTMENT_SERVERS_SERVERNAME, 'server', 40, 50); |
||
| 505 | $server_text->setExtra("id='txtServer'"); |
||
| 506 | |||
| 507 | $port_text = new XoopsFormText(_AM_XHELP_DEPARTMENT_SERVERS_PORT, 'port', 5, 5, "110"); |
||
| 508 | $port_text->setExtra("id='txtPort'"); |
||
| 509 | |||
| 510 | $username_text = new XoopsFormText(_AM_XHELP_DEPARTMENT_SERVER_USERNAME, 'username', 25, 50); |
||
| 511 | $username_text->setExtra("id='txtUsername'"); |
||
| 512 | |||
| 513 | $pass_text = new XoopsFormText(_AM_XHELP_DEPARTMENT_SERVER_PASSWORD, 'password', 25, 50); |
||
| 514 | $pass_text->setExtra("id='txtPassword'"); |
||
| 515 | |||
| 516 | $priority_radio = new xhelpFormRadio(_AM_XHELP_DEPARTMENT_SERVERS_PRIORITY, 'priority', XHELP_DEFAULT_PRIORITY); |
||
| 517 | $priority_array = array('1' => "<label for='priority1'><img src='".XHELP_IMAGE_URL."/priority1.png' title='". xhelpGetPriority(1)."' alt='priority1' /></label>", |
||
| 518 | '2' => "<label for='priority2'><img src='".XHELP_IMAGE_URL."/priority2.png' title='". xhelpGetPriority(2)."' alt='priority2' /></label>", |
||
| 519 | '3' => "<label for='priority3'><img src='".XHELP_IMAGE_URL."/priority3.png' title='". xhelpGetPriority(3)."' alt='priority3' /></label>", |
||
| 520 | '4' => "<label for='priority4'><img src='".XHELP_IMAGE_URL."/priority4.png' title='". xhelpGetPriority(4)."' alt='priority4' /></label>", |
||
| 521 | '5' => "<label for='priority5'><img src='".XHELP_IMAGE_URL."/priority5.png' title='". xhelpGetPriority(5)."' alt='priority5' /></label>"); |
||
| 522 | $priority_radio->addOptionArray($priority_array); |
||
| 523 | |||
| 524 | $email_text = new XoopsFormText(_AM_XHELP_DEPARTMENT_SERVER_EMAILADDRESS, 'emailaddress', 50, 255); |
||
| 525 | $email_text->setExtra("id='txtEmailaddress'"); |
||
| 526 | |||
| 527 | $btn_tray = new XoopsFormElementTray(''); |
||
| 528 | $test_button = new XoopsFormButton('', 'email_test', _AM_XHELP_BUTTON_TEST, 'button'); |
||
| 529 | $test_button->setExtra("id='test'"); |
||
| 530 | $submit_button = new XoopsFormButton('', 'updateDept2', _AM_XHELP_BUTTON_SUBMIT, 'submit'); |
||
| 531 | $cancel2_button = new XoopsFormButton('', 'cancel2', _AM_XHELP_BUTTON_CANCEL, 'button'); |
||
| 532 | $cancel2_button->setExtra("onclick='history.go(-1)'"); |
||
| 533 | $btn_tray->addElement($test_button); |
||
| 534 | $btn_tray->addElement($submit_button); |
||
| 535 | $btn_tray->addElement($cancel2_button); |
||
| 536 | |||
| 537 | $form->setLabelWidth('20%'); |
||
| 538 | foreach($formElements as $element){ |
||
| 539 | $form->addElement($$element); |
||
| 540 | } |
||
| 541 | echo $form->render(); |
||
| 542 | |||
| 543 | echo "<script type=\"text/javascript\" language=\"javascript\"> |
||
| 544 | <!-- |
||
| 545 | function xhelpEmailTest() |
||
| 546 | { |
||
| 547 | pop = openWithSelfMain(\"\", \"email_test\", 250, 150); |
||
| 548 | frm = xoopsGetElementById(\"add_server\"); |
||
| 549 | newaction = \"department.php?op=testMailbox\"; |
||
| 550 | oldaction = frm.action; |
||
| 551 | frm.action = newaction; |
||
| 552 | frm.target = \"email_test\"; |
||
| 553 | frm.submit(); |
||
| 554 | frm.action = oldaction; |
||
| 555 | frm.target = \"main\"; |
||
| 556 | |||
| 557 | } |
||
| 558 | |||
| 559 | xhelpDOMAddEvent(xoopsGetElementById(\"email_test\"), \"click\", xhelpEmailTest, false); |
||
| 560 | |||
| 561 | //--> |
||
| 562 | </script>"; |
||
| 563 | include_once "admin_footer.php"; |
||
| 564 | } |
||
| 565 | } |
||
| 566 | |||
| 986 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.