Jump to content

Help with getting the Album_is that match user_is or user sessionID???


danjapro

Recommended Posts

Can Anyone look at the String above and direct  me to hwo would I go about gathering and collection only the AblumId and passing it for Hidden fields or url etc..

This is the code I am trying to use to get the information I need.Please help me.

:confused: :confused: :confused: :confused:

 

   function check_album_on($album_id){
      
      if(!$album_id) return true; // everybody can add an album if is a registered /author user
      
      $db =& JFactory::getDBO();
      $user =& JFactory::getUser();
      $query = 'SELECT user_id, id, format_id, date FROM #__muscol_albums WHERE id = ' . $album_id ;
      $db->setQuery($query);
      $album_creator = $db->loadResult();
      
      if($album_creator == $user->id) return true;
      else return false;
                          echo ".$album_id" or echo
      
   }

Link to comment
Share on other sites

I'm a little unclear on your question.  Can you give me a little more info on this follow up question..

 

Are you saying that you want to do a search on the table "#__muscol_albums" WHERE the `id` could be $Album_is OR $user_is OR a user sessionID???

 

Sorry.. just a little unclear on this..

Link to comment
Share on other sites

Here is the explanation,

Can you tell me if this will return the album_id that marches the user ID and allow me to echo that ID

 

		$user =& JFactory::getUser();

$id = JRequest::getVar( 'id' ) ;
$view = JRequest::getVar( 'view' ) ;

$params = &JComponentHelper::getParams( 'com_community' );
	$itemid = $params->get('itemid');
	   if($itemid != "") $itemid = "&Itemid=" . $itemid;


//function check_album_on($album_id){

	if(!$album_id) return true; // everybody can add an album if is a registered user

	$db =& JFactory::getDBO();
	$user =& JFactory::getUser();
                          $user_id = $user->id;
	$query = 'SELECT user_id, id, format_id, date FROM #__muscol_albums WHERE id = ' . $album_id ;
	$db->setQuery($query);
	$album_creator = $db->loadResult();

	if($album_id == $user_id) return true;
	echo id= '.$album_id';

}

Link to comment
Share on other sites

I wrote this below, to get the userid that is in the browser to SQL query against the user_id  in album table and get the $album_id or $id.

 

When my url in the browser is looks like:

"http://localhost/index.php?option=com_community&view=profile&userid=xx&id=xx&Itemid=xx" .. This works fine.

 

But I want to work without the "&id=xx", just like this

"http://localhost/index.php?option=com_community&view=profile&userid=xx&temid=xx"

 

SEE CODE

if (!isset($_GET['userid']))
	{
	$db =& JFactory::getDBO();
	$user =& JFactory::getUser();
        $userid = $user->id;


	$id = $_GET['userid'];
	$query = 'SELECT user_id, id, format_id, year, name FROM #__muscol_albums WHERE user_id = ' . $id;
	//$query = 'SELECT user_id FROM #__muscol_albums WHERE id = ' . $album_id ;
	$result = mysql_query($query) or die('Error, No Album Search failed');
	list($name, $user_id, $id, $year) = mysql_fetch_array($result);


	//$db =& JFactory::getDBO();
	//$user =& JFactory::getUser();
	//$query = 'SELECT user_id FROM #__muscol_albums WHERE id = ' . $album_id ;
	$db->setQuery($query);
	$album_id = $result();		

	echo $id;
	echo $user_id;
	echo $year;
	//exit;
	}	 

/* Creating URL */
$id=JRequest::getVar($prefix . 'id') ;
$url=JURI::root().'index.php?'.$component.'&id='.$id.'&tmpl=component&print=1';
for($i=1;$i<count($type);$i++){
	$url.='&'.$type[$i].'='.$layout[$i];
}

$url.=$custom;
//$url.=$custom."&id=$id";
/* End */

/* Getting current User Logged in  Session ID and First Album Id */
$session=&JFactory::getSession();
$session_id=$session->getId();
$id=$session->getId();
/* End */

/* Starting curl session */
$c_open=curl_init();
    curl_setopt($c_open, CURLOPT_URL , $url);
    curl_setopt($c_open, CURLOPT_HEADER, 1);
