Fix Scrutinizer issues in mod [_well_know -> contactgroup]
- Remove unused variables and parameter - Updated function documentation - Fix formatting - Add back uninitialized variables - Simplify nested conditions
This commit is contained in:
parent
5640c42469
commit
819592c3bd
|
@ -488,16 +488,16 @@ function get_first_dim($y,$m) {
|
||||||
*
|
*
|
||||||
* @param int $y Year
|
* @param int $y Year
|
||||||
* @param int $m Month
|
* @param int $m Month
|
||||||
* @param bool $links (default false)
|
* @param array $links (default null)
|
||||||
* @param string $class
|
* @param string $class
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*
|
*
|
||||||
* @todo Provide (prev,next) links, define class variations for different size calendars
|
* @todo Provide (prev,next) links, define class variations for different size calendars
|
||||||
*/
|
*/
|
||||||
function cal($y = 0,$m = 0, $links = false, $class='') {
|
function cal($y = 0, $m = 0, $links = null, $class = '')
|
||||||
|
{
|
||||||
// month table - start at 1 to match human usage.
|
// month table - start at 1 to match human usage.
|
||||||
|
|
||||||
$mtab = array(' ',
|
$mtab = array(' ',
|
||||||
'January', 'February', 'March',
|
'January', 'February', 'March',
|
||||||
'April' , 'May' , 'June',
|
'April' , 'May' , 'June',
|
||||||
|
@ -510,6 +510,7 @@ function cal($y = 0,$m = 0, $links = false, $class='') {
|
||||||
if (!$y) {
|
if (!$y) {
|
||||||
$y = $thisyear;
|
$y = $thisyear;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$m) {
|
if (!$m) {
|
||||||
$m = intval($thismonth);
|
$m = intval($thismonth);
|
||||||
}
|
}
|
||||||
|
@ -535,15 +536,13 @@ function cal($y = 0,$m = 0, $links = false, $class='') {
|
||||||
$o .= '</tr><tr>';
|
$o .= '</tr><tr>';
|
||||||
|
|
||||||
while ($d <= $l) {
|
while ($d <= $l) {
|
||||||
if (($dow == $f) && (! $started)) {
|
$started = (($dow == $f) && (!$started));
|
||||||
$started = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$today = (((isset($tddate)) && ($tddate == $d)) ? "class=\"today\" " : '');
|
$today = (((isset($tddate)) && ($tddate == $d)) ? "class=\"today\" " : '');
|
||||||
$o .= "<td $today>";
|
$o .= "<td $today>";
|
||||||
$day = str_replace(' ', ' ', sprintf('%2.2d', $d));
|
$day = str_replace(' ', ' ', sprintf('%2.2d', $d));
|
||||||
if ($started) {
|
if ($started) {
|
||||||
if (is_array($links) && isset($links[$d])) {
|
if (x($links, $d) !== false) {
|
||||||
$o .= "<a href=\"{$links[$d]}\">$day</a>";
|
$o .= "<a href=\"{$links[$d]}\">$day</a>";
|
||||||
} else {
|
} else {
|
||||||
$o .= $day;
|
$o .= $day;
|
||||||
|
|
|
@ -507,10 +507,10 @@ function event_remove_duplicates($dates) {
|
||||||
/**
|
/**
|
||||||
* @brief Get an event by its event ID.
|
* @brief Get an event by its event ID.
|
||||||
*
|
*
|
||||||
* @param type $owner_uid The User ID of the owner of the event
|
* @param int $owner_uid The User ID of the owner of the event
|
||||||
* @param type $event_params An assoziative array with
|
* @param array $event_params An assoziative array with
|
||||||
* int 'event_id' => The ID of the event in the event table
|
* int 'event_id' => The ID of the event in the event table
|
||||||
* @param type $sql_extra
|
* @param string $sql_extra
|
||||||
* @return array Query result
|
* @return array Query result
|
||||||
*/
|
*/
|
||||||
function event_by_id($owner_uid = 0, $event_params, $sql_extra = '') {
|
function event_by_id($owner_uid = 0, $event_params, $sql_extra = '') {
|
||||||
|
|
|
@ -907,12 +907,17 @@ function profile_tabs($a, $is_owner = false, $nickname = null)
|
||||||
return replace_macros($tpl, array('$tabs' => $arr['tabs']));
|
return replace_macros($tpl, array('$tabs' => $arr['tabs']));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the my_url session variable
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function get_my_url()
|
function get_my_url()
|
||||||
{
|
{
|
||||||
if (x($_SESSION, 'my_url')) {
|
if (x($_SESSION, 'my_url')) {
|
||||||
return $_SESSION['my_url'];
|
return $_SESSION['my_url'];
|
||||||
}
|
}
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function zrl_init(App $a)
|
function zrl_init(App $a)
|
||||||
|
|
|
@ -7,14 +7,15 @@ require_once("mod/hostxrd.php");
|
||||||
require_once("mod/nodeinfo.php");
|
require_once("mod/nodeinfo.php");
|
||||||
require_once("mod/xrd.php");
|
require_once("mod/xrd.php");
|
||||||
|
|
||||||
function _well_known_init(App $a) {
|
function _well_known_init(App $a)
|
||||||
|
{
|
||||||
if ($a->argc > 1) {
|
if ($a->argc > 1) {
|
||||||
switch ($a->argv[1]) {
|
switch ($a->argv[1]) {
|
||||||
case "host-meta":
|
case "host-meta":
|
||||||
hostxrd_init($a);
|
hostxrd_init($a);
|
||||||
break;
|
break;
|
||||||
case "x-social-relay":
|
case "x-social-relay":
|
||||||
wk_social_relay($a);
|
wk_social_relay();
|
||||||
break;
|
break;
|
||||||
case "nodeinfo":
|
case "nodeinfo":
|
||||||
nodeinfo_wellknown($a);
|
nodeinfo_wellknown($a);
|
||||||
|
@ -28,8 +29,8 @@ function _well_known_init(App $a) {
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
||||||
function wk_social_relay(App $a) {
|
function wk_social_relay()
|
||||||
|
{
|
||||||
$subscribe = (bool) Config::get('system', 'relay_subscribe', false);
|
$subscribe = (bool) Config::get('system', 'relay_subscribe', false);
|
||||||
|
|
||||||
if ($subscribe) {
|
if ($subscribe) {
|
||||||
|
@ -63,9 +64,11 @@ function wk_social_relay(App $a) {
|
||||||
$taglist[] = $tag;
|
$taglist[] = $tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
$relay = array("subscribe" => $subscribe,
|
$relay = array(
|
||||||
|
"subscribe" => $subscribe,
|
||||||
"scope" => $scope,
|
"scope" => $scope,
|
||||||
"tags" => $taglist);
|
"tags" => $taglist
|
||||||
|
);
|
||||||
|
|
||||||
header('Content-type: application/json; charset=utf-8');
|
header('Content-type: application/json; charset=utf-8');
|
||||||
echo json_encode($relay, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
|
echo json_encode($relay, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
|
||||||
|
|
|
@ -3,12 +3,11 @@
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
use Friendica\Network\Probe;
|
use Friendica\Network\Probe;
|
||||||
|
|
||||||
function acctlink_init(App $a) {
|
function acctlink_init()
|
||||||
|
{
|
||||||
if (x($_GET, 'addr')) {
|
if (x($_GET, 'addr')) {
|
||||||
$addr = trim($_GET['addr']);
|
$addr = trim($_GET['addr']);
|
||||||
$res = Probe::uri($addr);
|
$res = Probe::uri($addr);
|
||||||
//logger('acctlink: ' . print_r($res,true));
|
|
||||||
if ($res['url']) {
|
if ($res['url']) {
|
||||||
goaway($res['url']);
|
goaway($res['url']);
|
||||||
killme();
|
killme();
|
||||||
|
|
102
mod/admin.php
102
mod/admin.php
|
@ -44,7 +44,7 @@ function admin_post(App $a)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// urls
|
$return_path = 'admin';
|
||||||
if ($a->argc > 1) {
|
if ($a->argc > 1) {
|
||||||
switch ($a->argv[1]) {
|
switch ($a->argv[1]) {
|
||||||
case 'site':
|
case 'site':
|
||||||
|
@ -62,8 +62,7 @@ function admin_post(App $a)
|
||||||
$func($a);
|
$func($a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
goaway('admin/plugins/' . $a->argv[2]);
|
$return_path = 'admin/plugins/' . $a->argv[2];
|
||||||
return; // NOTREACHED
|
|
||||||
break;
|
break;
|
||||||
case 'themes':
|
case 'themes':
|
||||||
if ($a->argc < 2) {
|
if ($a->argc < 2) {
|
||||||
|
@ -76,38 +75,31 @@ function admin_post(App $a)
|
||||||
|
|
||||||
$theme = $a->argv[2];
|
$theme = $a->argv[2];
|
||||||
if (is_file("view/theme/$theme/config.php")) {
|
if (is_file("view/theme/$theme/config.php")) {
|
||||||
|
|
||||||
function __call_theme_admin_post(App $a, $theme)
|
|
||||||
{
|
|
||||||
$orig_theme = $a->theme;
|
$orig_theme = $a->theme;
|
||||||
$orig_page = $a->page;
|
$orig_page = $a->page;
|
||||||
$orig_session_theme = $_SESSION['theme'];
|
$orig_session_theme = $_SESSION['theme'];
|
||||||
require_once("view/theme/$theme/theme.php");
|
require_once "view/theme/$theme/theme.php";
|
||||||
require_once("view/theme/$theme/config.php");
|
require_once "view/theme/$theme/config.php";
|
||||||
$_SESSION['theme'] = $theme;
|
$_SESSION['theme'] = $theme;
|
||||||
|
|
||||||
|
$init = $theme . '_init';
|
||||||
$init = $theme . "_init";
|
|
||||||
if (function_exists($init)) {
|
if (function_exists($init)) {
|
||||||
$init($a);
|
$init($a);
|
||||||
}
|
}
|
||||||
if (function_exists("theme_admin_post")) {
|
if (function_exists('theme_admin_post')) {
|
||||||
$admin_form = theme_admin_post($a);
|
theme_admin_post($a);
|
||||||
}
|
}
|
||||||
|
|
||||||
$_SESSION['theme'] = $orig_session_theme;
|
$_SESSION['theme'] = $orig_session_theme;
|
||||||
$a->theme = $orig_theme;
|
$a->theme = $orig_theme;
|
||||||
$a->page = $orig_page;
|
$a->page = $orig_page;
|
||||||
return $admin_form;
|
|
||||||
}
|
|
||||||
__call_theme_admin_post($a, $theme);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
info(t('Theme settings updated.'));
|
info(t('Theme settings updated.'));
|
||||||
if (is_ajax()) {
|
if (is_ajax()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
goaway('admin/themes/' . $theme);
|
$return_path = 'admin/themes/' . $theme;
|
||||||
return;
|
|
||||||
break;
|
break;
|
||||||
case 'features':
|
case 'features':
|
||||||
admin_page_features_post($a);
|
admin_page_features_post($a);
|
||||||
|
@ -115,9 +107,6 @@ function admin_post(App $a)
|
||||||
case 'logs':
|
case 'logs':
|
||||||
admin_page_logs_post($a);
|
admin_page_logs_post($a);
|
||||||
break;
|
break;
|
||||||
case 'dbsync':
|
|
||||||
admin_page_dbsync_post($a);
|
|
||||||
break;
|
|
||||||
case 'contactblock':
|
case 'contactblock':
|
||||||
admin_page_contactblock_post($a);
|
admin_page_contactblock_post($a);
|
||||||
break;
|
break;
|
||||||
|
@ -130,7 +119,7 @@ function admin_post(App $a)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
goaway('admin');
|
goaway($return_path);
|
||||||
return; // NOTREACHED
|
return; // NOTREACHED
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -720,7 +709,7 @@ function admin_page_summary(App $a)
|
||||||
if (Config::get('system', 'check_new_version_url', 'none') != 'none') {
|
if (Config::get('system', 'check_new_version_url', 'none') != 'none') {
|
||||||
$gitversion = Config::get('system', 'git_friendica_version');
|
$gitversion = Config::get('system', 'git_friendica_version');
|
||||||
if (version_compare(FRIENDICA_VERSION, $gitversion) < 0) {
|
if (version_compare(FRIENDICA_VERSION, $gitversion) < 0) {
|
||||||
$warningtext[] = sprintf(t('There is a new version of Friendica available for download. Your current version is %1$s, upstream version is %2$s'), $FRIENDICA_VERSION, $gitversion);
|
$warningtext[] = sprintf(t('There is a new version of Friendica available for download. Your current version is %1$s, upstream version is %2$s'), FRIENDICA_VERSION, $gitversion);
|
||||||
$showwarning = true;
|
$showwarning = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -817,7 +806,7 @@ function admin_page_site_post(App $a)
|
||||||
$new_url = rtrim($new_url, "/");
|
$new_url = rtrim($new_url, "/");
|
||||||
|
|
||||||
$parsed = @parse_url($new_url);
|
$parsed = @parse_url($new_url);
|
||||||
if (!$parsed || (!x($parsed, 'host') || !x($parsed, 'scheme'))) {
|
if (!is_array($parsed) || !x($parsed, 'host') || !x($parsed, 'scheme')) {
|
||||||
notice(t("Can not parse base url. Must have at least <scheme>://<domain>"));
|
notice(t("Can not parse base url. Must have at least <scheme>://<domain>"));
|
||||||
goaway('admin/site');
|
goaway('admin/site');
|
||||||
}
|
}
|
||||||
|
@ -1151,8 +1140,7 @@ function admin_page_site(App $a)
|
||||||
$theme_choices_mobile = array();
|
$theme_choices_mobile = array();
|
||||||
$theme_choices_mobile["---"] = t("No special theme for mobile devices");
|
$theme_choices_mobile["---"] = t("No special theme for mobile devices");
|
||||||
$files = glob('view/theme/*');
|
$files = glob('view/theme/*');
|
||||||
if ($files) {
|
if (is_array($files)) {
|
||||||
|
|
||||||
$allowed_theme_list = Config::get('system', 'allowed_themes');
|
$allowed_theme_list = Config::get('system', 'allowed_themes');
|
||||||
|
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
|
@ -1185,16 +1173,6 @@ function admin_page_site(App $a)
|
||||||
CP_USERS_AND_GLOBAL => t("Public postings from local users and the federated network")
|
CP_USERS_AND_GLOBAL => t("Public postings from local users and the federated network")
|
||||||
);
|
);
|
||||||
|
|
||||||
/* OStatus conversation poll choices */
|
|
||||||
$ostatus_poll_choices = array(
|
|
||||||
"-2" => t("Never"),
|
|
||||||
"-1" => t("At post arrival"),
|
|
||||||
"0" => t("Frequently"),
|
|
||||||
"60" => t("Hourly"),
|
|
||||||
"720" => t("Twice daily"),
|
|
||||||
"1440" => t("Daily")
|
|
||||||
);
|
|
||||||
|
|
||||||
$poco_discovery_choices = array(
|
$poco_discovery_choices = array(
|
||||||
"0" => t("Disabled"),
|
"0" => t("Disabled"),
|
||||||
"1" => t("Users"),
|
"1" => t("Users"),
|
||||||
|
@ -1397,7 +1375,7 @@ function admin_page_dbsync(App $a)
|
||||||
|
|
||||||
if (($a->argc > 2) && (intval($a->argv[2]) || ($a->argv[2] === 'check'))) {
|
if (($a->argc > 2) && (intval($a->argv[2]) || ($a->argv[2] === 'check'))) {
|
||||||
$retval = DBStructure::update(false, true);
|
$retval = DBStructure::update(false, true);
|
||||||
if (!$retval) {
|
if ($retval === '') {
|
||||||
$o .= sprintf(t("Database structure update %s was successfully applied."), DB_UPDATE_VERSION) . "<br />";
|
$o .= sprintf(t("Database structure update %s was successfully applied."), DB_UPDATE_VERSION) . "<br />";
|
||||||
Config::set('database', 'dbupdate_' . DB_UPDATE_VERSION, 'success');
|
Config::set('database', 'dbupdate_' . DB_UPDATE_VERSION, 'success');
|
||||||
} else {
|
} else {
|
||||||
|
@ -1637,9 +1615,6 @@ function admin_page_users(App $a)
|
||||||
if (in_array($new_order, $valid_orders)) {
|
if (in_array($new_order, $valid_orders)) {
|
||||||
$order = $new_order;
|
$order = $new_order;
|
||||||
}
|
}
|
||||||
if (x($_GET, 'd')) {
|
|
||||||
$new_direction = $_GET['d'];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$sql_order = "`" . str_replace('.', '`.`', $order) . "`";
|
$sql_order = "`" . str_replace('.', '`.`', $order) . "`";
|
||||||
$sql_order_direction = ($order_direction === "+") ? "ASC" : "DESC";
|
$sql_order_direction = ($order_direction === "+") ? "ASC" : "DESC";
|
||||||
|
@ -1795,8 +1770,6 @@ function admin_page_plugins(App $a)
|
||||||
}
|
}
|
||||||
|
|
||||||
// display plugin details
|
// display plugin details
|
||||||
require_once('library/markdown.php');
|
|
||||||
|
|
||||||
if (in_array($plugin, $a->plugins)) {
|
if (in_array($plugin, $a->plugins)) {
|
||||||
$status = "on";
|
$status = "on";
|
||||||
$action = t("Disable");
|
$action = t("Disable");
|
||||||
|
@ -1807,6 +1780,7 @@ function admin_page_plugins(App $a)
|
||||||
|
|
||||||
$readme = Null;
|
$readme = Null;
|
||||||
if (is_file("addon/$plugin/README.md")) {
|
if (is_file("addon/$plugin/README.md")) {
|
||||||
|
require_once 'library/markdown.php';
|
||||||
$readme = file_get_contents("addon/$plugin/README.md");
|
$readme = file_get_contents("addon/$plugin/README.md");
|
||||||
$readme = Markdown($readme, false);
|
$readme = Markdown($readme, false);
|
||||||
} elseif (is_file("addon/$plugin/README")) {
|
} elseif (is_file("addon/$plugin/README")) {
|
||||||
|
@ -1814,7 +1788,7 @@ function admin_page_plugins(App $a)
|
||||||
}
|
}
|
||||||
|
|
||||||
$admin_form = "";
|
$admin_form = "";
|
||||||
if (is_array($a->plugins_admin) && in_array($plugin, $a->plugins_admin)) {
|
if (in_array($plugin, $a->plugins_admin)) {
|
||||||
@require_once("addon/$plugin/$plugin.php");
|
@require_once("addon/$plugin/$plugin.php");
|
||||||
$func = $plugin . '_plugin_admin';
|
$func = $plugin . '_plugin_admin';
|
||||||
$func($a, $admin_form);
|
$func($a, $admin_form);
|
||||||
|
@ -1857,7 +1831,7 @@ function admin_page_plugins(App $a)
|
||||||
|
|
||||||
$plugins = array();
|
$plugins = array();
|
||||||
$files = glob("addon/*/");
|
$files = glob("addon/*/");
|
||||||
if ($files) {
|
if (is_array($files)) {
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
if (is_dir($file)) {
|
if (is_dir($file)) {
|
||||||
list($tmp, $id) = array_map("trim", explode("/", $file));
|
list($tmp, $id) = array_map("trim", explode("/", $file));
|
||||||
|
@ -1903,7 +1877,8 @@ function admin_page_plugins(App $a)
|
||||||
*/
|
*/
|
||||||
function toggle_theme(&$themes, $th, &$result)
|
function toggle_theme(&$themes, $th, &$result)
|
||||||
{
|
{
|
||||||
for ($x = 0; $x < count($themes); $x ++) {
|
$count = count($themes);
|
||||||
|
for ($x = 0; $x < $count; $x ++) {
|
||||||
if ($themes[$x]['name'] === $th) {
|
if ($themes[$x]['name'] === $th) {
|
||||||
if ($themes[$x]['allowed']) {
|
if ($themes[$x]['allowed']) {
|
||||||
$themes[$x]['allowed'] = 0;
|
$themes[$x]['allowed'] = 0;
|
||||||
|
@ -1923,7 +1898,8 @@ function toggle_theme(&$themes, $th, &$result)
|
||||||
*/
|
*/
|
||||||
function theme_status($themes, $th)
|
function theme_status($themes, $th)
|
||||||
{
|
{
|
||||||
for ($x = 0; $x < count($themes); $x ++) {
|
$count = count($themes);
|
||||||
|
for ($x = 0; $x < $count; $x ++) {
|
||||||
if ($themes[$x]['name'] === $th) {
|
if ($themes[$x]['name'] === $th) {
|
||||||
if ($themes[$x]['allowed']) {
|
if ($themes[$x]['allowed']) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1986,7 +1962,7 @@ function admin_page_themes(App $a)
|
||||||
|
|
||||||
$themes = array();
|
$themes = array();
|
||||||
$files = glob('view/theme/*');
|
$files = glob('view/theme/*');
|
||||||
if ($files) {
|
if (is_array($files)) {
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
$f = basename($file);
|
$f = basename($file);
|
||||||
|
|
||||||
|
@ -2045,8 +2021,6 @@ function admin_page_themes(App $a)
|
||||||
}
|
}
|
||||||
|
|
||||||
// display theme details
|
// display theme details
|
||||||
require_once 'library/markdown.php';
|
|
||||||
|
|
||||||
if (theme_status($themes, $theme)) {
|
if (theme_status($themes, $theme)) {
|
||||||
$status = "on";
|
$status = "on";
|
||||||
$action = t("Disable");
|
$action = t("Disable");
|
||||||
|
@ -2055,41 +2029,36 @@ function admin_page_themes(App $a)
|
||||||
$action = t("Enable");
|
$action = t("Enable");
|
||||||
}
|
}
|
||||||
|
|
||||||
$readme = Null;
|
$readme = null;
|
||||||
if (is_file("view/theme/$theme/README.md")) {
|
if (is_file("view/theme/$theme/README.md")) {
|
||||||
|
require_once 'library/markdown.php';
|
||||||
$readme = file_get_contents("view/theme/$theme/README.md");
|
$readme = file_get_contents("view/theme/$theme/README.md");
|
||||||
$readme = Markdown($readme, false);
|
$readme = Markdown($readme, false);
|
||||||
} elseif (is_file("view/theme/$theme/README")) {
|
} elseif (is_file("view/theme/$theme/README")) {
|
||||||
$readme = "<pre>" . file_get_contents("view/theme/$theme/README") . "</pre>";
|
$readme = "<pre>" . file_get_contents("view/theme/$theme/README") . "</pre>";
|
||||||
}
|
}
|
||||||
|
|
||||||
$admin_form = "";
|
$admin_form = '';
|
||||||
if (is_file("view/theme/$theme/config.php")) {
|
if (is_file("view/theme/$theme/config.php")) {
|
||||||
|
|
||||||
function __get_theme_admin_form(App $a, $theme)
|
|
||||||
{
|
|
||||||
$orig_theme = $a->theme;
|
$orig_theme = $a->theme;
|
||||||
$orig_page = $a->page;
|
$orig_page = $a->page;
|
||||||
$orig_session_theme = $_SESSION['theme'];
|
$orig_session_theme = $_SESSION['theme'];
|
||||||
require_once("view/theme/$theme/theme.php");
|
require_once "view/theme/$theme/theme.php";
|
||||||
require_once("view/theme/$theme/config.php");
|
require_once "view/theme/$theme/config.php";
|
||||||
$_SESSION['theme'] = $theme;
|
$_SESSION['theme'] = $theme;
|
||||||
|
|
||||||
|
|
||||||
$init = $theme . "_init";
|
$init = $theme . "_init";
|
||||||
if (function_exists($init)) {
|
if (function_exists($init)) {
|
||||||
$init($a);
|
$init($a);
|
||||||
}
|
}
|
||||||
if (function_exists("theme_admin")) {
|
|
||||||
|
if (function_exists('theme_admin')) {
|
||||||
$admin_form = theme_admin($a);
|
$admin_form = theme_admin($a);
|
||||||
}
|
}
|
||||||
|
|
||||||
$_SESSION['theme'] = $orig_session_theme;
|
$_SESSION['theme'] = $orig_session_theme;
|
||||||
$a->theme = $orig_theme;
|
$a->theme = $orig_theme;
|
||||||
$a->page = $orig_page;
|
$a->page = $orig_page;
|
||||||
return $admin_form;
|
|
||||||
}
|
|
||||||
$admin_form = __get_theme_admin_form($a, $theme);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$screenshot = array(get_theme_screenshot($theme), t('Screenshot'));
|
$screenshot = array(get_theme_screenshot($theme), t('Screenshot'));
|
||||||
|
@ -2123,14 +2092,12 @@ function admin_page_themes(App $a)
|
||||||
// reload active themes
|
// reload active themes
|
||||||
if (x($_GET, "a") && $_GET['a'] == "r") {
|
if (x($_GET, "a") && $_GET['a'] == "r") {
|
||||||
check_form_security_token_redirectOnErr(System::baseUrl() . '/admin/themes', 'admin_themes', 't');
|
check_form_security_token_redirectOnErr(System::baseUrl() . '/admin/themes', 'admin_themes', 't');
|
||||||
if ($themes) {
|
|
||||||
foreach ($themes as $th) {
|
foreach ($themes as $th) {
|
||||||
if ($th['allowed']) {
|
if ($th['allowed']) {
|
||||||
uninstall_theme($th['name']);
|
uninstall_theme($th['name']);
|
||||||
install_theme($th['name']);
|
install_theme($th['name']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
info("Themes reloaded");
|
info("Themes reloaded");
|
||||||
goaway(System::baseUrl() . '/admin/themes');
|
goaway(System::baseUrl() . '/admin/themes');
|
||||||
}
|
}
|
||||||
|
@ -2139,11 +2106,9 @@ function admin_page_themes(App $a)
|
||||||
* List themes
|
* List themes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$xthemes = array();
|
$plugins = array();
|
||||||
if ($themes) {
|
|
||||||
foreach ($themes as $th) {
|
foreach ($themes as $th) {
|
||||||
$xthemes[] = array($th['name'], (($th['allowed']) ? "on" : "off"), get_theme_info($th['name']));
|
$plugins[] = array($th['name'], (($th['allowed']) ? "on" : "off"), get_theme_info($th['name']));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$t = get_markup_template('admin/plugins.tpl');
|
$t = get_markup_template('admin/plugins.tpl');
|
||||||
|
@ -2154,7 +2119,7 @@ function admin_page_themes(App $a)
|
||||||
'$reload' => t('Reload active themes'),
|
'$reload' => t('Reload active themes'),
|
||||||
'$baseurl' => System::baseUrl(true),
|
'$baseurl' => System::baseUrl(true),
|
||||||
'$function' => 'themes',
|
'$function' => 'themes',
|
||||||
'$plugins' => $xthemes,
|
'$plugins' => $plugins,
|
||||||
'$pcount' => count($themes),
|
'$pcount' => count($themes),
|
||||||
'$noplugshint' => sprintf(t('No themes found on the system. They should be paced in %1$s'),'<code>/view/themes</code>'),
|
'$noplugshint' => sprintf(t('No themes found on the system. They should be paced in %1$s'),'<code>/view/themes</code>'),
|
||||||
'$experimental' => t('[Experimental]'),
|
'$experimental' => t('[Experimental]'),
|
||||||
|
@ -2307,7 +2272,6 @@ function admin_page_features_post(App $a)
|
||||||
|
|
||||||
logger('postvars: ' . print_r($_POST, true), LOGGER_DATA);
|
logger('postvars: ' . print_r($_POST, true), LOGGER_DATA);
|
||||||
|
|
||||||
$arr = array();
|
|
||||||
$features = Feature::get(false);
|
$features = Feature::get(false);
|
||||||
|
|
||||||
foreach ($features as $fname => $fdata) {
|
foreach ($features as $fname => $fdata) {
|
||||||
|
@ -2368,7 +2332,7 @@ function admin_page_features(App $a)
|
||||||
}
|
}
|
||||||
|
|
||||||
$tpl = get_markup_template('admin/settings_features.tpl');
|
$tpl = get_markup_template('admin/settings_features.tpl');
|
||||||
$o .= replace_macros($tpl, array(
|
$o = replace_macros($tpl, array(
|
||||||
'$form_security_token' => get_form_security_token("admin_manage_features"),
|
'$form_security_token' => get_form_security_token("admin_manage_features"),
|
||||||
'$title' => t('Manage Additional Features'),
|
'$title' => t('Manage Additional Features'),
|
||||||
'$features' => $arr,
|
'$features' => $arr,
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file mod/allfriends.php
|
* @file mod/allfriends.php
|
||||||
*/
|
*/
|
||||||
|
@ -11,14 +12,15 @@ use Friendica\Model\GContact;
|
||||||
require_once 'include/contact_selectors.php';
|
require_once 'include/contact_selectors.php';
|
||||||
require_once 'mod/contacts.php';
|
require_once 'mod/contacts.php';
|
||||||
|
|
||||||
function allfriends_content(App $a) {
|
function allfriends_content(App $a)
|
||||||
|
{
|
||||||
$o = '';
|
$o = '';
|
||||||
if (!local_user()) {
|
if (!local_user()) {
|
||||||
notice(t('Permission denied.') . EOL);
|
notice(t('Permission denied.') . EOL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$cid = 0;
|
||||||
if ($a->argc > 1) {
|
if ($a->argc > 1) {
|
||||||
$cid = intval($a->argv[1]);
|
$cid = intval($a->argv[1]);
|
||||||
}
|
}
|
||||||
|
@ -43,11 +45,9 @@ function allfriends_content(App $a) {
|
||||||
|
|
||||||
$total = GContact::countAllFriends(local_user(), $cid);
|
$total = GContact::countAllFriends(local_user(), $cid);
|
||||||
|
|
||||||
if(count($total))
|
|
||||||
$a->set_pager_total($total);
|
$a->set_pager_total($total);
|
||||||
|
|
||||||
$r = GContact::allFriends(local_user(), $cid, $a->pager['start'], $a->pager['itemspage']);
|
$r = GContact::allFriends(local_user(), $cid, $a->pager['start'], $a->pager['itemspage']);
|
||||||
|
|
||||||
if (!DBM::is_result($r)) {
|
if (!DBM::is_result($r)) {
|
||||||
$o .= t('No friends to display.');
|
$o .= t('No friends to display.');
|
||||||
return $o;
|
return $o;
|
||||||
|
@ -55,20 +55,20 @@ function allfriends_content(App $a) {
|
||||||
|
|
||||||
$id = 0;
|
$id = 0;
|
||||||
|
|
||||||
|
$entries = [];
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
|
|
||||||
//get further details of the contact
|
//get further details of the contact
|
||||||
$contact_details = Contact::getDetailsByURL($rr['url'], $uid, $rr);
|
$contact_details = Contact::getDetailsByURL($rr['url'], $uid, $rr);
|
||||||
|
|
||||||
$photo_menu = '';
|
$photo_menu = '';
|
||||||
|
|
||||||
|
$connlnk = '';
|
||||||
// $rr[cid] is only available for common contacts. So if the contact is a common one, use contact_photo_menu to generate the photo_menu
|
// $rr[cid] is only available for common contacts. So if the contact is a common one, use contact_photo_menu to generate the photo_menu
|
||||||
// If the contact is not common to the user, Connect/Follow' will be added to the photo menu
|
// If the contact is not common to the user, Connect/Follow' will be added to the photo menu
|
||||||
if ($rr[cid]) {
|
if ($rr['cid']) {
|
||||||
$rr[id] = $rr[cid];
|
$rr['id'] = $rr['cid'];
|
||||||
$photo_menu = Contact::photoMenu($rr);
|
$photo_menu = Contact::photoMenu($rr);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$connlnk = System::baseUrl() . '/follow/?url=' . $rr['url'];
|
$connlnk = System::baseUrl() . '/follow/?url=' . $rr['url'];
|
||||||
$photo_menu = array(
|
$photo_menu = array(
|
||||||
'profile' => array(t("View Profile"), zrl($rr['url'])),
|
'profile' => array(t("View Profile"), zrl($rr['url'])),
|
||||||
|
@ -78,7 +78,7 @@ function allfriends_content(App $a) {
|
||||||
|
|
||||||
$entry = array(
|
$entry = array(
|
||||||
'url' => $rr['url'],
|
'url' => $rr['url'],
|
||||||
'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
|
'itemurl' => defaults($contact_details, 'addr', $rr['url']),
|
||||||
'name' => htmlentities($contact_details['name']),
|
'name' => htmlentities($contact_details['name']),
|
||||||
'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB),
|
'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB),
|
||||||
'img_hover' => htmlentities($contact_details['name']),
|
'img_hover' => htmlentities($contact_details['name']),
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
use Friendica\App;
|
use Friendica\App;
|
||||||
|
|
||||||
function amcd_content(App $a) {
|
function amcd_content()
|
||||||
|
{
|
||||||
echo <<< JSON
|
echo <<< JSON
|
||||||
{
|
{
|
||||||
"version":1,
|
"version":1,
|
||||||
|
|
|
@ -7,12 +7,14 @@ require_once 'library/markdown.php';
|
||||||
require_once 'include/bb2diaspora.php';
|
require_once 'include/bb2diaspora.php';
|
||||||
require_once 'include/html2bbcode.php';
|
require_once 'include/html2bbcode.php';
|
||||||
|
|
||||||
function visible_lf($s) {
|
function visible_lf($s)
|
||||||
|
{
|
||||||
return str_replace("\n", '<br />', $s);
|
return str_replace("\n", '<br />', $s);
|
||||||
}
|
}
|
||||||
|
|
||||||
function babel_content(App $a) {
|
function babel_content()
|
||||||
$o .= '<h1>Babel Diagnostic</h1>';
|
{
|
||||||
|
$o = '<h1>Babel Diagnostic</h1>';
|
||||||
|
|
||||||
$o .= '<form action="babel" method="post">';
|
$o .= '<form action="babel" method="post">';
|
||||||
$o .= t('Source (bbcode) text:') . EOL;
|
$o .= t('Source (bbcode) text:') . EOL;
|
||||||
|
|
|
@ -7,7 +7,7 @@ use Friendica\Module\Login;
|
||||||
require_once('include/conversation.php');
|
require_once('include/conversation.php');
|
||||||
require_once('include/items.php');
|
require_once('include/items.php');
|
||||||
|
|
||||||
function bookmarklet_init(App $a)
|
function bookmarklet_init()
|
||||||
{
|
{
|
||||||
$_GET["mode"] = "minimal";
|
$_GET["mode"] = "minimal";
|
||||||
}
|
}
|
||||||
|
|
107
mod/cal.php
107
mod/cal.php
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file mod/cal.php
|
* @file mod/cal.php
|
||||||
* @brief The calendar module
|
* @brief The calendar module
|
||||||
|
@ -17,9 +18,11 @@ use Friendica\Model\Group;
|
||||||
require_once 'include/event.php';
|
require_once 'include/event.php';
|
||||||
require_once 'include/redir.php';
|
require_once 'include/redir.php';
|
||||||
|
|
||||||
function cal_init(App $a) {
|
function cal_init(App $a)
|
||||||
if($a->argc > 1)
|
{
|
||||||
|
if ($a->argc > 1) {
|
||||||
auto_redir($a, $a->argv[1]);
|
auto_redir($a, $a->argv[1]);
|
||||||
|
}
|
||||||
|
|
||||||
if ((Config::get('system', 'block_public')) && (!local_user()) && (!remote_user())) {
|
if ((Config::get('system', 'block_public')) && (!local_user()) && (!remote_user())) {
|
||||||
return;
|
return;
|
||||||
|
@ -27,24 +30,24 @@ function cal_init(App $a) {
|
||||||
|
|
||||||
nav_set_selected('events');
|
nav_set_selected('events');
|
||||||
|
|
||||||
$o = '';
|
|
||||||
|
|
||||||
if ($a->argc > 1) {
|
if ($a->argc > 1) {
|
||||||
$nick = $a->argv[1];
|
$nick = $a->argv[1];
|
||||||
$user = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1",
|
$user = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1",
|
||||||
dbesc($nick)
|
dbesc($nick)
|
||||||
);
|
);
|
||||||
|
|
||||||
if(! count($user))
|
if (!count($user)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$a->data['user'] = $user[0];
|
$a->data['user'] = $user[0];
|
||||||
$a->profile_uid = $user[0]['uid'];
|
$a->profile_uid = $user[0]['uid'];
|
||||||
|
|
||||||
// if it's a json request abort here becaus we don't
|
// if it's a json request abort here becaus we don't
|
||||||
// need the widget data
|
// need the widget data
|
||||||
if ($a->argv[2] === 'json')
|
if ($a->argv[2] === 'json') {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$profile = get_profiledata_by_nick($nick, $a->profile_uid);
|
$profile = get_profiledata_by_nick($nick, $a->profile_uid);
|
||||||
|
|
||||||
|
@ -52,7 +55,7 @@ function cal_init(App $a) {
|
||||||
|
|
||||||
$tpl = get_markup_template("vcard-widget.tpl");
|
$tpl = get_markup_template("vcard-widget.tpl");
|
||||||
|
|
||||||
$vcard_widget .= replace_macros($tpl, array(
|
$vcard_widget = replace_macros($tpl, array(
|
||||||
'$name' => $profile['name'],
|
'$name' => $profile['name'],
|
||||||
'$photo' => $profile['photo'],
|
'$photo' => $profile['photo'],
|
||||||
'$addr' => (($profile['addr'] != "") ? $profile['addr'] : ""),
|
'$addr' => (($profile['addr'] != "") ? $profile['addr'] : ""),
|
||||||
|
@ -62,8 +65,9 @@ function cal_init(App $a) {
|
||||||
|
|
||||||
$cal_widget = widget_events();
|
$cal_widget = widget_events();
|
||||||
|
|
||||||
if(! x($a->page,'aside'))
|
if (!x($a->page, 'aside')) {
|
||||||
$a->page['aside'] = '';
|
$a->page['aside'] = '';
|
||||||
|
}
|
||||||
|
|
||||||
$a->page['aside'] .= $vcard_widget;
|
$a->page['aside'] .= $vcard_widget;
|
||||||
$a->page['aside'] .= $cal_widget;
|
$a->page['aside'] .= $cal_widget;
|
||||||
|
@ -72,12 +76,10 @@ function cal_init(App $a) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function cal_content(App $a) {
|
function cal_content(App $a)
|
||||||
|
{
|
||||||
nav_set_selected('events');
|
nav_set_selected('events');
|
||||||
|
|
||||||
// First day of the week (0 = Sunday)
|
|
||||||
$firstDay = PConfig::get(local_user(),'system','first_day_of_week', 0);
|
|
||||||
|
|
||||||
// get the translation strings for the callendar
|
// get the translation strings for the callendar
|
||||||
$i18n = get_event_strings();
|
$i18n = get_event_strings();
|
||||||
|
|
||||||
|
@ -101,25 +103,20 @@ function cal_content(App $a) {
|
||||||
$m = 0;
|
$m = 0;
|
||||||
$ignored = ((x($_REQUEST, 'ignored')) ? intval($_REQUEST['ignored']) : 0);
|
$ignored = ((x($_REQUEST, 'ignored')) ? intval($_REQUEST['ignored']) : 0);
|
||||||
|
|
||||||
if($a->argc == 4) {
|
$format = 'ical';
|
||||||
if($a->argv[2] == 'export') {
|
if ($a->argc == 4 && $a->argv[2] == 'export') {
|
||||||
$mode = 'export';
|
$mode = 'export';
|
||||||
$format = $a->argv[3];
|
$format = $a->argv[3];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Setup permissions structures
|
// Setup permissions structures
|
||||||
//
|
|
||||||
|
|
||||||
$contact = null;
|
|
||||||
$remote_contact = false;
|
$remote_contact = false;
|
||||||
$contact_id = 0;
|
$contact_id = 0;
|
||||||
|
|
||||||
$owner_uid = $a->data['user']['uid'];
|
$owner_uid = $a->data['user']['uid'];
|
||||||
$nick = $a->data['user']['nickname'];
|
$nick = $a->data['user']['nickname'];
|
||||||
|
|
||||||
if(is_array($_SESSION['remote'])) {
|
if (x($_SESSION, 'remote') && is_array($_SESSION['remote'])) {
|
||||||
foreach ($_SESSION['remote'] as $v) {
|
foreach ($_SESSION['remote'] as $v) {
|
||||||
if ($v['uid'] == $a->profile['profile_uid']) {
|
if ($v['uid'] == $a->profile['profile_uid']) {
|
||||||
$contact_id = $v['cid'];
|
$contact_id = $v['cid'];
|
||||||
|
@ -127,6 +124,8 @@ function cal_content(App $a) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$groups = [];
|
||||||
if ($contact_id) {
|
if ($contact_id) {
|
||||||
$groups = Group::getIdsByContactId($contact_id);
|
$groups = Group::getIdsByContactId($contact_id);
|
||||||
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||||
|
@ -134,17 +133,11 @@ function cal_content(App $a) {
|
||||||
intval($a->profile['profile_uid'])
|
intval($a->profile['profile_uid'])
|
||||||
);
|
);
|
||||||
if (DBM::is_result($r)) {
|
if (DBM::is_result($r)) {
|
||||||
$contact = $r[0];
|
|
||||||
$remote_contact = true;
|
$remote_contact = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(! $remote_contact) {
|
|
||||||
if(local_user()) {
|
$is_owner = local_user() == $a->profile['profile_uid'];
|
||||||
$contact_id = $_SESSION['cid'];
|
|
||||||
$contact = $a->contact;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$is_owner = ((local_user()) && (local_user() == $a->profile['profile_uid']) ? true : false);
|
|
||||||
|
|
||||||
if ($a->profile['hidewall'] && (!$is_owner) && (!$remote_contact)) {
|
if ($a->profile['hidewall'] && (!$is_owner) && (!$remote_contact)) {
|
||||||
notice(t('Access to this profile has been restricted.') . EOL);
|
notice(t('Access to this profile has been restricted.') . EOL);
|
||||||
|
@ -157,26 +150,30 @@ function cal_content(App $a) {
|
||||||
$sql_extra = " AND `event`.`cid` = 0 " . $sql_perms;
|
$sql_extra = " AND `event`.`cid` = 0 " . $sql_perms;
|
||||||
|
|
||||||
// get the tab navigation bar
|
// get the tab navigation bar
|
||||||
$tabs .= profile_tabs($a,false, $a->data['user']['nickname']);
|
$tabs = profile_tabs($a, false, $a->data['user']['nickname']);
|
||||||
|
|
||||||
// The view mode part is similiar to /mod/events.php
|
// The view mode part is similiar to /mod/events.php
|
||||||
if ($mode == 'view') {
|
if ($mode == 'view') {
|
||||||
|
|
||||||
|
|
||||||
$thisyear = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y');
|
$thisyear = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y');
|
||||||
$thismonth = datetime_convert('UTC', date_default_timezone_get(), 'now', 'm');
|
$thismonth = datetime_convert('UTC', date_default_timezone_get(), 'now', 'm');
|
||||||
if(! $y)
|
if (!$y) {
|
||||||
$y = intval($thisyear);
|
$y = intval($thisyear);
|
||||||
if(! $m)
|
}
|
||||||
|
|
||||||
|
if (!$m) {
|
||||||
$m = intval($thismonth);
|
$m = intval($thismonth);
|
||||||
|
}
|
||||||
|
|
||||||
// Put some limits on dates. The PHP date functions don't seem to do so well before 1900.
|
// Put some limits on dates. The PHP date functions don't seem to do so well before 1900.
|
||||||
// An upper limit was chosen to keep search engines from exploring links millions of years in the future.
|
// An upper limit was chosen to keep search engines from exploring links millions of years in the future.
|
||||||
|
|
||||||
if($y < 1901)
|
if ($y < 1901) {
|
||||||
$y = 1900;
|
$y = 1900;
|
||||||
if($y > 2099)
|
}
|
||||||
|
|
||||||
|
if ($y > 2099) {
|
||||||
$y = 2100;
|
$y = 2100;
|
||||||
|
}
|
||||||
|
|
||||||
$nextyear = $y;
|
$nextyear = $y;
|
||||||
$nextmonth = $m + 1;
|
$nextmonth = $m + 1;
|
||||||
|
@ -186,9 +183,9 @@ function cal_content(App $a) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$prevyear = $y;
|
$prevyear = $y;
|
||||||
if($m > 1)
|
if ($m > 1) {
|
||||||
$prevmonth = $m - 1;
|
$prevmonth = $m - 1;
|
||||||
else {
|
} else {
|
||||||
$prevmonth = 12;
|
$prevmonth = 12;
|
||||||
$prevyear --;
|
$prevyear --;
|
||||||
}
|
}
|
||||||
|
@ -199,8 +196,13 @@ function cal_content(App $a) {
|
||||||
|
|
||||||
|
|
||||||
if ($a->argv[2] === 'json') {
|
if ($a->argv[2] === 'json') {
|
||||||
if (x($_GET,'start')) $start = $_GET['start'];
|
if (x($_GET, 'start')) {
|
||||||
if (x($_GET,'end')) $finish = $_GET['end'];
|
$start = $_GET['start'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x($_GET, 'end')) {
|
||||||
|
$finish = $_GET['end'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$start = datetime_convert('UTC', 'UTC', $start);
|
$start = datetime_convert('UTC', 'UTC', $start);
|
||||||
|
@ -238,16 +240,12 @@ function cal_content(App $a) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$events=array();
|
|
||||||
|
|
||||||
// transform the event in a usable array
|
// transform the event in a usable array
|
||||||
if (DBM::is_result($r))
|
|
||||||
$r = sort_by_date($r);
|
|
||||||
$events = process_events($r);
|
$events = process_events($r);
|
||||||
|
|
||||||
if ($a->argv[2] === 'json') {
|
if ($a->argv[2] === 'json') {
|
||||||
echo json_encode($events); killme();
|
echo json_encode($events);
|
||||||
|
killme();
|
||||||
}
|
}
|
||||||
|
|
||||||
// links: array('href', 'text', 'extra css classes', 'title')
|
// links: array('href', 'text', 'extra css classes', 'title')
|
||||||
|
@ -279,9 +277,7 @@ function cal_content(App $a) {
|
||||||
'$previous' => array(System::baseUrl() . "/events/$prevyear/$prevmonth", t('Previous'), '', ''),
|
'$previous' => array(System::baseUrl() . "/events/$prevyear/$prevmonth", t('Previous'), '', ''),
|
||||||
'$next' => array(System::baseUrl() . "/events/$nextyear/$nextmonth", t('Next'), '', ''),
|
'$next' => array(System::baseUrl() . "/events/$nextyear/$nextmonth", t('Next'), '', ''),
|
||||||
'$calendar' => cal($y, $m, $links, ' eventcal'),
|
'$calendar' => cal($y, $m, $links, ' eventcal'),
|
||||||
|
|
||||||
'$events' => $events,
|
'$events' => $events,
|
||||||
|
|
||||||
"today" => t("today"),
|
"today" => t("today"),
|
||||||
"month" => t("month"),
|
"month" => t("month"),
|
||||||
"week" => t("week"),
|
"week" => t("week"),
|
||||||
|
@ -289,7 +285,10 @@ function cal_content(App $a) {
|
||||||
"list" => t("list"),
|
"list" => t("list"),
|
||||||
));
|
));
|
||||||
|
|
||||||
if (x($_GET,'id')){ echo $o; killme(); }
|
if (x($_GET, 'id')) {
|
||||||
|
echo $o;
|
||||||
|
killme();
|
||||||
|
}
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
@ -311,17 +310,19 @@ function cal_content(App $a) {
|
||||||
$evexport = event_export($owner_uid, $format);
|
$evexport = event_export($owner_uid, $format);
|
||||||
|
|
||||||
if (!$evexport["success"]) {
|
if (!$evexport["success"]) {
|
||||||
if($evexport["content"])
|
if ($evexport["content"]) {
|
||||||
notice(t('This calendar format is not supported'));
|
notice(t('This calendar format is not supported'));
|
||||||
else
|
} else {
|
||||||
notice(t('No exportable data found'));
|
notice(t('No exportable data found'));
|
||||||
|
}
|
||||||
|
|
||||||
// If it the own calendar return to the events page
|
// If it the own calendar return to the events page
|
||||||
// otherwise to the profile calendar page
|
// otherwise to the profile calendar page
|
||||||
if (local_user() === intval($owner_uid))
|
if (local_user() === intval($owner_uid)) {
|
||||||
$return_path = "events";
|
$return_path = "events";
|
||||||
else
|
} else {
|
||||||
$returnpath = "cal/".$nick;
|
$return_path = "cal/" . $nick;
|
||||||
|
}
|
||||||
|
|
||||||
goaway($return_path);
|
goaway($return_path);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file include/common.php
|
* @file include/common.php
|
||||||
*/
|
*/
|
||||||
|
@ -10,8 +11,8 @@ use Friendica\Model\GContact;
|
||||||
require_once 'include/contact_selectors.php';
|
require_once 'include/contact_selectors.php';
|
||||||
require_once 'mod/contacts.php';
|
require_once 'mod/contacts.php';
|
||||||
|
|
||||||
function common_content(App $a) {
|
function common_content(App $a)
|
||||||
|
{
|
||||||
$o = '';
|
$o = '';
|
||||||
|
|
||||||
$cmd = $a->argv[1];
|
$cmd = $a->argv[1];
|
||||||
|
@ -45,8 +46,7 @@ function common_content(App $a) {
|
||||||
intval($uid)
|
intval($uid)
|
||||||
);
|
);
|
||||||
/// @TODO Handle $c with DBM::is_result()
|
/// @TODO Handle $c with DBM::is_result()
|
||||||
|
$vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"), array(
|
||||||
$vcard_widget .= replace_macros(get_markup_template("vcard-widget.tpl"),array(
|
|
||||||
'$name' => htmlentities($c[0]['name']),
|
'$name' => htmlentities($c[0]['name']),
|
||||||
'$photo' => $c[0]['photo'],
|
'$photo' => $c[0]['photo'],
|
||||||
'url' => 'contacts/' . $cid
|
'url' => 'contacts/' . $cid
|
||||||
|
@ -62,19 +62,19 @@ function common_content(App $a) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(! $cid) {
|
if (!$cid && get_my_url()) {
|
||||||
if(get_my_url()) {
|
/// @todo : Initialize $profile_uid
|
||||||
$r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1",
|
$r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1",
|
||||||
dbesc(normalise_link(get_my_url())),
|
dbesc(normalise_link(get_my_url())),
|
||||||
intval($profile_uid)
|
intval($profile_uid)
|
||||||
);
|
);
|
||||||
if (DBM::is_result($r))
|
if (DBM::is_result($r)) {
|
||||||
$cid = $r[0]['id'];
|
$cid = $r[0]['id'];
|
||||||
else {
|
} else {
|
||||||
$r = q("SELECT `id` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
|
$r = q("SELECT `id` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
|
||||||
dbesc(normalise_link(get_my_url()))
|
dbesc(normalise_link(get_my_url()))
|
||||||
);
|
);
|
||||||
if (DBM::is_result($r))
|
if (DBM::is_result($r)) {
|
||||||
$zcid = $r[0]['id'];
|
$zcid = $r[0]['id'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,29 +90,27 @@ function common_content(App $a) {
|
||||||
$t = GContact::countCommonFriendsZcid($uid, $zcid);
|
$t = GContact::countCommonFriendsZcid($uid, $zcid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($t)) {
|
if ($t > 0) {
|
||||||
$a->set_pager_total($t);
|
$a->set_pager_total($t);
|
||||||
} else {
|
} else {
|
||||||
notice(t('No contacts in common.') . EOL);
|
notice(t('No contacts in common.') . EOL);
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($cid) {
|
if ($cid) {
|
||||||
$r = GContact::commonFriends($uid, $cid, $a->pager['start'], $a->pager['itemspage']);
|
$r = GContact::commonFriends($uid, $cid, $a->pager['start'], $a->pager['itemspage']);
|
||||||
} else {
|
} else {
|
||||||
$r = GContact::commonFriendsZcid($uid, $zcid, $a->pager['start'], $a->pager['itemspage']);
|
$r = GContact::commonFriendsZcid($uid, $zcid, $a->pager['start'], $a->pager['itemspage']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!DBM::is_result($r)) {
|
if (!DBM::is_result($r)) {
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = 0;
|
$id = 0;
|
||||||
|
|
||||||
|
$entries = [];
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
|
|
||||||
//get further details of the contact
|
//get further details of the contact
|
||||||
$contact_details = Contact::getDetailsByURL($rr['url'], $uid);
|
$contact_details = Contact::getDetailsByURL($rr['url'], $uid);
|
||||||
|
|
||||||
|
@ -120,12 +118,11 @@ function common_content(App $a) {
|
||||||
/// @TODO Adding '/" here avoids E_NOTICE on missing constants
|
/// @TODO Adding '/" here avoids E_NOTICE on missing constants
|
||||||
$rr['id'] = $rr['cid'];
|
$rr['id'] = $rr['cid'];
|
||||||
|
|
||||||
$photo_menu = '';
|
|
||||||
$photo_menu = Contact::photoMenu($rr);
|
$photo_menu = Contact::photoMenu($rr);
|
||||||
|
|
||||||
$entry = array(
|
$entry = array(
|
||||||
'url' => $rr['url'],
|
'url' => $rr['url'],
|
||||||
'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
|
'itemurl' => defaults($contact_details, 'addr', $rr['url']),
|
||||||
'name' => $contact_details['name'],
|
'name' => $contact_details['name'],
|
||||||
'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB),
|
'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB),
|
||||||
'img_hover' => htmlentities($contact_details['name']),
|
'img_hover' => htmlentities($contact_details['name']),
|
||||||
|
@ -140,7 +137,9 @@ function common_content(App $a) {
|
||||||
$entries[] = $entry;
|
$entries[] = $entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cmd === 'loc' && $cid && $uid == local_user()) {
|
$title = '';
|
||||||
|
$tab_str = '';
|
||||||
|
if ($cmd === 'loc' && $cid && local_user() == $uid) {
|
||||||
$tab_str = contacts_tab($a, $cid, 4);
|
$tab_str = contacts_tab($a, $cid, 4);
|
||||||
} else {
|
} else {
|
||||||
$title = t('Common Friends');
|
$title = t('Common Friends');
|
||||||
|
|
|
@ -5,14 +5,16 @@ use Friendica\Core\Config;
|
||||||
use Friendica\Core\PConfig;
|
use Friendica\Core\PConfig;
|
||||||
use Friendica\Database\DBM;
|
use Friendica\Database\DBM;
|
||||||
|
|
||||||
function community_init(App $a) {
|
function community_init(App $a)
|
||||||
|
{
|
||||||
if (!local_user()) {
|
if (!local_user()) {
|
||||||
unset($_SESSION['theme']);
|
unset($_SESSION['theme']);
|
||||||
unset($_SESSION['mobile-theme']);
|
unset($_SESSION['mobile-theme']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function community_content(App $a, $update = 0) {
|
function community_content(App $a, $update = 0)
|
||||||
|
{
|
||||||
$o = '';
|
$o = '';
|
||||||
|
|
||||||
if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
|
if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
|
||||||
|
@ -60,21 +62,25 @@ function community_content(App $a, $update = 0) {
|
||||||
$tabs = [];
|
$tabs = [];
|
||||||
|
|
||||||
if (local_user() || in_array($page_style, [CP_USERS_AND_GLOBAL, CP_USERS_ON_SERVER])) {
|
if (local_user() || in_array($page_style, [CP_USERS_AND_GLOBAL, CP_USERS_ON_SERVER])) {
|
||||||
$tabs[] = array('label'=>t('Community'),
|
$tabs[] = array(
|
||||||
|
'label' => t('Community'),
|
||||||
'url' => 'community/local',
|
'url' => 'community/local',
|
||||||
'sel' => $content == 'local' ? 'active' : '',
|
'sel' => $content == 'local' ? 'active' : '',
|
||||||
'title' => t('Posts from local users on this server'),
|
'title' => t('Posts from local users on this server'),
|
||||||
'id' => 'community-local-tab',
|
'id' => 'community-local-tab',
|
||||||
'accesskey' => 'l');
|
'accesskey' => 'l'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (local_user() || in_array($page_style, [CP_USERS_AND_GLOBAL, CP_GLOBAL_COMMUNITY])) {
|
if (local_user() || in_array($page_style, [CP_USERS_AND_GLOBAL, CP_GLOBAL_COMMUNITY])) {
|
||||||
$tabs[] = array('label' => t('Global Timeline'),
|
$tabs[] = array(
|
||||||
|
'label' => t('Global Timeline'),
|
||||||
'url' => 'community/global',
|
'url' => 'community/global',
|
||||||
'sel' => $content == 'global' ? 'active' : '',
|
'sel' => $content == 'global' ? 'active' : '',
|
||||||
'title' => t('Posts from users of the federated network'),
|
'title' => t('Posts from users of the federated network'),
|
||||||
'id' => 'community-global-tab',
|
'id' => 'community-global-tab',
|
||||||
'accesskey' => 'g');
|
'accesskey' => 'g'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$tab_tpl = get_markup_template('common_tabs.tpl');
|
$tab_tpl = get_markup_template('common_tabs.tpl');
|
||||||
|
@ -108,7 +114,7 @@ function community_content(App $a, $update = 0) {
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
$maxpostperauthor = Config::get('system','max_author_posts_community_page');
|
$maxpostperauthor = (int) Config::get('system', 'max_author_posts_community_page');
|
||||||
|
|
||||||
if (($maxpostperauthor != 0) && ($content == 'local')) {
|
if (($maxpostperauthor != 0) && ($content == 'local')) {
|
||||||
$count = 1;
|
$count = 1;
|
||||||
|
@ -117,7 +123,7 @@ function community_content(App $a, $update = 0) {
|
||||||
$s = array();
|
$s = array();
|
||||||
|
|
||||||
do {
|
do {
|
||||||
foreach ($r AS $row=>$item) {
|
foreach ($r as $item) {
|
||||||
if ($previousauthor == $item["author-link"]) {
|
if ($previousauthor == $item["author-link"]) {
|
||||||
++$numposts;
|
++$numposts;
|
||||||
} else {
|
} else {
|
||||||
|
@ -125,14 +131,14 @@ function community_content(App $a, $update = 0) {
|
||||||
}
|
}
|
||||||
$previousauthor = $item["author-link"];
|
$previousauthor = $item["author-link"];
|
||||||
|
|
||||||
if (($numposts < $maxpostperauthor) && (sizeof($s) < $a->pager['itemspage'])) {
|
if (($numposts < $maxpostperauthor) && (count($s) < $a->pager['itemspage'])) {
|
||||||
$s[] = $item;
|
$s[] = $item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sizeof($s) < $a->pager['itemspage']) {
|
if (count($s) < $a->pager['itemspage']) {
|
||||||
$r = community_getitems($a->pager['start'] + ($count * $a->pager['itemspage']), $a->pager['itemspage'], $content);
|
$r = community_getitems($a->pager['start'] + ($count * $a->pager['itemspage']), $a->pager['itemspage'], $content);
|
||||||
}
|
}
|
||||||
} while ((sizeof($s) < $a->pager['itemspage']) && (++$count < 50) && (sizeof($r) > 0));
|
} while ((count($s) < $a->pager['itemspage']) && ( ++$count < 50) && (count($r) > 0));
|
||||||
} else {
|
} else {
|
||||||
$s = $r;
|
$s = $r;
|
||||||
}
|
}
|
||||||
|
@ -152,7 +158,8 @@ function community_content(App $a, $update = 0) {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
function community_getitems($start, $itemspage, $content) {
|
function community_getitems($start, $itemspage, $content)
|
||||||
|
{
|
||||||
if ($content == 'local') {
|
if ($content == 'local') {
|
||||||
$r = dba::p("SELECT " . item_fieldlists() . " FROM `thread`
|
$r = dba::p("SELECT " . item_fieldlists() . " FROM `thread`
|
||||||
INNER JOIN `user` ON `user`.`uid` = `thread`.`uid` AND NOT `user`.`hidewall`
|
INNER JOIN `user` ON `user`.`uid` = `thread`.`uid` AND NOT `user`.`hidewall`
|
||||||
|
|
|
@ -11,6 +11,7 @@ function contactgroup_content(App $a)
|
||||||
killme();
|
killme();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$change = null;
|
||||||
if (($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) {
|
if (($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) {
|
||||||
$r = q("SELECT `id` FROM `contact` WHERE `id` = %d AND `uid` = %d and `self` = 0 and `blocked` = 0 AND `pending` = 0 LIMIT 1",
|
$r = q("SELECT `id` FROM `contact` WHERE `id` = %d AND `uid` = %d and `self` = 0 and `blocked` = 0 AND `pending` = 0 LIMIT 1",
|
||||||
intval($a->argv[2]),
|
intval($a->argv[2]),
|
||||||
|
|
|
@ -60,6 +60,7 @@ class App {
|
||||||
public $timezone;
|
public $timezone;
|
||||||
public $interactive = true;
|
public $interactive = true;
|
||||||
public $plugins;
|
public $plugins;
|
||||||
|
public $plugins_admin = array();
|
||||||
public $apps = array();
|
public $apps = array();
|
||||||
public $identities;
|
public $identities;
|
||||||
public $is_mobile = false;
|
public $is_mobile = false;
|
||||||
|
|
|
@ -130,7 +130,7 @@ class Config
|
||||||
*
|
*
|
||||||
* @param string $family The category of the configuration value
|
* @param string $family The category of the configuration value
|
||||||
* @param string $key The configuration key to set
|
* @param string $key The configuration key to set
|
||||||
* @param string $value The value to store
|
* @param mixed $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
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -186,13 +186,22 @@ class DBStructure {
|
||||||
return t('Errors encountered performing database changes: ').$message.EOL;
|
return t('Errors encountered performing database changes: ').$message.EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function update($verbose, $action, $tables = null, $definition = null) {
|
/**
|
||||||
|
* Updates DB structure and returns eventual errors messages
|
||||||
|
*
|
||||||
|
* @param bool $verbose
|
||||||
|
* @param bool $action Whether to actually apply the update
|
||||||
|
* @param array $tables An array of the database tables
|
||||||
|
* @param array $definition An array of the definition tables
|
||||||
|
* @return string Empty string if the update is successful, error messages otherwise
|
||||||
|
*/
|
||||||
|
public static function update($verbose, $action, array $tables = null, array $definition = null) {
|
||||||
if ($action) {
|
if ($action) {
|
||||||
Config::set('system', 'maintenance', 1);
|
Config::set('system', 'maintenance', 1);
|
||||||
Config::set('system', 'maintenance_reason', sprintf(t(': Database update'), DBM::date().' '.date('e')));
|
Config::set('system', 'maintenance_reason', sprintf(t(': Database update'), DBM::date().' '.date('e')));
|
||||||
}
|
}
|
||||||
|
|
||||||
$errors = false;
|
$errors = '';
|
||||||
|
|
||||||
logger('updating structure', LOGGER_DEBUG);
|
logger('updating structure', LOGGER_DEBUG);
|
||||||
|
|
||||||
|
|
|
@ -327,8 +327,8 @@ class GContact
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param object $uid user
|
* @param integer $uid user
|
||||||
* @param object $cid cid
|
* @param integer $cid cid
|
||||||
* @param integer $start optional, default 0
|
* @param integer $start optional, default 0
|
||||||
* @param integer $limit optional, default 9999
|
* @param integer $limit optional, default 9999
|
||||||
* @param boolean $shuffle optional, default false
|
* @param boolean $shuffle optional, default false
|
||||||
|
@ -365,8 +365,8 @@ class GContact
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param object $uid user
|
* @param integer $uid user
|
||||||
* @param object $zcid zcid
|
* @param integer $zcid zcid
|
||||||
* @param integer $start optional, default 0
|
* @param integer $start optional, default 0
|
||||||
* @param integer $limit optional, default 9999
|
* @param integer $limit optional, default 9999
|
||||||
* @param boolean $shuffle optional, default false
|
* @param boolean $shuffle optional, default false
|
||||||
|
@ -397,8 +397,8 @@ class GContact
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param object $uid user
|
* @param integer $uid user
|
||||||
* @param object $cid cid
|
* @param integer $cid cid
|
||||||
* @return integer
|
* @return integer
|
||||||
*/
|
*/
|
||||||
public static function countAllFriends($uid, $cid)
|
public static function countAllFriends($uid, $cid)
|
||||||
|
@ -420,11 +420,11 @@ class GContact
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param object $uid user
|
* @param integer $uid user
|
||||||
* @param object $cid cid
|
* @param integer $cid cid
|
||||||
* @param integer $start optional, default 0
|
* @param integer $start optional, default 0
|
||||||
* @param integer $limit optional, default 80
|
* @param integer $limit optional, default 80
|
||||||
* @return object
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function allFriends($uid, $cid, $start = 0, $limit = 80)
|
public static function allFriends($uid, $cid, $start = 0, $limit = 80)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue