Ejemplo n.º 1
0
 public function run()
 {
     $model = new Video();
     if (isset($_POST['Video'])) {
         $model->attributes = $_POST['Video'];
         //封面、文件
         $model->cover_image = isset($_POST['cover_image']) ? $_POST['cover_image'] : '';
         $model->video_file = isset($_POST['video_file']) ? $_POST['video_file'] : '';
         //标签   (前5个标签有效)
         $tags = trim($_POST['Video']['tags']);
         $unique_tags = array_unique(explode(',', str_replace(array(' ', ','), array('', ','), $tags)));
         $explodeTags = array_slice($unique_tags, 0, 5);
         $model->tags = implode(',', $explodeTags);
         $model->create_time = time();
         $model->update_time = $model->create_time;
         if ($model->save()) {
             $this->controller->message('success', Yii::t('admin', 'Add Success'), $this->controller->createUrl('index'));
         }
     }
     //判断有无栏目
     $article_cat = Catalog::model()->find('type=:type', array(':type' => $this->controller->_type));
     if (!$article_cat) {
         $this->controller->message('error', Yii::t('admin', 'No Catalog'), $this->controller->createUrl('index'));
     }
     $this->controller->render('create', array('model' => $model));
 }
Ejemplo n.º 2
0
 /**
  * With Ajax Creates a new model.
  */
 public function actionAjaxCreate()
 {
     $model = new Video();
     $isSuccess = false;
     if (isset($_POST['Video'])) {
         $model->attributes = $_POST['Video'];
         $isSuccess = $model->save();
     }
     echo json_encode(array('isSuccess' => $isSuccess));
 }
Ejemplo n.º 3
0
 /**
  * 录入
  *
  */
 public function actionCreate()
 {
     parent::_acl('video_create');
     $model = new Video();
     if (isset($_POST['Video'])) {
         $model->attributes = $_POST['Video'];
         if ($model->save()) {
             AdminLogger::_create(array('catalog' => 'create', 'intro' => '录入视频,ID:' . $model->id));
             $this->redirect(array('index'));
         }
     }
     $this->render('create', array('model' => $model));
 }
Ejemplo n.º 4
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Video();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Video'])) {
         $model->attributes = $_POST['Video'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->video_id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Ejemplo n.º 5
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Video();
     if (isset($_POST['Video'])) {
         $model->attributes = $_POST['Video'];
         if ($model->save()) {
             Yii::app()->user->setFlash('success', Yii::t('main', 'Данные успешно сохранены!'));
             $this->redirect(array('update', 'id' => $model->id));
         } else {
             Yii::app()->user->setFlash('error', Yii::t('main', 'Ошибка сохранения данных!'));
         }
     }
     $this->render('create', array('model' => $model));
 }
Ejemplo n.º 6
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Video();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Video'])) {
         $model->attributes = $_POST['Video'];
         if ($model->save()) {
             Yii::app()->user->setFlash('success', Yii::t('main', 'Данные успешно сохранены!'));
             sleep(2);
             $this->redirect(array('index'));
         } else {
             Yii::app()->user->setFlash('error', Yii::t('main', 'Ошибка!'));
         }
     }
     $this->render('create', array('model' => $model));
 }
Ejemplo n.º 7
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCrear($id)
 {
     $video = new Video();
     if (isset($_POST['Video'])) {
         $video->attributes = $_POST['Video'];
         if ($video->save()) {
             Yii::app()->user->setFlash('success', 'Video ' . $video->nombre . ' guardado con éxito');
             $this->redirect(array('albumvideo/view', 'id' => $video->album_video_id));
         }
     }
     //if(isset($_POST['NovedadesForm']))
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     $album_video = $id ? AlbumVideo::model()->findByPk($id) : 0;
     $video->album_video_id = $album_video;
     $this->render('crear', array('model' => $video));
 }
 public function __construct()
 {
     $editor = getInput("editor_id");
     // Check if General album exists
     $album = getEntity(array("type" => "Videoalbum", "metadata_name_value_pairs" => array(array("name" => "owner_guid", "value" => getLoggedInUserGuid()), array("name" => "title", "value" => "General"))));
     $logged_in_user = getLoggedInUser();
     $logged_in_user_guid = $logged_in_user->guid;
     $title = getInput("title");
     $description = getInput("description");
     if (!file_exists($_FILES['video_file']['tmp_name']) || !is_uploaded_file($_FILES['video_file']['tmp_name'])) {
         $video_type = "youtube";
     } else {
         $video_type = "upload";
     }
     $video = new Video();
     $video->video_type = $video_type;
     $video->title = $title;
     $video->description = $description;
     $video->owner_guid = getLoggedInUserGuid();
     $video->access_id = getInput("access_id");
     $video->save();
     if ($video_type == "youtube") {
         $video->url = getInput("url");
     } else {
         $guid = VideosPlugin::processUploadedVideo("video_file", $video);
         $video->video_guid = $guid;
         $video->save();
         $video->createAvatar();
     }
     $video->save();
     new Activity(getLoggedInUserGuid(), "activity:video:add", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $video->getURL(), $video->title, $video->getURL(), $video->icon(LARGE, "img-responsive")));
     new SystemMessage("Your video has been uploaded.");
     if (!$album) {
         $album = new Videoalbum();
         $album->title = "General";
         $album->owner_guid = getLoggedInUserGuid();
         $album->save();
     }
     $video->container_guid = $album->guid;
     $video->save();
     forward(false, array("insertvideo" => $video->guid, "editor" => $editor));
 }
Ejemplo n.º 9
0
 public function createAction()
 {
     $this->view->Title = "Manage Video";
     $this->view->headTitle($this->view->Title);
     if ($this->getRequest()->isPost()) {
         $request = $this->getRequest()->getParams();
         $error = $this->_checkForm($request);
         if (count($error) == 0) {
             $Video = new Video();
             $Video->merge($request);
             $Video->save();
             $this->Member->log('Video:' . $Video->name . '(' . $Video->id . ')', 'Tạo mới');
             My_Plugin_Libs::setSplash('Video: <b>' . $Video->name . '</b> đã tạo thành công. ');
             $this->_redirect($this->_helper->url('index', 'video', 'admin'));
         }
         if (count($error)) {
             $this->view->error = $error;
         }
     }
 }
Ejemplo n.º 10
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);
     }
 }
