Ancaglon
Joined: 28 Sep 2006 Posts: 18
|
Posted: Tue Oct 31, 2006 5:00 pm Post subject: Suggested enhancement to Interface |
|
|
I have run into the problem of uploading the same day's data twice, which is rather painful to un-do without a backup of the database. As a way to avoid this, I've added another Function to my copy. See diff below:
| Code: |
--- dkprpc.php.orig 2006-10-31 02:00:00.000000000 +0000
+++ dkprpc.php 2006-10-31 17:43:34.000000000 +0000
@@ -915,7 +915,41 @@
"addRaidBatch" => array("function" => "addRaidBatch"),
"addEvent" => array("function" => "addEvent"),
"getAvailableRepresentations" => array("function" => "getAvailableRepresentations"),
+ "checkRaidTime" => array("function" => "checkRaidTime"),
"addDay" => array("function" => "addDay")
));
+/**
+ * checks if a raid exists with the given timestamp.
+ * @param string Username
+ * @param string Password
+ * @param int timestamp
+ * @return string raidName (or empty string if not found).
+ */
+function checkRaidTime($params) {
+ global $xmlrpcerruser;
+ if ($params->getNumParams() != 3) {
+ return new xmlrpcresp(0, $xmlrpcerruser+3, "Incorrect number of parameters.");
+ }
+
+ $user = toScalar($params->getParam(0));
+ $password = toScalar($params->getParam(1));
+ $raidTime = toScalar($params->getParam(2));
+
+ global $db, $eqdkp;
+
+ if(!hasUploadPermission($user, $password)) {
+ return new xmlrpcresp(0, $xmlrpcerruser+1, "Permission denied.");
+ }
+
+ $sql = "SELECT raid_name from ".RAIDS_TABLE." WHERE raid_date = ".$raidTime;
+ $result = $db->query($sql);
+ if($result === false) {
+ return new xmlrpcresp(0, $xmlrpcerruser+1, mysql_error());
+ }
+
+ $name = mysql_fetch_row($result);
+
+ return new xmlrpcresp(new xmlrpcval($name[0], "string"));
+}
?> |
(This is against the previous version of the Plug-in, but it also applies fine against the latest). |
|
Lokorin Site Admin
Joined: 03 Apr 2006 Posts: 697
|
Posted: Tue Oct 31, 2006 9:07 pm Post subject: Re: Suggested enhancement to Interface |
|
|
| Ancaglon wrote: |
| I have run into the problem of uploading the same day's data twice, which is rather painful to un-do without a backup of the database. As a way to avoid this, I've added another Function to my copy. |
Nice, it would certainly be useful. It has been entered as feature EDSI6. One option would be to implement it as an error message (if more than x% of the raids/loot/... already exist then rollback/abort and throw an error message), which would mean that one wouldn't have to change the client or interface specification. The drawback with that option would be that it would make it impossible to enter duplicates if one would ever want to (would one?). |
|