remove the private keywords stuff to reduce directory and search complexity

This commit is contained in:
friendica 2012-12-26 03:49:50 -08:00
parent 1aeea64311
commit c8292b3cdd
11 changed files with 34 additions and 42 deletions

View File

@ -16,9 +16,9 @@ require_once('include/features.php');
define ( 'FRIENDICA_PLATFORM', 'Friendica Red'); define ( 'FRIENDICA_PLATFORM', 'Friendica Red');
define ( 'FRIENDICA_VERSION', trim(file_get_contents('version.inc')) . 'R'); define ( 'FRIENDICA_VERSION', trim(file_get_contents('version.inc')) . 'R');
define ( 'ZOT_REVISION', 1 ); define ( 'ZOT_REVISION', 1 );
define ( 'DB_UPDATE_VERSION', 1008 ); define ( 'DB_UPDATE_VERSION', 1009 );
define ( 'EOL', "<br />\r\n" ); define ( 'EOL', '<br />' . "\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
@ -1261,11 +1261,11 @@ function profile_load(&$a, $nickname, $profile = 0) {
// fetch user tags if this isn't the default profile // fetch user tags if this isn't the default profile
if(! $r[0]['is_default']) { if(! $r[0]['is_default']) {
$x = q("select `pub_keywords` from `profile` where uid = %d and `is_default` = 1 limit 1", $x = q("select `keywords` from `profile` where uid = %d and `is_default` = 1 limit 1",
intval($profile_uid) intval($profile_uid)
); );
if($x && count($x)) if($x && count($x))
$r[0]['pub_keywords'] = $x[0]['pub_keywords']; $r[0]['keywords'] = $x[0]['keywords'];
} }
$a->profile = $r[0]; $a->profile = $r[0];

View File

@ -49,7 +49,7 @@ function advanced_profile(&$a) {
if($a->profile['hometown']) $profile['hometown'] = array( t('Hometown:'), linkify($a->profile['hometown']) ); if($a->profile['hometown']) $profile['hometown'] = array( t('Hometown:'), linkify($a->profile['hometown']) );
if($a->profile['pub_keywords']) $profile['pub_keywords'] = array( t('Tags:'), $a->profile['pub_keywords']); if($a->profile['keywords']) $profile['keywords'] = array( t('Tags:'), $a->profile['keywords']);
if($a->profile['politic']) $profile['politic'] = array( t('Political Views:'), $a->profile['politic']); if($a->profile['politic']) $profile['politic'] = array( t('Political Views:'), $a->profile['politic']);

View File

@ -654,8 +654,7 @@ CREATE TABLE IF NOT EXISTS `profile` (
`sexual` char(255) NOT NULL, `sexual` char(255) NOT NULL,
`politic` char(255) NOT NULL, `politic` char(255) NOT NULL,
`religion` char(255) NOT NULL, `religion` char(255) NOT NULL,
`pub_keywords` text NOT NULL, `keywords` text NOT NULL,
`prv_keywords` text NOT NULL,
`likes` text NOT NULL, `likes` text NOT NULL,
`dislikes` text NOT NULL, `dislikes` text NOT NULL,
`about` text NOT NULL, `about` text NOT NULL,
@ -687,9 +686,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`), KEY `profile_guid` (`profile_guid`)
FULLTEXT KEY `pub_keywords` (`pub_keywords`),
FULLTEXT KEY `prv_keywords` (`prv_keywords`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8; ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `profile_check` ( CREATE TABLE IF NOT EXISTS `profile_check` (

View File

@ -1,6 +1,6 @@
<?php <?php
define( 'UPDATE_VERSION' , 1008 ); define( 'UPDATE_VERSION' , 1009 );
/** /**
* *
@ -152,3 +152,11 @@ function update_r1007() {
return UPDATE_SUCCESS; return UPDATE_SUCCESS;
return UPDATE_FAILED; return UPDATE_FAILED;
} }
function update_r1008() {
$r = q("alter table profile drop prv_keywords, CHANGE `pub_keywords` `keywords` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, drop index pub_keywords");
if($r)
return UPDATE_SUCCESS;
return UPDATE_FAILED;
}

View File

@ -65,7 +65,7 @@ $localdir = true;
if($localdir) { if($localdir) {
if($search) if($search)
$search = dbesc($search); $search = dbesc($search);
$sql_extra = ((strlen($search)) ? " AND MATCH (`profile`.`name`, channel.channel_address, `pdesc`, `locality`,`region`,`country_name`,`gender`,`marital`,`sexual`,`about`,`romance`,`work`,`education`,`pub_keywords`,`prv_keywords` ) AGAINST ('$search' IN BOOLEAN MODE) " : ""); $sql_extra = ((strlen($search)) ? " AND MATCH (`profile`.`name`, channel.channel_address, `pdesc`, `locality`,`region`,`country_name`,`gender`,`marital`,`sexual`,`about`,`romance`,`work`,`education`,`keywords` ) AGAINST ('$search' IN BOOLEAN MODE) " : "");
$r = q("SELECT COUNT(channel_id) AS `total` FROM channel left join profile on channel.channel_id = profile.uid WHERE `is_default` = 1 and not ( channel_pageflags & %d ) $sql_extra ", $r = q("SELECT COUNT(channel_id) AS `total` FROM channel left join profile on channel.channel_id = profile.uid WHERE `is_default` = 1 and not ( channel_pageflags & %d ) $sql_extra ",

View File

@ -31,7 +31,7 @@ function hcard_init(&$a) {
} }
if(! $blocked) { if(! $blocked) {
$keywords = ((x($a->profile,'pub_keywords')) ? $a->profile['pub_keywords'] : ''); $keywords = ((x($a->profile,'keywords')) ? $a->profile['keywords'] : '');
$keywords = str_replace(array(',',' ',',,'),array(' ',',',','),$keywords); $keywords = str_replace(array(',',' ',',,'),array(' ',',',','),$keywords);
if(strlen($keywords)) if(strlen($keywords))
$a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n" ; $a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n" ;

View File

@ -11,19 +11,19 @@ function match_content(&$a) {
$o .= '<h2>' . t('Profile Match') . '</h2>'; $o .= '<h2>' . t('Profile Match') . '</h2>';
$r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is_default` = 1 AND `uid` = %d LIMIT 1", $r = q("SELECT `keywords` FROM `profile` WHERE `is_default` = 1 AND `uid` = %d LIMIT 1",
intval(local_user()) intval(local_user())
); );
if(! count($r)) if(! count($r))
return; return;
if(! $r[0]['pub_keywords'] && (! $r[0]['prv_keywords'])) { if(! $r[0]['keywords']) {
notice( t('No keywords to match. Please add keywords to your default profile.') . EOL); notice( t('No keywords to match. Please add keywords to your default profile.') . EOL);
return; return;
} }
$params = array(); $params = array();
$tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']); $tags = trim($r[0]['keywords'];
if($tags) { if($tags) {
$params['s'] = $tags; $params['s'] = $tags;

View File

@ -10,13 +10,13 @@ function msearch_post(&$a) {
if(! strlen($search)) if(! strlen($search))
killme(); killme();
$r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is_default` = 1 AND `user`.`hidewall` = 0 AND MATCH `pub_keywords` AGAINST ('%s') ", $r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is_default` = 1 AND `user`.`hidewall` = 0 AND MATCH `keywords` AGAINST ('%s') ",
dbesc($search) dbesc($search)
); );
if(count($r)) if(count($r))
$total = $r[0]['total']; $total = $r[0]['total'];
$r = q("SELECT `pub_keywords`, `username`, `nickname`, `user`.`uid` FROM `user` LEFT JOIN `profile` ON `user`.`uid` = `profile`.`uid` WHERE `is_default` = 1 AND `user`.`hidewall` = 0 AND MATCH `pub_keywords` AGAINST ('%s') LIMIT %d , %d ", $r = q("SELECT `keywords`, `username`, `nickname`, `user`.`uid` FROM `user` LEFT JOIN `profile` ON `user`.`uid` = `profile`.`uid` WHERE `is_default` = 1 AND `user`.`hidewall` = 0 AND MATCH `keywords` AGAINST ('%s') LIMIT %d , %d ",
dbesc($search), dbesc($search),
intval($startrec), intval($startrec),
intval($perpage) intval($perpage)
@ -29,7 +29,7 @@ function msearch_post(&$a) {
'name' => $rr['name'], 'name' => $rr['name'],
'url' => $a->get_baseurl() . '/channel/' . $rr['nickname'], 'url' => $a->get_baseurl() . '/channel/' . $rr['nickname'],
'photo' => $a->get_baseurl() . '/photo/avatar/' . $rr['uid'], 'photo' => $a->get_baseurl() . '/photo/avatar/' . $rr['uid'],
'tags' => str_replace(array(',',' '),array(' ',' '),$rr['pub_keywords']) 'tags' => str_replace(array(',',' '),array(' ',' '),$rr['keywords'])
); );
} }

View File

@ -61,8 +61,7 @@ function profiles_post(&$a) {
$region = notags(trim($_POST['region'])); $region = notags(trim($_POST['region']));
$postal_code = notags(trim($_POST['postal_code'])); $postal_code = notags(trim($_POST['postal_code']));
$country_name = notags(trim($_POST['country_name'])); $country_name = notags(trim($_POST['country_name']));
$pub_keywords = notags(trim($_POST['pub_keywords'])); $keywords = notags(trim($_POST['keywords']));
$prv_keywords = notags(trim($_POST['prv_keywords']));
$marital = notags(trim($_POST['marital'])); $marital = notags(trim($_POST['marital']));
$howlong = notags(trim($_POST['howlong'])); $howlong = notags(trim($_POST['howlong']));
$sexual = notags(trim($_POST['sexual'])); $sexual = notags(trim($_POST['sexual']));
@ -232,8 +231,7 @@ function profiles_post(&$a) {
`hometown` = '%s', `hometown` = '%s',
`politic` = '%s', `politic` = '%s',
`religion` = '%s', `religion` = '%s',
`pub_keywords` = '%s', `keywords` = '%s',
`prv_keywords` = '%s',
`likes` = '%s', `likes` = '%s',
`dislikes` = '%s', `dislikes` = '%s',
`about` = '%s', `about` = '%s',
@ -266,8 +264,7 @@ function profiles_post(&$a) {
dbesc($hometown), dbesc($hometown),
dbesc($politic), dbesc($politic),
dbesc($religion), dbesc($religion),
dbesc($pub_keywords), dbesc($keywords),
dbesc($prv_keywords),
dbesc($likes), dbesc($likes),
dbesc($dislikes), dbesc($dislikes),
dbesc($about), dbesc($about),
@ -511,13 +508,11 @@ function profiles_content(&$a) {
'$lbl_hometown' => t('Hometown:'), '$lbl_hometown' => t('Hometown:'),
'$lbl_politic' => t('Political Views:'), '$lbl_politic' => t('Political Views:'),
'$lbl_religion' => t('Religious Views:'), '$lbl_religion' => t('Religious Views:'),
'$lbl_pubkey' => t('Public Keywords:'), '$lbl_pubkey' => t('Keywords:'),
'$lbl_prvkey' => t('Private Keywords:'),
'$lbl_likes' => t('Likes:'), '$lbl_likes' => t('Likes:'),
'$lbl_dislikes' => t('Dislikes:'), '$lbl_dislikes' => t('Dislikes:'),
'$lbl_ex2' => t('Example: fishing photography software'), '$lbl_ex2' => t('Example: fishing photography software'),
'$lbl_pubdsc' => t("\x28Used for suggesting potential friends, can be seen by others\x29"), '$lbl_pubdsc' => t("Used in directory listings"),
'$lbl_prvdsc' => t("\x28Used for searching profiles, never shown to others\x29"),
'$lbl_about' => t('Tell us about yourself...'), '$lbl_about' => t('Tell us about yourself...'),
'$lbl_hobbies' => t('Hobbies/Interests'), '$lbl_hobbies' => t('Hobbies/Interests'),
'$lbl_social' => t('Contact information and Social Networks'), '$lbl_social' => t('Contact information and Social Networks'),
@ -553,8 +548,7 @@ function profiles_content(&$a) {
'$hometown' => $r[0]['hometown'], '$hometown' => $r[0]['hometown'],
'$politic' => $r[0]['politic'], '$politic' => $r[0]['politic'],
'$religion' => $r[0]['religion'], '$religion' => $r[0]['religion'],
'$pub_keywords' => $r[0]['pub_keywords'], '$keywords' => $r[0]['keywords'],
'$prv_keywords' => $r[0]['prv_keywords'],
'$likes' => $r[0]['likes'], '$likes' => $r[0]['likes'],
'$dislikes' => $r[0]['dislikes'], '$dislikes' => $r[0]['dislikes'],
'$music' => $r[0]['music'], '$music' => $r[0]['music'],

View File

@ -40,10 +40,10 @@
</dl> </dl>
{{ endif }} {{ endif }}
{{ if $profile.pub_keywords }} {{ if $profile.keywords }}
<dl id="aprofile-tags" class="aprofile"> <dl id="aprofile-tags" class="aprofile">
<dt>$profile.pub_keywords.0</dt> <dt>$profile.keywords.0</dt>
<dd>$profile.pub_keywords.1</dd> <dd>$profile.keywords.1</dd>
</dl> </dl>
{{ endif }} {{ endif }}

View File

@ -143,17 +143,10 @@ $sexual
<div id="profile-edit-pubkeywords-wrapper" > <div id="profile-edit-pubkeywords-wrapper" >
<label id="profile-edit-pubkeywords-label" for="profile-edit-pubkeywords" >$lbl_pubkey </label> <label id="profile-edit-pubkeywords-label" for="profile-edit-pubkeywords" >$lbl_pubkey </label>
<input type="text" size="32" name="pub_keywords" id="profile-edit-pubkeywords" title="$lbl_ex2" value="$pub_keywords" /> <input type="text" size="32" name="keywords" id="profile-edit-pubkeywords" title="$lbl_ex2" value="$keywords" />
</div><div id="profile-edit-pubkeywords-desc">$lbl_pubdsc</div> </div><div id="profile-edit-pubkeywords-desc">$lbl_pubdsc</div>
<div id="profile-edit-pubkeywords-end"></div> <div id="profile-edit-pubkeywords-end"></div>
<div id="profile-edit-prvkeywords-wrapper" >
<label id="profile-edit-prvkeywords-label" for="profile-edit-prvkeywords" >$lbl_prvkey </label>
<input type="text" size="32" name="prv_keywords" id="profile-edit-prvkeywords" title="$lbl_ex2" value="$prv_keywords" />
</div><div id="profile-edit-prvkeywords-desc">$lbl_prvdsc</div>
<div id="profile-edit-prvkeywords-end"></div>
<div class="profile-edit-submit-wrapper" > <div class="profile-edit-submit-wrapper" >
<input type="submit" name="submit" class="profile-edit-submit-button" value="$submit" /> <input type="submit" name="submit" class="profile-edit-submit-button" value="$submit" />
</div> </div>