<?php

defined('_VALID') or die('Restricted access ');
include_once('class.photoalbum.php');
$photogalleryObj = new photoalbum($configObj);
$action = $_REQUEST['action'];
$view = $_REQUEST['view'];
$configObj->glTplObj->set('mediaTab', true);
$photogalleryObj->intitialize($view);
$configObj->glTplObj->change_path($configObj->currentModulePath . 'html/templates/');
$configObj->glTplObj->set('configObj', $configObj);
$configObj->glTplObj->set('photogalleryObj', $photogalleryObj);

switch ($action) {
    case 'add':
        if ($_REQUEST['h_save'] == 'T') {
            $photogalleryObj->varpostdata = $_REQUEST;
            $photogalleryObj->insert_photo();
            $configObj->glLibraryObj->header_redirect('index.php?module=photoalbum&tname=' . $_REQUEST['tname'] . '&msg=add');
        } else {
            $photogalleryObj->pagename = 'index.php?module=photoalbum';
            $photogalleryObj->Generateurl();
            if ($_REQUEST['msg'] == 'add') {
                $messagebox = $photogalleryObj->configObj->glLibraryObj->message("Congrats! The record is successfully saved.");
                $photogalleryObj->configObj->glTplObj->set('messagebox', $messagebox);
            } else if ($_REQUEST['msg'] == 'edit') {
                $messagebox = $photogalleryObj->configObj->glLibraryObj->message("Congrats! The data has been successfully edited and saved.");
                $photogalleryObj->configObj->glTplObj->set('messagebox', $messagebox);
            }
            if ($modulename == 'activity' || $modulename == 'menu') {
                $configObj->adminContentPanel = $configObj->glTplObj->process('photoalbum_add.tpl.php');
            } else {
                $configObj->adminContentPanel = $configObj->glTplObj->process('photoalbum_add.tpl.php');
            }
        }
        break;

    case 'sharedata':

        if ($_REQUEST['h_save'] == 'T') {
            $photogalleryObj->varpostdata = $_REQUEST;
            echo $photogalleryObj->shareonfacebook();
        } else {
            echo $photogalleryObj->genrateshareOption();
        }
        exit;
        break;

    case 'edit':

        $photogalleryObj->pagename = 'index.php?module=photoalbum'; // Attribute of Page Name
        $photogalleryObj->Generateurl();
        if ($_REQUEST['h_save'] == 'T') {
            $photogalleryObj->varpostdata = $_REQUEST;

            if ($photogalleryObj->update_photos()) {
                $configObj->glLibraryObj->header_redirect('index.php?module=photoalbum&tname=' . $_REQUEST['tname'] . '&msg=edit');
            }
        }
        if ($_REQUEST['msg']) {
            if ($_REQUEST['msg'] == 'add') {
                $messagebox = $photogalleryObj->configObj->glLibraryObj->message("Congrats! The record has been successfully saved.");
                $photogalleryObj->configObj->glTplObj->set('messagebox', $messagebox);
            } else if ($_REQUEST['msg'] == 'edit') {
                $messagebox = $photogalleryObj->configObj->glLibraryObj->message("Congrats! The record has been successfully edited and saved.");
                $photogalleryObj->configObj->glTplObj->set('messagebox', $messagebox);
            }
        }
        $row = $photogalleryObj->select_photo($_REQUEST['eid']);
        $photogalleryObj->configObj->glTplObj->set('row', $row);
        $configObj->adminContentPanel = $configObj->glTplObj->process('photoalbum_add.tpl.php');
        break;

    case 'delete':
        if ($configObj->isAjaxSet) {

            $photogalleryObj->is_photoused();
        }
        break;
        
   case 'updatepublish':
        $id = $_REQUEST['id'];
        $configObj->glLibraryObj->updatefieldinmultiple();
        echo 1;
        exit;     

    default:
        $photogalleryObj->load_photogallery();
        break;
}
?>
