[ PHPXref.com ] [ Generated: Sun Jul 20 17:56:12 2008 ] [ Gallery 1.5.3 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/ -> album_permissions.php (source)

   1  <?php
   2  /*
   3   * Gallery - a web based photo album viewer and editor
   4   * Copyright (C) 2000-2006 Bharat Mediratta
   5   * 
   6   * This program is free software; you can redistribute it and/or modify
   7   * it under the terms of the GNU General Public License as published by
   8   * the Free Software Foundation; either version 2 of the License, or (at
   9   * your option) any later version.
  10   * 
  11   * This program is distributed in the hope that it will be useful, but
  12   * WITHOUT ANY WARRANTY; without even the implied warranty of
  13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14   * General Public License for more details.
  15   * 
  16   * You should have received a copy of the GNU General Public License
  17   * along with this program; if not, write to the Free Software
  18   * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.
  19   *
  20   * $Id: album_permissions.php,v 1.63.2.1 2006/03/27 15:31:24 jenst Exp $
  21   */
  22  ?>
  23  <?php
  24  
  25  require_once(dirname(__FILE__) . '/init.php');
  26  
  27  list($save, $ownerUid, $submit, $actionUid) =
  28      getRequestVar(array('save', 'ownerUid', 'submit', 'actionUid'));
  29  
  30  // Hack check
  31  if (!$gallery->user->isAdmin() && 
  32      !$gallery->user->isOwnerOfAlbum($gallery->album)) {
  33      echo _("You are not allowed to perform this action!");
  34      exit;
  35  }
  36  
  37  $perms = array(
  38      'canRead'           => _("Users who can see the album."),
  39      'canAddTo'          => _("Users who can add photos."),
  40      'canDeleteFrom'     => _("Users who can delete photos."),
  41      'canWrite'          => _("Users who can modify photos."),
  42      'canCreateSubAlbum' => _("Users who can create sub albums."),
  43      'zipDownload'       => _("Users who can to download album (with subalbums) as archive."),
  44      'canViewComments'   => _("Users who can view comments."),
  45      'canAddComments'    => _("Users who can add comments."),
  46      'canViewFullImages' => _("Users who can view full (original) images."),
  47      'canChangeText'     => _("Users who can change album text."),
  48  );
  49  
  50  foreach ($gallery->userDB->getUidList() as $uid) {
  51      $tmpUser = $gallery->userDB->getUserByUid($uid);
  52      $uname = $tmpUser->getUsername();
  53      if ($tmpUser->isPseudo()) {
  54          $uname = "*$uname*";
  55      }
  56      $uAll[$uid] = $uname;
  57  }
  58  
  59  asort($uAll);
  60  
  61  $changed = 0;
  62  if(empty($submit)) {
  63      $submit = array();
  64  }
  65  
  66  foreach ($submit as $perm => $action) {
  67      if(isset($action) && isset($actionUid)) {
  68          if($action == '-->') {
  69              $gallery->album->setPerm($perm, $actionUid, true);
  70              $changed++;
  71          }
  72          if($action == '<--') {
  73              $gallery->album->setPerm($perm, $actionUid, false);
  74              $changed++;
  75          }
  76      }
  77  }
  78  
  79  if (isset($save) && $ownerUid) {
  80      $gallery->album->setOwner($ownerUid);
  81      $changed++;
  82  }
  83  
  84  if ($changed) {
  85      $gallery->album->save(array(i18n("Permissions have been changed")));
  86      if (getRequestVar('setNested')) {
  87          $gallery->album->setNestedPermissions();
  88      }
  89  }
  90  
  91  // Start with a default owner of nobody -- if there is an
  92  // owner it'll get filled in below.
  93  $nobody = $gallery->userDB->getNobody();
  94  $ownerUid = $nobody->getUid();
  95  
  96  $owner = $gallery->album->getOwner();
  97  $ownerUid = $owner->getUid();
  98  
  99  // Set values for selectboxes
 100  foreach($perms as $perm => $trash)  {
 101      $uids[$perm] = $gallery->album->getPermUids($perm);
 102      asort($uids[$perm]);
 103      correctPseudoUsers($uids[$perm], $ownerUid);
 104  }
 105  
 106  doctype();
 107  ?>
 108  <html>
 109  <head>
 110    <title><?php echo _("Album Permissions") ?></title>
 111    <?php common_header(); ?>
 112  </head>
 113  <body dir="<?php echo $gallery->direction ?>" class="popupbody">
 114  <div class="popuphead"><?php echo _("Album Permissions") ?></div>
 115  <div class="popup" align="center">
 116  <?php echo sprintf(_("Changing permissions for %s"), '<b>'.$gallery->album->fields["title"] . '</b>');
 117  
 118  echo makeFormIntro("album_permissions.php", array("name" =>
 119              "albumperms_form"), array("type" => "popup"));
 120  
 121  if ($gallery->user->isAdmin) {
 122      echo _("Owner:") . drawSelect("ownerUid", $uAll, $ownerUid, 1, array(), true);
 123  }
 124  ?>
 125  
 126  <table border="0" cellspacing="0" cellpadding="0">
 127   <tr>
 128    <td align="center">
 129     <?php echo drawSelect('actionUid', $uAll, isset($allUid) ? $allUid : array(), 28, array(), true); ?>
 130    </td>
 131  
 132    <td>&nbsp;</td>
 133  
 134    <td style="vertical-align: top">
 135  <?php
 136  
 137  $permsTable = new galleryTable();
 138  $permsTable->setColumnCount(2);
 139  foreach($perms as $perm => $permDesc) {
 140      $permsTable->addElement(array('content' => $permDesc, 'cellArgs' => array('colspan' => 2)));
 141      $permsTable->addElement(
 142         array('content' => 
 143          "\n\t<input type=\"submit\" name=\"submit[$perm]\" value=\"-->\"><br>".
 144          "\n\t<input type=\"submit\" name=\"submit[$perm]\" value=\"<--\">"
 145      ));
 146      $permsTable->addElement(
 147      array('content' => drawSelect("actionUid", $uids[$perm], '', 3, array(), true))
 148      );
 149  }
 150  echo $permsTable->render();
 151  ?>    
 152    </td>
 153   </tr>
 154  </table>
 155  
 156  <label for="setNested"><?php echo _("Apply permissions to all sub-albums"); ?></label>
 157  <input type="checkbox" id="setNested" name="setNested" value="setNested" <?php if (getRequestVar('setNested')) echo 'CHECKED'; ?>>
 158  <br><br>
 159  <input type="submit" name="save" value="<?php echo _("Save") ?>">
 160  <input type="button" name="done" value="<?php echo _("Done") ?>" onclick='parent.close()'>
 161  </form>
 162  </div>
 163  <?php print gallery_validation_link("album_permissions.php"); ?>
 164  </body>
 165  </html>


[ Powered by PHPXref - Served by Debian GNU/Linux ]