Ejemplo n.º 1
0
    /**
     * Outputs frontpage HTML
     *
     * @return       Nothing
     */
    function addVideoToGroup()
	{
	global $database, $my, $acl, $mosConfig_absolute_path, $mosConfig_mailfrom, $mosConfig_fromname, $mosConfig_live_site, $Itemid, $mosConfig_sitename;
		$db = & JFactory::getDBO();
		$c = hwd_vs_Config::get_instance();
		$url = $db->getEscaped( strip_tags( trim( strtolower( mosGetParam( $_POST, 'url' ) ) ) ) );

		if (!$my->id) {
			hwd_vs_tools::infomessage(1, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ALERT_LOG2AV2G, "exclamation.png", 1);
			return;
		}

		$userid = $my->id;
		$videoid = intval ( mosGetParam($_POST, 'videoid') );
		$groupid = intval ( mosGetParam($_POST, 'groupid') );
		$date = date('Y-m-d H:i:s');
		$published = 1;

		if ($groupid == 0) {
			hwd_vs_tools::infomessage(1, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ALERTSELGROUP, "exclamation.png", 1);
			return;
		}

		$where = ' WHERE a.videoid = '.$videoid;
		$where .= ' AND a.groupid = '.$groupid;

		$db->SetQuery( 'SELECT count(*)'
							. ' FROM #__hwdvidsgroup_videos AS a'
							. $where
							);
  		$total = $db->loadResult();

		if ( $total>0 ) {
			hwd_vs_tools::infomessage(1, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ALERT_ALREADYAV2G, "exclamation.png", 1);
			return;
		}

		$row = new hwdvids_groupvideo($database);

		$_POST['videoid'] = $videoid;
		$_POST['groupid'] = $groupid;
		$_POST['memberid'] = $userid;
		$_POST['date'] = $date;

		// 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::recountVideosInGroup($groupid);

		hwd_vs_tools::infomessage(1, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ALERT_SUCAV2G, "exclamation.png", 1);
		return;
	}
Ejemplo n.º 2
0
    /**
     * Outputs frontpage HTML
     *
     * @return       Nothing
     */

    function addVideoToGroup()
	{
		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_LOG2ADD2G;
			exit;
		}

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

		if ($groupid == 0) {
			echo _HWDVIDS_ALERTSELGROUP;
			exit;
		}

		$where = ' WHERE a.videoid = '.$videoid;
		$where .= ' AND a.groupid = '.$groupid;

		$db->SetQuery( 'SELECT count(*)'
               		. ' FROM #__hwdvidsgroup_videos AS a'
               		. $where
               		);
  		$total = $db->loadResult();

		if ( $total>0 ) {
			echo _HWDVIDS_ALERT_ALREADYAV2G;
			exit;
		}

		$row = new hwdvids_groupvideo($db);

		$_POST['videoid'] = JRequest::getInt( 'videoid', 0, 'request' );
		$_POST['groupid'] = JRequest::getInt( 'groupid', 0, 'request' );
		$_POST['memberid'] = JRequest::getInt( 'userid', 0, 'request' );;
		$_POST['date'] = $date;

		// 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::recountVideosInGroup($groupid);

		echo _HWDVIDS_ALERT_SUCAV2G;
		exit;
	}