Ejemplo n.º 11
0
 /**
  * Store a newly created resource in storage.
  * POST /videos
  *
  * @return Response
  */
 public function store()
 {
     $post = new Video();
     $post->title = Input::get('title');
     if (Input::hasFile('photo')) {
         $photo = Input::file('photo');
         $filename = time() . '-' . $photo->getClientOriginalName();
         $destination = public_path() . '/uploads/' . $filename;
         if (!File::exists($destination)) {
             try {
                 $photo_path = $photo->move(public_path() . '/uploads/', $filename);
                 $post->url = $filename;
             } catch (Fileexception $e) {
                 return 'Sorry, Could not upload the file! Please, try again later!!';
             }
         } else {
             return 'This File already exist!! Please, upload another file!!!';
         }
     }
     $post->save();
     return Redirect::to('videos')->with('message', 'Photo uploaded Successfully');
 }
Ejemplo n.º 12
0
 public function store()
 {
     $rules = ['name' => 'required', 'url' => 'required', 'duration' => 'required|numeric'];
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     } else {
         if (Input::has('video_id')) {
             $id = Input::get('video_id');
             $video = VideoModel::find($id);
         } else {
             $video = new VideoModel();
         }
         $video->company_id = Session::get('company_id');
         $video->name = Input::get('name');
         $video->url = Input::get('url');
         $video->duration = Input::get('duration');
         $video->save();
         $alert['msg'] = 'Video has been saved successfully';
         $alert['type'] = 'success';
         return Redirect::route('company.video')->with('alert', $alert);
     }
 }
