aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-07-03 01:50:39 -0700
committerfriendica <info@friendica.com>2013-07-03 01:50:39 -0700
commit8369a8a7559391ea6cb2757b5093bcf47aed0ed1 (patch)
tree9a9bc185f4e0b8c331eeff3a75eca976bd0656c4
parentfd74c5b2ce303ba7018b139c033c6f92ea134751 (diff)
downloadvolse-hubzilla-8369a8a7559391ea6cb2757b5093bcf47aed0ed1.tar.gz
volse-hubzilla-8369a8a7559391ea6cb2757b5093bcf47aed0ed1.tar.bz2
volse-hubzilla-8369a8a7559391ea6cb2757b5093bcf47aed0ed1.zip
progress on multiple profiles, doing it the old way. I don't think we're going to be able to do it the new way - way too complicated.
-rwxr-xr-xboot.php23
-rw-r--r--include/contact_selectors.php16
-rw-r--r--mod/connections.php15
-rw-r--r--version.inc2
-rwxr-xr-xview/tpl/abook_edit.tpl9
5 files changed, 35 insertions, 30 deletions
diff --git a/boot.php b/boot.php
index db61a79ae..dc0ec48a5 100755
--- a/boot.php
+++ b/boot.php
@@ -1419,7 +1419,7 @@ function get_max_import_size() {
* Function : profile_load
* @parameter App $a
* @parameter string $nickname
- * @parameter int $profile
+ * @parameter string $profile
*
* Summary: Loads a profile into the page sidebar.
* The function requires a writeable copy of the main App structure, and the nickname
@@ -1436,7 +1436,7 @@ function get_max_import_size() {
*/
-function profile_load(&$a, $nickname, $profile = 0) {
+function profile_load(&$a, $nickname, $profile = '') {
$user = q("select channel_id from channel where channel_address = '%s' limit 1",
dbesc($nickname)
@@ -1468,22 +1468,19 @@ function profile_load(&$a, $nickname, $profile = 0) {
$r = null;
-
-
if($profile) {
- $profile_int = intval($profile);
- $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , channel.* FROM `profile`
- LEFT JOIN channel ON `profile`.`uid` = channel.channel_id
- WHERE channel.channel_address = '%s' AND `profile`.`id` = %d LIMIT 1",
+ $r = q("SELECT profile.uid AS profile_uid, profile.*, channel.* FROM profile
+ LEFT JOIN channel ON profile.uid = channel.channel_id
+ WHERE channel.channel_address = '%s' AND profile.profile_guid = '%s' LIMIT 1",
dbesc($nickname),
- intval($profile_int)
+ dbesc($profile)
);
}
- if(! ($r && count($r))) {
- $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `channel`.* FROM `profile`
- LEFT JOIN `channel` ON `profile`.`uid` = channel.channel_id
- WHERE channel.channel_address = '%s' AND `profile`.`is_default` = 1 LIMIT 1",
+ if(! $r) {
+ $r = q("SELECT profile.uid AS profile_uid, profile.*, channel.* FROM profile
+ LEFT JOIN channel ON profile.uid = channel.channel_id
+ WHERE channel.channel_address = '%s' AND profile.is_default = 1 LIMIT 1",
dbesc($nickname)
);
}
diff --git a/include/contact_selectors.php b/include/contact_selectors.php
index adcca2c52..b56a77937 100644
--- a/include/contact_selectors.php
+++ b/include/contact_selectors.php
@@ -1,21 +1,19 @@
<?php /** @file */
-function contact_profile_assign($current,$foreign_net) {
+function contact_profile_assign($current) {
$o = '';
- $disabled = (($foreign_net) ? ' disabled="true" ' : '');
+ $o .= "<select id=\"contact-profile-selector\" name=\"profile-assign\" />\r\n";
- $o .= "<select id=\"contact-profile-selector\" $disabled name=\"profile-assign\" />\r\n";
+ $r = q("SELECT profile_guid, profile_name FROM `profile` WHERE `uid` = %d",
+ intval($_SESSION['uid']));
- $r = q("SELECT `id`, `profile_name` FROM `profile` WHERE `uid` = %d",
- intval($_SESSION['uid']));
-
- if(count($r)) {
+ if($r) {
foreach($r as $rr) {
- $selected = (($rr['id'] == $current) ? " selected=\"selected\" " : "");
- $o .= "<option value=\"{$rr['id']}\" $selected >{$rr['profile_name']}</option>\r\n";
+ $selected = (($rr['profile_guid'] == $current) ? " selected=\"selected\" " : "");
+ $o .= "<option value=\"{$rr['profile_guid']}\" $selected >{$rr['profile_name']}</option>\r\n";
}
}
$o .= "</select>\r\n";
diff --git a/mod/connections.php b/mod/connections.php
index a53107dcf..89c0bcbc0 100644
--- a/mod/connections.php
+++ b/mod/connections.php
@@ -63,10 +63,10 @@ function connections_post(&$a) {
call_hooks('contact_edit_post', $_POST);
- $profile_id = intval($_POST['profile-assign']);
+ $profile_id = $_POST['profile-assign'];
if($profile_id) {
- $r = q("SELECT `id` FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
- intval($profile_id),
+ $r = q("SELECT profile_guid FROM profile WHERE profile_guid = '%s' AND `uid` = %d LIMIT 1",
+ dbesc($profile_id),
intval(local_user())
);
if(! count($r)) {
@@ -99,9 +99,9 @@ function connections_post(&$a) {
$abook_flags = ( $abook_flags ^ ABOOK_FLAG_PENDING );
}
- $r = q("UPDATE abook SET abook_profile = %d, abook_my_perms = %d , abook_closeness = %d, abook_flags = %d
+ $r = q("UPDATE abook SET abook_profile = '%s', abook_my_perms = %d , abook_closeness = %d, abook_flags = %d
where abook_id = %d AND abook_channel = %d LIMIT 1",
- intval($profile_id),
+ dbesc($profile_id),
intval($abook_my_perms),
intval($closeness),
intval($abook_flags),
@@ -405,7 +405,7 @@ function connections_content(&$a) {
'$noperm_desc' => (((! $self) && (! $contact['abook_my_perms'])) ? t('This may be appropriate based on your <a href="settings">privacy settings</a>, though you may wish to review the "Advanced Permissions"') : ''),
'$submit' => t('Submit'),
'$lbl_vis1' => t('Profile Visibility'),
- '$lbl_vis2' => sprintf( t('Please choose the profile you would like to display to %s when viewing your profile securely.'), $contact['name']),
+ '$lbl_vis2' => sprintf( t('Please choose the profile you would like to display to %s when viewing your profile securely.'), $contact['xchan_name']),
'$lbl_info1' => t('Contact Information / Notes'),
'$infedit' => t('Edit contact notes'),
'$close' => $contact['abook_closeness'],
@@ -438,7 +438,8 @@ function connections_content(&$a) {
'$updpub' => t('Update public posts'),
'$last_update' => $last_update,
'$udnow' => t('Update now'),
-// '$profile_select' => contact_profile_assign($contact['profile_id'],(($contact['network'] !== NETWORK_DFRN) ? true : false)),
+ '$profile_select' => contact_profile_assign($contact['abook_profile']),
+ '$multiprofs' => feature_enabled(local_user(),'multi_profiles'),
'$contact_id' => $contact['abook_id'],
'$block_text' => (($contact['blocked']) ? t('Unblock') : t('Block') ),
'$ignore_text' => (($contact['readonly']) ? t('Unignore') : t('Ignore') ),
diff --git a/version.inc b/version.inc
index 71c7a401a..3e4010a3d 100644
--- a/version.inc
+++ b/version.inc
@@ -1 +1 @@
-2013-07-02.362
+2013-07-03.363
diff --git a/view/tpl/abook_edit.tpl b/view/tpl/abook_edit.tpl
index 442692b3d..c373976ab 100755
--- a/view/tpl/abook_edit.tpl
+++ b/view/tpl/abook_edit.tpl
@@ -75,6 +75,15 @@
</div>
+{{if $multiprofs }}
+<div>
+<h3>{{$lbl_vis1}}</h3>
+<div>{{$lbl_vis2}}</div>
+
+{{$profile_select}}
+</div>
+{{/if}}
+
<input class="contact-edit-submit" type="submit" name="done" value="{{$submit}}" />
</form>