コード例 #1
0
ファイル: purgedeleted.php プロジェクト: nemein/openpsa
 public function _on_execute()
 {
     debug_add('called!');
     $cut_off = mktime(23, 59, 59, date('n'), date('j') - $GLOBALS['midcom_config']['cron_purge_deleted_after'], date('Y'));
     foreach (midcom_connection::get_schema_types() as $mgdschema) {
         if (substr($mgdschema, 0, 2) == '__') {
             continue;
         }
         debug_add("Processing class {$mgdschema}");
         $qb = new midgard_query_builder($mgdschema);
         $qb->add_constraint('metadata.deleted', '<>', 0);
         $qb->add_constraint('metadata.revised', '<', gmdate('Y-m-d H:i:s', $cut_off));
         $qb->include_deleted();
         $qb->set_limit(500);
         $objects = $qb->execute();
         unset($qb);
         if (!is_array($objects)) {
             debug_add("QB failed fatally on class {$mgdschema}, errstr: " . midcom_connection::get_error_string(), MIDCOM_LOG_ERROR);
             continue;
         }
         $found = count($objects);
         $purged = 0;
         foreach ($objects as $obj) {
             if (!$obj->purge()) {
                 debug_add("Failed to purge {$mgdschema} {$obj->guid}, deleted: {$obj->metadata->deleted},  revised: {$obj->metadata->revised}. errstr: " . midcom_connection::get_error_string(), MIDCOM_LOG_ERROR);
                 debug_print_r('Failed object', $obj);
                 continue;
             }
             $purged++;
         }
         if ($found > 0) {
             debug_add("Found {$found} {$mgdschema} objects deleted before " . date('Y-m-d H:i:s', $cut_off) . ", purged {$purged}", MIDCOM_LOG_INFO);
         } else {
             debug_add("No {$mgdschema} objects deleted before " . date('Y-m-d H:i:s', $cut_off) . " found");
         }
     }
 }
コード例 #2
0
ファイル: type.php プロジェクト: nemein/openpsa
 private function _prepare_toolbar(&$data)
 {
     if (midcom::get('auth')->can_user_do('midgard:create', null, $this->type)) {
         $data['asgard_toolbar']->add_item(array(MIDCOM_TOOLBAR_URL => "__mfa/asgard/object/create/{$this->type}/", MIDCOM_TOOLBAR_LABEL => sprintf(midcom::get('i18n')->get_string('create %s', 'midcom'), midgard_admin_asgard_plugin::get_type_label($this->type)), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/' . midcom_helper_reflector_tree::get_create_icon($this->type)));
     }
     if (midcom::get('auth')->admin) {
         $qb = new midgard_query_builder($this->type);
         $qb->include_deleted();
         $qb->add_constraint('metadata.deleted', '=', true);
         $deleted = $qb->count();
         if ($deleted > 0) {
             $data['asgard_toolbar']->add_item(array(MIDCOM_TOOLBAR_URL => "__mfa/asgard/trash/{$this->type}/", MIDCOM_TOOLBAR_LABEL => sprintf(midcom::get('i18n')->get_string('%s deleted items', 'midgard.admin.asgard'), $deleted), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/trash-full.png'));
         } else {
             $data['asgard_toolbar']->add_item(array(MIDCOM_TOOLBAR_URL => "__mfa/asgard/trash/{$this->type}/", MIDCOM_TOOLBAR_LABEL => midcom::get('i18n')->get_string('trash is empty', 'midgard.admin.asgard'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/trash.png'));
         }
     }
     if ($data['component'] != 'midgard') {
         $data['asgard_toolbar']->add_item(array(MIDCOM_TOOLBAR_URL => "__mfa/asgard/components/{$data['component']}/", MIDCOM_TOOLBAR_LABEL => midcom::get('i18n')->get_string($data['component'], $data['component']), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/component.png'));
     }
     $data['asgard_toolbar']->add_item(array(MIDCOM_TOOLBAR_URL => "__ais/help/{$data['documentation_component']}/mgdschemas/#{$this->type}", MIDCOM_TOOLBAR_LABEL => midcom::get('i18n')->get_string('type documentation', 'midgard.admin.asgard'), MIDCOM_TOOLBAR_OPTIONS => array('target' => '_blank'), MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_help-agent.png'));
 }
コード例 #3
0
ファイル: dbobject.php プロジェクト: nemein/openpsa
 /**
  * Purge the attachments related to a deleted object
  *
  * @param string $guid
  * @return boolean Indicating success
  */
 public static function purge_attachments($guid)
 {
     $purged_size = 0;
     $qb = new midgard_query_builder('midgard_attachment');
     $qb->include_deleted();
     $qb->add_constraint('parentguid', '=', $guid);
     $atts = $qb->execute();
     foreach ($atts as $att) {
         if (!$att->metadata->deleted) {
             $att->delete();
         }
         if ($att->purge()) {
             $purged_size += $att->metadata->size;
             self::purge_parameters($att->guid);
         } else {
             midcom::get('uimessages')->add(midcom::get('i18n')->get_string('midgard.admin.asgard', 'midgard.admin.asgard'), sprintf(midcom::get('i18n')->get_string('failed purging attachment %s => %s, reason %s', 'midgard.admin.asgard'), $att->guid, $att->name, midcom_connection::get_error_string()), 'error');
         }
     }
     return $purged_size;
 }
コード例 #4
0
ファイル: undelete.php プロジェクト: nemein/openpsa
 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');
     }
 }
コード例 #5
0
ファイル: main.php プロジェクト: nemein/openpsa
 /**
  * Get an object, deleted or not
  *
  * @param string $guid    GUID of the object
  * @param string $type    MgdSchema type
  * @return mixed          MgdSchema object
  */
 public static function get_object($guid, $type)
 {
     static $objects = array();
     if (!isset($objects[$guid])) {
         $qb = new midgard_query_builder($type);
         $qb->add_constraint('guid', '=', $guid);
         // We know we want/need only one result
         $qb->set_limit(1);
         $qb->include_deleted();
         $results = $qb->execute();
         if (count($results) == 0) {
             $objects[$guid] = null;
         } else {
             $objects[$guid] = $results[0];
         }
     }
     return $objects[$guid];
 }
コード例 #6
0
ファイル: purge_deleted.php プロジェクト: nemein/openpsa
 if ($mgdschema == '__midgard_cache') {
     continue;
 }
 echo "<h2>Processing class {$mgdschema}</h2>";
 flush();
 $total = 0;
 $purged = 0;
 $failed_guids = array();
 do {
     $qb = new midgard_query_builder($mgdschema);
     $qb->add_constraint('metadata.deleted', '<>', 0);
     if (!empty($failed_guids)) {
         $qb->add_constraint('guid', 'NOT IN', $failed_guids);
     }
     $qb->add_constraint('metadata.revised', '<', gmdate('Y-m-d H:i:s', $cut_off));
     $qb->include_deleted();
     $qb->set_limit($chunk_size);
     $objects = $qb->execute();
     unset($qb);
     if (!is_array($objects)) {
         echo "FATAL QB ERROR\n";
         continue;
     }
     $total += count($objects);
     foreach ($objects as $obj) {
         if (!$obj->purge()) {
             echo "ERROR: Failed to purge <tt>{$obj->guid}</tt>, deleted: {$obj->metadata->deleted},  revised: {$obj->metadata->revised}. errstr: " . midcom_connection::get_error_string() . "\n";
             $failed_guids[] = $obj->guid;
             continue 1;
         }
         $purged++;