include_once './includes/bootstrap.php';
try {
    $video = new Video($example_video_path);
    $process = $video->getProcess();
    $video->extractSegment(new Timecode(10), new Timecode(20));
    $multi_output = new MultiOutput();
    $ogg_output = './output/big_buck_bunny.multi1.ogg';
    $format = Format::getFormatFor($ogg_output, null, 'VideoFormat');
    $format->setVideoDimensions(VideoFormat::DIMENSION_SQCIF);
    $multi_output->addOutput($ogg_output, $format);
    $threegp_output = './output/big_buck_bunny.multi2.3gp';
    $format = Format::getFormatFor($threegp_output, null, 'VideoFormat');
    $format->setVideoDimensions(VideoFormat::DIMENSION_XGA);
    $multi_output->addOutput($threegp_output, $format);
    $process = $video->save($multi_output, null, Media::OVERWRITE_EXISTING);
    echo '<h1>Executed Command</h1>';
    Trace::vars($process->getExecutedCommand());
    echo '<h1>Executed Command RAW</h1>';
    Trace::vars($process->getExecutedCommand(true));
    echo '<hr /><h1>FFmpeg Process Messages</h1>';
    Trace::vars($process->getMessages());
    echo '<hr /><h1>Buffer Output</h1>';
    Trace::vars($process->getBuffer(true));
    echo '<hr /><h1>Resulting Output</h1>';
    $output = $process->getOutput();
    $output = array_values($output);
    $paths = array();
    foreach ($output as $obj) {
        array_push($paths, $obj->getMediaPath());
    }
Ejemplo n.º 14
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate($idLesson)
 {
     $this->layout = 'site';
     $model = new Video();
     $model->id_lesson = (int) $idLesson;
     $arrayModels = array();
     if (isset($_POST['Video'])) {
         $model->attributes = $_POST['Video'];
         $lesson = Lesson::model()->findByPk($idLesson);
         if (Yii::app()->user->checkAccess('adminOwnLesson', array('lesson' => $lesson))) {
             $model->is_active = $lesson->is_active;
         }
         $model->id_lesson = $idLesson;
         $model->path_video_thumbnail = Yii::app()->params['defaultLessonThumbnail'];
         if ($model->save()) {
             if (!Yii::app()->user->checkAccess('adminLesson')) {
                 $model->is_active = 0;
                 $adminUserIds = Yii::app()->db->createCommand()->select('userid')->from('authassignment')->where('itemname=:itemname', array(':itemname' => 'admin'))->queryColumn();
                 foreach ($adminUserIds as $id) {
                     $message = new Message();
                     $message->id_from = Yii::app()->user->getId();
                     $message->id_user = $id;
                     $message->subject = 'A new video is created';
                     $message->message = "User " . CHtml::link($this->viewer->username, $this->viewer->href) . " have just created the lesson " . CHtml::link($model->name, $model->href);
                     $message->save();
                 }
             }
             $this->redirect(array('view', 'id' => $model->id));
         }
         //            $model->file = $file = CUploadedFile::getInstance($model, 'file');
         //            if ($model->validate(array('file'))) {
         //                $fileName = Yii::app()->params['video'] . '/' . $file->getName();
         //                if (file_exists($fileName)) {
         //                    $fileName = Yii::app()->params['lessonThumbnails'] . '/' . time() . '_' . $file->getName();
         //                }
         //                if ($file->saveAs(strtolower($fileName))) {
         ////                    $videoHelper = new CVideo();
         ////                    $videoThumbnailName = $videoHelper->create_thumbnail($fileName,
         ////                            Yii::app()->params['videoWidth'],
         ////                            Yii::app()->params['videoHeight'],
         ////                            Yii::app()->params['videoThumbnail']
         ////                    );
         ////                    $convertVideoFileName = $videoHelper->convertVideo($fileName);
         ////
         ////                    $model->path = $convertVideoFileName;
         ////                    $model->path_video_thumbnail = $videoThumbnailName;
         //
         //                    $model->path = $fileName;
         //                    $model->path_video_thumbnail = Yii::app()->params['defaultLessonThumbnail'];
         //
         //                    if ($model->save()) {
         //                        $this->redirect(array('view', 'id' => $model->getPrimaryKey()));
         //                    }
         //                }
         //            }
     }
     if (Yii::app()->user->checkAccess('adminVideo')) {
         $model->is_active = 1;
     }
     $this->render('create', array('model' => $model));
 }
Ejemplo n.º 15
0
 /**
  * 新增数据
  *
  */
 public function actionCreate()
 {
     $model = new Video();
     if (isset($_POST['Video'])) {
         $model->attributes = $_POST['Video'];
         //软件文件
         $fileids = is_array($_POST['fileid']) ? implode(',', $_POST['fileid']) : '';
         $model->fileid = $fileids;
         if ($_FILES['attach']['error'] == UPLOAD_ERR_OK) {
             //封面图片
             $upload = new Uploader();
             $upload->uploadFile($_FILES['attach']);
             if ($upload->_error) {
                 $upload->deleteFile($upload->_file_name);
                 $this->message('error', Yii::t('admin', $upload->_error));
                 return;
             }
             $model->cover_image = $upload->_file_name;
         } else {
             //未改变前的封面图片
             $model->cover_image = $_POST['old_cover'];
         }
         $model->create_time = time();
         $model->update_time = $model->create_time;
         if ($model->save()) {
             $this->message('success', Yii::t('admin', 'Add Success'), $this->createUrl('index'));
         }
     }
     //判断有无视频栏目
     $video_cat = Catalog::model()->find('type=:type', array(':type' => $this->_type));
     if (!$video_cat) {
         $this->message('error', Yii::t('admin', 'No Catalog'), $this->createUrl('index'));
     }
     $this->render('update', array('model' => $model));
 }
<?php

namespace PHPVideoToolkit;

include_once './includes/bootstrap.php';
try {
    Trace::vars('Note, this process will purposely NOT work as the additional commands are invalid.');
    $video = new Video($example_video_path);
    $process = $video->getProcess();
    $process->addPreInputCommand('-custom-command');
    $process->addCommand('-custom-command-with-arg', 'arg value');
    $process->addPostOutputCommand('-output-command', 'another value');
    //  $process->setProcessTimelimit(1);
    $video->save('./output/big_buck_bunny.mp4', null, Media::OVERWRITE_EXISTING);
    echo '<h1>Raw Executed Command</h1>';
    Trace::vars($process->getExecutedCommand(true));
    echo '<h1>Executed Command</h1>';
    Trace::vars($process->getExecutedCommand());
    echo '<hr /><h1>FFmpeg Process Messages</h1>';
    Trace::vars($process->getMessages());
    echo '<hr /><h1>Buffer Output</h1>';
    Trace::vars($process->getBuffer(true));
    echo '<hr /><h1>Resulting Output</h1>';
    Trace::vars($process->getOutput()->getMediaPath());
} catch (FfmpegProcessOutputException $e) {
    echo '<h1>Error</h1>';
    Trace::vars($e);
    $process = $video->getProcess();
    if ($process->isCompleted()) {
        echo '<h1>Raw Executed Command</h1>';
        Trace::vars($process->getExecutedCommand(true));
Ejemplo n.º 17
0
 /**
  * Add selfie video to backend
  * POST /adduselfievideo
  *
  * @return Response
  */
 public function addSelfieVideo()
 {
     $arr = array();
     $missingParam = '';
     if (Input::get('title') == '') {
         $missingParam .= 'title,';
     }
     if (Input::get('youtube_id') == '') {
         $missingParam .= 'youtube_id,';
     }
     if (Input::get('youtube_url') == '') {
         $missingParam .= 'youtube_url,';
     }
     if (Input::get('language') == '') {
         $missingParam .= 'language,';
     }
     if (Input::get('email') == '') {
         $missingParam .= 'email,';
     }
     if (Input::get('scripture_text') == '') {
         $missingParam .= 'scripture_text,';
     }
     if (Input::get('book_name') == '') {
         $missingParam .= 'book_name,';
     }
     if (Input::get('chapter') == '') {
         $missingParam .= 'chapter,';
     }
     if (Input::get('verse') == '') {
         $missingParam .= 'verse,';
     }
     if (Input::get('country') == '') {
         $missingParam .= 'country,';
     }
     if (Input::get('topics') == '') {
         $missingParam .= 'topics,';
     }
     if ($missingParam != '') {
         $arr['Success'] = false;
         $arr['Status'] = 'Parameter missing: ' . rtrim($missingParam, ',');
         $arr['StatusCode'] = 400;
     } else {
         $user = User::whereEmail(Input::get('email'))->first();
         if ($user) {
             //Save video
             $userId = $user->id;
             $video = new Video();
             $video->video_title = Input::get('title');
             $video->video_desc = Input::get('description');
             $video->video_short_desc = Input::get('description');
             $video->video_youtube_id = Input::get('youtube_id');
             $embedCode = "<iframe type='text/html' src='http://www.youtube.com/embed/" . Input::get('youtube_id') . "' width='640' height='360' frameborder='0' allowfullscreen='true'/></iframe>";
             $video->video_embed = $embedCode;
             $video->video_url = Input::get('youtube_url');
             $video->video_thumbnail_url = Input::get('youtube_thumbnail_url');
             $video->scripture_text = Input::get('scripture_text');
             $video->book_id = Input::get('book_id');
             $video->book_name = Input::get('book_name');
             $video->book_order = Input::get('book_order');
             $video->chapter = Input::get('chapter');
             $video->verse = Input::get('verse');
             $video->bible_name = Input::get('bible_name');
             $video->video_language = Input::get('language');
             $video->user_id = $userId;
             $video->video_type = 'selfie';
             $video->video_status = '0';
             $video->video_youtube_upload_status = 'uploaded';
             $video->video_country = Input::get('country');
             $video->save();
             $videoId = $video->video_id;
             //Video Tags
             if (Input::get('tags') != '') {
                 $tags = Input::get('tags');
                 if (strpos($tags, ',') !== FALSE) {
                     //Split by comma
                     $tagList = explode(',', $tags);
                     if (count($tagList) > 0) {
                         foreach ($tagList as $tagName) {
                             $tagDetails = Tag::wherehashName($tagName)->first();
                             //Tag exists, then save it
                             if ($tagDetails) {
                                 $tagId = $tagDetails->hash_id;
                             } else {
                                 //Tag not exists, then add it and return id
                                 $tg = new Tag();
                                 $tg->hash_name = $tagName;
                                 $tg->hash_language = Input::get('language');
                                 $tg->save();
                                 $tagId = $tg->id;
                             }
                             if ($tagId > 0) {
                                 $videoh = new VideoHash();
                                 $videoh->video_id = $videoId;
                                 $videoh->hash_id = $tagId;
                                 $videoh->push();
                             }
                         }
                     }
                 } else {
                     //Tag doesn't contain comma
                     $tagDetails = Tag::wherehashName($tags)->first();
                     //Tag exists, then save it
                     if ($tagDetails) {
                         $tagId = $tagDetails->hash_id;
                     } else {
                         //Tag not exists, then add it and return id
                         $tg = new Tag();
                         $tg->hash_name = $tags;
                         $tg->hash_language = Input::get('language');
                         $tg->save();
                         $tagId = $tg->id;
                     }
                     if ($tagId > 0) {
                         $videoh = new VideoHash();
                         $videoh->video_id = $videoId;
                         $videoh->hash_id = $tagId;
                         $videoh->push();
                     }
                 }
             }
             //Topics
             if (Input::get('topics') != '') {
                 $topics = Input::get('topics');
                 if (strpos($topics, ',') !== FALSE) {
                     //Split by comma
                     $topicList = explode(',', $topics);
                     if (count($topicList) > 0) {
                         foreach ($topicList as $topicId) {
                             $videotopic = new VideoTopic();
                             $videotopic->video_id = $videoId;
                             $videotopic->topic_id = $topicId;
                             $videotopic->push();
                         }
                     }
                 } else {
                     $videotopic = new VideoTopic();
                     $videotopic->video_id = $videoId;
                     $videotopic->topic_id = Input::get('topics');
                     $videotopic->push();
                 }
             }
             //Get saved video details
             $addedSelfie = Video::wherevideoId($videoId)->first();
             $arr['Success'] = true;
             $arr['Status'] = 'OK';
             $arr['StatusCode'] = 200;
             $arr['language'] = Input::get('language');
             $arr['Result']['email'] = Input::get('email');
             $arr['Result']['video_id'] = $videoId;
             $arr['Result']['title'] = $addedSelfie->video_title;
             $arr['Result']['description'] = $addedSelfie->video_desc;
             $arr['Result']['video_short_desc'] = $addedSelfie->video_desc;
             $arr['Result']['youtube_id'] = $addedSelfie->video_youtube_id;
             $arr['Result']['embedcode'] = $addedSelfie->video_embed;
             $arr['Result']['youtube_url'] = $addedSelfie->video_url;
             $arr['Result']['youtube_thumbnail_url'] = $addedSelfie->video_thumbnail_url;
             $arr['Result']['scripture_text'] = $addedSelfie->scripture_text;
             $arr['Result']['book_id'] = $addedSelfie->book_id;
             $arr['Result']['book_name'] = $addedSelfie->book_name;
             $arr['Result']['book_order'] = $addedSelfie->book_order;
             $arr['Result']['chapter'] = $addedSelfie->chapter;
             $arr['Result']['verse'] = $addedSelfie->verse;
             $arr['Result']['bible_name'] = $addedSelfie->bible_name;
             $arr['Result']['country'] = $addedSelfie->video_country;
         } else {
             $arr['Success'] = false;
             $arr['Status'] = 'User not found';
             $arr['StatusCode'] = 404;
         }
     }
     return Response::json($arr);
 }
<?php

namespace PHPVideoToolkit;

include_once './includes/bootstrap.php';
try {
    $video = new Video($example_video_path);
    $video->extractSegment(new Timecode(15));
    $process = $video->save('./output/big_buck_bunny.my_silly_custom_file_extension', new ImageFormat_Jpeg('output'), Media::OVERWRITE_EXISTING);
    echo '<h1>Executed Command</h1>';
    Trace::vars($process->getExecutedCommand());
    echo '<hr /><h1>FFmpeg Process Messages</h1>';
    Trace::vars($process->getMessages());
    echo '<hr /><h1>Buffer Output</h1>';
    Trace::vars($process->getBuffer(true));
    echo '<hr /><h1>Resulting Output</h1>';
    Trace::vars($process->getOutput()->getMediaPath());
} catch (FfmpegProcessOutputException $e) {
    echo '<h1>Error</h1>';
    Trace::vars($e);
    $process = $video->getProcess();
    if ($process->isCompleted()) {
        echo '<hr /><h2>Executed Command</h2>';
        Trace::vars($process->getExecutedCommand());
        echo '<hr /><h2>FFmpeg Process Messages</h2>';
        Trace::vars($process->getMessages());
        echo '<hr /><h2>Buffer Output</h2>';
        Trace::vars($process->getBuffer(true));
    }
} catch (Exception $e) {
    echo '<h1>Error</h1>';
Ejemplo n.º 19
0
 public function actionCreate()
 {
     $model = new Video();
     $newOv = new Overlays();
     $newGeo = new Geolocation();
     if (isset($_POST['Video'])) {
         $model->attributes = $_POST['Video'];
         if ($model->save()) {
             $this->redirect(url("videosr/update", array("id" => $model->id)));
         }
     }
     $user = User::model()->findByPk(uid());
     $pay = $user->payModel;
     //intval($user->pay);
     switch ($pay) {
         case 'basic':
             $hint = 'Your new video will be initialized with a "basic" subscription.';
             break;
         case 'basicplus':
             $hint = 'Your new video will be initialized with a "basic+" subscription.';
             break;
         case 'pro':
             $hint = 'Your new video will be initialized with a "Pro" subscription.';
             break;
         case '':
         default:
             $hint = 'Your new video will initially have the "Free" Subscription. Most of features will be disabled';
             break;
     }
     $this->render('create', array('user' => $user, 'model' => $model, 'newOv' => $newOv, 'newGeo' => $newGeo, 'hint' => $hint));
 }
 public static function add_default_media($user_id, $type = '', $network_info = NULL)
 {
     // global var $path_prefix has been removed - please, use PA::$path static variable
     require_once "api/User/User.php";
     require_once "api/Album/Album.php";
     require_once "api/Image/Image.php";
     require_once "api/Audio/Audio.php";
     require_once "api/Video/Video.php";
     require_once "api/ContentCollection/ContentCollection.php";
     //$extra contains networks extra information
     $extra = unserialize($network_info->extra);
     /** setting common variables according to media type */
     if ($type == '') {
         $net_extra_ccid_str = $extra['user_defaults']['default_image_gallery'];
         $alb_type = IMAGE_ALBUM;
         $new_img = new Image();
     } elseif ($type == '_audio') {
         $net_extra_ccid_str = $extra['user_defaults']['default_audio_gallery'];
         $alb_type = AUDIO_ALBUM;
         $new_img = new Audio();
     } elseif ($type == '_video') {
         $net_extra_ccid_str = $extra['user_defaults']['default_video_gallery'];
         $alb_type = VIDEO_ALBUM;
         $new_img = new Video();
     }
     /** getting array of content collection from comma separated string */
     if (!empty($net_extra_ccid_str)) {
         $net_extra_ccid = explode(',', $net_extra_ccid_str);
         /** setting all content collection variables */
         if (count($net_extra_ccid) >= 1) {
             for ($i = 0; $i < count($net_extra_ccid); $i++) {
                 $new_im_al = new Album($alb_type);
                 $new_im_al_default = new Album($alb_type);
                 $new_im_al->load((int) $net_extra_ccid[$i]);
                 $content_collection_obj = new ContentCollection();
                 $content_collection_obj->collection_id = $new_im_al->collection_id;
                 $contents = $content_collection_obj->get_contents_for_collection();
                 $new_im_al_default->title = $new_im_al->title;
                 $new_im_al_default->description = $new_im_al->description;
                 $new_im_al_default->author_id = $user_id;
                 $new_im_al_default->type = 2;
                 // FOR ALBUM, type is 2
                 $new_im_al_default->save();
                 /** Setting content variable */
                 for ($j = 0; $j < count($contents); $j++) {
                     if ($contents[$j]['type'] != 7) {
                         // If content is not a SB content
                         if ($alb_type == IMAGE_ALBUM) {
                             $new_img_default = new Image();
                             $new_img_default->type = IMAGE;
                         } elseif ($alb_type == AUDIO_ALBUM) {
                             $new_img_default = new Audio();
                             $new_img_default->type = AUDIO;
                         } elseif ($alb_type == VIDEO_ALBUM) {
                             $new_img_default = new Video();
                             $new_img_default->type = VIDEO;
                         }
                         $new_img->load((int) $contents[$j]['content_id']);
                         $new_img_default->file_name = $new_img->file_name;
                         $new_img_default->file_perm = $new_img->file_perm;
                         $new_img_default->title = $contents[$j]['title'];
                         $new_img_default->body = $contents[$j]['body'];
                         $tags = Tag::load_tags_for_content($contents[$j]['content_id']);
                         $new_img_default->allow_comments = 1;
                         $new_img_default->author_id = $user_id;
                         $new_img_default->parent_collection_id = $new_im_al_default->collection_id;
                         $new_img_default->save();
                         if (!empty($tags)) {
                             $tag_array = array();
                             if (is_array($tags)) {
                                 for ($i = 0; $i < count($tags); $i++) {
                                     $tag_array[] = $tags[$i]['name'];
                                 }
                             }
                             Tag::add_tags_to_content($new_img_default->content_id, $tag_array);
                         }
                     } else {
                         // If content is a SB content
                         //TODO: handling of SB content if it is in media gallery.
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 21
0
        forward(REFERER);
    }
    if (!$title) {
        // user blanked title, but we need one
        $title = $video->title;
    }
}
$video->title = $title;
$video->description = $desc;
$video->access_id = $access_id;
$video->container_guid = $container_guid;
$tags = explode(",", $tags);
$video->tags = $tags;
// Save the entity to push attributes to database
// and to get access to guid if adding a new video
$video->save();
// we have a video upload, so process it
if (isset($_FILES['upload']['name']) && !empty($_FILES['upload']['name'])) {
    $prefix = "video/{$video->getGUID()}/";
    // if previous video, delete it
    if ($new_video == false) {
        $videoname = $video->getFilenameOnFilestore();
        if (file_exists($videoname)) {
            unlink($videoname);
        }
        // use same videoname on the disk - ensures thumbnails are overwritten
        $videostorename = $video->getFilename();
        $videostorename = elgg_substr($videostorename, elgg_strlen($prefix));
    } else {
        $videostorename = elgg_strtolower($_FILES['upload']['name']);
    }
Ejemplo n.º 22
0
 public function actionAddExternal()
 {
     $id = $_GET['id'];
     Yii::import('application.vendors.google-api-php-client.*');
     Yii::import('application.vendors.google-api-php-client.contrib.*');
     $client = new Google_Client();
     $youtube = new Google_YouTubeService($client);
     $thumb = "";
     $title = "";
     try {
         $searchResponse = $youtube->videos->listVideos("snippet", array('id' => $id));
         //Цикл для изучения возвращаемого содержимого
         //foreach(array_keys($searchResponse['items'][0]['snippet']) as $key) echo $key."<br>";
         $thumb = $searchResponse['items'][0]['snippet']['thumbnails']['medium']['url'];
         $title = $searchResponse['items'][0]['snippet']['title'];
     } catch (Google_ServiceException $e) {
         $htmlBody .= sprintf('<p>A service error occurred: <code>%s</code></p>', htmlspecialchars($e->getMessage()));
         echo $htmlBody;
     } catch (Google_Exception $e) {
         $htmlBody .= sprintf('<p>An client error occurred: <code>%s</code></p>', htmlspecialchars($e->getMessage()));
         echo $htmlBody;
     }
     $uploaded = 0;
     if (strlen($thumb) > 1) {
         $uploaded = 1;
     }
     if ($uploaded) {
         $video = new Video();
         $video->type = $this->YOUTUBE;
         $video->name = $title;
         $video->thumb = $thumb;
         $video->path = $id;
         $video->save();
         echo "Using external URL";
     }
 }
Ejemplo n.º 23
0
    $Video->category = $_REQUEST['category'];
    $Video->rating = $_REQUEST['rating'];
    $Video->inetref = $_REQUEST['inetref'];
    $Video->year = $_REQUEST['year'];
    $Video->userrating = $_REQUEST['userrating'];
    $Video->length = $_REQUEST['length'];
    $Video->showlevel = $_REQUEST['showlevel'];
    $Video->browse = $_REQUEST['browse'];
    if (is_uploaded_file($_FILES['coverfile']['tmp_name'])) {
        $filename = setting('VideoArtworkDir', hostname) . '/id-' . $_REQUEST['intid'] . '.jpg';
        move_uploaded_file($_FILES['coverfile']['tmp_name'], $filename);
        chmod($filename, 0644);
        // make cover file readable by other users
        $Video->cover_file = $filename;
    }
    $Video->save();
    ?>
        <script type="text/javascript">
        <!--Hide script from old browsers
            parent.update_video('<?php 
    echo $_REQUEST['intid'];
    ?>
');
            parent.$('window').hide();
        //Stop hiding script from old browsers -->
        </script>
        <?php 
}
?>

</head>
Ejemplo n.º 24
0
 public function actionV_copy($id)
 {
     $video = Video::model()->findByPk($id);
     $model = new Video();
     //echo "<pre>";
     //print_r($video->attributes);
     if (!empty($video->attributes)) {
         $data = $video->attributes;
         unset($data['id']);
         $data['title'] = $data['title'] . "  -- Copy";
         $model->attributes = $data;
         if ($model->save()) {
             $verlays = Overlays::model()->findAll("video_id = {$id}");
             // print_r($verlays);
             foreach ($verlays as $overlay) {
                 $newOv = new Overlays();
                 $data_ov = $overlay->attributes;
                 unset($data_ov['id']);
                 $data_ov['video_id'] = $model->id;
                 $newOv->attributes = $data_ov;
                 $newOv->save();
             }
         }
     }
     //echo "</pre>";
     // die();
     $this->redirect(url("video/admin"));
 }
Ejemplo n.º 25
0
function uihelper_upload_gallery_for_group($uid, $type, $k = 0)
{
    require_once "api/User/User.php";
    require_once "api/Tag/Tag.php";
    require_once "api/Album/Album.php";
    require_once "api/Image/Image.php";
    require_once "api/Audio/Audio.php";
    require_once "api/Video/Video.php";
    require_once "web/includes/classes/CNFileUploader.php";
    $logged_in_user = get_login_user();
    $user = new User();
    $media_count_no = $k;
    $error_file = NULL;
    $uploaded = False;
    if ($type == '') {
        $file_type = "image";
        $alb_type = IMAGE_ALBUM;
        $new_img = new Image();
        $new_img->file_perm = @$_POST['image_perm'];
    } elseif ($type == '_audio') {
        $file_type = "audio";
        $alb_type = AUDIO_ALBUM;
        $new_img = new Audio();
        $new_img->file_perm = @$_POST['audio_perm'];
    } elseif ($type == '_video') {
        $file_type = "video";
        $alb_type = VIDEO_ALBUM;
        $new_img = new Video();
        $new_img->file_perm = @$_POST['video_perm'];
    }
    //file uploading start
    $file_name_dynamic = "userfile{$type}" . "_" . "{$k}";
    $file_name_dynamic_type = $file_name_dynamic;
    //"$file_name_dynamic"."$type";
    $newname = $_FILES[$file_name_dynamic_type]['name'];
    $uploadfile = PA::$upload_path . basename($_FILES[$file_name_dynamic_type]['name']);
    $myUploadobj = new FileUploader();
    //creating instance of file.
    $image_type = "{$file_type}";
    $value = $file_name_dynamic_type;
    $file = $myUploadobj->upload_file(PA::$upload_path, $value, true, true, $image_type);
    if ($file == false) {
        $msg = $myUploadobj->error;
        $error = TRUE;
    } else {
        $new_img->file_name = "{$file}";
        $error_file = FALSE;
    }
    // file uploading end
    if (empty($error)) {
        try {
            $user->load((int) $uid);
            $action = !empty($_GET['action']) ? $_GET['action'] : 'upload';
            $colls = Album::load_all($uid, $alb_type);
            if (isset($_POST['submit' . $type]) && $action != 'delete' && $error_file == FALSE) {
                $new_img->author_id = $uid;
                if ($type == '_audio') {
                    $new_img->type = AUDIO;
                } elseif ($type == '_video') {
                    $new_img->type = VIDEO;
                } else {
                    $new_img->type = IMAGE;
                }
                if (empty($_POST['caption' . $type][$k])) {
                    $ext = explode(".", $newname);
                    $_POST['caption' . $type][$k] = $ext[0];
                }
                $new_img->title = stripslashes(trim($_POST['caption' . $type][$k]));
                $new_img->title = strip_tags($new_img->title);
                $new_img->file_perm = ANYONE;
                $new_img->excerpt = stripslashes(trim($_POST['caption' . $type][$k]));
                $new_img->excerpt = strip_tags($new_img->excerpt);
                if (empty($_POST['body' . $type][$k])) {
                    $new_img->body = '';
                    $new_img->body = strip_tags($new_img->body);
                } else {
                    $new_img->body = stripslashes(trim($_POST['body' . $type][$k]));
                    $new_img->body = strip_tags($new_img->body);
                }
                $new_img->allow_comments = 1;
                $new_img->parent_collection_id = $_POST['group_id'];
                $new_img->save();
                if (!empty($_POST['tags' . $type][$media_count_no])) {
                    $tag_array = Tag::split_tags($_POST['tags' . $type][$media_count_no]);
                    Tag::add_tags_to_content($new_img->content_id, $tag_array);
                }
            } else {
                throw new CNException(USER_NOT_FOUND, 'unable to upload file.');
            }
            if (!empty($msg)) {
                $uploaded = FALSE;
            } else {
                $uploaded = TRUE;
                if (isset($_REQUEST['gid'])) {
                    $mail_type = "group_media_uploaded";
                    $new_img->group_id = $_REQUEST['gid'];
                } else {
                    $mail_type = "media_uploaded";
                }
                PANotify::send($mail_type, PA::$network_info, PA::$login_user, $new_img);
            }
        } catch (CNException $e) {
            $msg = "{$e->message}";
            $error = TRUE;
        }
    }
    $array_of_error_message = array(@$error, @$msg, @$error_file, @$uploaded, 'collection_id' => $new_img->parent_collection_id, 'content_id' => $new_img->content_id);
    return $array_of_error_message;
}
function peopleaggregator_newFile($args)
{
    $user = User::from_auth_token($args['authToken']);
    $title = strip_tags($args['title']);
    $body = strip_tags($args['content']);
    $file_type = $args['type'];
    $tags = $args['tags'];
    $access = $args['access'];
    $context = $args['context'];
    // URL or file?
    if (!empty($args['url'])) {
        $upload_type = 'url';
        $url = $args['url'];
    } else {
        $upload_type = 'file';
        $filename = api_sanitize_filename($args['filename']);
        // strip attempts to ascend the directory tree
        $data = $args['data'];
    }
    $alb_type = API::$album_type_to_id[$file_type];
    switch ($alb_type) {
        case IMAGE_ALBUM:
            $new_img = new Image();
            $new_img->type = IMAGE;
            break;
        case AUDIO_ALBUM:
            $new_img = new Audio();
            $new_img->type = AUDIO;
            break;
        case VIDEO_ALBUM:
            $new_img = new Video();
            $new_img->type = VIDEO;
            break;
        default:
            throw new PAException(INVALID_ID, "file type must be 'image', 'audio' or 'video' (not {$file_type})");
    }
    // When uploading a file, we can use the special 'default album' context: 'user:123:album:default'
    if (preg_match("/^user:\\d+:album:default:([a-z]+)\$/", $context, $m)) {
        $default_alb_type = API::$album_type_to_id[$m[1]];
        $collection = Album::get_or_create_default($user->user_id, $default_alb_type);
        $collection_id = $collection->collection_id;
    } else {
        list($collection_id, $collection) = api_validate_album_context($context, $user, "write");
    }
    if ($collection instanceof Album) {
        $album_file_type = API::$album_type_from_id[(int) $collection->album_type];
        if ($album_file_type != $file_type) {
            throw new PAException(OPERATION_NOT_PERMITTED, "Attempting to upload a file of type '{$file_type}' into an album that can only contain '{$album_file_type}' files");
        }
    }
    try {
        switch ($upload_type) {
            case 'url':
                // just supplying a URL; no upload to handle
                $new_img->file_name = $url;
                break;
            case 'file':
                // we're uploading a file - figure out where to put it
                $upload_path = realpath(PA::$upload_path);
                // make a filename that isn't already used
                $fn_munge = "";
                $munge_serial = 0;
                while (1) {
                    $fn = "{$upload_path}/" . $user->user_id . "_" . $fn_munge . $filename;
                    if (!file_exists($fn)) {
                        break;
                    }
                    // we have our filename!
                    $fn_munge = ++$munge_serial . "_";
                }
                // and try to save the file, then put it in the database,
                // removing the file if an exception occurs at any point.
                if (file_put_contents($fn, $data) != strlen($data)) {
                    global $php_errormsg;
                    throw new PAException(FILE_NOT_UPLOADED, "An error occurred when saving the file: {$php_errormsg}");
                }
                $new_img->file_name = basename($fn);
                break;
        }
        $access_map = array('nobody' => 0, 'everybody' => 1, 'relations' => 2);
        $new_img->file_perm = $access_map[$access];
        $new_img->author_id = $user->user_id;
        $new_img->title = $new_img->excerpt = $title;
        $new_img->body = $body;
        $new_img->allow_comments = 1;
        $new_img->parent_collection_id = $collection_id;
        $new_img->save();
        if ($tags) {
            Tag::add_tags_to_content($new_img->content_id, Tag::split_tags($tags));
        }
    } catch (PAException $e) {
        if ($upload_type == 'file') {
            // delete file
            @unlink($fn);
        }
        throw $e;
    }
    return array('success' => TRUE, 'id' => "file:{$new_img->content_id}", 'url' => api_get_url_of_file($new_img->file_name));
}
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
    exit;
}
include_once dirname(dirname(__FILE__)) . "/engine/start.php";
$key = getInput("key");
if ($key == SITESECRET) {
    $owner_guid = getInput("owner_guid");
    $container_guid = getInput("container_guid");
    $video = new Video();
    $video->video_type = "upload";
    // $video->title = $title;
    // $video->description = $description;
    $video->owner_guid = $owner_guid;
    $video->access_id = "public";
    $video->container_guid = $container_guid;
    $video->save();
    $file = new File();
    $file->access_id = "public";
    $file->container_guid = $video->guid;
    $file_guid = $file->save();
    FileSystem::uploadFile("video", $file_guid, array("mov", "mpeg4", "mp4", "avi", "wmv", "mpegps", "flv", "3gpp", "webm", "3gp", "3g2", "m4v", "m2v", "mkv"));
    $video->video_guid = $file_guid;
    $video->save();
    $video->createAvatar();
    $video->save();
} else {
    echo "bad key";
}
Ejemplo n.º 28
0
 function update()
 {
     if (!isset($_SESSION['user_id']) && !is_numeric($_SESSION['user_id'])) {
         header("Location: /user/login");
     }
     if (isset($_POST['delete']) && $_POST['delete'] == "true") {
         $video = new Video($_POST['id']);
         $video->user_id = $_SESSION['user_id'];
         $video->del_save();
     }
     if (isset($_POST) && !empty($_POST)) {
         $error = false;
         if (!$_POST['title'] || empty($_POST['title'])) {
             $error = true;
         }
         if (!$_POST['description'] || empty($_POST['description'])) {
             $error = true;
         }
         if ($error == false) {
             $video = new Video($_POST['id']);
             if ($video->user_id == $_SESSION['user_id']) {
                 $video->title = $_POST['title'];
                 $video->descripton = $_POST['description'];
                 $video->visibility_setting = $_POST['visibility'];
                 $video->thumb = isset($_POST['thumb']) ? $_POST['thumb'] : "1";
                 $video->save();
                 header("Location: " . Config::get('address') . "/user/video");
             }
         }
     }
 }
Ejemplo n.º 29
0
                $error = $e->message;
            }
        } else {
            $new_save->parent_collection_id = $_POST['album'];
        }
        if (!$error) {
            $condition = array('content_id' => $new_save->content_id);
            $is_active = ACTIVE;
            if ($extra['network_content_moderation'] == NET_YES) {
                $content = Content::load_all_content_for_moderation(NULL, $condition);
                if (!empty($content)) {
                    $is_active = $content[0]['is_active'];
                }
            }
            $new_save->is_active = $is_active;
            $new_save->save();
            if (!empty($_POST['tags'])) {
                $tag_array = Tag::split_tags($_POST['tags']);
                Tag::add_tags_to_content($new_save->content_id, $tag_array);
            }
            $album_id = $_POST['album'];
            $album = "&album_id=" . $album_id;
            header("Location: media_gallery.php?msg_id=2007&uid=" . $_SESSION['user']['id'] . "&type=" . $module . $album);
        }
    }
}
$user = new User();
$user->load((int) $uid);
function setup_module($column, $moduleName, $obj)
{
    global $show_media, $users, $uid, $cc_info, $user, $_REQUEST;
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     if ($model->occupation->templ == 'members') {
         $model->scenario = 'genre';
     }
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     if (isset($_POST['Users'])) {
         if ($_POST['member'] == 0) {
             $model->name = $_POST['Users']['name'];
             Yii::app()->user->name = $model->name;
             $model->gender = $_POST['Users']['gender'];
             $model->date_birth = $_POST['year_b'] . '-' . $_POST['month_b'] . '-' . $_POST['day_b'];
             $model->birth_public = $_POST['Users']['birth_public'];
             $model->city_id = $_POST['Users']['city_id'];
             $model->email = $_POST['Users']['email'];
             $model->about = $_POST['Users']['about'];
             $model->phone = $_POST['Users']['phone'];
             $model->phone2 = $_POST['Users']['phone2'];
             $model->phone3 = $_POST['Users']['phone3'];
             if ($model->validate() && $model->save()) {
                 Yii::app()->user->setFlash('success_save', '1');
                 $this->redirect(array('index'));
             }
             /*else { 
                   echo CHtml::errorSummary($model);
                   //exit();
               }*/
         }
         if ($_POST['member'] == 1) {
             //$model->attributes=$_POST['Users'];
             if (isset($_POST['Users']['name_studio'])) {
                 $_POST['Users']['name'] = $_POST['Users']['name_studio'];
                 //unset($_POST['Users']['name_studio']);
                 $model->setScenario('studio_update');
             }
             foreach ($_POST['Users'] as $k => $v) {
                 if ($k == 'photo') {
                     if ($v != '') {
                         $model->photo = CUploadedFile::getInstance($model, 'photo');
                     }
                 } elseif ($k == 'url') {
                     $v = str_replace('http://', '', $v);
                     $model->{$k} = $v;
                 } else {
                     $model->{$k} = $v;
                 }
             }
             if (!isset($_POST['Users']['phone2'])) {
                 $model->phone2 = '';
             }
             if (!isset($_POST['Users']['phone3'])) {
                 $model->phone3 = '';
             }
             if (isset($_POST['year_b'])) {
                 $model->date_birth = $_POST['year_b'] . '-' . $_POST['month_b'] . '-' . $_POST['day_b'];
             }
             Yii::app()->user->name = $model->name;
             //echo '<pre>';
             //print_r($_POST);
             //echo '</pre>';
             //exit();
             if (isset($_POST['Users']['genre_id'])) {
                 $model->genre_id = serialize($_POST['Users']['genre_id']);
             }
             if ($model->save()) {
                 if (isset($_POST['Users']['genre_id'])) {
                     Yii::import('application.modules.my.models.Portfolio');
                     Yii::import('application.modules.my.models.Video');
                     Yii::import('application.modules.my.models.Genre');
                     $keys = array();
                     $data = '';
                     $data = Portfolio::model()->findAllByAttributes(array('uid' => Yii::app()->user->id));
                     //print_r($data); exit();
                     if (is_array($data) && !empty($data)) {
                         //Portfolio::model()->deleteAllByAttributes(array('uid'=>Yii::app()->user->id));
                         //exit();
                         foreach ($_POST['Users']['genre_id'] as $genre) {
                             $item = Portfolio::model()->findByAttributes(array('uid' => Yii::app()->user->id, 'title' => Genre::getName($genre)));
                             if (count($item) > 0) {
                                 $keys[] = $item->id;
                             } else {
                                 $mod = new Portfolio();
                                 $mod->title = Genre::getName($genre);
                                 $mod->uid = Yii::app()->user->id;
                                 $mod->save();
                                 $keys[] = $mod->id;
                             }
                         }
                         $del = new Portfolio();
                         $criteria = new CDbCriteria();
                         $criteria->condition = 'uid=' . Yii::app()->user->id;
                         $criteria->addNotInCondition('id', $keys);
                         $del->deleteAll($criteria);
                     } else {
                         foreach ($_POST['Users']['genre_id'] as $genre) {
                             $mod = new Portfolio();
                             $mod->title = Genre::getName($genre);
                             $mod->uid = Yii::app()->user->id;
                             $mod->save();
                             //print_r($mod);
                         }
                         //exit();
                     }
                     //////////VIDEO/////////////////////////
                     $keys = array();
                     $data = '';
                     $data = Video::model()->findAllByAttributes(array('uid' => Yii::app()->user->id));
                     //print_r($data); exit();
                     if (is_array($data) && !empty($data)) {
                         //Portfolio::model()->deleteAllByAttributes(array('uid'=>Yii::app()->user->id));
                         //exit();
                         foreach ($_POST['Users']['genre_id'] as $genre) {
                             $item = Video::model()->findByAttributes(array('uid' => Yii::app()->user->id, 'title' => Genre::getName($genre)));
                             if (count($item) > 0) {
                                 $keys[] = $item->id;
                             } else {
                                 $mod = new Video();
                                 $mod->title = Genre::getName($genre);
                                 $mod->uid = Yii::app()->user->id;
                                 $mod->save();
                                 $keys[] = $mod->id;
                             }
                         }
                         $del = new Video();
                         $criteria = new CDbCriteria();
                         $criteria->condition = 'uid=' . Yii::app()->user->id;
                         $criteria->addNotInCondition('id', $keys);
                         $del->deleteAll($criteria);
                     } else {
                         foreach ($_POST['Users']['genre_id'] as $genre) {
                             $mod = new Video();
                             $mod->title = Genre::getName($genre);
                             $mod->uid = Yii::app()->user->id;
                             $mod->save();
                             //print_r($mod);
                         }
                         //exit();
                     }
                 } elseif (isset($_POST['Users']['hals'])) {
                     StudioHals::model()->deleteAllByAttributes(array('uid' => Yii::app()->user->id));
                     $h = 1;
                     while ($h <= $_POST['Users']['hals']) {
                         $mod = new StudioHals();
                         $mod->title = 'Зал ' . $h;
                         $mod->uid = Yii::app()->user->id;
                         $mod->save();
                         $h++;
                     }
                 }
                 Yii::app()->user->setFlash('success_save', '1');
                 $this->redirect(array('index'));
             }
             /*else { 
                   $this->render('index',array('model'=>$model));
                   //echo CHtml::errorSummary($model);
                   //exit();
               } */
         }
     }
     //if(empty($_POST['Users']['genre_id']))
     //    $model->addError('genre_id','Необходимо указать жанр, в котром Вы работаете.');
     $this->render('index', array('model' => $model));
 }