Example #1
0
 if ($user->isAdmin()) {
     $newFirstName = $_POST['firstName'];
     $newLastName = $_POST['lastName'];
 }
 $newProfileDescription = $_POST['profileDescription'];
 $newMobileNumber = $_POST['newMobileNum'];
 // check if new changes are required. if to update process
 if ($user->isAdmin() && strcmp($prevFirstName, $newFirstName) !== 0) {
     User::updateName($user->getId(), User::DB_COLUMN_FIRST_NAME, $newFirstName);
     $newUpdate = true;
 }
 if ($user->isAdmin() && strcmp($prevLastName, $newLastName) !== 0) {
     if (!$user->isAdmin()) {
         throw new Exception("You're trying to hack this app. Process aborted.");
     }
     User::updateName($user->getId(), User::DB_COLUMN_LAST_NAME, $newLastName);
     $newUpdate = true;
 }
 if (strcmp($prevProfileDescription, $newProfileDescription) !== 0) {
     User::updateProfileDescription($user->getId(), $newProfileDescription);
     $newUpdate = true;
 }
 if (strcmp($prevMobileNumber, $newMobileNumber) !== 0) {
     User::updateMobileNumber($user->getId(), $newMobileNumber);
     $newUpdate = true;
 }
 // TODO: use OOP instead of procedural programming for file upload
 if (isNewAvatarImageUploadedTemp()) {
     uploadAvatarImage($user);
     $newUpdate = true;
 }
Example #2
0
     header('location:../controle.php#tabs-1');
     # code...
     break;
 case 'updateadmin':
     $id = $_GET['id'];
     $user->admin = $_GET['admin'];
     $user->updateAdmin($id);
     echo "user update succsess";
     header('location:../controle.php#tabs-1');
     # code...
     break;
 case 'editname':
     $id = $_SESSION['user_id'];
     $name = $_GET['name'];
     $user->name = $name;
     $user->updateName($id);
     echo "user update succsess";
     break;
 case 'editemail':
     $id = $_SESSION['user_id'];
     $email = $_GET['email'];
     $user->email = $email;
     $user->updateemail($id);
     echo "user update succsess";
     break;
 case 'editpassword':
     $id = $_SESSION['user_id'];
     $password = $_GET['password'];
     $user->password = $password;
     $user->updatepassword($id);
     echo "user update succsess";
Example #3
0
 public static function createUser($username)
 {
     $user = new User();
     $user->setUser($username);
     $user->setName($username);
     $user->setEmail($username . "@imperial.ac.uk");
     $user->setInfo(json_encode(array()));
     $user->setVisits(0);
     $user->setIp(0);
     $user->setImage(676);
     // FIXME - Move to const
     $user->setShowEmail(TRUE);
     $user->setShowLdap(TRUE);
     $user->updateName();
     $user->updateEmail();
     $user->updateInfo();
     $user->save();
     return $user;
 }