/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: a11timgu
  • Date: 2013-05-30 08:52:01 UTC
  • mfrom: (125 lenasys_b)
  • mto: This revision was merged to the branch mainline in revision 127.
  • Revision ID: a11timgu@student.his.se-20130530085201-vzvlcuxzljq5m2zh
sdasdawd:

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
                $this->load->database();
13
13
        }
14
14
 
15
 
 
 
15
        /* Get all of the courses */
16
16
        function getCourses() {
17
17
                $this->db->order_by("name", "asc");
18
18
                $query = $this->db->get('Courses');
19
19
                return $query->result();
20
20
        }
 
21
        
 
22
        /* Get all the public courses */
 
23
        function getPublicCourses() {
 
24
                $this->db->from("Courses");
 
25
                $this->db->order_by("name", "asc");
 
26
                $this->db->where("isHidden","0");
 
27
                $this->db->where("isPublic","1");
 
28
                $query = $this->db->get();
 
29
                return $query->result();
 
30
        }
 
31
        
 
32
        /* Get all the private courses for a student - If they are published and private*/
 
33
        function getPrivateCourses($username) {
 
34
                $this->db->from("Courses");
 
35
                $this->db->join("StudentCourseRegistrations", "Courses.courseID = StudentCourseRegistrations.courseID");
 
36
                $this->db->order_by("name", "asc");
 
37
                $this->db->where("userName", $username);
 
38
                $this->db->where("isPublic", "0");
 
39
                $this->db->where("isHidden","0");
 
40
                $query = $this->db->get();
 
41
                return $query->result();
 
42
        }
 
43
        
 
44
        /* Get all the courses for a student, both private from getPrivateCourses(), and public from getPublicCourses() */
 
45
        function getStudentCourses($username) {
 
46
                $private = $this->getPrivateCourses($username);
 
47
                $public = $this->getPublicCourses();
 
48
                return array_merge($private, $public);
 
49
        }
 
50
 
 
51
        function setCourseHidden($courseID) {
 
52
                $this->db->where("courseID", $courseID);
 
53
                $this->db->update("Courses", array("isHidden" => 1));
 
54
        }
 
55
 
 
56
        function unsetCourseHidden($courseID){
 
57
                $this->db->where("courseID", $courseID);
 
58
                $this->db->update("Courses", array("isHidden" => 0));
 
59
        }
21
60
 
22
61
        function addCourse($cid, $name, $courseData){
23
62
                $data = array(
31
70
 
32
71
        }
33
72
 
 
73
        function editCourse($cid, $name, $courseData) {
 
74
                $data = array(
 
75
                        'name' => $name,
 
76
                        'courseData' => $courseData
 
77
                );
 
78
 
 
79
                $this->db->where('courseID', $cid);
 
80
                $this->db->update('Courses', $data);
 
81
        }
 
82
 
34
83
        function getMenu(){
35
84
                $menu = array();
36
85
                $courses = $this->db->get("Courses");
56
105
        }
57
106
 
58
107
        function getCategories($cid) {
 
108
                $this->db->order_by("orderNr", "asc");
59
109
                $query = $this->db->get_where('Categories', array("courseID" => $cid));
60
110
                return $query->result();
61
111
        }
211
261
                        echo json_encode(array('status'=>'File was uploaded successfuly!'));
212
262
                }       
213
263
        }
 
264
 
214
265
}