aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
authorOlivier Migeot <olivier@migeot.org>2011-03-28 12:11:10 +0200
committerOlivier Migeot <olivier@migeot.org>2011-03-28 12:11:10 +0200
commitda546588db1863dd240a4c738644372fc4d183e6 (patch)
treedd6c869207098867aa6c7207f29ab5a2e9b6dc69 /mod
parent19d7e7fefeb3d20697d6a7e0b1fc7a16d9127c64 (diff)
parent1f6c6c466a449ba422c4e67744577f6c35b3ce0b (diff)
downloadvolse-hubzilla-da546588db1863dd240a4c738644372fc4d183e6.tar.gz
volse-hubzilla-da546588db1863dd240a4c738644372fc4d183e6.tar.bz2
volse-hubzilla-da546588db1863dd240a4c738644372fc4d183e6.zip
Merge remote branch 'mike/master'
Diffstat (limited to 'mod')
-rw-r--r--mod/directory.php6
-rw-r--r--mod/friendika.php47
-rw-r--r--mod/network.php90
-rw-r--r--mod/profile.php69
-rw-r--r--mod/register.php18
-rw-r--r--mod/settings.php5
-rw-r--r--mod/uexport.php72
7 files changed, 285 insertions, 22 deletions
diff --git a/mod/directory.php b/mod/directory.php
index 825e2a375..72c30fb31 100644
--- a/mod/directory.php
+++ b/mod/directory.php
@@ -86,10 +86,10 @@ function directory_content(&$a) {
}
if(strlen($rr['dob'])) {
if(($years = age($rr['dob'],$rr['timezone'],'')) != 0)
- $details .= "<br />Age: $years" ;
+ $details .= '<br />' . t('Age: ') . $years ;
}
if(strlen($rr['gender']))
- $details .= '<br />Gender: ' . $rr['gender'];
+ $details .= '<br />' . t('Gender: ') . $rr['gender'];
$entry = replace_macros($tpl,array(
'$id' => $rr['id'],
@@ -115,7 +115,7 @@ function directory_content(&$a) {
}
else
- notice("No entries (some entries may be hidden).");
+ notice( t("No entries \x28some entries may be hidden\x29.") . EOL);
return $o;
} \ No newline at end of file
diff --git a/mod/friendika.php b/mod/friendika.php
new file mode 100644
index 000000000..4a8240a11
--- /dev/null
+++ b/mod/friendika.php
@@ -0,0 +1,47 @@
+<?php
+
+function friendika_content(&$a) {
+
+ $o = '';
+ $o .= '<h3>Friendika</h3>';
+
+
+ $o .= '<p></p><p>';
+
+ $o .= 'View <a href="LICENSE">License</a>' . '<br /><br />';
+ $o .= t('This is Friendika version') . ' ' . FRIENDIKA_VERSION . ' ';
+ $o .= t('running at web location') . ' ' . $a->get_baseurl() . '</p><p>';
+
+ $o .= t('Shared content within the Friendika network is provided under the <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0 license</a>') . '</p><p>';
+
+ $o .= t('Please visit <a href="http://project.friendika.com">Project.Friendika.com</a> to learn more about the Friendika project.') . '</p><p>';
+
+ $o .= t('Bug reports and issues: please visit') . ' ' . '<a href="http://bugs.friendika.com">Bugs.Friendika.com</a></p><p>';
+ $o .= t('Suggestions, praise, donations, etc. - please email "Info" at Friendika - dot com') . '</p>';
+
+ $o .= '<p></p>';
+
+ if(count($a->plugins)) {
+ $o .= '<p>' . t('Installed plugins/addons/apps') . '</p>';
+ $o .= '<ul>';
+ foreach($a->plugins as $p)
+ if(strlen($p))
+ $o .= '<li>' . $p . '</li>';
+ $o .= '</ul>';
+ }
+ else
+ $o .= '<p>' . t('No installed plugins/addons/apps');
+
+ return $o;
+
+
+
+
+
+
+
+
+
+
+
+} \ No newline at end of file
diff --git a/mod/network.php b/mod/network.php
index 97bc0713d..17d36dfb2 100644
--- a/mod/network.php
+++ b/mod/network.php
@@ -183,8 +183,11 @@ function network_content(&$a, $update = 0) {
intval($_SESSION['uid'])
);
- if(count($r))
+ if(count($r)) {
$a->set_pager_total($r[0]['total']);
+ $a->set_pager_itemspage(40);
+ }
+
if($nouveau) {
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
@@ -203,21 +206,41 @@ function network_content(&$a, $update = 0) {
);
}
else {
- $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
- `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
- `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
- `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
- FROM `item`, (SELECT `p`.`id`,`p`.`created` FROM `item` AS `p` WHERE `p`.`parent`=`p`.`id`) as `parentitem`, `contact`
+ $r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact_uid`
+ FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
- AND `contact`.`id` = `item`.`contact-id`
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
- AND `item`.`parent` = `parentitem`.`id`
+ AND `item`.`parent` = `item`.`id`
$sql_extra
- ORDER BY `parentitem`.`created` DESC, `item`.`gravity` ASC, `item`.`created` ASC LIMIT %d ,%d ",
+ ORDER BY `item`.`created` DESC LIMIT %d ,%d ",
intval(local_user()),
intval($a->pager['start']),
intval($a->pager['itemspage'])
);
+
+ $parents_arr = array();
+ $parents_str = '';
+
+ if(count($r)) {
+ foreach($r as $rr)
+ $parents_arr[] = $rr['item_id'];
+ $parents_str = implode(', ', $parents_arr);
+
+ $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
+ `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
+ `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
+ `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
+ FROM `item`, (SELECT `p`.`id`,`p`.`created` FROM `item` AS `p` WHERE `p`.`parent`=`p`.`id`) as `parentitem`, `contact`
+ WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
+ AND `contact`.`id` = `item`.`contact-id`
+ AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+ AND `item`.`parent` = `parentitem`.`id` AND `item`.`parent` IN ( %s )
+ $sql_extra
+ ORDER BY `parentitem`.`created` DESC, `item`.`gravity` ASC, `item`.`created` ASC ",
+ intval(local_user()),
+ dbesc($parents_str)
+ );
+ }
}
$author_contacts = extract_item_authors($r,local_user());
@@ -303,12 +326,25 @@ function network_content(&$a, $update = 0) {
}
+ $comments = array();
+ foreach($r as $rr) {
+ if(intval($rr['gravity']) == 6) {
+ if(! x($comments,$rr['parent']))
+ $comments[$rr['parent']] = 1;
+ else
+ $comments[$rr['parent']] += 1;
+ }
+ }
foreach($r as $item) {
like_puller($a,$item,$alike,'like');
like_puller($a,$item,$dlike,'dislike');
}
+ $comments_collapsed = false;
+ $blowhard = 0;
+ $blowhard_count = 0;
+
foreach($r as $item) {
$comment = '';
@@ -320,9 +356,39 @@ function network_content(&$a, $update = 0) {
if(((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE))) && ($item['id'] != $item['parent']))
continue;
- $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
+ if($item['id'] == $item['parent']) {
+ if($blowhard == $item['cid'] && (! $item['self'])) {
+ $blowhard_count ++;
+ if($blowhard_count == 3) {
+ $o .= '<div class="icollapse-wrapper fakelink" id="icollapse-wrapper-' . $item['parent'] . '" onclick="openClose(' . '\'icollapse-' . $item['parent'] . '\');" >' . t('See more posts like this') . '</div>' . '<div class="icollapse" id="icollapse-' . $item['parent'] . '" style="display: none;" >';
+ }
+ }
+ else {
+ $blowhard = $item['cid'];
+ if($blowhard_count > 3)
+ $o .= '</div>';
+ $blowhard_count = 0;
+ }
+
+ $comments_seen = 0;
+ $comments_collapsed = false;
+ }
+ else
+ $comments_seen ++;
+ if(($comments[$item['parent']] > 2) && ($comments_seen <= ($comments[$item['parent']] - 2)) && ($item['gravity'] == 6)) {
+ if(! $comments_collapsed) {
+ $o .= '<div class="ccollapse-wrapper fakelink" id="ccollapse-wrapper-' . $item['parent'] . '" onclick="openClose(' . '\'ccollapse-' . $item['parent'] . '\');" >' . sprintf( t('See all %d comments'), $comments[$item['parent']]) . '</div>';
+ $o .= '<div class="ccollapse" id="ccollapse-' . $item['parent'] . '" style="display: none;" >';
+ $comments_collapsed = true;
+ }
+ }
+ if(($comments[$item['parent']] > 2) && ($comments_seen == ($comments[$item['parent']] - 1))) {
+ $o .= '</div>';
+ }
+
+ $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
$lock = ((($item['private']) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid'])
|| strlen($item['deny_cid']) || strlen($item['deny_gid']))))
@@ -480,6 +546,10 @@ function network_content(&$a, $update = 0) {
}
if(! $update) {
+ if($blowhard_count > 3)
+ $o .= '</div>';
+
+
$o .= paginate($a);
$o .= '<div class="cc-license">' . t('Shared content is covered by the <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0</a> license.') . '</div>';
}
diff --git a/mod/profile.php b/mod/profile.php
index 4b5f92a1f..1101c6998 100644
--- a/mod/profile.php
+++ b/mod/profile.php
@@ -243,31 +243,52 @@ function profile_content(&$a, $update = 0) {
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
- AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` AND `wall` = 1 )
+ AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 1
$sql_extra ",
intval($a->profile['profile_uid'])
);
- if(count($r))
+ if(count($r)) {
$a->set_pager_total($r[0]['total']);
+ $a->set_pager_itemspage(40);
+ }
- $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
- `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`network`, `contact`.`rel`,
- `contact`.`thumb`, `contact`.`self`,
- `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
+ $r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact-uid`
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
- AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` AND `wall` = 1 )
+ AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 1
$sql_extra
- ORDER BY `parent` DESC, `gravity` ASC, `id` ASC LIMIT %d ,%d ",
+ ORDER BY `item`.`created` DESC LIMIT %d ,%d ",
intval($a->profile['profile_uid']),
intval($a->pager['start']),
intval($a->pager['itemspage'])
);
+ $parents_arr = array();
+ $parents_str = '';
+
+ if(count($r)) {
+ foreach($r as $rr)
+ $parents_arr[] = $rr['item_id'];
+ $parents_str = implode(', ', $parents_arr);
+
+ $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
+ `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`network`, `contact`.`rel`,
+ `contact`.`thumb`, `contact`.`self`,
+ `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
+ FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
+ WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
+ AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
+ AND `item`.`parent` IN ( %s )
+ $sql_extra
+ ORDER BY `parent` DESC, `gravity` ASC, `item`.`id` ASC ",
+ intval($a->profile['profile_uid']),
+ dbesc($parents_str)
+ );
+ }
if($is_owner && ! $update)
$o .= get_birthdays();
@@ -292,11 +313,23 @@ function profile_content(&$a, $update = 0) {
if($r !== false && count($r)) {
+ $comments = array();
+ foreach($r as $rr) {
+ if(intval($rr['gravity']) == 6) {
+ if(! x($comments,$rr['parent']))
+ $comments[$rr['parent']] = 1;
+ else
+ $comments[$rr['parent']] += 1;
+ }
+ }
+
foreach($r as $item) {
like_puller($a,$item,$alike,'like');
like_puller($a,$item,$dlike,'dislike');
}
+ $comments_collapsed = false;
+
foreach($r as $item) {
$sparkle = '';
@@ -311,6 +344,25 @@ function profile_content(&$a, $update = 0) {
&& ($item['id'] != $item['parent']))
continue;
+ if($item['id'] == $item['parent']) {
+ $comments_seen = 0;
+ $comments_collapsed = false;
+ }
+ else
+ $comments_seen ++;
+
+
+ if(($comments[$item['parent']] > 2) && ($comments_seen <= ($comments[$item['parent']] - 2)) && ($item['gravity'] == 6)) {
+ if(! $comments_collapsed) {
+ $o .= '<div class="ccollapse-wrapper fakelink" id="ccollapse-wrapper-' . $item['parent'] . '" onclick="openClose(' . '\'ccollapse-' . $item['parent'] . '\');" >' . sprintf( t('See all %d comments'), $comments[$item['parent']]) . '</div>';
+ $o .= '<div class="ccollapse" id="ccollapse-' . $item['parent'] . '" style="display: none;" >';
+ $comments_collapsed = true;
+ }
+ }
+ if(($comments[$item['parent']] > 2) && ($comments_seen == ($comments[$item['parent']] - 1))) {
+ $o .= '</div></div>';
+ }
+
$lock = ((($item['private']) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid'])
|| strlen($item['deny_cid']) || strlen($item['deny_gid']))))
? '<div class="wall-item-lock"><img src="images/lock_icon.gif" class="lockview" alt="' . t('Private Message') . '" onclick="lockview(event,' . $item['id'] . ');" /></div>'
@@ -437,6 +489,5 @@ function profile_content(&$a, $update = 0) {
$o .= paginate($a);
$o .= '<div class="cc-license">' . t('Shared content is covered by the <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0</a> license.') . '</div>';
-
return $o;
}
diff --git a/mod/register.php b/mod/register.php
index 95e9d581f..06ed1e0f1 100644
--- a/mod/register.php
+++ b/mod/register.php
@@ -199,6 +199,24 @@ function register_post(&$a) {
return;
}
+ /**
+ * if somebody clicked submit twice very quickly, they could end up with two accounts
+ * due to race condition. Remove this one.
+ */
+
+ $r = q("SELECT `uid` FROM `user`
+ WHERE `nickname` = '%s' ",
+ dbesc($nickname)
+ );
+ if((count($r) > 1) && $newuid) {
+ $err .= t('Nickname is already registered. Please choose another.') . EOL;
+ q("DELETE FROM `user` WHERE `uid` = %d LIMIT 1",
+ intval($newuid)
+ );
+ notice ($err);
+ return;
+ }
+
if(x($newuid) !== false) {
$r = q("INSERT INTO `profile` ( `uid`, `profile-name`, `is-default`, `name`, `photo`, `thumb`, `publish`, `net-publish` )
VALUES ( %d, '%s', %d, '%s', '%s', '%s', %d, %d ) ",
diff --git a/mod/settings.php b/mod/settings.php
index 6a2733d7c..b20f4d11b 100644
--- a/mod/settings.php
+++ b/mod/settings.php
@@ -5,6 +5,7 @@ function settings_init(&$a) {
if(local_user()) {
profile_load($a,$a->user['nickname']);
}
+
}
@@ -341,9 +342,13 @@ function settings_content(&$a) {
$celeb = ((($a->user['page-flags'] == PAGE_SOAPBOX) || ($a->user['page-flags'] == PAGE_COMMUNITY)) ? true : false);
+ $uexport = '<div id="uexport-link"><a href="uexport" >' . t('Export Personal Data') . '</a></div>';
+
+
$o .= replace_macros($stpl,array(
'$baseurl' => $a->get_baseurl(),
'$oidhtml' => $oidhtml,
+ '$uexport' => $uexport,
'$uid' => local_user(),
'$username' => $username,
'$openid' => $openid,
diff --git a/mod/uexport.php b/mod/uexport.php
new file mode 100644
index 000000000..96f062c41
--- /dev/null
+++ b/mod/uexport.php
@@ -0,0 +1,72 @@
+<?php
+
+function uexport_init(&$a) {
+
+ if(! local_user())
+ killme();
+
+ $user = array();
+ $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
+ local_user()
+ );
+ if(count($r)) {
+ foreach($r as $rr)
+ foreach($rr as $k => $v)
+ $user[$k] = $v;
+
+ }
+ $contact = array();
+ $r = q("SELECT * FROM `contact` WHERE `uid` = %d ",
+ intval(local_user())
+ );
+ if(count($r)) {
+ foreach($r as $rr)
+ foreach($rr as $k => $v)
+ $contact[][$k] = $v;
+
+ }
+
+ $profile = array();
+ $r = q("SELECT * FROM `profile` WHERE `uid` = %d ",
+ intval(local_user())
+ );
+ if(count($r)) {
+ foreach($r as $rr)
+ foreach($rr as $k => $v)
+ $profile[][$k] = $v;
+ }
+
+ $output = array('user' => $user, 'contact' => $contact, 'profile' => $profile );
+
+ header("Content-type: application/json");
+ echo str_replace('\\/','/',json_encode($output));
+
+ $r = q("SELECT count(*) as `total` FROM `item` WHERE `uid` = %d ",
+ intval(local_user())
+ );
+ if(count($r))
+ $total = $r[0]['total'];
+
+ // chunk the output to avoid exhausting memory
+
+ for($x = 0; $x < $total; $x += 500) {
+ $item = array();
+ $r = q("SELECT * FROM `item` WHERE `uid` = %d LIMIT %d, %d",
+ intval(local_user()),
+ intval($x),
+ intval(500)
+ );
+ if(count($r)) {
+ foreach($r as $rr)
+ foreach($rr as $k => $v)
+ $item[][$k] = $v;
+ }
+
+ $output = array('item' => $item);
+ echo str_replace('\\/','/',json_encode($output));
+ }
+
+
+ killme();
+
+} \ No newline at end of file