示例#1
0
 /**
  * Import midgard_blob unserialized with midgard_replicator::unserialize()
  *
  * This method does ACL checks and triggers watchers etc.
  *
  * @param midgard_blob $unserialized_object midgard_blob gotten from midgard_replicator::unserialize()
  * @param string $xml XML the midgard_blob was unserialized from
  * @param boolean $use_force set use of force for the midcom_helper_replicator_import_from_xml() call
  * @return boolean indicating success/failure
  */
 function import_blob(&$unserialized_object, &$xml, $use_force = false)
 {
     if (!is_a($unserialized_object, 'midgard_blob')) {
         debug_add("You should use the *import* method to import normal objects, passing control there", MIDCOM_LOG_WARNING);
         return $this->import($unserialized_object, $use_force);
     }
     // We need this helper (workaround Zend bug)
     if (!function_exists('midcom_helper_replicator_import_object')) {
         midcom::get('componentloader')->load('midcom.helper.replicator');
     }
     try {
         $acl_object = midcom::get('dbfactory')->get_object_by_guid($unserialized_object->parentguid);
     } catch (midcom_error $e) {
         debug_add("Could not get parent object (GUID: {$unserialized_object->parentguid}), aborting", MIDCOM_LOG_ERROR);
         return false;
     }
     // midgard_blob has no action, update is the best check for allowing import of blob data
     if (!midcom_baseclasses_core_dbobject::update_pre_checks($acl_object)) {
         $parent_class = get_class($acl_object);
         debug_add("parent ({$parent_class} {$acl_object->guid}) update pre-flight check returned false", MIDCOM_LOG_ERROR);
         return false;
     }
     // Actual import
     // NOTE: midgard_replicator::import_from_xml returns void, which evaluates to false, check midcom_connection::get_error instead
     midcom_helper_replicator_import_from_xml($xml, $use_force);
     if (midcom_connection::get_error() !== MGD_ERR_OK) {
         debug_add('midcom_helper_replicator_import_from_xml returned false, errstr: ' . midcom_connection::get_error_string(), MIDCOM_LOG_ERROR);
         return false;
     }
     // Trigger parent updated
     midcom_baseclasses_core_dbobject::update_post_ops($acl_object);
     // And also imported
     midcom::get('componentloader')->trigger_watches(MIDCOM_OPERATION_DBA_IMPORT, $acl_object);
     return true;
 }
示例#2
0
文件: fetch.php 项目: nemein/openpsa
 /**
  * Cleans up old, removed items from feeds
  * @param Array $item Feed item as provided by MagpieRSS
  */
 function clean($items)
 {
     if ($this->_feed->keepremoved) {
         // This feed is set up so that we retain items removed from array
         return false;
     }
     // Create array of item GUIDs
     $item_guids = array();
     foreach ($items as $item) {
         $item_guids[] = $item['guid'];
     }
     // Find articles resulting from this feed
     $qb = midcom_db_article::new_query_builder();
     $feed_category = md5($this->_feed->url);
     $qb->add_constraint('extra1', 'LIKE', "%|feed:{$feed_category}|%");
     $local_items = $qb->execute_unchecked();
     $guid_property = $this->_guid_property;
     $purge_guids = array();
     foreach ($local_items as $item) {
         if (!in_array($item->{$guid_property}, $item_guids)) {
             // This item has been removed from the feed.
             if (midcom::get('componentloader')->is_installed('net.nemein.favourites') && midcom::get('componentloader')->load_graceful('net.nemein.favourites')) {
                 // If it has been favorited keep it
                 $qb = net_nemein_favourites_favourite_dba::new_query_builder();
                 $qb->add_constraint('objectGuid', '=', $item->guid);
                 if ($qb->count_unchecked() > 0) {
                     continue;
                     // Skip deleting this one
                 }
             }
             $purge_guids[] = $item->guid;
             $item->delete();
         }
     }
     midcom_baseclasses_core_dbobject::purge($purge_guids, 'midgard_article');
     return true;
 }
示例#3
0
 private function _undelete()
 {
     //TODO: This variable is unused
     static $undeleted_size = 0;
     if (!$this->_request_data['midcom_dba_classname']) {
         // No DBA class for the type, use plain Midgard undelete API
         foreach ($_POST['undelete'] as $guid) {
             $qb = new midgard_query_builder($this->type);
             $qb->add_constraint('guid', '=', $guid);
             $qb->include_deleted();
             $results = $qb->execute();
             foreach ($results as $object) {
                 $object->undelete();
             }
         }
     } else {
         // Delegate undeletion to DBA
         midcom_baseclasses_core_dbobject::undelete($_POST['undelete'], $this->type);
     }
     if ($undeleted_size > 0) {
         midcom::get('uimessages')->add($this->_l10n->get('midgard.admin.asgard'), sprintf($this->_l10n->get('in total %s undeleted'), midcom_helper_misc::filesize_to_string($undeleted_size)), 'info');
     }
 }
示例#4
0
 public function update()
 {
     return midcom_baseclasses_core_dbobject::update($this);
 }