Code Duplication    Length = 64-64 lines in 2 locations

caffeinated/admin/new/tickets/Tickets_Admin_Page.core.php 1 location

@@ 173-236 (lines=64) @@
170
    }
171
172
173
    public function get_default_tickets($per_page = 10, $count = false, $trashed = false)
174
    {
175
176
        $orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby'];
177
        $order = empty($this->_req_data['order']) ? 'ASC' : $order;
178
179
        switch ($orderby) {
180
            case 'TKT_name':
181
                $orderby = array('TKT_name' => $order);
182
                break;
183
184
            case 'TKT_price':
185
                $orderby = array('TKT_price' => $order);
186
                break;
187
188
            case 'TKT_uses':
189
                $orderby = array('TKT_uses' => $order);
190
                break;
191
192
            case 'TKT_min':
193
                $orderby = array('TKT_min' => $order);
194
                break;
195
196
            case 'TKT_max':
197
                $orderby = array('TKT_max' => $order);
198
                break;
199
200
            case 'TKT_qty':
201
                $orderby = array('TKT_qty' => $order);
202
                break;
203
        }
204
205
        $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
206
            ? $this->_req_data['paged'] : 1;
207
        $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
208
            ? $this->_req_data['perpage'] : $per_page;
209
210
        $_where = array(
211
            'TKT_is_default' => 1,
212
            'TKT_deleted'    => $trashed,
213
        );
214
215
        $offset = ($current_page - 1) * $per_page;
216
        $limit = array($offset, $per_page);
217
218
        if (isset($this->_req_data['s'])) {
219
            $sstr = '%' . $this->_req_data['s'] . '%';
220
            $_where['OR'] = array(
221
                'TKT_name'        => array('LIKE', $sstr),
222
                'TKT_description' => array('LIKE', $sstr),
223
            );
224
        }
225
226
        $query_params = array(
227
            $_where,
228
            'order_by' => $orderby,
229
            'limit'    => $limit,
230
            'group_by' => 'TKT_ID',
231
        );
232
233
        if ($count) {
234
            return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where));
235
        } else {
236
            return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params);
237
        }
238
    }
239

caffeinated/admin/extend/events/Extend_Events_Admin_Page.core.php 1 location

@@ 1169-1232 (lines=64) @@
1166
     * @param bool $trashed
1167
     * @return \EE_Soft_Delete_Base_Class[]|int
1168
     */
1169
    public function get_default_tickets($per_page = 10, $count = false, $trashed = false)
1170
    {
1171
        $orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby'];
1172
        $order = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order'];
1173
        switch ($orderby) {
1174
            case 'TKT_name':
1175
                $orderby = array('TKT_name' => $order);
1176
                break;
1177
            case 'TKT_price':
1178
                $orderby = array('TKT_price' => $order);
1179
                break;
1180
            case 'TKT_uses':
1181
                $orderby = array('TKT_uses' => $order);
1182
                break;
1183
            case 'TKT_min':
1184
                $orderby = array('TKT_min' => $order);
1185
                break;
1186
            case 'TKT_max':
1187
                $orderby = array('TKT_max' => $order);
1188
                break;
1189
            case 'TKT_qty':
1190
                $orderby = array('TKT_qty' => $order);
1191
                break;
1192
        }
1193
        $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
1194
            ? $this->_req_data['paged']
1195
            : 1;
1196
        $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
1197
            ? $this->_req_data['perpage']
1198
            : $per_page;
1199
        $_where = array(
1200
            'TKT_is_default' => 1,
1201
            'TKT_deleted'    => $trashed,
1202
        );
1203
        $offset = ($current_page - 1) * $per_page;
1204
        $limit = array($offset, $per_page);
1205
        if (isset($this->_req_data['s'])) {
1206
            $sstr = '%' . $this->_req_data['s'] . '%';
1207
            $_where['OR'] = array(
1208
                'TKT_name'        => array('LIKE', $sstr),
1209
                'TKT_description' => array('LIKE', $sstr),
1210
            );
1211
        }
1212
        $query_params = array(
1213
            $_where,
1214
            'order_by' => $orderby,
1215
            'limit'    => $limit,
1216
            'group_by' => 'TKT_ID',
1217
        );
1218
        if ($count) {
1219
            return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where));
1220
        } else {
1221
            return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params);
1222
        }
1223
    }
1224
1225
1226
    /**
1227
     * @param bool $trash
1228
     * @throws EE_Error
1229
     */
1230
    protected function _trash_or_restore_ticket($trash = false)
1231
    {
1232
        $success = 1;
1233
        $TKT = EEM_Ticket::instance();
1234
        // checkboxes?
1235
        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {