EVOLUTION-NINJA
Edit File: E_video.php
<?php namespace App\Controllers\video; use App\Controllers\BaseController; use CodeIgniter\RESTful\ResourceController; use CodeIgniter\API\ResponseTrait; use App\Models\VideoModel; use App\Models\VideoSectionModel; use App\Models\OrganisationModel; use App\Models\VideoCatagoryModel; require_once('../vendor/autoload.php'); require_once('../vendor/vimeo/vimeo-api/src/Vimeo/Vimeo.php'); use Vimeo\Vimeo; use App\Models\NotificationModel; class E_video extends BaseController { use ResponseTrait; public function __construct() { helper(['form','url']); } public function index(){ $dr_id = session()->get('dr_id'); $section = new VideoSectionModel(); $details = $section->findAll(); $data['section'] = $details; // print_r($details);die(); if($dr_id){ return view('video/e-video',$data); }else{ return redirect()->route("login"); } } public function find_sub_categories(){ $id = $this->request->getVar('id'); // print_r($id);die(); $findsub = new VideoCatagoryModel(); $details = $findsub->where('field_names',$id)->findAll(); // $data['subpart'] = $details; // print_r($details);die(); if(!empty($details)){ return json_encode(array( 'result' => 1, )); } else{ return json_encode(array( 'result' => 0, 'message' => 'No Sub Categories Found' )); } } public function video_edit_list(){ $org_id = session()->get('org_id'); $role_id = session()->get('role_id'); if($org_id){ $edituser=['z,x,y']; $data['user_management'] = $edituser; if($org_id == 1 ){ //super admin $model = new OrganisationModel(); // $model->where('id',$temple_id); $details = $model->get()->getResultArray(); $data['org'] = $details; } else{ $model = new OrganisationModel(); // $model->where('id',$org_id); $details = $model->get()->getResultArray(); $data['org'] = $details; } // $model = new AdminModel(); // $user_details = $model->get()->getResultArray(); // $data['details'] = $user_details; return view('admin/video_list_v', $data); }else{ return view('admin/super-admin-login'); } } public function video_upload(){ $dr_id = session()->get('dr_id'); $section = new VideoSectionModel(); $details = $section->findAll(); $data['section'] = $details; $model = new OrganisationModel(); $details = $model->get()->getResultArray(); $data['org'] = $details; if($dr_id){ return view('video/Upload',$data); }else{ return redirect()->route("login"); } } public function upload() { $org_id = session()->get('org_id'); $dr_id = session()->get('dr_id'); print_r($_POST); print_r($_GET);die(); $section_id = $this->request->getVar('field_name'); $category_id = $this->request->getVar('category'); $clientId = "611557a1e37caa2c0a6e3386c20a930fb021dc03"; $clientSecret = "BOMlaqiovPJZauRKZ6ZKkWNclEn17AZJ9gCXJVRWeukZQt+PDpgstfJ/GbdePxsAoi/RelOmQxabuCcY2ni/ftFtVylNasyq3+zQ6wKCjXKD97/wW5gWzDP2lopx7swv"; $accessToken = "898a649a97f4916ad0222eb39d36d018"; $client = new Vimeo($clientId,$clientSecret,$accessToken); $response = $client->request('/tutorial', array(), 'GET'); $file = $_FILES['file1']['name']; $tmp = $_FILES['file1']['tmp_name']; $title = $_POST['vidtitle']; $desc = $_POST['viddesc']; $uri = $client->upload($tmp, array( "name" => $title, "description" => $desc )); $response = $client->request($uri . '?fields=transcode.status'); $response = $client->request($uri . '?fields=link'); $video_link = $response['body']['link']; $get_vid_id = explode("/",$video_link); $get_vid_id = $get_vid_id['3']; if($video_link){ $title1 = "New Video Is Added"; $message = $title." Video Is Added.."; $date = date("Y-m-d"); $details = array( //'user_id'=>$user_id, 'type'=>$title1, 'message'=>$message, 'sending_to'=>"All", 'status'=>'active', 'created_at'=>$date ); $add_note = new NotificationModel(); $add_note->save($details); $insertedID = $add_note->insertID(); $video_data = array( 'org_id'=> $org_id, 'dr_id' => $dr_id, 'section_id' => $section_id, 'category_id' => $category_id, 'video_link'=> $get_vid_id, "title" => $title, "description" => $desc, 'delete_status'=> 'ACTIVE' ); $model = new VideoModel(); $model->save($video_data); $insertedId = $model->insertID(); if($insertedId){ return json_encode(array( 'result' => 1, 'message' => 'Added Successfully.....' )); } else{ return json_encode(array( 'result' => 0, 'message' => 'Something went wrong.....' )); } }else{ return json_encode(array( 'result' => 0, 'message' => 'Something went wrong.....' )); } } public function get_video_c_list(){ $org_id = session()->get('org_id'); $section = $_GET['section_input']; $model = new VideoCatagoryModel(); $model->where('org_id',$org_id); $model->where('field_names',$section); $details = $model->findAll(); if($details){ return json_encode(array( 'result' => 1, 'data' => $details, )); } else{ return json_encode(array( 'result' => 0, 'message' => 'No Category Created...' )); } } public function search_all_details_video(){ $field = $this->request->getVar('field_input'); // print_r($field);die(); $data1= []; $Model = new VideoSectionModel(); $Model->select('video_section.master_name,video_categories.category_name,video_table.title,video_table.id'); $Model->join('video_categories','video_section.id=video_categories.field_names'); $Model->join('video_table','video_section.id=video_table.section_id'); $Model->like('video_section.master_name',$field); $Model->orLike('video_categories.category_name',$field); $Model->orLike('video_table.title',$field); $data1 = $Model->get()->getResultArray(); // print_r($data1);die(); echo json_encode($data1); } public function search_details_video(){ $field = $this->request->getVar('field'); $id = $this->request->getVar('id'); $data1= []; $Model = new VideoCatagoryModel(); $Model->select('video_categories.fields,video_categories.category_name,video_table.title,video_table.id'); $Model->join('video_table','video_categories.field_names=video_table.section_id'); $Model->like('video_categories.category_name',$field); $Model->where('video_categories.field_names',$id)->orLike('video_categories.fields',$field); $Model->where('video_table.section_id',$id)->orLike('video_table.title',$field); $Model->where('video_categories.field_names',$id); $data1 = $Model->get()->getResultArray(); echo json_encode($data1); } public function list(){ echo 'hello'; } public function get_all_users(){ // print_r($org_id); die(); $dbDetails = array( "host"=>$this->db->hostname, "user"=>$this->db->username, "pass"=>$this->db->password, "db"=>$this->db->database, "port"=>$this->db->port ); $table = "video_table"; $primaryKey = "id"; $columns = array( array( "db"=>"id", "dt"=>0, ), // array( // "db"=>"field_names", // "dt"=>1, // ), array( "db"=>"title", "dt"=>1, ), array( "db"=>"description", "dt"=>2, ), array( "db"=>"id", "dt"=>3, "formatter"=>function($d, $row){ return "<div class='btn-group'> <button type='button' class='btn btn-sm btn-primary' data-id='".$row['id']."' id='updateCountryBtn'>Update</button> <button type='button' class='btn btn-sm btn-danger' data-id='".$row['id']."' id='deleteCountryBtn'>Delete</button> </div>"; } ), ); echo json_encode( \SSP::simple($_GET, $dbDetails, $table, $primaryKey, $columns, null, "status= '1'") ); } } ?>