Passed
Push — master ( 2ecc51...c1b656 )
by Michael
04:26 queued 02:02
created
admin/fieldtypes.php 1 patch
Switch Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -281,18 +281,18 @@
 block discarded – undo
281 281
     $op = $_POST['op'];
282 282
 }
283 283
 switch ($op) {
284
-    case 'view':
285
-        viewFieldtype();
286
-        break;
287
-    case 'editFieldtype':
288
-        editFieldtype();
289
-        break;
290
-    case 'addFieldtype':
291
-        addFieldtype();
292
-        break;
293
-    default:
294
-        fieldtypesConfig();
295
-        break;
284
+    	case 'view':
285
+        	viewFieldtype();
286
+        	break;
287
+    	case 'editFieldtype':
288
+        	editFieldtype();
289
+        	break;
290
+    	case 'addFieldtype':
291
+        	addFieldtype();
292
+        	break;
293
+    	default:
294
+        	fieldtypesConfig();
295
+        	break;
296 296
 }
297 297
 
298 298
 function getCatOverview()
Please login to merge, or discard this patch.
admin/main.php 1 patch
Switch Indentation   +269 added lines, -269 removed lines patch added patch discarded remove patch
@@ -301,275 +301,275 @@
 block discarded – undo
301 301
     $op = $_POST['op'];
302 302
 }
