1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <?php
- $items = elgg_get_entities(array(
- 'type' => 'user',
- 'limit' => 5,
- 'order_by' => 'e.time_created asc',
- ));
- if (!$items) {
- return;
- }
- $local_version = (int)elgg_get_plugin_setting('version', 'elggpg');
- if (2012022501 <= $local_version) {
- error_log("ElggPG requires no upgrade");
-
- return;
- }
- global $MIGRATED;
- $MIGRATED = 0;
- function elggpg_2012022501($user) {
-
- global $MIGRATED;
- $MIGRATED += 1;
- if ($MIGRATED % 100 == 0) {
- error_log(" * elggpg $user->guid");
- }
- elgg_load_library('elggpg');
- $user_fp = current(elgg_get_metadata(array(
- 'guid' => $user->guid,
- 'metadata_name' => 'openpgp_publickey',
- )));
- $gnupg = new gnupg();
- if (!$user_fp && $user->email) {
- try {
- $info = $gnupg->keyinfo($user->email);
- $fingerprint = $info[0]['subkeys'][0]['fingerprint'];
- if ($fingerprint) {
- create_metadata($user->guid, "openpgp_publickey", $fingerprint, 'text', $user->guid, ACCESS_LOGGEDIN);
- }
- }
- catch (Exception $e) {
-
- }
- }
- return true;
- }
- $previous_access = elgg_set_ignore_access(true);
- $options = array(
- 'type' => 'user',
- 'limit' => 0,
- );
- $batch = new ElggBatch('elgg_get_entities', $options, 'elggpg_2012022501', 100);
- elgg_set_ignore_access($previous_access);
- if ($batch->callbackResult) {
- error_log("Elgg elggpg upgrade (2012022501) succeeded");
- elgg_set_plugin_setting('version', 2012022501, 'elggpg');
- } else {
- error_log("Elgg elggpg upgrade (2012022501) failed");
- }
|