diff options
-rw-r--r-- | engine/lib/actions.php | 4 | ||||
-rw-r--r-- | engine/lib/objects.php | 12 | ||||
-rw-r--r-- | languages/en.php | 7 | ||||
-rw-r--r-- | mod/test/index.php | 9 | ||||
-rw-r--r-- | mod/test/start.php | 3 | ||||
-rw-r--r-- | mod/test/views/default/testplugin/pageshell.php | 5 |
6 files changed, 22 insertions, 18 deletions
diff --git a/engine/lib/actions.php b/engine/lib/actions.php index bc5d6374f..b4a495414 100644 --- a/engine/lib/actions.php +++ b/engine/lib/actions.php @@ -37,10 +37,10 @@ if ($CONFIG->actions[$action]['public'] || $_SESSION['id'] != -1) {
if (@include($CONFIG->path . $CONFIG->actions[$action]['file'])) {
} else {
- register_error("The requested action was not defined in the system.");
+ register_error(sprintf(elgg_echo('actionundefined'),$action));
}
} else {
- register_error("Sorry, you cannot perform this action while logged out.");
+ register_error(elgg_echo('actionloggedout'));
}
}
forward($CONFIG->url . $forwarder);
diff --git a/engine/lib/objects.php b/engine/lib/objects.php index ccfc6b8b1..71488009e 100644 --- a/engine/lib/objects.php +++ b/engine/lib/objects.php @@ -81,12 +81,13 @@ * @return true|false Depending on success
*/
function save() {
- if (!empty($this->id)) {
+ if (isset($this->id)) {
return update_object($this->id, $this->title, $this->description, $this->type, $this->owner_id, $this->access_id, $this->site_id);
} else if ($id = create_object($this->title,$this->description,$this->type,$this->owner_id,$this->access_id,$this->site_id)) {
$this->id = $id;
return true;
}
+ return false;
}
/**
@@ -314,15 +315,15 @@ // We can't let non-logged in users create data
// We also need the access restriction to be valid
- if ($owner > 0 && in_array($access_id,get_access_array())) {
+ if (in_array($access_id,get_access_array())) {
$type_id = get_object_type_id($type);
$query = " insert into {$CONFIG->dbprefix}objects ";
$query .= "(`title`,`description`,`type_id`,`owner_id`,`site_id`,`access_id`) values ";
- $query .= "('{$title}','{$description}', {$type_id}, {$owner}, {$site_id}, {$access_id}";
+ $query .= "('{$title}','{$description}', {$type_id}, {$owner}, {$site_id}, {$access_id})";
return insert_data($query);
-
+
}
return false;
@@ -345,7 +346,6 @@ function update_object($id, $title = null, $description = null, $type = null, $owner_id = null, $access_id = null, $site_id = null) {
global $CONFIG;
-
$id = (int) $id;
if ($title != null) $title = sanitise_string($title);
if ($description != null) $description = sanitise_string($description);
@@ -357,7 +357,7 @@ // We can't let non-logged in users create data
// We also need the access restriction to be valid
- if ($owner > 0 && in_array($access_id,get_access_array())) {
+ if ($owner == $_SESSION['id'] && in_array($access_id,get_access_array())) {
$type_id = get_object_type_id($type);
diff --git a/languages/en.php b/languages/en.php index d4c68706c..f77c645a5 100644 --- a/languages/en.php +++ b/languages/en.php @@ -15,6 +15,13 @@ 'logouterror' => "We couldn't log you out. Please try again.",
/**
+ * Errors
+ */
+
+ 'actionundefined' => "The requested action (%s) was not defined in the system.",
+ 'actionloggedout' => "Sorry, you cannot perform this action while logged out.",
+
+ /**
* User details
*/
diff --git a/mod/test/index.php b/mod/test/index.php index e8940c6a4..96fc4bdab 100644 --- a/mod/test/index.php +++ b/mod/test/index.php @@ -5,15 +5,8 @@ global $CONFIG;
//var_export($CONFIG);
+
$body = elgg_view("testplugin/pageshell");
page_draw("Test plugin",$body);
-
- $object = new ElggObject();
- $object->type = "forum";
- $object->title = "Howdy!";
- $object->description = "I am the very model of a modern major general";
- $object->access = 2;
- $object->save();
- $object->setMetadata('parent',0,2);
?>
\ No newline at end of file diff --git a/mod/test/start.php b/mod/test/start.php index 345ca7588..09d536052 100644 --- a/mod/test/start.php +++ b/mod/test/start.php @@ -23,5 +23,6 @@ // Make sure test_init is called on initialisation
register_event_handler('init','system','test_init');
-
+ global $CONFIG;
+ register_action('banana',true,$CONFIG->path . "mod/test/banana.php");
?>
\ No newline at end of file diff --git a/mod/test/views/default/testplugin/pageshell.php b/mod/test/views/default/testplugin/pageshell.php index 889fba661..694f26874 100644 --- a/mod/test/views/default/testplugin/pageshell.php +++ b/mod/test/views/default/testplugin/pageshell.php @@ -1 +1,4 @@ -<p><i>Gosh! This view was added to!</i></p>
\ No newline at end of file +<form action="<?php echo $vars['url']; ?>action/banana" method="post">
+ <p><i>Gosh! This view was added to!</i></p>
+ <input type="submit" value="Go" />
+</form>
\ No newline at end of file |