Example #1
0
/**
 * This function actually converts the video
 * @param string $file file loacation
 * @param int $videoId video guid
 * @param int $ownerGuid video owner guid
 * @param int $accessId access id
 * @return boolean
 */
function izapConvertVideo_izap_videos($file, $videoId, $videoTitle, $videoUrl, $ownerGuid, $accessId = 2)
{
    $return = false;
    // Works only if we have the input file
    if (file_exists($file)) {
        // Need to set flag for the file going in the conversion
        $queue_object = new izapQueue();
        $queue_object->change_conversion_flag($videoId);
        $video = new izapConvert($file);
        $videofile = $video->izap_video_convert();
        // Check if everything is ok
        if (!is_array($videofile)) {
            // If everything is ok then get back values to save
            $file_values = $video->getValues();
            $izap_videofile = 'izap_videos/uploaded/' . $file_values['filename'];
            $izap_origfile = 'izap_videos/uploaded/' . $file_values['origname'];
            $izap_videos = get_entity($videoId);
            $izap_videos->setFilename($izap_videofile);
            $izap_videos->open("write");
            $izap_videos->write($file_values['filecontent']);
            // Check if we have to keep original file
            if (izapAdminSettings_izap_videos('izapKeepOriginal') == 'YES') {
                $izap_videos->setFilename($izap_origfile);
                $izap_videos->open("write");
                $izap_videos->write($file_values['origcontent']);
            }
            $izap_videos->converted = 'yes';
            $izap_videos->videofile = $izap_videofile;
            $izap_videos->orignalfile = $izap_origfile;
            notify_user($ownerGuid, elgg_get_site_entity()->getGUID(), elgg_echo('izap_videos:notifySub:videoConverted'), elgg_echo('izap_videos:notifyMsg:videoConverted', array($videoUrl)));
            return true;
        } else {
            $errorReason = $videofile['message'];
        }
    } else {
        $errorReason = elgg_echo('izap_videos:fileNotFound');
    }
    $adminGuid = izapGetSiteAdmin_izap_videos(true);
    // notify admin
    notify_user($adminGuid, elgg_get_site_entity()->getGUID(), elgg_echo('izap_videos:notifySub:videoNotConverted'), elgg_echo('izap_videos:notifyAdminMsg:videoNotConverted', array($errorReason)));
    if (!empty($errorReason)) {
        $return = array('error' => true, 'reason' => $errorReason);
    }
    return $return;
}
Example #2
0
/**
 * this fucntion actually converts the video
 * @param string $file file loacation
 * @param int $videoId video guid
 * @param int $ownerGuid video owner guid
 * @param int $accessId access id
 * @return boolean
 */
function izapConvertVideo_izap_videos($file, $videoId, $videoTitle, $videoUrl, $ownerGuid, $accessId = 2)
{
    global $CONFIG;
    $return = FALSE;
    // works only if we have the input file
    if (file_exists($file)) {
        // now convert video
        //
        // Need to set flag for the file going in the conversion.
        $queue_object = new izapQueue();
        $queue_object->change_conversion_flag($videoId);
        $video = new izapConvert($file);
        $videofile = $video->izap_video_convert();
        // check if every this is ok
        if (!is_array($videofile)) {
            // if every thing is ok then get back values to save
            $file_values = $video->getValues();
            $izap_videofile = 'izap_videos/uploaded/' . $file_values['filename'];
            $izap_origfile = 'izap_videos/uploaded/' . $file_values['origname'];
            $izap_videos = new IzapVideos($videoId);
            $izap_videos->setFilename($izap_videofile);
            $izap_videos->open("write");
            $izap_videos->write($file_values['filecontent']);
            //check if you do not want to keep original file
            if (get_plugin_setting('izapKeepOriginal', GLOBAL_IZAP_VIDEOS_PLUGIN) == 'YES') {
                $izap_videos->setFilename($izap_origfile);
                $izap_videos->open("write");
                $izap_videos->write($file_values['origcontent']);
            }
            $izap_videos->converted = 'yes';
            $izap_videos->videofile = $izap_videofile;
            $izap_videos->orignalfile = $izap_origfile;
            notify_user($ownerGuid, $CONFIG->site_guid, elgg_echo('izap_videos:notifySub:videoConverted'), sprintf(elgg_echo('izap_videos:notifyMsg:videoConverted'), $izap_videos->getUrl()));
            return true;
        } else {
            $errorReason = $videofile['message'];
        }
    } else {
        $errorReason = elgg_echo('izap_videos:fileNotFound');
    }
    $adminGuid = izapGetSiteAdmin_izap_videos(TRUE);
    // notify admin
    notify_user($adminGuid, $CONFIG->site_guid, elgg_echo('izap_videos:notifySub:videoNotConverted'), sprintf(elgg_echo('izap_videos:notifyAdminMsg:videoNotConverted'), $errorReason));
    if (!empty($errorReason)) {
        $return = array('error' => TRUE, 'reason' => $errorReason);
    }
    return $return;
}