aboutsummaryrefslogtreecommitdiff
path: root/mod/defaultwidgets/actions
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-03-03 17:53:05 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-03-03 17:53:05 +0000
commit4766f36a4d74924f21ff329c4318ce4e069ffa04 (patch)
tree969b84632f2a8b0db79788a8a6db8e41d63e5cb4 /mod/defaultwidgets/actions
parent57a217fd6b708844407486046a1faa23b46cac08 (diff)
downloadelgg-4766f36a4d74924f21ff329c4318ce4e069ffa04.tar.gz
elgg-4766f36a4d74924f21ff329c4318ce4e069ffa04.tar.bz2
Pulled in the interface changes.
git-svn-id: http://code.elgg.org/elgg/trunk@5257 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/defaultwidgets/actions')
-rw-r--r--mod/defaultwidgets/actions/update.php61
1 files changed, 61 insertions, 0 deletions
diff --git a/mod/defaultwidgets/actions/update.php b/mod/defaultwidgets/actions/update.php
new file mode 100644
index 000000000..aaf03430d
--- /dev/null
+++ b/mod/defaultwidgets/actions/update.php
@@ -0,0 +1,61 @@
+<?php
+/**
+ * Elgg default_widgets plugin.
+ *
+ * @package DefaultWidgets
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU
+ * @author Milan Magudia & Curverider
+ * @copyright HedgeHogs.net & Curverider Ltd
+ *
+ **/
+
+// validate user is an admin
+admin_gatekeeper ();
+
+// get parameters
+$context = get_input ( 'context' );
+$leftbar = str_replace ( '::0', '', get_input ( 'debugField1' ) );
+$middlebar = str_replace ( '::0', '', get_input ( 'debugField2' ) );
+$rightbar = str_replace ( '::0', '', get_input ( 'debugField3' ) );
+
+// make sure enough parameters are set
+if ($context && isset ( $leftbar ) && isset ( $middlebar ) && isset ( $rightbar )) {
+
+ // join widgets into a single string
+ $widgets = $leftbar . '%%' . $middlebar . '%%' . $rightbar;
+
+ // get the elgg object that contains our settings
+ $entities = elgg_get_entities (array('type' => 'object', 'subtype' => 'moddefaultwidgets', 'limit' => 9999));
+
+ // create new object unless one already exists
+ if (! isset ( $entities [0] )) {
+ $entity = new ElggObject ( );
+ $entity->subtype = 'moddefaultwidgets';
+ $entity->owner_guid = $_SESSION ['user']->getGUID ();
+ } else {
+ $entity = $entities [0];
+ }
+
+ // store the default widgets for each context
+ $entity->$context = $widgets;
+
+ // make sure this object is public.
+ $entity->access_id = 2;
+
+ // save the object or report error
+ if ($entity->save ()) {
+ system_message ( elgg_echo ( 'defaultwidgets:update:success' ) );
+ $entity->state = "active";
+ forward ( 'pg/admin' );
+ } else {
+ register_error ( elgg_echo ( 'defaultwidgets:update:failed' ) );
+ forward ( 'pg/defaultwidgets/' . $context );
+ }
+
+} else {
+
+ // report incorrect parameters error
+ register_error ( elgg_echo ( 'defaultwidgets:update:noparams' ) );
+ forward ( 'pg/defaultwidgets/' . $context );
+
+}