Example #1
0
 private function editProfile()
 {
     if ($this->registry->getObject('authenticate')->isLoggedIn() == true) {
         $user = $this->registry->getObject('authenticate')->getUser()->getUserID();
         if (isset($_POST) && count($_POST) > 0) {
             $profile = new ProfileModel($this->registry, $user);
             $profile->setBio($this->registry->getObject('db')->sanitizeData($_POST['bio']));
             $profile->setName($this->registry->getObject('db')->sanitizeData($_POST['name']));
             $profile->setGender($this->registry->getObject('db')->sanitizeData($_POST['gender']), false);
             $profile->setDOB($this->registry->getObject('db')->sanitizeData($_POST['dob']), false);
             if (isset($_FILES['profile_pic'])) {
                 require_once 'mediaManager.php';
                 $im = new ImageManager();
                 $image = $im->loadFromPost('profile_pic', $this->registry->getSetting('upload_path') . 'profile/' . $profile->getUsername() . '/', time());
                 //$images .= $image;
                 if ($image == true) {
                     $im->resizeScale(50);
                     $im->save($this->registry->getSetting('upload_path') . 'profile/' . $im->getName());
                     $profile->setPhoto($im->getName());
                 }
                 //$this->registry->redirectUser('profile/edit/'.$profile->getID(), 'Image Saved', 'Image upload success');
             } else {
                 $this->registry->errorPage('Error', 'Image uploading failed');
             }
             $profile->save();
             $this->registry->redirectUser('profile/view', 'Profile saved', 'The changes to your profile have been saved.');
             //array('profile', 'view', 'edit')
         } else {
             //Show the edit form
             $this->registry->getObject('template')->buildFromTemplate('header.php', 'profile_info_edit.php', 'footer.php');
             $profile = new ProfileModel($this->registry, $user);
             $profile->toTags('p_');
         }
     } else {
         $this->registry->errorPage('Error', 'Please login to continue');
     }
 }