Changeset 726e265f078bf31aa4c2386546da1a2a27a05848
- 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:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r3846fb0
|
r726e265
|
|
| 345 | 345 | } |
| 346 | 346 | |
| | 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 | |
| 347 | 364 | function paginateMediaByCrumb($id, $crumbs) { |
| 348 | 365 | $tmp = $this->getParams(); |
-
|
re0d7c0e
|
r726e265
|
|
| 768 | 768 | */ |
| 769 | 769 | function updatemeta($id) { |
| 770 | | if (!$this->RequestHandler->isAjax() || !$this->RequestHandler->isPost()) { |
| | 770 | if (!$this->RequestHandler->isAjax()) { |
| 771 | 771 | Logger::warn("Decline wrong ajax request"); |
| 772 | 772 | $this->redirect(null, '404'); |
| … |
… |
|
| 781 | 781 | |
| 782 | 782 | function editacl($id) { |
| 783 | | if (!$this->RequestHandler->isAjax() || !$this->RequestHandler->isPost()) { |
| | 783 | if (!$this->RequestHandler->isAjax()) { |
| 784 | 784 | Logger::warn("Decline wrong ajax request"); |
| 785 | 785 | $this->redirect(null, '404'); |
| … |
… |
|
| 805 | 805 | |
| 806 | 806 | function saveacl($id) { |
| 807 | | if (!$this->RequestHandler->isAjax() || !$this->RequestHandler->isPost()) { |
| | 807 | if (!$this->RequestHandler->isAjax()) { |
| 808 | 808 | Logger::warn("Decline wrong ajax request"); |
| 809 | 809 | $this->redirect(null, '404'); |
| … |
… |
|
| 817 | 817 | $user = $this->getUser(); |
| 818 | 818 | $userId = $user['User']['id']; |
| | 819 | $this->Search->setUser($user['User']['username']); // Triggers acl descriptions |
| 819 | 820 | if (!$this->Media->checkAccess(&$media, &$user, 1, 0)) { |
| 820 | 821 | Logger::warn("User '{$user['User']['username']}' ({$user['User']['id']}) has no previleges to change ACL of image ".$id); |
| … |
… |
|
| 840 | 841 | $media['Media']['modified'] = null; |
| 841 | 842 | $this->Media->save($media['Media'], true, array('group_id', 'gacl', 'uacl', 'oacl')); |
| | 843 | Logger::info("Changed acl of media $id"); |
| 842 | 844 | } |
| 843 | 845 | } |
| 844 | 846 | $media = $this->Media->findById($id); |
| 845 | 847 | $this->Media->setAccessFlags(&$media, $this->getUser()); |
| 846 | | $this->set('data', $media); |
| | 848 | $this->data = $media; |
| 847 | 849 | $this->layout='bare'; |
| | 850 | $this->Search->setUser($user['User']['username']); |
| | 851 | $this->Search->setHelperData(); |
| | 852 | Configure::write('debug', 0); |
| 848 | 853 | $this->render('updatemeta'); |
| 849 | | Configure::write('debug', 0); |
| 850 | 854 | } |
| 851 | 855 | |
-
|
r163132b
|
r726e265
|
|
| | 1 | <?php $search->initialize(); ?> |
| 1 | 2 | <?php echo $this->element('explorer/date', array('media' => $media)); ?> |
| 2 | 3 | <?php if (count($media['Tag'])): ?> |
-
|
rafc40e0
|
r726e265
|
|
| 44 | 44 | array('escape' => false)); |
| 45 | 45 | } |
| | 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 | } |
| 46 | 52 | if ($media['Media']['canReadOriginal']) { |
| 47 | 53 | foreach ($media['File'] as $file) { |
-
|
r7f46ca8
|
r726e265
|
|
| 1 | 1 | <?php |
| 2 | 2 | $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)); |
| 4 | 4 | ?> |
| 5 | 5 | <fieldset> |
| … |
… |
|
| 12 | 12 | ?> |
| 13 | 13 | </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 | | ?> |
| 18 | 14 | </form> |
-
|
re0d7c0e
|
r726e265
|
|
| 32 | 32 | ':SAVE': function() { |
| 33 | 33 | 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); |
| 34 | 61 | $.post($form.attr('action'), $form.serialize(), function(data) { |
| 35 | 62 | $('#description-' + id).html(data); |
| … |
… |
|
| 118 | 145 | 'BASE_URL' => Router::url('/', true), |
| 119 | 146 | 'EDIT_TITLE' => __("Edit Meta Data", true), |
| | 147 | 'ACL_TITLE' => __("Edit Access Rights", true), |
| 120 | 148 | 'SAVE' => __("Update", true), |
| 121 | 149 | 'CANCEL' => __("Cancel", true)); |
-
|
r6f2d701
|
r726e265
|
|
| 36 | 36 | width: 224px |
| 37 | 37 | 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 |
| 38 | 50 | > img |
| 39 | 51 | margin-top: 12px |