?>
</td>
		<td><input type="text" size="40" name="album"
			value="<?php 
echo $albumname;
?>
" /></td>
	</tr>
	<tr>
		<td><?php 
echo gettext("Create in:");
?>
</td>
		<td><select id="albumselectmenu" name="albumselect">
		<?php 
if (isMyAlbum('/', UPLOAD_RIGHTS)) {
    ?>
			<option value="" selected="SELECTED" style="font-weight: bold;">/</option>
			<?php 
}
$bglevels = array('#fff', '#f8f8f8', '#efefef', '#e8e8e8', '#dfdfdf', '#d8d8d8', '#cfcfcf', '#c8c8c8');
foreach ($albumlist as $fullfolder => $albumtitle) {
    $singlefolder = $fullfolder;
    $saprefix = "";
    $salevel = 0;
    // Get rid of the slashes in the subalbum, while also making a subalbum prefix for the menu.
    while (strstr($singlefolder, '/') !== false) {
        $singlefolder = substr(strstr($singlefolder, '/'), 1);
        $saprefix = "&nbsp; &nbsp;&raquo;&nbsp;" . $saprefix;
        $salevel++;
    }
Example #2
0
/**
 * Returns a list of album IDs that the current viewer is allowed to see
 *
 * @return array
 */
function getNotViewableAlbums()
{
    if (zp_loggedin(ADMIN_RIGHTS | ALL_ALBUMS_RIGHTS)) {
        return array();
    }
    //admins can see all
    $hint = '';
    global $_zp_not_viewable_album_list;
    if (is_null($_zp_not_viewable_album_list)) {
        $sql = 'SELECT `folder`, `id`, `password`, `show` FROM ' . prefix('albums') . ' WHERE `show`=0 OR `password`!=""';
        $result = query_full_array($sql);
        if (is_array($result)) {
            $_zp_not_viewable_album_list = array();
            foreach ($result as $row) {
                if (!checkAlbumPassword($row['folder'], $hint)) {
                    $_zp_not_viewable_album_list[] = $row['id'];
                } else {
                    if (!($row['show'] || isMyAlbum($row['folder'], ALL_RIGHTS))) {
                        $_zp_not_viewable_album_list[] = $row['id'];
                    }
                }
            }
        }
    }
    return $_zp_not_viewable_album_list;
}
zenSortablesHeader($_zp_sortable_list, 'images', 'imageOrder', 'img', "placeholder:'zensortable_img'");
echo "\n</head>";
?>


<body>

<?php 
// Create our gallery
$gallery = new Gallery();
// Create our album
if (!isset($_GET['album'])) {
    die(gettext("No album provided to sort."));
} else {
    $folder = strip($_GET['album']);
    if (!isMyAlbum($folder, EDIT_RIGHTS)) {
        die(gettext("You do not have rights to sort this album"));
    }
    $album = new Album($gallery, $folder);
    if (isset($_GET['saved'])) {
        $album->setSortType("manual");
        $album->setSortDirection('image', 0);
        $album->save();
    }
    // Layout the page
    printLogoAndLinks();
    ?>

<div id="main"><?php 
    printTabs('edit');
    ?>
	<?php 
        if ($subtab == 'theme' && $_zp_loggedin & (ADMIN_RIGHTS | THEMES_RIGHTS)) {
            ?>
	<div id="tab_theme" class="box" style="padding: 15px;">
	<?php 
            $themelist = array();
            if ($_zp_loggedin & ADMIN_RIGHTS) {
                $gallery_title = get_language_string(getOption('gallery_title'));
                if ($gallery_title != gettext("Gallery")) {
                    $gallery_title .= ' (' . gettext("Gallery") . ')';
                }
                $themelist[$gallery_title] = '';
            }
            $albums = $gallery->getAlbums(0);
            foreach ($albums as $alb) {
                if (isMyAlbum($alb, THEMES_RIGHTS)) {
                    $album = new Album($gallery, $alb);
                    $theme = $album->getAlbumTheme();
                    if (!empty($theme)) {
                        $key = $album->getTitle();
                        if ($key != $alb) {
                            $key .= " ({$alb})";
                        }
                        $themelist[$key] = urlencode($alb);
                    }
                }
            }
            if (!empty($_REQUEST['themealbum'])) {
                $alb = urldecode(sanitize_path($_REQUEST['themealbum']));
                $album = new Album($gallery, $alb);
                $albumtitle = $album->getTitle();
 /**
  * sortImageArray will sort an array of Images based on the given key. The
  * key must be one of (filename, title, sort_order) at the moment.
  *
  * @param array $images The array of filenames to be sorted.
  * @param  string $sorttype optional sort type
  * @param  string $sortdirection optional sort direction
  * @return array
  */
 function sortImageArray($images, $sorttype = NULL, $sortdirection = NULL)
 {
     $mine = isMyAlbum($this->name, ALL_RIGHTS);
     $key = $this->getSortKey($sorttype);
     $direction = '';
     if ($key != '`sort_order`') {
         // manual sort is always ascending
         if (!is_null($sortdirection)) {
             $direction = ' ' . $sortdirection;
         } else {
             if ($this->getSortDirection('image')) {
                 $direction = ' DESC';
             }
         }
     }
     $result = query($sql = "SELECT `filename`, `title`, `sort_order`, `title`, `show`, `id` FROM " . prefix("images") . " WHERE `albumid`= '" . $this->id . "' ORDER BY " . $key . $direction);
     $loop = 0;
     do {
         $hidden = array();
         $results = array();
         while ($row = mysql_fetch_assoc($result)) {
             $results[] = $row;
         }
         if ($key == 'title') {
             $results = sortByMultilingual($results, 'title', $direction == ' DESC');
         } else {
             if ($key == 'filename') {
                 if ($direction == 'DESC') {
                     $order = 'dsc';
                 } else {
                     $order = 'asc';
                 }
                 $results = sortMultiArray($results, 'filename', $order, true, false);
             }
         }
         $i = 0;
         $flippedimages = array_flip($images);
         $images_to_keys = array();
         $images_in_db = array();
         $images_invisible = array();
         foreach ($results as $row) {
             // see what images are in the database so we can check for visible
             $filename = $row['filename'];
             if (isset($flippedimages[$filename])) {
                 // ignore db entries for images that no longer exist.
                 if ($row['show'] || $mine) {
                     // unpublished content available only to someone with rights on the album
                     $images_to_keys[$filename] = $i;
                     $i++;
                 }
                 $images_in_db[] = $filename;
             } else {
                 $id = $row['id'];
                 query("DELETE FROM " . prefix('images') . " WHERE `id`={$id}");
                 // delete the record
                 query("DELETE FROM " . prefix('comments') . " WHERE `type` IN (" . zp_image_types("'") . ") AND `ownerid`= '{$id}'");
                 // remove image comments
             }
         }
         // Place the images not yet in the database before those with sort columns.
         // This is consistent with the sort oder of a NULL sort_order key in manual sorts
         // but will almost certainly be wrong in all other cases.
         $images_not_in_db = array_diff($images, $images_in_db);
         if (count($images_not_in_db) > 0) {
             $loop++;
             foreach ($images_not_in_db as $filename) {
                 $imgobj = newImage($this, $filename);
                 // force it into the database
                 $images_to_keys[$filename] = $i;
                 $i++;
             }
         } else {
             $loop = 0;
         }
     } while ($loop == 1);
     $images = array_flip($images_to_keys);
     ksort($images);
     $images_ordered = array();
     foreach ($images as $image) {
         $images_ordered[] = $image;
     }
     return $images_ordered;
 }
Example #6
0
        }
        if (isset($_GET['counters_reset'])) {
            echo '<div class="messagebox" id="fade-message">';
            echo "<h2>" . gettext("Hitcounters have been reset.") . "</h2>";
            echo '</div>';
        }
        if (isset($_GET['action']) && $_GET['action'] == 'clear_cache') {
            echo '<div class="messagebox" id="fade-message">';
            echo "<h2>" . gettext("Cache has been purged.") . "</h2>";
            echo '</div>';
        }
        $albumsprime = $gallery->getAlbums();
        $albums = array();
        foreach ($albumsprime as $album) {
            // check for rights
            if (isMyAlbum($album, EDIT_RIGHTS)) {
                $albums[] = $album;
            }
        }
        ?>
<p><?php 
        if (count($albums) > 0) {
            if ($_zp_loggedin & ADMIN_RIGHTS && count($albums) > 1) {
                $sorttype = strtolower(getOption('gallery_sorttype'));
                if ($sorttype != 'manual') {
                    if (getOption('gallery_sortdirection')) {
                        $dir = gettext(' descending');
                    } else {
                        $dir = '';
                    }
                    $sortNames = array_flip($sortby);
/**
 * Prints the clickable drop down toolbox on any theme page with generic admin helpers
 * @param string $id the html/css theming id
 */
function printAdminToolbox($id = 'admin')
{
    global $_zp_current_album, $_zp_current_image, $_zp_current_search, $_zp_loggedin, $_zp_gallery_page;
    if (zp_loggedin()) {
        echo '<script type="text/javascript" src="' . WEBPATH . '/' . ZENFOLDER . '/js/admin.js"></script>';
        $zf = WEBPATH . "/" . ZENFOLDER;
        $dataid = $id . '_data';
        $page = getCurrentPage();
        $redirect = '';
        echo '<div id="' . $id . '">' . "\n" . '<h3><a href="javascript: toggle(' . "'" . $dataid . "'" . ');">' . gettext('Admin Toolbox') . '</a></h3>' . "\n" . "\n</div>";
        echo '<div id="' . $dataid . '" style="display: none;">' . "\n";
        // open the list--all links go between here and the close of the list below
        echo "<ul style='list-style-type: none;'>";
        // generic link to Admin.php
        echo "<li>";
        printAdminLink(gettext('Admin'), '', "</li>\n");
        // setup for return links
        if (isset($_GET['p'])) {
            $redirect = "&amp;p=" . $_GET['p'];
        }
        if ($page > 1) {
            $redirect .= "&amp;page={$page}";
        }
        if ($_zp_loggedin & (ADMIN_RIGHTS | OPTIONS_RIGHTS)) {
            // options link for all admins with options rights
            echo "<li>";
            printLink($zf . '/admin-options.php', gettext("Options"), NULL, NULL, NULL);
            echo "</li>\n";
        }
        apply_filter('admin_toolbox_global');
        $gal = getOption('custom_index_page');
        if (empty($gal) || !file_exists(SERVERPATH . '/' . THEMEFOLDER . '/' . getOption('current_theme') . '/' . UTF8ToFilesystem($gal) . '.php')) {
            $gal = 'index.php';
        } else {
            $gal .= '.php';
        }
        if ($_zp_gallery_page === $gal) {
            // script is either index.php or the gallery index page
            if ($_zp_loggedin & (ADMIN_RIGHTS | EDIT_RIGHTS)) {
                // admin has edit rights so he can sort the gallery (at least those albums he is assigned)
                echo "<li>";
                printSortableGalleryLink(gettext('Sort gallery'), gettext('Manual sorting'));
                echo "</li>\n";
            }
            if ($_zp_loggedin & (ADMIN_RIGHTS | UPLOAD_RIGHTS)) {
                // admin has upload rights, provide an upload link for a new album
                echo "<li>";
                printLink($zf . '/admin-upload.php', gettext("New album"), NULL, NULL, NULL);
                echo "</li>\n";
            }
            apply_filter('admin_toolbox_gallery');
        } else {
            if ($_zp_gallery_page === 'album.php') {
                // script is album.php
                $albumname = $_zp_current_album->name;
                if (isMyAlbum($albumname, EDIT_RIGHTS)) {
                    // admin is empowered to edit this album--show an edit link
                    echo "<li>";
                    printSubalbumAdmin(gettext('Edit album'), '', "</li>\n");
                    if (!$_zp_current_album->isDynamic()) {
                        echo "<li>";
                        printSortableAlbumLink(gettext('Sort album'), gettext('Manual sorting'));
                        echo "</li>\n";
                    }
                    // and a delete link
                    echo "<li><a href=\"javascript: confirmDeleteAlbum('" . $zf . "/admin-edit.php?page=edit&amp;action=deletealbum&amp;album=" . urlencode(urlencode($albumname)) . "','" . js_encode(gettext("Are you sure you want to delete this entire album?")) . "','" . js_encode(gettext("Are you Absolutely Positively sure you want to delete the album? THIS CANNOT BE UNDONE!")) . "');\" title=\"" . gettext("Delete the album") . "\">" . gettext("Delete album") . "</a></li>\n";
                }
                if (isMyAlbum($albumname, UPLOAD_RIGHTS) && !$_zp_current_album->isDynamic()) {
                    // provide an album upload link if the admin has upload rights for this album and it is not a dynamic album
                    echo "<li>";
                    printLink($zf . '/admin-upload.php?album=' . urlencode($albumname), gettext("Upload Here"), NULL, NULL, NULL);
                    echo "</li>\n";
                    echo "<li>";
                    printLink($zf . '/admin-upload.php?new&album=' . urlencode($albumname), gettext("New Album Here"), NULL, NULL, NULL);
                    echo "</li>\n";
                }
                // set the return to this album/page
                apply_filter('admin_toolbox_album');
                $redirect = "&amp;album=" . urlencode($albumname) . "&amp;page={$page}";
            } else {
                if ($_zp_gallery_page === 'image.php') {
                    // script is image.php
                    $albumname = $_zp_current_album->name;
                    $imagename = urlencode($_zp_current_image->filename);
                    if (isMyAlbum($albumname, EDIT_RIGHTS)) {
                        // if admin has edit rights on this album, provide a delete link for the image.
                        echo "<li><a href=\"javascript: confirmDeleteImage('" . $zf . "/admin-edit.php?page=edit&amp;action=deleteimage&amp;album=" . urlencode(urlencode($albumname)) . "&amp;image=" . urlencode($imagename) . "','" . js_encode(gettext("Are you sure you want to delete the image? THIS CANNOT BE UNDONE!")) . "');\" title=\"" . gettext("Delete the image") . "\">" . gettext("Delete image") . "</a>";
                        echo "</li>\n";
                        echo '<li><a href="' . $zf . '/admin-edit.php?page=edit&amp;album=' . urlencode($albumname) . '&amp;image=' . urlencode($imagename) . '&amp;tab=imageinfo#IT" title="' . gettext('Edit this image') . '">' . gettext('Edit image') . '</a></li>' . "\n";
                    }
                    // set return to this image page
                    apply_filter('admin_toolbox_image');
                    $redirect = "&amp;album=" . urlencode($albumname) . "&amp;image={$imagename}";
                } else {
                    if ($_zp_gallery_page === 'search.php' && !empty($_zp_current_search->words)) {
                        // script is search.php with a search string
                        if ($_zp_loggedin & (ADMIN_RIGHTS | UPLOAD_RIGHTS)) {
                            // if admin has edit rights allow him to create a dynamic album from the search
                            echo "<li><a href=\"" . $zf . "/admin-dynamic-album.php\" title=\"" . gettext("Create an album from the search") . "\">" . gettext("Create Album") . "</a></li>";
                        }
                        apply_filter('admin_toolbox_search');
                        $redirect = "&amp;p=search" . $_zp_current_search->getSearchParams() . "&amp;page={$page}";
                    }
                }
            }
        }
        // zenpage script pages
        if (function_exists('is_NewsArticle')) {
            if ($_zp_loggedin & (ADMIN_RIGHTS | ZENPAGE_RIGHTS)) {
                // admin has zenpage rights, provide link to the zenpage admin tab
                echo "<li><a href=\"" . $zf . "/plugins/zenpage/\">" . gettext("Zenpage") . "</a></li>";
                if (is_NewsArticle()) {
                    // page is a NewsArticle--provide zenpage edit, delete, and Add links
                    echo "<li><a href=\"" . $zf . "/plugins/zenpage/admin-edit.php?newsarticle&amp;edit&amp;titlelink=" . urlencode(getNewsTitlelink()) . "\">" . gettext("Edit Article") . "</li>";
                    ?>
 
					<li><a href="javascript: confirmDeleteImage('<?php 
                    echo $zf;
                    ?>
/plugins/zenpage/news-article-admin.php?del=<?php 
                    echo getNewsID();
                    ?>
','<?php 
                    echo js_encode(gettext("Are you sure you want to delete this article? THIS CANNOT BE UNDONE!"));
                    ?>
')" title="<?php 
                    echo gettext("Delete article");
                    ?>
"><?php 
                    echo gettext("Delete Article");
                    ?>
</a></li>
					<?php 
                    echo "<li><a href=\"" . $zf . "/plugins/zenpage/admin-edit.php?newsarticle&amp;add\">" . gettext("Add Article") . "</li>";
                }
                if (is_Pages()) {
                    // page is zenpage page--provide edit, delete, and add links
                    echo "<li><a href=\"" . $zf . "/plugins/zenpage/admin-edit.php?page&amp;edit&amp;titlelink=" . urlencode(getPageTitlelink()) . "\">" . gettext("Edit Page") . "</li>";
                    ?>
 
					<li><a href="javascript: confirmDeleteImage('<?php 
                    echo $zf;
                    ?>
/plugins/zenpage/page-admin.php?del=<?php 
                    echo getPageID();
                    ?>
','<?php 
                    echo js_encode(gettext("Are you sure you want to delete this page? THIS CANNOT BE UNDONE!"));
                    ?>
')" title="<?php 
                    echo gettext("Delete page");
                    ?>
"><?php 
                    echo gettext("Delete Page");
                    ?>
</a></li>
					<?php 
                    echo "<li><a href=\"" . FULLWEBPATH . "/" . ZENFOLDER . "/plugins/zenpage/admin-edit.php?page&amp;add\">" . gettext("Add Page") . "</li>";
                }
            }
            apply_filter('admin_toolbox_news');
        }
        // logout link
        echo "<li><a href=\"" . $zf . "/admin.php?logout{$redirect}\">" . gettext("Logout") . "</a></li>\n";
        // close the list
        echo "</ul>\n";
        echo "</div>\n";
    }
}
function genAlbumUploadList(&$list, $curAlbum = NULL)
{
    global $gallery;
    $albums = array();
    if (is_null($curAlbum)) {
        $albumsprime = $gallery->getAlbums(0);
        foreach ($albumsprime as $album) {
            // check for rights
            if (isMyAlbum($album, UPLOAD_RIGHTS)) {
                $albums[] = $album;
            }
        }
    } else {
        $albums = $curAlbum->getSubAlbums(0);
    }
    if (is_array($albums)) {
        foreach ($albums as $folder) {
            $album = new Album($gallery, $folder);
            if (!$album->isDynamic()) {
                $list[$album->getFolder()] = $album->getTitle();
                genAlbumUploadList($list, $album);
                /* generate for subalbums */
            }
        }
    }
}