Exemple #1
0
 public static function remove(Video $video)
 {
     if (!Session::get('is_admin')) {
         if ($video->user_id !== Auth::user()->id_member) {
             return false;
         }
     }
     $video->delete();
     return true;
 }
Exemple #2
0
 /**
  * Unlink files from video
  */
 public function unlinkFromVideo()
 {
     $post = $this->input->post();
     if (!empty($post['video_id'])) {
         $video = new Video($post['video_id']);
         if (!empty($post['video_file_id'])) {
             $video->video_file_id = null;
             $video->save();
             $result['video_file_id'] = $post['video_file_id'];
         }
         if (!empty($post['file'])) {
             $file = new File($post['file'][0]);
             if ($file->exists()) {
                 $video->delete($file);
                 $result['file'] = $post['file'];
             }
         }
         $result['success'] = true;
         echo json_encode($result);
     }
 }
        exit;
    }

    if ($_GET['type'] == 'audio') {
        $new_image = new Audio();
        $new_image->content_id = $id;
        $new_image->delete($id);
        $msg = 2005;
        header("Location: $base_url/media_gallery.php?type=$type&msg_id=$msg&album_id=$album_id");
        exit;
    }

    if ($_GET['type'] == 'video') {
        $new_image = new Video();
        $new_image->content_id = $id;
        $new_image->delete($id);
        $msg = 2006;
        header("Location: $base_url/media_gallery.php?type=$type&msg_id=$msg&album_id=$album_id");
        exit;
    }
  }
}
catch (PAException $e) {
   $msg = "$e->message";
   $error = TRUE;
}
/* End of Uploading and deleting */
     
/* This function is a Callback function which initialize the value for the BLOCK MODULES */
function setup_module($column, $moduleName, $obj) {
/* in this module we have to set user_id , group_id, as well as netwrok_id */  
    Redirect::to('../index.php');
} else {
    if (!$user->isLoggedIn() || !$user->hasPermission('admin')) {
        Redirect::to('../index.php');
    } else {
        foreach ($_GET as $key => $value) {
            if ($value == "") {
                Redirect::to('../index.php');
            }
        }
        if (Input::exists('get')) {
            $video_entry = new Video();
            $video_entry_id = $video_entry->safe_string(Input::get('id'));
            $video_entry->find($video_entry_id);
            if (!$video_entry->exists()) {
                Redirect::to('../index.php');
            } else {
                $video_entry_title = $video_entry->data()->video_title;
                try {
                    $video_entry->delete(['id', '=', Input::get('id')]);
                    Session::flash('delete', 'Video for entry "' . $video_entry_title . '" has been deleted from the database.');
                    Redirect::to('../index.php');
                } catch (Exception $e) {
                    die($e->getMessage());
                }
            }
        } else {
            Redirect::to('../index.php');
        }
    }
}
                 if ($videoObj->{$postVar} === "") {
                     array_push($errorArr, "Please enter {$postVar} ");
                 }
                 break;
             default:
                 $videoObj->{$postVar} = filter_input(INPUT_POST, $postVar) ? mysqli_real_escape_string($dbObj->connection, filter_input(INPUT_POST, $postVar)) : '';
                 if ($videoObj->{$postVar} === "") {
                     array_push($errorArr, "Please enter {$postVar} ");
                 }
                 break;
         }
     }
     if (count($errorArr) < 1) {
         if ($videoMedFil != '' && file_exists(MEDIA_FILES_PATH . "video/" . $videoMedFil)) {
             unlink(MEDIA_FILES_PATH . "video/" . $videoMedFil);
             echo $videoObj->delete();
         } else {
             $json = array("status" => 0, "msg" => $errorArr);
             $dbObj->close();
             //Close Database Connection
             header('Content-type: application/json');
             echo json_encode($json);
         }
     } else {
         $json = array("status" => 0, "msg" => $errorArr);
         $dbObj->close();
         //Close Database Connection
         header('Content-type: application/json');
         echo json_encode($json);
     }
 }