Beispiel #1
0
 /**
  * delete one server in the database
  *
  * @param int the id of the server to delete
  * @return boolean TRUE on success, FALSE otherwise
  *
  * @see servers/delete.php
  */
 public static function delete($id)
 {
     global $context;
     // id cannot be empty
     if (!$id || !is_numeric($id)) {
         return FALSE;
     }
     // delete related items
     Anchors::delete_related_to('server:' . $id);
     // delete the record in the database
     $query = "DELETE FROM " . SQL::table_name('servers') . " WHERE id = " . $id;
     if (SQL::query($query) === FALSE) {
         return FALSE;
     }
     // job done
     return TRUE;
 }
Beispiel #2
0
 /**
  * delete one section
  *
  * @param int the id of the section to delete
  * @return boolean TRUE on success, FALSE otherwise
  *
  * @see sections/delete.php
  */
 public static function delete($id)
 {
     global $context;
     // load the row
     $item = Sections::get($id);
     if (!$item['id']) {
         Logger::error(i18n::s('No item has the provided id.'));
         return FALSE;
     }
     // delete related items
     Anchors::delete_related_to('section:' . $item['id']);
     // delete the record in the database
     $query = "DELETE FROM " . SQL::table_name('sections') . " WHERE id = " . SQL::escape($item['id']);
     if (SQL::query($query) === FALSE) {
         return FALSE;
     }
     // remember overlay deletion
     if (isset($item['overlay']) && ($overlay = Overlay::load($item, 'section:' . $item['id']))) {
         $overlay->remember('delete', $item, 'section:' . $item['id']);
     }
     // job done
     return TRUE;
 }
Beispiel #3
0
 /**
  * delete one file in the database and in the file system
  *
  * @param int the id of the file to delete
  * @return boolean TRUE on success, FALSE otherwise
  */
 public static function delete($id)
 {
     global $context;
     // load the row
     $item = Files::get($id);
     if (!$item['id']) {
         Logger::error(i18n::s('No item has the provided id.'));
         return FALSE;
     }
     // actual deletion of the file
     $file_path = $context['path_to_root'] . Files::get_path($item['anchor']);
     Safe::unlink($file_path . '/' . $item['file_name']);
     Safe::unlink($file_path . '/thumbs/' . $item['file_name']);
     Safe::rmdir($file_path . '/thumbs');
     Safe::rmdir($file_path);
     Safe::rmdir(dirname($file_path));
     // delete related items
     Anchors::delete_related_to('file:' . $id);
     // delete the record in the database
     $query = "DELETE FROM " . SQL::table_name('files') . " WHERE id = " . SQL::escape($item['id']);
     if (SQL::query($query) === FALSE) {
         return FALSE;
     }
     // job done
     return TRUE;
 }