Merge pull request #1008 from annando/master

Expire, "attachment" element and database structure
This commit is contained in:
fabrixxm 2014-06-14 20:05:10 +02:00
commit adefb06ff7
13 changed files with 588 additions and 376 deletions

View file

@ -143,6 +143,7 @@ define ( 'NETWORK_PUMPIO', 'pump'); // pump.io
define ( 'NETWORK_TWITTER', 'twit'); // Twitter
define ( 'NETWORK_DIASPORA2', 'dspc'); // Diaspora connector
define ( 'NETWORK_STATUSNET', 'stac'); // Statusnet connector
define ( 'NETWORK_APPNET', 'apdn'); // app.net
define ( 'NETWORK_PHANTOM', 'unkn'); // Place holder
@ -169,6 +170,7 @@ $netgroup_ids = array(
NETWORK_TWITTER => (-14),
NETWORK_DIASPORA2 => (-15),
NETWORK_STATUSNET => (-16),
NETWORK_APPNET => (-17),
NETWORK_PHANTOM => (-127),
);
@ -1000,6 +1002,10 @@ if(! function_exists('update_db')) {
if(DB_UPDATE_VERSION == UPDATE_VERSION) {
// Compare the current structure with the defined structure
require_once("include/dbstructure.php");
update_structure(false, true);
for($x = $stored; $x < $current; $x ++) {
if(function_exists('update_' . $x)) {

View file

@ -2,6 +2,79 @@
require_once("include/oembed.php");
require_once('include/event.php');
function bb_attachment($Text, $plaintext = false, $tryoembed = true) {
$Text = preg_replace_callback("/\[attachment(.*?)\](.*?)\[\/attachment\]/ism",
function ($match) use ($plaintext){
$attributes = $match[1];
$type = "";
preg_match("/type='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
$type = $matches[1];
preg_match('/type="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "")
$type = $matches[1];
if ($type == "")
return($match[0]);
if (!in_array($type, array("link", "audio", "video")))
return($match[0]);
$url = "";
preg_match("/url='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
$url = $matches[1];
preg_match('/url="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "")
$url = $matches[1];
$title = "";
preg_match("/title='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
$title = $matches[1];
preg_match('/title="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "")
$title = $matches[1];
$image = "";
preg_match("/image='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "")
$image = $matches[1];
preg_match('/image="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "")
$image = $matches[1];
if ($plaintext)
$text = sprintf('<a href="%s" target="_blank">%s</a>', $url, $title);
else {
$text = sprintf('<span class="type-%s">', $type);
$bookmark = array(sprintf('[bookmark=%s]%s[/bookmark]', $url, $title), $title, $url);
if ($tryoembed)
$oembed = tryoembed($bookmark);
else
$oembed = $bookmark[0];
if (($image != "") AND !strstr(strtolower($oembed), "<img "))
$text .= sprintf('<img src="%s" alt="%s" />', $image, $title); // To-Do: Anführungszeichen in "alt"
$text .= $oembed;
$text .= sprintf('<blockquote>%s</blockquote></span>', trim($match[2]));
}
return($text);
},$Text);
return($Text);
}
function bb_rearrange_link($shared) {
if ($shared[1] != "type-link")
return($shared[0]);
@ -535,6 +608,10 @@ function GetProfileUsername($profile, $username) {
if ($twitter != $profile)
return($username." (".$twitter.")");
$appnet = preg_replace("=https?://alpha.app.net/(.*)=ism", "$1@alpha.app.net", $profile);
if ($appnet != $profile)
return($username." (".$appnet.")");
$gplus = preg_replace("=https?://plus.google.com/(.*)=ism", "$1@plus.google.com", $profile);
if ($gplus != $profile)
return($username." (".$gplus.")");
@ -561,7 +638,7 @@ function GetProfileUsername($profile, $username) {
// pumpio (http://host.name/user)
$rest = preg_replace("=https?://([\.\w]+)/([\.\w]+)(.*)=ism", "$3", $profile);
if ($rest == "") {
$pumpio = preg_replace("=https?://([\.\w]+)/([\.\w]+)(.*)=ism", "*$2@$1*", $profile);
$pumpio = preg_replace("=https?://([\.\w]+)/([\.\w]+)(.*)=ism", "$2@$1", $profile);
if ($pumpio != $profile)
return($username." (".$pumpio.")");
}
@ -706,6 +783,9 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
$Text = preg_replace("/\n\[code\]/ism", "[code]", $Text);
$Text = preg_replace("/\[\/code\]\n/ism", "[/code]", $Text);
// Handle attached links or videos
$Text = bb_attachment($Text, ($simplehtml != 4) AND ($simplehtml != 0), $tryoembed);
// Rearrange shared links
if (get_config("system", "rearrange_shared_links") AND (!$simplehtml OR $tryoembed))
$Text = preg_replace_callback("(\[class=(.*?)\](.*?)\[\/class\])ism","bb_rearrange_link",$Text);
@ -822,8 +902,8 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
// Check for sized text
// [size=50] --> font-size: 50px (with the unit).
$Text = preg_replace("(\[size=(\d*?)\](.*?)\[\/size\])ism","<span style=\"font-size: $1px;\">$2</span>",$Text);
$Text = preg_replace("(\[size=(.*?)\](.*?)\[\/size\])ism","<span style=\"font-size: $1;\">$2</span>",$Text);
$Text = preg_replace("(\[size=(\d*?)\](.*?)\[\/size\])ism","<span style=\"font-size: $1px; line-height: initial;\">$2</span>",$Text);
$Text = preg_replace("(\[size=(.*?)\](.*?)\[\/size\])ism","<span style=\"font-size: $1; line-height: initial;\">$2</span>",$Text);
// Check for centered text
$Text = preg_replace("(\[center\](.*?)\[\/center\])ism","<div style=\"text-align:center;\">$1</div>",$Text);

View file

@ -88,7 +88,8 @@ function network_to_name($s) {
NETWORK_PUMPIO => t('pump.io'),
NETWORK_TWITTER => t('Twitter'),
NETWORK_DIASPORA2 => t('Diaspora Connector'),
NETWORK_STATUSNET => t('Statusnet')
NETWORK_STATUSNET => t('Statusnet'),
NETWORK_APPNET => t('App.net')
);
call_hooks('network_to_name', $nets);

File diff suppressed because it is too large Load diff

View file

@ -47,6 +47,10 @@ function expire_run(&$argv, &$argc){
}
}
load_hooks();
call_hooks('expire');
return;
}

View file

@ -4102,7 +4102,7 @@ function item_getfeedattach($item) {
function item_expire($uid,$days) {
function item_expire($uid, $days, $network = "", $force = false) {
if((! $uid) || ($days < 1))
return;
@ -4113,9 +4113,17 @@ function item_expire($uid,$days) {
$expire_network_only = get_pconfig($uid,'expire','network_only');
$sql_extra = ((intval($expire_network_only)) ? " AND wall = 0 " : "");
if ($network != "") {
$sql_extra .= sprintf(" AND network = '%s' ", dbesc($network));
// There is an index "uid_network_received" but not "uid_network_created"
// This avoids the creation of another index just for one purpose.
// And it doesn't really matter wether to look at "received" or "created"
$range = "AND `received` < UTC_TIMESTAMP() - INTERVAL %d DAY ";
} else
$range = "AND `created` < UTC_TIMESTAMP() - INTERVAL %d DAY ";
$r = q("SELECT * FROM `item`
WHERE `uid` = %d
AND `created` < UTC_TIMESTAMP() - INTERVAL %d DAY
WHERE `uid` = %d $range
AND `id` = `parent`
$sql_extra
AND `deleted` = 0",
@ -4129,6 +4137,10 @@ function item_expire($uid,$days) {
$expire_items = get_pconfig($uid, 'expire','items');
$expire_items = (($expire_items===false)?1:intval($expire_items)); // default if not set: 1
// Forcing expiring of items - but not notes and marked items
if ($force)
$expire_items = true;
$expire_notes = get_pconfig($uid, 'expire','notes');
$expire_notes = (($expire_notes===false)?1:intval($expire_notes)); // default if not set: 1

View file

@ -90,9 +90,30 @@ function community_content(&$a, $update = 0) {
return $o;
}
$maxpostperauthor = get_config('system','max_author_posts_community_page');
if ($maxpostperauthor != 0) {
$previousauthor = "";
$numposts = 0;
$s = array();
foreach ($r AS $row=>$item) {
if ($previousauthor == $item["author-link"])
++$numposts;
else
$numposts = 0;
$previousauthor = $item["author-link"];
if ($numposts < $maxpostperauthor)
$s[] = $item;
}
} else
$s = $r;
// we behave the same in message lists as the search module
$o .= conversation($a,$r,'community',$update);
$o .= conversation($a,$s,'community',$update);
if(get_config('alt_pager', 'global') || get_pconfig(local_user(),'system','alt_pager') ) {
$o .= alt_pager($a,count($r));

View file

@ -498,7 +498,10 @@ function load_database_rem($v, $i){
function load_database($db) {
$str = file_get_contents('database.sql');
require_once("include/dbstructure.php");
$errors = update_structure(false, true);
/* $str = file_get_contents('database.sql');
$arr = explode(';',$str);
$errors = false;
foreach($arr as $a) {
@ -508,7 +511,8 @@ function load_database($db) {
$errors .= t('Errors encountered creating database tables.') . $a . EOL;
}
}
}
}*/
return $errors;
}

View file

@ -1127,7 +1127,8 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) {
if(count($r)) {
$profile = $r[0]['url'];
//set newname to nick, find alias
if(($r[0]['network'] === NETWORK_OSTATUS) OR ($r[0]['network'] === NETWORK_TWITTER) OR ($r[0]['network'] === NETWORK_STATUSNET)) {
if(($r[0]['network'] === NETWORK_OSTATUS) OR ($r[0]['network'] === NETWORK_TWITTER)
OR ($r[0]['network'] === NETWORK_STATUSNET) OR ($r[0]['network'] === NETWORK_APPNET)) {
$newname = $r[0]['nick'];
$stat = true;
if($r[0]['alias'])

View file

@ -26,10 +26,9 @@ define( 'UPDATE_VERSION' , 1170 );
* The DB_UPDATE_VERSION will always be one greater than the last numbered script in this file.
*
* If you change the database schema, the following are required:
* 1. Update the file database.sql to match the new schema.
* 2. Update this file by adding a new function at the end with the number of the current DB_UPDATE_VERSION.
* This function should modify the current database schema and perform any other steps necessary
* to ensure that upgrade is silent and free from requiring interaction.
* 1. Update the file include/dbstructure.php to match the new schema.
* 2. If there is a need for a post procession, update this file by adding a new function at the end with the number of the current DB_UPDATE_VERSION.
* This function should perform some post procession steps but no database updates.
* 3. Increment the DB_UPDATE_VERSION in boot.php *AND* the UPDATE_VERSION in this file to match it
* 4. TEST the upgrade prior to checkin and filing a pull request.
*

View file

@ -193,26 +193,35 @@ img {
margin-bottom: 5px;
}
div.pager a {
margin-left: 5px;
margin-right: 5px;
}
span.pager_first a, span.pager_n a,
span.pager_last a, span.pager_prev a, span.pager_next a {
color: darkgray;
}
div.pager {
/* .birthday-notice { */
clear: left;
text-align: center;
/*
height: 1.2em;
padding-bottom: 12px;
color: black;
/*-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;*/
background-color: #f2f2f2;
clear: left;
margin-top: 5px;
padding: 1%;
height: 1em;
margin-bottom: 5px;
}*/
*/
}
.birthday-notice {
.birthday-notice, .event-notice {
margin-top: 5px;
margin-bottom: 5px;
background-color: #F5F5F5;
}
#live-network {
@ -383,7 +392,8 @@ code {
#sidebar-ungrouped:hover, .side-link:hover, .nets-ul li:hover, #forum-list div:hover,
.nets-all:hover, .saved-search-li:hover, li.tool:hover, .admin.link:hover, aside h4 a:hover, #message-new:hover {
/* background-color: #ddd; */
background-color: #e5e5e5;
/* background-color: #e5e5e5; */
background-color: #F5F5F5;
}
#message-new a {
@ -1866,16 +1876,21 @@ h2 {
}
/** /acl **/
/** tab buttons **/
ul.tabs {
div.pager, ul.tabs {
list-style-type: none;
padding-bottom: 10px;
padding-left: 0px;
padding-left: 10px;
padding-top: 0px;
margin-bottom: 5px;
line-height: 27px;
height: 27px;
font-size: 11px;
line-height: 28px;
height: 20px;
/* font-size: 11px; */
font-size: 13px;
font-weight: bold;
/* margin-bottom: 30px; */
background-color: #FAFAFA;
box-shadow: 1px 2px 0px 0px #D8D8D8;
border-bottom: 1px solid #D2D2D2;
}
ul.tabs li {
float: left;
@ -1885,18 +1900,21 @@ ul.tabs li {
border-bottom: 1px solid #005c94;
}*/
ul.tabs a {
ul.tabs a, div.pager a {
/* min-width: 34px; */
display: block;
float: left;
padding-bottom: 0px;
padding: 0px 12px 0px 12px;
color: #444;
/* display: block;
float: left; */
padding: 0px;
padding-bottom: 6px;
/* padding: 0px 12px 0px 12px; */
/* color: #444; */
color: darkgray;
}
ul.tabs a {
box-shadow: 1px 2px 0px 0px #D8D8D8;
margin-right: 5px;
/* box-shadow: 1px 2px 0px 0px #D8D8D8; */
margin-right: 15px;
margin-left: 5px;
}
#birthday-notice, #event-notice {
@ -1914,30 +1932,49 @@ ul.tabs a {
margin-bottom: 0px;
}
div.pager, .birthday-notice, .comment-edit-submit-wrapper .fakelink {
.birthday-notice, .event-notice {
padding: 2px 7px 2px 7px;
color: darkgrey;
font-weight: bold;
}
.comment-edit-submit-wrapper .fakelink {
padding: 2px 7px 2px 7px;
color: black;
}
div.pager, .birthday-notice, ul.tabs a, .comment-edit-submit-wrapper .fakelink {
border: 1px solid lightgray;
.comment-edit-submit-wrapper .fakelink {
/* border: 1px solid lightgray; */
background: #F2F2F2;
margin-top: 2px;
margin-bottom: 2px;
}
ul.tabs a:hover {
color: #333;
}
#event-notice:hover, #birthday-notice:hover, ul.tabs li .active, .comment-edit-submit-wrapper .fakelink:hover {
#event-notice:hover, #birthday-notice:hover, ul.tabs li .active,
.comment-edit-submit-wrapper .fakelink:hover {
color: black;
}
ul.tabs a:hover, #event-notice:hover, #birthday-notice:hover, ul.tabs li .active, .comment-edit-submit-wrapper .fakelink:hover {
background-color: #e5e5e5;
span.pager_current, span.pager_n a:hover,
span.pager_first a:hover, span.pager_last a:hover,
span.pager_prev a:hover, span.pager_next a:hover,
ul.tabs a:hover {
border-bottom: 2px solid #244C5E;
text-decoration: none;
border: 1px solid darkgray;
color: grey;
padding-bottom: 6px;
}
ul.tabs li .active, span.pager_current a {
border-bottom: 2px solid #244C5E;
text-decoration: none;
color: black;
}
#event-notice:hover, #birthday-notice:hover, .comment-edit-submit-wrapper .fakelink:hover {
/* background-color: #e5e5e5; */
color: grey;
text-decoration: none;
/* border: 1px solid darkgray; */
}
.comment-edit-bb {
@ -2077,8 +2114,10 @@ aside form .field label {
/* contacts */
.contact-entry-wrapper {
width: 120px;
height: 120px;
height: 130px;
float: left;
/* overflow: hidden; */
margin-left: 5px;
}
/* photo */
.lframe {

View file

@ -99,7 +99,7 @@
{{if $item.threaded}}
{{/if}}
{{if $item.comment}}
<span id="comment-{{$item.id}}" class="fakelink togglecomment" onclick="openClose('item-comments-{{$item.id}}'); commentExpand({{$item.id}});"><i class="icon-reply"></i></span>
<span id="comment-{{$item.id}}" class="fakelink togglecomment" onclick="openClose('item-comments-{{$item.id}}'); commentExpand({{$item.id}});" title="{{$item.switchcomment}}"><i class="icon-reply"></i></span>
{{/if}}
{{if $item.vote}}
{{if $item.vote.like}}