Jamroom Logo Jamroom 5 Core
is now Open Source!
User Support Forum Archive (Read Only)
Jamroom Developers:
Still trying to lose the Youtube ID requirement
jamesd116



Joined: 05 Jun 2006
Posts: 1559
Location: Rochester Pa

Posted: 06/28/09 10:37 
Ihave tried many things here to try to lose the yout ube id requirement can someone tell me what parts of the code needs changed so that it is not a reuirement Thanks James


Code
<?php
/**
 * Jamroom jrYouTube Module Form Controller
 * @copyright 2009 by Talldude Networks LLC
 * @author Brian Johnson - bigguy@talldude.net
 */
require('include/jamroom-include.inc.php');

// Our script
$GLOBALS['JR_SCRIPT_NAME'] = 'jrYouTube.php';

$_post = getPostVars();
// Login required - get $_user
$_user = sessionVerify();
// get the correct language pack included..
$language = getLanguage($_user['user_language']);

// Show correct form based on "mode" received
switch ($_post['mode']) {

    // Create
    case 'create':

        // retrieve saved data from session
        $_rep = getForm('jrYouTube');

        jmHtmlBegin($language['jrYouTube'][1]);
        jmBodyBegin();
        jmSpanCell($language['jrYouTube'][1],'',30,'html_modify.png');
        jrGetFormNotice();
        jmBeginForm('jrYouTube.php?mode=save');
        jmInput($language['jrYouTube'][4],'youtube_video_id','text',$_rep['youtube_video_id']);
        jmInput($language['jrYouTube'][5],'youtube_video_category','text',$_rep['youtube_video_category']);
        jrFormSubmit($language['jrYouTube'][2],false,false,'admin.php?s=section_jrYouTubeMenu');
        jmEndForm();
        jmBodyEnd();
        jmHtmlEnd();
        exit;
        break;

    // Save
    case 'save':

        // Save posted values to session
        saveForm('jrYouTube');

        // Error Checking - YouTube ID is required
        if (strlen($_post['youtube_video_id']) === 0) {
            setFormHighlight('youtube_video_id');
            jrSetFormNotice('error',$language['jrYouTube'][6]);
            jrLocation('jrYouTube.php?mode=create');
        }

        // We need to grab the YouTube ID from the URL they entered
        // URL will be like: http://www.youtube.com/watch?v=84sZMS95yYM
        // We need "v"
        if (isset($_post['youtube_video_id']) && strstr($_post['youtube_video_id'],'http')) {
            // They entered the FULL UL
            $_tmp = parse_url($_post['youtube_video_id']);
            parse_str($_tmp['query'],$_tmp);
            // This will get us "v=84sZMS95yYM" - run through
            if (isset($_tmp['v']) && strlen($_tmp['v']) > 0) {
                $_post['youtube_video_id'] = $_tmp['v'];
            }
            else {
                setFormHighlight('youtube_video_id');
                jrSetFormNotice('error',$language['jrYouTube'][6]);
                jrLocation('jrYouTube.php?mode=create');
            }
        }
        else {
            // See if they gave us just the YouTube ID
            // We safeBaseName the value to prevent someone from entering a full path
            $_post['youtube_video_id'] = safeBaseName(trim($_post['youtube_video_id']));
        }
        // No error - prep database values
        $_post['youtube_video_id']       = dbEscapeString($_post['youtube_video_id']);
        $_post['youtube_video_category'] = dbEscapeString($_post['youtube_video_category']);

        // see if we are doing a new video or an
        // existing video (we'll receive a youtube_id)
        if (checkType($_post['youtube_id'],'number_nz')) {
            $req = "UPDATE {$jamroom_db['jrYouTubeVideos']} SET
                      youtube_video_id       = '{$_post['youtube_video_id']}',
                      youtube_video_time     = '". time() ."',
                      youtube_video_category = '{$_post['youtube_video_category']}'
                     WHERE youtube_id = '{$_post['youtube_id']}'
                       AND youtube_band_id = '{$_user['user_band_id']}'
                     LIMIT 1";
            $cnt = dbQuery($req,'COUNT');
            if (!checkType($cnt,'number_nz')) {
                jrSetFormNotice('error','Error updating entry - check connection');
                jrLocation("jrYouTube.php?mode=update&youtube_id={$_post['youtube_id']}");
            }
        }
        else {
            $req = "INSERT INTO {$jamroom_db['jrYouTubeVideos']} (
                      youtube_band_id,
                      youtube_video_id,
                      youtube_video_time,
                      youtube_video_category
                    ) VALUES (
                      '{$_user['user_band_id']}',
                      '{$_post['youtube_video_id']}',
                      '". time() ."',
                      '{$_post['youtube_video_category']}'
                    )";
            $cnt = dbQuery($req,'INSERT_ID');
            $_post['youtube_id'] = (int) $cnt;
            if (!checkType($cnt,'number_nz')) {
                jrSetFormNotice('error','Error saving entry - check connection');
                jrLocation('jrYouTube.php?mode=create');
            }
        }
        // Looks good - reset, rebuild and return
        resetForm('jrYouTube');
        setLock($_user['user_band_id'],'on');
        jrSetFormNotice('success',$language['jrYouTube'][7]);
        jrLocation("jrYouTube.php?mode=update&youtube_id={$_post['youtube_id']}");
        break;

    // Modify
    case 'modify':

        // Get existing videos for this profile
        $req = "SELECT youtube_id, youtube_video_id, youtube_video_category
                  FROM {$jamroom_db['jrYouTubeVideos']}
                 WHERE youtube_band_id = '{$_user['user_band_id']}'
                 ORDER BY youtube_video_id ASC";
        $_rt = dbQuery($req,'NUMERIC');
        if (isset($_rt[0]) && is_array($_rt[0])) {
            foreach ($_rt as $_video) {
                $_sel["{$_video['youtube_id']}"] = "{$_video['youtube_video_id']} ({$_video['youtube_video_category']})";
            }
        }
        jmHtmlBegin($language['jrYouTube'][11]);
        jmBodyBegin();
        jmSpanCell($language['jrYouTube'][11],'',30,'html_modify.png');
        jrGetFormNotice();
        jmBeginForm('jrYouTube.php?mode=update');
        jmSelect($language['jrYouTube'][11],'youtube_id',$_sel);
        jrFormSubmit($language['jrYouTube'][11],false,false,'admin.php?s=section_jrYouTubeMenu');
        jmEndForm();
        jmBodyEnd();
        jmHtmlEnd();
        exit;
        break;

    // Update
    case 'update':

        if (!checkType($_post['youtube_id'],'number_nz')) {
            setFormHighlight('youtube_id');
            jrSetFormNotice('error',$language['jrYouTube'][6]);
            jrLocation('jrYouTube.php?mode=modify');
        }
        // Get the request youtube video info from the DB
        $req = "SELECT *
                  FROM {$jamroom_db['jrYouTubeVideos']}
                 WHERE youtube_id = '{$_post['youtube_id']}'
                 LIMIT 1";
        $_rt = dbQuery($req,'SINGLE');
        if (!isset($_rt) || !is_array($_rt)) {
            // Cannot find entry in database
            setFormHighlight('youtube_id');
            jrSetFormNotice('error',$language['jrYouTube'][6]);
            jrLocation('jrYouTube.php?mode=modify');
        }
        jmHtmlBegin($language['jrYouTube'][11]);
        jmBodyBegin();
        jmSpanCell($language['jrYouTube'][11],'',30,'html_modify.png');
        jrGetFormNotice();
        jmBeginForm("jrYouTube.php?mode=save&amp;youtube_id={$_post['youtube_id']}");
        jmShowLine('<object width="480" height="295"><param name="movie" value="http://www.youtube.com/v/'. $_rt['youtube_video_id'] .'&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'. $_rt['youtube_video_id'] .'&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="295"></embed></object>');
        jmInput($language['jrYouTube'][4],'youtube_video_id','text',$_rt['youtube_video_id']);
        jmInput($language['jrYouTube'][5],'youtube_video_category','text',$_rt['youtube_video_category']);
        jrFormSubmit($language['jrYouTube'][2],false,false,'admin.php?s=section_jrYouTubeMenu');
        jmEndForm();
        jmBodyEnd();
        jmHtmlEnd();
        exit;
        break;

    // Delete
    case 'delete':

        jmHtmlBegin($language['jrYouTube'][1]);
        jmBodyBegin();
        jmSpanCell($language['jrYouTube'][1],'',30,'html_modify.png');
        jmBeginForm('jrYouTube.php?mode=remove');
        jrGetFormNotice();
     
        // Get our current videos
        $req = "SELECT *
                  FROM {$jamroom_db['jrYouTubeVideos']}
                 WHERE youtube_band_id = '{$_user['user_band_id']}'";
        $_rt = dbQuery($req,'youtube_video_id',null,false,'youtube_video_id');

        if (is_array($_rt)) {
            jmSelect($language['jrYouTube'][3],'youtube_video_id',$_rt);
            jrFormSubmit($language['jrYouTube'][3],false,false,false,$language['jrYouTube'][9]);
        }
        else {
            jmShowLine($language['jrYouTube'][8]);
            jrCancel('admin.php?s=section_jrYouTubeMenu');
        }
        jmEndForm();
        jmBodyEnd();
        jmHtmlEnd();
        exit;
        break;

    // Remove
    case 'remove':

        // Error Checking - YouTube ID is required
        if (strlen($_post['youtube_video_id']) > 0) {
            $req = "DELETE FROM {$jamroom_db['jrYouTubeVideos']}
                     WHERE youtube_video_id = '". dbEscapeString($_post['youtube_video_id']) ."'
                       AND youtube_band_id = '{$_user['user_band_id']}'
                     LIMIT 1";
            $cnt = dbQuery($req,'COUNT');
            if (isset($cnt) && $cnt == '1') {
                setLock($_user['user_band_id'],'on');
                jrSetFormNotice('success',$language['jrYouTube'][10]);
                jrLocation('jrYouTube.php?mode=delete');
            }
        }
        jrSetFormNotice('error',$language['jrYouTube'][6]);
        jrLocation('jrYouTube.php?mode=delete');
        break;

    // Video Browse - admin only
    case 'video_browse':

        jrAdminOnly();

        jmHtmlBegin('Browse YouTube Videos');
        jmBodyBegin();
        jmSpanCell('Browse YouTube Videos','',30,'html_select.png');
        // Start our header
        $dat[1]['title'] = 'YouTube URL';
        $dat[1]['style'] = 'width:75%;';
        $dat[2]['title'] = 'Category';
        $dat[2]['style'] = 'width:25%;';
        htmlPageSelect('header',$dat);
        unset($dat);

        // Get all of the YouTube Videos entered
        $req = "SELECT *
                  FROM {$jamroom_db['jrYouTubeVideos']}
                 ORDER BY youtube_id DESC";
        $_rt = dbQuery($req,'NUMERIC');
        if (isset($_rt) && is_array($_rt)) {
           foreach ($_rt as $_video) {
               $dat[1]['title'] = "<a href=\"{$config['jryoutube_base_url']}{$_video['youtube_video_id']}\" target=\"_blank\">{$_video['youtube_video_id']}</a>";
               $dat[2]['title'] = $_video['youtube_video_category'];
               htmlPageSelect('row',$dat);
           }
        }
        htmlPageSelect('footer');
        jmBodyEnd();
        jmHtmlEnd();
        exit;
        break;

    // Default - invalid mode
    default:
        jrInvalidOption();
        break;
}
?>



