Calling a module from another module?

jerryh

Joined: 2013-02-04
Posts: 27
Posted: Wed, 2013-02-20 22:56

I am fairly new to gallery. the framework looks nice.
I am looking for some guidance to call a separate module from a different module.
Would like to reuse the archiveupload in a new module I am writing. Some guidance and direction would be appreciated...

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Wed, 2013-02-20 23:03
GalleryCoreApi::requireOnce('modules/archiveupload/classes/ArchiveExtractToolkit.class');
list($ret, $mimeType, $context) = ArchiveExtractToolkit::performOperation($mimeType, $operationName, $sourceFilename, $destFilename, $parameters);
if($ret){
    return array($ret, null, null);
}

-s
________________________________
All New jQuery Minislideshow for G2/G3

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Wed, 2013-02-20 23:06

I created a cool little hack that would let anonymous users upload archives to album owners.
The album owner receives an email notifying them about the uploaded archive, and they could decide whether to process the archive into their album or refuse - deleting the archive.

-s
________________________________
All New jQuery Minislideshow for G2/G3

 
jerryh

Joined: 2013-02-04
Posts: 27
Posted: Wed, 2013-02-20 23:12

Nice... I like it....

So just this code... so do some tests and ensure archive file, then just this call and done.
I'll give it a try.

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Wed, 2013-02-20 23:20

Depending on scope, you may have to:

GalleryCoreApi::requireOnce('modules/archiveupload/classes/ArchiveExtractToolkit.class');
$toolkit = new ArchiveExtractToolkit();
list($ret, $mimeType, $context) = $toolkit->performOperation($mimeType, $operationName, $sourceFilename, $destFilename, $parameters);
if($ret){
    return array($ret, null, null);
}

-s
________________________________
All New jQuery Minislideshow for G2/G3

 
jerryh

Joined: 2013-02-04
Posts: 27
Posted: Wed, 2013-02-20 23:39

OK.. AS I am looking over the code, this will extract the files and return me a list of files. then I pass the list along to upload the individual items, right?

 
jerryh

Joined: 2013-02-04
Posts: 27
Posted: Thu, 2013-02-28 17:10

OK.. I've been playing with this code.... It looks like it goes through performOperation ok, but then I get http: Upload failed error after everything..Any thoughts?