daily pastebin goal
8%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public function expireFeedImages(AgaviRequestDataHolder $rd)
  2.     {
  3.         $feed_images_module = new Exo_CMS_Module();
  4.         $feed_images_module = $this->getContext()->getModel('Exo_CMS_ModuleFinder')->getModule("feed_images");
  5.         $feed_images_field_id = $feed_images_module->getInputElement("id");
  6.  
  7.         $con = Propel::getConnection();
  8.         $candidates = $con->prepare("SELECT i.id, i.language".
  9.             " FROM feed_images i LEFT JOIN feed_images_feeds fi ON i.id=fi.feed_images_id".
  10.             " WHERE fi.feed_images_id IS NULL");
  11.  
  12.         try
  13.         {
  14.             $state_deleted = Exo_CMS_ModuleEntry::STATE_DELETED;
  15.  
  16.             $con->beginTransaction();
  17.             $candidates->execute();
  18.             $candidates->setFetchMode(PDO::FETCH_NUM);
  19.             foreach ($candidates as $row)
  20.             {
  21.                 $image = $feed_images_module->loadEntry($row[0], $row[1]);
  22.                 if ($image)
  23.                 {
  24.                     $values = array("image" => array("delete_binary" => 1));
  25.                     $image->hydrate($values);
  26.                     $image->store();
  27.                     $image->delete();
  28.                     exit;
  29.                 }
  30.             }
  31.             $candidates->closeCursor();
  32.  
  33.             $stmnt = $con->prepare("DELETE cms_history".
  34.                 " FROM feed_images, cms_history".
  35.                 " WHERE feed_images.state=:STATE".
  36.                 " AND feed_images.id=cms_history.object_id");
  37.             $stmnt->bindParam(":STATE", $state_deleted, PDO::PARAM_INT);
  38.             $stmnt->execute();
  39.             $stmnt->closeCursor();
  40.  
  41.             $stmnt = $con->prepare("DELETE cms_id_sequence".
  42.                 " FROM feed_images, cms_id_sequence".
  43.                 " WHERE feed_images.state=:STATE".
  44.                 " AND feed_images.id=cms_id_sequence.id");
  45.             $stmnt->bindParam(":STATE", $state_deleted, PDO::PARAM_INT);
  46.             $stmnt->execute();
  47.             $stmnt->closeCursor();
  48.  
  49.             $stmnt = $con->prepare("DELETE FROM feed_images WHERE feed_images.state=:STATE");
  50.             $stmnt->bindParam(":STATE", $state_deleted, PDO::PARAM_INT);
  51.             $stmnt->execute();
  52.             $stmnt->closeCursor();
  53.  
  54.             $con->commit();
  55.         }
  56.         catch(Exception $e)
  57.         {
  58.             $con->rollBack();
  59.             throw $e;
  60.         }
  61.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top