New_staff_export::index()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 13
nc 1
nop 0
dl 0
loc 21
rs 9.3142
c 0
b 0
f 0
1
<?php defined('BASEPATH') OR exit('No direct script access allowed');
2
3
class New_staff_export extends My_Public {
4
5
    public function __construct() {
6
        parent::__construct();
7
        $this->load->helper('download');
8
        $this->load->model('computing-support/New_account_model', 'new_account_model');
9
        
10
    }
11
    
12
    // URLs for both funtions locked using htpasswd in Apache config.
13
    // Script on SAD02-46 accesses these using the htpasswd account.
14
    // Used to download new staff csv and complete staff after creation.
15
    
16
    // This controller must be PUBLIC
17
    
18
    // If changed are made, duplicate in New_account.php controller.
19
     
20
    function index() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
21
        
22
            $function = 'SAD-02_export_staff_accounts';
23
            $this->user_model->function_log($function);
24
        
25
            $this->load->dbutil();
26
            //MySQL View - only export incomplete
27
            $query = $this->db->query("SELECT * FROM new_account_export");
28
            $delimiter = ",";
29
            $newline = "\n";
30
            $output = $this->dbutil->csv_from_result($query, $delimiter, $newline);
31
32
            function clean_export($string) {
0 ignored issues
show
Best Practice introduced by
The function clean_export() has been defined more than once; this definition is ignored, only the first definition in dashboard/application/co...g-support/Disposals.php (L153-156) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
33
                $string = str_replace('"', '', $string); // Replaces all spaces with hyphens - Required by SAD02-46 script.
34
                return $string;
35
            }
36
37
            $output = clean_export($output);
38
            force_download("newstaff.csv", $output);
39
        
40
    }
41
42
    public function complete() {
43
        
44
            $function = 'SAD-02_complete_staff_accounts';
45
            $this->user_model->function_log($function);
46
        
47
            $this->new_account_model->complete_account();
48
49
            $this->load->view('templates/header');
50
            $this->load->view('computing-support/new-account/complete');
51
            $this->load->view('templates/footer');
52
    }
53
}