'; _e("Note: Because changing this option will move this page, after changing it you will be presented with an error. Just click ‘back’ and then navigate to the 'Manage » Addressbook' or 'Options » Addressbook' tab."); echo '

'; } ?>

'.__(Yes); ?> '.__(No); ?>

prefix."addressbook SET organisation = '".$wpdb->escape($_POST['organisation'])."', first_name = '".$wpdb->escape($_POST['first_name'])."', surname = '".$wpdb->escape($_POST['surname'])."', email = '".$wpdb->escape($_POST['email'])."', website = '".$wpdb->escape($_POST['website'])."', address_line1 = '".$wpdb->escape($_POST['address_line1'])."', address_line2 = '".$wpdb->escape($_POST['address_line2'])."', suburb = '".$wpdb->escape($_POST['suburb'])."', postcode = '".$wpdb->escape($_POST['postcode'])."', state = '".$wpdb->escape($_POST['state'])."', country = '".$wpdb->escape($_POST['country'])."', phone = '".$wpdb->escape($_POST['phone'])."', notes = '".$wpdb->escape($_POST['notes'])."'"; $wpdb->query($sql); ?>

. »

prefix."addressbook WHERE id='".$wpdb->escape($_GET['id'])."'"; $row = $wpdb->get_row($sql); if ($_GET['confirm']=='yes') { $wpdb->query("DELETE FROM ".$wpdb->prefix."addressbook WHERE id='".$wpdb->escape($_GET['id'])."'"); echo '

'.__('The address has been deleted.').' '.__('Continue').' »

'; } else { echo "

".__('Are you sure you want to delete the following address?')."

".stripslashes($row->first_name." ".$row->surname)."
".stripslashes($row->organisation)."
".stripslashes($row->email." ".$row->phone)."
".stripslashes($row->address_line1)."
".stripslashes($row->address_line2)."
".stripslashes($row->suburb." ".$row->postcode)."
".stripslashes($row->state)."
".stripslashes($row->country)."
".__('Notes:')." ".stripslashes($row->notes)."

".__('[Yes]')."      ".__('[No]')."

"; } } else if ($_GET['action']=='edit') { $sql = "SELECT * FROM ".$wpdb->prefix."addressbook WHERE id='".$wpdb->escape($_GET['id'])."'"; $row = $wpdb->get_row($sql); if ($_POST['save']) { $wpdb->query("UPDATE ".$wpdb->prefix."addressbook SET first_name = '".$wpdb->escape($_POST['first_name'])."', surname = '".$wpdb->escape($_POST['surname'])."', organisation = '".$wpdb->escape($_POST['organisation'])."', email = '".$wpdb->escape($_POST['email'])."', phone = '".$wpdb->escape($_POST['phone'])."', address_line1 = '".$wpdb->escape($_POST['address_line1'])."', address_line2 = '".$wpdb->escape($_POST['address_line2'])."', suburb = '".$wpdb->escape($_POST['suburb'])."', postcode = '".$wpdb->escape($_POST['postcode'])."', state = '".$wpdb->escape($_POST['state'])."', country = '".$wpdb->escape($_POST['country'])."', notes = '".$wpdb->escape($_POST['notes'])."', website = '".$wpdb->escape($_POST['website'])."' WHERE id ='".$wpdb->escape($_GET['id'])."'"); echo '

'.__('The address has been updated.').' '.__('Continue').' »

'; } else { ?>

prefix."addressbook"; If ($wpdb->get_var("SHOW TABLES LIKE '$table_name'")!=$table_name || get_option("addressbook_version")!=$addressbook_version ) { // Call the install function here rather than through the more usual // activate_blah.php action hook so the user doesn't have to worry about // deactivating then reactivating the plugin. Should happen seemlessly. _addressbook_install(); print('

'); printf('The Addressbook plugin (version %s) has been installed or upgraded.', get_option("addressbook_version")); print('

'); } ?>

Addressbook plugin."), get_option("addressbook_version")); echo '
'; _e("Please report any bugs and feature requests at samwilson.id.au/plugins/addressbook."); echo '
'.__('Thankyou.'); ?>


'.__('Name').''; ?> prefix."addressbook WHERE first_name LIKE '%".$wpdb->escape($_GET['q'])."%' OR surname LIKE '%".$wpdb->escape($_GET['q'])."%' OR organisation LIKE '%".$wpdb->escape($_GET['q'])."%' OR email LIKE '%".$wpdb->escape($_GET['q'])."%' OR phone LIKE '%".$wpdb->escape($_GET['q'])."%' OR notes LIKE '%".$wpdb->escape($_GET['q'])."%' ORDER BY first_name"; } else { $sql = "SELECT * FROM ".$wpdb->prefix."addressbook ORDER BY first_name"; } $results = $wpdb->get_results($sql); foreach ($results as $row) { echo""; } ?>
'.__('Organisation').''.__('Email address').''.__('Phone number').'
".stripslashes($row->first_name." ".$row->surname)."  ".stripslashes($row->organisation)." ".stripslashes($row->email)." ".stripslashes($row->phone)."
id."-info' style='display:none'>

".__('[Edit]')." ".__('[Delete]')."

".stripslashes($row->first_name." ".$row->surname)." (".stripslashes($row->organisation).")
".stripslashes($row->email)." ".stripslashes($row->phone)."

"; echo "

"; if (!empty($row->notes)) { echo "".__('Notes:')." ".stripslashes($row->notes); } echo "

".stripslashes($row->address_line1)."
"; if ($row->address_line2) echo stripslashes($row->address_line2)."
"; echo stripslashes($row->suburb." ".$row->postcode); echo "
"; echo stripslashes($row->state)."
"; echo stripslashes($row->country)."
"; echo "".stripslashes($row->website)."

"; echo "
"; } ?>

Add Address

website; $out = '
'; return $out; } function _addressbook_install() { global $wpdb, $addressbook_version; $table_name = $wpdb->prefix."addressbook"; $sql = "CREATE TABLE " . $table_name . " ( id mediumint(9) NOT NULL AUTO_INCREMENT, first_name tinytext NOT NULL, surname tinytext NOT NULL, organisation tinytext NOT NULL, email tinytext NOT NULL, phone tinytext NOT NULL, address_line1 tinytext NOT NULL, address_line2 tinytext NOT NULL, suburb tinytext NOT NULL, postcode tinytext NOT NULL, state tinytext NOT NULL, country tinytext NOT NULL, website VARCHAR(55) NOT NULL, notes tinytext NOT NULL, PRIMARY KEY (id) );"; require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); dbDelta($sql); update_option('addressbook_version', $addressbook_version); } /** * For other plugins, etc., to use. */ function addressbook_getselect($name, $sel_id=false) { global $wpdb; $out = ""; return $out; } /** * For other plugins, etc., to use. */ function addressbook_getIdFromEmail($email) { global $wpdb; $sql = "SELECT id FROM ".$wpdb->prefix."addressbook where email='".$wpdb->escape($email)."'"; $res = $wpdb->get_var($sql); return $res; } /** * For other plugins, etc., to use. */ function addressbook_getFullnameFromId($id) { global $wpdb; $sql = "SELECT CONCAT(first_name,' ',surname) FROM ".$wpdb->prefix."addressbook WHERE id='".$wpdb->escape($id)."'"; $res = $wpdb->get_var($sql); return $res; } add_filter('the_content', 'addressbook_list'); function addressbook_list($content) { global $wpdb; $sql = "SELECT * FROM ".$wpdb->prefix."addressbook ORDER BY first_name"; $results = $wpdb->get_results($sql); $out = "
    \n\n"; foreach ($results as $row) { $out .= "
  1. \n". " ". addressbook_getIfNotEmpty(" %s\n", stripslashes($row->first_name." ".$row->surname)). addressbook_getIfNotEmpty(" %s\n", stripslashes($row->organisation)). addressbook_getIfNotEmpty(" \n", stripslashes($row->email)). addressbook_getIfNotEmpty(" %s\n", stripslashes($row->phone)). addressbook_getIfNotEmpty(" %1\$s\n", stripslashes($row->website)); if (!empty($row->address_line1) || !empty($row->suburb) || !empty($row->postcode) || !empty($row->state) || !empty($row->country)) { $out .= "
    \n"; if (!empty($row->address_line1) || !empty($row->address_line2)) { $out .= " \n". addressbook_getIfNotEmpty(" %s\n", stripslashes($row->address_line1)). addressbook_getIfNotEmpty(" %s\n", stripslashes($row->address_line2)). " \n"; } $out .= addressbook_getIfNotEmpty(" %s\n", stripslashes($row->suburb)). addressbook_getIfNotEmpty(" %s\n", stripslashes($row->postcode)). addressbook_getIfNotEmpty(" %s\n", stripslashes($row->state)). addressbook_getIfNotEmpty(" %s\n", stripslashes($row->country)). "
    \n"; } $out .= addressbook_getIfNotEmpty("
    %s\n
    \n", stripslashes($row->notes)); $out .= "
  2. \n\n"; } $out .= "
\n"; return preg_replace("/|.*<\/addressbook>/", $out, $content); } function addressbook_getIfNotEmpty($format,$var) { if (!empty($var)) { return sprintf($format, $var); } } ?>