/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/user.php

  • Committer: a11andoh
  • Date: 2013-05-28 14:18:18 UTC
  • mto: This revision was merged to the branch mainline in revision 121.
  • Revision ID: a11andoh@student.his.se-20130528141818-a95jt0njmm2e7bif
added information to the XML API course to be able to test with the system

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
                        $hash = $this->getSaltedHash($password);
52
52
        
53
53
                        //Query-structure
54
 
                        $this->db->select('userName, name, passwd, userType, ssn'); // Tog bort firstLogin här.
 
54
                        $this->db->select('userName, name, passwd, userType, ssn, activeCourse'); // Tog bort firstLogin här.
55
55
                        $this->db->from('Users');
56
56
                        $this->db->where('userName', $username);
57
57
                        $this->db->where('passwd', $hash);
71
71
                                                'name' => $row->name,
72
72
                                                'usertype' => $row->userType,
73
73
                                                'ssn' => $row->ssn,
 
74
                                                'activeCourse' => $row->activeCourse, 
74
75
                                        //      'firstLogin' => $row->firstLogin
75
76
                                        );
76
77
                                }
174
175
                        return FALSE;
175
176
                }
176
177
 
 
178
                /* 
 
179
                 * Updates the details of a user. Takes a username and an associative array of data with the details to be changed 
 
180
                 */
 
181
                public function updateUser($username, $data) {
 
182
                        $this->db->where("username", $username);
 
183
                        $this->db->update("Users", $data);
 
184
                }
 
185
 
177
186
 
178
187
                /*
179
188
                 *      This function removes users from the database.
384
393
                        
385
394
                        return FALSE;
386
395
                }
 
396
                
 
397
                /*
 
398
                * This function fetches the active course info
 
399
                */
 
400
                public function getActiveCourse(){
 
401
                        
 
402
                        if($this->isLoggedIn()) {
 
403
                                $temp = $this->session->userdata('authenticated');
 
404
                                $courseID = $temp['activeCourse'];
 
405
                                $courseName;
 
406
                        
 
407
                                //Query-structure
 
408
                                $this->db->select('name');
 
409
                                $this->db->from('Courses');
 
410
                                $this->db->where('courseID', $courseID);
 
411
                                $this->db->limit(1);
 
412
                                //Execute query
 
413
                                $query = $this->db->get();
 
414
                                $result = $query->result();
 
415
 
 
416
                                foreach($result as $row) {
 
417
                                        $courseName = $row->name;
 
418
                                }
 
419
                                
 
420
                                $data = array(
 
421
                                        'courseID' => $courseID,
 
422
                                        'courseName' => $courseName
 
423
                                );
 
424
                                
 
425
                                return $data;
 
426
                        }
 
427
                        return FALSE;
 
428
                }
387
429
        }
388
 
        
389
430
?>
 
 
b'\\ No newline at end of file'