_________________
One day the court system will learn that a childs mother is not the only option...... Question is will it be too late by that time...
Back to top
SteveX
Ultrabubble


Joined: 30 Aug 2005
Posts: 8792
Location: Ultrabubble

Posted: 06/28/09 11:32 
This is the check:

Code
        // Error Checking - YouTube ID is required
        if (strlen($_post['youtube_video_id']) === 0) {
            setFormHighlight('youtube_video_id');
            jrSetFormNotice('error',$language['jrYouTube'][6]);
            jrLocation('jrYouTube.php?mode=create');
        }

But if you remove it you will still need an id because everything revolves around the youtube id - if there is no id there is no item.


_________________
Kulshi Mezian!

"Stranger from another planet, welcome to our hole. Just strap on your guitar and we'll play some rock and roll"

Ultrabubble create things.
Back to top
jamesd116



Joined: 05 Jun 2006
Posts: 1559
Location: Rochester Pa

Posted: 06/28/09 12:38 
right if i remove it then it doesnt work but i am not trying to pull a you tube video so I do not need the you tube ID I am just trying to get the form to input the information into the database


_________________
One day the court system will learn that a childs mother is not the only option...... Question is will it be too late by that time...
Back to top
jamesd116



Joined: 05 Jun 2006
Posts: 1559
Location: Rochester Pa

