Пример #1
0
 function delete_entity()
 {
     $media_work = new entity($this->get_value('id'));
     $shim = MediaWorkFactory::shim($media_work);
     if ($shim) {
         $shim->delete_media_work($this);
     }
     parent::delete_entity();
 }
Пример #2
0
 function delete_entity()
 {
     if ($this->get_value('id')) {
         $e = new entity($this->get_value('id'));
         if ($e->get_value('state') == 'Live' || $e->get_value('state') == 'Deleted') {
             $q = 'UPDATE URL_history SET deleted="yes" WHERE page_id="' . $this->get_value('id') . '"';
             $r = db_query($q, 'Deleting Page');
         }
     }
     parent::delete_entity();
 }
Пример #3
0
 function delete_entity()
 {
     if (!$this->get_value('id')) {
         return;
     }
     $image = new entity($this->get_value('id'));
     $paths = array();
     $paths['thumbnail'] = reason_get_image_path($image, 'thumbnail');
     $paths['normal'] = reason_get_image_path($image);
     $paths['original'] = reason_get_image_path($image, 'original');
     foreach ($paths as $key => $path) {
         if (file_exists($path)) {
             $largest = $key;
         }
     }
     if ($largest) {
         // move to image graveyard
         if (defined('REASON_IMAGE_GRAVEYARD') && REASON_IMAGE_GRAVEYARD) {
             if (!file_exists(REASON_IMAGE_GRAVEYARD)) {
                 mkdir(REASON_IMAGE_GRAVEYARD);
             }
             rename($paths[$largest], REASON_IMAGE_GRAVEYARD . basename($paths[$largest]));
             unset($paths[$largest]);
         }
         foreach ($paths as $key => $path) {
             if (file_exists($path)) {
                 unlink($path);
             }
         }
     }
     $sized_image_directory = REASON_SIZED_IMAGE_DIR . $image->id() . '/';
     if (file_exists($sized_image_directory)) {
         $this->delete_directory($sized_image_directory);
     }
     $custom_sized_image_directory = REASON_INC . 'www/sized_images_custom/' . $image->id() . '/';
     if (file_exists($custom_sized_image_directory)) {
         $this->delete_directory($custom_sized_image_directory);
     }
     parent::delete_entity();
 }
Пример #4
0
 function delete_entity()
 {
     $e = new entity($this->get_value('id'));
     // don't drop table if this is dending or archived -- this might just be a duplicate
     if ($e->get_value('state') == 'Live' || $e->get_value('state') == 'Deleted') {
         if (in_array($e->get_value('name'), reason_get_protected_tables())) {
             trigger_error('Unable to zap protected table (' . $e->get_value('name') . ')');
             die;
         }
         if ($e->has_right_relation_of_type('type_to_table')) {
             trigger_error('Unable to zap Live or Deleted entity table that is part of a type (' . $e->get_value('name') . ')');
             die;
         }
         $r = db_query('SHOW TABLES');
         while ($row = mysql_fetch_array($r, MYSQL_ASSOC)) {
             $all_tables[] = current($row);
         }
         if (in_array($e->get_value('name'), $all_tables)) {
             $r = db_query('DROP TABLE `' . $e->get_value('name') . '`');
         }
     }
     parent::delete_entity();
 }
Пример #5
0
 /**
  * This function does the actual deleting once the button is pressed.
  *
  * The main function is to check whether or not a page is master admin,
  * and then deleting all entities that are owned by  page if it is not.
  * Rewrites are updated after the pages are deleted.
  */
 function delete_entity()
 {
     $user_id = $this->admin_page->authenticate();
     $url_manager = new url_manager($this->get_value('id'));
     $site = new entity($this->get_value('id'));
     if (!($site->get_value('unique_name') == 'master_admin')) {
         $owned_entities = $this->get_owned_entities($site);
         foreach ($owned_entities as $type_id => $array) {
             foreach ($array as $entity) {
                 reason_update_entity($entity->id(), $user_id, array('state' => 'Deleted'), false);
             }
         }
         parent::delete_entity();
         $url_manager->update_rewrites();
     }
 }