aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-04-16 17:20:53 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-04-16 17:20:53 +0000
commit732207c9a17483d1a660f9b7cec81f531a0838e5 (patch)
treeafbf7f6205102350a33d3a6c6ba46fc36ca417a6
parent741808bdf03d09c3e5c2ac3865451fade409d892 (diff)
downloadelgg-732207c9a17483d1a660f9b7cec81f531a0838e5.tar.gz
elgg-732207c9a17483d1a660f9b7cec81f531a0838e5.tar.bz2
ECML permissions frontend presents a whitelist instead of a black list.
git-svn-id: http://code.elgg.org/elgg/trunk@5779 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--mod/ecml/actions/save_permissions.php23
-rw-r--r--mod/ecml/languages/en.php1
-rw-r--r--mod/ecml/views/default/ecml/admin/css.php3
-rw-r--r--mod/ecml/views/default/ecml/admin/ecml_admin.php27
4 files changed, 44 insertions, 10 deletions
diff --git a/mod/ecml/actions/save_permissions.php b/mod/ecml/actions/save_permissions.php
index 490a8928b..3aecd9585 100644
--- a/mod/ecml/actions/save_permissions.php
+++ b/mod/ecml/actions/save_permissions.php
@@ -9,7 +9,28 @@
* @link http://elgg.org/
*/
-$perms = get_input('perms', array());
+$whitelist = get_input('whitelist', array());
+$keywords = $CONFIG->ecml_keywords;
+$views = $CONFIG->ecml_parse_views;
+
+// the front end uses a white list but the backend uses a
+// blacklist for performance and extensibility.
+// gotta convert.
+$perms = array();
+
+foreach ($views as $view => $view_info) {
+ foreach ($keywords as $keyword => $keyword_info) {
+
+ // don't need to add perms for restricted keywords
+ // because those perms are checked separately
+ if (isset($keyword_info['restricted'])) {
+ continue;
+ }
+ if (!isset($whitelist[$view]) || !in_array($keyword, $whitelist[$view])) {
+ $perms[$view][] = $keyword;
+ }
+ }
+}
if (set_plugin_setting('ecml_permissions', serialize($perms), 'ecml')) {
system_message(elgg_echo('ecml:admin:permissions_saved'));
diff --git a/mod/ecml/languages/en.php b/mod/ecml/languages/en.php
index 2b9b9118b..505dbcf63 100644
--- a/mod/ecml/languages/en.php
+++ b/mod/ecml/languages/en.php
@@ -71,6 +71,7 @@ grid below.
'ecml:admin:permissions_saved' => 'ECML permissions saved.',
'ecml:admin:cannot_save_permissions' => 'Cannot save ECML permissions!',
+ 'ecml:admin:restricted' => 'Restricted',
);
diff --git a/mod/ecml/views/default/ecml/admin/css.php b/mod/ecml/views/default/ecml/admin/css.php
index 960941a03..1431074f0 100644
--- a/mod/ecml/views/default/ecml/admin/css.php
+++ b/mod/ecml/views/default/ecml/admin/css.php
@@ -14,4 +14,7 @@
}
.ecml_row_even {
+}
+.ecml_restricted {
+ color: #555;
} \ No newline at end of file
diff --git a/mod/ecml/views/default/ecml/admin/ecml_admin.php b/mod/ecml/views/default/ecml/admin/ecml_admin.php
index 0bd7793c8..36ad11f93 100644
--- a/mod/ecml/views/default/ecml/admin/ecml_admin.php
+++ b/mod/ecml/views/default/ecml/admin/ecml_admin.php
@@ -35,21 +35,30 @@ $form_body .= '</tr>';
$odd = 'odd';
foreach ($keywords as $keyword => $keyword_info) {
$keyword_desc = $keyword_info['description'];
- $form_body .= "
- <tr class=\"ecml_row_$odd\">
- <td class=\"ecml_keyword_desc\"><acronym class=\"ecml_keyword ecml_check_all\" title=\"$keyword_desc\">$keyword</acronym></td>
-";
+ if (isset($keyword_info['restricted'])) {
+ $restricted = elgg_echo('ecml:admin:restricted');
+ $form_body .= "
+ <tr class=\"ecml_row_$odd\">
+ <td class=\"ecml_keyword_desc\"><acronym class=\"ecml_keyword ecml_restricted\" title=\"$keyword_desc\">$keyword ($restricted)</acronym></td>
+ ";
+ } else {
+ $form_body .= "
+ <tr class=\"ecml_row_$odd\">
+ <td class=\"ecml_keyword_desc\"><acronym class=\"ecml_keyword ecml_check_all\" title=\"$keyword_desc\">$keyword</acronym></td>
+ ";
+ }
foreach ($views as $view => $view_info) {
// if this is restricted and we're not on the specified view don't allow changes
// since we don't save this, no need to pass a name
- if (isset($keyword_info['restricted']) && !in_array($view, $keyword_info['restricted'])) {
- $form_body .= "<td><input type=\"checkbox\" checked=\"checked\" disabled=\"disabled\"/></td>";
+ if (isset($keyword_info['restricted'])) {
+ $checked = (in_array($view, $keyword_info['restricted'])) ? 'checked="checked"' : '';
+ $form_body .= "<td><input type=\"checkbox\" $checked name=\"whitelist[$view][]\" value=\"$keyword\" disabled=\"disabled\"/></td>";
} else {
- $checked = (in_array($keyword, $perms[$view])) ? 'checked="checked"' : '';
+ $checked = (!in_array($keyword, $perms[$view])) ? 'checked="checked"' : '';
// ooook. input/checkboxes isn't overly useful.
// do it ourself.
- $form_body .= "<td><input type=\"checkbox\" name=\"perms[$view][]\" value=\"$keyword\" $checked /></td>";
+ $form_body .= "<td><input type=\"checkbox\" name=\"whitelist[$view][]\" value=\"$keyword\" $checked /></td>";
}
}
$form_body .= '</tr>';
@@ -71,7 +80,7 @@ echo elgg_view('input/form', array(
$(document).ready(function() {
// append check all link
- $('.ecml_check_all').before('<input type="checkbox" class="check_all">');
+ $('.ecml_check_all').before('<input type="checkbox" checked="checked" class="check_all">');
$('input.check_all').click(function() {
// yoinked from