Changeset 726e265f078bf31aa4c2386546da1a2a27a05848

Show
Ignore:
Timestamp:
09/25/11 14:06:57 (8 months ago)
Author:
Xemle <xemle@phtagr.org>
Children:
6962dbe2230051bb593a4854f784df11ad37c6ca
Parents:
e0d7c0e704e5bf97231c4c96a5d4f455b4c5e8ac
git-committer:
Xemle <xemle@phtagr.org> / 2011-09-25T14:06:57Z+0200
Message:

Edit single access right in explorer

Files:
7 modified

Legend:

Unmodified
Added
Removed
  • controllers/components/search.php

    r3846fb0 r726e265  
    345345  } 
    346346 
     347  /**  
     348    Sets the data for the search helper  
     349    */ 
     350  function setHelperData() { 
     351    $params = array( 
     352      'pageCount' => 0,  
     353      'current' => 0,  
     354      'nextPage' => false,  
     355      'prevPage' => false, 
     356      'baseUri' => $this->baseUri, 
     357      'afterUri' => false, 
     358      'defaults' => $this->defaults, 
     359      'data' => $this->getParams() 
     360      ); 
     361    $this->controller->params['search'] = $params; 
     362  } 
     363 
    347364  function paginateMediaByCrumb($id, $crumbs) { 
    348365    $tmp = $this->getParams(); 
  • controllers/explorer_controller.php

    re0d7c0e r726e265  
    768768   */ 
    769769  function updatemeta($id) { 
    770     if (!$this->RequestHandler->isAjax() || !$this->RequestHandler->isPost()) { 
     770    if (!$this->RequestHandler->isAjax()) { 
    771771      Logger::warn("Decline wrong ajax request"); 
    772772      $this->redirect(null, '404'); 
     
    781781 
    782782  function editacl($id) { 
    783     if (!$this->RequestHandler->isAjax() || !$this->RequestHandler->isPost()) { 
     783    if (!$this->RequestHandler->isAjax()) { 
    784784      Logger::warn("Decline wrong ajax request"); 
    785785      $this->redirect(null, '404'); 
     
    805805 
    806806  function saveacl($id) { 
    807     if (!$this->RequestHandler->isAjax() || !$this->RequestHandler->isPost()) { 
     807    if (!$this->RequestHandler->isAjax()) { 
    808808      Logger::warn("Decline wrong ajax request"); 
    809809      $this->redirect(null, '404'); 
     
    817817      $user = $this->getUser(); 
    818818      $userId = $user['User']['id']; 
     819      $this->Search->setUser($user['User']['username']); // Triggers acl descriptions 
    819820      if (!$this->Media->checkAccess(&$media, &$user, 1, 0)) { 
    820821        Logger::warn("User '{$user['User']['username']}' ({$user['User']['id']}) has no previleges to change ACL of image ".$id); 
     
    840841        $media['Media']['modified'] = null; 
    841842        $this->Media->save($media['Media'], true, array('group_id', 'gacl', 'uacl', 'oacl')); 
     843        Logger::info("Changed acl of media $id"); 
    842844      } 
    843845    } 
    844846    $media = $this->Media->findById($id); 
    845847    $this->Media->setAccessFlags(&$media, $this->getUser()); 
    846     $this->set('data', $media); 
     848    $this->data = $media; 
    847849    $this->layout='bare'; 
     850    $this->Search->setUser($user['User']['username']); 
     851    $this->Search->setHelperData(); 
     852    Configure::write('debug', 0); 
    848853    $this->render('updatemeta'); 
    849     Configure::write('debug', 0); 
    850854  } 
    851855 
  • views/elements/explorer/description.ctp

    r163132b r726e265  
     1<?php $search->initialize(); ?> 
    12<?php echo $this->element('explorer/date', array('media' => $media)); ?> 
    23<?php if (count($media['Tag'])): ?> 
  • views/elements/explorer/media.ctp

    rafc40e0 r726e265  
    4444      array('escape' => false)); 
    4545  } 
     46  if ($search->getUser() == $currentUser['User']['username'] && $media['Media']['canWriteAcl']) { 
     47    $keyIcon = $this->Html->image('icons/key.png', array('title' => __('Edit access rights', true), 'alt' => 'Edit ACL')); 
     48    echo $html->tag('li',  
     49      $html->link($keyIcon, 'javascript:void', array('escape' => false, 'class' => 'acl')), 
     50      array('escape' => false)); 
     51  } 
    4652  if ($media['Media']['canReadOriginal']) { 
    4753    foreach ($media['File'] as $file) { 
  • views/explorer/editacl.ctp

    r7f46ca8 r726e265  
    11<?php  
    22  $mediaId = $data['Media']['id']; 
    3   echo $ajax->form('saveacl/'.$mediaId, 'post', array('url' => '/explorer/saveacl/'.$mediaId, 'update' => 'meta-'.$mediaId));  
     3  echo $form->create(null, array('url' => 'saveacl/'.$mediaId, 'id' => 'form-acl-'.$mediaId)); 
    44?> 
    55<fieldset> 
     
    1212?> 
    1313</fieldset> 
    14 <?php 
    15   echo $form->submit(__('Save', true), array('div' => false));  
    16   echo $ajax->link(__('Cancel', true), '/explorer/updatemeta/'.$mediaId, array('update' => 'meta-'.$mediaId, 'class' => 'reset')); 
    17 ?> 
    1814</form> 
  • views/explorer/index.ctp

    re0d7c0e r726e265  
    3232                ':SAVE': function() { 
    3333                  var $form = $('#form-meta-' + id); 
     34                  $.post($form.attr('action'), $form.serialize(), function(data) { 
     35                    $('#description-' + id).html(data); 
     36                    $('#description-' + id).find('.tooltip-actions').tooltipAction(); 
     37                  }); 
     38                  $(this).dialog("close"); 
     39                }, 
     40                ':CANCEL': function() { 
     41                  $(this).dialog("close"); 
     42                } 
     43              } 
     44            }); 
     45          } 
     46        }); 
     47      }); 
     48      $(this).find('ul li .acl').click(function() { 
     49        var $dialog = $('#dialog'); 
     50        $.ajax(':BASE_URLexplorer/editacl/' + id, { 
     51          success: function(data, xhr, status) { 
     52            $dialog.children().remove(); 
     53            $dialog.append(data); 
     54            $dialog.dialog({ 
     55              modal: true,  
     56              width: 520, 
     57              title: ':ACL_TITLE', 
     58              buttons: { 
     59                ':SAVE': function() { 
     60                  var $form = $('#form-acl-' + id); 
    3461                  $.post($form.attr('action'), $form.serialize(), function(data) { 
    3562                    $('#description-' + id).html(data); 
     
    118145    'BASE_URL' => Router::url('/', true),  
    119146    'EDIT_TITLE' => __("Edit Meta Data", true), 
     147    'ACL_TITLE' => __("Edit Access Rights", true), 
    120148    'SAVE' => __("Update", true),  
    121149    'CANCEL' => __("Cancel", true)); 
  • webroot/css/default/_form.sass

    r6f2d701 r726e265  
    3636        width: 224px 
    3737        margin-top: 10px 
     38      select 
     39        +default-input 
     40        font-size: 12pt 
     41        margin-top: 10px 
     42        option 
     43          padding: 3px 0 
     44          font-size: 12pt 
     45          background-color: $clickable-default-bg 
     46          &.selected 
     47            background-color: $clickable-active-bg 
     48          &:hover 
     49            background-color: $clickable-hover-bg 
    3850      > img 
    3951        margin-top: 12px