block-random, etc

gary_d

Joined: 2004-11-19
Posts: 26
Posted: Tue, 2004-11-23 18:45

Being that block-random is now part of the gallery "distribution", please change the line in block-random.php which requires init.php to require_once():

- require(dirname(__FILE__) . "/init.php");
+ require_once(dirname(__FILE__) . "/init.php");

(This should solve problems with people calling block-random along with other 'stuff' that makes use of gallery at the same time. )

Thanks
Gary

 
gary_d

Joined: 2004-11-19
Posts: 26
Posted: Tue, 2004-11-23 19:21

On second thought... there MIGHT be an issue with this suggested change: block-random.php turns off sessions, and then requires init.php. If something ELSE (?) wants to require init.php but with sessions on - sessions.php will not get included..

(I don't know if this would be an issue in actual practice or not...)

 
signe
signe's picture

Joined: 2003-07-27
Posts: 2322
Posted: Tue, 2004-11-23 19:40

block-random is *required* to be included via http - if you include as a file, you will encounter issues with multiple definitions. There's no way around this - if block-random is set to require_once and included as a file, Gallery will fail.

 
gary_d

Joined: 2004-11-19
Posts: 26
Posted: Tue, 2004-11-23 21:20

From a Mambo module that uses block-random:

defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.'
 );

global $GALLERY_EMBEDDED_INSIDE;
global $GALLERY_EMBEDDED_INSIDE_TYPE;
global $GALLERY_MODULENAME;
global $include;
global $option;

$option = "com_gallery";          // Tells Gallery that we're inside Mambo
$include = "block-random.php";    // ... and that we want block-random.php.

$database->setQuery('SELECT `value` FROM #__gallery WHERE `field` = \'path\'');
define ('GALLERY_URL',$database->loadResult() );

$GALLERY_MODULENAME = $option;
$GALLERY_EMBEDDED_INSIDE = 'mambo';
$GALLERY_EMBEDDED_INSIDE_TYPE = 'mambo';

include(GALLERY_URL . "/$include");
?>

(I also did something similar when trying out drupal some time ago.)

As a software engineer (who had a bad day today) I can attest to the fact that any OTHER programmer will certainly use any library or source in EVERY POSSIBLE way that was never intented (and then complain when it doesn't work.) ;)