aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-10-18 20:59:00 -0700
committerfriendica <info@friendica.com>2012-10-18 20:59:00 -0700
commit2c3c933ed4cf6846c0240f576082da2deda5a25a (patch)
tree1d58de4e19906f40dcf4f1cef1d3fecddd1c1a70
parent0b37d4efd69de4306bb27de8d19090c5f1149abc (diff)
downloadvolse-hubzilla-2c3c933ed4cf6846c0240f576082da2deda5a25a.tar.gz
volse-hubzilla-2c3c933ed4cf6846c0240f576082da2deda5a25a.tar.bz2
volse-hubzilla-2c3c933ed4cf6846c0240f576082da2deda5a25a.zip
get profile edits working
-rw-r--r--database.sql4
-rw-r--r--include/identity.php8
-rw-r--r--mod/profiles.php44
3 files changed, 28 insertions, 28 deletions
diff --git a/database.sql b/database.sql
index c096c0f12..d88782a50 100644
--- a/database.sql
+++ b/database.sql
@@ -18,6 +18,7 @@ CREATE TABLE IF NOT EXISTS `abook` (
`updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`connnected` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`abook_flags` int(11) NOT NULL DEFAULT '0',
+ `abook_profile` char(64) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
@@ -724,6 +725,7 @@ CREATE TABLE IF NOT EXISTS `photo` (
CREATE TABLE IF NOT EXISTS `profile` (
`id` int(11) NOT NULL AUTO_INCREMENT,
+ `profile_guid` char(64) NOT NULL DEFAULT '',
`aid` int(10) unsigned NOT NULL DEFAULT '0',
`uid` int(11) NOT NULL,
`profile_name` char(255) NOT NULL,
@@ -765,6 +767,7 @@ CREATE TABLE IF NOT EXISTS `profile` (
`thumb` char(255) NOT NULL,
`publish` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
+ UNIQUE KEY `guid` (`profile_guid`,`uid`),
KEY `uid` (`uid`),
KEY `locality` (`locality`),
KEY `hometown` (`hometown`),
@@ -777,6 +780,7 @@ CREATE TABLE IF NOT EXISTS `profile` (
KEY `hide_friends` (`hide_friends`),
KEY `postal_code` (`postal_code`),
KEY `country_name` (`country_name`),
+ KEY `profile_guid` (`profile_guid`),
FULLTEXT KEY `pub_keywords` (`pub_keywords`),
FULLTEXT KEY `prv_keywords` (`prv_keywords`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
diff --git a/include/identity.php b/include/identity.php
index d8eb42ae7..ac033edf4 100644
--- a/include/identity.php
+++ b/include/identity.php
@@ -110,10 +110,11 @@ function create_identity($arr) {
$newuid = $ret['channel']['channel_id'];
- $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_photo, xchan_addr, xchan_profile, xchan_name, xchan_network, xchan_photo_date, xchan_name_date ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
+ $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo, xchan_addr, xchan_profile, xchan_name, xchan_network, xchan_photo_date, xchan_name_date ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
dbesc($hash),
dbesc($ret['channel']['channel_guid']),
dbesc($sig),
+ dbesc($key['pubkey']),
dbesc($a->get_baseurl() . "/photo/profile/{$newuid}"),
dbesc($ret['channel']['channel_address'] . '@' . $a->get_hostname()),
dbesc(z_root() . '/profile/' . $ret['channel']['channel_address']),
@@ -127,10 +128,11 @@ function create_identity($arr) {
// It's ok for this to fail if it's an imported channel, and therefore the hash is a duplicate
- $r = q("INSERT INTO `profile` ( `aid`, `uid`, `profile_name`, `is_default`, `name`, `photo`, `thumb`)
- VALUES ( %d, %d, '%s', %d, '%s', '%s', '%s') ",
+ $r = q("INSERT INTO `profile` ( `aid`, `uid`, `profile_guid`, `profile_name`, `is_default`, `name`, `photo`, `thumb`)
+ VALUES ( %d, %d, '%s', '%s', %d, '%s', '%s', '%s') ",
intval($ret['channel']['channel_account_id']),
intval($newuid),
+ dbesc(random_string()),
t('default'),
1,
dbesc($ret['channel']['channel_name']),
diff --git a/mod/profiles.php b/mod/profiles.php
index 6c33deb0f..d4b8a1ed8 100644
--- a/mod/profiles.php
+++ b/mod/profiles.php
@@ -52,17 +52,17 @@ function profiles_post(&$a) {
$namechanged = true;
- $pdesc = notags(trim($_POST['pdesc']));
- $gender = notags(trim($_POST['gender']));
- $address = notags(trim($_POST['address']));
- $locality = notags(trim($_POST['locality']));
- $region = notags(trim($_POST['region']));
- $postal_code = notags(trim($_POST['postal_code']));
+ $pdesc = notags(trim($_POST['pdesc']));
+ $gender = notags(trim($_POST['gender']));
+ $address = notags(trim($_POST['address']));
+ $locality = notags(trim($_POST['locality']));
+ $region = notags(trim($_POST['region']));
+ $postal_code = notags(trim($_POST['postal_code']));
$country_name = notags(trim($_POST['country_name']));
$pub_keywords = notags(trim($_POST['pub_keywords']));
$prv_keywords = notags(trim($_POST['prv_keywords']));
- $marital = notags(trim($_POST['marital']));
- $howlong = notags(trim($_POST['howlong']));
+ $marital = notags(trim($_POST['marital']));
+ $howlong = notags(trim($_POST['howlong']));
$with = ((x($_POST,'with')) ? notags(trim($_POST['with'])) : '');
@@ -96,19 +96,7 @@ function profiles_post(&$a) {
}
else {
$newname = $lookup;
-/* if(strstr($lookup,' ')) {
- $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
- dbesc($newname),
- intval(local_user())
- );
- }
- else {
- $r = q("SELECT * FROM `contact` WHERE `nick` = '%s' AND `uid` = %d LIMIT 1",
- dbesc($lookup),
- intval(local_user())
- );
- }*/
-
+
$r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
dbesc($newname),
intval(local_user())
@@ -426,14 +414,15 @@ function profiles_content(&$a) {
goaway($a->get_baseurl(true) . '/profiles');
return; // NOTREACHED
}
+ $profile_guid = $r['profile_guid'];
check_form_security_token_redirectOnErr('/profiles', 'profile_drop', 't');
// move every contact using this profile as their default to the user default
- $r = q("UPDATE `contact` SET `profile_id` = (SELECT `profile`.`id` AS `profile_id` FROM `profile` WHERE `profile`.`is_default` = 1 AND `profile`.`uid` = %d LIMIT 1) WHERE `profile_id` = %d AND `uid` = %d ",
+ $r = q("UPDATE abook SET abook_profile = (SELECT profile_guid AS FROM profile WHERE is_default = 1 AND uid = %d LIMIT 1) WHERE abook_profile = '%s' AND `uid` = %d ",
intval(local_user()),
- intval($a->argv[2]),
+ dbesc($profile_guid),
intval(local_user())
);
$r = q("DELETE FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
@@ -464,9 +453,11 @@ function profiles_content(&$a) {
$r1 = q("SELECT `name`, `photo`, `thumb` FROM `profile` WHERE `uid` = %d AND `is_default` = 1 LIMIT 1",
intval(local_user()));
- $r2 = q("INSERT INTO `profile` (`uid` , `profile_name` , `name`, `photo`, `thumb`)
+ $r2 = q("INSERT INTO `profile` (`aid`, `uid` , `profile_guid`, `profile_name` , `name`, `photo`, `thumb`)
VALUES ( %d, '%s', '%s', '%s', '%s' )",
+ intval(get_account_id()),
intval(local_user()),
+ dbesc(random_string()),
dbesc($name),
dbesc($r1[0]['name']),
dbesc($r1[0]['photo']),
@@ -506,6 +497,7 @@ function profiles_content(&$a) {
$r1[0]['is_default'] = 0;
$r1[0]['publish'] = 0;
$r1[0]['profile_name'] = dbesc($name);
+ $r1[0]['profile_guid'] = dbesc(random_string());
dbesc_array($r1[0]);
@@ -539,7 +531,9 @@ function profiles_content(&$a) {
return;
}
- profile_load($a,$a->user['nickname'],$r[0]['id']);
+ $chan = $a->get_channel();
+
+ profile_load($a,$chan['channel_address'],$r[0]['id']);
require_once('include/profile_selectors.php');