Code Duplication    Length = 8-9 lines in 2 locations

admin/department.php 1 location

@@ 278-285 (lines=8) @@
275
            // Update default dept
276
            if(isset($_POST['defaultDept']) && ($_POST['defaultDept'] == 1)){
277
                xhelpSetMeta("default_department", $dept->getVar('id'));
278
            } 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');

admin/upgrade.php 1 location

@@ 519-527 (lines=9) @@
516
            $xoopsModuleConfig =& xhelpGetModuleConfig();
517
            if(isset($xoopsModuleConfig['xhelp_defaultDept']) && $xoopsModuleConfig['xhelp_defaultDept'] != 0){
518
                $ret = xhelpSetMeta('default_department', $xoopsModuleConfig['xhelp_defaultDept']);
519
            } else {
520
                $hDepartments =& xhelpGetHandler('department');
521
                $depts =& $hDepartments->getObjects();
522
                $aDepts = array();
523
                foreach($depts as $dpt){
524
                    $aDepts[] = $dpt->getVar('id');
525
                }
526
                $ret = xhelpSetMeta("default_department", $aDepts[0]);
527
            }
528
529
            $qry = $xoopsDB->query(sprintf("ALTER TABLE %s DROP PRIMARY KEY", $xoopsDB->prefix('xhelp_ticket_submit_emails')));
530
            $ret = $ret && _runQuery(sprintf("ALTER TABLE %s ADD PRIMARY KEY(ticketid, uid, email)", $xoopsDB->prefix('xhelp_ticket_submit_emails')),