JOOM::GALLERY::FORUM

JoomGallery 2.x ACL => Solved Topics: Frontend => Topic started by: wolfoenix on 17-09-2012 13:50:21



Title: [ Fixed ] Bug between obSocialSubmit 1.8.6 (plugin v1.8) and JoomGallery 2.0
Post by: wolfoenix on 17-09-2012 13:50:21
Hello all,

As foobla.com as the worst forum ever that didn't even work, I post this issue here as it's about JoomGallery and some users may be interested

I've found a 2 bugs betwwen obSocialSubmit 1.8.6 and JoomGallery 2.0.

1/ when you activate JoomGallery plugin for obSocialSubmit (v1.8) it seems tht he incompatible with JoomGallery 2.0 as I get error when browsing categories in Front-End and Back-End.
Code:
Fatal error: Call to a member function getUserState() on a non-object in blablabla.com/components/com_obsocialsubmit/addons/intern/joomgallery/joomgallery.php on line 88


To solve this bug, edit the PHP file and add this line :
Code:
$mainframe = &JFactory::getApplication();
on line 87 before
Code:
$joomgallery_category_id = $mainframe->getUserState( 'joomgallery_category_id' );


Maybe not the best fix, but solve the issue



2/ When you try to configure the obSocialSubmit JoomGallery 1.8 with JoomGallery 2.0, it doesn't show any categorie.
"None data!" is displayed instead.
Edit the file blablabla.com/components/com_obsocialsubmit/addons/intern/joomgallery/joomgallery.php