Posted: 07/03/09 21:17 
I have been over and over this form mayny times over does anyone see why that it keeps asking me for the ID


_________________
One day the court system will learn that a childs mother is not the only option...... Question is will it be too late by that time...
Back to top
smith.kyle
CodeSmith


Joined: 27 Apr 2006
Posts: 22009
Location: Southern California

Posted: 07/04/09 14:57 
What is the exact error you're getting?


_________________
kyle[at]jamroom.net

Yes...that's a soda machine...

I get bored when no one's posting...
Back to top
jamesd116



Joined: 05 Jun 2006
Posts: 1559
Location: Rochester Pa

Posted: 07/04/09 16:36 

Code
Invalid YouTube ID - please enter a valid ID
This is the error code I have modified the coding which is in my other post or if someone can give me an exmaple of how to create the form and have it work wihout the you tube ID


_________________
One day the court system will learn that a childs mother is not the only option...... Question is will it be too late by that time...
Back to top
SteveX
Ultrabubble


Joined: 30 Aug 2005
Posts: 8792
Location: Ultrabubble

Posted: 07/04/09 17:39 
JimmyD, the youtube module is the example.

You might need to spend a little time reading some of the sites liked to in this thread:
http://www.jamroom.net/phpBB2/viewtopic.php?t=851

