aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/attach.php1
-rw-r--r--include/bbcode.php10
-rw-r--r--include/config.php6
-rw-r--r--include/dir_fns.php5
-rw-r--r--include/event.php50
-rw-r--r--include/widgets.php57
6 files changed, 114 insertions, 15 deletions
diff --git a/include/attach.php b/include/attach.php
index 8541c142c..ad6ca1b21 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -567,6 +567,7 @@ function z_readdir($channel_id, $observer_hash, $pathname, $parent_hash = '') {
* $arr['deny_cid']
* $arr['deny_gid']
*/
+
function attach_mkdir($channel, $observer_hash, $arr = null) {
$ret = array('success' => false);
diff --git a/include/bbcode.php b/include/bbcode.php
index 6b7217f91..5b7451a6b 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -431,14 +431,16 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
// replace [observer.baseurl]
if ($observer) {
+ $s1 = '<span class="bb_observer">';
+ $s2 = '</span>';
$obsBaseURL = $observer['xchan_connurl'];
$obsBaseURL = preg_replace("/\/poco\/.*$/", '', $obsBaseURL);
$Text = str_replace('[observer.baseurl]', $obsBaseURL, $Text);
$Text = str_replace('[observer.url]',$observer['xchan_url'], $Text);
- $Text = str_replace('[observer.name]',$observer['xchan_name'], $Text);
- $Text = str_replace('[observer.address]',$observer['xchan_addr'], $Text);
- $Text = str_replace('[observer.webname]',substr($observer['xchan_addr'],0,strpos($observer['xchan_addr'],'@')), $Text);
- $Text = str_replace('[observer.photo]','[zmg]'.$observer['xchan_photo_l'].'[/zmg]', $Text);
+ $Text = str_replace('[observer.name]',$s1 . $observer['xchan_name'] . $s2, $Text);
+ $Text = str_replace('[observer.address]',$s1 . $observer['xchan_addr'] . $s2, $Text);
+ $Text = str_replace('[observer.webname]',$s1 . substr($observer['xchan_addr'],0,strpos($observer['xchan_addr'],'@')) . $s2, $Text);
+ $Text = str_replace('[observer.photo]',$s1 . '[zmg]'.$observer['xchan_photo_l'].'[/zmg]' . $s2, $Text);
} else {
$Text = str_replace('[observer.baseurl]', '', $Text);
$Text = str_replace('[observer.url]','', $Text);
diff --git a/include/config.php b/include/config.php
index 9eaa6b2e6..87b91e51a 100644
--- a/include/config.php
+++ b/include/config.php
@@ -212,7 +212,7 @@ function load_pconfig($uid) {
if(! array_key_exists($uid, $a->config))
$a->config[$uid] = array();
- $r = q("SELECT * FROM `pconfig` WHERE `uid` = %d",
+ $r = q("SELECT * FROM pconfig WHERE uid = %d",
intval($uid)
);
@@ -390,7 +390,7 @@ function load_xconfig($xchan) {
if(! array_key_exists($xchan, $a->config))
$a->config[$xchan] = array();
- $r = q("SELECT * FROM `xconfig` WHERE `xchan` = '%s'",
+ $r = q("SELECT * FROM xconfig WHERE xchan = '%s'",
dbesc($xchan)
);
@@ -517,7 +517,7 @@ function del_xconfig($xchan, $family, $key) {
if(x($a->config[$xchan][$family], $key))
unset($a->config[$xchan][$family][$key]);
- $ret = q("DELETE FROM `xconfig` WHERE `xchan` = '%s' AND `cat` = '%s' AND `k` = '%s'",
+ $ret = q("DELETE FROM xconfig WHERE xchan = '%s' AND cat = '%s' AND k = '%s'",
dbesc($xchan),
dbesc($family),
dbesc($key)
diff --git a/include/dir_fns.php b/include/dir_fns.php
index 0ba4f8712..909005bbb 100644
--- a/include/dir_fns.php
+++ b/include/dir_fns.php
@@ -53,10 +53,11 @@ function check_upstream_directory() {
function dir_sort_links() {
$o = replace_macros(get_markup_template('dir_sort_links.tpl'), array(
- '$header' => t('Sort Options'),
+ '$header' => t('Directory Options'),
'$normal' => t('Alphabetic'),
'$reverse' => t('Reverse Alphabetic'),
- '$date' => t('Newest to Oldest')
+ '$date' => t('Newest to Oldest'),
+ '$pubforums' => t('Public Forums Only'),
));
return $o;
}
diff --git a/include/event.php b/include/event.php
index d95e8b401..1ed541d99 100644
--- a/include/event.php
+++ b/include/event.php
@@ -45,6 +45,56 @@ function format_event_html($ev) {
return $o;
}
+
+
+function ical_wrapper($ev) {
+
+ if(! ((is_array($ev)) && count($ev)))
+ return '';
+
+ $o .= "BEGIN:VCALENDAR";
+ $o .= "\nVERSION:2.0";
+ $o .= "\nMETHOD:PUBLISH";
+ $o .= "\nPRODID:-//" . get_config('system','sitename') . "//" . RED_PLATFORM . "//" . strtoupper(get_app()->language). "\n";
+ if(array_key_exists('start',$ev))
+ $o .= format_event_ical($ev);
+ else {
+ foreach($ev as $e) {
+ $o .= format_event_ical($e);
+ }
+ }
+ $o .= "\nEND:VCALENDAR\n";
+
+ return $o;
+}
+
+function format_event_ical($ev) {
+
+ $o = '';
+
+ $o .= "\nBEGIN:VEVENT";
+ if($ev['start'])
+ $o .= "\nDTSTART:" . datetime_convert('UTC','UTC', $ev['start'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : ''));
+ if($ev['finish'] && ! $ev['nofinish'])
+ $o .= "\nDTEND:" . datetime_convert('UTC','UTC', $ev['finish'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : ''));
+ if($ev['summary'])
+ $o .= "\nSUMMARY:" . format_ical_text($ev['summary']);
+ if($ev['location'])
+ $o .= "\nLOCATION:" . format_ical_text($ev['location']);
+ if($ev['description'])
+ $o .= "\nDESCRIPTION:" . format_ical_text($ev['description']);
+ $o .= "\nEND:VEVENT\n";
+ return $o;
+}
+
+function format_ical_text($s) {
+
+ require_once('include/bbcode.php');
+ require_once('include/html2plain.php');
+ return(wordwrap(html2plain(bbcode($s)),72,"\n ",true));
+}
+
+
function format_event_bbcode($ev) {
$o = '';
diff --git a/include/widgets.php b/include/widgets.php
index 076a8fa91..f7b8a20bd 100644
--- a/include/widgets.php
+++ b/include/widgets.php
@@ -659,9 +659,11 @@ function widget_bookmarkedchats($arr) {
$r = q("select * from xchat where xchat_xchan = '%s' group by xchat_url order by xchat_desc",
dbesc($h)
);
-
- for($x = 0; $x < count($r); $x ++)
- $r[$x]['xchat_url'] = zid($r[$x]['xchat_url']);
+ if($r) {
+ for($x = 0; $x < count($r); $x ++) {
+ $r[$x]['xchat_url'] = zid($r[$x]['xchat_url']);
+ }
+ }
return replace_macros(get_markup_template('bookmarkedchats.tpl'),array(
'$header' => t('Bookmarked Chatrooms'),
'$rooms' => $r
@@ -677,9 +679,11 @@ function widget_suggestedchats($arr) {
if(! $h)
return;
$r = q("select *, count(xchat_url) as total from xchat group by xchat_url order by total desc, xchat_desc limit 24");
-
- for($x = 0; $x < count($r); $x ++)
- $r[$x]['xchat_url'] = zid($r[$x]['xchat_url']);
+ if($r) {
+ for($x = 0; $x < count($r); $x ++) {
+ $r[$x]['xchat_url'] = zid($r[$x]['xchat_url']);
+ }
+ }
return replace_macros(get_markup_template('bookmarkedchats.tpl'),array(
'$header' => t('Suggested Chatrooms'),
'$rooms' => $r
@@ -874,3 +878,44 @@ function widget_photo_rand($arr) {
return $o;
}
+
+
+function widget_random_block($arr) {
+
+ $channel_id = 0;
+ if(array_key_exists('channel_id',$arr) && intval($arr['channel_id']))
+ $channel_id = intval($arr['channel_id']);
+ if(! $channel_id)
+ $channel_id = get_app()->profile_uid;
+ if(! $channel_id)
+ return '';
+
+ if(array_key_exists('contains',$arr))
+ $contains = $arr['contains'];
+
+ $o = '';
+
+ require_once('include/security.php');
+ $sql_options = item_permissions_sql($channel_id);
+
+ $randfunc = db_getfunc('RAND');
+
+ $r = q("select item.* from item left join item_id on item.id = item_id.iid
+ where item.uid = %d and sid like '%s' and service = 'BUILDBLOCK' and
+ item_restrict = %d $sql_options order by $randfunc limit 1",
+ intval($channel_id),
+ dbesc('%' . $contains . '%'),
+ intval(ITEM_BUILDBLOCK)
+ );
+
+ if($r) {
+ $o = '<div class="widget bblock">';
+ if($r[0]['title'])
+ $o .= '<h3>' . $r[0]['title'] . '</h3>';
+ $o .= prepare_text($r[0]['body'],$r[0]['mimetype']);
+ $o .= '</div>';
+
+ }
+ return $o;
+
+} \ No newline at end of file