Esempio n. 1
0
                 $session->message("Success! Your password was updated. ");
                 redirect_to('admin_view_profile.php');
             } else {
                 $session->message("Error! Your password could not be updated. ");
             }
         } else {
             $session->message("Error! The existing password did not match. ");
         }
     }
     if (isset($_POST['upload'])) {
         $photo = new Photograph();
         $photo->related_object_type = '5';
         $photo->related_object_id = $user->id;
         $photo->photo_type = 9;
         // photo_type 9 is "User Profile"
         $photo->attach_file_admin_user($_FILES['file_upload'], $user->id, $user->first_name, $user->last_name);
         if ($photo->save()) {
             $session->message("Success! The photo was uploaded successfully. ");
             redirect_to('admin-list-admin-users.php');
         } else {
             $message = join("<br />", $photo->errors);
         }
     }
 } else {
     if ($session->object_type == 4) {
         //bus personnel
         $user = $bus_personnel_object->find_by_id($_SESSION['id']);
         $profile_picture = $photo_object->get_profile_picture($session->object_type, $user->id);
         $roles = BusPersonnelRole::find_all();
         $buses = Bus::find_all();
         if (isset($_POST['submit'])) {
                    $session->message("Success! The user's password was updated. ");
                    redirect_to('admin-list-admin-users.php');
                } else {
                    $session->message("Error! The user's password could not be updated. ");
                }
            } else {
                $session->message("Error! The existing password did not match. ");
            }
        }
        if (isset($_POST['upload'])) {
            $photo_to_upload = new Photograph();
            $photo_to_upload->related_object_type = '5';
            $photo_to_upload->related_object_id = $_GET['adminid'];
            $photo_to_upload->photo_type = '9';
            // photo_type 9 is "User Profile"
            $photo_to_upload->attach_file_admin_user($_FILES['file_upload'], $user_to_read_update->id, $user_to_read_update->first_name, $user_to_read_update->last_name);
            if ($photo_to_upload->save()) {
                $session->message("Success! The photo was uploaded successfully. ");
                redirect_to('admin-list-admin-users.php');
            } else {
                $message = join("<br />", $photo_to_upload->errors);
            }
        }
    } else {
        $session->message("Error! You do not have sufficient priviledges to view the requested page. ");
        redirect_to("index.php");
    }
} else {
    $session->message("Error! You must login to view the requested page. ");
    redirect_to("login.php");
}