[0] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Dotclear 2. |
---|
| 5 | # |
---|
| 6 | # Copyright (c) 2003-2010 Olivier Meunier & Association Dotclear |
---|
| 7 | # Licensed under the GPL version 2.0 license. |
---|
| 8 | # See LICENSE file or |
---|
| 9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
| 10 | # |
---|
| 11 | # -- END LICENSE BLOCK ----------------------------------------- |
---|
| 12 | |
---|
| 13 | require dirname(__FILE__).'/../inc/admin/prepend.php'; |
---|
| 14 | |
---|
| 15 | dcPage::checkSuper(); |
---|
| 16 | |
---|
| 17 | $q = !empty($_GET['q']) ? $_GET['q'] : ''; |
---|
| 18 | |
---|
| 19 | # Check users |
---|
| 20 | if (!empty($_REQUEST['user_id']) && is_array($_REQUEST['user_id'])) |
---|
| 21 | { |
---|
| 22 | foreach ($_REQUEST['user_id'] as $u) |
---|
| 23 | { |
---|
| 24 | if ($core->userExists($u)) { |
---|
| 25 | $users[] = $u; |
---|
| 26 | } |
---|
| 27 | } |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | if (empty($users)) |
---|
| 31 | { |
---|
| 32 | $core->error->add(__('No blog or user given.')); |
---|
| 33 | } |
---|
| 34 | else |
---|
| 35 | { |
---|
[520] | 36 | $blogs_list = new adminBlogPermissionsList($core); |
---|
[0] | 37 | |
---|
[520] | 38 | $params = new ArrayObject(); |
---|
| 39 | |
---|
| 40 | # - Limit, sortby and order filter |
---|
| 41 | $params = $blogs_list->applyFilters($params); |
---|
[0] | 42 | |
---|
| 43 | $show_filters = false; |
---|
| 44 | |
---|
| 45 | # - Search filter |
---|
| 46 | if ($q) { |
---|
| 47 | $params['q'] = $q; |
---|
| 48 | $show_filters = true; |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | try { |
---|
| 52 | $rs = $core->getBlogs($params); |
---|
| 53 | $counter = $core->getBlogs($params,1); |
---|
[520] | 54 | $blogs_list->setItems($rs,$counter->f(0)); |
---|
[0] | 55 | } catch (Exception $e) { |
---|
| 56 | $core->error->add($e->getMessage()); |
---|
| 57 | } |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | /* DISPLAY |
---|
| 61 | -------------------------------------------------------- */ |
---|
| 62 | $starting_script = dcPage::jsLoad('js/_permissions_blog.js'); |
---|
| 63 | if (!$show_filters) { |
---|
| 64 | $starting_script .= dcPage::jsLoad('js/filter-controls.js'); |
---|
| 65 | } |
---|
| 66 | dcPage::open(__('choose a blog'),$starting_script); |
---|
| 67 | |
---|
| 68 | echo '<h2><a href="users.php">'.__('Users').'</a> › '.__('Choose a blog').'</h2>'; |
---|
| 69 | |
---|
| 70 | if (!$core->error->flag()) |
---|
| 71 | { |
---|
| 72 | $hidden_fields = ''; |
---|
| 73 | foreach ($users as $u) { |
---|
| 74 | $hidden_fields .= form::hidden(array('user_id[]'),$u); |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | if (!$show_filters) { |
---|
| 78 | echo '<p><a id="filter-control" class="form-control" href="#">'.__('Filters').'</a></p>'; |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | echo |
---|
| 82 | '<form action="permissions_blog.php" method="get" id="filters-form">'. |
---|
| 83 | '<fieldset class="two-cols"><legend>'.__('Filters').'</legend>'. |
---|
| 84 | |
---|
[68] | 85 | '<p><label for="q">'.__('Search:').' '. |
---|
[0] | 86 | form::field('q',20,255,html::escapeHTML($q)). |
---|
| 87 | '</label></p>'. |
---|
[520] | 88 | '<p><input type="submit" value="'.__('Apply filters').'" />'. |
---|
[0] | 89 | $hidden_fields.'</p>'. |
---|
| 90 | |
---|
| 91 | '<br class="clear" />'. //Opera sucks |
---|
| 92 | '</fieldset>'. |
---|
| 93 | '</form>'; |
---|
| 94 | |
---|
| 95 | echo |
---|
| 96 | '<p>'. |
---|
| 97 | sprintf(__('Choose one or more blogs to which you want to give permissions to users %s.'), |
---|
| 98 | '<strong>'.implode(', ',$users).'</strong>').'</p>'; |
---|
| 99 | |
---|
| 100 | # Show blogs |
---|
[520] | 101 | $blogs_list->display('<form action="permissions.php" method="post" id="form-blogs">'. |
---|
[456] | 102 | '%s'. |
---|
[0] | 103 | '<p class="checkboxes-helpers"></p>'. |
---|
| 104 | '<p><input type="submit" value="'.__('set permissions').'" />'. |
---|
| 105 | $hidden_fields. |
---|
| 106 | $core->formNonce().'</p>'. |
---|
[456] | 107 | '</form>' |
---|
| 108 | ); |
---|
[0] | 109 | } |
---|
| 110 | |
---|
| 111 | dcPage::close(); |
---|
| 112 | |
---|
| 113 | ?> |
---|