/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
class Admin_model extends CI_Model {

	function __construct() {
		$this->load->database();
	}

	function getCourses() {
		$query = $this->db->get('courses');
		return $query->result();
	}

	function addCourse($cid, $name){
		$data = array(
			'cid' => $cid ,
			'name' => $name
		);

		$this->db->insert('courses', $data); 
		mkdir("../courses/".$cid);

	}

	function getExamples($cid) {
		$query = $this->db->get_where('examples', array("cid" => $cid));
		return $query->result();
	}

	function addExample($cid, $example){
		$data = array(
			'cid' => $cid ,
			'example' => $example
		);

		$this->db->insert('examples', $data); 
		mkdir("../courses/".$cid."/".$example);

	}

	function getPages($cid, $example) {
		$query = $this->db->get_where('pages', array("cid" => $cid, "example" => $example));
		return $query->result();
	}

	function addPage($cid, $example, $page, $documentation){
		$data = array(
			'cid' => $cid ,
			'example' => $example,
			'page' => $page ,
			'documentation' => $documentation 
		);

		$this->db->insert('pages', $data); 
		mkdir("../courses/".$cid."/".$example."/".$page);

	}

	function managePage($cid, $example, $page, $documentation){
		$data = array(
			'documentation' => $documentation 
		);

		$this->db->where('cid', $cid);
		$this->db->where('example', $example);
		$this->db->where('documentation', $documentation);
		$this->db->update('pages', $data); 
	}

	function uploadFile($files, $cid, $example, $page){
		if(move_uploaded_file($files['tmp_name'], "../courses/".$cid."/".$example."/".$page."/".$files['name'])){
			echo json_encode(array('status'=>'File was uploaded successfuly!'));
		}	
	}
}