aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/ItemObject.php1
-rw-r--r--include/conversation.php1
-rw-r--r--include/datetime.php2
-rw-r--r--include/dir_fns.php2
-rw-r--r--include/event.php34
-rw-r--r--include/externals.php21
-rwxr-xr-xinclude/items.php7
-rw-r--r--include/js_strings.php1
-rw-r--r--include/network.php159
-rw-r--r--include/taxonomy.php4
-rw-r--r--include/text.php38
-rw-r--r--include/widgets.php16
-rw-r--r--include/zot.php21
13 files changed, 263 insertions, 44 deletions
diff --git a/include/ItemObject.php b/include/ItemObject.php
index 512e12838..8be99d91e 100644
--- a/include/ItemObject.php
+++ b/include/ItemObject.php
@@ -346,6 +346,7 @@ class Item extends BaseObject {
'owner_photo' => $this->get_owner_photo(),
'owner_name' => $this->get_owner_name(),
'photo' => $body['photo'],
+ 'event' => $body['event'],
'has_tags' => $has_tags,
// Item toolbar buttons
diff --git a/include/conversation.php b/include/conversation.php
index 2c447acbc..3b534dc69 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -697,6 +697,7 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
'thumb' => $profile_avatar,
'title' => $item['title'],
'body' => $body['html'],
+ 'event' => $body['event'],
'photo' => $body['photo'],
'tags' => $body['tags'],
'categories' => $body['categories'],
diff --git a/include/datetime.php b/include/datetime.php
index f7df70a36..1d10e7ad7 100644
--- a/include/datetime.php
+++ b/include/datetime.php
@@ -235,7 +235,7 @@ function datetimesel($format, $min, $max, $default, $label, $id = 'datetimepicke
$o .= replace_macros($tpl,array(
'$field' => array($id, $label, $input_text, (($required) ? t('Required') : ''), (($required) ? '*' : ''), 'placeholder="' . $readable_format . '"'),
));
- $o .= "<script>\$(function () {var picker = \$('#id_$id').datetimepicker({step:5,format:'$dateformat' $minjs $maxjs $pickers $defaultdatejs,dayOfWeekStart:$first_day}); $extra_js})</script>";
+ $o .= "<script>\$(function () {var picker = \$('#id_$id').datetimepicker({step:15,format:'$dateformat' $minjs $maxjs $pickers $defaultdatejs,dayOfWeekStart:$first_day}); $extra_js})</script>";
return $o;
}
diff --git a/include/dir_fns.php b/include/dir_fns.php
index b9f221bd1..fd2a5835d 100644
--- a/include/dir_fns.php
+++ b/include/dir_fns.php
@@ -22,7 +22,7 @@ function find_upstream_directory($dirmode) {
$r = q("select * from site where site_url = '%s' limit 1",
dbesc($preferred)
);
- if(($r) && ($r[0]['site_flags'] & DIRECTORY_MODE_STADALONE)) {
+ if(($r) && ($r[0]['site_flags'] & DIRECTORY_MODE_STANDALONE)) {
$preferred = '';
}
}
diff --git a/include/event.php b/include/event.php
index e303ad232..539bfe484 100644
--- a/include/event.php
+++ b/include/event.php
@@ -21,35 +21,37 @@ function format_event_html($ev) {
$bd_format = t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8:01 AM
- $o = '<div class="vevent">' . "\r\n";
+ //todo: move this to template
- $o .= '<p class="summary event-summary">' . bbcode($ev['summary']) . '</p>' . "\r\n";
+ $o = '<div class="vevent">' . "\r\n";
- $o .= '<p class="description event-description">' . bbcode($ev['description']) . '</p>' . "\r\n";
+ $o .= '<div class="event-title"><h3><i class="icon-calendar"></i>&nbsp;' . bbcode($ev['summary']) . '</h3></div>' . "\r\n";
- $o .= '<p class="event-start">' . t('Starts:') . ' <abbr class="dtstart" title="'
+ $o .= '<div class="event-start"><span class="event-label">' . t('Starts:') . '</span>&nbsp;<span class="dtstart" title="'
. datetime_convert('UTC', 'UTC', $ev['start'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' ))
. '" >'
. (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(),
$ev['start'] , $bd_format ))
: day_translate(datetime_convert('UTC', 'UTC',
$ev['start'] , $bd_format)))
- . '</abbr></p>' . "\r\n";
+ . '</span></div>' . "\r\n";
if(! $ev['nofinish'])
- $o .= '<p class="event-end" >' . t('Finishes:') . ' <abbr class="dtend" title="'
+ $o .= '<div class="event-end" ><span class="event-label">' . t('Finishes:') . '</span>&nbsp;<span class="dtend" title="'
. datetime_convert('UTC','UTC',$ev['finish'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' ))
. '" >'
. (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(),
$ev['finish'] , $bd_format ))
: day_translate(datetime_convert('UTC', 'UTC',
$ev['finish'] , $bd_format )))
- . '</abbr></p>' . "\r\n";
+ . '</span></div>' . "\r\n";
+
+ $o .= '<div class="event-description">' . bbcode($ev['description']) . '</div>' . "\r\n";
if(strlen($ev['location']))
- $o .= '<p class="event-location"> ' . t('Location:') . ' <span class="location">'
+ $o .= '<div class="event-location"><span class="event-label"> ' . t('Location:') . '</span>&nbsp;<span class="location">'
. bbcode($ev['location'])
- . '</span></p>' . "\r\n";
+ . '</span></div>' . "\r\n";
$o .= '</div>' . "\r\n";
@@ -785,6 +787,12 @@ function event_store_item($arr, $event) {
'type' => ACTIVITY_OBJ_EVENT,
'id' => z_root() . '/event/' . $r[0]['resource_id'],
'title' => $arr['summary'],
+ 'start' => $arr['start'],
+ 'finish' => $arr['finish'],
+ 'nofinish' => $arr['nofinish'],
+ 'description' => $arr['description'],
+ 'location' => $arr['location'],
+ 'adjust' => $arr['adjust'],
'content' => format_event_bbcode($arr),
'author' => array(
'name' => $r[0]['xchan_name'],
@@ -887,7 +895,7 @@ function event_store_item($arr, $event) {
$item_arr['verb'] = ACTIVITY_POST;
$item_arr['item_wall'] = $item_wall;
$item_arr['item_origin'] = $item_origin;
- $item_arr['item_thread_top'] = $item_thread_top;;
+ $item_arr['item_thread_top'] = $item_thread_top;
$attach = array(array(
'href' => z_root() . '/events/ical/' . urlencode($event['event_hash']),
@@ -924,6 +932,12 @@ function event_store_item($arr, $event) {
'type' => ACTIVITY_OBJ_EVENT,
'id' => z_root() . '/event/' . $event['event_hash'],
'title' => $arr['summary'],
+ 'start' => $arr['start'],
+ 'finish' => $arr['finish'],
+ 'nofinish' => $arr['nofinish'],
+ 'description' => $arr['description'],
+ 'location' => $arr['location'],
+ 'adjust' => $arr['adjust'],
'content' => format_event_bbcode($arr),
'author' => array(
'name' => $x[0]['xchan_name'],
diff --git a/include/externals.php b/include/externals.php
index 18c034bb2..3a3a32420 100644
--- a/include/externals.php
+++ b/include/externals.php
@@ -28,7 +28,10 @@ function externals_run($argv, $argc){
}
else {
$randfunc = db_getfunc('RAND');
- $r = q("select site_url, site_pull from site where site_url != '%s' and site_flags != %d and site_type = %d order by $randfunc limit 1",
+
+ // fixme this query does not deal with directory realms.
+
+ $r = q("select site_url, site_pull from site where site_url != '%s' and site_flags != %d and site_type = %d and site_dead = 0 order by $randfunc limit 1",
dbesc(z_root()),
intval(DIRECTORY_MODE_STANDALONE),
intval(SITE_TYPE_ZOT)
@@ -37,19 +40,11 @@ function externals_run($argv, $argc){
$url = $r[0]['site_url'];
}
- // Note: blacklisted sites must be stored in the config as an array.
- // No simple way to turn this into a personal config because we have no identity here.
- // For that we probably need a variant of superblock.
-
$blacklisted = false;
- $bl1 = get_config('system','blacklisted_sites');
- if(is_array($bl1) && $bl1) {
- foreach($bl1 as $bl) {
- if($bl && strpos($url,$bl) !== false) {
- $blacklisted = true;
- break;
- }
- }
+
+ if(! check_siteallowed($url)) {
+ logger('blacklisted site: ' . $url);
+ $blacklisted = true;
}
$attempts ++;
diff --git a/include/items.php b/include/items.php
index 7d349c631..46b396ad2 100755
--- a/include/items.php
+++ b/include/items.php
@@ -550,6 +550,7 @@ function get_public_feed($channel, $params) {
$params['direction'] = ((x($params,'direction')) ? $params['direction'] : 'desc');
$params['pages'] = ((x($params,'pages')) ? intval($params['pages']) : 0);
$params['top'] = ((x($params,'top')) ? intval($params['top']) : 0);
+ $params['cat'] = ((x($params,'cat')) ? $params['cat'] : '');
switch($params['type']) {
case 'json':
@@ -593,7 +594,8 @@ function get_feed_for($channel, $observer_hash, $params) {
'direction' => $params['direction'], // FIXME
'pages' => $params['pages'],
'order' => 'post',
- 'top' => $params['top']
+ 'top' => $params['top'],
+ 'cat' => $params['cat']
), $channel, $observer_hash, CLIENT_MODE_NORMAL, get_app()->module);
@@ -4817,6 +4819,9 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C
if($arr['since_id'])
$sql_extra .= " and item.id > " . $since_id . " ";
+ if($arr['cat'])
+ $sql_extra .= protect_sprintf(term_query('item', $arr['cat'], TERM_CATEGORY));
+
if($arr['gid'] && $uid) {
$r = q("SELECT * FROM `groups` WHERE id = %d AND uid = %d LIMIT 1",
intval($arr['group']),
diff --git a/include/js_strings.php b/include/js_strings.php
index a21461a52..b1817f373 100644
--- a/include/js_strings.php
+++ b/include/js_strings.php
@@ -22,6 +22,7 @@ function js_strings() {
'$submit' => t('Submit'),
'$linkurl' => t('Please enter a link URL'),
'$leavethispage' => t('Unsaved changes. Are you sure you wish to leave this page?'),
+ '$location' => t('Location'),
'$t01' => ((t('timeago.prefixAgo') != 'timeago.prefixAgo') ? t('timeago.prefixAgo') : ''),
'$t02' => ((t('timeago.prefixFromNow') != 'timeago.prefixFromNow') ? t('timeago.prefixFromNow') : ''),
diff --git a/include/network.php b/include/network.php
index 026f5ee0a..e906fc7cb 100644
--- a/include/network.php
+++ b/include/network.php
@@ -1709,3 +1709,162 @@ function do_delivery($deliveries) {
}
+
+
+function get_site_info() {
+
+ global $db;
+ global $a;
+
+ $register_policy = Array('REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN');
+ $directory_mode = Array('DIRECTORY_MODE_NORMAL', 'DIRECTORY_MODE_SECONDARY','DIRECTORY_MODE_PRIMARY', 256 => 'DIRECTORY_MODE_STANDALONE');
+
+ $sql_extra = '';
+
+ $r = q("select * from channel left join account on account_id = channel_account_id where ( account_roles & 4096 )>0 and account_default_channel = channel_id");
+
+
+ if($r) {
+ $admin = array();
+ foreach($r as $rr) {
+ if($rr['channel_pageflags'] & PAGE_HUBADMIN)
+ $admin[] = array( 'name' => $rr['channel_name'], 'address' => $rr['channel_address'] . '@' . get_app()->get_hostname(), 'channel' => z_root() . '/channel/' . $rr['channel_address']);
+ }
+ if(! $admin) {
+ foreach($r as $rr) {
+ $admin[] = array( 'name' => $rr['channel_name'], 'address' => $rr['channel_address'] . '@' . get_app()->get_hostname(), 'channel' => z_root() . '/channel/' . $rr['channel_address']);
+ }
+ }
+ }
+ else {
+ $admin = false;
+ }
+
+ $def_service_class = get_config('system','default_service_class');
+ if($def_service_class)
+ $service_class = get_config('service_class',$def_service_class);
+ else
+ $service_class = false;
+
+ $visible_plugins = array();
+ if(is_array($a->plugins) && count($a->plugins)) {
+ $r = q("select * from addon where hidden = 0");
+ if(count($r))
+ foreach($r as $rr)
+ $visible_plugins[] = $rr['name'];
+ }
+ sort($visible_plugins);
+
+ if(@is_dir('.git') && function_exists('shell_exec'))
+ $commit = trim(@shell_exec('git log -1 --format="%h"'));
+ if(! isset($commit) || strlen($commit) > 16)
+ $commit = '';
+
+ $site_info = get_config('system','info');
+ $site_name = get_config('system','sitename');
+ if(! get_config('system','hidden_version_siteinfo')) {
+ $version = RED_VERSION;
+ if(@is_dir('.git') && function_exists('shell_exec')) {
+ $commit = trim( @shell_exec('git log -1 --format="%h"'));
+ if(! get_config('system','hidden_tag_siteinfo'))
+ $tag = trim( @shell_exec('git describe --tags --abbrev=0'));
+ else
+ $tag = '';
+ }
+ if(! isset($commit) || strlen($commit) > 16)
+ $commit = '';
+ }
+ else {
+ $version = $commit = '';
+ }
+
+ //Statistics
+ $channels_total_stat = intval(get_config('system','channels_total_stat'));
+ $channels_active_halfyear_stat = intval(get_config('system','channels_active_halfyear_stat'));
+ $channels_active_monthly_stat = intval(get_config('system','channels_active_monthly_stat'));
+ $local_posts_stat = intval(get_config('system','local_posts_stat'));
+ $hide_in_statistics = intval(get_config('system','hide_in_statistics'));
+ $site_expire = intval(get_config('system', 'default_expire_days'));
+
+
+ $data = Array(
+ 'version' => $version,
+ 'version_tag' => $tag,
+ 'commit' => $commit,
+ 'url' => z_root(),
+ 'plugins' => $visible_plugins,
+ 'register_policy' => $register_policy[get_config('system','register_policy')],
+ 'directory_mode' => $directory_mode[get_config('system','directory_mode')],
+ 'language' => get_config('system','language'),
+ 'rss_connections' => get_config('system','feed_contacts'),
+ 'expiration' => $site_expire,
+ 'default_service_restrictions' => $service_class,
+ 'admin' => $admin,
+ 'site_name' => (($site_name) ? $site_name : ''),
+ 'platform' => PLATFORM_NAME,
+ 'dbdriver' => $db->getdriver(),
+ 'lastpoll' => get_config('system','lastpoll'),
+ 'info' => (($site_info) ? $site_info : ''),
+ 'channels_total' => $channels_total_stat,
+ 'channels_active_halfyear' => $channels_active_halfyear_stat,
+ 'channels_active_monthly' => $channels_active_monthly_stat,
+ 'local_posts' => $local_posts_stat,
+ 'hide_in_statistics' => $hide_in_statistics
+ );
+ return $data;
+}
+
+
+
+function check_siteallowed($url) {
+
+ $retvalue = true;
+
+ $bl1 = get_config('system','whitelisted_sites');
+ if(is_array($bl1) && $bl1) {
+ foreach($bl1 as $bl) {
+ if($bl1 === '*')
+ $retvalue = true;
+ if($bl && strpos($url,$bl) !== false)
+ return true;
+ }
+ }
+ $bl1 = get_config('system','blacklisted_sites');
+ if(is_array($bl1) && $bl1) {
+ foreach($bl1 as $bl) {
+ if($bl1 === '*')
+ $retvalue = false;
+ if($bl && strpos($url,$bl) !== false) {
+ return false;
+ }
+ }
+ }
+ return $retvalue;
+}
+
+function check_channelallowed($hash) {
+
+ $retvalue = true;
+
+ $bl1 = get_config('system','whitelisted_channels');
+ if(is_array($bl1) && $bl1) {
+ foreach($bl1 as $bl) {
+ if($bl1 === '*')
+ $retvalue = true;
+ if($bl && strpos($hash,$bl) !== false)
+ return true;
+ }
+ }
+ $bl1 = get_config('system','blacklisted_channels');
+ if(is_array($bl1) && $bl1) {
+ foreach($bl1 as $bl) {
+ if($bl1 === '*')
+ $retvalue = false;
+ if($bl && strpos($hash,$bl) !== false) {
+ return false;
+ }
+ }
+ }
+ return $retvalue;
+}
+
diff --git a/include/taxonomy.php b/include/taxonomy.php
index b396d53f1..0bf89a7c1 100644
--- a/include/taxonomy.php
+++ b/include/taxonomy.php
@@ -117,6 +117,8 @@ function tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags = 0, $re
if(! perm_is_allowed($uid,get_observer_hash(),'view_stream'))
return array();
+
+ $item_normal = item_normal();
$sql_options = item_permissions_sql($uid);
$count = intval($count);
@@ -142,7 +144,7 @@ function tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags = 0, $re
$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_type = %d and item_private = 0
- $sql_options
+ $sql_options $item_normal
group by term order by total desc %s",
intval($uid),
intval($type),
diff --git a/include/text.php b/include/text.php
index eb9171b40..4777e7a61 100644
--- a/include/text.php
+++ b/include/text.php
@@ -5,6 +5,7 @@
require_once("include/template_processor.php");
require_once("include/smarty.php");
+require_once("include/bbcode.php");
// random string, there are 86 characters max in text mode, 128 for hex
// output is urlsafe
@@ -1380,7 +1381,37 @@ function generate_named_map($location) {
return (($arr['html']) ? $arr['html'] : $location);
}
+function format_event($jobject) {
+ $event = array();
+ $object = json_decode($jobject,true);
+
+ //ensure compatibility with older items - this check can be removed at a later point
+ if(array_key_exists('description', $object)) {
+
+ $bd_format = t('l F d, Y \@ g:i A'); // Friday January 18, 2011 @ 8:01 AM
+
+ $event['header'] = replace_macros(get_markup_template('event_item_header.tpl'),array(
+ '$title' => bbcode($object['title']),
+ '$dtstart_label' => t('Starts:'),
+ '$dtstart_title' => datetime_convert('UTC', 'UTC', $object['start'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )),
+ '$dtstart_dt' => (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['start'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['start'] , $bd_format))),
+ '$finish' => (($object['nofinish']) ? false : true),
+ '$dtend_label' => t('Finishes:'),
+ '$dtend_title' => datetime_convert('UTC','UTC',$object['finish'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )),
+ '$dtend_dt' => (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['finish'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['finish'] , $bd_format )))
+ ));
+
+ $event['content'] = replace_macros(get_markup_template('event_item_content.tpl'),array(
+ '$description' => bbcode($object['description']),
+ '$location_label' => t('Location:'),
+ '$location' => bbcode($object['location'])
+ ));
+
+ }
+
+ return $event;
+}
function prepare_body(&$item,$attach = false) {
require_once('include/identity.php');
@@ -1413,9 +1444,12 @@ function prepare_body(&$item,$attach = false) {
}
}
+ $event = (($item['obj_type'] === ACTIVITY_OBJ_EVENT) ? format_event($item['object']) : false);
+
$prep_arr = array(
'item' => $item,
- 'html' => $s,
+ 'html' => $event ? $event['content'] : $s,
+ 'event' => $event['header'],
'photo' => $photo
);
@@ -1423,6 +1457,7 @@ function prepare_body(&$item,$attach = false) {
$s = $prep_arr['html'];
$photo = $prep_arr['photo'];
+ $event = $prep_arr['event'];
// q("update item set html = '%s' where id = %d",
// dbesc($s),
@@ -1489,6 +1524,7 @@ function prepare_body(&$item,$attach = false) {
'item' => $item,
'photo' => $photo,
'html' => $s,
+ 'event' => $event,
'categories' => $categories,
'folders' => $filer,
'tags' => $tags,
diff --git a/include/widgets.php b/include/widgets.php
index a3f7444ec..d4f3d32e1 100644
--- a/include/widgets.php
+++ b/include/widgets.php
@@ -666,7 +666,7 @@ function widget_eventsmenu($arr) {
if (! local_channel())
return;
- return replace_macros(get_markup_template('events_side.tpl'), array(
+ return replace_macros(get_markup_template('events_menu_side.tpl'), array(
'$title' => t('Events Menu'),
'$day' => t('Day View'),
'$week' => t('Week View'),
@@ -677,6 +677,18 @@ function widget_eventsmenu($arr) {
));
}
+function widget_eventstools($arr) {
+ if (! local_channel())
+ return;
+
+ return replace_macros(get_markup_template('events_tools_side.tpl'), array(
+ '$title' => t('Events Tools'),
+ '$export' => t('Export Calendar'),
+ '$import' => t('Import Calendar'),
+ '$submit' => t('Submit')
+ ));
+}
+
function widget_design_tools($arr) {
$a = get_app();
@@ -1147,6 +1159,8 @@ function widget_forums($arr) {
function widget_tasklist($arr) {
+ if (! local_channel())
+ return;
require_once('include/event.php');
$o .= '<script>var tasksShowAll = 0; $(document).ready(function() { tasksFetch(); $("#tasklist-new-form").submit(function(event) { event.preventDefault(); $.post( "tasks/new", $("#tasklist-new-form").serialize(), function(data) { tasksFetch(); $("#tasklist-new-summary").val(""); } ); return false; } )});</script>';
diff --git a/include/zot.php b/include/zot.php
index 2366c1d2d..6764072aa 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -554,18 +554,8 @@ function zot_gethub($arr,$multiple = false) {
if($arr['guid'] && $arr['guid_sig'] && $arr['url'] && $arr['url_sig']) {
- $blacklisted = false;
- $bl1 = get_config('system','blacklisted_sites');
- if(is_array($bl1) && $bl1) {
- foreach($bl1 as $bl) {
- if($bl && strpos($arr['url'],$bl) !== false) {
- $blacklisted = true;
- break;
- }
- }
- }
- if($blacklisted) {
- logger('zot_gethub: blacklisted site: ' . $arr['url']);
+ if(! check_siteallowed($arr['url'])) {
+ logger('blacklisted site: ' . $arr['url']);
return null;
}
@@ -1246,6 +1236,10 @@ function zot_import($arr, $sender_url) {
$no_dups = array();
if($deliveries) {
foreach($deliveries as $d) {
+ if(! is_array($d)) {
+ logger('Delivery hash array is not an array: ' . print_r($d,true));
+ continue;
+ }
if(! in_array($d['hash'],$no_dups))
$no_dups[] = $d['hash'];
}
@@ -3951,9 +3945,6 @@ function delivery_report_is_storable($dr) {
return false;
-
-
-
// is the recipient one of our connections, or do we want to store every report?
$r = explode(' ', $dr['recipient']);