Example #1
0
    /**
     * Outputs frontpage HTML
     *
     * @return       Nothing
     */

    function addVideoToPlaylist()
	{
		header('Content-type: text/html; charset=utf-8');
		echo "<META NAME=\"ROBOTS\" CONTENT=\"NOINDEX, NOFOLLOW\">";

		$c = hwd_vs_Config::get_instance();
		$db = & JFactory::getDBO();
		$my = & JFactory::getUser();

		if (!$my->id) {
			echo _HWDVIDS_AJAX_LOG2ADD2PL;
			exit;
		}

		$user_id = $my->id;
		$videoid = JRequest::getInt( 'videoid', 0, 'request' );
		$playlistid = JRequest::getInt( 'playlistid', 0, 'request' );
		$date = date('Y-m-d H:i:s');
		$published = 1;

		if ($playlistid == 0) {
			echo _HWDVIDS_SELPL;
			exit;
		}

		$row = new hwdvids_playlist($db);
		$row->load( $playlistid );

		if (empty($row->playlist_data)) {
			$playlist_data = $videoid;
		} else {
			$playlist_data = $row->playlist_data.",".$videoid;
		}

		$_POST['id'] 	   			   = $playlistid;
		$_POST['playlist_data']        = $playlist_data;

		// bind it to the table
		if (!$row -> bind($_POST)) {
			echo "<script> alert('"
				.$row -> getError()
				."'); window.history.go(-1); </script>\n";
			exit();
		}

		// store it in the db
		if (!$row -> store()) {
			echo "<script> alert('"
				.$row -> getError()
				."'); window.history.go(-1); </script>\n";
			exit();
		}

		// perform maintenance
		require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'libraries'.DS.'maintenance_recount.class.php');
		hwd_vs_recount::recountVideosInPlaylist($playlistid);

		$row = new hwdvids_playlist($db);
		$row->load( $playlistid );
		if (!empty($row->playlist_data))
		{
			$playlist = explode(",", $row->playlist_data);
			$playlist = preg_replace("/[^0-9]/", "", $playlist);

			$counter = 0;
			$pl_videos = array();
			for ($i=0, $n=count($playlist); $i < $n; $i++)
			{
				$db->SetQuery('SELECT * FROM #__hwdvidsvideos WHERE id = '.$playlist[$i]);
				$video = $db->loadObject();
				if (isset($video->id))
				{
					$pl_videos[$counter] = $video;
					$counter++;
				}
			}
		}

		require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'helpers'.DS.'draw.php');
		hwdvsDrawFile::XMLDataFile($pl_videos, "pl_$playlistid");
		hwdvsDrawFile::XMLPlaylistFile($pl_videos, "pl_$playlistid");

		echo _HWDVIDS_ALERT_SUCAV2PL;
		exit;
	}
Example #2
0
    /**
     * Outputs frontpage HTML
     *
     * @return       Nothing
     */
    function updatePlaylist()
	{
		global $Itemid, $mainframe;
		$db = & JFactory::getDBO();
		$my = & JFactory::getUser();
		$c = hwd_vs_Config::get_instance();

		$playlist_id = JRequest::getInt( 'playlist_id', 0 );
		$referrer = JRequest::getVar( 'referrer', JURI::root( true ) . '/index.php?option=com_hwdvideoshare&task=viewChannel&Itemid='.$Itemid.'&user_id='.$my->id.'&sort=playlists' );

		$row = new hwdvids_playlist($db);
		$row->load( $playlist_id );

		if ($row->user_id != $my->id) {
			$mainframe->enqueueMessage(_HWDVIDS_ALERT_NOPERM);
			$mainframe->redirect( $referrer );
		}

		$playlist_name 		   = Jrequest::getVar( 'playlist_name', _HWDPS_UNKNOWN );
		$playlist_description  = Jrequest::getVar( 'playlist_description', _HWDPS_UNKNOWN );
		$public_private    	   = JRequest::getWord( 'public_private' );

		$_POST['id'] 		            = $playlist_id;
		$_POST['playlist_name'] 		= $playlist_name;
		$_POST['playlist_description']  = $playlist_description;
		$_POST['public_private'] 	    = $public_private;

		// bind it to the table
		if (!$row -> bind($_POST)) {
			echo "<script> alert('"
				.$row -> getError()
				."'); window.history.go(-1); </script>\n";
			exit();
		}

		// store it in the db
		if (!$row -> store()) {
			echo "<script> alert('"
				.$row -> getError()
				."'); window.history.go(-1); </script>\n";
			exit();
		}

		$msg = _HWDVIDS_ALERT_PLSAVED;
		$mainframe->enqueueMessage($msg);
		$mainframe->redirect( $referrer );
  	}