/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: Gustav Hatvigsson
  • Date: 2013-05-16 11:36:39 UTC
  • mfrom: (69.1.3 lenasys)
  • Revision ID: gustav.hartvigsson@gmail.com-20130516113639-1kr2ab9naio8k4e6
Merged some changes to the AJAX controller.

Show diffs side-by-side

added added

removed removed

Lines of Context:
147
147
                 *      This function registers user into the database.
148
148
                 *  RESTRICTED-LEVEL: Teacher
149
149
                 */
150
 
                public function addUser($userName, $name, $ssn, $password, $userType, $pwdHint) {
 
150
                public function addUser($userName, $name, $ssn, $password, $userType, $pwdHint, $email) {
151
151
                        //Check that a user is logged in and has the right privileges (is teacher)
152
152
                        if($this->isLoggedIn() && $this->getUserType() === 'Teacher') {
153
153
                                //Generate a salted hash
157
157
                                $this->db->set('userName', $userName);
158
158
                                $this->db->set('name', $name);
159
159
                                $this->db->set('ssn', $ssn);
160
 
                                $this->db->set('passwd', $password);
 
160
                                $this->db->set('passwd', $hash);
161
161
                                $this->db->set('userType', $userType);
162
162
                                $this->db->set('passwdHint', $pwdHint);
 
163
                                $this->db->set('email', $email);
163
164
                                $result = $this->db->insert('Users');
164
165
                                
165
166
                                //Check for my-sql error
166
167
                                if($result) {
167
168
                                        //Return success
168
169
                                        return TRUE;
169
 
                                }
 
170
                                } 
170
171
                        }
171
172
                        
172
173
                        //Return error
282
283
                                                'firstname' => substr($ladokUsers[$key][1], 0, stripos($ladokUsers[$key][1], ' ')),
283
284
                                                'email' => substr($ladokUsers[$key][1], (strrpos($ladokUsers[$key][1], ' ') + 1))
284
285
                                        );
 
286
                                        $temp['username'] = substr($temp['email'], 0, (stripos($temp['email'], '@')));
285
287
                                        array_push($userArray, $temp);
286
288
                                }
287
289