Example #1
0
 if (isset($_POST['addAlbum'])) {
     $user = new User($_POST['addAlbum']);
     $statement = $user->addAlbum($_POST['albumName'], $_POST['description']);
 } else {
     if (isset($_POST['getPhoto'])) {
         $user = new User($_POST['getPhoto']);
         $statement = $user->getPhoto($_POST['i'], $_POST['j']);
     } else {
         if (isset($_POST['editPhoto'])) {
             $user = new User($_POST['editPhoto']);
             $user->editPhoto($_POST['i'], $_POST['j'], $_POST['description'], $_POST['photoDate']);
             $statement = true;
         } else {
             if (isset($_POST['addPhoto'])) {
                 $user = new User($_POST['addPhoto']);
                 $statement = $user->addPhoto($_POST['i'], $_POST['photoName'], $_POST['description'], $_POST['photoSize'], $_POST['photoDate'], $_POST['sourcePath']);
             } else {
                 if (isset($_POST['deletePhoto'])) {
                     $user = new User($_POST['deletePhoto']);
                     if (is_array($_POST['j'])) {
                         //allow to delete multiple photo at a times by pass array of integers
                         rsort($_POST['j']);
                         //to make sure that deletion will start for behind
                         for ($i = 0; $i < count($_POST['j']); $i++) {
                             $photoInfo = $user->getPhoto($_POST['i'], $_POST['j'][$i]);
                             unlink($photoInfo['sourcePath']);
                             $user->deletePhoto($_POST['i'], $_POST['j'][$i]);
                         }
                         $statement = true;
                     } else {
                         $photoInfo = $user->getPhoto($_POST['i'], $_POST['j']);