Code Duplication    Length = 53-53 lines in 2 locations

main/inc/lib/event_email_template.class.php 1 location

@@ 79-131 (lines=53) @@
76
     *
77
     * @return  FormValidator
78
     */
79
    public function return_form($url, $action)
80
    {
81
        $form = new FormValidator('career', 'post', $url);
82
        // Setting the form elements
83
        $header = get_lang('Add');
84
        if ($action == 'edit') {
85
            $header = get_lang('Modify');
86
        }
87
88
        $form->addElement('header', $header);
89
        $id = isset($_GET['id']) ? intval($_GET['id']) : '';
90
        $form->addElement('hidden', 'id', $id);
91
        $form->addElement('text', 'name', get_lang('Name'), array('size' => '70'));
92
        $form->addHtmlEditor(
93
            'description',
94
            get_lang('Description'),
95
            false,
96
            false,
97
            array(
98
                'ToolbarSet' => 'careers',
99
                'Width' => '100%',
100
                'Height' => '250',
101
            )
102
        );
103
        $status_list = $this->get_status_list();
104
        $form->addElement('select', 'status', get_lang('Status'), $status_list);
105
        if ($action == 'edit') {
106
            $form->addElement('text', 'created_at', get_lang('CreatedAt'));
107
            $form->freeze('created_at');
108
        }
109
110
        if ($action == 'edit') {
111
            $form->addButtonSave(get_lang('Modify'), 'submit');
112
        } else {
113
            $form->addButtonCreate(get_lang('Add'), 'submit');
114
        }
115
116
        // Setting the defaults
117
        $defaults = $this->get($id);
118
119
        if (!empty($defaults['created_at'])) {
120
            $defaults['created_at'] = api_convert_and_format_date($defaults['created_at']);
121
        }
122
        if (!empty($defaults['updated_at'])) {
123
            $defaults['updated_at'] = api_convert_and_format_date($defaults['updated_at']);
124
        }
125
        $form->setDefaults($defaults);
126
127
        // Setting the rules
128
        $form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
129
130
        return $form;
131
    }
132
133
    public function get_count()
134
    {

main/inc/lib/career.lib.php 1 location

@@ 109-161 (lines=53) @@
106
     * @param   string  $action add, edit
107
     * @return  FormValidator
108
     */
109
    public function return_form($url, $action)
110
    {
111
        $form = new FormValidator('career', 'post', $url);
112
        // Setting the form elements
113
        $header = get_lang('Add');
114
        if ($action == 'edit') {
115
            $header = get_lang('Modify');
116
        }
117
118
        $form->addElement('header', $header);
119
        $id = isset($_GET['id']) ? intval($_GET['id']) : '';
120
        $form->addElement('hidden', 'id', $id);
121
        $form->addElement('text', 'name', get_lang('Name'), array('size' => '70'));
122
        $form->addHtmlEditor(
123
            'description',
124
            get_lang('Description'),
125
            false,
126
            false,
127
            array(
128
                'ToolbarSet' => 'Careers',
129
                'Width' => '100%',
130
                'Height' => '250'
131
            )
132
        );
133
        $status_list = $this->get_status_list();
134
        $form->addElement('select', 'status', get_lang('Status'), $status_list);
135
        if ($action == 'edit') {
136
            $form->addElement('text', 'created_at', get_lang('CreatedAt'));
137
            $form->freeze('created_at');
138
        }
139
        if ($action == 'edit') {
140
            $form->addButtonSave(get_lang('Modify'), 'submit');
141
        } else {
142
            $form->addButtonCreate(get_lang('Add'), 'submit');
143
        }
144
145
        // Setting the defaults
146
        $defaults = $this->get($id);
147
148
        if (!empty($defaults['created_at'])) {
149
            $defaults['created_at'] = api_convert_and_format_date($defaults['created_at']);
150
        }
151
        if (!empty($defaults['updated_at'])) {
152
            $defaults['updated_at'] = api_convert_and_format_date($defaults['updated_at']);
153
        }
154
        $form->setDefaults($defaults);
155
156
        // Setting the rules
157
        $form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
158
159
        return $form;
160
    }
161
162
    /**
163
     * Copies the career to a new one
164
     * @param   integer     Career ID