EVOLUTION-NINJA
Edit File: Guidelines1.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; use App\Models\RegisterUserModel; use App\Models\CommentModel; use App\Models\NotificationModel; class Guidelines1 extends BaseController { use ResponseTrait; public function __construct() { helper(['form','url']); } public function index() { $values = $_GET['id']; $dr_id = session()->get('dr_id'); $findsub = new VideoModel(); $details = $findsub->where('categories_id',$values)->findAll(); $data['subpart'] = $details; $subcatename = new VideoCatagoryModel(); $details1 = $subcatename->select('fields,category_name')->where('id',$values)->first(); $data['category_name'] = $details1; // print_r($details1);die(); if($dr_id){ return view('video/guidelines-1',$data); }else{ return redirect()->route("login"); } } public function get_video_c_list(){ $org_id = session()->get('org_id'); $section = $_GET['category']; $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 iframe() { return view('vimeo/iframe'); } public function upload() { $org_id = session()->get('org_id'); $dr_id = session()->get('dr_id'); $section_id = $this->request->getVar('field_name'); $category_id = $this->request->getVar('category'); // $clientId = "4dd7996c03103fa81b585bc5a685046b2694920c"; // $clientSecret = "q8ron6BE8Zd/qo7jTfe4S4tFb2z4tQe2suiwscVJvTT099OaVMASsMWGwTDwI/tkdF84SHfnzcUDpGOELv2o9no++4URtrxVzCzGUISyZ+kFhIgT2JSBWurizIkD+xfS"; // $accessToken = "f6943c44e810eb5439775f5cabcb7f71"; $clientId = "611557a1e37caa2c0a6e3386c20a930fb021dc03"; $clientSecret = "BOMlaqiovPJZauRKZ6ZKkWNclEn17AZJ9gCXJVRWeukZQt+PDpgstfJ/GbdePxsAoi/RelOmQxabuCcY2ni/ftFtVylNasyq3+zQ6wKCjXKD97/wW5gWzDP2lopx7swv"; $accessToken = "898a649a97f4916ad0222eb39d36d018"; error_reporting(E_ALL); ini_set('display_errors', 1); $client = new Vimeo($clientId,$clientSecret,$accessToken); $response = $client->request('/tutorial', array(), 'GET'); // print_r($response);die(); $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){ $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 ls1_video() { if(session()->get('name')){ $values = $_GET['id']; $model = new VideoModel(); $model->where('category_id',$values); $model->where('status','1'); $result = $model->get()->getResultArray(); $data['video'] = $result; $array = array(); $model = new VideoSectionModel(); $result = $model->get()->getResultArray(); foreach ($result as $val){ $cat = array(); $obj['name'] = $val['master_name']; $obj['id'] = $val['id']; $model1 = new VideoCatagoryModel(); $model1->where('field_names',$val['id']); $result1 = $model1->get()->getResultArray(); foreach($result1 as $res){ $catobj['name'] = $res['category_name']; $catobj['id'] = $res['id']; array_push($cat,$catobj); } $obj['cat'] = $cat; array_push($array,$obj); } $data['cate'] = $array; return view('video/Video',$data); } else{ //echo 'hello'; return redirect()->to('login'); } } public function ls2_video() { if(session()->get('name')){ $id = $_GET['id']; $model = new VideoModel(); $model->where('id',$id); $result = $model->get()->getResultArray(); $findsub = new VideoModel(); $details = $findsub->where('id',$id)->findAll(); $user = new RegisterUserModel(); $user_details = $user->where('id',$details[0]['dr_id'])->findAll(); $commet = new CommentModel(); $commet->where('blog_id',$id); $commet->where('parent_id','0'); $commet->orderBy('id','DESC'); $data['commet_details'] = $commet->get()->getResultArray(); $reply = new CommentModel(); $reply->where('blog_id',$id); $reply->where('parent_id >',0); //$reply->orderBy('id','DESC'); $data['reply_details'] = $reply->get()->getResultArray(); $data['dr_name'] = $user_details[0]['f_name']; $data['video_id'] = $id; $data['video'] = $result; return view('video/video2',$data); } else{ return redirect()->to('login'); } } public function savecomment() { if(session()->get('name')){ $org_id = session()->get('org_id'); $dr_id = session()->get('dr_id'); $f_name = session()->get('name'); $id = $this->request->getVar('id'); $Comment_id = $this->request->getVar('Comment_id'); $comment = $this->request->getVar('comment'); $main_id = 0; $name = ''; $title = ''; $message = ''; if($Comment_id != '0'){ $parent_com = new CommentModel(); $parent_com_details = $parent_com->where('id',$Comment_id)->findAll(); if($parent_com_details[0]['main_id'] == 0){ $main_id = $parent_com_details[0]['id']; } else{ $main_id = $parent_com_details[0]['main_id']; } if($parent_com_details[0]['parent_id'] == 0){ $name = ''; $comment = $comment; $model = new VideoCatagoryModel(); $model->select('*'); $data['val2'] = $model->where('id',$data['val']['category_id'])->first(); $user_id = $data['val']['dr_id']; $title = 'New comment is posted in MeLS CME, Video e-Learning module'; $message = "Dr. ".$f_name ." has posted a comment to ".$data['val']['title']." video in ". $data['val2']['category_name ']." section & ".$data['val2']['fields'] ." category"; } else{ $name = $parent_com_details[0]['f_name']; $comment = '@'.$name." ".$comment; $model = new VideoCatagoryModel(); $model->select('*'); $data['val2'] = $model->where('id',$data['val']['category_id'])->first(); $user_id = $data['val']['dr_id']; $title = 'New reply is posted in MeLS CME, Video e-Learning module'; $message = "Dr. ".$f_name ." has replied a comment to ".$data['val']['title']." video in ". $data['val2']['category_name ']." section & ".$data['val2']['fields'] ." category"; } } else{ $name = ''; $comment = $comment; } $comment_data = array( 'blog_id'=> $id, 'user_id' => $dr_id, 'message' => $comment, 'parent_id' => $Comment_id, 'f_name' => $f_name, 'main_id'=>$main_id ); $model = new VideoModel(); $model->select('*'); $data['val'] = $model->where('id',$id)->first(); $date = date("Y-m-d"); $model5 = new CommentModel(); $model5->where('blog_id',$id); $model5->select('user_id'); $model5->groupBy('user_id'); $details2 = $model5->get()->getResultArray(); date_default_timezone_set("Asia/Calcutta"); //India time (GMT+5:30) $time = date('H:i:s'); $link_video="https://medusys.in/ls2-video?id=".$id; foreach($details2 as $key=>$val){ $details = array( 'user_id'=>$val['user_id'], 'type'=>$title, 'message'=>$message, //'sending_to'=>"All", 'status'=>'active', 'created_at'=>$date, 'time'=> $time , 'links_main'=>$link_video ); $add_note = new NotificationModel(); $add_note->save($details); $insertedID = $add_note->insertID(); } $model = new VideoCatagoryModel(); $model->select('*'); $data['val2'] = $model->where('id',$data['val']['category_id'])->first(); $user_id = $data['val']['dr_id']; $title = 'New comment is posted in MeLS CME, Video e-Learning module'; $message = "Dr. ".$f_name ." has posted a comment to ".$data['val']['title']." video in ". $data['val2']['category_name ']." section & ".$data['val2']['fields'] ." category"; $link_video="https://medusys.in/ls2-video?id=".$id; $details = array( 'user_id'=>$user_id, 'type'=>$title, 'message'=>$message, 'status'=>'active', 'created_at'=>$date, 'time'=> $time , 'links_main'=>$link_video ); $add_note = new NotificationModel(); $add_note->save($details); $insertedID = $add_note->insertID(); $model = new CommentModel(); $model->save($comment_data); $insertedId = $model->insertID(); if($insertedId){ return json_encode(array( 'result' => 1, 'insertedId' => $insertedId, 'name' => $f_name, 'message' => 'Added Successfully.....' )); } else{ return json_encode(array( 'result' => 0, 'message' => 'Something went wrong.....' )); } } else{ redirect('login'); } } public function show_files(){ $z = $this->request->uri->getSegment(4); $dr_id = session()->get('dr_id'); if($dr_id){ return view('library/show_files_v'); }else{ return redirect()->route("login"); } } public function find_details(){ $values = $this->request->getVar('id'); $findsub = new VideoModel(); $details = $findsub->where('category_id',$values)->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 Files Found' )); } } public function search_sub_details(){ $field = $this->request->getVar('filed_input'); $id = $this->request->getVar('id'); // print_r($id);die(); $data1= []; // if($field) // { $patient_Model = new VideoModel(); // $patient_Model->select('id,files,categories_id'); $patient_Model->like('files',$field); $patient_Model->where('categories_id',$id)->orLike('name',$field); $patient_Model->where('categories_id',$id)->orLike('key_value',$field); $patient_Model->where('categories_id',$id); $data1 = $patient_Model->get()->getResultArray(); // print_r($data1); die(); echo json_encode($data1); // } // else{ // $model = new VideoModel(); // // $model->select('id,files,categories_id,'); // $model->where('categories_id',$id); // $data2 = $model->get()->getResultArray(); // echo json_encode($data2); // } } } ?>