/** * Called on plugin activation and upgrading. * * @see register_activation_hook */ function openid_activate_plugin() { global $nxt_rewrite; // if first time activation, set OpenID capability for administrators if (get_option('openid_plugin_revision') === false) { global $nxt_roles; $role = $nxt_roles->get_role('administrator'); if ($role) { $role->add_cap('use_openid_provider'); } } // for some reason, show_on_front is not always set, causing is_front_page() to fail $show_on_front = get_option('show_on_front'); if (empty($show_on_front)) { update_option('show_on_front', 'posts'); } // Add custom OpenID options add_option('openid_enable_commentform', true); add_option('openid_plugin_enabled', true); add_option('openid_plugin_revision', 0); add_option('openid_db_revision', 0); add_option('openid_enable_approval', false); add_option('openid_xrds_returnto', true); add_option('openid_comment_displayname_length', 12); openid_create_tables(); openid_migrate_old_data(); // setup schedule cleanup nxt_clear_scheduled_hook('cleanup_openid'); nxt_schedule_event(time(), 'hourly', 'cleanup_openid'); // flush rewrite rules if (!isset($nxt_rewrite)) { $nxt_rewrite = new nxt_Rewrite(); } $nxt_rewrite->flush_rules(); // set current revision update_option('openid_plugin_revision', OPENID_PLUGIN_REVISION); openid_remove_historical_options(); }
/** * Check to see whether the nonce, association, and identity tables exist. * * @param bool $retry if true, tables will try to be recreated if they are not okay * @return bool if tables are okay */ function openid_check_tables($retry=true) { global $wpdb; $ok = true; $message = array(); $tables = array( openid_identity_table(), ); foreach( $tables as $t ) { if( $wpdb->get_var("SHOW TABLES LIKE '$t'") != $t ) { $ok = false; $message[] = "Table $t doesn't exist."; } else { $message[] = "Table $t exists."; } } if( $retry and !$ok) { openid_create_tables(); $ok = openid_check_tables( false ); } return $ok; }
/** * Called on plugin activation. * * @see register_activation_hook */ function openid_activate_plugin() { // if first time activation, set OpenID capability for administrators if (get_option('openid_plugin_revision') === false) { global $wp_roles; $role = $wp_roles->get_role('administrator'); if ($role) { $role->add_cap('use_openid_provider'); } } // Add custom OpenID options add_option('openid_enable_commentform', true); add_option('openid_plugin_enabled', true); add_option('openid_plugin_revision', 0); add_option('openid_db_revision', 0); add_option('openid_enable_approval', false); add_option('openid_enable_email_mapping', false); add_option('openid_xrds_returnto', true); add_option('openid_xrds_idib', true); add_option('openid_xrds_eaut', true); openid_create_tables(); openid_migrate_old_data(); wp_schedule_event(time(), 'hourly', 'cleanup_openid'); // cleanup old option names delete_option('oid_db_revision'); delete_option('oid_db_version'); delete_option('oid_enable_approval'); delete_option('oid_enable_commentform'); delete_option('oid_enable_email_mapping'); delete_option('oid_enable_foaf'); delete_option('oid_enable_localaccounts'); delete_option('oid_enable_loginform'); delete_option('oid_enable_selfstyle'); delete_option('oid_enable_unobtrusive'); delete_option('oid_plugin_enabled'); delete_option('oid_plugin_revision'); delete_option('oid_plugin_version'); delete_option('oid_trust_root'); }
function openid_user_update($openid, $sreg) { openid_create_tables(); theDb()->query('INSERT IGNORE INTO eb_users (oid) values (?)', array($openid)); foreach (array('nickname', 'fullname', 'email') as $key) { if (array_key_exists($key, $sreg)) { theDb()->query("UPDATE eb_users SET {$key}=? WHERE oid=?", array($sreg[$key], $openid)); } } $user =& theDb()->getRow('SELECT * FROM eb_users WHERE oid=?', array($openid)); if (!strlen($user["nickname"])) { $user["nickname"] = $user["fullname"]; } if (!strlen($user["nickname"])) { $user["nickname"] = $user["email"]; } if (!strlen($user["nickname"])) { $user["nickname"] = substr(md5($openid), 0, 8); } $_SESSION["user"] = $user; }
<?php include "lib/setup.php"; include "lib/openid.php"; evidence_create_tables(); openid_create_tables(); if ($_REQUEST["test-insert"]) { if (!getCurrentUser("is_admin")) { die("yours is not an admin account."); } header("Content-type: text/plain"); $variant_id = evidence_get_variant_id("NPHP4", 848, "Arg", "Trp", true); $e = evidence_edit_id_generate(null, $variant_id); evidence_save_draft($e, array("variant_impact" => "unknown", "variant_dominance" => "unknown", "summary_short" => "This variant has been found together with R682X as a compound heterozygote in three nephronophthisis and retinitis pigmentosa, (Senior-Loken syndrome) patients from one family.")); print "after evidence_save_draft\n"; print_r(theDb()->getRow("SELECT * FROM edits WHERE edit_id=?", array($e))); evidence_submit($e); print "after evidence_submit\n"; print_r(evidence_get_report("latest", $variant_id)); evidence_signoff($e); $a = evidence_edit_id_generate(null, $variant_id); evidence_save_draft($a, array("article_pmid" => 12205563, "summary_short" => "Otto, E. et al. A gene mutated in nephronophthisis and retinitis pigmentosa encodes a novel protein, nephroretinin, conserved in evolution. Am J Hum Genet 71, 1161-1167, doi:S0002-9297(07)60408-X [pii]")); evidence_submit($a); evidence_signoff($a); $a = evidence_edit_id_generate(null, $variant_id); evidence_save_draft($a, array("article_pmid" => 9734597, "summary_short" => "Lemmink, H. H. et al. Novel mutations in the thiazide-sensitive NaCl cotransporter gene in patients with Gitelman syndrome with predominant localization to the C-terminal domain. Kidney Int 54, 720-730, doi:10.1046/j.1523-1755.1998.00070.x (1998).")); evidence_submit($a); print "release:\n"; print_r(evidence_get_report("release", $variant_id)); print "latest:\n"; print_r(evidence_get_report("latest", $variant_id));