protected function processDBData() { parent::processDBData(); $item_list = $this->getItemList('integer'); $instance_id = $this->app->getInstanceId(); // delete attached files using their dataobjects to remove the actual // files $sql = sprintf('select * from BlorgFile inner join BlorgPost on BlorgPost.id = BlorgFile.post where BlorgPost.instance %s %s and BlorgFile.post in (%s)', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $item_list); $files = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('BlorgFileWrapper')); foreach ($files as $file) { $file->setFileBase('../'); $file->delete(); } // delete the posts $sql = sprintf('delete from BlorgPost where instance %s %s and id in (%s)', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $item_list); $num = SwatDB::exec($this->app->db, $sql); if (isset($this->app->memcache)) { $this->app->memcache->flushNS('posts'); } $message = new SwatMessage(sprintf(Blorg::ngettext('One post has been deleted.', '%s posts have been deleted.', $num), SwatString::numberFormat($num))); $this->app->messages->add($message); }
protected function processDBData() { parent::processDBData(); $locale = SwatI18NLocale::get(); $relocate = true; $message = null; $delete_count = 0; $error_count = 0; $newsletters = $this->getNewsletters(); foreach ($newsletters as $newsletter) { // only allow deleting unsent newsletters. There is nothing // technically stopping us from deleting ones that have been sent, // but do this for the sake of stats until deleting sent newsletters // is required. if ($newsletter->isSent() == false) { $list = $this->getList($newsletter); $campaign_type = $newsletter->instance instanceof SiteInstance ? $newsletter->instance->shortname : null; $campaign = $newsletter->getCampaign($this->app, $campaign_type); $transaction = new SwatDBTransaction($this->app->db); try { // If not a draft, remove the resources. Don't delete draft // newsletter resources as they are shared across all // drafts. if ($newsletter->isScheduled()) { DeliveranceCampaign::removeResources($this->app, $campaign); } $list->deleteCampaign($campaign); $sql = 'delete from Newsletter where id = %s'; $sql = sprintf($sql, $this->app->db->quote($newsletter->id, 'integer')); $delete_count += SwatDB::exec($this->app->db, $sql); $transaction->commit(); } catch (DeliveranceAPIConnectionException $e) { $transaction->rollback(); $e->processAndContinue(); $error_count++; $relocate = false; } catch (Exception $e) { $transaction->rollback(); $e = new DeliveranceException($e); $e->processAndContinue(); $error_count++; $relocate = false; } } } if ($delete_count > 0) { $message = new SwatMessage(sprintf(Deliverance::ngettext('One newsletter has been deleted.', '%s newsletters have been deleted.', $delete_count), $locale->formatNumber($delete_count)), 'notice'); $this->app->messages->add($message); } if ($error_count > 0) { $message = new SwatMessage(Deliverance::_('There was an issue connecting to the email service ' . 'provider.'), 'error'); $message->content_type = 'text/xml'; $message->secondary_content = sprintf('<strong>%s</strong><br />%s', sprintf(Deliverance::ngettext('One newsletter has not been deleted.', '%s newsletters have not been deleted.', $error_count), $locale->formatNumber($error_count)), Deliverance::ngettext('Connection issues are typically short-lived and ' . 'attempting to delete the newsletter again after a ' . 'delay will usually be successful.', 'Connection issues are typically short-lived and ' . 'attempting to delete the newsletters again after a ' . 'delay will usually be successful.', $error_count)); } return $relocate; }
protected function processDBData() { parent::processDBData(); $sql = 'delete from CMEFrontMatter where id in (%s);'; $item_list = $this->getItemList('integer'); $sql = sprintf($sql, $item_list); $num = SwatDB::exec($this->app->db, $sql); $locale = SwatI18NLocale::get(); $message = new SwatMessage(sprintf(CME::ngettext('One CME front matter has been deleted.', '%s CME front matters have been deleted.', $num), $locale->formatNumber($num))); $this->app->messages->add($message); }
protected function processDBData() { parent::processDBData(); $sql = 'delete from Block where id in (%s)'; $item_list = $this->getItemList('integer'); $sql = sprintf($sql, $item_list); $num = SwatDB::exec($this->app->db, $sql); if ($num > 0) { $this->app->messages->add(new SwatMessage(Building::_('Content has been deleted.'))); } }
protected function processDBData() { parent::processDBData(); $instance_id = $this->app->getInstanceId(); $sql = 'delete from PinholePhotographer where id in (%s) and instance %s %s'; $item_list = $this->getItemList('integer'); $sql = sprintf($sql, $item_list, SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer')); $num = SwatDB::exec($this->app->db, $sql); $message = new SwatMessage(sprintf(Pinhole::ngettext('One photographer has been deleted.', '%s photographers have been deleted.', $num), SwatString::numberFormat($num))); $this->app->messages->add($message); }
protected function processDBData() { parent::processDBData(); $item_list = $this->getItemList('integer'); $sql = sprintf('delete from BlorgTag where id in (%s)', $item_list); $num = SwatDB::exec($this->app->db, $sql); if (isset($this->app->memcache)) { $this->app->memcache->flushNs('tags'); $this->app->memcache->flushNs('posts'); } $message = new SwatMessage(sprintf(Blorg::ngettext('One tag has been deleted.', '%s tags have been deleted.', $num), SwatString::numberFormat($num))); $this->app->messages->add($message); }
protected function processDBData() { AdminDBDelete::processDBData(); $instance_id = $this->app->getInstanceId(); $sql = sprintf('select parent from Article where id = %s and instance %s %s', $this->app->db->quote($this->getFirstItem(), 'integer'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer')); $this->parent_id = SwatDB::queryOne($this->app->db, $sql); $item_list = $this->getItemList('integer'); $sql = sprintf('delete from Article where id in (%s) and instance %s %s', $item_list, SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer')); $num = SwatDB::exec($this->app->db, $sql); $message = new SwatMessage(sprintf(Site::ngettext('One article has been deleted.', '%s articles have been deleted.', $num), SwatString::numberFormat($num))); $this->app->messages->add($message); }
protected function processDBData() { parent::processDBData(); $item_list = $this->getItemList('integer'); $instance_id = $this->app->getInstanceId(); $sql = sprintf('delete from BlorgAuthor where id in (%s) and instance %s %s', $item_list, SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer')); $num = SwatDB::exec($this->app->db, $sql); if (isset($this->app->memcache)) { $this->app->memcache->flushNs('authors'); $this->app->memcache->flushNs('posts'); } $message = new SwatMessage(sprintf(Blorg::ngettext('One author has been deleted.', '%s authors have been deleted.', $num), SwatString::numberFormat($num))); $this->app->messages->add($message); }
protected function processDBData() { parent::processDBData(); $photos = $this->getPhotos(); $num = count($photos); foreach ($photos as $photo) { $photo->setFileBase('../../photos'); $photo->delete(); } $message = new SwatMessage(sprintf(Pinhole::ngettext('One photo has been deleted.', '%s photos have been deleted.', $num), SwatString::numberFormat($num))); $this->app->messages->add($message); if (isset($this->app->memcache)) { $this->app->memcache->flushNs('photos'); } }
protected function processDBData() { parent::processDBData(); $sql = 'delete from PinholeTag where instance %s %s'; $item_list = $this->getItemList('integer'); $instance_id = $this->app->getInstanceId(); $sql = sprintf($sql, SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer')); if (!$this->extended_selected) { $sql .= sprintf(' and id in (%s)', $item_list); } $num = SwatDB::exec($this->app->db, $sql); if (isset($this->app->memcache)) { $this->app->memcache->flushNs('photos'); } $message = new SwatMessage(sprintf(Pinhole::ngettext('One tag has been deleted.', '%s tags have been deleted.', $num), SwatString::numberFormat($num))); $this->app->messages->add($message); }
protected function processDBData() { parent::processDBData(); $item_list = $this->getItemList('integer'); $instance_id = $this->app->getInstanceId(); $this->addToSearchQueue($item_list); $sql = sprintf('delete from BlorgComment where id in (select BlorgComment.id from BlorgComment inner join BlorgPost on BlorgPost.id = BlorgComment.post where instance %s %s and BlorgComment.id in (%s))', SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $item_list); $num = SwatDB::exec($this->app->db, $sql); if (isset($this->app->memcache)) { $this->app->memcache->flushNS('posts'); } $message = new SwatMessage(sprintf(Blorg::ngettext('One comment has been deleted.', '%s comments have been deleted.', $num), SwatString::numberFormat($num))); $this->app->messages->add($message); }