303 303
 switch ($op) {
304
-    case 'approve':
305
-        approve();
306
-        break;
307
-    case 'deleteListingConfirm':
308
-        delListingConfirm();
309
-        break;
310
-    case 'deleteListing':
311
-        delListing();
312
-        break;
313
-    case 'delVote':
314
-        delVote();
315
-        break;
316
-    case 'listNewListings':
317
-        listNewListings();
318
-        break;
319
-    case 'updateItemType':
320
-        updateItemType();
321
-        break;
322
-    case 'duplicateDataTypes':
323
-        listDuplicateDataTypes();
324
-        break;
325
-    case 'mergeDuplicates':
326
-        mergeDuplicates();
327
-        break;
328
-    case 'edit':
329
-        global $xoopsDB, $xoopsConfig, $myts, $eh, $efqtree, $moddir, $xoopsUser, $datafieldmanager, $subscription, $subscriptionhandler;
330
-        $sql         = 'SELECT i.itemid, i.logourl, i.uid, i.status, i.created, i.title, i.typeid, t.description FROM '
331
-                       . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_items')
332
-                       . ' i LEFT JOIN '
333
-                       . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_item_text')
334
-                       . ' t ON (i.itemid=t.itemid) WHERE i.itemid='
335
-                       . $get_itemid
336
-                       . '';
337
-        $item_result = $xoopsDB->query($sql);
338
-        $numrows     = $xoopsDB->getRowsNum($item_result);
339
-        xoops_cp_header();
340
-        //adminmenu(-1, _MD_A_MODADMIN_HOME);
341
-        echo "<hr size='1'><br>";
342
-        while (list($itemid, $logourl, $submitter, $status, $created, $itemtitle, $typeid, $description) = $xoopsDB->fetchRow($item_result)) {
343
-            if ($status == '1') {
344
-                echo '<input type="button" value="' . _MD_APPROVE . "\" onclick=\"location='main.php?op=approve&amp;item=$get_itemid'\">&nbsp;";
345
-            }
346
-            echo '&nbsp;<input type="button" value="'
347
-                 . _MD_DELETE
348
-                 . "\" onClick=\"location='main.php?op=deleteListingConfirm&amp;item=$get_itemid'\">&nbsp;<input type=\"button\" value=\""
349
-                 . _MD_VIEWITEM
350
-                 . "\" onclick=\"location='"
351
-                 . XOOPS_URL
352
-                 . '/modules/'
353
-                 . $moddir
354
-                 . "/listing.php?item=$get_itemid'\"><br><br>";
355
-
356
-            $sql         = 'SELECT DISTINCT t.dtypeid, t.title, t.section, f.typeid, f.fieldtype, f.ext, t.options, d.itemid, d.value, d.customtitle, t.custom ';
357
-            $sql         .= 'FROM '
358
-                            . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_item_x_cat')
359
-                            . ' ic, '
360
-                            . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_dtypes_x_cat')
361
-                            . ' xc, '
362
-                            . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_fieldtypes')
363
-                            . ' f, '
364
-                            . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_dtypes')
365
-                            . ' t ';
366
-            $sql         .= 'LEFT JOIN ' . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_data') . ' d ON (t.dtypeid=d.dtypeid AND d.itemid=' . $get_itemid . ') ';
367
-            $sql         .= "WHERE ic.cid=xc.cid AND ic.active='1' AND xc.dtypeid=t.dtypeid AND t.fieldtypeid=f.typeid AND t.activeyn='1' AND ic.itemid=" . $get_itemid . '';
368
-            $data_result = $xoopsDB->query($sql) or $eh->show('0013');
369
-            $numrows     = $xoopsDB->getRowsNum($data_result);
370
-
371
-            $form = new XoopsThemeForm(_MD_EDITITEM_FORM, 'editform', 'main.php');
372
-            $form->addElement(new XoopsFormText(_MD_TITLE, 'itemtitle', 50, 250, $itemtitle), true);
373
-            //$categories = getCategoriesPaths($get_itemid);
374
-            $get_dirid  = getDirIdFromItem($itemid);
375
-            $categories = getCatSelectArea($itemid, $get_dirid);
376
-            $form_cats  = new XoopsFormLabel(_MD_ITEMCATEGORIES, "$categories");
377
-            $form->addElement($form_cats);
378
-            $form->addElement(new XoopsFormDhtmlTextArea(_MD_DESCRIPTION, 'description', $description, 5, 50));
379
-            while (list($dtypeid, $title, $section, $ftypeid, $fieldtype, $ext, $options, $itemid, $value, $customtitle, $custom) = $xoopsDB->fetchRow($data_result)) {
380
-                $field = $datafieldmanager->createField($title, $dtypeid, $fieldtype, $ext, $options, $value, $custom, $customtitle);
381
-            }
382
-            $form->addElement(new XoopsFormButton('', 'submit', _MD_SAVE, 'submit'));
383
-            $form->addElement(new XoopsFormHidden('op', 'save'));
384
-            $form->addElement(new XoopsFormHidden('itemid', $get_itemid));
385
-            $form->addElement(new XoopsFormHidden('dirid', $get_dirid));
386
-            $form->addElement(new XoopsFormHidden('ini_itemtitle', $itemtitle));
387
-            $form->addElement(new XoopsFormHidden('uid', $xoopsUser->getVar('uid')));
388
-            if ($description === false) {
389
-                $form->addElement(new XoopsFormHidden('description_set', '0'));
390
-            } else {
391
-                $form->addElement(new XoopsFormHidden('description_set', '1'));
392
-            }
393
-            $form->display();
394
-            echo '<br>';
395
-            $itemtypes        = $subscriptionhandler->itemTypesArray();
396
-            $form             = new XoopsThemeForm(_MD_EDITITEMTYPE_FORM, 'edititemtypeform', 'main.php');
397
-            $itemtypes_select = new XoopsFormSelect(_MD_SELECT_ITEMTYPE, 'typeid', $typeid);
398
-            $itemtypes_select->addOptionArray($itemtypes);
399
-            $form->addElement($itemtypes_select);
400
-            $form->addElement(new XoopsFormButton('', 'submit', _MD_SAVE, 'submit'));
401
-            $form->addElement(new XoopsFormHidden('op', 'updateItemType'));
402
-            $form->addElement(new XoopsFormHidden('itemid', $get_itemid));
403
-            $form->addElement(new XoopsFormHidden('dirid', $get_dirid));
404
-            $form->addElement(new XoopsFormHidden('uid', $xoopsUser->getVar('uid')));
405
-            $form->display();
406
-        }
407
-        xoops_cp_footer();
408
-        break;
409
-    case 'save':
410
-        if (!empty($_POST['submit'])) {
411
-            $submitter = !empty($xoopsUser) ? $xoopsUser->getVar('uid') : 0;
412
-
413
-            if (!empty($_POST['itemid'])) {
414
-                $post_itemid = (int)$_POST['itemid'];
415
-            } else {
416
-                redirect_header('index.php', 2, _MD_NOVALIDITEM);
417
-                exit();
418
-            }
419
-            if (isset($_POST['itemtitle'])) {
420
-                $p_title     = $myts->makeTboxData4Save($_POST['itemtitle']);
421
-                $p_ini_title = $_POST['ini_itemtitle'];
422
-                if ($p_title != $p_ini_title) {
423
-                    //If the posted title is different from the initial title the record should be updated.
424
-                    $sql = 'UPDATE ' . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_items') . " SET title = '$p_title' WHERE itemid = $post_itemid";
425
-                    $xoopsDB->query($sql) or $eh->show('0013');
426
-                }
427
-            } else {
428
-                redirect_header('index.php', 2, _MD_NOVALIDITEM);
429
-                exit();
430
-            }
431
-            if (!empty($_POST['dirid'])) {
432
-                $post_dirid = (int)$_POST['dirid'];
433
-            } else {
434
-                $post_dirid = 0;
435
-            }
436
-            if (isset($_POST['ini_description'])) {
437
-                $p_ini_description = $myts->makeTareaData4Save($_POST['ini_description']);
438
-            } else {
439
-                $p_ini_description = null;
440
-            }
441
-            if (isset($_POST['description'])) {
442
-                $p_description = $myts->makeTareaData4Save($_POST['description']);
443
-            } else {
444
-                $p_description = null;
445
-            }
446
-            if (isset($_POST['description_set'])) {
447
-                if ($_POST['description_set'] == '1') {
448
-                    if ($p_ini_description != $p_description) {
449
-                        $sql = 'UPDATE ' . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_item_text') . " SET description = '$p_description' WHERE itemid = $post_itemid";
450
-                        $xoopsDB->query($sql) or $eh->show('0013');
451
-                    }
452
-                } elseif (isset($_POST['description']) && $_POST['description'] != '') {
453
-                    if ($p_description != null) {
454
-                        $sql = sprintf("INSERT INTO %s (itemid, description) VALUES (%u, '%s')", $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_item_text'), $post_itemid, $p_description);
455
-                        $xoopsDB->query($sql) or $eh->show('0013');
456
-                    }
457
-                }
458
-            }
459
-            $sql         = 'SELECT DISTINCT t.dtypeid, t.title, t.section, f.typeid, f.fieldtype, f.ext, t.options, d.itemid, d.value ';
460
-            $sql         .= 'FROM '
461
-                            . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_item_x_cat')
462
-                            . ' ic, '
463
-                            . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_dtypes_x_cat')
464
-                            . ' xc, '
465
-                            . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_fieldtypes')
466
-                            . ' f, '
467
-                            . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_dtypes')
468
-                            . ' t ';
469
-            $sql         .= 'LEFT JOIN ' . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_data') . ' d ON (t.dtypeid=d.dtypeid AND d.itemid=' . $post_itemid . ') ';
470
-            $sql         .= "WHERE ic.cid=xc.cid AND ic.active='1' AND xc.dtypeid=t.dtypeid AND t.fieldtypeid=f.typeid AND ic.itemid=" . $post_itemid . '';
471
-            $data_result = $xoopsDB->query($sql) or $eh->show('0013');
472
-            $numrows     = $xoopsDB->getRowsNum($data_result);
473
-            while (list($dtypeid, $title, $section, $ftypeid, $fieldtype, $ext, $options, $itemid, $value) = $xoopsDB->fetchRow($data_result)) {
474
-                if (isset($_POST["$dtypeid"])) {
475
-                    if ($fieldtype == 'textarea' || 'dhtml') {
476
-                        $post_value = $myts->makeTareaData4Save($_POST["$dtypeid"]);
477
-                    } else {
478
-                        $post_value = $myts->makeTboxData4Save($_POST["$dtypeid"]);
479
-                    }
480
-                } else {
481
-                    $post_value = '';
482
-                }
483
-
484
-                if (isset($_POST['custom' . $dtypeid . ''])) {
485
-                    $post_customtitle = $myts->makeTboxData4Save($_POST['custom' . $dtypeid . '']);
486
-                } else {
487
-                    $post_customtitle = '';
488
-                }
489
-                if ($fieldtype == 'address') {
490
-                    $addressfields = array('address', 'address2', 'zip', 'postcode', 'phone', 'lat', 'lon', 'phone', 'fax', 'mobile', 'city', 'country', 'uselocyn', 'main', 'active');
491
-                    foreach ($addressfields as $field) {
492
-                        if (isset($_POST["$dtypeid$field"])) {
493
-                            ${'post_' . $field} = $myts->makeTboxData4Save($_POST["$dtypeid$field"]);
494
-                        } else {
495
-                            ${'post_' . $field} = '';
496
-                        }
497
-                    }
498
-                    //INSERT OF UPDATE address
499
-                    //If INSERT, then get $newid and save it as the value in efqdiralpha1_data table
500
-                    if (isset($_POST['submitaddress'])) {
501
-                        if ($itemid == null || $post_value == '') {
502
-                            //That means there was not any value, so a new record should be added to the data table.
503
-                            $newaddrid = $xoopsDB->genId($xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_addresses') . '_addrid_seq');
504
-                            $sql       = sprintf("INSERT INTO %s (addrid, itemid, dtypeid, address, address2, zip, postcode, phone, lat, lon, main, active, fax, mobile, city, country) VALUES (%u, %u, %u, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %u, %u, '%s', '%s', '%s', '%s')",
505
-                                                 $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_addresses'), $newaddrid, $post_itemid, $dtypeid, $post_address, $post_address2, $post_zip, $post_postcode, $post_phone, $post_lat, $post_lon, $post_main, $post_active, $post_fax, $post_mobile,
506
-                                                 $post_city, $post_country);
507
-                            //echo $sql."<br><br>";
508
-                            $xoopsDB->query($sql) or $eh->show('0013');
509
-                            $post_value = $xoopsDB->getInsertId();
510
-                        } else {
511
-                            $sql = 'UPDATE '
512
-                                   . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_addresses')
513
-                                   . " SET address = '$post_address', address2 = '$post_address2', zip = '$post_zip', postcode = '$post_postcode', lat = '$post_lat', lon = '$post_lon', main = '$post_main', active = '$post_active', fax = '$post_fax', mobile = '$post_mobile', city = '$post_city', country = '$post_country' WHERE addrid = '$post_value' AND itemid = '$post_itemid'";
514
-                            //echo $sql."<br><br>";
515
-                            $xoopsDB->query($sql) or $eh->show('0013');
516
-                        }
517
-                    }
518
-                }
519
-                if ($itemid == null) {
520
-                    //That means there was not any value, so a new record should be added to the data table.
521
-                    $newid = $xoopsDB->genId($xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_data') . '_dataid_seq');
522
-                    $sql   = sprintf("INSERT INTO %s (dataid, itemid, dtypeid, VALUE, created) VALUES (%u, %u, %u, '%s', '%s')", $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_data'), $newid, $post_itemid, $dtypeid, $post_value, time());
523
-                    $xoopsDB->query($sql) or $eh->show('0013');
524
-                } else {
525
-                    if ($value != $post_value) {
526
-                        $sql = 'UPDATE ' . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_data') . " SET value = '$post_value' WHERE dtypeid = $dtypeid AND itemid = $itemid";
527
-                        $xoopsDB->query($sql) or $eh->show('0013');
528
-                    }
529
-                }
530
-            }
531
-
532
-            $efqlisting        = new efqListing();
533
-            $efqlistinghandler = new efqListingHandler();
534
-            $linkedcats        = $efqlistinghandler->getLinkedCatsArray($post_itemid, $post_dirid);
535
-            $sql               = 'SELECT cid FROM ' . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_cat') . " WHERE dirid='" . $post_dirid . '\' AND active=\'1\'';
536
-            $allcatsresult     = $xoopsDB->query($sql);
537
-
538
-            $numrows = $xoopsDB->getRowsNum($allcatsresult);
539
-            $count   = 0;
540
-            if ($numrows > 0) {
541
-                while (list($cid) = $xoopsDB->fetchRow($allcatsresult)) {
542
-                    if (isset($_POST['selected' . $cid . ''])) {
543
-                        if (!in_array($cid, $linkedcats)) {
544
-                            $newid = $xoopsDB->genId($xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_item_x_cat') . '_xid_seq');
545
-                            $sql   = sprintf("INSERT INTO %s (xid, cid, itemid, active, created) VALUES (%u, %u, %u, '%s', '%s')", $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_item_x_cat'), $newid, $cid, $post_itemid, 1, time());
546
-                            $xoopsDB->query($sql) or $eh->show('0013');
547
-                        }
548
-
549
-                        ++$count;
550
-                    } else {
551
-                        if (in_array($cid, $linkedcats)) {
552
-                            $sql = sprintf('DELETE FROM %s WHERE cid=%u AND itemid=%u', $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_item_x_cat'), $cid, $post_itemid);
553
-                            $xoopsDB->query($sql) or $eh->show('0013');
554
-                        }
555
-                    }
556
-                }
557
-                if ($count == 0) {
558
-                    redirect_header(XOOPS_URL . "/modules/$moddir/admin/main.php?op=edit&item=" . $post_itemid . '', 2, _MD_NOCATEGORYMATCH);
559
-                    exit();
560
-                }
561
-            } else {
562
-                redirect_header(XOOPS_URL . "/modules/$moddir/admin/main.php?op=edit&item=" . $post_itemid . '', 2, _MD_NOCATEGORIESAVAILABLE);
563
-                exit();
564
-            }
565
-
566
-            redirect_header("main.php?op=edit&amp;item=$post_itemid", 2, _MD_ITEM_UPDATED);
567
-            exit();
568
-        }
569
-        break;
570
-    default:
571
-        listings();
572
-        break;
304
+    	case 'approve':
305
+        	approve();
306
+        	break;
307
+    	case 'deleteListingConfirm':
308
+        	delListingConfirm();
309
+        	break;
310
+    	case 'deleteListing':
311
+        	delListing();
312
+        	break;
313
+    	case 'delVote':
314
+        	delVote();
315
+        	break;
316
+    	case 'listNewListings':
317
+        	listNewListings();
318
+        	break;
319
+    	case 'updateItemType':
320
+        	updateItemType();
321
+        	break;
322
+    	case 'duplicateDataTypes':
323
+        	listDuplicateDataTypes();
324
+        	break;
325
+    	case 'mergeDuplicates':
326
+        	mergeDuplicates();
327
+        	break;
328
+    	case 'edit':
329
+        	global $xoopsDB, $xoopsConfig, $myts, $eh, $efqtree, $moddir, $xoopsUser, $datafieldmanager, $subscription, $subscriptionhandler;
330
+        	$sql         = 'SELECT i.itemid, i.logourl, i.uid, i.status, i.created, i.title, i.typeid, t.description FROM '
331
+                       	. $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_items')
332
+                       	. ' i LEFT JOIN '
333
+                       	. $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_item_text')
334
+                       	. ' t ON (i.itemid=t.itemid) WHERE i.itemid='
335
+                       	. $get_itemid
336
+                       	. '';
337
+        	$item_result = $xoopsDB->query($sql);
338
+        	$numrows     = $xoopsDB->getRowsNum($item_result);
339
+        	xoops_cp_header();
340
+        	//adminmenu(-1, _MD_A_MODADMIN_HOME);
341
+        	echo "<hr size='1'><br>";
342
+        	while (list($itemid, $logourl, $submitter, $status, $created, $itemtitle, $typeid, $description) = $xoopsDB->fetchRow($item_result)) {
343
+            	if ($status == '1') {
344
+                	echo '<input type="button" value="' . _MD_APPROVE . "\" onclick=\"location='main.php?op=approve&amp;item=$get_itemid'\">&nbsp;";
345
+            	}
346
+            	echo '&nbsp;<input type="button" value="'
347
+                 	. _MD_DELETE
348
+                 	. "\" onClick=\"location='main.php?op=deleteListingConfirm&amp;item=$get_itemid'\">&nbsp;<input type=\"button\" value=\""
349
+                 	. _MD_VIEWITEM
350
+                 	. "\" onclick=\"location='"
351
+                 	. XOOPS_URL
352
+                 	. '/modules/'
353
+                 	. $moddir
354
+                 	. "/listing.php?item=$get_itemid'\"><br><br>";
355
+
356
+            	$sql         = 'SELECT DISTINCT t.dtypeid, t.title, t.section, f.typeid, f.fieldtype, f.ext, t.options, d.itemid, d.value, d.customtitle, t.custom ';
357
+            	$sql         .= 'FROM '
358
+                            	. $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_item_x_cat')
359
+                            	. ' ic, '
360
+                            	. $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_dtypes_x_cat')
361
+                            	. ' xc, '
362
+                            	. $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_fieldtypes')
363
+                            	. ' f, '
364
+                            	. $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_dtypes')
365
+                            	. ' t ';
366
+            	$sql         .= 'LEFT JOIN ' . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_data') . ' d ON (t.dtypeid=d.dtypeid AND d.itemid=' . $get_itemid . ') ';
367
+            	$sql         .= "WHERE ic.cid=xc.cid AND ic.active='1' AND xc.dtypeid=t.dtypeid AND t.fieldtypeid=f.typeid AND t.activeyn='1' AND ic.itemid=" . $get_itemid . '';
368
+            	$data_result = $xoopsDB->query($sql) or $eh->show('0013');
369
+            	$numrows     = $xoopsDB->getRowsNum($data_result);
370
+
371
+            	$form = new XoopsThemeForm(_MD_EDITITEM_FORM, 'editform', 'main.php');
372
+            	$form->addElement(new XoopsFormText(_MD_TITLE, 'itemtitle', 50, 250, $itemtitle), true);
373
+            	//$categories = getCategoriesPaths($get_itemid);
374
+            	$get_dirid  = getDirIdFromItem($itemid);
375
+            	$categories = getCatSelectArea($itemid, $get_dirid);
376
+            	$form_cats  = new XoopsFormLabel(_MD_ITEMCATEGORIES, "$categories");
377
+            	$form->addElement($form_cats);
378
+            	$form->addElement(new XoopsFormDhtmlTextArea(_MD_DESCRIPTION, 'description', $description, 5, 50));
379
+            	while (list($dtypeid, $title, $section, $ftypeid, $fieldtype, $ext, $options, $itemid, $value, $customtitle, $custom) = $xoopsDB->fetchRow($data_result)) {
380
+                	$field = $datafieldmanager->createField($title, $dtypeid, $fieldtype, $ext, $options, $value, $custom, $customtitle);
381
+            	}
382
+            	$form->addElement(new XoopsFormButton('', 'submit', _MD_SAVE, 'submit'));
383
+            	$form->addElement(new XoopsFormHidden('op', 'save'));
384
+            	$form->addElement(new XoopsFormHidden('itemid', $get_itemid));
385
+            	$form->addElement(new XoopsFormHidden('dirid', $get_dirid));
386
+            	$form->addElement(new XoopsFormHidden('ini_itemtitle', $itemtitle));
387
+            	$form->addElement(new XoopsFormHidden('uid', $xoopsUser->getVar('uid')));
388
+            	if ($description === false) {
389
+                	$form->addElement(new XoopsFormHidden('description_set', '0'));
390
+            	} else {
391
+                	$form->addElement(new XoopsFormHidden('description_set', '1'));
392
+            	}
393
+            	$form->display();
394
+            	echo '<br>';
395
+            	$itemtypes        = $subscriptionhandler->itemTypesArray();
396
+            	$form             = new XoopsThemeForm(_MD_EDITITEMTYPE_FORM, 'edititemtypeform', 'main.php');
397
+            	$itemtypes_select = new XoopsFormSelect(_MD_SELECT_ITEMTYPE, 'typeid', $typeid);
398
+            	$itemtypes_select->addOptionArray($itemtypes);
399
+            	$form->addElement($itemtypes_select);
400
+            	$form->addElement(new XoopsFormButton('', 'submit', _MD_SAVE, 'submit'));
401
+            	$form->addElement(new XoopsFormHidden('op', 'updateItemType'));
402
+            	$form->addElement(new XoopsFormHidden('itemid', $get_itemid));
403
+            	$form->addElement(new XoopsFormHidden('dirid', $get_dirid));
404
+            	$form->addElement(new XoopsFormHidden('uid', $xoopsUser->getVar('uid')));
405
+            	$form->display();
406
+        	}
407
+        	xoops_cp_footer();
408
+        	break;
409
+    	case 'save':
410
+        	if (!empty($_POST['submit'])) {
411
+            	$submitter = !empty($xoopsUser) ? $xoopsUser->getVar('uid') : 0;
412
+
413
+            	if (!empty($_POST['itemid'])) {
414
+                	$post_itemid = (int)$_POST['itemid'];
415
+            	} else {
416
+                	redirect_header('index.php', 2, _MD_NOVALIDITEM);
417
+                	exit();
418
+            	}
419
+            	if (isset($_POST['itemtitle'])) {
420
+                	$p_title     = $myts->makeTboxData4Save($_POST['itemtitle']);
421
+                	$p_ini_title = $_POST['ini_itemtitle'];
422
+                	if ($p_title != $p_ini_title) {
423
+                    	//If the posted title is different from the initial title the record should be updated.
424
+                    	$sql = 'UPDATE ' . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_items') . " SET title = '$p_title' WHERE itemid = $post_itemid";
425
+                    	$xoopsDB->query($sql) or $eh->show('0013');
426
+                	}
427
+            	} else {
428
+                	redirect_header('index.php', 2, _MD_NOVALIDITEM);
429
+                	exit();
430
+            	}
431
+            	if (!empty($_POST['dirid'])) {
432
+                	$post_dirid = (int)$_POST['dirid'];
433
+            	} else {
434
+                	$post_dirid = 0;
435
+            	}
436
+            	if (isset($_POST['ini_description'])) {
437
+                	$p_ini_description = $myts->makeTareaData4Save($_POST['ini_description']);
438
+            	} else {
439
+                	$p_ini_description = null;
440
+            	}
441
+            	if (isset($_POST['description'])) {
442
+                	$p_description = $myts->makeTareaData4Save($_POST['description']);
443
+            	} else {
444
+                	$p_description = null;
445
+            	}
446
+            	if (isset($_POST['description_set'])) {
447
+                	if ($_POST['description_set'] == '1') {
448
+                    	if ($p_ini_description != $p_description) {
449
+                        	$sql = 'UPDATE ' . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_item_text') . " SET description = '$p_description' WHERE itemid = $post_itemid";
450
+                        	$xoopsDB->query($sql) or $eh->show('0013');
451
+                    	}
452
+                	} elseif (isset($_POST['description']) && $_POST['description'] != '') {
453
+                    	if ($p_description != null) {
454
+                        	$sql = sprintf("INSERT INTO %s (itemid, description) VALUES (%u, '%s')", $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_item_text'), $post_itemid, $p_description);
455
+                        	$xoopsDB->query($sql) or $eh->show('0013');
456
+                    	}
457
+                	}
458
+            	}
459
+            	$sql         = 'SELECT DISTINCT t.dtypeid, t.title, t.section, f.typeid, f.fieldtype, f.ext, t.options, d.itemid, d.value ';
460
+            	$sql         .= 'FROM '
461
+                            	. $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_item_x_cat')
462
+                            	. ' ic, '
463
+                            	. $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_dtypes_x_cat')
464
+                            	. ' xc, '
465
+                            	. $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_fieldtypes')
466
+                            	. ' f, '
467
+                            	. $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_dtypes')
468
+                            	. ' t ';
469
+            	$sql         .= 'LEFT JOIN ' . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_data') . ' d ON (t.dtypeid=d.dtypeid AND d.itemid=' . $post_itemid . ') ';
470
+            	$sql         .= "WHERE ic.cid=xc.cid AND ic.active='1' AND xc.dtypeid=t.dtypeid AND t.fieldtypeid=f.typeid AND ic.itemid=" . $post_itemid . '';
471
+            	$data_result = $xoopsDB->query($sql) or $eh->show('0013');
472
+            	$numrows     = $xoopsDB->getRowsNum($data_result);
473
+            	while (list($dtypeid, $title, $section, $ftypeid, $fieldtype, $ext, $options, $itemid, $value) = $xoopsDB->fetchRow($data_result)) {
474
+                	if (isset($_POST["$dtypeid"])) {
475
+                    	if ($fieldtype == 'textarea' || 'dhtml') {
476
+                        	$post_value = $myts->makeTareaData4Save($_POST["$dtypeid"]);
477
+                    	} else {
478
+                        	$post_value = $myts->makeTboxData4Save($_POST["$dtypeid"]);
479
+                    	}
480
+                	} else {
481
+                    	$post_value = '';
482
+                	}
483
+
484
+                	if (isset($_POST['custom' . $dtypeid . ''])) {
485
+                    	$post_customtitle = $myts->makeTboxData4Save($_POST['custom' . $dtypeid . '']);
486
+                	} else {
487
+                    	$post_customtitle = '';
488
+                	}
489
+                	if ($fieldtype == 'address') {
490
+                    	$addressfields = array('address', 'address2', 'zip', 'postcode', 'phone', 'lat', 'lon', 'phone', 'fax', 'mobile', 'city', 'country', 'uselocyn', 'main', 'active');
491
+                    	foreach ($addressfields as $field) {
492
+                        	if (isset($_POST["$dtypeid$field"])) {
493
+                            	${'post_' . $field} = $myts->makeTboxData4Save($_POST["$dtypeid$field"]);
494
+                        	} else {
495
+                            	${'post_' . $field} = '';
496
+                        	}
497
+                    	}
498
+                    	//INSERT OF UPDATE address
499
+                    	//If INSERT, then get $newid and save it as the value in efqdiralpha1_data table
500
+                    	if (isset($_POST['submitaddress'])) {
501
+                        	if ($itemid == null || $post_value == '') {
502
+                            	//That means there was not any value, so a new record should be added to the data table.
503
+                            	$newaddrid = $xoopsDB->genId($xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_addresses') . '_addrid_seq');
504
+                            	$sql       = sprintf("INSERT INTO %s (addrid, itemid, dtypeid, address, address2, zip, postcode, phone, lat, lon, main, active, fax, mobile, city, country) VALUES (%u, %u, %u, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %u, %u, '%s', '%s', '%s', '%s')",
505
+                                                 	$xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_addresses'), $newaddrid, $post_itemid, $dtypeid, $post_address, $post_address2, $post_zip, $post_postcode, $post_phone, $post_lat, $post_lon, $post_main, $post_active, $post_fax, $post_mobile,
506
+                                                 	$post_city, $post_country);
507
+                            	//echo $sql."<br><br>";
508
+                            	$xoopsDB->query($sql) or $eh->show('0013');
509
+                            	$post_value = $xoopsDB->getInsertId();
510
+                        	} else {
511
+                            	$sql = 'UPDATE '
512
+                                   	. $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_addresses')
513
+                                   	. " SET address = '$post_address', address2 = '$post_address2', zip = '$post_zip', postcode = '$post_postcode', lat = '$post_lat', lon = '$post_lon', main = '$post_main', active = '$post_active', fax = '$post_fax', mobile = '$post_mobile', city = '$post_city', country = '$post_country' WHERE addrid = '$post_value' AND itemid = '$post_itemid'";
514
+                            	//echo $sql."<br><br>";
515
+                            	$xoopsDB->query($sql) or $eh->show('0013');
516
+                        	}
517
+                    	}
518
+                	}
519
+                	if ($itemid == null) {
520
+                    	//That means there was not any value, so a new record should be added to the data table.
521
+                    	$newid = $xoopsDB->genId($xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_data') . '_dataid_seq');
522
+                    	$sql   = sprintf("INSERT INTO %s (dataid, itemid, dtypeid, VALUE, created) VALUES (%u, %u, %u, '%s', '%s')", $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_data'), $newid, $post_itemid, $dtypeid, $post_value, time());
523
+                    	$xoopsDB->query($sql) or $eh->show('0013');
524
+                	} else {
525
+                    	if ($value != $post_value) {
526
+                        	$sql = 'UPDATE ' . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_data') . " SET value = '$post_value' WHERE dtypeid = $dtypeid AND itemid = $itemid";
527
+                        	$xoopsDB->query($sql) or $eh->show('0013');
528
+                    	}
529
+                	}
530
+            	}
531
+
532
+            	$efqlisting        = new efqListing();
533
+            	$efqlistinghandler = new efqListingHandler();
534
+            	$linkedcats        = $efqlistinghandler->getLinkedCatsArray($post_itemid, $post_dirid);
535
+            	$sql               = 'SELECT cid FROM ' . $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_cat') . " WHERE dirid='" . $post_dirid . '\' AND active=\'1\'';
536
+            	$allcatsresult     = $xoopsDB->query($sql);
537
+
538
+            	$numrows = $xoopsDB->getRowsNum($allcatsresult);
539
+            	$count   = 0;
540
+            	if ($numrows > 0) {
541
+                	while (list($cid) = $xoopsDB->fetchRow($allcatsresult)) {
542
+                    	if (isset($_POST['selected' . $cid . ''])) {
543
+                        	if (!in_array($cid, $linkedcats)) {
544
+                            	$newid = $xoopsDB->genId($xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_item_x_cat') . '_xid_seq');
545
+                            	$sql   = sprintf("INSERT INTO %s (xid, cid, itemid, active, created) VALUES (%u, %u, %u, '%s', '%s')", $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_item_x_cat'), $newid, $cid, $post_itemid, 1, time());
546
+                            	$xoopsDB->query($sql) or $eh->show('0013');
547
+                        	}
548
+
549
+                        	++$count;
550
+                    	} else {
551
+                        	if (in_array($cid, $linkedcats)) {
552
+                            	$sql = sprintf('DELETE FROM %s WHERE cid=%u AND itemid=%u', $xoopsDB->prefix($xoopsModule->getVar('dirname', 'n') . '_item_x_cat'), $cid, $post_itemid);
553
+                            	$xoopsDB->query($sql) or $eh->show('0013');
554
+                        	}
555
+                    	}
556
+                	}
557
+                	if ($count == 0) {
558
+                    	redirect_header(XOOPS_URL . "/modules/$moddir/admin/main.php?op=edit&item=" . $post_itemid . '', 2, _MD_NOCATEGORYMATCH);
559
+                    	exit();
560
+                	}
561
+            	} else {
562
+                	redirect_header(XOOPS_URL . "/modules/$moddir/admin/main.php?op=edit&item=" . $post_itemid . '', 2, _MD_NOCATEGORIESAVAILABLE);
563
+                	exit();
564
+            	}
565
+
566
+            	redirect_header("main.php?op=edit&amp;item=$post_itemid", 2, _MD_ITEM_UPDATED);
567
+            	exit();
568
+        	}
569
+        	break;
570
+    	default:
571
+        	listings();
572
+        	break;
573 573
 }
574 574
 
575 575
 function unique_events($array)
Please login to merge, or discard this patch.
admin/xdir_migrate.php 1 patch
Switch Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -112,10 +112,10 @@
 block discarded – undo
112 112
 }
113 113
 switch ($op) {
114 114
 
115
-    case 'newdir':
116
-        newDir();
117
-        break;
118
-    default:
119
-        xdirConfig();
120
-        break;
115
+    	case 'newdir':
116
+        	newDir();
117
+        	break;
118
+    	default:
119
+        	xdirConfig();
120
+        	break;
121 121
 }
Please login to merge, or discard this patch.
admin/directories.php 1 patch
Switch Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -251,30 +251,30 @@
 block discarded – undo
251 251
     $op = $_POST['op'];
252 252
 }
253 253
 switch ($op) {
254
-    case 'edit':
255
-        editDir();
256
-        break;
257
-    case 'update':
258
-        updateDir();
259
-        break;
260
-    case 'changestatus':
261
-        if (isset($_POST['fct'])) {
262
-            $fct = $_POST['fct'];
263
-            if ($fct == 'activate') {
264
-                $newstatus = 1;
265
-            } elseif ($fct == 'inactivate') {
266
-                $newstatus = 0;
267
-            }
268
-        }
269
-        changeStatus($newstatus);
270
-        break;
271
-    case 'newdir':
272
-        newDir();
273
-        break;
274
-    case 'moddir':
275
-        modDir($get_dir);
276
-        break;
277
-    default:
278
-        dirConfig();
279
-        break;
254
+    	case 'edit':
255
+        	editDir();
256
+        	break;
257
+    	case 'update':
258
+        	updateDir();
259
+        	break;
260
+    	case 'changestatus':
261
+        	if (isset($_POST['fct'])) {
262
+            	$fct = $_POST['fct'];
263
+            	if ($fct == 'activate') {
264
+                	$newstatus = 1;
265
+            	} elseif ($fct == 'inactivate') {
266
+                	$newstatus = 0;
267
+            	}
268
+        	}
269
+        	changeStatus($newstatus);
270
+        	break;
271
+    	case 'newdir':
272
+        	newDir();
273
+        	break;
274
+    	case 'moddir':
275
+        	modDir($get_dir);
276
+        	break;
277
+    	default:
278
+        	dirConfig();
279
+        	break;
280 280
 }
Please login to merge, or discard this patch.
admin/categories.php 1 patch
Switch Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -935,39 +935,39 @@
 block discarded – undo
935 935
     $op = $_POST['op'];
936 936
 }
937 937
 switch ($op) {
938
-    case 'newdatatype':
939
-        addDatatype();
940
-        break;
941
-    case 'editdtypes':
942
-        editDatatypes();
943
-        break;
944
-    case 'editdtype':
945
-        editDatatype($get_dtypeid);
946
-        break;
947
-    case 'savedtype':
948
-        saveDatatype();
949
-        break;
950
-    case 'importdtypes':
951
-        importDatatypes();
952
-        break;
953
-    case 'edit':
954
-        editCat($get_catid);
955
-        break;
956
-    case 'update':
957
-        updateCat();
958
-        break;
959
-    case 'newcat':
960
-        newCat();
961
-        break;
962
-    case 'deleteCat':
963
-        deleteCat();
964
-        break;
965
-    case 'deleteCatConfirm':
966
-        deleteCatConfirm();
967
-        break;
968
-    default:
969
-        catConfig($get_dirid);
970
-        break;
938
+    	case 'newdatatype':
939
+        	addDatatype();
940
+        	break;
941
+    	case 'editdtypes':
942
+        	editDatatypes();
943
+        	break;
944
+    	case 'editdtype':
945
+        	editDatatype($get_dtypeid);
946
+        	break;
947
+    	case 'savedtype':
948
+        	saveDatatype();
949
+        	break;
950
+    	case 'importdtypes':
951
+        	importDatatypes();
952
+        	break;
953
+    	case 'edit':
954
+        	editCat($get_catid);
955
+        	break;
956
+    	case 'update':
957
+        	updateCat();
958
+        	break;
959
+    	case 'newcat':
960
+        	newCat();
961
+        	break;
962
+    	case 'deleteCat':
963
+        	deleteCat();
964
+        	break;
965
+    	case 'deleteCatConfirm':
966
+        	deleteCatConfirm();
967
+        	break;
968
+    	default:
969
+        	catConfig($get_dirid);
970
+        	break;
971 971
 }
972 972
 
973 973
 function getCatOverview()
Please login to merge, or discard this patch.
admin/extensionmanager.php 1 patch
Switch Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -355,7 +355,7 @@
 block discarded – undo
355 355
     case "delLocs2":
356 356
     delLocationsToLink();
357 357
     break;*/
358
-    default:
359
-        showExtFields($type, $ext);
360
-        break;
358
+    	default:
359
+        	showExtFields($type, $ext);
360
+        	break;
361 361
 }
Please login to merge, or discard this patch.
subscriptions.php 1 patch
Switch Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -319,38 +319,38 @@
 block discarded – undo
319 319
 }
320 320
 
321 321
 switch ($op) {
322
-    case 'upgrade':
323
-        upgrade();
324
-        break;
325
-    case 'orderselect':
326
-        orderselect();
327
-        break;
328
-    case 'orderpayment':
329
-        $GLOBALS['xoopsOption']['template_main'] = 'efqdiralpha1_subscriptions.tpl';
330
-        include XOOPS_ROOT_PATH . '/header.php';
331
-        orderpayment();
332
-        $xoopsTpl->assign('xoops_module_header', $xoops_module_header);
333
-        break;
334
-    case 'terminate':
335
-        $GLOBALS['xoopsOption']['template_main'] = 'efqdiralpha1_subscriptions.tpl';
336
-        include XOOPS_ROOT_PATH . '/header.php';
337
-        terminate();
338
-        $xoopsTpl->assign('xoops_module_header', $xoops_module_header);
339
-        break;
340
-    case 'terminate_confirm':
341
-        include XOOPS_ROOT_PATH . '/header.php';
342
-        terminate_confirm();
343
-        break;
344
-    case 'renew':
345
-        include XOOPS_ROOT_PATH . '/header.php';
346
-        renew();
347
-        break;
348
-    default:
349
-        $GLOBALS['xoopsOption']['template_main'] = 'efqdiralpha1_subscriptions.tpl';
350
-        include XOOPS_ROOT_PATH . '/header.php';
351
-        showsubscription();
352
-        $xoopsTpl->assign('xoops_module_header', $xoops_module_header);
353
-        break;
322
+    	case 'upgrade':
323
+        	upgrade();
324
+        	break;
325
+    	case 'orderselect':
326
+        	orderselect();
327
+        	break;
328
+    	case 'orderpayment':
329
+        	$GLOBALS['xoopsOption']['template_main'] = 'efqdiralpha1_subscriptions.tpl';
330
+        	include XOOPS_ROOT_PATH . '/header.php';
331
+        	orderpayment();
332
+        	$xoopsTpl->assign('xoops_module_header', $xoops_module_header);
333
+        	break;
334
+    	case 'terminate':
335
+        	$GLOBALS['xoopsOption']['template_main'] = 'efqdiralpha1_subscriptions.tpl';
336
+        	include XOOPS_ROOT_PATH . '/header.php';
337
+        	terminate();
338
+        	$xoopsTpl->assign('xoops_module_header', $xoops_module_header);
339
+        	break;
340
+    	case 'terminate_confirm':
341
+        	include XOOPS_ROOT_PATH . '/header.php';
342
+        	terminate_confirm();
343
+        	break;
344
+    	case 'renew':
345
+        	include XOOPS_ROOT_PATH . '/header.php';
346
+        	renew();
347
+        	break;
348
+    	default:
349
+        	$GLOBALS['xoopsOption']['template_main'] = 'efqdiralpha1_subscriptions.tpl';
350
+        	include XOOPS_ROOT_PATH . '/header.php';
351
+        	showsubscription();
352
+        	$xoopsTpl->assign('xoops_module_header', $xoops_module_header);
353
+        	break;
354 354
 }
355 355
 
356 356
 include XOOPS_ROOT_PATH . '/footer.php';
Please login to merge, or discard this patch.