Coding Standards
A few updates for coding standards
This commit is contained in:
parent
5888cce08e
commit
d9e9cbe753
|
@ -905,11 +905,11 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
|
||||||
|
|
||||||
if ($item['id'] == $item['parent']) {
|
if ($item['id'] == $item['parent']) {
|
||||||
$item_object = new Item($item);
|
$item_object = new Item($item);
|
||||||
$conv->add_thread($item_object);
|
$conv->addThread($item_object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$threads = $conv->get_template_data($conv_responses);
|
$threads = $conv->getTemplateData($conv_responses);
|
||||||
|
|
||||||
if (!$threads) {
|
if (!$threads) {
|
||||||
logger('[ERROR] conversation : Failed to get template data.', LOGGER_DEBUG);
|
logger('[ERROR] conversation : Failed to get template data.', LOGGER_DEBUG);
|
||||||
|
|
106
index.php
106
index.php
|
@ -20,7 +20,7 @@ require_once 'boot.php';
|
||||||
if (empty($a)) {
|
if (empty($a)) {
|
||||||
$a = new App(__DIR__);
|
$a = new App(__DIR__);
|
||||||
}
|
}
|
||||||
BaseObject::set_app($a);
|
BaseObject::setApp($a);
|
||||||
|
|
||||||
// We assume that the index.php is called by a frontend process
|
// We assume that the index.php is called by a frontend process
|
||||||
// The value is set to "true" by default in boot.php
|
// The value is set to "true" by default in boot.php
|
||||||
|
@ -40,9 +40,7 @@ if (!$install) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Try to open the database;
|
* Try to open the database;
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once "include/dba.php";
|
require_once "include/dba.php";
|
||||||
|
@ -64,9 +62,10 @@ if (!$install) {
|
||||||
die("System is currently unavailable. Please try again later");
|
die("System is currently unavailable. Please try again later");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config::get('system', 'force_ssl') && ($a->get_scheme() == "http") &&
|
if (Config::get('system', 'force_ssl') && ($a->get_scheme() == "http")
|
||||||
(intval(Config::get('system', 'ssl_policy')) == SSL_POLICY_FULL) &&
|
&& (intval(Config::get('system', 'ssl_policy')) == SSL_POLICY_FULL)
|
||||||
(substr(System::baseUrl(), 0, 8) == "https://")) {
|
&& (substr(System::baseUrl(), 0, 8) == "https://")
|
||||||
|
) {
|
||||||
header("HTTP/1.1 302 Moved Temporarily");
|
header("HTTP/1.1 302 Moved Temporarily");
|
||||||
header("Location: " . System::baseUrl() . "/" . $a->query_string);
|
header("Location: " . System::baseUrl() . "/" . $a->query_string);
|
||||||
exit();
|
exit();
|
||||||
|
@ -84,14 +83,12 @@ $lang = get_browser_language();
|
||||||
load_translation_table($lang);
|
load_translation_table($lang);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Important stuff we always need to do.
|
* Important stuff we always need to do.
|
||||||
*
|
*
|
||||||
* The order of these may be important so use caution if you think they're all
|
* The order of these may be important so use caution if you think they're all
|
||||||
* intertwingled with no logical order and decide to sort it out. Some of the
|
* intertwingled with no logical order and decide to sort it out. Some of the
|
||||||
* dependencies have changed, but at least at one time in the recent past - the
|
* dependencies have changed, but at least at one time in the recent past - the
|
||||||
* order was critical to everything working properly
|
* order was critical to everything working properly
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Exclude the backend processes from the session management
|
// Exclude the backend processes from the session management
|
||||||
|
@ -107,7 +104,7 @@ if (!$a->is_backend()) {
|
||||||
* Language was set earlier, but we can over-ride it in the session.
|
* Language was set earlier, but we can over-ride it in the session.
|
||||||
* We have to do it here because the session was just now opened.
|
* We have to do it here because the session was just now opened.
|
||||||
*/
|
*/
|
||||||
if (x($_SESSION,'authenticated') && !x($_SESSION,'language')) {
|
if (x($_SESSION, 'authenticated') && !x($_SESSION, 'language')) {
|
||||||
// we didn't loaded user data yet, but we need user language
|
// we didn't loaded user data yet, but we need user language
|
||||||
$r = dba::select('user', array('language'), array('uid' => $_SESSION['uid']), array('limit' => 1));
|
$r = dba::select('user', array('language'), array('uid' => $_SESSION['uid']), array('limit' => 1));
|
||||||
$_SESSION['language'] = $lang;
|
$_SESSION['language'] = $lang;
|
||||||
|
@ -116,18 +113,19 @@ if (x($_SESSION,'authenticated') && !x($_SESSION,'language')) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((x($_SESSION,'language')) && ($_SESSION['language'] !== $lang)) {
|
if ((x($_SESSION, 'language')) && ($_SESSION['language'] !== $lang)) {
|
||||||
$lang = $_SESSION['language'];
|
$lang = $_SESSION['language'];
|
||||||
load_translation_table($lang);
|
load_translation_table($lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((x($_GET,'zrl')) && (!$install && !$maintenance)) {
|
if ((x($_GET, 'zrl')) && (!$install && !$maintenance)) {
|
||||||
// Only continue when the given profile link seems valid
|
// Only continue when the given profile link seems valid
|
||||||
// Valid profile links contain a path with "/profile/" and no query parameters
|
// Valid profile links contain a path with "/profile/" and no query parameters
|
||||||
if ((parse_url($_GET['zrl'], PHP_URL_QUERY) == "") &&
|
if ((parse_url($_GET['zrl'], PHP_URL_QUERY) == "")
|
||||||
strstr(parse_url($_GET['zrl'], PHP_URL_PATH), "/profile/")) {
|
&& strstr(parse_url($_GET['zrl'], PHP_URL_PATH), "/profile/")
|
||||||
|
) {
|
||||||
$_SESSION['my_url'] = $_GET['zrl'];
|
$_SESSION['my_url'] = $_GET['zrl'];
|
||||||
$a->query_string = preg_replace('/[\?&]zrl=(.*?)([\?&]|$)/is','',$a->query_string);
|
$a->query_string = preg_replace('/[\?&]zrl=(.*?)([\?&]|$)/is', '', $a->query_string);
|
||||||
zrl_init($a);
|
zrl_init($a);
|
||||||
} else {
|
} else {
|
||||||
// Someone came with an invalid parameter, maybe as a DDoS attempt
|
// Someone came with an invalid parameter, maybe as a DDoS attempt
|
||||||
|
@ -140,23 +138,21 @@ if ((x($_GET,'zrl')) && (!$install && !$maintenance)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* For Mozilla auth manager - still needs sorting, and this might conflict with LRDD header.
|
* For Mozilla auth manager - still needs sorting, and this might conflict with LRDD header.
|
||||||
* Apache/PHP lumps the Link: headers into one - and other services might not be able to parse it
|
* Apache/PHP lumps the Link: headers into one - and other services might not be able to parse it
|
||||||
* this way. There's a PHP flag to link the headers because by default this will over-write any other
|
* this way. There's a PHP flag to link the headers because by default this will over-write any other
|
||||||
* link header.
|
* link header.
|
||||||
*
|
*
|
||||||
* What we really need to do is output the raw headers ourselves so we can keep them separate.
|
* What we really need to do is output the raw headers ourselves so we can keep them separate.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// header('Link: <' . System::baseUrl() . '/amcd>; rel="acct-mgmt";');
|
// header('Link: <' . System::baseUrl() . '/amcd>; rel="acct-mgmt";');
|
||||||
|
|
||||||
if (x($_COOKIE["Friendica"]) || (x($_SESSION,'authenticated')) || (x($_POST,'auth-params')) || ($a->module === 'login')) {
|
if (x($_COOKIE["Friendica"]) || (x($_SESSION, 'authenticated')) || (x($_POST, 'auth-params')) || ($a->module === 'login')) {
|
||||||
require("include/auth.php");
|
require "include/auth.php";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! x($_SESSION,'authenticated')) {
|
if (! x($_SESSION, 'authenticated')) {
|
||||||
header('X-Account-Management-Status: none');
|
header('X-Account-Management-Status: none');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,16 +161,16 @@ $a->page['htmlhead'] = '';
|
||||||
$a->page['end'] = '';
|
$a->page['end'] = '';
|
||||||
|
|
||||||
|
|
||||||
if (! x($_SESSION,'sysmsg')) {
|
if (! x($_SESSION, 'sysmsg')) {
|
||||||
$_SESSION['sysmsg'] = array();
|
$_SESSION['sysmsg'] = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! x($_SESSION,'sysmsg_info')) {
|
if (! x($_SESSION, 'sysmsg_info')) {
|
||||||
$_SESSION['sysmsg_info'] = array();
|
$_SESSION['sysmsg_info'] = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Array for informations about last received items
|
// Array for informations about last received items
|
||||||
if (! x($_SESSION,'last_updated')) {
|
if (! x($_SESSION, 'last_updated')) {
|
||||||
$_SESSION['last_updated'] = array();
|
$_SESSION['last_updated'] = array();
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -198,7 +194,7 @@ if ($install && $a->module!="view") {
|
||||||
nav_set_selected('nothing');
|
nav_set_selected('nothing');
|
||||||
|
|
||||||
//Don't populate apps_menu if apps are private
|
//Don't populate apps_menu if apps are private
|
||||||
$privateapps = Config::get('config','private_addons');
|
$privateapps = Config::get('config', 'private_addons');
|
||||||
if ((local_user()) || (! $privateapps === "1")) {
|
if ((local_user()) || (! $privateapps === "1")) {
|
||||||
$arr = array('app_menu' => $a->apps);
|
$arr = array('app_menu' => $a->apps);
|
||||||
|
|
||||||
|
@ -208,7 +204,6 @@ if ((local_user()) || (! $privateapps === "1")) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* We have already parsed the server path into $a->argc and $a->argv
|
* We have already parsed the server path into $a->argc and $a->argv
|
||||||
*
|
*
|
||||||
* $a->argv[0] is our module name. We will load the file mod/{$a->argv[0]}.php
|
* $a->argv[0] is our module name. We will load the file mod/{$a->argv[0]}.php
|
||||||
|
@ -229,10 +224,8 @@ if ((local_user()) || (! $privateapps === "1")) {
|
||||||
if (strlen($a->module)) {
|
if (strlen($a->module)) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* We will always have a module name.
|
* We will always have a module name.
|
||||||
* First see if we have a plugin which is masquerading as a module.
|
* First see if we have a plugin which is masquerading as a module.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Compatibility with the Android Diaspora client
|
// Compatibility with the Android Diaspora client
|
||||||
|
@ -245,14 +238,14 @@ if (strlen($a->module)) {
|
||||||
$a->module = "login";
|
$a->module = "login";
|
||||||
}
|
}
|
||||||
|
|
||||||
$privateapps = Config::get('config','private_addons');
|
$privateapps = Config::get('config', 'private_addons');
|
||||||
|
|
||||||
if (is_array($a->plugins) && in_array($a->module,$a->plugins) && file_exists("addon/{$a->module}/{$a->module}.php")) {
|
if (is_array($a->plugins) && in_array($a->module, $a->plugins) && file_exists("addon/{$a->module}/{$a->module}.php")) {
|
||||||
//Check if module is an app and if public access to apps is allowed or not
|
//Check if module is an app and if public access to apps is allowed or not
|
||||||
if ((!local_user()) && plugin_is_app($a->module) && $privateapps === "1") {
|
if ((!local_user()) && plugin_is_app($a->module) && $privateapps === "1") {
|
||||||
info( t("You must be logged in to use addons. "));
|
info(t("You must be logged in to use addons. "));
|
||||||
} else {
|
} else {
|
||||||
include_once("addon/{$a->module}/{$a->module}.php");
|
include_once "addon/{$a->module}/{$a->module}.php";
|
||||||
if (function_exists($a->module . '_module')) {
|
if (function_exists($a->module . '_module')) {
|
||||||
$a->module_loaded = true;
|
$a->module_loaded = true;
|
||||||
}
|
}
|
||||||
|
@ -264,12 +257,11 @@ if (strlen($a->module)) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ((! $a->module_loaded) && (file_exists("mod/{$a->module}.php"))) {
|
if ((! $a->module_loaded) && (file_exists("mod/{$a->module}.php"))) {
|
||||||
include_once("mod/{$a->module}.php");
|
include_once "mod/{$a->module}.php";
|
||||||
$a->module_loaded = true;
|
$a->module_loaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* The URL provided does not resolve to a valid module.
|
* The URL provided does not resolve to a valid module.
|
||||||
*
|
*
|
||||||
* On Dreamhost sites, quite often things go wrong for no apparent reason and they send us to '/internal_error.html'.
|
* On Dreamhost sites, quite often things go wrong for no apparent reason and they send us to '/internal_error.html'.
|
||||||
|
@ -278,17 +270,15 @@ if (strlen($a->module)) {
|
||||||
* this will often succeed and eventually do the right thing.
|
* this will often succeed and eventually do the right thing.
|
||||||
*
|
*
|
||||||
* Otherwise we are going to emit a 404 not found.
|
* Otherwise we are going to emit a 404 not found.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (! $a->module_loaded) {
|
if (! $a->module_loaded) {
|
||||||
|
|
||||||
// Stupid browser tried to pre-fetch our Javascript img template. Don't log the event or return anything - just quietly exit.
|
// Stupid browser tried to pre-fetch our Javascript img template. Don't log the event or return anything - just quietly exit.
|
||||||
if ((x($_SERVER,'QUERY_STRING')) && preg_match('/{[0-9]}/',$_SERVER['QUERY_STRING']) !== 0) {
|
if ((x($_SERVER, 'QUERY_STRING')) && preg_match('/{[0-9]}/', $_SERVER['QUERY_STRING']) !== 0) {
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((x($_SERVER,'QUERY_STRING')) && ($_SERVER['QUERY_STRING'] === 'q=internal_error.html') && isset($dreamhost_error_hack)) {
|
if ((x($_SERVER, 'QUERY_STRING')) && ($_SERVER['QUERY_STRING'] === 'q=internal_error.html') && isset($dreamhost_error_hack)) {
|
||||||
logger('index.php: dreamhost_error_hack invoked. Original URI =' . $_SERVER['REQUEST_URI']);
|
logger('index.php: dreamhost_error_hack invoked. Original URI =' . $_SERVER['REQUEST_URI']);
|
||||||
goaway(System::baseUrl() . $_SERVER['REQUEST_URI']);
|
goaway(System::baseUrl() . $_SERVER['REQUEST_URI']);
|
||||||
}
|
}
|
||||||
|
@ -296,29 +286,31 @@ if (strlen($a->module)) {
|
||||||
logger('index.php: page not found: ' . $_SERVER['REQUEST_URI'] . ' ADDRESS: ' . $_SERVER['REMOTE_ADDR'] . ' QUERY: ' . $_SERVER['QUERY_STRING'], LOGGER_DEBUG);
|
logger('index.php: page not found: ' . $_SERVER['REQUEST_URI'] . ' ADDRESS: ' . $_SERVER['REMOTE_ADDR'] . ' QUERY: ' . $_SERVER['QUERY_STRING'], LOGGER_DEBUG);
|
||||||
header($_SERVER["SERVER_PROTOCOL"] . ' 404 ' . t('Not Found'));
|
header($_SERVER["SERVER_PROTOCOL"] . ' 404 ' . t('Not Found'));
|
||||||
$tpl = get_markup_template("404.tpl");
|
$tpl = get_markup_template("404.tpl");
|
||||||
$a->page['content'] = replace_macros($tpl, array(
|
$a->page['content'] = replace_macros(
|
||||||
'$message' => t('Page not found.' )
|
$tpl,
|
||||||
));
|
array(
|
||||||
|
'$message' => t('Page not found.'))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* load current theme info
|
* Load current theme info
|
||||||
*/
|
*/
|
||||||
$theme_info_file = "view/theme/".current_theme()."/theme.php";
|
$theme_info_file = "view/theme/".current_theme()."/theme.php";
|
||||||
if (file_exists($theme_info_file)){
|
if (file_exists($theme_info_file)) {
|
||||||
require_once($theme_info_file);
|
require_once $theme_info_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* initialise content region */
|
/* initialise content region */
|
||||||
|
|
||||||
if (! x($a->page,'content')) {
|
if (! x($a->page, 'content')) {
|
||||||
$a->page['content'] = '';
|
$a->page['content'] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$install && !$maintenance) {
|
if (!$install && !$maintenance) {
|
||||||
call_hooks('page_content_top',$a->page['content']);
|
call_hooks('page_content_top', $a->page['content']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -335,21 +327,22 @@ if ($a->module_loaded) {
|
||||||
$func($a);
|
$func($a);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (function_exists(str_replace('-','_',current_theme()) . '_init')) {
|
if (function_exists(str_replace('-', '_', current_theme()) . '_init')) {
|
||||||
$func = str_replace('-','_',current_theme()) . '_init';
|
$func = str_replace('-', '_', current_theme()) . '_init';
|
||||||
$func($a);
|
$func($a);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($_SERVER['REQUEST_METHOD'] === 'POST') && (! $a->error)
|
if (($_SERVER['REQUEST_METHOD'] === 'POST') && (! $a->error)
|
||||||
&& (function_exists($a->module . '_post'))
|
&& (function_exists($a->module . '_post'))
|
||||||
&& (! x($_POST,'auth-params'))) {
|
&& (! x($_POST, 'auth-params'))
|
||||||
|
) {
|
||||||
call_hooks($a->module . '_mod_post', $_POST);
|
call_hooks($a->module . '_mod_post', $_POST);
|
||||||
$func = $a->module . '_post';
|
$func = $a->module . '_post';
|
||||||
$func($a);
|
$func($a);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((! $a->error) && (function_exists($a->module . '_afterpost'))) {
|
if ((! $a->error) && (function_exists($a->module . '_afterpost'))) {
|
||||||
call_hooks($a->module . '_mod_afterpost',$placeholder);
|
call_hooks($a->module . '_mod_afterpost', $placeholder);
|
||||||
$func = $a->module . '_afterpost';
|
$func = $a->module . '_afterpost';
|
||||||
$func($a);
|
$func($a);
|
||||||
}
|
}
|
||||||
|
@ -364,8 +357,8 @@ if ($a->module_loaded) {
|
||||||
$a->page['content'] .= $arr['content'];
|
$a->page['content'] .= $arr['content'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (function_exists(str_replace('-','_',current_theme()) . '_content_loaded')) {
|
if (function_exists(str_replace('-', '_', current_theme()) . '_content_loaded')) {
|
||||||
$func = str_replace('-','_',current_theme()) . '_content_loaded';
|
$func = str_replace('-', '_', current_theme()) . '_content_loaded';
|
||||||
$func($a);
|
$func($a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -427,10 +420,12 @@ if ($a->is_mobile || $a->is_tablet) {
|
||||||
} else {
|
} else {
|
||||||
$link = 'toggle_mobile?off=1&address=' . curPageURL();
|
$link = 'toggle_mobile?off=1&address=' . curPageURL();
|
||||||
}
|
}
|
||||||
$a->page['footer'] = replace_macros(get_markup_template("toggle_mobile_footer.tpl"), array(
|
$a->page['footer'] = replace_macros(
|
||||||
'$toggle_link' => $link,
|
get_markup_template("toggle_mobile_footer.tpl"),
|
||||||
'$toggle_text' => t('toggle mobile')
|
array(
|
||||||
));
|
'$toggle_link' => $link,
|
||||||
|
'$toggle_text' => t('toggle mobile'))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -443,7 +438,7 @@ if (!$a->theme['stylesheet']) {
|
||||||
$stylesheet = $a->theme['stylesheet'];
|
$stylesheet = $a->theme['stylesheet'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$a->page['htmlhead'] = str_replace('{{$stylesheet}}',$stylesheet,$a->page['htmlhead']);
|
$a->page['htmlhead'] = str_replace('{{$stylesheet}}', $stylesheet, $a->page['htmlhead']);
|
||||||
//$a->page['htmlhead'] = replace_macros($a->page['htmlhead'], array('$stylesheet' => $stylesheet));
|
//$a->page['htmlhead'] = replace_macros($a->page['htmlhead'], array('$stylesheet' => $stylesheet));
|
||||||
|
|
||||||
if (isset($_GET["mode"]) && (($_GET["mode"] == "raw") || ($_GET["mode"] == "minimal"))) {
|
if (isset($_GET["mode"]) && (($_GET["mode"] == "raw") || ($_GET["mode"] == "minimal"))) {
|
||||||
|
@ -470,7 +465,6 @@ if (isset($_GET["mode"]) && (($_GET["mode"] == "raw") || ($_GET["mode"] == "mini
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_GET["mode"]) && ($_GET["mode"] == "raw")) {
|
if (isset($_GET["mode"]) && ($_GET["mode"] == "raw")) {
|
||||||
|
|
||||||
header("Content-type: text/html; charset=utf-8");
|
header("Content-type: text/html; charset=utf-8");
|
||||||
|
|
||||||
echo substr($target->saveHTML(), 6, -8);
|
echo substr($target->saveHTML(), 6, -8);
|
||||||
|
|
|
@ -6,10 +6,10 @@
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
use Friendica\Content\Smilies;
|
use Friendica\Content\Smilies;
|
||||||
|
|
||||||
function smilies_content(App $a)
|
function smiliesContent(App $a)
|
||||||
{
|
{
|
||||||
if ($a->argv[1] === "json") {
|
if ($a->argv[1] === "json") {
|
||||||
$tmp = Smilies::get_list();
|
$tmp = Smilies::getList();
|
||||||
$results = array();
|
$results = array();
|
||||||
for ($i = 0; $i < count($tmp['texts']); $i++) {
|
for ($i = 0; $i < count($tmp['texts']); $i++) {
|
||||||
$results[] = array('text' => $tmp['texts'][$i], 'icon' => $tmp['icons'][$i]);
|
$results[] = array('text' => $tmp['texts'][$i], 'icon' => $tmp['icons'][$i]);
|
||||||
|
|
|
@ -33,6 +33,8 @@ class Smilies
|
||||||
* @param array $b Array of emoticons
|
* @param array $b Array of emoticons
|
||||||
* @param string $smiley The text smilie
|
* @param string $smiley The text smilie
|
||||||
* @param string $representation The replacement
|
* @param string $representation The replacement
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function add(&$b, $smiley, $representation)
|
public static function add(&$b, $smiley, $representation)
|
||||||
{
|
{
|
||||||
|
@ -57,7 +59,7 @@ class Smilies
|
||||||
*
|
*
|
||||||
* @hook smilie ('texts' => smilies texts array, 'icons' => smilies html array)
|
* @hook smilie ('texts' => smilies texts array, 'icons' => smilies html array)
|
||||||
*/
|
*/
|
||||||
public static function get_list()
|
public static function getList()
|
||||||
{
|
{
|
||||||
$texts = array(
|
$texts = array(
|
||||||
'<3',
|
'<3',
|
||||||
|
@ -154,7 +156,7 @@ class Smilies
|
||||||
* bbcode source for HTML display
|
* bbcode source for HTML display
|
||||||
*
|
*
|
||||||
* @param string $s Text that should be replaced
|
* @param string $s Text that should be replaced
|
||||||
* @param boolean $sample
|
* @param boolean $sample optional, default false
|
||||||
* @param boolean $no_images Only replace emoticons without images
|
* @param boolean $no_images Only replace emoticons without images
|
||||||
*
|
*
|
||||||
* @return string HML Output of the Smilie
|
* @return string HML Output of the Smilie
|
||||||
|
@ -170,7 +172,7 @@ class Smilies
|
||||||
$s = preg_replace_callback('/<pre>(.*?)<\/pre>/ism', 'self::encode', $s);
|
$s = preg_replace_callback('/<pre>(.*?)<\/pre>/ism', 'self::encode', $s);
|
||||||
$s = preg_replace_callback('/<code>(.*?)<\/code>/ism', 'self::encode', $s);
|
$s = preg_replace_callback('/<code>(.*?)<\/code>/ism', 'self::encode', $s);
|
||||||
|
|
||||||
$params = self::get_list();
|
$params = self::getList();
|
||||||
|
|
||||||
if ($no_images) {
|
if ($no_images) {
|
||||||
$cleaned = array('texts' => array(), 'icons' => array());
|
$cleaned = array('texts' => array(), 'icons' => array());
|
||||||
|
@ -192,7 +194,7 @@ class Smilies
|
||||||
$s .= '<dl><dt>' . $params['texts'][$x] . '</dt><dd>' . $params['icons'][$x] . '</dd></dl>';
|
$s .= '<dl><dt>' . $params['texts'][$x] . '</dt><dd>' . $params['icons'][$x] . '</dd></dl>';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$params['string'] = preg_replace_callback('/<(3+)/', 'self::preg_heart', $params['string']);
|
$params['string'] = preg_replace_callback('/<(3+)/', 'self::pregHeart', $params['string']);
|
||||||
$s = str_replace($params['texts'], $params['icons'], $params['string']);
|
$s = str_replace($params['texts'], $params['icons'], $params['string']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,11 +204,21 @@ class Smilies
|
||||||
return $s;
|
return $s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $m string
|
||||||
|
*
|
||||||
|
* @return string base64 encoded string
|
||||||
|
*/
|
||||||
private static function encode($m)
|
private static function encode($m)
|
||||||
{
|
{
|
||||||
return(str_replace($m[1], base64url_encode($m[1]), $m[0]));
|
return(str_replace($m[1], base64url_encode($m[1]), $m[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $m string
|
||||||
|
*
|
||||||
|
* @return string base64 decoded string
|
||||||
|
*/
|
||||||
private static function decode($m)
|
private static function decode($m)
|
||||||
{
|
{
|
||||||
return(str_replace($m[1], base64url_decode($m[1]), $m[0]));
|
return(str_replace($m[1], base64url_decode($m[1]), $m[0]));
|
||||||
|
@ -216,13 +228,13 @@ class Smilies
|
||||||
/**
|
/**
|
||||||
* @brief expand <3333 to the correct number of hearts
|
* @brief expand <3333 to the correct number of hearts
|
||||||
*
|
*
|
||||||
* @param string $x
|
* @param string $x string
|
||||||
*
|
*
|
||||||
* @return string HTML Output
|
* @return string HTML Output
|
||||||
*
|
*
|
||||||
* @todo: Rework because it doesn't work correctly
|
* @todo: Rework because it doesn't work correctly
|
||||||
*/
|
*/
|
||||||
private static function preg_heart($x)
|
private static function pregHeart($x)
|
||||||
{
|
{
|
||||||
if (strlen($x[1]) == 1) {
|
if (strlen($x[1]) == 1) {
|
||||||
return $x[0];
|
return $x[0];
|
||||||
|
|
|
@ -19,8 +19,10 @@ class BaseObject
|
||||||
* Get the app
|
* Get the app
|
||||||
*
|
*
|
||||||
* Same as get_app from boot.php
|
* Same as get_app from boot.php
|
||||||
|
*
|
||||||
|
* @return object
|
||||||
*/
|
*/
|
||||||
public function get_app()
|
public function getApp()
|
||||||
{
|
{
|
||||||
if (self::$app) {
|
if (self::$app) {
|
||||||
return self::$app;
|
return self::$app;
|
||||||
|
@ -35,8 +37,10 @@ class BaseObject
|
||||||
* Set the app
|
* Set the app
|
||||||
*
|
*
|
||||||
* @param object $app App
|
* @param object $app App
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function set_app($app)
|
public static function setApp($app)
|
||||||
{
|
{
|
||||||
self::$app = $app;
|
self::$app = $app;
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,6 +134,8 @@ class Cache
|
||||||
* @param string $key The key to the cached data
|
* @param string $key The key to the cached data
|
||||||
* @param mixed $value The value that is about to be stored
|
* @param mixed $value The value that is about to be stored
|
||||||
* @param integer $duration The cache lifespan
|
* @param integer $duration The cache lifespan
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function set($key, $value, $duration = CACHE_MONTH)
|
public static function set($key, $value, $duration = CACHE_MONTH)
|
||||||
{
|
{
|
||||||
|
@ -159,6 +161,8 @@ class Cache
|
||||||
* @brief Remove outdated data from the cache
|
* @brief Remove outdated data from the cache
|
||||||
*
|
*
|
||||||
* @param integer $max_level The maximum cache level that is to be cleared
|
* @param integer $max_level The maximum cache level that is to be cleared
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function clear($max_level = CACHE_MONTH)
|
public static function clear($max_level = CACHE_MONTH)
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,8 +21,8 @@ use dba;
|
||||||
* There are a few places in the code (such as the admin panel) where boolean
|
* There are a few places in the code (such as the admin panel) where boolean
|
||||||
* configurations need to be fixed as of 10/08/2011.
|
* configurations need to be fixed as of 10/08/2011.
|
||||||
*/
|
*/
|
||||||
class Config {
|
class Config
|
||||||
|
{
|
||||||
private static $cache;
|
private static $cache;
|
||||||
private static $in_db;
|
private static $in_db;
|
||||||
|
|
||||||
|
@ -32,12 +32,12 @@ class Config {
|
||||||
* All configuration values of the system are stored in global cache
|
* All configuration values of the system are stored in global cache
|
||||||
* which is available under the global variable $a->config
|
* which is available under the global variable $a->config
|
||||||
*
|
*
|
||||||
* @param string $family
|
* @param string $family The category of the configuration value
|
||||||
* The category of the configuration value
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function load($family = "config") {
|
public static function load($family = "config")
|
||||||
|
{
|
||||||
// We don't preload "system" anymore.
|
// We don't preload "system" anymore.
|
||||||
// This reduces the number of database reads a lot.
|
// This reduces the number of database reads a lot.
|
||||||
if ($family === 'system') {
|
if ($family === 'system') {
|
||||||
|
@ -72,18 +72,15 @@ class Config {
|
||||||
* local config cache, pull it into the cache so we don't have
|
* local config cache, pull it into the cache so we don't have
|
||||||
* to hit the DB again for this item.
|
* to hit the DB again for this item.
|
||||||
*
|
*
|
||||||
* @param string $family
|
* @param string $family The category of the configuration value
|
||||||
* The category of the configuration value
|
* @param string $key The configuration key to query
|
||||||
* @param string $key
|
* @param mixed $default_value optional, The value to return if key is not set (default: null)
|
||||||
* The configuration key to query
|
* @param boolean $refresh optional, If true the config is loaded from the db and not from the cache (default: false)
|
||||||
* @param mixed $default_value optional
|
*
|
||||||
* The value to return if key is not set (default: null)
|
|
||||||
* @param boolean $refresh optional
|
|
||||||
* If true the config is loaded from the db and not from the cache (default: false)
|
|
||||||
* @return mixed Stored value or null if it does not exist
|
* @return mixed Stored value or null if it does not exist
|
||||||
*/
|
*/
|
||||||
public static function get($family, $key, $default_value = null, $refresh = false) {
|
public static function get($family, $key, $default_value = null, $refresh = false)
|
||||||
|
{
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
if (!$refresh) {
|
if (!$refresh) {
|
||||||
|
@ -128,15 +125,14 @@ class Config {
|
||||||
*
|
*
|
||||||
* Note: Please do not store booleans - convert to 0/1 integer values!
|
* Note: Please do not store booleans - convert to 0/1 integer values!
|
||||||
*
|
*
|
||||||
* @param string $family
|
* @param string $family The category of the configuration value
|
||||||
* The category of the configuration value
|
* @param string $key The configuration key to set
|
||||||
* @param string $key
|
* @param string $value The value to store
|
||||||
* The configuration key to set
|
*
|
||||||
* @param string $value
|
|
||||||
* The value to store
|
|
||||||
* @return mixed Stored $value or false if the database update failed
|
* @return mixed Stored $value or false if the database update failed
|
||||||
*/
|
*/
|
||||||
public static function set($family, $key, $value) {
|
public static function set($family, $key, $value)
|
||||||
|
{
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
// We store our setting values in a string variable.
|
// We store our setting values in a string variable.
|
||||||
|
@ -177,14 +173,13 @@ class Config {
|
||||||
* Removes the configured value from the stored cache in $a->config
|
* Removes the configured value from the stored cache in $a->config
|
||||||
* and removes it from the database.
|
* and removes it from the database.
|
||||||
*
|
*
|
||||||
* @param string $family
|
* @param string $family The category of the configuration value
|
||||||
* The category of the configuration value
|
* @param string $key The configuration key to delete
|
||||||
* @param string $key
|
*
|
||||||
* The configuration key to delete
|
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public static function delete($family, $key) {
|
public static function delete($family, $key)
|
||||||
|
{
|
||||||
if (isset(self::$cache[$family][$key])) {
|
if (isset(self::$cache[$family][$key])) {
|
||||||
unset(self::$cache[$family][$key]);
|
unset(self::$cache[$family][$key]);
|
||||||
unset(self::$in_db[$family][$key]);
|
unset(self::$in_db[$family][$key]);
|
||||||
|
|
|
@ -23,22 +23,32 @@ class Conversation extends BaseObject
|
||||||
private $profile_owner = 0;
|
private $profile_owner = 0;
|
||||||
private $preview = false;
|
private $preview = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param string $mode The mode
|
||||||
|
* @param boolean $preview boolean value
|
||||||
|
*/
|
||||||
public function __construct($mode, $preview)
|
public function __construct($mode, $preview)
|
||||||
{
|
{
|
||||||
$this->set_mode($mode);
|
$this->setMode($mode);
|
||||||
$this->preview = $preview;
|
$this->preview = $preview;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the mode we'll be displayed on
|
* Set the mode we'll be displayed on
|
||||||
|
*
|
||||||
|
* @param string $mode The mode to set
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function set_mode($mode)
|
private function setMode($mode)
|
||||||
{
|
{
|
||||||
if ($this->get_mode() == $mode) {
|
if ($this->getMode() == $mode) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$a = $this->get_app();
|
$a = $this->getApp();
|
||||||
|
|
||||||
switch ($mode) {
|
switch ($mode) {
|
||||||
case 'network':
|
case 'network':
|
||||||
|
@ -55,7 +65,7 @@ class Conversation extends BaseObject
|
||||||
$this->writable = can_write_wall($a, $this->profile_owner);
|
$this->writable = can_write_wall($a, $this->profile_owner);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logger('[ERROR] Conversation::set_mode : Unhandled mode ('. $mode .').', LOGGER_DEBUG);
|
logger('[ERROR] Conversation::setMode : Unhandled mode ('. $mode .').', LOGGER_DEBUG);
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -64,32 +74,40 @@ class Conversation extends BaseObject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get mode
|
* Get mode
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function get_mode()
|
public function getMode()
|
||||||
{
|
{
|
||||||
return $this->mode;
|
return $this->mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if page is writable
|
* Check if page is writable
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function is_writable()
|
public function isWritable()
|
||||||
{
|
{
|
||||||
return $this->writable;
|
return $this->writable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if page is a preview
|
* Check if page is a preview
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function is_preview()
|
public function isPreview()
|
||||||
{
|
{
|
||||||
return $this->preview;
|
return $this->preview;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get profile owner
|
* Get profile owner
|
||||||
|
*
|
||||||
|
* @return integer
|
||||||
*/
|
*/
|
||||||
public function get_profile_owner()
|
public function getProfileOwner()
|
||||||
{
|
{
|
||||||
return $this->profile_owner;
|
return $this->profile_owner;
|
||||||
}
|
}
|
||||||
|
@ -97,21 +115,22 @@ class Conversation extends BaseObject
|
||||||
/**
|
/**
|
||||||
* Add a thread to the conversation
|
* Add a thread to the conversation
|
||||||
*
|
*
|
||||||
* Returns:
|
* @param object $item The item to insert
|
||||||
* _ The inserted item on success
|
*
|
||||||
* _ false on failure
|
* @return mixed The inserted item on success
|
||||||
|
* false on failure
|
||||||
*/
|
*/
|
||||||
public function add_thread($item)
|
public function addThread($item)
|
||||||
{
|
{
|
||||||
$item_id = $item->getId();
|
$item_id = $item->getId();
|
||||||
|
|
||||||
if (!$item_id) {
|
if (!$item_id) {
|
||||||
logger('[ERROR] Conversation::add_thread : Item has no ID!!', LOGGER_DEBUG);
|
logger('[ERROR] Conversation::addThread : Item has no ID!!', LOGGER_DEBUG);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->get_thread($item->getId())) {
|
if ($this->getThread($item->getId())) {
|
||||||
logger('[WARN] Conversation::add_thread : Thread already exists ('. $item->getId() .').', LOGGER_DEBUG);
|
logger('[WARN] Conversation::addThread : Thread already exists ('. $item->getId() .').', LOGGER_DEBUG);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,12 +138,12 @@ class Conversation extends BaseObject
|
||||||
* Only add will be displayed
|
* Only add will be displayed
|
||||||
*/
|
*/
|
||||||
if ($item->getDataValue('network') === NETWORK_MAIL && local_user() != $item->getDataValue('uid')) {
|
if ($item->getDataValue('network') === NETWORK_MAIL && local_user() != $item->getDataValue('uid')) {
|
||||||
logger('[WARN] Conversation::add_thread : Thread is a mail ('. $item->getId() .').', LOGGER_DEBUG);
|
logger('[WARN] Conversation::addThread : Thread is a mail ('. $item->getId() .').', LOGGER_DEBUG);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($item->getDataValue('verb') === ACTIVITY_LIKE || $item->getDataValue('verb') === ACTIVITY_DISLIKE) {
|
if ($item->getDataValue('verb') === ACTIVITY_LIKE || $item->getDataValue('verb') === ACTIVITY_DISLIKE) {
|
||||||
logger('[WARN] Conversation::add_thread : Thread is a (dis)like ('. $item->getId() .').', LOGGER_DEBUG);
|
logger('[WARN] Conversation::addThread : Thread is a (dis)like ('. $item->getId() .').', LOGGER_DEBUG);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,13 +158,14 @@ class Conversation extends BaseObject
|
||||||
*
|
*
|
||||||
* We should find a way to avoid using those arguments (at least most of them)
|
* We should find a way to avoid using those arguments (at least most of them)
|
||||||
*
|
*
|
||||||
* Returns:
|
* @param object $conv_responses data
|
||||||
* _ The data requested on success
|
*
|
||||||
* _ false on failure
|
* @return mixed The data requested on success
|
||||||
|
* false on failure
|
||||||
*/
|
*/
|
||||||
public function get_template_data($conv_responses)
|
public function getTemplateData($conv_responses)
|
||||||
{
|
{
|
||||||
$a = get_app();
|
$a = getApp();
|
||||||
$result = array();
|
$result = array();
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
|
@ -157,7 +177,7 @@ class Conversation extends BaseObject
|
||||||
$item_data = $item->getTemplateData($conv_responses);
|
$item_data = $item->getTemplateData($conv_responses);
|
||||||
|
|
||||||
if (!$item_data) {
|
if (!$item_data) {
|
||||||
logger('[ERROR] Conversation::get_template_data : Failed to get item template data ('. $item->getId() .').', LOGGER_DEBUG);
|
logger('[ERROR] Conversation::getTemplateData : Failed to get item template data ('. $item->getId() .').', LOGGER_DEBUG);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$result[] = $item_data;
|
$result[] = $item_data;
|
||||||
|
@ -169,11 +189,12 @@ class Conversation extends BaseObject
|
||||||
/**
|
/**
|
||||||
* Get a thread based on its item id
|
* Get a thread based on its item id
|
||||||
*
|
*
|
||||||
* Returns:
|
* @param integer $id Item id
|
||||||
* _ The found item on success
|
*
|
||||||
* _ false on failure
|
* @return mixed The found item on success
|
||||||
|
* false on failure
|
||||||
*/
|
*/
|
||||||
private function get_thread($id)
|
private function getThread($id)
|
||||||
{
|
{
|
||||||
foreach ($this->threads as $item) {
|
foreach ($this->threads as $item) {
|
||||||
if ($item->getId() == $id) {
|
if ($item->getId() == $id) {
|
||||||
|
|
|
@ -39,9 +39,14 @@ class Item extends BaseObject
|
||||||
private $threaded = false;
|
private $threaded = false;
|
||||||
private $visiting = false;
|
private $visiting = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param array $data data array
|
||||||
|
*/
|
||||||
public function __construct($data)
|
public function __construct($data)
|
||||||
{
|
{
|
||||||
$a = $this->get_app();
|
$a = $this->getApp();
|
||||||
|
|
||||||
$this->data = $data;
|
$this->data = $data;
|
||||||
$this->setTemplate('wall');
|
$this->setTemplate('wall');
|
||||||
|
@ -92,9 +97,11 @@ class Item extends BaseObject
|
||||||
/**
|
/**
|
||||||
* Get data in a form usable by a conversation template
|
* Get data in a form usable by a conversation template
|
||||||
*
|
*
|
||||||
* Returns:
|
* @param object $conv_responses conversation responses
|
||||||
* _ The data requested on success
|
* @param integer $thread_level default = 1
|
||||||
* _ false on failure
|
*
|
||||||
|
* @return mixed The data requested on success
|
||||||
|
* false on failure
|
||||||
*/
|
*/
|
||||||
public function getTemplateData($conv_responses, $thread_level = 1)
|
public function getTemplateData($conv_responses, $thread_level = 1)
|
||||||
{
|
{
|
||||||
|
@ -102,7 +109,7 @@ class Item extends BaseObject
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
|
|
||||||
$a = $this->get_app();
|
$a = $this->getApp();
|
||||||
|
|
||||||
$item = $this->getData();
|
$item = $this->getData();
|
||||||
$edited = false;
|
$edited = false;
|
||||||
|
@ -136,7 +143,7 @@ class Item extends BaseObject
|
||||||
|| strlen($item['deny_cid']) || strlen($item['deny_gid']))))
|
|| strlen($item['deny_cid']) || strlen($item['deny_gid']))))
|
||||||
? t('Private Message')
|
? t('Private Message')
|
||||||
: false);
|
: false);
|
||||||
$shareable = ((($conv->get_profile_owner() == local_user()) && ($item['private'] != 1)) ? true : false);
|
$shareable = ((($conv->getProfileOwner() == local_user()) && ($item['private'] != 1)) ? true : false);
|
||||||
if (local_user() && link_compare($a->contact['url'], $item['author-link'])) {
|
if (local_user() && link_compare($a->contact['url'], $item['author-link'])) {
|
||||||
if ($item["event-id"] != 0) {
|
if ($item["event-id"] != 0) {
|
||||||
$edpost = array("events/event/".$item['event-id'], t("Edit"));
|
$edpost = array("events/event/".$item['event-id'], t("Edit"));
|
||||||
|
@ -153,12 +160,12 @@ class Item extends BaseObject
|
||||||
|
|
||||||
$drop = array(
|
$drop = array(
|
||||||
'dropping' => $dropping,
|
'dropping' => $dropping,
|
||||||
'pagedrop' => ((feature_enabled($conv->get_profile_owner(), 'multi_delete')) ? $item['pagedrop'] : ''),
|
'pagedrop' => ((feature_enabled($conv->getProfileOwner(), 'multi_delete')) ? $item['pagedrop'] : ''),
|
||||||
'select' => t('Select'),
|
'select' => t('Select'),
|
||||||
'delete' => t('Delete'),
|
'delete' => t('Delete'),
|
||||||
);
|
);
|
||||||
|
|
||||||
$filer = (($conv->get_profile_owner() == local_user()) ? t("save to folder") : false);
|
$filer = (($conv->getProfileOwner() == local_user()) ? t("save to folder") : false);
|
||||||
|
|
||||||
$diff_author = ((link_compare($item['url'], $item['author-link'])) ? false : true);
|
$diff_author = ((link_compare($item['url'], $item['author-link'])) ? false : true);
|
||||||
$profile_name = htmlentities(((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']);
|
$profile_name = htmlentities(((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']);
|
||||||
|
@ -179,7 +186,7 @@ class Item extends BaseObject
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($item['author-thumb']) || ($item['author-thumb'] == "")) {
|
if (!isset($item['author-thumb']) || ($item['author-thumb'] == "")) {
|
||||||
$author_contact = get_contact_details_by_url($item['author-link'], $conv->get_profile_owner());
|
$author_contact = get_contact_details_by_url($item['author-link'], $conv->getProfileOwner());
|
||||||
if ($author_contact["thumb"]) {
|
if ($author_contact["thumb"]) {
|
||||||
$item['author-thumb'] = $author_contact["thumb"];
|
$item['author-thumb'] = $author_contact["thumb"];
|
||||||
} else {
|
} else {
|
||||||
|
@ -188,7 +195,7 @@ class Item extends BaseObject
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($item['owner-thumb']) || ($item['owner-thumb'] == "")) {
|
if (!isset($item['owner-thumb']) || ($item['owner-thumb'] == "")) {
|
||||||
$owner_contact = get_contact_details_by_url($item['owner-link'], $conv->get_profile_owner());
|
$owner_contact = get_contact_details_by_url($item['owner-link'], $conv->getProfileOwner());
|
||||||
if ($owner_contact["thumb"]) {
|
if ($owner_contact["thumb"]) {
|
||||||
$item['owner-thumb'] = $owner_contact["thumb"];
|
$item['owner-thumb'] = $owner_contact["thumb"];
|
||||||
} else {
|
} else {
|
||||||
|
@ -223,7 +230,7 @@ class Item extends BaseObject
|
||||||
$response_verbs[] = 'attendyes';
|
$response_verbs[] = 'attendyes';
|
||||||
$response_verbs[] = 'attendno';
|
$response_verbs[] = 'attendno';
|
||||||
$response_verbs[] = 'attendmaybe';
|
$response_verbs[] = 'attendmaybe';
|
||||||
if ($conv->is_writable()) {
|
if ($conv->isWritable()) {
|
||||||
$isevent = true;
|
$isevent = true;
|
||||||
$attend = array( t('I will attend'), t('I will not attend'), t('I might attend'));
|
$attend = array( t('I will attend'), t('I will not attend'), t('I might attend'));
|
||||||
}
|
}
|
||||||
|
@ -247,7 +254,7 @@ class Item extends BaseObject
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->isToplevel()) {
|
if ($this->isToplevel()) {
|
||||||
if ($conv->get_profile_owner() == local_user()) {
|
if ($conv->getProfileOwner() == local_user()) {
|
||||||
$isstarred = (($item['starred']) ? "starred" : "unstarred");
|
$isstarred = (($item['starred']) ? "starred" : "unstarred");
|
||||||
|
|
||||||
$star = array(
|
$star = array(
|
||||||
|
@ -271,7 +278,7 @@ class Item extends BaseObject
|
||||||
}
|
}
|
||||||
|
|
||||||
$tagger = '';
|
$tagger = '';
|
||||||
if (feature_enabled($conv->get_profile_owner(), 'commtag')) {
|
if (feature_enabled($conv->getProfileOwner(), 'commtag')) {
|
||||||
$tagger = array(
|
$tagger = array(
|
||||||
'add' => t("add tag"),
|
'add' => t("add tag"),
|
||||||
'class' => "",
|
'class' => "",
|
||||||
|
@ -282,10 +289,10 @@ class Item extends BaseObject
|
||||||
$indent = 'comment';
|
$indent = 'comment';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($conv->is_writable()) {
|
if ($conv->isWritable()) {
|
||||||
$buttons = array(
|
$buttons = array(
|
||||||
'like' => array( t("I like this \x28toggle\x29"), t("like")),
|
'like' => array( t("I like this \x28toggle\x29"), t("like")),
|
||||||
'dislike' => ((feature_enabled($conv->get_profile_owner(), 'dislike')) ? array( t("I don't like this \x28toggle\x29"), t("dislike")) : ''),
|
'dislike' => ((feature_enabled($conv->getProfileOwner(), 'dislike')) ? array( t("I don't like this \x28toggle\x29"), t("dislike")) : ''),
|
||||||
);
|
);
|
||||||
if ($shareable) {
|
if ($shareable) {
|
||||||
$buttons['share'] = array( t('Share this'), t('share'));
|
$buttons['share'] = array( t('Share this'), t('share'));
|
||||||
|
@ -379,12 +386,12 @@ class Item extends BaseObject
|
||||||
'owner_photo' => $a->remove_baseurl(proxy_url($item['owner-thumb'], false, PROXY_SIZE_THUMB)),
|
'owner_photo' => $a->remove_baseurl(proxy_url($item['owner-thumb'], false, PROXY_SIZE_THUMB)),
|
||||||
'owner_name' => htmlentities($owner_name_e),
|
'owner_name' => htmlentities($owner_name_e),
|
||||||
'plink' => get_plink($item),
|
'plink' => get_plink($item),
|
||||||
'edpost' => ((feature_enabled($conv->get_profile_owner(), 'edit_posts')) ? $edpost : ''),
|
'edpost' => ((feature_enabled($conv->getProfileOwner(), 'edit_posts')) ? $edpost : ''),
|
||||||
'isstarred' => $isstarred,
|
'isstarred' => $isstarred,
|
||||||
'star' => ((feature_enabled($conv->get_profile_owner(), 'star_posts')) ? $star : ''),
|
'star' => ((feature_enabled($conv->getProfileOwner(), 'star_posts')) ? $star : ''),
|
||||||
'ignore' => ((feature_enabled($conv->get_profile_owner(), 'ignore_posts')) ? $ignore : ''),
|
'ignore' => ((feature_enabled($conv->getProfileOwner(), 'ignore_posts')) ? $ignore : ''),
|
||||||
'tagger' => $tagger,
|
'tagger' => $tagger,
|
||||||
'filer' => ((feature_enabled($conv->get_profile_owner(), 'filing')) ? $filer : ''),
|
'filer' => ((feature_enabled($conv->getProfileOwner(), 'filing')) ? $filer : ''),
|
||||||
'drop' => $drop,
|
'drop' => $drop,
|
||||||
'vote' => $buttons,
|
'vote' => $buttons,
|
||||||
'like' => $responses['like']['output'],
|
'like' => $responses['like']['output'],
|
||||||
|
@ -392,7 +399,7 @@ class Item extends BaseObject
|
||||||
'responses' => $responses,
|
'responses' => $responses,
|
||||||
'switchcomment' => t('Comment'),
|
'switchcomment' => t('Comment'),
|
||||||
'comment' => $comment,
|
'comment' => $comment,
|
||||||
'previewing' => ($conv->is_preview() ? ' preview ' : ''),
|
'previewing' => ($conv->isPreview() ? ' preview ' : ''),
|
||||||
'wait' => t('Please wait'),
|
'wait' => t('Please wait'),
|
||||||
'thread_level' => $thread_level,
|
'thread_level' => $thread_level,
|
||||||
'edited' => $edited,
|
'edited' => $edited,
|
||||||
|
@ -449,11 +456,17 @@ class Item extends BaseObject
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
public function getId()
|
public function getId()
|
||||||
{
|
{
|
||||||
return $this->getDataValue('id');
|
return $this->getDataValue('id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
public function isThreaded()
|
public function isThreaded()
|
||||||
{
|
{
|
||||||
return $this->threaded;
|
return $this->threaded;
|
||||||
|
@ -461,6 +474,10 @@ class Item extends BaseObject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a child item
|
* Add a child item
|
||||||
|
*
|
||||||
|
* @param object $item The child item to add
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function addChild(Item $item)
|
public function addChild(Item $item)
|
||||||
{
|
{
|
||||||
|
@ -489,6 +506,10 @@ class Item extends BaseObject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a child by its ID
|
* Get a child by its ID
|
||||||
|
*
|
||||||
|
* @param integer $id The child id
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getChild($id)
|
public function getChild($id)
|
||||||
{
|
{
|
||||||
|
@ -502,7 +523,9 @@ class Item extends BaseObject
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all ou children
|
* Get all our children
|
||||||
|
*
|
||||||
|
* @return object
|
||||||
*/
|
*/
|
||||||
public function getChildren()
|
public function getChildren()
|
||||||
{
|
{
|
||||||
|
@ -511,6 +534,10 @@ class Item extends BaseObject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set our parent
|
* Set our parent
|
||||||
|
*
|
||||||
|
* @param object $item The item to set as parent
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function setParent($item)
|
protected function setParent($item)
|
||||||
{
|
{
|
||||||
|
@ -525,6 +552,8 @@ class Item extends BaseObject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove our parent
|
* Remove our parent
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function removeParent()
|
protected function removeParent()
|
||||||
{
|
{
|
||||||
|
@ -534,6 +563,10 @@ class Item extends BaseObject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a child
|
* Remove a child
|
||||||
|
*
|
||||||
|
* @param object $item The child to be removed
|
||||||
|
*
|
||||||
|
* @return boolean Success or failure
|
||||||
*/
|
*/
|
||||||
public function removeChild($item)
|
public function removeChild($item)
|
||||||
{
|
{
|
||||||
|
@ -553,6 +586,8 @@ class Item extends BaseObject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get parent item
|
* Get parent item
|
||||||
|
*
|
||||||
|
* @return object
|
||||||
*/
|
*/
|
||||||
protected function getParent()
|
protected function getParent()
|
||||||
{
|
{
|
||||||
|
@ -560,11 +595,15 @@ class Item extends BaseObject
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set conversation
|
* Set conversation
|
||||||
|
*
|
||||||
|
* @param object $conv The conversation
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setConversation($conv)
|
public function setConversation($conv)
|
||||||
{
|
{
|
||||||
$previous_mode = ($this->conversation ? $this->conversation->get_mode() : '');
|
$previous_mode = ($this->conversation ? $this->conversation->getMode() : '');
|
||||||
|
|
||||||
$this->conversation = $conv;
|
$this->conversation = $conv;
|
||||||
|
|
||||||
|
@ -575,7 +614,9 @@ class Item extends BaseObject
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get conversation
|
* Get conversation
|
||||||
|
*
|
||||||
|
* @return object
|
||||||
*/
|
*/
|
||||||
public function getConversation()
|
public function getConversation()
|
||||||
{
|
{
|
||||||
|
@ -586,6 +627,8 @@ class Item extends BaseObject
|
||||||
* Get raw data
|
* Get raw data
|
||||||
*
|
*
|
||||||
* We shouldn't need this
|
* We shouldn't need this
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getData()
|
public function getData()
|
||||||
{
|
{
|
||||||
|
@ -595,9 +638,10 @@ class Item extends BaseObject
|
||||||
/**
|
/**
|
||||||
* Get a data value
|
* Get a data value
|
||||||
*
|
*
|
||||||
* Returns:
|
* @param object $name key
|
||||||
* _ value on success
|
*
|
||||||
* _ false on failure
|
* @return mixed value on success
|
||||||
|
* false on failure
|
||||||
*/
|
*/
|
||||||
public function getDataValue($name)
|
public function getDataValue($name)
|
||||||
{
|
{
|
||||||
|
@ -611,6 +655,10 @@ class Item extends BaseObject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set template
|
* Set template
|
||||||
|
*
|
||||||
|
* @param object $name template name
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function setTemplate($name)
|
private function setTemplate($name)
|
||||||
{
|
{
|
||||||
|
@ -624,6 +672,8 @@ class Item extends BaseObject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get template
|
* Get template
|
||||||
|
*
|
||||||
|
* @return object
|
||||||
*/
|
*/
|
||||||
private function getTemplate()
|
private function getTemplate()
|
||||||
{
|
{
|
||||||
|
@ -632,6 +682,8 @@ class Item extends BaseObject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if this is a toplevel post
|
* Check if this is a toplevel post
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
private function isToplevel()
|
private function isToplevel()
|
||||||
{
|
{
|
||||||
|
@ -640,6 +692,8 @@ class Item extends BaseObject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if this is writable
|
* Check if this is writable
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
private function isWritable()
|
private function isWritable()
|
||||||
{
|
{
|
||||||
|
@ -650,18 +704,20 @@ class Item extends BaseObject
|
||||||
// and community forums even if somebody else wrote the post.
|
// and community forums even if somebody else wrote the post.
|
||||||
|
|
||||||
// bug #517 - this fixes for conversation owner
|
// bug #517 - this fixes for conversation owner
|
||||||
if ($conv->get_mode() == 'profile' && $conv->get_profile_owner() == local_user()) {
|
if ($conv->getMode() == 'profile' && $conv->getProfileOwner() == local_user()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this fixes for visitors
|
// this fixes for visitors
|
||||||
return ($this->writable || ($this->isVisiting() && $conv->get_mode() == 'profile'));
|
return ($this->writable || ($this->isVisiting() && $conv->getMode() == 'profile'));
|
||||||
}
|
}
|
||||||
return $this->writable;
|
return $this->writable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Count the total of our descendants
|
* Count the total of our descendants
|
||||||
|
*
|
||||||
|
* @return integer
|
||||||
*/
|
*/
|
||||||
private function countDescendants()
|
private function countDescendants()
|
||||||
{
|
{
|
||||||
|
@ -678,6 +734,8 @@ class Item extends BaseObject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the template for the comment box
|
* Get the template for the comment box
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function getCommentBoxTemplate()
|
private function getCommentBoxTemplate()
|
||||||
{
|
{
|
||||||
|
@ -687,13 +745,14 @@ class Item extends BaseObject
|
||||||
/**
|
/**
|
||||||
* Get the comment box
|
* Get the comment box
|
||||||
*
|
*
|
||||||
* Returns:
|
* @param string $indent Indent value
|
||||||
* _ The comment box string (empty if no comment box)
|
*
|
||||||
* _ false on failure
|
* @return mixed The comment box string (empty if no comment box)
|
||||||
|
* false on failure
|
||||||
*/
|
*/
|
||||||
private function getCommentBox($indent)
|
private function getCommentBox($indent)
|
||||||
{
|
{
|
||||||
$a = $this->get_app();
|
$a = $this->getApp();
|
||||||
if (!$this->isToplevel() && !(Config::get('system', 'thread_allow') && $a->theme_thread_allow)) {
|
if (!$this->isToplevel() && !(Config::get('system', 'thread_allow') && $a->theme_thread_allow)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -702,11 +761,11 @@ class Item extends BaseObject
|
||||||
$conv = $this->getConversation();
|
$conv = $this->getConversation();
|
||||||
$template = get_markup_template($this->getCommentBoxTemplate());
|
$template = get_markup_template($this->getCommentBoxTemplate());
|
||||||
$ww = '';
|
$ww = '';
|
||||||
if (($conv->get_mode() === 'network') && $this->isWallToWall()) {
|
if (($conv->getMode() === 'network') && $this->isWallToWall()) {
|
||||||
$ww = 'ww';
|
$ww = 'ww';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($conv->is_writable() && $this->isWritable()) {
|
if ($conv->isWritable() && $this->isWritable()) {
|
||||||
$qc = $qcomment = null;
|
$qc = $qcomment = null;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -723,13 +782,13 @@ class Item extends BaseObject
|
||||||
array(
|
array(
|
||||||
'$return_path' => $a->query_string,
|
'$return_path' => $a->query_string,
|
||||||
'$threaded' => $this->isThreaded(),
|
'$threaded' => $this->isThreaded(),
|
||||||
// '$jsreload' => (($conv->get_mode() === 'display') ? $_SESSION['return_url'] : ''),
|
// '$jsreload' => (($conv->getMode() === 'display') ? $_SESSION['return_url'] : ''),
|
||||||
'$jsreload' => '',
|
'$jsreload' => '',
|
||||||
'$type' => (($conv->get_mode() === 'profile') ? 'wall-comment' : 'net-comment'),
|
'$type' => (($conv->getMode() === 'profile') ? 'wall-comment' : 'net-comment'),
|
||||||
'$id' => $this->getId(),
|
'$id' => $this->getId(),
|
||||||
'$parent' => $this->getId(),
|
'$parent' => $this->getId(),
|
||||||
'$qcomment' => $qcomment,
|
'$qcomment' => $qcomment,
|
||||||
'$profile_uid' => $conv->get_profile_owner(),
|
'$profile_uid' => $conv->getProfileOwner(),
|
||||||
'$mylink' => $a->remove_baseurl($a->contact['url']),
|
'$mylink' => $a->remove_baseurl($a->contact['url']),
|
||||||
'$mytitle' => t('This is you'),
|
'$mytitle' => t('This is you'),
|
||||||
'$myphoto' => $a->remove_baseurl($a->contact['thumb']),
|
'$myphoto' => $a->remove_baseurl($a->contact['thumb']),
|
||||||
|
@ -743,10 +802,10 @@ class Item extends BaseObject
|
||||||
'$edimg' => t('Image'),
|
'$edimg' => t('Image'),
|
||||||
'$edurl' => t('Link'),
|
'$edurl' => t('Link'),
|
||||||
'$edvideo' => t('Video'),
|
'$edvideo' => t('Video'),
|
||||||
'$preview' => ((feature_enabled($conv->get_profile_owner(), 'preview')) ? t('Preview') : ''),
|
'$preview' => ((feature_enabled($conv->getProfileOwner(), 'preview')) ? t('Preview') : ''),
|
||||||
'$indent' => $indent,
|
'$indent' => $indent,
|
||||||
'$sourceapp' => t($a->sourcename),
|
'$sourceapp' => t($a->sourcename),
|
||||||
'$ww' => (($conv->get_mode() === 'network') ? $ww : ''),
|
'$ww' => (($conv->getMode() === 'network') ? $ww : ''),
|
||||||
'$rand_num' => random_digits(12))
|
'$rand_num' => random_digits(12))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -754,6 +813,9 @@ class Item extends BaseObject
|
||||||
return $comment_box;
|
return $comment_box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
private function getRedirectUrl()
|
private function getRedirectUrl()
|
||||||
{
|
{
|
||||||
return $this->redirect_url;
|
return $this->redirect_url;
|
||||||
|
@ -761,15 +823,17 @@ class Item extends BaseObject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if we are a wall to wall item and set the relevant properties
|
* Check if we are a wall to wall item and set the relevant properties
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function checkWallToWall()
|
protected function checkWallToWall()
|
||||||
{
|
{
|
||||||
$a = $this->get_app();
|
$a = $this->getApp();
|
||||||
$conv = $this->getConversation();
|
$conv = $this->getConversation();
|
||||||
$this->wall_to_wall = false;
|
$this->wall_to_wall = false;
|
||||||
|
|
||||||
if ($this->isToplevel()) {
|
if ($this->isToplevel()) {
|
||||||
if ($conv->get_mode() !== 'profile') {
|
if ($conv->getMode() !== 'profile') {
|
||||||
if ($this->getDataValue('wall') && !$this->getDataValue('self')) {
|
if ($this->getDataValue('wall') && !$this->getDataValue('self')) {
|
||||||
// On the network page, I am the owner. On the display page it will be the profile owner.
|
// On the network page, I am the owner. On the display page it will be the profile owner.
|
||||||
// This will have been stored in $a->page_contact by our calling page.
|
// This will have been stored in $a->page_contact by our calling page.
|
||||||
|
@ -819,26 +883,41 @@ class Item extends BaseObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
private function isWallToWall()
|
private function isWallToWall()
|
||||||
{
|
{
|
||||||
return $this->wall_to_wall;
|
return $this->wall_to_wall;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
private function getOwnerUrl()
|
private function getOwnerUrl()
|
||||||
{
|
{
|
||||||
return $this->owner_url;
|
return $this->owner_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
private function getOwnerPhoto()
|
private function getOwnerPhoto()
|
||||||
{
|
{
|
||||||
return $this->owner_photo;
|
return $this->owner_photo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
private function getOwnerName()
|
private function getOwnerName()
|
||||||
{
|
{
|
||||||
return $this->owner_name;
|
return $this->owner_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
private function isVisiting()
|
private function isVisiting()
|
||||||
{
|
{
|
||||||
return $this->visiting;
|
return $this->visiting;
|
||||||
|
|
|
@ -322,7 +322,7 @@ class NotificationsManager
|
||||||
'link' => System::baseUrl(true).'/display/'.$it['pguid'],
|
'link' => System::baseUrl(true).'/display/'.$it['pguid'],
|
||||||
'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
|
'image' => proxy_url($it['author-avatar'], false, PROXY_SIZE_MICRO),
|
||||||
'url' => $it['author-link'],
|
'url' => $it['author-link'],
|
||||||
'text' => sprintf( t("%s is not attending %s's event"), $it['author-name'], $it['pname']),
|
'text' => sprintf(t("%s is not attending %s's event"), $it['author-name'], $it['pname']),
|
||||||
'when' => $default_item_when,
|
'when' => $default_item_when,
|
||||||
'ago' => $default_item_ago,
|
'ago' => $default_item_ago,
|
||||||
'seen' => $it['seen']
|
'seen' => $it['seen']
|
||||||
|
@ -381,9 +381,9 @@ class NotificationsManager
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Total number of network notifications
|
* @brief Total number of network notifications
|
||||||
* @param int|string $seen
|
* @param int|string $seen If 0 only include notifications into the query
|
||||||
* If 0 only include notifications into the query
|
* which aren't marked as "seen"
|
||||||
* which aren't marked as "seen"
|
*
|
||||||
* @return int Number of network notifications
|
* @return int Number of network notifications
|
||||||
*/
|
*/
|
||||||
private function networkTotal($seen = 0)
|
private function networkTotal($seen = 0)
|
||||||
|
@ -413,9 +413,8 @@ class NotificationsManager
|
||||||
/**
|
/**
|
||||||
* @brief Get network notifications
|
* @brief Get network notifications
|
||||||
*
|
*
|
||||||
* @param int|string $seen
|
* @param int|string $seen If 0 only include notifications into the query
|
||||||
* If 0 only include notifications into the query
|
* which aren't marked as "seen"
|
||||||
* which aren't marked as "seen"
|
|
||||||
* @param int $start Start the query at this point
|
* @param int $start Start the query at this point
|
||||||
* @param int $limit Maximum number of query results
|
* @param int $limit Maximum number of query results
|
||||||
*
|
*
|
||||||
|
@ -465,9 +464,9 @@ class NotificationsManager
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Total number of system notifications
|
* @brief Total number of system notifications
|
||||||
* @param int|string $seen
|
* @param int|string $seen If 0 only include notifications into the query
|
||||||
* If 0 only include notifications into the query
|
* which aren't marked as "seen"
|
||||||
* which aren't marked as "seen"
|
*
|
||||||
* @return int Number of system notifications
|
* @return int Number of system notifications
|
||||||
*/
|
*/
|
||||||
private function systemTotal($seen = 0)
|
private function systemTotal($seen = 0)
|
||||||
|
@ -493,9 +492,8 @@ class NotificationsManager
|
||||||
/**
|
/**
|
||||||
* @brief Get system notifications
|
* @brief Get system notifications
|
||||||
*
|
*
|
||||||
* @param int|string $seen
|
* @param int|string $seen If 0 only include notifications into the query
|
||||||
* If 0 only include notifications into the query
|
* which aren't marked as "seen"
|
||||||
* which aren't marked as "seen"
|
|
||||||
* @param int $start Start the query at this point
|
* @param int $start Start the query at this point
|
||||||
* @param int $limit Maximum number of query results
|
* @param int $limit Maximum number of query results
|
||||||
*
|
*
|
||||||
|
@ -541,7 +539,7 @@ class NotificationsManager
|
||||||
*
|
*
|
||||||
* @return string The additional sql query
|
* @return string The additional sql query
|
||||||
*/
|
*/
|
||||||
private function _personal_sql_extra()
|
private function personalSqlExtra()
|
||||||
{
|
{
|
||||||
$myurl = System::baseUrl(true) . '/profile/'. $this->a->user['nickname'];
|
$myurl = System::baseUrl(true) . '/profile/'. $this->a->user['nickname'];
|
||||||
$myurl = substr($myurl, strpos($myurl, '://') + 3);
|
$myurl = substr($myurl, strpos($myurl, '://') + 3);
|
||||||
|
@ -559,15 +557,15 @@ class NotificationsManager
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Total number of personal notifications
|
* @brief Total number of personal notifications
|
||||||
* @param int|string $seen
|
* @param int|string $seen If 0 only include notifications into the query
|
||||||
* If 0 only include notifications into the query
|
* which aren't marked as "seen"
|
||||||
* which aren't marked as "seen"
|
*
|
||||||
* @return int Number of personal notifications
|
* @return int Number of personal notifications
|
||||||
*/
|
*/
|
||||||
private function personalTotal($seen = 0)
|
private function personalTotal($seen = 0)
|
||||||
{
|
{
|
||||||
$sql_seen = "";
|
$sql_seen = "";
|
||||||
$sql_extra = $this->_personal_sql_extra();
|
$sql_extra = $this->personalSqlExtra();
|
||||||
|
|
||||||
if ($seen === 0) {
|
if ($seen === 0) {
|
||||||
$sql_seen = " AND `item`.`unseen` = 1 ";
|
$sql_seen = " AND `item`.`unseen` = 1 ";
|
||||||
|
@ -579,7 +577,7 @@ class NotificationsManager
|
||||||
WHERE `item`.`visible` = 1
|
WHERE `item`.`visible` = 1
|
||||||
$sql_extra
|
$sql_extra
|
||||||
$sql_seen
|
$sql_seen
|
||||||
AND `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0 " ,
|
AND `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0 ",
|
||||||
intval(local_user())
|
intval(local_user())
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -593,9 +591,8 @@ class NotificationsManager
|
||||||
/**
|
/**
|
||||||
* @brief Get personal notifications
|
* @brief Get personal notifications
|
||||||
*
|
*
|
||||||
* @param int|string $seen
|
* @param int|string $seen If 0 only include notifications into the query
|
||||||
* If 0 only include notifications into the query
|
* which aren't marked as "seen"
|
||||||
* which aren't marked as "seen"
|
|
||||||
* @param int $start Start the query at this point
|
* @param int $start Start the query at this point
|
||||||
* @param int $limit Maximum number of query results
|
* @param int $limit Maximum number of query results
|
||||||
*
|
*
|
||||||
|
@ -608,7 +605,7 @@ class NotificationsManager
|
||||||
{
|
{
|
||||||
$ident = 'personal';
|
$ident = 'personal';
|
||||||
$total = $this->personalTotal($seen);
|
$total = $this->personalTotal($seen);
|
||||||
$sql_extra = $this->_personal_sql_extra();
|
$sql_extra = $this->personalSqlExtra();
|
||||||
$notifs = array();
|
$notifs = array();
|
||||||
$sql_seen = "";
|
$sql_seen = "";
|
||||||
|
|
||||||
|
@ -646,9 +643,9 @@ class NotificationsManager
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Total number of home notifications
|
* @brief Total number of home notifications
|
||||||
* @param int|string $seen
|
* @param int|string $seen If 0 only include notifications into the query
|
||||||
* If 0 only include notifications into the query
|
* which aren't marked as "seen"
|
||||||
* which aren't marked as "seen"
|
*
|
||||||
* @return int Number of home notifications
|
* @return int Number of home notifications
|
||||||
*/
|
*/
|
||||||
private function homeTotal($seen = 0)
|
private function homeTotal($seen = 0)
|
||||||
|
@ -677,9 +674,8 @@ class NotificationsManager
|
||||||
/**
|
/**
|
||||||
* @brief Get home notifications
|
* @brief Get home notifications
|
||||||
*
|
*
|
||||||
* @param int|string $seen
|
* @param int|string $seen If 0 only include notifications into the query
|
||||||
* If 0 only include notifications into the query
|
* which aren't marked as "seen"
|
||||||
* which aren't marked as "seen"
|
|
||||||
* @param int $start Start the query at this point
|
* @param int $start Start the query at this point
|
||||||
* @param int $limit Maximum number of query results
|
* @param int $limit Maximum number of query results
|
||||||
*
|
*
|
||||||
|
@ -728,9 +724,9 @@ class NotificationsManager
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Total number of introductions
|
* @brief Total number of introductions
|
||||||
* @param bool $all
|
* @param bool $all If false only include introductions into the query
|
||||||
* If false only include introductions into the query
|
* which aren't marked as ignored
|
||||||
* which aren't marked as ignored
|
*
|
||||||
* @return int Number of introductions
|
* @return int Number of introductions
|
||||||
*/
|
*/
|
||||||
private function introTotal($all = false)
|
private function introTotal($all = false)
|
||||||
|
@ -757,18 +753,18 @@ class NotificationsManager
|
||||||
/**
|
/**
|
||||||
* @brief Get introductions
|
* @brief Get introductions
|
||||||
*
|
*
|
||||||
* @param bool $all
|
* @param bool $all If false only include introductions into the query
|
||||||
* If false only include introductions into the query
|
* which aren't marked as ignored
|
||||||
* which aren't marked as ignored
|
* @param int $start Start the query at this point
|
||||||
* @param int $start Start the query at this point
|
* @param int $limit Maximum number of query results
|
||||||
* @param int $limit Maximum number of query results
|
|
||||||
*
|
*
|
||||||
* @return array with
|
* @return array with
|
||||||
* string 'ident' => Notification identifier
|
* string 'ident' => Notification identifier
|
||||||
* int 'total' => Total number of available introductions
|
* int 'total' => Total number of available introductions
|
||||||
* array 'notifications' => Introductions
|
* array 'notifications' => Introductions
|
||||||
*/
|
*/
|
||||||
public function introNotifs($all = false, $start = 0, $limit = 80) {
|
public function introNotifs($all = false, $start = 0, $limit = 80)
|
||||||
|
{
|
||||||
$ident = 'introductions';
|
$ident = 'introductions';
|
||||||
$total = $this->introTotal($seen);
|
$total = $this->introTotal($seen);
|
||||||
$notifs = array();
|
$notifs = array();
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @file src/Core/PConfig.php
|
||||||
|
*/
|
||||||
namespace Friendica\Core;
|
namespace Friendica\Core;
|
||||||
|
|
||||||
use Friendica\Database\DBM;
|
use Friendica\Database\DBM;
|
||||||
|
@ -17,8 +20,8 @@ use dba;
|
||||||
* The PConfig::get() functions return boolean false for keys that are unset,
|
* The PConfig::get() functions return boolean false for keys that are unset,
|
||||||
* and this could lead to subtle bugs.
|
* and this could lead to subtle bugs.
|
||||||
*/
|
*/
|
||||||
class PConfig {
|
class PConfig
|
||||||
|
{
|
||||||
private static $in_db;
|
private static $in_db;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,13 +30,13 @@ class PConfig {
|
||||||
* All configuration values of the given user are stored in global cache
|
* All configuration values of the given user are stored in global cache
|
||||||
* which is available under the global variable $a->config[$uid].
|
* which is available under the global variable $a->config[$uid].
|
||||||
*
|
*
|
||||||
* @param string $uid
|
* @param string $uid The user_id
|
||||||
* The user_id
|
* @param string $family The category of the configuration value
|
||||||
* @param string $family
|
*
|
||||||
* The category of the configuration value
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function load($uid, $family) {
|
public static function load($uid, $family)
|
||||||
|
{
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
$r = dba::select('pconfig', array('v', 'k'), array('cat' => $family, 'uid' => $uid));
|
$r = dba::select('pconfig', array('v', 'k'), array('cat' => $family, 'uid' => $uid));
|
||||||
|
@ -57,20 +60,16 @@ class PConfig {
|
||||||
* Get a particular user's config value from the given category ($family)
|
* Get a particular user's config value from the given category ($family)
|
||||||
* and the $key from a cached storage in $a->config[$uid].
|
* and the $key from a cached storage in $a->config[$uid].
|
||||||
*
|
*
|
||||||
* @param string $uid
|
* @param string $uid The user_id
|
||||||
* The user_id
|
* @param string $family The category of the configuration value
|
||||||
* @param string $family
|
* @param string $key The configuration key to query
|
||||||
* The category of the configuration value
|
* @param mixed $default_value optional, The value to return if key is not set (default: null)
|
||||||
* @param string $key
|
* @param boolean $refresh optional, If true the config is loaded from the db and not from the cache (default: false)
|
||||||
* The configuration key to query
|
*
|
||||||
* @param mixed $default_value optional
|
|
||||||
* The value to return if key is not set (default: null)
|
|
||||||
* @param boolean $refresh optional
|
|
||||||
* If true the config is loaded from the db and not from the cache (default: false)
|
|
||||||
* @return mixed Stored value or null if it does not exist
|
* @return mixed Stored value or null if it does not exist
|
||||||
*/
|
*/
|
||||||
public static function get($uid, $family, $key, $default_value = null, $refresh = false) {
|
public static function get($uid, $family, $key, $default_value = null, $refresh = false)
|
||||||
|
{
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
if (!$refresh) {
|
if (!$refresh) {
|
||||||
|
@ -112,18 +111,15 @@ class PConfig {
|
||||||
*
|
*
|
||||||
* @note Please do not store booleans - convert to 0/1 integer values!
|
* @note Please do not store booleans - convert to 0/1 integer values!
|
||||||
*
|
*
|
||||||
* @param string $uid
|
* @param string $uid The user_id
|
||||||
* The user_id
|
* @param string $family The category of the configuration value
|
||||||
* @param string $family
|
* @param string $key The configuration key to set
|
||||||
* The category of the configuration value
|
* @param string $value The value to store
|
||||||
* @param string $key
|
*
|
||||||
* The configuration key to set
|
|
||||||
* @param string $value
|
|
||||||
* The value to store
|
|
||||||
* @return mixed Stored $value or false
|
* @return mixed Stored $value or false
|
||||||
*/
|
*/
|
||||||
public static function set($uid, $family, $key, $value) {
|
public static function set($uid, $family, $key, $value)
|
||||||
|
{
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
// We store our setting values in a string variable.
|
// We store our setting values in a string variable.
|
||||||
|
@ -157,15 +153,14 @@ class PConfig {
|
||||||
* Removes the configured value from the stored cache in $a->config[$uid]
|
* Removes the configured value from the stored cache in $a->config[$uid]
|
||||||
* and removes it from the database.
|
* and removes it from the database.
|
||||||
*
|
*
|
||||||
* @param string $uid The user_id
|
* @param string $uid The user_id
|
||||||
* @param string $family
|
* @param string $family The category of the configuration value
|
||||||
* The category of the configuration value
|
* @param string $key The configuration key to delete
|
||||||
* @param string $key
|
*
|
||||||
* The configuration key to delete
|
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public static function delete($uid,$family,$key) {
|
public static function delete($uid, $family, $key)
|
||||||
|
{
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
if (x($a->config[$uid][$family], $key)) {
|
if (x($a->config[$uid][$family], $key)) {
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @file src/Core/System.php
|
||||||
|
*/
|
||||||
namespace Friendica\Core;
|
namespace Friendica\Core;
|
||||||
|
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
|
@ -13,14 +16,16 @@ use Friendica\App;
|
||||||
/**
|
/**
|
||||||
* @brief System methods
|
* @brief System methods
|
||||||
*/
|
*/
|
||||||
class System {
|
class System
|
||||||
|
{
|
||||||
private static $a;
|
private static $a;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initializes the static class variable
|
* @brief Initializes the static class variable
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
private static function init() {
|
private static function init()
|
||||||
|
{
|
||||||
global $a;
|
global $a;
|
||||||
|
|
||||||
if (!is_object(self::$a)) {
|
if (!is_object(self::$a)) {
|
||||||
|
@ -34,7 +39,8 @@ class System {
|
||||||
* @param bool $ssl Whether to append http or https under SSL_POLICY_SELFSIGN
|
* @param bool $ssl Whether to append http or https under SSL_POLICY_SELFSIGN
|
||||||
* @return string Friendica server base URL
|
* @return string Friendica server base URL
|
||||||
*/
|
*/
|
||||||
public static function baseUrl($ssl = false) {
|
public static function baseUrl($ssl = false)
|
||||||
|
{
|
||||||
self::init();
|
self::init();
|
||||||
return self::$a->get_baseurl($ssl);
|
return self::$a->get_baseurl($ssl);
|
||||||
}
|
}
|
||||||
|
@ -42,21 +48,23 @@ class System {
|
||||||
/**
|
/**
|
||||||
* @brief Removes the baseurl from an url. This avoids some mixed content problems.
|
* @brief Removes the baseurl from an url. This avoids some mixed content problems.
|
||||||
*
|
*
|
||||||
* @param string $orig_url
|
* @param string $orig_url The url to be cleaned
|
||||||
*
|
*
|
||||||
* @return string The cleaned url
|
* @return string The cleaned url
|
||||||
*/
|
*/
|
||||||
public static function removedBaseUrl($orig_url) {
|
public static function removedBaseUrl($orig_url)
|
||||||
|
{
|
||||||
self::init();
|
self::init();
|
||||||
return self::$a->remove_baseurl($orig_url);
|
return self::$a->remove_baseurl($orig_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns a string with a callstack. Can be used for logging.
|
* @brief Returns a string with a callstack. Can be used for logging.
|
||||||
*
|
* @param integer $depth optional, default 4
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function callstack($depth = 4) {
|
public static function callstack($depth = 4)
|
||||||
|
{
|
||||||
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||||
|
|
||||||
// We remove the first two items from the list since they contain data that we don't need.
|
// We remove the first two items from the list since they contain data that we don't need.
|
||||||
|
|
Loading…
Reference in a new issue