Commits

Hans van der Weij  committed 608e3e6

Fix issue 26, 27, 48 (incomplete delete checkout privileges, custom fields). Update removes orphaned database rows.

  • Participants
  • Parent commits e55a300

Comments (0)

Files changed (8)

File admin/copy_fields_del.php

   $restrictInDemo = true;
   require_once("../shared/logincheck.php");
   require_once("../classes/DmQuery.php");
+  require_once("../classes/BiblioCopyQuery.php");
   require_once("../functions/errorFuncs.php");
   require_once("../classes/Localize.php");
   $loc = new Localize(OBIB_LOCALE,$tab);
   $dmQ->delete("biblio_copy_fields_dm",$code);
   $dmQ->close();
 
+  $biblioCopyQ = new BiblioCopyQuery();
+  $biblioCopyQ->connect();
+  $biblioCopyQ->deleteCustomField($code);
+  $biblioCopyQ->close();
+
   #**************************************************************************
   #*  Show success page
   #**************************************************************************

File admin/materials_del.php

   $restrictInDemo = true;
   require_once("../shared/logincheck.php");
   require_once("../classes/DmQuery.php");
+  require_once("../classes/CheckoutPrivsQuery.php");
+  require_once("../classes/MaterialFieldQuery.php");
   require_once("../functions/errorFuncs.php");
   require_once("../classes/Localize.php");
   $loc = new Localize(OBIB_LOCALE,$tab);
   $dmQ->delete("material_type_dm",$code);
   $dmQ->close();
 
+  $checkoutPrivsQ = new CheckoutPrivsQuery();
+  $checkoutPrivsQ->connect();
+  $checkoutPrivsQ->delete_by_material_cd($code);
+  $checkoutPrivsQ->close();
+
+  $materialFieldQ = new MaterialFieldQuery();
+  $materialFieldQ->connect();
+  $materialFieldQ->deleteCustomField($code);
+  $materialFieldQ->close();
+
   #**************************************************************************
   #*  Show success page
   #**************************************************************************

File admin/mbr_classify_del.php

   $restrictInDemo = true;
   require_once("../shared/logincheck.php");
   require_once("../classes/DmQuery.php");
+  require_once("../classes/CheckoutPrivsQuery.php");
   require_once("../functions/errorFuncs.php");
   require_once("../classes/Localize.php");
   $loc = new Localize(OBIB_LOCALE,$tab);
   $dmQ->connect();
   $dmQ->delete("mbr_classify_dm",$code);
   $dmQ->close();
+  
+  $checkoutPrivsQ = new CheckoutPrivsQuery();
+  $checkoutPrivsQ->connect();
+  $checkoutPrivsQ->delete_by_classification($code);
+  $checkoutPrivsQ->close();
 
   #**************************************************************************
   #*  Show success page

File admin/member_fields_del.php

   $restrictInDemo = true;
   require_once("../shared/logincheck.php");
   require_once("../classes/DmQuery.php");
+  require_once("../classes/MemberQuery.php");
   require_once("../functions/errorFuncs.php");
   require_once("../classes/Localize.php");
   $loc = new Localize(OBIB_LOCALE,$tab);
   $dmQ->delete("member_fields_dm",$code);
   $dmQ->close();
 
+  $memberQ = new MemberQuery();
+  $memberQ->connect();
+  $memberQ->deleteCustomField($code);
+  $dmQ->close();
+
   #**************************************************************************
   #*  Show success page
   #**************************************************************************

File classes/CheckoutPrivsQuery.php

                         $material_cd, $classification, $checkout_limit, $renewal_limit);
     $this->exec($sql);
   }
+  function delete_by_material_cd($code) {
+    $sql = $this->mkSQL("delete from checkout_privs where material_cd = %Q", $code);
+    $this->exec($sql);
+  }
+  function delete_by_classification($code) {
+    $sql = $this->mkSQL("delete from checkout_privs where classification = %Q", $code);
+    $this->exec($sql);
+  }
 }
 
 ?>

File classes/MaterialFieldQuery.php

            . $this->mkSQL('WHERE xref_id=%N ', $id);
     $this->exec($sql);
   }
+  function deleteCustomField($code) {
+    $sql = 'DELETE FROM material_usmarc_xref '
+           . $this->mkSQL('WHERE materialCd=%N ', $code);
+    $this->exec($sql);
+  }
 }
 
 ?>

File classes/UpgradeQuery.php

       '0.4.0' => '_upgrade040_e',
       '0.5.2' => '_upgrade052_e',
       '0.6.0' => '_upgrade060_e',
+      '0.7.0' => '_upgrade071_e',
     );
     $tmpPrfx = "obiblio_upgrade_";
     # FIXME - translate upgrade messages
     $notices = array();
     return array($notices, NULL);
   }
+  /* Upgrade 0.7.0 to 0.7.1 */
+  function _upgrade071_e($prfx, $tmpPrfx) {
+    # No new features, remove orphaned database rows (checkout privileges, custom fields).
+    $this->exec('delete '.$prfx.'checkout_privs from '.$prfx.'checkout_privs '
+                . 'left join '.$prfx.'mbr_classify_dm on '
+                . $prfx.'checkout_privs.classification='.$prfx.'mbr_classify_dm.code '
+                . 'where '.$prfx.'mbr_classify_dm.code is null ');
+    $this->exec('delete '.$prfx.'checkout_privs from '.$prfx.'checkout_privs '
+                . 'left join '.$prfx.'material_type_dm on '
+                . $prfx.'checkout_privs.material_cd='.$prfx.'material_type_dm.code '
+                . 'where '.$prfx.'material_type_dm.code is null ');
+    $this->exec('delete '.$prfx.'member_fields from '.$prfx.'member_fields '
+                . 'left join '.$prfx.'member_fields_dm on '
+                . $prfx.'member_fields.code='.$prfx.'member_fields_dm.code '
+                . 'where '.$prfx.'member_fields_dm.code is null ');
+    $this->exec('delete '.$prfx.'biblio_copy_fields from '.$prfx.'biblio_copy_fields '
+                . 'left join '.$prfx.'biblio_copy_fields_dm on '
+                . $prfx.'biblio_copy_fields.code='.$prfx.'biblio_copy_fields_dm.code '
+                . 'where '.$prfx.'biblio_copy_fields_dm.code is null ');
+    $this->exec('delete '.$prfx.'material_usmarc_xref from '.$prfx.'material_usmarc_xref '
+                . 'left join '.$prfx.'material_type_dm on '
+                . $prfx.'material_usmarc_xref.materialCd='.$prfx.'material_type_dm.code '
+                . 'where '.$prfx.'material_type_dm.code is null ');
+    $this->exec("update settings set version='0.7.1'");
+    $notices = array();
+    return array($notices, NULL);
+  }
 }
 
 ?>

File shared/global_constants.php

  ****************************************************************************
  */
 define("OBIB_CODE_VERSION","CVS");
-define("OBIB_LATEST_DB_VERSION","0.7.0");
+define("OBIB_LATEST_DB_VERSION","0.7.1");
 define("OBIB_DEFAULT_STATUS","in");
 define("OBIB_STATUS_IN","in");
 define("OBIB_STATUS_OUT","out");