get profile edits working

This commit is contained in:
friendica 2012-10-18 20:59:00 -07:00
parent 0b37d4efd6
commit 2c3c933ed4
3 changed files with 28 additions and 28 deletions

View File

@ -18,6 +18,7 @@ CREATE TABLE IF NOT EXISTS `abook` (
`updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`connnected` 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_flags` int(11) NOT NULL DEFAULT '0',
`abook_profile` char(64) NOT NULL DEFAULT '',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8; ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
@ -724,6 +725,7 @@ CREATE TABLE IF NOT EXISTS `photo` (
CREATE TABLE IF NOT EXISTS `profile` ( CREATE TABLE IF NOT EXISTS `profile` (
`id` int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
`profile_guid` char(64) NOT NULL DEFAULT '',
`aid` int(10) unsigned NOT NULL DEFAULT '0', `aid` int(10) unsigned NOT NULL DEFAULT '0',
`uid` int(11) NOT NULL, `uid` int(11) NOT NULL,
`profile_name` char(255) NOT NULL, `profile_name` char(255) NOT NULL,
@ -765,6 +767,7 @@ CREATE TABLE IF NOT EXISTS `profile` (
`thumb` char(255) NOT NULL, `thumb` char(255) NOT NULL,
`publish` tinyint(1) NOT NULL DEFAULT '0', `publish` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `guid` (`profile_guid`,`uid`),
KEY `uid` (`uid`), KEY `uid` (`uid`),
KEY `locality` (`locality`), KEY `locality` (`locality`),
KEY `hometown` (`hometown`), KEY `hometown` (`hometown`),
@ -777,6 +780,7 @@ CREATE TABLE IF NOT EXISTS `profile` (
KEY `hide_friends` (`hide_friends`), KEY `hide_friends` (`hide_friends`),
KEY `postal_code` (`postal_code`), KEY `postal_code` (`postal_code`),
KEY `country_name` (`country_name`), KEY `country_name` (`country_name`),
KEY `profile_guid` (`profile_guid`),
FULLTEXT KEY `pub_keywords` (`pub_keywords`), FULLTEXT KEY `pub_keywords` (`pub_keywords`),
FULLTEXT KEY `prv_keywords` (`prv_keywords`) FULLTEXT KEY `prv_keywords` (`prv_keywords`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8; ) ENGINE=MyISAM DEFAULT CHARSET=utf8;

View File

@ -110,10 +110,11 @@ function create_identity($arr) {
$newuid = $ret['channel']['channel_id']; $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($hash),
dbesc($ret['channel']['channel_guid']), dbesc($ret['channel']['channel_guid']),
dbesc($sig), dbesc($sig),
dbesc($key['pubkey']),
dbesc($a->get_baseurl() . "/photo/profile/{$newuid}"), dbesc($a->get_baseurl() . "/photo/profile/{$newuid}"),
dbesc($ret['channel']['channel_address'] . '@' . $a->get_hostname()), dbesc($ret['channel']['channel_address'] . '@' . $a->get_hostname()),
dbesc(z_root() . '/profile/' . $ret['channel']['channel_address']), 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 // 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`) $r = q("INSERT INTO `profile` ( `aid`, `uid`, `profile_guid`, `profile_name`, `is_default`, `name`, `photo`, `thumb`)
VALUES ( %d, %d, '%s', %d, '%s', '%s', '%s') ", VALUES ( %d, %d, '%s', '%s', %d, '%s', '%s', '%s') ",
intval($ret['channel']['channel_account_id']), intval($ret['channel']['channel_account_id']),
intval($newuid), intval($newuid),
dbesc(random_string()),
t('default'), t('default'),
1, 1,
dbesc($ret['channel']['channel_name']), dbesc($ret['channel']['channel_name']),

View File

@ -96,18 +96,6 @@ function profiles_post(&$a) {
} }
else { else {
$newname = $lookup; $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", $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
dbesc($newname), dbesc($newname),
@ -426,14 +414,15 @@ function profiles_content(&$a) {
goaway($a->get_baseurl(true) . '/profiles'); goaway($a->get_baseurl(true) . '/profiles');
return; // NOTREACHED return; // NOTREACHED
} }
$profile_guid = $r['profile_guid'];
check_form_security_token_redirectOnErr('/profiles', 'profile_drop', 't'); check_form_security_token_redirectOnErr('/profiles', 'profile_drop', 't');
// move every contact using this profile as their default to the user default // 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(local_user()),
intval($a->argv[2]), dbesc($profile_guid),
intval(local_user()) intval(local_user())
); );
$r = q("DELETE FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", $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", $r1 = q("SELECT `name`, `photo`, `thumb` FROM `profile` WHERE `uid` = %d AND `is_default` = 1 LIMIT 1",
intval(local_user())); 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' )", VALUES ( %d, '%s', '%s', '%s', '%s' )",
intval(get_account_id()),
intval(local_user()), intval(local_user()),
dbesc(random_string()),
dbesc($name), dbesc($name),
dbesc($r1[0]['name']), dbesc($r1[0]['name']),
dbesc($r1[0]['photo']), dbesc($r1[0]['photo']),
@ -506,6 +497,7 @@ function profiles_content(&$a) {
$r1[0]['is_default'] = 0; $r1[0]['is_default'] = 0;
$r1[0]['publish'] = 0; $r1[0]['publish'] = 0;
$r1[0]['profile_name'] = dbesc($name); $r1[0]['profile_name'] = dbesc($name);
$r1[0]['profile_guid'] = dbesc(random_string());
dbesc_array($r1[0]); dbesc_array($r1[0]);
@ -539,7 +531,9 @@ function profiles_content(&$a) {
return; 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'); require_once('include/profile_selectors.php');