ZenphotoCMS Forum
Deleting album via plugin - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: Plugins (https://forum.zenphoto.org/forum-6.html)
+--- Thread: Deleting album via plugin (/thread-10945.html)



Deleting album via plugin - jphilbert - 25-03-2013

After some debugging I am having a issue with this lightroom plugin when it comes to deleting a album that I am not able to over come.

Security LOG:


2013-03-24 19:45:33 96.26.68.117 Album access admin Blocked /zp-core/admin-edit.php?page=edit&action=deletealbum&album=album-other&return=.&XSRFToken=7dfa49081ea171e9313ddd1de65d022e32a2c01d
2013-03-24 19:45:34 96.26.68.117 Album access admin Blocked /zp-core/admin-edit.php?page=edit
.&ndeleted=3

Delete code


--current old code
function deleteAlbum($args) {

if (is_object($login_state = authorize($args))) return $login_state;

$args = decode64($args);

if (!($album = getAlbumForAlbumID($args['id'])))
    return new IXR_Error(-1, 'No folder with database ID '.$args['id'].' found!');

$album->deleteAlbum();

}
/**
code I am testing trying to see what works best..
function deleteAlbum($args) {
global $_zp_current_album;
if (is_object($login_state = authorize($args))) return $login_state;

$args = decode64($args);
$album = getAlbumForAlbumID($args['id']);

// log($album);
debugLog($album);
debugLog("deleteAlbum");

if ($album)
    $album->remove();
else
    return new IXR_Error(-1, 'Folder not found on server '.$args['id'].' found!');

}
**/

Other thing

I moved core XMLRPC part of the plugin to the "plugins" folder because to me this is the proper place to have it run from but it seems that it may need to be moved back to the zp-core..(the orginal developer did) I would like to avoid this if at all possible

HEADER it loads


$dir = str_replace('\', '/', realpath(dirname(FILE)));
define('SERVERPATH', strstr($dir, '/plugins/zp-lightroom', true));

require_once(SERVERPATH . '/zp-core/functions.php');
include_once(SERVERPATH . '/zp-core/template-functions.php');
require_once(SERVERPATH . '/zp-core/lib-auth.php');
include_once(SERVERPATH . '/plugins/zp-lightroom/IXR_Library.inc.php');

code if you want to look on github
https://github.com/philbertphotos/Zenphoto-Lightroom-Publisher/tree/master/zp-lightroom


any insight or help is GREATLY appreciated.




Deleting album via plugin - jphilbert - 25-03-2013

I figured it out .. the thing about taking over someones code is cleaning up some of their mistakes and trying to figure out their mind set on what direction they were going.


function deleteAlbum($args) {

if (is_object($login_state = authorize($args))) return $login_state;

$args = decode64($args);
$album = getAlbumForAlbumID($args['id']);
if ($album)
$album->remove();
else
    return new IXR_Error(-1, 'No folder with database ID '.$args['id'].' found!');

}

but if you see anything I can do or approve on .. dont hesitate