diff --git a/boot.php b/boot.php index 110bf423e..32942bbce 100755 --- a/boot.php +++ b/boot.php @@ -43,7 +43,7 @@ require_once('include/taxonomy.php'); define ( 'RED_PLATFORM', 'Red Matrix' ); define ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'R'); define ( 'ZOT_REVISION', 1 ); -define ( 'DB_UPDATE_VERSION', 1048 ); +define ( 'DB_UPDATE_VERSION', 1049 ); define ( 'EOL', '
' . "\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); @@ -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,9 @@ function get_max_import_size() { */ -function profile_load(&$a, $nickname, $profile = 0) { +function profile_load(&$a, $nickname, $profile = '') { + + logger('profile_load: ' . $profile); $user = q("select channel_id from channel where channel_address = '%s' limit 1", dbesc($nickname) @@ -1460,30 +1462,29 @@ function profile_load(&$a, $nickname, $profile = 0) { return; } - $r = q("SELECT abook_profile FROM abook WHERE abook_xchan = '%s' limit 1", - dbesc($observer['xchan_hash']) - ); - if($r) - $profile = $r[0]['abook_profile']; - + if(! $profile) { + $r = q("SELECT abook_profile FROM abook WHERE abook_xchan = '%s' and abook_channel = '%d' limit 1", + dbesc($observer['xchan_hash']), + intval($user[0]['channel_id']) + ); + if($r) + $profile = $r[0]['abook_profile']; + } $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 @@ \r\n"; - $o .= "\r\n"; diff --git a/include/dir_fns.php b/include/dir_fns.php index 5a1d671cb..0b678fd91 100644 --- a/include/dir_fns.php +++ b/include/dir_fns.php @@ -53,7 +53,7 @@ function syncdirs($uid) { logger('syncdirs', LOGGER_DEBUG); - $p = q("select channel.channel_hash, profile.* from profile left join channel on channel_id = uid where uid = %d and is_default = 1", + $p = q("select channel.channel_hash, channel_timezone, profile.* from profile left join channel on channel_id = uid where uid = %d and is_default = 1", intval($uid) ); @@ -64,6 +64,9 @@ function syncdirs($uid) { $profile['description'] = $p[0]['pdesc']; $profile['birthday'] = $p[0]['dob']; + if($age = age($p[0]['dob'],$p[0]['channel_timezone'],'')) + $profile['age'] = $age; + $profile['gender'] = $p[0]['gender']; $profile['marital'] = $p[0]['marital']; $profile['sexual'] = $p[0]['sexual']; diff --git a/include/features.php b/include/features.php index c2aabbc42..da1322a14 100644 --- a/include/features.php +++ b/include/features.php @@ -58,6 +58,7 @@ function get_features() { array('filing', t('Saved Folders'), t('Ability to file posts under folders')), array('dislike', t('Dislike Posts'), t('Ability to dislike posts/comments')), array('star_posts', t('Star Posts'), t('Ability to mark special posts with a star indicator')), + array('tagadelic', t('Tag Cloud'), t('Provide a personal tag cloud on your channel page')), ), ); diff --git a/include/items.php b/include/items.php index c4ffcbca6..a3d591899 100755 --- a/include/items.php +++ b/include/items.php @@ -1858,9 +1858,6 @@ function tag_deliver($uid,$item_id) { // See if we are the owner of the parent item and have given permission to tag our posts. // If so tag the parent post. - // FIXME --- If the item is deleted, remove the tag from the parent. - // (First ensure that deleted items use this function, or else do that part separately.) - logger('tag_deliver: community tag activity received'); if(($item['owner_xchan'] === $u[0]['channel_hash']) && (! get_pconfig($u[0]['channel_id'],'system','blocktags'))) { diff --git a/include/taxonomy.php b/include/taxonomy.php index 7e9a4c856..e9cc0faf4 100644 --- a/include/taxonomy.php +++ b/include/taxonomy.php @@ -96,12 +96,15 @@ function format_term_for_display($term) { // Tag cloud functions - need to be adpated to this database format -function tagadelic($uid, $count = 0, $type = TERM_HASHTAG) { +function tagadelic($uid, $count = 0, $flags = 0, $type = TERM_HASHTAG) { + if($flags) + $sql_options = " and ((item_flags & " . intval($flags) . ") = " . intval($flags) . ") "; // Fetch tags - $r = q("select term, count(term) as total from term - where uid = %d and type = %d - and otype = %d + $r = q("select term, count(term) as total from term left join item on term.oid = item.id + where term.uid = %d and term.type = %d + and otype = %d and item_restrict = 0 + $sql_options group by term order by total desc %s", intval($uid), intval($type), @@ -145,15 +148,17 @@ function tags_sort($a,$b) { } -function tagblock($link,$uid,$count = 0,$type = TERM_HASHTAG) { +function tagblock($link,$uid,$count = 0,$flags = 0,$type = TERM_HASHTAG) { + $o = ''; $tab = 0; - $r = tagadelic($uid,$count,$type); + $r = tagadelic($uid,$count,$flags,$type); if($r) { - echo '
'; + $o = '

' . t('Tags') . '

'; foreach($r as $rr) { - echo ''.$rr[0].' '; + $o .= ''.$rr[0].' ' . "\r\n"; } - echo '
'; + $o .= '
'; } + return $o; } diff --git a/include/zot.php b/include/zot.php index f10a02d47..f9b40c06f 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1312,7 +1312,6 @@ function import_directory_profile($hash,$profile) { $arr['xprof_keywords'] = implode(' ',$clean); - $r = q("select * from xprof where xprof_hash = '%s' limit 1", dbesc($hash) ); @@ -1328,6 +1327,7 @@ function import_directory_profile($hash,$profile) { $x = q("update xprof set xprof_desc = '%s', xprof_dob = '%s', + xprof_age = %d, xprof_gender = '%s', xprof_marital = '%s', xprof_sexual = '%s', @@ -1339,6 +1339,7 @@ function import_directory_profile($hash,$profile) { where xprof_hash = '%s' limit 1", dbesc($arr['xprof_desc']), dbesc($arr['xprof_dob']), + intval($arr['xprof_age']), dbesc($arr['xprof_gender']), dbesc($arr['xprof_marital']), dbesc($arr['xprof_sexual']), @@ -1353,10 +1354,11 @@ function import_directory_profile($hash,$profile) { } else { $update = true; - $x = q("insert into xprof (xprof_hash, xprof_desc, xprof_dob, xprof_gender, xprof_marital, xprof_sexual, xprof_locale, xprof_region, xprof_postcode, xprof_country, xprof_keywords) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s') ", + $x = q("insert into xprof (xprof_hash, xprof_desc, xprof_dob, xprof_age, xprof_gender, xprof_marital, xprof_sexual, xprof_locale, xprof_region, xprof_postcode, xprof_country, xprof_keywords) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s') ", dbesc($arr['xprof_hash']), dbesc($arr['xprof_desc']), dbesc($arr['xprof_dob']), + intval($arr['xprof_age']), dbesc($arr['xprof_gender']), dbesc($arr['xprof_marital']), dbesc($arr['xprof_sexual']), diff --git a/install/database.sql b/install/database.sql index 5cb0146f7..59192b753 100644 --- a/install/database.sql +++ b/install/database.sql @@ -599,6 +599,23 @@ CREATE TABLE IF NOT EXISTS `notify` ( KEY `otype` (`otype`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; +CREATE TABLE IF NOT EXISTS `obj` ( + `obj_id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `obj_page` char(64) NOT NULL DEFAULT '', + `obj_verb` char(255) NOT NULL DEFAULT '', + `obj_type` int(10) unsigned NOT NULL DEFAULT '0', + `obj_obj` char(255) NOT NULL DEFAULT '', + `obj_channel` int(10) unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (`obj_id`), + KEY `obj_verb` (`obj_verb`), + KEY `obj_page` (`obj_page`), + KEY `obj_type` (`obj_type`), + KEY `obj_channel` (`obj_channel`), + KEY `obj_obj` (`obj_obj`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + + + CREATE TABLE IF NOT EXISTS `outq` ( `outq_hash` char(255) NOT NULL, `outq_account` int(10) unsigned NOT NULL DEFAULT '0', diff --git a/install/update.php b/install/update.php index ef436c688..22c069d2f 100644 --- a/install/update.php +++ b/install/update.php @@ -1,6 +1,6 @@ set_widget('archive',posted_date_widget($a->get_baseurl(true) . '/channel/' . $a->profile['channel_address'],$a->profile['profile_uid'],true)); $a->set_widget('categories',categories_widget($a->get_baseurl(true) . '/channel/' . $a->profile['channel_address'],$cat)); } + if(feature_enabled($a->profile['profile_uid'],'tagadelic')) + $a->set_widget('tagcloud',tagblock('search',$a->profile['profile_uid'],50,ITEM_WALL|ITEM_THREAD_TOP)); + } 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 privacy settings, 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/mod/photos.php b/mod/photos.php index 65bf866f1..f0b2b882e 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -633,6 +633,9 @@ function photos_content(&$a) { // dispatch request // + /** + * Display upload form + */ if($datatype === 'upload') { if(! ($can_post)) { @@ -640,12 +643,8 @@ function photos_content(&$a) { return; } - $selname = (($datum) ? hex2bin($datum) : ''); - - $albumselect = '
'; + /* Show space usage */ $r = q("select sum(size) as total from photo where uid = %d and scale = 0 ", intval($a->data['channel']['channel_id']) @@ -687,15 +687,8 @@ function photos_content(&$a) { $usage_message = sprintf( t('You have used %1$.2f Mbytes of photo storage.'), $r[0]['total'] / 1024000 ); } - - if($a->get_template_engine() === 'internal') { - $albumselect_e = template_escape($albumselect); - $aclselect_e = (($visitor) ? '' : template_escape(populate_acl($a->user, $celeb))); - } - else { - $albumselect_e = $albumselect; - $aclselect_e = (($visitor) ? '' : populate_acl($a->user, $celeb)); - } + $albumselect_e = $albumselect; + $aclselect_e = (($visitor) ? '' : populate_acl($a->user, $celeb)); $tpl = get_markup_template('photos_upload.tpl'); $o .= replace_macros($tpl,array( @@ -718,6 +711,10 @@ function photos_content(&$a) { return $o; } + /* + * Display a single photo album + */ + if($datatype === 'album') { $album = hex2bin($datum); @@ -793,6 +790,7 @@ function photos_content(&$a) { if(count($r)) $twist = 'rotright'; foreach($r as $rr) { + if($twist == 'rotright') $twist = 'rotleft'; else @@ -839,12 +837,12 @@ function photos_content(&$a) { } + /** + * Display one photo + */ if($datatype === 'image') { - - - //$o = ''; // fetch image, item containing image, then comments $ph = q("SELECT * FROM `photo` WHERE `uid` = %d AND `resource_id` = '%s' @@ -853,13 +851,16 @@ function photos_content(&$a) { dbesc($datum) ); - if(! count($ph)) { + if(! $ph) { + + /* Check again - this time without specifying permissions */ + $ph = q("SELECT `id` FROM `photo` WHERE `uid` = %d AND `resource_id` = '%s' LIMIT 1", intval($owner_uid), dbesc($datum) ); - if(count($ph)) + if($ph) notice( t('Permission denied. Access to this item may be restricted.')); else notice( t('Photo not available') . EOL ); @@ -893,9 +894,9 @@ function photos_content(&$a) { break; } } - $edit_suffix = ((($cmd === 'edit') && ($can_post)) ? '/edit' : ''); - $prevlink = $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $prvnxt[$prv]['resource_id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''); - $nextlink = $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $prvnxt[$nxt]['resource_id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''); + + $prevlink = $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $prvnxt[$prv]['resource_id'] . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''); + $nextlink = $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $prvnxt[$nxt]['resource_id'] . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''); } @@ -918,7 +919,6 @@ function photos_content(&$a) { if($can_post && ($ph[0]['uid'] == $owner_uid)) { $tools = array( - 'edit' => array($a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $datum . (($cmd === 'edit') ? '' : '/edit'), (($cmd === 'edit') ? t('View photo') : t('Edit photo'))), 'profile'=>array($a->get_baseurl() . '/profile_photo/use/'.$ph[0]['resource_id'], t('Use as profile photo')), ); @@ -931,7 +931,7 @@ function photos_content(&$a) { } - if(! $cmd !== 'edit') { + if(! $can_post) { $a->page['htmlhead'] .= '