Completed
Push — master ( d21053...c59b30 )
by
unknown
08:11
created

UploadUsersFile::setStatus()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Upload users file class
5
 *
6
 * @package upload_users
7
 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
8
 * @author Jaakko Naakka / Mediamaisteri Group
9
 * @author Ismayil Khayredinov / Arck Interactive
10
 * @copyright Mediamaisteri Group 2009
11
 * @copyright ArckInteractive 2013
12
 * @link http://www.mediamaisteri.com/
13
 * @link http://arckinteractive.com/
14
 */
15
class UploadUsersFile extends ElggFile {
16
17
	protected function initializeAttributes() {
18
		parent::initializeAttributes();
19
20
		$this->attributes['subtype'] = "upload_users_file";
21
	}
22
23
	public function __construct($guid = null) {
24
		parent::__construct($guid);
25
	}
26
27
	function parseCSVHeader() {
28
		if (($handle = fopen($this->getFilenameOnFilestore(), 'r')) !== FALSE) {
29
			return fgetcsv($handle, 0, $this->delimiter, $this->enclosure);
30
		}
31
		return false;
32
	}
33
34
	function parseCSV() {
35
		$data = array();
36
		if (($handle = fopen($this->getFilenameOnFilestore(), 'r')) !== FALSE) {
37
			while (($row = fgetcsv($handle, 0, $this->delimiter, $this->enclosure)) !== FALSE) {
38
				if (empty($headers)) {
39
					$headers = $row;
40
				} else {
41
					$data[] = array_combine($headers, $row);
42
				}
43
			}
44
			fclose($handle);
45
		}
46
47
		return $data;
48
	}
49
50
	function setHeaderMapping($mapping = array()) {
51
		$this->header_mapping = serialize($mapping);
52
	}
53
54
	function getHeaderMapping() {
55
		return (isset($this->header_mapping)) ? unserialize($this->header_mapping) : null;
56
	}
57
58
	function setRequiredFieldMapping($mapping = array()) {
59
		$this->required_fields_mapping = serialize($mapping);
60
	}
61
62
	function getRequiredFieldMapping() {
63
		return (isset($this->required_fields_mapping)) ? unserialize($this->required_fields_mapping) : null;
64
	}
65
66
	function setStatus($status = '') {
67
		$this->status = $status;
68
	}
69
70
	function getStatus() {
71
		return ($this->status) ? $this->status : 'uploaded';
72
	}
73
74
}
75