/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk
20.1.1 by galaxyAbstractor
* Added an simple admin panel to the codeviewer-cmssy stuff
1
<?php
2
class Admin_model extends CI_Model {
3
4
	function __construct() {
5
		$this->load->database();
6
	}
7
8
	function getCourses() {
9
		$query = $this->db->get('courses');
10
		return $query->result();
11
	}
12
13
	function addCourse($cid, $name){
14
		$data = array(
15
			'cid' => $cid ,
16
			'name' => $name
17
		);
18
19
		$this->db->insert('courses', $data); 
20
		mkdir("../courses/".$cid);
21
22
	}
23
24
	function getExamples($cid) {
25
		$query = $this->db->get_where('examples', array("cid" => $cid));
26
		return $query->result();
27
	}
28
29
	function addExample($cid, $example){
30
		$data = array(
31
			'cid' => $cid ,
32
			'example' => $example
33
		);
34
35
		$this->db->insert('examples', $data); 
36
		mkdir("../courses/".$cid."/".$example);
37
38
	}
39
40
	function getPages($cid, $example) {
41
		$query = $this->db->get_where('pages', array("cid" => $cid, "example" => $example));
42
		return $query->result();
43
	}
44
45
	function addPage($cid, $example, $page, $documentation){
46
		$data = array(
47
			'cid' => $cid ,
48
			'example' => $example,
49
			'page' => $page ,
50
			'documentation' => $documentation 
51
		);
52
53
		$this->db->insert('pages', $data); 
54
		mkdir("../courses/".$cid."/".$example."/".$page);
55
56
	}
57
23.1.1 by galaxyAbstractor
Removed codeigniter user guide, shouldn't be in the repo
58
	function updatePage($cid, $example, $page, $documentation){
20.1.1 by galaxyAbstractor
* Added an simple admin panel to the codeviewer-cmssy stuff
59
		$data = array(
60
			'documentation' => $documentation 
61
		);
62
63
		$this->db->where('cid', $cid);
64
		$this->db->where('example', $example);
23.1.1 by galaxyAbstractor
Removed codeigniter user guide, shouldn't be in the repo
65
		$this->db->where('page', $page);
20.1.1 by galaxyAbstractor
* Added an simple admin panel to the codeviewer-cmssy stuff
66
		$this->db->update('pages', $data); 
67
	}
68
69
	function uploadFile($files, $cid, $example, $page){
70
		if(move_uploaded_file($files['tmp_name'], "../courses/".$cid."/".$example."/".$page."/".$files['name'])){
71
			echo json_encode(array('status'=>'File was uploaded successfuly!'));
72
		}	
73
	}
74
}