X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/a4093ac103388ffae1275c1c5937c4163901917d..6152f4bd9a8f960c79ae025b775b719930574cc9:/WEB-INF/lib/ttFileHelper.class.php diff --git a/WEB-INF/lib/ttFileHelper.class.php b/WEB-INF/lib/ttFileHelper.class.php index d5815f4c..ce24cd79 100644 --- a/WEB-INF/lib/ttFileHelper.class.php +++ b/WEB-INF/lib/ttFileHelper.class.php @@ -44,6 +44,7 @@ class ttFileHelper { $this->storage_uri = FILE_STORAGE_URI; $this->register_uri = $this->storage_uri.'register'; $this->putfile_uri = $this->storage_uri.'putfile'; + $this->deletefile_uri = $this->storage_uri.'deletefile'; $this->getfile_uri = $this->storage_uri.'getfile'; $this->checkSiteRegistration(); } @@ -213,8 +214,8 @@ class ttFileHelper { 'user_id' => urlencode($fields['user_id']), // May be null. 'user_key' => urlencode($fields['user_key']), // May be null. 'file_id' => urlencode($fields['remote_id']), - 'file_key' => urlencode($fields['file_key']) - ); + 'file_key' => urlencode($fields['file_key']), + 'file_name' => urlencode($fields['file_name'])); // url-ify the data for the POST. foreach($curl_fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } @@ -224,7 +225,7 @@ class ttFileHelper { $ch = curl_init(); // Set the url, number of POST vars, POST data. - curl_setopt($ch, CURLOPT_URL, $this->putfile_uri); + curl_setopt($ch, CURLOPT_URL, $this->deletefile_uri); curl_setopt($ch, CURLOPT_POST, count($fields)); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); @@ -334,4 +335,21 @@ class ttFileHelper { } return false; } + + // update - updates file details in local database. + static function update($fields) { + global $user; + $mdb2 = getConnection(); + + $group_id = $user->getGroup(); + $org_id = $user->org_id; + + $file_id = (int) $fields['id']; + $description = $mdb2->quote($fields['description']); + + $sql = "update tt_files set description = $description where id = $file_id". + " and group_id = $group_id and org_id = $org_id and (status = 0 or status = 1)"; + $affected = $mdb2->exec($sql); + return !is_a($affected, 'PEAR_Error'); + } }