As a shortcut, the php.net site is the bible, but it is sometimes faster to find suitable examples on
http://www.w3schools.com/
http://tizag.com
or others
[/u][/i]


_________________
Kulshi Mezian!

"Stranger from another planet, welcome to our hole. Just strap on your guitar and we'll play some rock and roll"

Ultrabubble create things.
Back to top
smith.kyle
CodeSmith


Joined: 27 Apr 2006
Posts: 22009
Location: Southern California

Posted: 07/05/09 12:21 
Removing this:

// Error Checking - YouTube ID is required
if (strlen($_post['youtube_video_id']) === 0) {
setFormHighlight('youtube_video_id');
jrSetFormNotice('error',$language['jrYouTube'][6]);
jrLocation('jrYouTube.php?mode=create');
}

As SteveX suggested should make it not require a youtube_video_id. What happens when you remove that?


_________________
kyle[at]jamroom.net

Yes...that's a soda machine...

I get bored when no one's posting...
Back to top
elygen



Joined: 22 Feb 2007
Posts: 637

Posted: 07/06/09 07:10 
The script checks the id a few times. You may want to add a "case save2:" for example that only checks for elements you want the add then add them to the database. Just curious, not adding the video is defeating the purpose of this module, isn't it?


_________________
~ Todd
=================
Happy Jamrooming
New Jersey
www.bandarray.com
Back to top
Display posts from previous:   
User Support Forum Archive (Read Only)
Jamroom Developers

 
Solutions
• Social Media Platform
• Social Networking Software
• Musician Website Manager
• Community Builder
Products
• Jamroom Core
• Jamroom Addons
• Jamroom Modules
• Jamroom Marketplace
Support
• Support Forum
• Documentation
• Support Center
• Contact Support
Community
• Community Forum
• Member Sites
• Developers
Company
• About Us
• Contact Us
• Privacy Policy
©2003 - 2010 Talldude Networks, LLC.