and change those lines (starting at line #25:
Code:
$qr = '
SELECT
`cid` as `id`, `name` as `title`, `parent`
FROM
`#__joomgallery_catg`
WHERE
`published` = 1
AND
`parent` = '.(int)$id;  
to those lines
Code:

$qr = '
SELECT
`cid` as `id`, `name` as `title`, `parent_id`
FROM
`#__joomgallery_catg`
WHERE
`published` = 1
AND
`parent_id` = '.(int)$id;  


Hope it helps

Regards


WFX


Title: Re: [ Fixed ] Bug between obSocialSubmit 1.8.6 (plugin v1.8) and JoomGallery 2.0
Post by: Chraneco on 17-09-2012 14:59:19
Hi,

according to the code this plugin was written for JoomGallery 1.5.
The developers of that extension have to update it. It would be better to use the interface class (http://www.en.joomgallery.net/documentation/common-information/api/interface.html) that comes with JoomGallery for things like that because this class doesn't change across the different versions of JoomGallery.

Regards
Chraneco


Title: Re: [ Fixed ] Bug between obSocialSubmit 1.8.6 (plugin v1.8) and JoomGallery 2.0
Post by: wurstel on 13-12-2012 09:40:10
Hello! I've the same issue.

The first fix works perfectly for me. Thank you!

But for the second one there is none of the code in my file. The word 'parent' don't appears once in the whole file.

I've problems with posting code, maybe it works with a new answer.


Title: Re: [ Fixed ] Bug between obSocialSubmit 1.8.6 (plugin v1.8) and JoomGallery 2.0
Post by: wurstel on 13-12-2012 09:40:54
Code:
class OBSSInAddonJoomGallery {
public $config = null;
public $event = 'onAfterDispatch';
public $data = null;
public $revent = array();

function __construct($data=null) {
$this->data = $data;
$this->event = array('onAfterDispatch');
}

function onCronJob(){
return null;
}

public function onAfterInitialise(){
$mainframe = &JFactory::getApplication();
if($mainframe->isAdmin()){
return $this->onAfterRoute();
}
}

public function onAfterRoute(){
$mainframe = &JFactory::getApplication();
$option = &JRequest::getVar('option');
$controller = &JRequest::getVar('controller');
$task = &JRequest::getVar('task');
$config = $this->getConfig();
$action = $config->get('action');
$write_log = $config->get('write_log');
if( $write_log && $controller=='categories' ){
jimport('joomla.filesystem.file');
$file_path = dirname(__FILE__).DS.pathinfo(__FILE__,PATHINFO_FILENAME).'.html';
$content='';
if(JFile::exists($file_path)){
$content = JFile::read( $file_path );
}
$content = "\n-----onAfterRoute-----\n".print_r($_REQUEST,true)."\n-----onAfterRoute-----\n";
JFile::write($file_path,$content);
}
if($option=='com_joomgallery' && ( ($controller=='categories' && ( $task == 'apply' || $task == 'save' ))|| $task=='savecategory') ) {

# echo '<pre>'.print_r($_REQUEST,true).'</pre>';exit();
$cid = &JRequest::getVar('cid');
$published = &JRequest::getVar('published');
$details  = &JRequest::getVar('details');
$catimage = isset($details['catimage'])?$details['catimage']:'';
if($mainframe->isSite()) $catimage=&JRequest::getVar('catimage');

# only publish mesage to social network when edit categor
if( $catimage && $published && $cid ){
$mainframe->setUserState('joomgallery_category_id', $cid);
}
}
if($option == 'com_joomgallery' && $controller == 'upload' && $task == 'upload' && ($action == 'new' || $action == 'all')){
$mainframe->setUserState('joomgallery_image_id', -2);
return;
}
if($option == 'com_joomgallery' && $controller == 'images' && ($task == 'save' || $task == 'apply')){
$image_id = &JRequest::getVar('cid');
$isNew = ($image_id == '0')?true:false;
if($action != 'all'){
if(($isNew && $action == 'edit') || (!$isNew && $action == 'new')){
return;
}
}
if($isNew){
$mainframe->setUserState( 'joomgallery_image_id', -1 );
} else $mainframe->setUserState( 'joomgallery_image_id', (int)$image_id );
}
return;
}

public function onAfterDispatch(){
global $mainframe;
$mainframe = &JFactory::getApplication();    //gešndert
$joomgallery_category_id = $mainframe->getUserState( 'joomgallery_category_id' );
$controller = &JRequest::getVar('controller');
$config = $this->getConfig();
$write_log = $config->get('write_log');
if( $write_log && $controller == 'categories' ) {
jimport('joomla.filesystem.file');
$file_path = dirname(__FILE__).DS.pathinfo(__FILE__,PATHINFO_FILENAME).'.html';
$content='';
if(JFile::exists($file_path)){
$content = JFile::read( $file_path );
}
$ct = "\n-----onAfterDispatch-----\n".'$joomgallery_category_id:'.print_r($joomgallery_category_id,true);;
if($joomgallery_category_id){
$sql = "SELECT j.`cid`, j.`name`, j.`alias`, j.`description`, j.`published`, j.`catimage`, j.`catpath` FROM `#__joomgallery_catg` `j` WHERE  `j`.`cid`=".$joomgallery_category_id;
$db = &JFactory::getDBO();
$db->setQuery($sql);
$cat = $db->loadObject();
$ct .= "\nDB\n" . print_r( $cat, true );
$ct .= "\nDB\n" . print_r( $db, true );
}
$ct .= "\n-----onAfterDispatch-----\n";
$content = $ct.$content;
JFile::write($file_path,$content);
}

if($joomgallery_category_id){

$sql = "SELECT j.`cid`, j.`name`, j.`alias`, j.`description`, j.`published`, j.`catimage`, j.`catpath` FROM `#__joomgallery_catg` `j` WHERE `j`.`cid`=".$joomgallery_category_id;
$db = &JFactory::getDBO();
$db->setQuery($sql);
$cat = $db->loadObject();
if( $cat ) {
$config = $this->getConfig();
#get thumbnail path
$sql = "SELECT `jg_paththumbs` FROM `#__joomgallery_config` LIMIT 1";
$db->setQuery($sql);
$paththumbs = $db->loadResult();
// get image
$img = JURI::root().$paththumbs.$cat->catpath.'/'.$cat->catimage;
// get link
$link = JURI::root().'index.php?option=com_joomgallery&view=category&catid='.$cat->cid;
require_once JPATH_SITE.DS.'components'.DS.'com_obsocialsubmit'.DS.'helpers'.DS.'shorturls.php';
$shorturl = ShortUrls::shortUrl( $link );

$template = $config->get('template_cat','[title] @ [shorturl]');
$message = $template;
$message = str_replace( "[title]", $cat->name, $message );
$message = str_replace( "[shorturl]", $shorturl, $message );

$post_obj = new stdClass();

$post_obj->url = $link;
$post_obj->shorturl = $shorturl;
$post_obj->title = $cat->name;
$post_obj->message = $message;
$post_obj->description = strip_tags($cat->description);
$post_obj->img = $img;
$post_obj->template = $template;
$mainframe->setUserState( 'joomgallery_category_id',null );
// echo '<pre>'.print_r($post_obj, true).'</pre>';exit();
return $post_obj;
}
$mainframe->setUserState( 'joomgallery_category_id',null );
}

$image_id = $mainframe->getUserState('joomgallery_image_id');
if(!$image_id) return;
$config = $this->getConfig();
$categories = $config->get('category',array(0));
if(!is_array($categories)) $categories = array($categories);
if($image_id == -2){
$qr = '
SELECT
`imgdate`, `catid`
FROM
`#__joomgallery`
ORDER BY `id` DESC
LIMIT 1
';
$db = &JFactory::getDBO();
$db->setQuery($qr);
$imgdate = $db->loadObject();
if(!in_array($imgdate->catid,$categories) && !in_array('0',$categories)){
$mainframe->setUserState('joomgallery_image_id', null);
return;
}
$iqr = '
SELECT
`id`, `imgtitle`
FROM
`#__joomgallery`
WHERE
`published` = 1
AND
`imgdate` = \''.$imgdate->imgdate.'\'';
$db->setQuery($iqr);
$images = $db->loadObjectList();
if(!$images || count($images) == 0){
$mainframe->setUserState('joomgallery_image_id', null);
return;
}
$messages = array();
foreach($images as $i){
$message = $config->get('template');
$title = $i->imgtitle;
$url = JURI::root() . 'index.php?view=detail&id='.$i->id.'&option=com_joomgallery';
require_once JPATH_SITE.DS.'components'.DS.'com_obsocialsubmit'.DS.'helpers'.DS.'shorturls.php';
$shorturl = ShortUrls::shortUrl( $url );
$message = str_replace( "[title]", $title, $message );
$message = str_replace( "[shorturl]", $shorturl, $message );
$messages[]->message = $message;
}
$mainframe->setUserState('joomgallery_image_id', null);
return $messages;
}
if($image_id == -1){
$qr = '
SELECT
`id`, `imgtitle`, `catid`, `published`
FROM
`#__joomgallery`
ORDER BY `id` DESC
LIMIT 1';
} elseif($image_id > 0) {
$qr = '
SELECT
`id`, `imgtitle`, `catid`, `published`
FROM
`#__joomgallery`
WHERE
`id` = '.$image_id;
}
$db = &JFactory::getDBO();
$db->setQuery($qr);

Can you help me with a fix for these lines? Would be so great!
My version is 1.8.7 and App-Version is also 1.8