AlumniListingForm   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 129
Duplicated Lines 9.3 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 12
loc 129
rs 10
c 0
b 0
f 0
wmc 14
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
F __construct() 12 123 14

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
12
/**
13
 * Alumni module for Xoops
14
 *
15
 * @copyright       XOOPS Project https://xoops.org/
16
 * @license         GPL 2.0 or later
17
 * @package         alumni
18
 * @since           2.6.x
19
 * @author          John Mordo (jlm69)
20
 */
21
22
use Xoops\Core\Request;
23
24
/**
25
 * Class AlumniListingForm
26
 */
27
class AlumniListingForm extends Xoops\Form\ThemeForm
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
28
{
29
    /**
30
     * @param \AlumniListing $obj
31
     */
32
    public function __construct(AlumniListing $obj)
0 ignored issues
show
Coding Style introduced by
__construct uses the super-global variable $_REQUEST which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
33
    {
34
        $xoops = Xoops::getInstance();
35
36
        if ('1' == $xoops->getModuleConfig('alumni_moderated')) {
37
            $title = sprintf($obj->isNew() ? AlumniLocale::ADD_MOD : AlumniLocale::EDIT_MOD);
38
        } else {
39
            $title = sprintf($obj->isNew() ? AlumniLocale::ADD_LISTING : AlumniLocale::EDIT_LISTING);
40
        }
41
42
        parent::__construct($title, 'form', false, 'post', true);
43
44
        $this->setExtra('enctype="multipart/form-data"');
45
46
        $member_handler = $xoops->getHandlerMember();
0 ignored issues
show
Coding Style introduced by
$member_handler does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
47
        $userGroups     = $member_handler->getGroupList();
0 ignored issues
show
Coding Style introduced by
$member_handler does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
Unused Code introduced by
$userGroups is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
48
49
        $lid = Request::getInt('lid', 0);
0 ignored issues
show
Unused Code introduced by
$lid is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
50
//        if (isset($lid)) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
51
//            $lid = $lid;
52
//        }
53
54
        $this->addElement(new Xoops\Form\Label(AlumniLocale::SUBMITTER, $xoops->user->uname()));
55
56
        $categoryHandler = $xoops->getModuleHandler('category', 'alumni');
57
        $categories      = $categoryHandler->getObjects();
58
        $mytree          = new XoopsObjectTree($categories, 'cid', 'pid');
0 ignored issues
show
Unused Code introduced by
$mytree is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
59
        if ($obj->isNew()) {
60
            $this_cid = Request::getInt('cid', 0);
0 ignored issues
show
Coding Style introduced by
$this_cid does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
61
        } else {
62
            $this_cid = $obj->getVar('cid');
0 ignored issues
show
Coding Style introduced by
$this_cid does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
63
        }
64
        $categories_Handler = $xoops->getModuleHandler('category', 'alumni');
0 ignored issues
show
Coding Style introduced by
$categories_Handler does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
65
        $categories         = $categories_Handler->getObjects();
0 ignored issues
show
Coding Style introduced by
$categories_Handler does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
66
        $mytree             = new XoopsObjectTree($categories, 'cid', 'pid');
67
        $category_select    = $mytree->makeSelBox('cid', 'title', '--', $this_cid, true);
0 ignored issues
show
Coding Style introduced by
$category_select does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
68
        $this->addElement(new Xoops\Form\Label(AlumniLocale::SCHOOL, $category_select), true);
0 ignored issues
show
Coding Style introduced by
$category_select does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
69
70
        $cat_name           = '';
0 ignored issues
show
Coding Style introduced by
$cat_name does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
Unused Code introduced by
$cat_name is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
71
        $categories_Handler = $xoops->getModuleHandler('category', 'alumni');
0 ignored issues
show
Coding Style introduced by
$categories_Handler does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
72
        $catObj             = $categories_Handler->get($obj->getVar('cid'));
0 ignored issues
show
Coding Style introduced by
$categories_Handler does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
73
        $cat_name           = $catObj->getVar('title');
0 ignored issues
show
Coding Style introduced by
$cat_name does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
74
        $this->addElement(new Xoops\Form\Hidden('school', $cat_name));
0 ignored issues
show
Coding Style introduced by
$cat_name does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
75
76
        $this->addElement(new Xoops\Form\Text(AlumniLocale::NAME_2, 'name', 50, 255, $obj->getVar('name')), true);
77
        $this->addElement(new Xoops\Form\Text(AlumniLocale::MNAME_2, 'mname', 50, 255, $obj->getVar('mname')), false);
78
        $this->addElement(new Xoops\Form\Text(AlumniLocale::LNAME_2, 'lname', 50, 255, $obj->getVar('lname')), true);
79
        $this->addElement(new Xoops\Form\Text(AlumniLocale::CLASS_OF_2, 'year', 50, 255, $obj->getVar('year')), true);
80
        $this->addElement(new Xoops\Form\Text(AlumniLocale::STUDIES_2, 'studies', 50, 255, $obj->getVar('studies')), false);
81
        $activities               = $obj->getVar('activities', 'e') ?: '';
82
        $editor_configs           = [];
0 ignored issues
show
Coding Style introduced by
$editor_configs does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
83
        $editor_configs['name']   = 'activities';
0 ignored issues
show
Coding Style introduced by
$editor_configs does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
84
        $editor_configs['value']  = $activities;
0 ignored issues
show
Coding Style introduced by
$editor_configs does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
85
        $editor_configs['editor'] = $xoops->getModuleConfig('alumni_form_options');
0 ignored issues
show
Coding Style introduced by
$editor_configs does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
86
        $editor_configs['rows']   = 6;
0 ignored issues
show
Coding Style introduced by
$editor_configs does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
87
        $editor_configs['cols']   = 8;
0 ignored issues
show
Coding Style introduced by
$editor_configs does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
88
89
        $this->addElement(new Xoops\Form\Editor(AlumniLocale::ACTIVITIES, 'activities', $editor_configs), false);
0 ignored issues
show
Coding Style introduced by
$editor_configs does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
90
        $extrainfo                = $obj->getVar('extrainfo', 'e') ?: '';
91
        $editor_configs           = [];
0 ignored issues
show
Coding Style introduced by
$editor_configs does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
92
        $editor_configs['name']   = 'extrainfo';
0 ignored issues
show
Coding Style introduced by
$editor_configs does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
93
        $editor_configs['value']  = $extrainfo;
0 ignored issues
show
Coding Style introduced by
$editor_configs does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
94
        $editor_configs['editor'] = $xoops->getModuleConfig('alumni_form_options');
0 ignored issues
show
Coding Style introduced by
$editor_configs does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
95
        $editor_configs['rows']   = 6;
0 ignored issues
show
Coding Style introduced by
$editor_configs does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
96
        $editor_configs['cols']   = 8;
0 ignored issues
show
Coding Style introduced by
$editor_configs does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
97
98
        $this->addElement(new Xoops\Form\Editor(AlumniLocale::EXTRAINFO, 'extrainfo', $editor_configs), false);
0 ignored issues
show
Coding Style introduced by
$editor_configs does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
99
        $photo_old            = $obj->getVar('photo') ?: '';
0 ignored issues
show
Coding Style introduced by
$photo_old does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
100
        $uploadirectory_photo = XOOPS_ROOT_PATH . '/modules/alumni/photos/grad_photo';
0 ignored issues
show
Coding Style introduced by
$uploadirectory_photo does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
101
        $imgtray_photo        = new Xoops\Form\ElementTray(AlumniLocale::GRAD_PHOTO, '<br>');
0 ignored issues
show
Coding Style introduced by
$imgtray_photo does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
102
        $imgpath_photo        = sprintf(AlumniLocale::FORMIMAGE_PATH, $uploadirectory_photo);
0 ignored issues
show
Coding Style introduced by
$imgpath_photo does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
Unused Code introduced by
$imgpath_photo is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
103
        $fileseltray_photo    = new Xoops\Form\ElementTray('', '<br>');
0 ignored issues
show
Coding Style introduced by
$fileseltray_photo does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
104
        $fileseltray_photo->addElement(new Xoops\Form\File(AlumniLocale::FORMUPLOAD, 'photo', $xoops->getModuleConfig('alumni_photomax')), false);
0 ignored issues
show
Coding Style introduced by
$fileseltray_photo does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
105
106 View Code Duplication
        if ($photo_old) {
0 ignored issues
show
Coding Style introduced by
$photo_old does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
107
            $fileseltray_photo->addElement(new Xoops\Form\Label(AlumniLocale::PHOTO2, '<a href="photos/grad_photo/' . $photo_old . '">' . $photo_old . '</a>', false));
0 ignored issues
show
Coding Style introduced by
$fileseltray_photo does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
108
            $imgtray_checkbox = new Xoops\Form\Checkbox('', 'del_photo', 0);
0 ignored issues
show
Coding Style introduced by
$imgtray_checkbox does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
109
            $imgtray_checkbox->addOption(1, AlumniLocale::DELPICT);
0 ignored issues
show
Coding Style introduced by
$imgtray_checkbox does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
110
            $fileseltray_photo->addElement($imgtray_checkbox);
0 ignored issues
show
Coding Style introduced by
$fileseltray_photo does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
111
        }
112
        $imgtray_photo->addElement($fileseltray_photo);
0 ignored issues
show
Coding Style introduced by
$imgtray_photo does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
113
        $this->addElement($imgtray_photo);
0 ignored issues
show
Coding Style introduced by
$imgtray_photo does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
114
        $this->addElement(new Xoops\Form\Hidden('photo_old', $photo_old));
0 ignored issues
show
Coding Style introduced by
$photo_old does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
115
116
        $photo2_old            = $obj->getVar('photo2') ?: '';
0 ignored issues
show
Coding Style introduced by
$photo2_old does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
117
        $uploadirectory_photo2 = XOOPS_ROOT_PATH . '/modules/alumni/photos/now_photo';
0 ignored issues
show
Coding Style introduced by
$uploadirectory_photo2 does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
118
        $imgtray_photo2        = new Xoops\Form\ElementTray(AlumniLocale::NOW_PHOTO, '<br>');
0 ignored issues
show
Coding Style introduced by
$imgtray_photo2 does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
119
        $imgpath_photo2        = sprintf(AlumniLocale::FORMIMAGE_PATH, $uploadirectory_photo2);
0 ignored issues
show
Coding Style introduced by
$imgpath_photo2 does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
Unused Code introduced by
$imgpath_photo2 is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
120
        $fileseltray_photo2    = new Xoops\Form\ElementTray('', '<br>');
0 ignored issues
show
Coding Style introduced by
$fileseltray_photo2 does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
121
        $fileseltray_photo2->addElement(new Xoops\Form\File(AlumniLocale::FORMUPLOAD, 'photo2', $xoops->getModuleConfig('alumni_photomax')), false);
0 ignored issues
show
Coding Style introduced by
$fileseltray_photo2 does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
122
123 View Code Duplication
        if ($photo2_old) {
0 ignored issues
show
Coding Style introduced by
$photo2_old does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
124
            $fileseltray_photo2->addElement(new Xoops\Form\Label(AlumniLocale::PHOTO2, '<a href="photos/now_photo/' . $photo2_old . '">' . $photo2_old . '</a>', false));
0 ignored issues
show
Coding Style introduced by
$fileseltray_photo2 does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
125
            $imgtray_checkbox2 = new Xoops\Form\Checkbox('', 'del_photo2', 0);
0 ignored issues
show
Coding Style introduced by
$imgtray_checkbox2 does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
126
            $imgtray_checkbox2->addOption(1, AlumniLocale::DELPICT);
0 ignored issues
show
Coding Style introduced by
$imgtray_checkbox2 does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
127
            $fileseltray_photo2->addElement($imgtray_checkbox2);
0 ignored issues
show
Coding Style introduced by
$fileseltray_photo2 does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
128
        }
129
        $imgtray_photo2->addElement($fileseltray_photo2);
0 ignored issues
show
Coding Style introduced by
$imgtray_photo2 does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
130
        $this->addElement($imgtray_photo2);
0 ignored issues
show
Coding Style introduced by
$imgtray_photo2 does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
131
        $this->addElement(new Xoops\Form\Hidden('photo2_old', $photo2_old));
0 ignored issues
show
Coding Style introduced by
$photo2_old does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
132
        $this->addElement(new Xoops\Form\Text(AlumniLocale::EMAIL_2, 'email', 50, 255, $obj->getVar('email')), true);
133
        $this->addElement(new Xoops\Form\Text(AlumniLocale::OCC_2, 'occ', 50, 255, $obj->getVar('occ')), false);
134
        $this->addElement(new Xoops\Form\Text(AlumniLocale::TOWN_2, 'town', 50, 255, $obj->getVar('town')), false);
135
136
        if ($xoops->user->isAdmin()) {
137
            $this->addElement(new Xoops\Form\RadioYesNo(AlumniLocale::APPROVE_2, 'valid', $obj->getVar('valid'), XoopsLocale::YES, XoopsLocale::NO));
138
        }
139
        if ('1' == $xoops->getModuleConfig('alumni_use_captcha')) {
140
            $this->addElement(new Xoops\Form\Captcha());
141
        }
142
143
        $this->addElement(new Xoops\Form\Hidden('security', $xoops->security()->createToken()));
144
145
        if (isset($_REQUEST['date'])) {
146
            $this->addElement(new Xoops\Form\Hidden('date', $_REQUEST['date']));
147
        } else {
148
            $this->addElement(new XoopsFormHidden('date', time()));
149
        }
150
        $this->addElement(new Xoops\Form\Hidden('submitter', $xoops->user->uname()));
151
        $this->addElement(new Xoops\Form\Hidden('usid', $xoops->user->uid()));
152
        $this->addElement(new Xoops\Form\Hidden('op', 'save_listing'));
153
        $this->addElement(new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit'));
154
    }
155
}
156