curl_setopt($c_open, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($c_open, CURLOPT_COOKIE, session_name().'='.$session_id );  
// Passing session ID.
    
$result=curl_exec($c_open);
    curl_close($c_open);
    /* End of curl session */

Link to comment
Share on other sites

The userid is passed from previous apges and is listed in borwser url and can be read a var or get.

I would leikt o query the userid = user_id from the muscol_album table and get back the ID of that match. What am I missing to get it to run the query and return the correct value, I have and If else statement that goes to another url and places default 'id=1'

 

I want the$url= with the correct id of that user??? HELP PLEASE  :shrug: :shrug:

 

 

/* Creating URL */
$id=JRequest::getVar($prefix . 'id') ; 	
if($id!=''){
	$db =& JFactory::getDBO();
	$user =& JFactory::getUser();
        $user_id = $user->id;


	$id = $_GET['userid'];
	$query = 'SELECT user_id, id, format_id, year, name FROM #__muscol_albums WHERE user_id = ' . $user_id;
	//$query = 'SELECT user_id FROM #__muscol_albums WHERE id = ' . $album_id ;
	$result = mysql_query($query) or die('Error, No Album Search failed');
	list($name, $user_id, $id, $year) = mysql_fetch_array($result);  
     $url=JURI::root().'index.php?'.$component.'&id='.$id.'&tmpl=component&print=1';
} else {
     $url=JURI::root().'index.php?'.$component.'&id=1&tmpl=component&print=1'; 
 //redirect is a function 
}	
//$url=JURI::root().'index.php?'.$component.'&id='.$id.'&tmpl=component&print=1';
for($i=1;$i<count($type);$i++){
	$url.='&'.$type[$i].'='.$layout[$i];
}

$url.=$custom;
//$url.=$custom."&id=$id";
/* End */

Link to comment
Share on other sites

 

please take a look at code below.. IAm trying to parse the userid from borwser to matcht eh user_id in table in DB then reutn it vaues, especially value for ID

 

HELPPPP

 

// no direct access
defined('_JEXEC') or die ('Restricted access');

/* Getting Parameters */
$component= $params->get('component','');
$view= $params->get('views','');
$custom=$params->get('custom','');
$auto=$params->get('autojscss','0');
$js=$params->get('customjs','');
$css=$params->get('customcss','');
$head_js=$params->get('custombodyjs','');
$head_css=$params->get('custombodycss','');
$id      = JRequest::getVar($prefix . 'id') ;
/* End of Parameters */



$type=array();
$layout=array();
if($component!=''){
/* Getting components parameters like task, view, layout, etc. */
$re1='.*?';	
$re2='(?:[a-z][a-z0-9_]*)';	
$re3='.*?';	
$re4='((?:[a-z][a-z0-9_]*))';	
$re5='.*?';	
$re6='((?:[a-z][a-z0-9_]*))';	
if ($c=preg_match_all ("/".$re1.$re2.$re3.$re4.$re5.$re6."/is", $view, $matches)){
	$type=$matches[1];
	$layout=$matches[2];
}
/* end */

    /* Passing Album Id from URL in borwser

      if(isset($_GET['id']) && is_numeric($_GET['id']))
              {
               if(intval($_GET['id'])=== null){
                echo '$id is a null and belongs to Administrator';
              }
         else
          {
        echo "NO ALBUM ID FOUND. SORRY.";
       }
		  
}
 */

	if (!isset($_GET['userid']))
	{
	$db =& JFactory::getDBO();
	$user =& JFactory::getUser();
        $userid = $user->id;


	$id = (!isset($_GET['userid']));
	$query = 'SELECT user_id, id, format_id, year, name FROM #__muscol_albums WHERE user_id = ' . $id;
	//$query = 'SELECT user_id FROM #__muscol_albums WHERE id = ' . $album_id ;
	$result = mysql_query($query) or die('Error, No Album Search failed');
	list($name, $user_id, $id, $year) = mysql_fetch_array($result);




	echo $id;
	echo $user_id;
	echo $year;
	//exit;
	}	 

/* Creating URL */

//if (!empty($_GET['id']) && (intval($_GET['id']) == $_GET['id'])) { 
//     $url=JURI::root().'index.php?'.$component.'&id='.$id.'&tmpl=component&print=1';
//} else {
    // $url=JURI::root().'index.php?'.$component.'&id=1&tmpl=component&print=1'; //redirect      is a function 

//}
$id=JRequest::getVar($prefix . 'id') ; 		
$url=JURI::root().'index.php?'.$component.'&id='.$id.'&tmpl=component&print=1';
for($i=1;$i<count($type);$i++){
	$url.='&'.$type[$i].'='.$layout[$i];
}

//$url.=$custom;
$url.=$custom."&id=$id";
/* End */

/* Getting current User Logged in  Session ID and First Album Id */
$session=&JFactory::getSession();
$session_id=$session->getId();
$id=$session->getId();
/* End */

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.