<?php
/**
 * This file is to upload the audios
 *
 * This file is having AudioUpload class to upload the audios
 *
 * PHP version 5.0
 *
 * @category	Anova
 * @package		Members
 * @author 		shankar_76ag08
 * @copyright 	Copyright (c) 2009 {@link http://www.agriya.com Agriya Infoway}
 * @license		http://www.agriya.com Agriya Infoway Licence
 * @version		SVN: $Id:
 * @since 		2008-11-07
 *
 **/
require_once('../common/configs/config.inc.php');

$CFG['lang']['include_files'][] = 'languages/%s/'.$CFG['admin']['index']['anova_module'].'/videoUpload.php';
$CFG['site']['is_module_page'] = $CFG['admin']['index']['anova_module'];
//compulsory
$CFG['mods']['is_include_only']['html_header'] = false;
$CFG['html']['is_use_header'] = false;
$CFG['auth']['is_authenticate'] = 'members';
$CFG['is']['ajax_page'] = true;
require_once($CFG['site']['project_path'].'common/application_top.inc.php');
set_time_limit(0);
/**
 * AudioUpload
 *
 * @package
 * @author selvaraj_35ag05
 * @copyright Copyright (c) 2009
 * @version $Id: audioUpload.php 892 2007-05-26 13:23:06Z selvaraj_35ag05 $
 * @access public
 **/
class AudioUpload extends FormHandler
	{
		public function chkIsValidCaptureFile()
			{
				$file_name = $this->CFG['admin']['video']['red5_flv_path'].$this->fields_arr['rid'].'.mp3';
				if(1 or is_file($file_name))
					return true;
				return false;
			}

		public function resetFieldsArray()
			{
				$this->setFormField('rid', '');
			}
	}
//<<<<<-------------- Class AudioUpload begins ---------------//
//-------------------- Code begins -------------->>>>>//
$AudioUpload = new AudioUpload();

if(!isAjax())
	Redirect2URL(getAnovaUrl('questions', '?view=ask', 'ask/'));

$AudioUpload->setPageBlockNames(array('audio_upload_form_capture'));

//default form fields and values...
$AudioUpload->resetFieldsArray();

$AudioUpload->setAllPageBlocksHide();
$AudioUpload->setPageBlockShow('audio_upload_form_capture');
$AudioUpload->sanitizeFormInputs($_REQUEST);

if($AudioUpload->isFormGETed($_GET, 'upload'))
	{
		if($AudioUpload->chkIsValidCaptureFile())
			{
				$AudioUpload->setAllPageBlocksHide();
				$AudioUpload->setCommonSuccessMsg($LANG['success_uploaded']);
				$AudioUpload->setPageBlockShow('block_msg_form_success');
			}
		else
			{
				$AudioUpload->setCommonSuccessMsg($LANG['error_uploaded']);
				$AudioUpload->setPageBlockShow('block_msg_form_error');
			}
	}
//<<<<<-------------------- Code ends----------------------//
//-------------------- Page block templates begins -------------------->>>>>//

if ($AudioUpload->isShowPageBlock('audio_upload_form_capture'))
	{
		$settingspath = $CFG['site']['url'].$CFG['admin']['index']['anova_module'].'/quickCaptureConfigXmlCode.php?file_name='.$AudioUpload->getFormField('rid');
		$skinpath = $CFG['site']['url'].$CFG['admin']['index']['anova_module'].'/files/flash/audio_capture/skins/skin.xml';
		$AudioUpload->quick_recorder_path = $CFG['site']['url'].$CFG['admin']['index']['anova_module'].'/files/flash/audio_capture/QuickRecorder.swf?filename='.$AudioUpload->getFormField('rid').'&settingspath='.$settingspath.'&themePath='.$skinpath;
	}

//--------------------Page block templates begins-------------------->>>>>//
//include the header file
$AudioUpload->includeAjaxHeader();
//include the content of the page
setTemplateFolder('members/', $CFG['admin']['index']['anova_module']);
$smartyObj->display('audioUpload.tpl');
//include the footer of the page
//<<<<<<--------------------Page block templates Ends--------------------//
$AudioUpload->includeAjaxFooter();
?>