aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/bookmarks.php2
-rw-r--r--include/comanche.php54
-rw-r--r--include/language.php15
-rw-r--r--include/photos.php75
-rw-r--r--include/security.php36
-rw-r--r--include/socgraph.php46
-rw-r--r--include/taxonomy.php121
7 files changed, 174 insertions, 175 deletions
diff --git a/include/bookmarks.php b/include/bookmarks.php
index e70158476..c6e8e86f2 100644
--- a/include/bookmarks.php
+++ b/include/bookmarks.php
@@ -9,7 +9,7 @@ function bookmark_add($channel,$sender,$taxonomy,$private,$opts = null) {
$ischat = false;
if(is_array($opts)) {
- $menu_id = ((x($opts,'menu_id')) ? intval($opt['menu_id']) : 0);
+ $menu_id = ((x($opts,'menu_id')) ? intval($opts['menu_id']) : 0);
$menu_name = ((x($opts,'menu_name')) ? escape_tags($opts['menu_name']) : '');
$ischat = ((x($opts,'ischat')) ? intval($opts['ischat']) : 0);
}
diff --git a/include/comanche.php b/include/comanche.php
index b181d415a..9db375c38 100644
--- a/include/comanche.php
+++ b/include/comanche.php
@@ -15,23 +15,22 @@ require_once('include/widgets.php');
// page layout from the given description
-function pdl_selector($uid,$current="") {
-
+function pdl_selector($uid, $current="") {
$o = '';
- $sql_extra = item_permissions_sql($uid);
+ //$sql_extra = item_permissions_sql($uid);
$r = q("select item_id.*, mid from item_id left join item on iid = item.id where item_id.uid = %d and item_id.uid = item.uid and service = 'PDL' order by sid asc",
- intval($owner)
+ intval($uid)
);
$arr = array('channel_id' => $uid, 'current' => $current, 'entries' => $r);
call_hooks('pdl_selector',$arr);
$entries = $arr['entries'];
- $current = $arr['current'];
-
- $o .= "<select name=\"pdl_select\" id=\"pdl_select\" size=\"1\" >";
+ $current = $arr['current'];
+
+ $o .= '<select name="pdl_select" id="pdl_select" size="1">';
$entries[] = array('title' => t('Default'), 'mid' => '');
foreach($entries as $selection) {
$selected = (($selection == $current) ? ' selected="selected" ' : '');
@@ -40,16 +39,17 @@ function pdl_selector($uid,$current="") {
$o .= '</select>';
return $o;
-}
+}
-function comanche_parser(&$a,$s) {
+function comanche_parser(&$a, $s) {
+ $matches = array();
$cnt = preg_match_all("/\[comment\](.*?)\[\/comment\]/ism", $s, $matches, PREG_SET_ORDER);
if($cnt) {
foreach($matches as $mtch) {
- $s = str_replace($mtch[0],'',$s);
+ $s = str_replace($mtch[0], '', $s);
}
}
@@ -99,14 +99,14 @@ function comanche_parser(&$a,$s) {
function comanche_menu($name,$class = '') {
$channel_id = comanche_get_channel_id();
if($channel_id) {
- $m = menu_fetch($name,$channel_id,get_observer_hash());
- return menu_render($m,$class);
+ $m = menu_fetch($name,$channel_id, get_observer_hash());
+ return menu_render($m, $class);
}
}
function comanche_replace_region($match) {
$a = get_app();
- if(array_key_exists($match[1],$a->page)) {
+ if(array_key_exists($match[1], $a->page)) {
return $a->page[$match[1]];
}
}
@@ -121,15 +121,15 @@ function comanche_get_channel_id() {
$channel_id = ((is_array(get_app()->profile)) ? get_app()->profile['profile_uid'] : 0);
if((! $channel_id) && (local_channel()))
$channel_id = local_channel();
+
return $channel_id;
}
function comanche_block($name) {
-
+ $o = '';
$channel_id = comanche_get_channel_id();
-
+
if($channel_id) {
- $o = '';
$r = q("select * from item inner join item_id on iid = item.id and item_id.uid = item.uid and item.uid = %d and service = 'BUILDBLOCK' and sid = '%s' limit 1",
intval($channel_id),
dbesc($name)
@@ -138,11 +138,12 @@ function comanche_block($name) {
$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>';
+ $o .= prepare_text($r[0]['body'], $r[0]['mimetype']);
+ $o .= '</div>';
}
}
+
return $o;
}
@@ -154,8 +155,9 @@ function comanche_block($name) {
// of what template and webpage options we might desire.
function comanche_webpage(&$a,$s) {
-
$ret = array();
+ $matches = array();
+
$cnt = preg_match_all("/\[authored\](.*?)\[\/authored\]/ism", $s, $matches, PREG_SET_ORDER);
if($cnt) {
foreach($matches as $mtch) {
@@ -170,9 +172,10 @@ function comanche_webpage(&$a,$s) {
// the global app environment, or config storage until we implement argument passing
-function comanche_widget($name,$text) {
- $a = get_app();
+function comanche_widget($name, $text) {
$vars = array();
+ $matches = array();
+
$cnt = preg_match_all("/\[var=(.*?)\](.*?)\[\/var\]/ism", $text, $matches, PREG_SET_ORDER);
if($cnt) {
foreach($matches as $mtch) {
@@ -186,12 +189,13 @@ function comanche_widget($name,$text) {
}
-function comanche_region(&$a,$s) {
+function comanche_region(&$a, $s) {
+ $matches = array();
$cnt = preg_match_all("/\[menu\](.*?)\[\/menu\]/ism", $s, $matches, PREG_SET_ORDER);
if($cnt) {
foreach($matches as $mtch) {
- $s = str_replace($mtch[0],comanche_menu(trim($mtch[1])),$s);
+ $s = str_replace($mtch[0], comanche_menu(trim($mtch[1])), $s);
}
}
@@ -244,7 +248,3 @@ function register_page_template($arr) {
get_app()->page_layouts[$arr['template']] = array($arr['variant']);
return;
}
-
-
-
-
diff --git a/include/language.php b/include/language.php
index f5ee3471e..ec5fa84fa 100644
--- a/include/language.php
+++ b/include/language.php
@@ -24,6 +24,7 @@
*/
function get_browser_language() {
$langs = array();
+ $lang_parse = array();
if (x($_SERVER,'HTTP_ACCEPT_LANGUAGE')) {
// break up string into pieces (languages and q factors)
@@ -33,7 +34,7 @@ function get_browser_language() {
if (count($lang_parse[1])) {
// create a list like "en" => 0.8
$langs = array_combine($lang_parse[1], $lang_parse[4]);
-
+
// set default to 1 for any without q factor
foreach ($langs as $lang => $val) {
if ($val === '') $langs[$lang] = 1;
@@ -144,16 +145,16 @@ function load_translation_table($lang, $install = false) {
/**
* @brief translate string if translation exists.
*
- * @param $s string that should get translated
- * @param $ctx optional context to appear in po file
+ * @param string $s string that should get translated
+ * @param string $ctx optional context to appear in po file
* @return translated string if exists, otherwise return $s
*
*/
-function t($s,$ctx = '') {
+function t($s, $ctx = '') {
global $a;
- $cs = $ctx?"__ctx:".$ctx."__ ".$s:$s;
- if(x($a->strings,$cs)) {
+ $cs = $ctx ? '__ctx:' . $ctx . '__ ' . $s : $s;
+ if(x($a->strings, $cs)) {
$t = $a->strings[$cs];
return is_array($t) ? $t[0] : $t;
}
@@ -218,7 +219,7 @@ function detect_language($s) {
// strip off bbcode
$naked_body = preg_replace('/\[(.+?)\]/', '', $naked_body);
if(mb_strlen($naked_body) < intval($min_length)) {
- logger('detect language: string length less than ' . intval($min_length), LOGGER_DATA);
+ logger('string length less than ' . intval($min_length), LOGGER_DATA);
return '';
}
diff --git a/include/photos.php b/include/photos.php
index ee94bac60..794ff7748 100644
--- a/include/photos.php
+++ b/include/photos.php
@@ -53,7 +53,7 @@ function photo_upload($channel, $observer, $args) {
$visible = 1;
else
$visible = 0;
-
+
if(intval($args['not_visible']) || $args['not_visible'] === 'true')
$visible = 0;
@@ -98,7 +98,6 @@ function photo_upload($channel, $observer, $args) {
logger('photo_upload: received file: ' . $filename . ' as ' . $src . ' ('. $type . ') ' . $filesize . ' bytes', LOGGER_DEBUG);
-
$maximagesize = get_config('system','maximagesize');
if(($maximagesize) && ($filesize > $maximagesize)) {
@@ -133,7 +132,6 @@ function photo_upload($channel, $observer, $args) {
call_hooks('photo_post_end',$ret);
return $ret;
}
-
$ph = photo_factory($imagedata, $type);
@@ -185,7 +183,7 @@ function photo_upload($channel, $observer, $args) {
$r1 = $ph->save($p);
if(! $r1)
$errors = true;
-
+
if(($width > 640 || $height > 640) && (! $errors)) {
$ph->scaleImage(640);
$p['scale'] = 1;
@@ -204,7 +202,6 @@ function photo_upload($channel, $observer, $args) {
$errors = true;
}
-
if($errors) {
q("delete from photo where resource_id = '%s' and uid = %d",
dbesc($photo_hash),
@@ -220,16 +217,15 @@ function photo_upload($channel, $observer, $args) {
$width_x_height = $ph->getWidth() . 'x' . $ph->getHeight();
- $basename = basename($filename);
$mid = item_message_id();
// Create item container
$item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_THREAD_TOP;
- $item_restrict = (($visible) ? ITEM_VISIBLE : ITEM_HIDDEN);
+ $item_restrict = (($visible) ? ITEM_VISIBLE : ITEM_HIDDEN);
$title = '';
$mid = item_message_id();
-
+
$arr = array();
$arr['aid'] = $account_id;
@@ -254,7 +250,7 @@ function photo_upload($channel, $observer, $args) {
// We should also put a width_x_height on large photos. Left as an exercise for
// devs looking fo simple stuff to fix.
- $larger = feature_enabled($channel['channel_id'],'large_photos');
+ $larger = feature_enabled($channel['channel_id'], 'large_photos');
if($larger) {
$tag = '[zmg]';
if($r2)
@@ -273,7 +269,7 @@ function photo_upload($channel, $observer, $args) {
$arr['body'] = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo_hash . ']'
. $tag . z_root() . "/photo/{$photo_hash}-{$smallest}.".$ph->getExt() . '[/zmg]'
. '[/zrl]';
-
+
$result = item_store($arr);
$item_id = $result['item_id'];
@@ -291,15 +287,23 @@ function photo_upload($channel, $observer, $args) {
return $ret;
}
-
-
-
-function photos_albums_list($channel,$observer) {
+/**
+ * @brief Returns a list with all photo albums observer is allowed to see.
+ *
+ * Returns an associative array with all albums where observer has permissions.
+ *
+ * @param array $channel
+ * @param array $observer
+ * @return bool|array false if no view_photos permission or an array
+ * * success (bool)
+ * * albums (array)
+ */
+function photos_albums_list($channel, $observer) {
$channel_id = $channel['channel_id'];
$observer_xchan = (($observer) ? $observer['xchan_hash'] : '');
- if(! perm_is_allowed($channel_id,$observer_xchan,'view_photos'))
+ if(! perm_is_allowed($channel_id, $observer_xchan, 'view_photos'))
return false;
// FIXME - create a permissions SQL which works on arbitrary observers and channels, regardless of login or web status
@@ -310,7 +314,6 @@ function photos_albums_list($channel,$observer) {
intval($channel_id),
intval(PHOTO_NORMAL),
intval(PHOTO_PROFILE)
-
);
// add various encodings to the array so we can just loop through and pick them out in a template
@@ -330,8 +333,8 @@ function photos_albums_list($channel,$observer) {
$ret['albums'][] = $entry;
}
}
- return $ret;
+ return $ret;
}
function photos_album_widget($channelx,$observer,$albums = null) {
@@ -395,17 +398,32 @@ function photos_list_photos($channel,$observer,$album = '') {
return $ret;
}
-
-
-function photos_album_exists($channel_id,$album) {
- $r = q("SELECT id from photo where album = '%s' and uid = %d limit 1",
+/**
+ * @brief Check if given photo album exists in channel.
+ *
+ * @param int $channel_id id of the channel
+ * @param string $album name of the album
+ * @return boolean
+ */
+function photos_album_exists($channel_id, $album) {
+ $r = q("SELECT id FROM photo WHERE album = '%s' AND uid = %d limit 1",
dbesc($album),
intval($channel_id)
);
+
return (($r) ? true : false);
}
-function photos_album_rename($channel_id,$oldname,$newname) {
+/**
+ * @brief Renames a photo album in a channel.
+ *
+ * @todo Do we need to check if new album name already exists?
+ * @param int $channel_id id of the channel
+ * @param string $oldname The name of the album to rename
+ * @param string $newname The new name of the album
+ * @return bool|array
+ */
+function photos_album_rename($channel_id, $oldname, $newname) {
return q("UPDATE photo SET album = '%s' WHERE album = '%s' AND uid = %d",
dbesc($newname),
dbesc($oldname),
@@ -437,8 +455,8 @@ function photos_album_get_db_idstr($channel_id,$album,$remote_xchan = '') {
$str = implode(',',$arr);
return $str;
}
- return false;
+ return false;
}
function photos_create_item($channel, $creator_hash, $photo, $visible = false) {
@@ -446,11 +464,10 @@ function photos_create_item($channel, $creator_hash, $photo, $visible = false) {
// Create item container
$item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_THREAD_TOP;
- $item_restrict = (($visible) ? ITEM_VISIBLE : ITEM_HIDDEN);
+ $item_restrict = (($visible) ? ITEM_VISIBLE : ITEM_HIDDEN);
- $title = '';
$mid = item_message_id();
-
+
$arr = array();
$arr['aid'] = $channel['channel_account_id'];
@@ -470,13 +487,13 @@ function photos_create_item($channel, $creator_hash, $photo, $visible = false) {
$arr['deny_gid'] = $photo['deny_gid'];
$arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid'];
-
+
$arr['body'] = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo['resource_id'] . ']'
. '[zmg]' . z_root() . '/photo/' . $photo['resource_id'] . '-' . $photo['scale'] . '[/zmg]'
. '[/zrl]';
-
+
$result = item_store($arr);
$item_id = $result['item_id'];
- return $item_id;
+ return $item_id;
}
diff --git a/include/security.php b/include/security.php
index 216299099..e9b41dcf9 100644
--- a/include/security.php
+++ b/include/security.php
@@ -22,7 +22,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive
$a->account = $user_record;
$_SESSION['account_id'] = $user_record['account_id'];
$_SESSION['authenticated'] = 1;
-
+
if($login_initial || $update_lastlog) {
q("update account set account_lastlog = '%s' where account_id = %d",
dbesc(datetime_convert()),
@@ -150,11 +150,7 @@ function change_channel($change_channel) {
*/
function permissions_sql($owner_id, $remote_verified = false, $groups = null) {
- if(defined('STATUSNET_PRIVACY_COMPATIBILITY'))
- return '';
-
$local_channel = local_channel();
- $remote_channel = remote_channel();
/**
* Construct permissions
@@ -173,7 +169,7 @@ function permissions_sql($owner_id, $remote_verified = false, $groups = null) {
*/
if(($local_channel) && ($local_channel == $owner_id)) {
- $sql = '';
+ $sql = '';
}
/**
@@ -194,7 +190,7 @@ function permissions_sql($owner_id, $remote_verified = false, $groups = null) {
if(is_array($groups) && count($groups)) {
foreach($groups as $g)
$gs .= '|<' . $g . '>';
- }
+ }
$regexop = db_getfunc('REGEXP');
$sql = sprintf(
" AND ( NOT (deny_cid like '%s' OR deny_gid $regexop '%s')
@@ -223,11 +219,7 @@ function permissions_sql($owner_id, $remote_verified = false, $groups = null) {
*/
function item_permissions_sql($owner_id, $remote_verified = false, $groups = null) {
- if(defined('STATUSNET_PRIVACY_COMPATIBILITY'))
- return '';
-
$local_channel = local_channel();
- $remote_channel = remote_channel();
/**
* Construct permissions
@@ -246,7 +238,7 @@ function item_permissions_sql($owner_id, $remote_verified = false, $groups = nul
}
/**
- * Authenticated visitor. Unless pre-verified,
+ * Authenticated visitor. Unless pre-verified,
* check that the contact belongs to this $owner_id
* and load the groups the visitor belongs to.
* If pre-verified, the caller is expected to have already
@@ -330,7 +322,7 @@ function public_permissions_sql($observer_hash) {
*/
function get_form_security_token($typename = '') {
$a = get_app();
-
+
$timestamp = time();
$sec_hash = hash('whirlpool', $a->user['guid'] . $a->user['prvkey'] . session_id() . $timestamp . $typename);
@@ -340,16 +332,16 @@ function get_form_security_token($typename = '') {
function check_form_security_token($typename = '', $formname = 'form_security_token') {
if (!x($_REQUEST, $formname)) return false;
$hash = $_REQUEST[$formname];
-
+
$max_livetime = 10800; // 3 hours
-
+
$a = get_app();
-
+
$x = explode('.', $hash);
if (time() > (IntVal($x[0]) + $max_livetime)) return false;
-
+
$sec_hash = hash('whirlpool', $a->user['guid'] . $a->user['prvkey'] . session_id() . $x[0] . $typename);
-
+
return ($sec_hash == $x[1]);
}
@@ -417,7 +409,7 @@ function stream_perms_api_uids($perms = NULL ) {
if($r) {
foreach($r as $rr)
if(! in_array($rr['channel_id'], $ret))
- $ret[] = $rr['channel_id'];
+ $ret[] = $rr['channel_id'];
}
$str = '';
@@ -425,7 +417,7 @@ function stream_perms_api_uids($perms = NULL ) {
foreach($ret as $rr) {
if($str)
$str .= ',';
- $str .= intval($rr);
+ $str .= intval($rr);
}
}
logger('stream_perms_api_uids: ' . $str, LOGGER_DEBUG);
@@ -447,7 +439,7 @@ function stream_perms_xchans($perms = NULL ) {
if($r) {
foreach($r as $rr)
if(! in_array($rr['channel_hash'], $ret))
- $ret[] = $rr['channel_hash'];
+ $ret[] = $rr['channel_hash'];
}
$str = '';
@@ -455,7 +447,7 @@ function stream_perms_xchans($perms = NULL ) {
foreach($ret as $rr) {
if($str)
$str .= ',';
- $str .= "'" . dbesc($rr) . "'";
+ $str .= "'" . dbesc($rr) . "'";
}
}
logger('stream_perms_xchans: ' . $str, LOGGER_DEBUG);
diff --git a/include/socgraph.php b/include/socgraph.php
index 59830ef1b..7f03f8696 100644
--- a/include/socgraph.php
+++ b/include/socgraph.php
@@ -3,7 +3,7 @@
require_once('include/dir_fns.php');
require_once('include/zot.php');
-/*
+/**
* poco_load
*
* xchan is your connection
@@ -21,13 +21,10 @@ require_once('include/zot.php');
* the given uid, cid to the global contact entry. There can be many uid/cid combinations
* pointing to the same global contact id.
*
+ * @param string $xchan
+ * @param string $url
*/
-
-
-
-
-function poco_load($xchan = '',$url = null) {
- $a = get_app();
+function poco_load($xchan = '', $url = null) {
if($xchan && ! $url) {
$r = q("select xchan_connurl from xchan where xchan_hash = '%s' limit 1",
@@ -43,7 +40,6 @@ function poco_load($xchan = '',$url = null) {
return;
}
-
$url = $url . '?f=&fields=displayName,hash,urls,photos,rating' ;
logger('poco_load: ' . $url, LOGGER_DEBUG);
@@ -148,7 +144,7 @@ function poco_load($xchan = '',$url = null) {
logger('poco_load: missing data');
continue;
}
-
+
$x = q("select xchan_hash from xchan where xchan_hash = '%s' limit 1",
dbesc($hash)
);
@@ -182,9 +178,8 @@ function poco_load($xchan = '',$url = null) {
continue;
}
}
-
- $total ++;
+ $total ++;
}
logger("poco_load: loaded $total entries",LOGGER_DEBUG);
@@ -193,7 +188,6 @@ function poco_load($xchan = '',$url = null) {
db_utcnow(), db_quoteinterval('2 DAY')
);
-
}
@@ -230,7 +224,6 @@ function common_friends($uid,$xchan,$start = 0,$limit=100000000,$shuffle = false
);
return $r;
-
}
@@ -246,8 +239,8 @@ function count_common_friends_zcid($uid,$zcid) {
if(count($r))
return $r[0]['total'];
- return 0;
+ return 0;
}
function common_friends_zcid($uid,$zcid,$start = 0, $limit = 9999,$shuffle = false) {
@@ -269,7 +262,6 @@ function common_friends_zcid($uid,$zcid,$start = 0, $limit = 9999,$shuffle = fal
);
return $r;
-
}
@@ -284,8 +276,8 @@ function count_all_friends($uid,$cid) {
if(count($r))
return $r[0]['total'];
- return 0;
+ return 0;
}
@@ -358,9 +350,7 @@ function suggestion_query($uid, $myxchan, $start = 0, $limit = 80) {
function update_suggestions() {
- $a = get_app();
-
- $dirmode = get_config('system','directory_mode');
+ $dirmode = get_config('system', 'directory_mode');
if($dirmode === false)
$dirmode = DIRECTORY_MODE_NORMAL;
@@ -374,8 +364,6 @@ function update_suggestions() {
if(! $url)
return;
-
-
$ret = z_fetch_url($url);
if($ret['success']) {
@@ -388,7 +376,6 @@ function update_suggestions() {
db_utcnow(), db_quoteinterval('7 DAY')
);
-
$j = json_decode($ret['body'],true);
if($j && $j['success']) {
foreach($j['entries'] as $host) {
@@ -422,7 +409,6 @@ function poco($a,$extended = false) {
$system_mode = true;
}
-
$format = (($_REQUEST['format']) ? $_REQUEST['format'] : 'json');
$justme = false;
@@ -437,7 +423,7 @@ function poco($a,$extended = false) {
}
if(argc() > 4 && intval(argv(4)) && $justme == false)
$cid = intval(argv(4));
-
+
if(! $system_mode) {
$r = q("SELECT channel_id from channel where channel_address = '%s' limit 1",
@@ -487,8 +473,8 @@ function poco($a,$extended = false) {
$startIndex = intval($_GET['startIndex']);
if(! $startIndex)
$startIndex = 0;
- $itemsPerPage = ((x($_GET,'count') && intval($_GET['count'])) ? intval($_GET['count']) : $totalResults);
+ $itemsPerPage = ((x($_GET,'count') && intval($_GET['count'])) ? intval($_GET['count']) : $totalResults);
if($system_mode) {
$r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where ( abook_flags & " . ABOOK_FLAG_SELF .
@@ -496,8 +482,7 @@ function poco($a,$extended = false) {
intval($itemsPerPage),
intval($startIndex)
);
- }
- else {
+ } else {
$r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d
$sql_extra LIMIT %d OFFSET %d",
intval($channel_id),
@@ -525,8 +510,7 @@ function poco($a,$extended = false) {
}
}
- $ret['entry'] = array();
-
+ $ret['entry'] = array();
$fields_ret = array(
'id' => false,
@@ -540,10 +524,10 @@ function poco($a,$extended = false) {
'rating' => false
);
- if((! x($_GET,'fields')) || ($_GET['fields'] === '@all'))
+ if((! x($_GET,'fields')) || ($_GET['fields'] === '@all')) {
foreach($fields_ret as $k => $v)
$fields_ret[$k] = true;
- else {
+ } else {
$fields_req = explode(',',$_GET['fields']);
foreach($fields_req as $f)
$fields_ret[trim($f)] = true;
diff --git a/include/taxonomy.php b/include/taxonomy.php
index ef3639067..4333cdf03 100644
--- a/include/taxonomy.php
+++ b/include/taxonomy.php
@@ -38,6 +38,7 @@ function term_query($table,$s,$type = TERM_UNKNOWN) {
function store_item_tag($uid,$iid,$otype,$type,$term,$url = '') {
if(! $term)
return false;
+
$r = q("select * from term
where uid = %d and oid = %d and otype = %d and type = %d
and term = '%s' and url = '%s' ",
@@ -50,6 +51,7 @@ function store_item_tag($uid,$iid,$otype,$type,$term,$url = '') {
);
if($r)
return false;
+
$r = q("insert into term (uid, oid, otype, type, term, url)
values( %d, %d, %d, %d, '%s', '%s') ",
intval($uid),
@@ -59,9 +61,11 @@ function store_item_tag($uid,$iid,$otype,$type,$term,$url = '') {
dbesc($term),
dbesc($url)
);
+
return $r;
}
-
+
+
function get_terms_oftype($arr,$type) {
$ret = array();
if(! (is_array($arr) && count($arr)))
@@ -74,6 +78,7 @@ function get_terms_oftype($arr,$type) {
foreach($arr as $x)
if($x['type'] == $t)
$ret[] = $x;
+
return $ret;
}
@@ -99,7 +104,7 @@ function format_term_for_display($term) {
function tagadelic($uid, $count = 0, $authors = '', $flags = 0, $restrict = 0, $type = TERM_HASHTAG) {
require_once('include/security.php');
-
+
if(! perm_is_allowed($uid,get_observer_hash(),'view_stream'))
return array();
@@ -112,6 +117,7 @@ function tagadelic($uid, $count = 0, $authors = '', $flags = 0, $restrict = 0, $
if($authors) {
if(! is_array($authors))
$authors = array($authors);
+
stringify_array_elms($authors,true);
$sql_options .= " and author_xchan in (" . implode(',',$authors) . ") ";
}
@@ -131,8 +137,8 @@ function tagadelic($uid, $count = 0, $authors = '', $flags = 0, $restrict = 0, $
if(! $r)
return array();
-
- // Find minimum and maximum log-count.
+
+ // Find minimum and maximum log-count.
$tags = array();
$min = 1e9;
$max = -1e9;
@@ -158,16 +164,17 @@ function tagadelic($uid, $count = 0, $authors = '', $flags = 0, $restrict = 0, $
return $tags;
}
+
function tags_sort($a,$b) {
- if(strtolower($a[0]) == strtolower($b[0]))
- return 0;
- return((strtolower($a[0]) < strtolower($b[0])) ? -1 : 1);
+ if(strtolower($a[0]) == strtolower($b[0]))
+ return 0;
+
+ return((strtolower($a[0]) < strtolower($b[0])) ? -1 : 1);
}
function dir_tagadelic($count = 0) {
- $sql_options = '';
$count = intval($count);
// Fetch tags
@@ -178,8 +185,8 @@ function dir_tagadelic($count = 0) {
if(! $r)
return array();
-
- // Find minimum and maximum log-count.
+
+ // Find minimum and maximum log-count.
$tags = array();
$min = 1e9;
$max = -1e9;
@@ -207,65 +214,66 @@ function dir_tagadelic($count = 0) {
function tagblock($link,$uid,$count = 0,$authors = '',$flags = 0,$restrict = 0,$type = TERM_HASHTAG) {
- $o = '';
- $tab = 0;
- $r = tagadelic($uid,$count,$authors,$flags,$restrict,$type);
-
- if($r) {
- $o = '<div class="tagblock widget"><h3>' . t('Tags') . '</h3><div class="tags" align="center">';
- foreach($r as $rr) {
- $o .= '<span class="tag'.$rr[2].'">#</span><a href="'.$link .'/' . '?f=&tag=' . urlencode($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ' . "\r\n";
+ $o = '';
+
+ $r = tagadelic($uid,$count,$authors,$flags,$restrict,$type);
+
+ if($r) {
+ $o = '<div class="tagblock widget"><h3>' . t('Tags') . '</h3><div class="tags" align="center">';
+ foreach($r as $rr) {
+ $o .= '<span class="tag'.$rr[2].'">#</span><a href="'.$link .'/' . '?f=&tag=' . urlencode($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ' . "\r\n";
+ }
+ $o .= '</div></div>';
}
- $o .= '</div></div>';
- }
+
return $o;
}
+
function wtagblock($uid,$count = 0,$authors = '',$flags = 0,$restrict = 0,$type = TERM_HASHTAG) {
- $o = '';
- $tab = 0;
- $r = tagadelic($uid,$count,$authors,$flags,$restrict,$type);
+ $o = '';
- if($r) {
- $c = q("select channel_address from channel where channel_id = %d limit 1",
- intval($uid)
- );
+ $r = tagadelic($uid,$count,$authors,$flags,$restrict,$type);
- $o = '<div class="tagblock widget"><h3>' . t('Tags') . '</h3><div class="tags" align="center">';
- foreach($r as $rr) {
- $o .= '<span class="tag' . $rr[2] . '">#</span><a href="channel/' . $c[0]['channel_address'] . '?f=&tag=' . urlencode($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ' . "\r\n";
+ if($r) {
+ $c = q("select channel_address from channel where channel_id = %d limit 1",
+ intval($uid)
+ );
+
+ $o = '<div class="tagblock widget"><h3>' . t('Tags') . '</h3><div class="tags" align="center">';
+ foreach($r as $rr) {
+ $o .= '<span class="tag' . $rr[2] . '">#</span><a href="channel/' . $c[0]['channel_address'] . '?f=&tag=' . urlencode($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ' . "\r\n";
+ }
+ $o .= '</div></div>';
}
- $o .= '</div></div>';
- }
+
return $o;
}
function catblock($uid,$count = 0,$authors = '',$flags = 0,$restrict = 0,$type = TERM_CATEGORY) {
- $o = '';
- $tab = 0;
+ $o = '';
- $r = tagadelic($uid,$count,$authors,$flags,$restrict,$type);
+ $r = tagadelic($uid,$count,$authors,$flags,$restrict,$type);
- if($r) {
- $c = q("select channel_address from channel where channel_id = %d limit 1",
- intval($uid)
- );
-
- $o = '<div class="tagblock widget"><h3>' . t('Categories') . '</h3><div class="tags" align="center">';
- foreach($r as $rr) {
- $o .= '<a href="channel/' . $c[0]['channel_address']. '?f=&cat=' . urlencode($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ' . "\r\n";
+ if($r) {
+ $c = q("select channel_address from channel where channel_id = %d limit 1",
+ intval($uid)
+ );
+
+ $o = '<div class="tagblock widget"><h3>' . t('Categories') . '</h3><div class="tags" align="center">';
+ foreach($r as $rr) {
+ $o .= '<a href="channel/' . $c[0]['channel_address']. '?f=&cat=' . urlencode($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ' . "\r\n";
+ }
+ $o .= '</div></div>';
}
- $o .= '</div></div>';
- }
+
return $o;
}
-
function dir_tagblock($link,$r) {
$o = '';
- $tab = 0;
if(! $r)
$r = get_app()->data['directory_keywords'];
@@ -277,14 +285,12 @@ function dir_tagblock($link,$r) {
}
$o .= '</div></div>';
}
+
return $o;
}
-
-
-
/**
* verbs: [0] = first person singular, e.g. "I want", [1] = 3rd person singular, e.g. "Bill wants"
* We use the first person form when creating an activity, but the third person for use in activities
@@ -292,8 +298,6 @@ function dir_tagblock($link,$r) {
* require obj_verbs() to provide full conjugations and specify which form to use in the $_REQUEST params to this module.
*/
-
-
function obj_verbs() {
$verbs = array(
'has' => array( t('have'), t('has')),
@@ -304,26 +308,27 @@ function obj_verbs() {
$arr = array('verbs' => $verbs);
call_hooks('obj_verbs', $arr);
+
return $arr['verbs'];
}
function obj_verb_selector($current = '') {
$verbs = obj_verbs();
- $o .= '<select class="obj-verb-selector" name="verb" >';
+ $o = '<select class="obj-verb-selector" name="verb">';
foreach($verbs as $k => $v) {
$selected = (($k == $current) ? ' selected="selected" ' : '');
$o .= '<option value="' . urlencode($k) . '"' . $selected . '>' . $v[1] . '</option>';
}
$o .= '</select>';
- return $o;
+ return $o;
}
function get_things($profile_hash,$uid) {
$sql_extra = (($profile_hash) ? " and obj_page = '" . $profile_hash . "' " : '');
-
+
$r = q("select * from obj left join term on obj_obj = term_hash where term_hash != '' and uid = %d and obj_type = %d $sql_extra order by obj_verb, term",
intval($uid),
intval(TERM_OBJ_THING)
@@ -379,11 +384,11 @@ function get_things($profile_hash,$uid) {
for($x = 0; $x < count($l); $x ++)
$l[$x]['xchan_url'] = zid($l[$x]['xchan_url']);
-
+
if(! $things[$rr['obj_verb']])
$things[$rr['obj_verb']] = array();
- $things[$rr['obj_verb']][] = array('term' => $rr['term'],'url' => $rr['url'],'img' => $rr['imgurl'], 'profile' => $rr['profile_name'],'term_hash' => $rr['term_hash'], 'likes' => $l,'like_count' => count($l),'like_label' => tt('Like','Likes',count($l),'noun'));
+ $things[$rr['obj_verb']][] = array('term' => $rr['term'],'url' => $rr['url'],'img' => $rr['imgurl'], 'profile' => $rr['profile_name'],'term_hash' => $rr['term_hash'], 'likes' => $l,'like_count' => count($l),'like_label' => tt('Like','Likes',count($l),'noun'));
}
$sorted_things = array();
if($things) {
@@ -395,6 +400,6 @@ function get_things($profile_hash,$uid) {
}
}
//logger('things: ' . print_r($sorted_things,true));
- return $sorted_things;
+ return $sorted_things;
} \ No newline at end of file