/lenasys/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/trunk

« back to all changes in this revision

Viewing changes to codeigniter/application/models/admin/admin_model.php

  • Committer: Gustav Hatvigsson
  • Date: 2013-04-11 09:20:09 UTC
  • mfrom: (19.1.5 lenasys)
  • Revision ID: gustav.hartvigsson@gmail.com-20130411092009-ylcqzqwcmjdglb17
merged in implemetaion group one's team bransh, it contains code-ignighter
and the new admin-panel.
20130411

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
58
        function managePage($cid, $example, $page, $documentation){
 
59
                $data = array(
 
60
                        'documentation' => $documentation 
 
61
                );
 
62
 
 
63
                $this->db->where('cid', $cid);
 
64
                $this->db->where('example', $example);
 
65
                $this->db->where('documentation', $documentation);
 
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
}