diff options
-rw-r--r-- | engine/lib/entities.php | 8 | ||||
-rw-r--r-- | engine/lib/objects.php | 10 | ||||
-rw-r--r-- | engine/lib/sites.php | 10 | ||||
-rw-r--r-- | engine/lib/users.php | 10 |
4 files changed, 26 insertions, 12 deletions
diff --git a/engine/lib/entities.php b/engine/lib/entities.php index 0cbd538a6..17b6ff7f3 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -767,12 +767,8 @@ // Erased by Ben: sometimes we need unauthenticated users to create things! (eg users on registration) // if ($owner_guid==0) throw new InvalidParameterException("owner_guid must not be 0"); - - if ($result = insert_data("INSERT into {$CONFIG->dbprefix}entities (type, subtype, owner_guid, site_guid, access_id, time_created, time_updated) values ('$type',$subtype, $owner_guid, $site_guid, $access_id, $time, $time)")) {
- $entity = get_entity($result);
- trigger_event('create',$entity->type,$entity);
- }
- return $result; +
+ return insert_data("INSERT into {$CONFIG->dbprefix}entities (type, subtype, owner_guid, site_guid, access_id, time_created, time_updated) values ('$type',$subtype, $owner_guid, $site_guid, $access_id, $time, $time)"); } /** diff --git a/engine/lib/objects.php b/engine/lib/objects.php index 8d78bddd8..e44a005ff 100644 --- a/engine/lib/objects.php +++ b/engine/lib/objects.php @@ -225,8 +225,14 @@ // Insert it
$result = insert_data("INSERT into {$CONFIG->dbprefix}objects_entity (guid, title, description) values ($guid, '$title','$description')");
- if ($result!==false)
- return true;
+ if ($result!==false) {
+ $entity = get_entity($guid);
+ if (trigger_event('create',$entity->type,$entity)) {
+ return true;
+ } else {
+ delete_entity($guid);
+ }
+ }
}
return false;
diff --git a/engine/lib/sites.php b/engine/lib/sites.php index cf815d885..dbe6d13b1 100644 --- a/engine/lib/sites.php +++ b/engine/lib/sites.php @@ -259,8 +259,14 @@ // Insert it $result = insert_data("INSERT into {$CONFIG->dbprefix}sites_entity (guid, name, description, url) values ($guid, '$name','$description','$url')"); - if ($result!==false) - return true; + if ($result!==false) {
+ get_entity($guid);
+ if (trigger_event('create',$entity->type,$entity)) { + return true;
+ } else {
+ delete_entity($guid);
+ }
+ } } return false; diff --git a/engine/lib/users.php b/engine/lib/users.php index 96881b1df..358abc133 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -342,8 +342,14 @@ // Insert it
$result = insert_data("INSERT into {$CONFIG->dbprefix}users_entity (guid, name, username, password, email, language, code) values ($guid, '$name', '$username', '$password', '$email', '$language', '$code')");
- if ($result!==false)
- return true;
+ if ($result!==false) {
+ $entity = get_entity($guid);
+ if (trigger_event('create',$entity->type,$entity)) {
+ return true;
+ } else {
+ delete_entity($guid);
+ }
+ }
}
return false;
|