diff options
Diffstat (limited to 'engine/lib')
-rw-r--r-- | engine/lib/annotations.php | 6 | ||||
-rw-r--r-- | engine/lib/cache.php | 4 | ||||
-rw-r--r-- | engine/lib/database.php | 18 | ||||
-rw-r--r-- | engine/lib/elgglib.php | 4 | ||||
-rw-r--r-- | engine/lib/entities.php | 29 | ||||
-rw-r--r-- | engine/lib/export.php | 6 | ||||
-rw-r--r-- | engine/lib/extender.php | 6 | ||||
-rw-r--r-- | engine/lib/filestore.php | 2 | ||||
-rw-r--r-- | engine/lib/metadata.php | 6 | ||||
-rw-r--r-- | engine/lib/objects.php | 10 | ||||
-rw-r--r-- | engine/lib/plugins.php | 2 | ||||
-rw-r--r-- | engine/lib/relationships.php | 10 | ||||
-rw-r--r-- | engine/lib/sites.php | 10 | ||||
-rw-r--r-- | engine/lib/users.php | 12 |
14 files changed, 61 insertions, 64 deletions
diff --git a/engine/lib/annotations.php b/engine/lib/annotations.php index 4ecb9ea16..3b5be89b3 100644 --- a/engine/lib/annotations.php +++ b/engine/lib/annotations.php @@ -87,7 +87,7 @@ else
{
$this->id = create_annotation($this->entity_guid, $this->name, $this->value, $this->value_type, $this->owner_guid, $this->access_id);
- if (!$this->id) throw new IOException("Unable to save new ElggAnnotation");
+ if (!$this->id) throw new IOException(sprintf(elgg_new('IOException:UnableToSaveNew'), get_class()));
return $this->id;
}
}
@@ -439,10 +439,10 @@ {
// Sanity check values
if ((!is_array($params)) && (!isset($params['guid'])))
- throw new InvalidParameterException("GUID has not been specified during export, this should never happen.");
+ throw new InvalidParameterException(elgg_echo('InvalidParameterException:GUIDNotForExport'));
if (!is_array($returnvalue))
- throw new InvalidParameterException("Entity serialisation function passed a non-array returnvalue parameter");
+ throw new InvalidParameterException(elgg_echo('InvalidParameterException:NonArrayReturnValue'));
$guid = (int)$params['guid'];
$name = $params['name'];
diff --git a/engine/lib/cache.php b/engine/lib/cache.php index 6f7b99abe..2fbbf3f04 100644 --- a/engine/lib/cache.php +++ b/engine/lib/cache.php @@ -98,7 +98,7 @@ $this->set_variable("max_age", $max_age); $this->set_variable("max_size", $max_size); - if ($cache_path=="") throw new ConfigurationException("Cache path set to nothing!"); + if ($cache_path=="") throw new ConfigurationException(elgg_echo('ConfigurationException:NoCachePath')); } /** @@ -197,7 +197,7 @@ $exclude = array(".",".."); $files = scandir($dir); - if (!$files) throw new IOException("$dir is not a directory."); + if (!$files) throw new IOException(sprintf(elgg_echo('IOException:NotDirectory'), $dir)); // Perform cleanup foreach ($files as $f) diff --git a/engine/lib/database.php b/engine/lib/database.php index 55d2533c2..55ff021e5 100644 --- a/engine/lib/database.php +++ b/engine/lib/database.php @@ -48,9 +48,9 @@ // Connect to database
if (!$dblink[$dblinkname] = mysql_connect($CONFIG->dbhost, $CONFIG->dbuser, $CONFIG->dbpass, true))
- throw new DatabaseException("Elgg couldn't connect to the database using the given credentials.");
+ throw new DatabaseException(elgg_echo('DatabaseException:WrongCredentials'));
if (!mysql_select_db($CONFIG->dbname, $dblink[$dblinkname]))
- throw new DatabaseException("Elgg couldn't select the database {$CONFIG->dbname}.");
+ throw new DatabaseException(sprintf(elgg_echo('DatabaseException:NoConnect'), $CONFIG->dbname));
}
@@ -130,7 +130,7 @@ global $CONFIG, $dbcalls; if (!callpath_gatekeeper($CONFIG->path . "engine/", true, true)) - throw new DatabaseException("Access to privileged function 'get_data()' is denied.");
+ throw new SecurityException(sprintf(elgg_echo('SecurityException:FunctionDenied'), 'get_data()'));
$dblink = get_db_link('read');
@@ -175,7 +175,7 @@ global $CONFIG, $dbcalls; if (!callpath_gatekeeper($CONFIG->path . "engine/", true, true)) - throw new DatabaseException("Access to privileged function 'get_data_row()' is denied.");
+ throw new SecurityException(sprintf(elgg_echo('SecurityException:FunctionDenied'), 'get_data_row()'));
$dblink = get_db_link('read');
@@ -214,7 +214,7 @@ global $CONFIG, $dbcalls; if (!callpath_gatekeeper($CONFIG->path . "engine/", true, true)) - throw new DatabaseException("Access to privileged function 'insert_data()' is denied.");
+ throw new SecurityException(sprintf(elgg_echo('SecurityException:FunctionDenied'), 'insert_data()'));
$dblink = get_db_link('write');
@@ -241,7 +241,7 @@ global $dbcalls, $CONFIG; if (!callpath_gatekeeper($CONFIG->path . "engine/", true, true)) - throw new DatabaseException("Access to privileged function 'update_data()' is denied.");
+ throw new SecurityException(sprintf(elgg_echo('SecurityException:FunctionDenied'), 'update_data()'));
$dblink = get_db_link('write');
@@ -269,7 +269,7 @@ global $dbcalls, $CONFIG; if (!callpath_gatekeeper($CONFIG->path . "engine/", true, true)) - throw new DatabaseException("Access to privileged function 'delete_data()' is denied.");
+ throw new SecurityException(sprintf(elgg_echo('SecurityException:FunctionDenied'), 'delete_data()'));
$dblink = get_db_link('write');
@@ -361,11 +361,11 @@ $errortxt = "";
foreach($errors as $error)
$errortxt .= " {$error};";
- throw new DatabaseException("There were a number of issues: " . $errortxt);
+ throw new DatabaseException(elgg_echo('DatabaseException:DBSetupIssues') . $errortxt);
}
} else {
- throw new DatabaseException("Elgg couldn't find the requested database script at {$scriptlocation}.");
+ throw new DatabaseException(sprintf(elgg_echo('DatabaseException:ScriptNotFound'), $scriptlocation));
}
}
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index e07d59162..9c071f497 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -859,7 +859,7 @@ register_error("ERROR: " . $error);
// Since this is a fatal error, we want to stop any further execution but do so gracefully.
- throw new Exception("ERROR: " . $error);
+ throw new Exception($error);
break;
case E_WARNING :
@@ -1159,7 +1159,7 @@ } } - throw new SecurityException("Denied access to execute privileged code block"); + throw new SecurityException(elgg_echo("SecurityException:Codeblock")); } /** diff --git a/engine/lib/entities.php b/engine/lib/entities.php index 4507c2bb0..3d206f783 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -397,7 +397,7 @@ else { $this->attributes['guid'] = create_entity($this->attributes['type'], $this->attributes['subtype'], $this->attributes['owner_guid'], $this->attributes['access_id']); // Create a new entity (nb: using attribute array directly 'cos set function does something special!) - if (!$this->attributes['guid']) throw new IOException("Unable to save new object's base entity information!"); + if (!$this->attributes['guid']) throw new IOException(elgg_echo('IOException:BaseEntitySaveFailed')); // Save any unsaved metadata
if (sizeof($this->temp_metadata) > 0) {
@@ -520,7 +520,7 @@ public function import(ODD $data) { if (!($data instanceof ODDEntity)) - throw new InvalidParameterException("ElggEntity::import() passed an unexpected ODD class"); + throw new InvalidParameterException(elgg_echo('InvalidParameterException:UnexpectedODDClass')); // Set type and subtype $this->attributes['type'] = $data->getAttribute('class'); @@ -791,11 +791,8 @@ $site_guid = $CONFIG->site_guid;
$site_guid = (int) $site_guid; - if ($type=="") throw new InvalidParameterException("Entity type must be set.");
+ if ($type=="") throw new InvalidParameterException(elgg_echo('InvalidParameterException:EntityTypeNotSet'));
- // 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"); -
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)"); } @@ -832,7 +829,7 @@ $tmp = new $classname($row); if (!($tmp instanceof ElggEntity)) - throw new ClassException("$classname is not an ElggEntity."); + throw new ClassException(sprintf(elgg_echo('ClassException:ClassnameNotClass'), $classname, get_class())); return $tmp; } @@ -848,7 +845,7 @@ return new ElggCollection($row); case 'site' : return new ElggSite($row); - default: throw new InstallationException("Type {$row->type} is not supported. This indicates an error in your installation, most likely caused by an incomplete upgrade."); + default: throw new InstallationException(sprintf(elgg_echo('InstallationException:TypeNotSupported'), $row->type)); } } @@ -987,17 +984,17 @@ { // Sanity check values if ((!is_array($params)) && (!isset($params['guid']))) - throw new InvalidParameterException("GUID has not been specified during export, this should never happen."); + throw new InvalidParameterException(elgg_echo('InvalidParameterException:GUIDNotForExport')); if (!is_array($returnvalue)) - throw new InvalidParameterException("Entity serialisation function passed a non-array returnvalue parameter"); + throw new InvalidParameterException(elgg_echo('InvalidParameterException:NonArrayReturnValue')); $guid = (int)$params['guid']; // Get the entity $entity = get_entity($guid); if (!($entity instanceof ElggEntity)) - throw new InvalidClassException("GUID:$guid is not an ElggEntity"); + throw new InvalidClassException(sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $guid, get_class())); $export = $entity->export(); @@ -1038,7 +1035,7 @@ $tmp = new $classname(); if (!($tmp instanceof ElggEntity)) - throw new ClassException("$classname is not an ElggEntity."); + throw new ClassException(sprintf(elgg_echo('ClassException:ClassnameNotClass', $classname, get_class()))); } else @@ -1049,7 +1046,7 @@ case 'user' : $tmp = new ElggUser($row); break; case 'collection' : $tmp = new ElggCollection($row); break; case 'site' : $tmp = new ElggSite($row); break; - default: throw new InstallationException("Type $class is not supported. This indicates an error in your installation, most likely caused by an incomplete upgrade."); + default: throw new InstallationException(sprintf(elgg_echo('InstallationException:TypeNotSupported'), $class)); } } } @@ -1057,14 +1054,14 @@ if ($tmp) { if (!$tmp->import($element)) - throw new ImportException("Could not import element " . $element->getAttribute('uuid')); + throw new ImportException(sprintf(elgg_echo('ImportException:ImportFailed'), $element->getAttribute('uuid'))); if (!$tmp->save()) // Make sure its saved - throw new ImportException("There was a problem saving ". $element->getAttribute('uuid')); + throw new ImportException(sprintf(elgg_echo('ImportException:ProblemSaving'), $element->getAttribute('uuid'))); // Belts and braces if (!$tmp->guid) - throw new ImportException("New entity created but has no GUID, this should not happen."); + throw new ImportException(elgg_echo('ImportException:NoGUID')); add_uuid_to_guid($tmp->guid, $element->getAttribute('uuid')); // We have saved, so now tag diff --git a/engine/lib/export.php b/engine/lib/export.php index b0d7ae3a5..14a3ff76b 100644 --- a/engine/lib/export.php +++ b/engine/lib/export.php @@ -175,7 +175,7 @@ $to_be_serialised = trigger_plugin_hook("export", "all", array("guid" => $guid), $to_be_serialised); // Sanity check - if ((!is_array($to_be_serialised)) || (count($to_be_serialised)==0)) throw new ExportException("No such entity GUID:$guid"); + if ((!is_array($to_be_serialised)) || (count($to_be_serialised)==0)) throw new ExportException(sprintf(elgg_echo('ExportException:NoSuchEntity'), $guid)); $odd = new ODDDocument($to_be_serialised); @@ -199,13 +199,13 @@ $document = ODD_Import($xml); if (!$document) - throw new ImportException("No OpenDD elements found in import data, import failed."); + throw new ImportException(elgg_echo('ImportException:NoODDElements')); foreach ($document as $element) __process_element($element); if ($IMPORTED_OBJECT_COUNTER!= count($IMPORTED_DATA)) - throw new ImportException("Not all elements were imported."); + throw new ImportException(elgg_echo('ImportException:NotAllImported')); return true; } diff --git a/engine/lib/extender.php b/engine/lib/extender.php index 2f35d4aea..8221124af 100644 --- a/engine/lib/extender.php +++ b/engine/lib/extender.php @@ -49,7 +49,7 @@ //case 'file' : case 'text' : return ($this->attributes['value']); - default : throw new InstallationException("Type {$this->attributes['value_type']} is not supported. This indicates an error in your installation, most likely caused by an incomplete upgrade."); + default : throw new InstallationException(sprintf(elgg_echo('InstallationException:TypeNotSupported'), $this->attributes['value_type'])); } } @@ -250,7 +250,7 @@ $entity_uuid = $element->getAttribute('entity_uuid'); $entity = get_entity_from_uuid($entity_uuid); if (!$entity) - throw new ImportException("Entity '$entity_uuid' could not be found."); + throw new ImportException(sprintf(elgg_echo('ImportException:GUIDNotFound'), $entity_uuid)); // Get the type of extender (metadata, type, attribute etc) $type = $element->getAttribute('type'); @@ -276,7 +276,7 @@ // Save if (!$entity->save()) - throw new ImportException("There was a problem updating '$attr_name' on entity '$entity_uuid'"); + throw new ImportException(sprintf(elgg_echo('ImportException:ProblemUpdatingMeta'), $attr_name, $entity_uuid)); return true; } diff --git a/engine/lib/filestore.php b/engine/lib/filestore.php index 6dfa8073f..0c8e5f121 100644 --- a/engine/lib/filestore.php +++ b/engine/lib/filestore.php @@ -162,7 +162,7 @@ case "read" : $mode = "r+b"; break; case "write" : $mode = "w+b"; break; case "append" : $mode = "a+b"; break; - default: throw new InvalidParameterException("Unrecognised file mode '$mode'"); + default: throw new InvalidParameterException(sprintf(elgg_echo('InvalidParameterException:UnrecognisedFileMode'), $mode)); } return fopen($fullname, $mode); diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php index 798505288..44474c7d6 100644 --- a/engine/lib/metadata.php +++ b/engine/lib/metadata.php @@ -81,7 +81,7 @@ else { $this->id = create_metadata($this->entity_guid, $this->name, $this->value, $this->value_type, $this->owner_guid, $this->access_id); - if (!$this->id) throw new IOException("Unable to save new ElggAnnotation"); + if (!$this->id) throw new IOException(sprintf(elgg_new('IOException:UnableToSaveNew'), get_class())); return $this->id; } @@ -514,10 +514,10 @@ { // Sanity check values if ((!is_array($params)) && (!isset($params['guid']))) - throw new InvalidParameterException("GUID has not been specified during export, this should never happen."); + throw new InvalidParameterException(elgg_echo('InvalidParameterException:GUIDNotForExport')); if (!is_array($returnvalue)) - throw new InvalidParameterException("Entity serialisation function passed a non-array returnvalue parameter"); + throw new InvalidParameterException(elgg_echo('InvalidParameterException:NonArrayReturnValue')); $guid = (int)$params['guid']; $name = $params['name']; diff --git a/engine/lib/objects.php b/engine/lib/objects.php index b14e984c0..a51665b5b 100644 --- a/engine/lib/objects.php +++ b/engine/lib/objects.php @@ -55,7 +55,7 @@ if ($guid instanceof stdClass) {
// Load the rest
if (!$this->load($guid->guid)) - throw new IOException("Failed to load new ElggObject from GUID:$guid->guid");
+ throw new IOException(sprintf(elgg_echo('IOException:FailedToLoadGUID'), get_class(), $guid->guid));
}
// Is $guid is an ElggObject? Use a copy constructor
@@ -67,15 +67,15 @@ // Is this is an ElggEntity but not an ElggObject = ERROR!
else if ($guid instanceof ElggEntity)
- throw new InvalidParameterException("Passing a non-ElggObject to an ElggObject constructor!");
+ throw new InvalidParameterException(elgg_echo('InvalidParameterException:NonElggObject'));
// We assume if we have got this far, $guid is an int
else if (is_numeric($guid)) {
- if (!$this->load($guid)) throw new IOException("Could not create a new ElggObject object from GUID:$guid");
+ if (!$this->load($guid)) IOException(sprintf(elgg_echo('IOException:FailedToLoadGUID'), get_class(), $guid));
} else - throw new IOException("Unrecognised value passed to constuctor.");
+ throw new InvalidParameterException(elgg_echo('InvalidParameterException:UnrecognisedValue'));
}
}
@@ -112,7 +112,7 @@ // Check the type
if ($this->attributes['type']!='object')
- throw new InvalidClassException("GUID:$guid is not a valid ElggObject");
+ throw new InvalidClassException(sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $guid, get_class()));
// Load missing data
$row = get_object_entity_as_row($guid);
diff --git a/engine/lib/plugins.php b/engine/lib/plugins.php index e5b292492..8a008f278 100644 --- a/engine/lib/plugins.php +++ b/engine/lib/plugins.php @@ -29,7 +29,7 @@ while ($mod = readdir($handle)) {
if (!in_array($mod,array('.','..','.svn','CVS')) && is_dir($CONFIG->pluginspath . "/" . $mod)) {
if (!@include($CONFIG->pluginspath . $mod . "/start.php"))
- throw new PluginException("{$mod} is a misconfigured plugin.");
+ throw new PluginException(sprintf(elgg_echo('PluginException:MisconfiguredPlugin'), $mod));
if (is_dir($CONFIG->pluginspath . $mod . "/views/default")) {
autoregister_views("",$CONFIG->pluginspath . $mod . "/views/default",$CONFIG->pluginspath . $mod . "/views/");
}
diff --git a/engine/lib/relationships.php b/engine/lib/relationships.php index b5d5816a1..3f053460a 100644 --- a/engine/lib/relationships.php +++ b/engine/lib/relationships.php @@ -94,7 +94,7 @@ } $this->id = add_entity_relationship($this->guid_one, $this->relationship, $this->guid_two); - if (!$this->id) throw new IOException("Unable to save new ElggAnnotation"); + if (!$this->id) throw new IOException(sprintf(elgg_new('IOException:UnableToSaveNew'), get_class())); return $this->id; @@ -137,7 +137,7 @@ public function import(ODD $data) { if (!($element instanceof ODDRelationship)) - throw new InvalidParameterException("ElggRelationship::import() passed an unexpected ODD class"); + throw new InvalidParameterException(elgg_echo('InvalidParameterException:UnexpectedODDClass')); $uuid_one = $data->getAttribute('uuid1'); $uuid_two = $data->getAttribute('uuid2'); @@ -162,7 +162,7 @@ // save $result = $this->save(); if (!$result) - throw new ImportException("There was a problem saving the ElggExtender"); + throw new ImportException(sprintf(elgg_echo('ImportException:ProblemSaving'), get_class())); return $this; } @@ -576,10 +576,10 @@ // Sanity check values if ((!is_array($params)) && (!isset($params['guid']))) - throw new InvalidParameterException("GUID has not been specified during export, this should never happen."); + throw new InvalidParameterException(elgg_echo('InvalidParameterException:GUIDNotForExport')); if (!is_array($returnvalue)) - throw new InvalidParameterException("Entity serialisation function passed a non-array returnvalue parameter"); + throw new InvalidParameterException(elgg_echo('InvalidParameterException:NonArrayReturnValue')); $guid = (int)$params['guid']; diff --git a/engine/lib/sites.php b/engine/lib/sites.php index 0db40e5d4..9823f097a 100644 --- a/engine/lib/sites.php +++ b/engine/lib/sites.php @@ -54,7 +54,7 @@ if ($guid instanceof stdClass) { // Load the rest if (!$this->load($guid->guid)) - throw new IOException("Failed to load new ElggSite from GUID:$guid->guid"); + throw new IOException(sprintf(elgg_echo('IOException:FailedToLoadGUID'), get_class(), $guid->guid)); } // Is $guid is an ElggSite? Use a copy constructor @@ -66,7 +66,7 @@ // Is this is an ElggEntity but not an ElggSite = ERROR! else if ($guid instanceof ElggEntity) - throw new InvalidParameterException("Passing a non-ElggSite to an ElggSite constructor!"); + throw new InvalidParameterException(elgg_echo('InvalidParameterException:NonElggSite')); // See if this is a URL else if (strpos($guid, "http")!==false) @@ -79,11 +79,11 @@ // We assume if we have got this far, $guid is an int else if (is_numeric($guid)) { - if (!$this->load($guid)) throw new IOException("Could not create a new ElggSite object from GUID:$guid"); + if (!$this->load($guid)) throw new IOException(sprintf(elgg_echo('IOException:FailedToLoadGUID'), get_class(), $guid)); } else - throw new IOException("Unrecognised value passed to constuctor."); + throw new InvalidParameterException(elgg_echo('InvalidParameterException:UnrecognisedValue')); } } @@ -119,7 +119,7 @@ // Check the type if ($this->attributes['type']!='site') - throw new InvalidClassException("GUID:$guid is not a valid ElggSite"); + throw new InvalidClassException(sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $guid, get_class())); // Load missing data $row = get_site_entity_as_row($guid); diff --git a/engine/lib/users.php b/engine/lib/users.php index f9fc09ae0..b4fa795b8 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -59,7 +59,7 @@ if ($guid instanceof stdClass) {
// Load the rest
if (!$this->load($guid->guid))
- throw new IOException("Failed to load new ElggUser from GUID:$guid->guid");
+ throw new IOException(sprintf(elgg_echo('IOException:FailedToLoadGUID'), get_class(), $guid->guid));
}
// See if this is a username
@@ -80,15 +80,15 @@ // Is this is an ElggEntity but not an ElggUser = ERROR!
else if ($guid instanceof ElggEntity)
- throw new InvalidParameterException("Passing a non-ElggUser to an ElggUser constructor!");
+ throw new InvalidParameterException(elgg_echo('InvalidParameterException:NonElggUser'));
// We assume if we have got this far, $guid is an int
else if (is_numeric($guid)) {
- if (!$this->load($guid)) throw new IOException("Could not create a new ElggUser user from GUID:$guid");
+ if (!$this->load($guid)) IOException(sprintf(elgg_echo('IOException:FailedToLoadGUID'), get_class(), $guid));
} else - throw new IOException("Unrecognised value passed to constuctor.");
+ throw new InvalidParameterException(elgg_echo('InvalidParameterException:UnrecognisedValue'));
}
}
@@ -125,7 +125,7 @@ // Check the type
if ($this->attributes['type']!='user')
- throw new InvalidClassException("GUID:$guid is not a valid ElggUser");
+ throw new InvalidClassException(sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $guid, get_class()));
// Load missing data
$row = get_user_entity_as_row($guid);
@@ -560,7 +560,7 @@ $result = get_entity($guid);
if ((!empty($result)) && (!($result instanceof ElggUser)))
- throw new InvalidParameterException("GUID:$guid is not an ElggUser");
+ throw new InvalidClassException(sprintf(elgg_echo('InvalidClassException:NotValidElggStar'), $guid, get_class()));
if (!empty($result))
return $result;
|