Merge pull request #4171 from MrPetovan/task/fix-scrutinizer-issues
[Scrutinizer] Fix issues in mod/ (_well_known to contactgroup)
This commit is contained in:
commit
045a0b2a00
18 changed files with 390 additions and 400 deletions
|
@ -486,18 +486,18 @@ function get_first_dim($y,$m) {
|
|||
* altering td class.
|
||||
* Months count from 1.
|
||||
*
|
||||
* @param int $y Year
|
||||
* @param int $m Month
|
||||
* @param bool $links (default false)
|
||||
* @param int $y Year
|
||||
* @param int $m Month
|
||||
* @param array $links (default null)
|
||||
* @param string $class
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @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.
|
||||
|
||||
$mtab = array(' ',
|
||||
'January', 'February', 'March',
|
||||
'April' , 'May' , 'June',
|
||||
|
@ -505,18 +505,19 @@ function cal($y = 0,$m = 0, $links = false, $class='') {
|
|||
'October', 'November', 'December'
|
||||
);
|
||||
|
||||
$thisyear = datetime_convert('UTC', date_default_timezone_get(), 'now','Y');
|
||||
$thismonth = datetime_convert('UTC', date_default_timezone_get(), 'now','m');
|
||||
if (! $y) {
|
||||
$thisyear = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y');
|
||||
$thismonth = datetime_convert('UTC', date_default_timezone_get(), 'now', 'm');
|
||||
if (!$y) {
|
||||
$y = $thisyear;
|
||||
}
|
||||
if (! $m) {
|
||||
|
||||
if (!$m) {
|
||||
$m = intval($thismonth);
|
||||
}
|
||||
|
||||
$dn = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
|
||||
$f = get_first_dim($y,$m);
|
||||
$l = get_dim($y,$m);
|
||||
$f = get_first_dim($y, $m);
|
||||
$l = get_dim($y, $m);
|
||||
$d = 1;
|
||||
$dow = 0;
|
||||
$started = false;
|
||||
|
@ -543,8 +544,8 @@ function cal($y = 0,$m = 0, $links = false, $class='') {
|
|||
$o .= "<td $today>";
|
||||
$day = str_replace(' ', ' ', sprintf('%2.2d', $d));
|
||||
if ($started) {
|
||||
if (is_array($links) && isset($links[$d])) {
|
||||
$o .= "<a href=\"{$links[$d]}\">$day</a>";
|
||||
if (x($links, $d) !== false) {
|
||||
$o .= "<a href=\"{$links[$d]}\">$day</a>";
|
||||
} else {
|
||||
$o .= $day;
|
||||
}
|
||||
|
@ -567,7 +568,7 @@ function cal($y = 0,$m = 0, $links = false, $class='') {
|
|||
}
|
||||
}
|
||||
|
||||
$o .= '</tr></table>'."\r\n";
|
||||
$o .= '</tr></table>' . "\r\n";
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
|
|
@ -507,10 +507,10 @@ function event_remove_duplicates($dates) {
|
|||
/**
|
||||
* @brief Get an event by its event ID.
|
||||
*
|
||||
* @param type $owner_uid The User ID of the owner of the event
|
||||
* @param type $event_params An assoziative array with
|
||||
* int 'event_id' => The ID of the event in the event table
|
||||
* @param type $sql_extra
|
||||
* @param int $owner_uid The User ID of the owner of the event
|
||||
* @param array $event_params An assoziative array with
|
||||
* int 'event_id' => The ID of the event in the event table
|
||||
* @param string $sql_extra
|
||||
* @return array Query result
|
||||
*/
|
||||
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']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the my_url session variable
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_my_url()
|
||||
{
|
||||
if (x($_SESSION, 'my_url')) {
|
||||
return $_SESSION['my_url'];
|
||||
}
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
function zrl_init(App $a)
|
||||
|
|
|
@ -7,14 +7,15 @@ require_once("mod/hostxrd.php");
|
|||
require_once("mod/nodeinfo.php");
|
||||
require_once("mod/xrd.php");
|
||||
|
||||
function _well_known_init(App $a) {
|
||||
function _well_known_init(App $a)
|
||||
{
|
||||
if ($a->argc > 1) {
|
||||
switch($a->argv[1]) {
|
||||
switch ($a->argv[1]) {
|
||||
case "host-meta":
|
||||
hostxrd_init($a);
|
||||
break;
|
||||
case "x-social-relay":
|
||||
wk_social_relay($a);
|
||||
wk_social_relay();
|
||||
break;
|
||||
case "nodeinfo":
|
||||
nodeinfo_wellknown($a);
|
||||
|
@ -28,9 +29,9 @@ function _well_known_init(App $a) {
|
|||
killme();
|
||||
}
|
||||
|
||||
function wk_social_relay(App $a) {
|
||||
|
||||
$subscribe = (bool)Config::get('system', 'relay_subscribe', false);
|
||||
function wk_social_relay()
|
||||
{
|
||||
$subscribe = (bool) Config::get('system', 'relay_subscribe', false);
|
||||
|
||||
if ($subscribe) {
|
||||
$scope = Config::get('system', 'relay_scope', SR_SCOPE_ALL);
|
||||
|
@ -44,14 +45,14 @@ function wk_social_relay(App $a) {
|
|||
$server_tags = Config::get('system', 'relay_server_tags');
|
||||
$tagitems = explode(",", $server_tags);
|
||||
|
||||
foreach($tagitems AS $tag) {
|
||||
foreach ($tagitems AS $tag) {
|
||||
$tags[trim($tag, "# ")] = trim($tag, "# ");
|
||||
}
|
||||
|
||||
if (Config::get('system', 'relay_user_tags')) {
|
||||
$terms = q("SELECT DISTINCT(`term`) FROM `search`");
|
||||
|
||||
foreach($terms AS $term) {
|
||||
foreach ($terms AS $term) {
|
||||
$tag = trim($term["term"], "#");
|
||||
$tags[$tag] = $tag;
|
||||
}
|
||||
|
@ -59,15 +60,17 @@ function wk_social_relay(App $a) {
|
|||
}
|
||||
|
||||
$taglist = array();
|
||||
foreach($tags AS $tag) {
|
||||
foreach ($tags AS $tag) {
|
||||
$taglist[] = $tag;
|
||||
}
|
||||
|
||||
$relay = array("subscribe" => $subscribe,
|
||||
"scope" => $scope,
|
||||
"tags" => $taglist);
|
||||
$relay = array(
|
||||
"subscribe" => $subscribe,
|
||||
"scope" => $scope,
|
||||
"tags" => $taglist
|
||||
);
|
||||
|
||||
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);
|
||||
exit;
|
||||
}
|
||||
|
|
|
@ -3,13 +3,12 @@
|
|||
use Friendica\App;
|
||||
use Friendica\Network\Probe;
|
||||
|
||||
function acctlink_init(App $a) {
|
||||
|
||||
if(x($_GET,'addr')) {
|
||||
function acctlink_init()
|
||||
{
|
||||
if (x($_GET, 'addr')) {
|
||||
$addr = trim($_GET['addr']);
|
||||
$res = Probe::uri($addr);
|
||||
//logger('acctlink: ' . print_r($res,true));
|
||||
if($res['url']) {
|
||||
if ($res['url']) {
|
||||
goaway($res['url']);
|
||||
killme();
|
||||
}
|
||||
|
|
227
mod/admin.php
227
mod/admin.php
|
@ -44,7 +44,7 @@ function admin_post(App $a)
|
|||
return;
|
||||
}
|
||||
|
||||
// urls
|
||||
$return_path = 'admin';
|
||||
if ($a->argc > 1) {
|
||||
switch ($a->argv[1]) {
|
||||
case 'site':
|
||||
|
@ -62,8 +62,7 @@ function admin_post(App $a)
|
|||
$func($a);
|
||||
}
|
||||
}
|
||||
goaway('admin/plugins/' . $a->argv[2]);
|
||||
return; // NOTREACHED
|
||||
$return_path = 'admin/plugins/' . $a->argv[2];
|
||||
break;
|
||||
case 'themes':
|
||||
if ($a->argc < 2) {
|
||||
|
@ -76,38 +75,31 @@ function admin_post(App $a)
|
|||
|
||||
$theme = $a->argv[2];
|
||||
if (is_file("view/theme/$theme/config.php")) {
|
||||
$orig_theme = $a->theme;
|
||||
$orig_page = $a->page;
|
||||
$orig_session_theme = $_SESSION['theme'];
|
||||
require_once "view/theme/$theme/theme.php";
|
||||
require_once "view/theme/$theme/config.php";
|
||||
$_SESSION['theme'] = $theme;
|
||||
|
||||
function __call_theme_admin_post(App $a, $theme)
|
||||
{
|
||||
$orig_theme = $a->theme;
|
||||
$orig_page = $a->page;
|
||||
$orig_session_theme = $_SESSION['theme'];
|
||||
require_once("view/theme/$theme/theme.php");
|
||||
require_once("view/theme/$theme/config.php");
|
||||
$_SESSION['theme'] = $theme;
|
||||
|
||||
|
||||
$init = $theme . "_init";
|
||||
if (function_exists($init)) {
|
||||
$init($a);
|
||||
}
|
||||
if (function_exists("theme_admin_post")) {
|
||||
$admin_form = theme_admin_post($a);
|
||||
}
|
||||
|
||||
$_SESSION['theme'] = $orig_session_theme;
|
||||
$a->theme = $orig_theme;
|
||||
$a->page = $orig_page;
|
||||
return $admin_form;
|
||||
$init = $theme . '_init';
|
||||
if (function_exists($init)) {
|
||||
$init($a);
|
||||
}
|
||||
__call_theme_admin_post($a, $theme);
|
||||
if (function_exists('theme_admin_post')) {
|
||||
theme_admin_post($a);
|
||||
}
|
||||
|
||||
$_SESSION['theme'] = $orig_session_theme;
|
||||
$a->theme = $orig_theme;
|
||||
$a->page = $orig_page;
|
||||
}
|
||||
|
||||
info(t('Theme settings updated.'));
|
||||
if (is_ajax()) {
|
||||
return;
|
||||
}
|
||||
goaway('admin/themes/' . $theme);
|
||||
return;
|
||||
$return_path = 'admin/themes/' . $theme;
|
||||
break;
|
||||
case 'features':
|
||||
admin_page_features_post($a);
|
||||
|
@ -115,9 +107,6 @@ function admin_post(App $a)
|
|||
case 'logs':
|
||||
admin_page_logs_post($a);
|
||||
break;
|
||||
case 'dbsync':
|
||||
admin_page_dbsync_post($a);
|
||||
break;
|
||||
case 'contactblock':
|
||||
admin_page_contactblock_post($a);
|
||||
break;
|
||||
|
@ -130,7 +119,7 @@ function admin_post(App $a)
|
|||
}
|
||||
}
|
||||
|
||||
goaway('admin');
|
||||
goaway($return_path);
|
||||
return; // NOTREACHED
|
||||
}
|
||||
|
||||
|
@ -652,7 +641,7 @@ function admin_page_federation(App $a)
|
|||
'$autoactive' => Config::get('system', 'poco_completion'),
|
||||
'$counts' => $counts,
|
||||
'$version' => FRIENDICA_VERSION,
|
||||
'$legendtext' => sprintf(t('Currently this node is aware of %d nodes with %d registered users from the following platforms:'), $total, $users),
|
||||
'$legendtext' => t('Currently this node is aware of %d nodes with %d registered users from the following platforms:', $total, $users),
|
||||
'$baseurl' => System::baseUrl(),
|
||||
));
|
||||
}
|
||||
|
@ -682,7 +671,7 @@ function admin_page_queue(App $a)
|
|||
return replace_macros($t, array(
|
||||
'$title' => t('Administration'),
|
||||
'$page' => t('Inspect Queue'),
|
||||
'$count' => sizeof($r),
|
||||
'$count' => count($r),
|
||||
'id_header' => t('ID'),
|
||||
'$to_header' => t('Recipient Name'),
|
||||
'$url_header' => t('Recipient Profile'),
|
||||
|
@ -713,14 +702,14 @@ function admin_page_summary(App $a)
|
|||
$warningtext = array();
|
||||
if (DBM::is_result($r)) {
|
||||
$showwarning = true;
|
||||
$warningtext[] = sprintf(t('Your DB still runs with MyISAM tables. You should change the engine type to InnoDB. As Friendica will use InnoDB only features in the future, you should change this! See <a href="%s">here</a> for a guide that may be helpful converting the table engines. You may also use the command <tt>php scripts/dbstructure.php toinnodb</tt> of your Friendica installation for an automatic conversion.<br />'), 'https://dev.mysql.com/doc/refman/5.7/en/converting-tables-to-innodb.html');
|
||||
$warningtext[] = t('Your DB still runs with MyISAM tables. You should change the engine type to InnoDB. As Friendica will use InnoDB only features in the future, you should change this! See <a href="%s">here</a> for a guide that may be helpful converting the table engines. You may also use the command <tt>php scripts/dbstructure.php toinnodb</tt> of your Friendica installation for an automatic conversion.<br />', 'https://dev.mysql.com/doc/refman/5.7/en/converting-tables-to-innodb.html');
|
||||
}
|
||||
// Check if github.com/friendica/master/VERSION is higher then
|
||||
// the local version of Friendica. Check is opt-in, source may be master or devel branch
|
||||
if (Config::get('system', 'check_new_version_url', 'none') != 'none') {
|
||||
$gitversion = Config::get('system', 'git_friendica_version');
|
||||
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[] = 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;
|
||||
}
|
||||
}
|
||||
|
@ -739,7 +728,7 @@ function admin_page_summary(App $a)
|
|||
$warningtext[] = t('The worker was never executed. Please check your database structure!');
|
||||
} elseif ((strtotime(datetime_convert()) - strtotime($last_worker_call)) > 60 * 60) {
|
||||
$showwarning = true;
|
||||
$warningtext[] = sprintf(t('The last worker execution was on %s UTC. This is older than one hour. Please check your crontab settings.'), $last_worker_call);
|
||||
$warningtext[] = t('The last worker execution was on %s UTC. This is older than one hour. Please check your crontab settings.', $last_worker_call);
|
||||
}
|
||||
|
||||
$r = q("SELECT `page-flags`, COUNT(`uid`) AS `count` FROM `user` GROUP BY `page-flags`");
|
||||
|
@ -817,7 +806,7 @@ function admin_page_site_post(App $a)
|
|||
$new_url = rtrim($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>"));
|
||||
goaway('admin/site');
|
||||
}
|
||||
|
@ -847,11 +836,8 @@ function admin_page_site_post(App $a)
|
|||
|
||||
$upds = implode(", ", $upd);
|
||||
|
||||
|
||||
|
||||
$q = sprintf("UPDATE %s SET %s;", $table_name, $upds);
|
||||
$r = q($q);
|
||||
if (!$r) {
|
||||
$r = q("UPDATE %s SET %s;", $table_name, $upds);
|
||||
if (!DBM::is_result($r)) {
|
||||
notice("Failed updating '$table_name': " . dba::errorMessage());
|
||||
goaway('admin/site');
|
||||
}
|
||||
|
@ -1151,8 +1137,7 @@ function admin_page_site(App $a)
|
|||
$theme_choices_mobile = array();
|
||||
$theme_choices_mobile["---"] = t("No special theme for mobile devices");
|
||||
$files = glob('view/theme/*');
|
||||
if ($files) {
|
||||
|
||||
if (is_array($files)) {
|
||||
$allowed_theme_list = Config::get('system', 'allowed_themes');
|
||||
|
||||
foreach ($files as $file) {
|
||||
|
@ -1185,16 +1170,6 @@ function admin_page_site(App $a)
|
|||
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(
|
||||
"0" => t("Disabled"),
|
||||
"1" => t("Users"),
|
||||
|
@ -1288,7 +1263,7 @@ function admin_page_site(App $a)
|
|||
'$banner' => array('banner', t("Banner/Logo"), $banner, ""),
|
||||
'$shortcut_icon' => array('shortcut_icon', t("Shortcut icon"), Config::get('system','shortcut_icon'), t("Link to an icon that will be used for browsers.")),
|
||||
'$touch_icon' => array('touch_icon', t("Touch icon"), Config::get('system','touch_icon'), t("Link to an icon that will be used for tablets and mobiles.")),
|
||||
'$info' => array('info', t('Additional Info'), $info, sprintf(t('For public servers: you can add additional information here that will be listed at %s/servers.'), get_server())),
|
||||
'$info' => array('info', t('Additional Info'), $info, t('For public servers: you can add additional information here that will be listed at %s/servers.', get_server())),
|
||||
'$language' => array('language', t("System language"), Config::get('system','language'), "", $lang_choices),
|
||||
'$theme' => array('theme', t("System theme"), Config::get('system','theme'), t("Default system theme - may be over-ridden by user profiles - <a href='#' id='cnftheme'>change theme settings</a>"), $theme_choices),
|
||||
'$theme_mobile' => array('theme_mobile', t("Mobile system theme"), Config::get('system', 'mobile-theme', '---'), t("Theme for mobile devices"), $theme_choices_mobile),
|
||||
|
@ -1363,7 +1338,7 @@ function admin_page_site(App $a)
|
|||
'$worker_queues' => array('worker_queues', t("Maximum number of parallel workers"), Config::get('system','worker_queues'), t("On shared hosters set this to 2. On larger systems, values of 10 are great. Default value is 4.")),
|
||||
'$worker_dont_fork' => array('worker_dont_fork', t("Don't use 'proc_open' with the worker"), Config::get('system','worker_dont_fork'), t("Enable this if your system doesn't allow the use of 'proc_open'. This can happen on shared hosters. If this is enabled you should increase the frequency of worker calls in your crontab.")),
|
||||
'$worker_fastlane' => array('worker_fastlane', t("Enable fastlane"), Config::get('system','worker_fastlane'), t("When enabed, the fastlane mechanism starts an additional worker if processes with higher priority are blocked by processes of lower priority.")),
|
||||
'$worker_frontend' => array('worker_frontend', t('Enable frontend worker'), Config::get('system','frontend_worker'), sprintf(t('When enabled the Worker process is triggered when backend access is performed (e.g. messages being delivered). On smaller sites you might want to call %s/worker on a regular basis via an external cron job. You should only enable this option if you cannot utilize cron/scheduled jobs on your server.'), System::baseUrl())),
|
||||
'$worker_frontend' => array('worker_frontend', t('Enable frontend worker'), Config::get('system','frontend_worker'), t('When enabled the Worker process is triggered when backend access is performed (e.g. messages being delivered). On smaller sites you might want to call %s/worker on a regular basis via an external cron job. You should only enable this option if you cannot utilize cron/scheduled jobs on your server.', System::baseUrl())),
|
||||
|
||||
'$form_security_token' => get_form_security_token("admin_site")
|
||||
));
|
||||
|
@ -1397,11 +1372,11 @@ function admin_page_dbsync(App $a)
|
|||
|
||||
if (($a->argc > 2) && (intval($a->argv[2]) || ($a->argv[2] === 'check'))) {
|
||||
$retval = DBStructure::update(false, true);
|
||||
if (!$retval) {
|
||||
$o .= sprintf(t("Database structure update %s was successfully applied."), DB_UPDATE_VERSION) . "<br />";
|
||||
if ($retval === '') {
|
||||
$o .= t("Database structure update %s was successfully applied.", DB_UPDATE_VERSION) . "<br />";
|
||||
Config::set('database', 'dbupdate_' . DB_UPDATE_VERSION, 'success');
|
||||
} else {
|
||||
$o .= sprintf(t("Executing of database structure update %s failed with error: %s"), DB_UPDATE_VERSION, $retval) . "<br />";
|
||||
$o .= t("Executing of database structure update %s failed with error: %s", DB_UPDATE_VERSION, $retval) . "<br />";
|
||||
}
|
||||
if ($a->argv[2] === 'check') {
|
||||
return $o;
|
||||
|
@ -1414,15 +1389,15 @@ function admin_page_dbsync(App $a)
|
|||
if (function_exists($func)) {
|
||||
$retval = $func();
|
||||
if ($retval === UPDATE_FAILED) {
|
||||
$o .= sprintf(t("Executing %s failed with error: %s"), $func, $retval);
|
||||
$o .= t("Executing %s failed with error: %s", $func, $retval);
|
||||
} elseif ($retval === UPDATE_SUCCESS) {
|
||||
$o .= sprintf(t('Update %s was successfully applied.', $func));
|
||||
$o .= t('Update %s was successfully applied.', $func);
|
||||
Config::set('database', $func, 'success');
|
||||
} else {
|
||||
$o .= sprintf(t('Update %s did not return a status. Unknown if it succeeded.'), $func);
|
||||
$o .= t('Update %s did not return a status. Unknown if it succeeded.', $func);
|
||||
}
|
||||
} else {
|
||||
$o .= sprintf(t('There was no additional update function %s that needed to be called.'), $func) . "<br />";
|
||||
$o .= t('There was no additional update function %s that needed to be called.', $func) . "<br />";
|
||||
Config::set('database', $func, 'success');
|
||||
}
|
||||
return $o;
|
||||
|
@ -1466,11 +1441,11 @@ function admin_page_dbsync(App $a)
|
|||
*/
|
||||
function admin_page_users_post(App $a)
|
||||
{
|
||||
$pending = (x($_POST, 'pending') ? $_POST['pending'] : array());
|
||||
$users = (x($_POST, 'user') ? $_POST['user'] : array());
|
||||
$nu_name = (x($_POST, 'new_user_name') ? $_POST['new_user_name'] : '');
|
||||
$nu_nickname = (x($_POST, 'new_user_nickname') ? $_POST['new_user_nickname'] : '');
|
||||
$nu_email = (x($_POST, 'new_user_email') ? $_POST['new_user_email'] : '');
|
||||
$pending = defaults($_POST, 'pending' , array());
|
||||
$users = defaults($_POST, 'user' , array());
|
||||
$nu_name = defaults($_POST, 'new_user_name' , '');
|
||||
$nu_nickname = defaults($_POST, 'new_user_nickname', '');
|
||||
$nu_email = defaults($_POST, 'new_user_email' , '');
|
||||
$nu_language = Config::get('system', 'language');
|
||||
|
||||
check_form_security_token_redirectOnErr('/admin/users', 'admin_users');
|
||||
|
@ -1525,7 +1500,7 @@ function admin_page_users_post(App $a)
|
|||
notification(array(
|
||||
'type' => SYSTEM_EMAIL,
|
||||
'to_email' => $user['email'],
|
||||
'subject' => sprintf(t('Registration details for %s'), $a->config['sitename']),
|
||||
'subject' => t('Registration details for %s', $a->config['sitename']),
|
||||
'preamble' => $preamble,
|
||||
'body' => $body));
|
||||
}
|
||||
|
@ -1535,23 +1510,23 @@ function admin_page_users_post(App $a)
|
|||
q("UPDATE `user` SET `blocked` = 1-`blocked` WHERE `uid` = %s", intval($uid)
|
||||
);
|
||||
}
|
||||
notice(sprintf(tt("%s user blocked/unblocked", "%s users blocked/unblocked", count($users)), count($users)));
|
||||
notice(tt("%s user blocked/unblocked", "%s users blocked/unblocked", count($users)));
|
||||
}
|
||||
if (x($_POST, 'page_users_delete')) {
|
||||
foreach ($users as $uid) {
|
||||
User::remove($uid);
|
||||
}
|
||||
notice(sprintf(tt("%s user deleted", "%s users deleted", count($users)), count($users)));
|
||||
notice(tt("%s user deleted", "%s users deleted", count($users)));
|
||||
}
|
||||
|
||||
if (x($_POST, 'page_users_approve')) {
|
||||
require_once("mod/regmod.php");
|
||||
require_once "mod/regmod.php";
|
||||
foreach ($pending as $hash) {
|
||||
user_allow($hash);
|
||||
}
|
||||
}
|
||||
if (x($_POST, 'page_users_deny')) {
|
||||
require_once("mod/regmod.php");
|
||||
require_once "mod/regmod.php";
|
||||
foreach ($pending as $hash) {
|
||||
user_deny($hash);
|
||||
}
|
||||
|
@ -1588,11 +1563,13 @@ function admin_page_users(App $a)
|
|||
// delete user
|
||||
User::remove($uid);
|
||||
|
||||
notice(sprintf(t("User '%s' deleted"), $user[0]['username']) . EOL);
|
||||
notice(t("User '%s' deleted", $user[0]['username']) . EOL);
|
||||
break;
|
||||
case "block":
|
||||
check_form_security_token_redirectOnErr('/admin/users', 'admin_users', 't');
|
||||
q("UPDATE `user` SET `blocked` = %d WHERE `uid` = %s", intval(1 - $user[0]['blocked']), intval($uid)
|
||||
q("UPDATE `user` SET `blocked` = %d WHERE `uid` = %s",
|
||||
intval(1 - $user[0]['blocked']),
|
||||
intval($uid)
|
||||
);
|
||||
notice(sprintf(($user[0]['blocked'] ? t("User '%s' unblocked") : t("User '%s' blocked")), $user[0]['username']) . EOL);
|
||||
break;
|
||||
|
@ -1637,9 +1614,6 @@ function admin_page_users(App $a)
|
|||
if (in_array($new_order, $valid_orders)) {
|
||||
$order = $new_order;
|
||||
}
|
||||
if (x($_GET, 'd')) {
|
||||
$new_direction = $_GET['d'];
|
||||
}
|
||||
}
|
||||
$sql_order = "`" . str_replace('.', '`.`', $order) . "`";
|
||||
$sql_order_direction = ($order_direction === "+") ? "ASC" : "DESC";
|
||||
|
@ -1783,11 +1757,11 @@ function admin_page_plugins(App $a)
|
|||
if ($idx !== false) {
|
||||
unset($a->plugins[$idx]);
|
||||
uninstall_plugin($plugin);
|
||||
info(sprintf(t("Plugin %s disabled."), $plugin));
|
||||
info(t("Plugin %s disabled.", $plugin));
|
||||
} else {
|
||||
$a->plugins[] = $plugin;
|
||||
install_plugin($plugin);
|
||||
info(sprintf(t("Plugin %s enabled."), $plugin));
|
||||
info(t("Plugin %s enabled.", $plugin));
|
||||
}
|
||||
Config::set("system", "addon", implode(", ", $a->plugins));
|
||||
goaway('admin/plugins');
|
||||
|
@ -1795,8 +1769,6 @@ function admin_page_plugins(App $a)
|
|||
}
|
||||
|
||||
// display plugin details
|
||||
require_once('library/markdown.php');
|
||||
|
||||
if (in_array($plugin, $a->plugins)) {
|
||||
$status = "on";
|
||||
$action = t("Disable");
|
||||
|
@ -1807,6 +1779,7 @@ function admin_page_plugins(App $a)
|
|||
|
||||
$readme = Null;
|
||||
if (is_file("addon/$plugin/README.md")) {
|
||||
require_once 'library/markdown.php';
|
||||
$readme = file_get_contents("addon/$plugin/README.md");
|
||||
$readme = Markdown($readme, false);
|
||||
} elseif (is_file("addon/$plugin/README")) {
|
||||
|
@ -1814,7 +1787,7 @@ function admin_page_plugins(App $a)
|
|||
}
|
||||
|
||||
$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");
|
||||
$func = $plugin . '_plugin_admin';
|
||||
$func($a, $admin_form);
|
||||
|
@ -1857,7 +1830,7 @@ function admin_page_plugins(App $a)
|
|||
|
||||
$plugins = array();
|
||||
$files = glob("addon/*/");
|
||||
if ($files) {
|
||||
if (is_array($files)) {
|
||||
foreach ($files as $file) {
|
||||
if (is_dir($file)) {
|
||||
list($tmp, $id) = array_map("trim", explode("/", $file));
|
||||
|
@ -1891,7 +1864,7 @@ function admin_page_plugins(App $a)
|
|||
'$function' => 'plugins',
|
||||
'$plugins' => $plugins,
|
||||
'$pcount' => count($plugins),
|
||||
'$noplugshint' => sprintf(t('There are currently no plugins available on your node. You can find the official plugin repository at %1$s and might find other interesting plugins in the open plugin registry at %2$s'), 'https://github.com/friendica/friendica-addons', 'http://addons.friendi.ca'),
|
||||
'$noplugshint' => t('There are currently no plugins available on your node. You can find the official plugin repository at %1$s and might find other interesting plugins in the open plugin registry at %2$s', 'https://github.com/friendica/friendica-addons', 'http://addons.friendi.ca'),
|
||||
'$form_security_token' => get_form_security_token("admin_themes"),
|
||||
));
|
||||
}
|
||||
|
@ -1903,7 +1876,8 @@ function admin_page_plugins(App $a)
|
|||
*/
|
||||
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]['allowed']) {
|
||||
$themes[$x]['allowed'] = 0;
|
||||
|
@ -1923,7 +1897,8 @@ function toggle_theme(&$themes, $th, &$result)
|
|||
*/
|
||||
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]['allowed']) {
|
||||
return 1;
|
||||
|
@ -1986,7 +1961,7 @@ function admin_page_themes(App $a)
|
|||
|
||||
$themes = array();
|
||||
$files = glob('view/theme/*');
|
||||
if ($files) {
|
||||
if (is_array($files)) {
|
||||
foreach ($files as $file) {
|
||||
$f = basename($file);
|
||||
|
||||
|
@ -2045,8 +2020,6 @@ function admin_page_themes(App $a)
|
|||
}
|
||||
|
||||
// display theme details
|
||||
require_once 'library/markdown.php';
|
||||
|
||||
if (theme_status($themes, $theme)) {
|
||||
$status = "on";
|
||||
$action = t("Disable");
|
||||
|
@ -2055,41 +2028,36 @@ function admin_page_themes(App $a)
|
|||
$action = t("Enable");
|
||||
}
|
||||
|
||||
$readme = Null;
|
||||
$readme = null;
|
||||
if (is_file("view/theme/$theme/README.md")) {
|
||||
require_once 'library/markdown.php';
|
||||
$readme = file_get_contents("view/theme/$theme/README.md");
|
||||
$readme = Markdown($readme, false);
|
||||
} elseif (is_file("view/theme/$theme/README")) {
|
||||
$readme = "<pre>" . file_get_contents("view/theme/$theme/README") . "</pre>";
|
||||
}
|
||||
|
||||
$admin_form = "";
|
||||
$admin_form = '';
|
||||
if (is_file("view/theme/$theme/config.php")) {
|
||||
$orig_theme = $a->theme;
|
||||
$orig_page = $a->page;
|
||||
$orig_session_theme = $_SESSION['theme'];
|
||||
require_once "view/theme/$theme/theme.php";
|
||||
require_once "view/theme/$theme/config.php";
|
||||
$_SESSION['theme'] = $theme;
|
||||
|
||||
function __get_theme_admin_form(App $a, $theme)
|
||||
{
|
||||
$orig_theme = $a->theme;
|
||||
$orig_page = $a->page;
|
||||
$orig_session_theme = $_SESSION['theme'];
|
||||
require_once("view/theme/$theme/theme.php");
|
||||
require_once("view/theme/$theme/config.php");
|
||||
$_SESSION['theme'] = $theme;
|
||||
|
||||
|
||||
$init = $theme . "_init";
|
||||
if (function_exists($init)) {
|
||||
$init($a);
|
||||
}
|
||||
if (function_exists("theme_admin")) {
|
||||
$admin_form = theme_admin($a);
|
||||
}
|
||||
|
||||
$_SESSION['theme'] = $orig_session_theme;
|
||||
$a->theme = $orig_theme;
|
||||
$a->page = $orig_page;
|
||||
return $admin_form;
|
||||
$init = $theme . "_init";
|
||||
if (function_exists($init)) {
|
||||
$init($a);
|
||||
}
|
||||
$admin_form = __get_theme_admin_form($a, $theme);
|
||||
|
||||
if (function_exists('theme_admin')) {
|
||||
$admin_form = theme_admin($a);
|
||||
}
|
||||
|
||||
$_SESSION['theme'] = $orig_session_theme;
|
||||
$a->theme = $orig_theme;
|
||||
$a->page = $orig_page;
|
||||
}
|
||||
|
||||
$screenshot = array(get_theme_screenshot($theme), t('Screenshot'));
|
||||
|
@ -2123,12 +2091,10 @@ function admin_page_themes(App $a)
|
|||
// reload active themes
|
||||
if (x($_GET, "a") && $_GET['a'] == "r") {
|
||||
check_form_security_token_redirectOnErr(System::baseUrl() . '/admin/themes', 'admin_themes', 't');
|
||||
if ($themes) {
|
||||
foreach ($themes as $th) {
|
||||
if ($th['allowed']) {
|
||||
uninstall_theme($th['name']);
|
||||
install_theme($th['name']);
|
||||
}
|
||||
foreach ($themes as $th) {
|
||||
if ($th['allowed']) {
|
||||
uninstall_theme($th['name']);
|
||||
install_theme($th['name']);
|
||||
}
|
||||
}
|
||||
info("Themes reloaded");
|
||||
|
@ -2139,11 +2105,9 @@ function admin_page_themes(App $a)
|
|||
* List themes
|
||||
*/
|
||||
|
||||
$xthemes = array();
|
||||
if ($themes) {
|
||||
foreach ($themes as $th) {
|
||||
$xthemes[] = array($th['name'], (($th['allowed']) ? "on" : "off"), get_theme_info($th['name']));
|
||||
}
|
||||
$plugins = array();
|
||||
foreach ($themes as $th) {
|
||||
$plugins[] = array($th['name'], (($th['allowed']) ? "on" : "off"), get_theme_info($th['name']));
|
||||
}
|
||||
|
||||
$t = get_markup_template('admin/plugins.tpl');
|
||||
|
@ -2154,9 +2118,9 @@ function admin_page_themes(App $a)
|
|||
'$reload' => t('Reload active themes'),
|
||||
'$baseurl' => System::baseUrl(true),
|
||||
'$function' => 'themes',
|
||||
'$plugins' => $xthemes,
|
||||
'$plugins' => $plugins,
|
||||
'$pcount' => count($themes),
|
||||
'$noplugshint' => sprintf(t('No themes found on the system. They should be paced in %1$s'),'<code>/view/themes</code>'),
|
||||
'$noplugshint' => t('No themes found on the system. They should be placed in %1$s', '<code>/view/themes</code>'),
|
||||
'$experimental' => t('[Experimental]'),
|
||||
'$unsupported' => t('[Unsupported]'),
|
||||
'$form_security_token' => get_form_security_token("admin_themes"),
|
||||
|
@ -2307,7 +2271,6 @@ function admin_page_features_post(App $a)
|
|||
|
||||
logger('postvars: ' . print_r($_POST, true), LOGGER_DATA);
|
||||
|
||||
$arr = array();
|
||||
$features = Feature::get(false);
|
||||
|
||||
foreach ($features as $fname => $fdata) {
|
||||
|
@ -2362,13 +2325,13 @@ function admin_page_features(App $a)
|
|||
$set = Config::get('feature', $f[0], $f[3]);
|
||||
$arr[$fname][1][] = array(
|
||||
array('feature_' . $f[0], $f[1], $set, $f[2], array(t('Off'), t('On'))),
|
||||
array('featurelock_' . $f[0], sprintf(t('Lock feature %s'), $f[1]), (($f[4] !== false) ? "1" : ''), '', array(t('Off'), t('On')))
|
||||
array('featurelock_' . $f[0], t('Lock feature %s', $f[1]), (($f[4] !== false) ? "1" : ''), '', array(t('Off'), t('On')))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$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"),
|
||||
'$title' => t('Manage Additional Features'),
|
||||
'$features' => $arr,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file mod/allfriends.php
|
||||
*/
|
||||
|
@ -11,19 +12,20 @@ use Friendica\Model\GContact;
|
|||
require_once 'include/contact_selectors.php';
|
||||
require_once 'mod/contacts.php';
|
||||
|
||||
function allfriends_content(App $a) {
|
||||
|
||||
function allfriends_content(App $a)
|
||||
{
|
||||
$o = '';
|
||||
if (! local_user()) {
|
||||
notice( t('Permission denied.') . EOL);
|
||||
if (!local_user()) {
|
||||
notice(t('Permission denied.') . EOL);
|
||||
return;
|
||||
}
|
||||
|
||||
$cid = 0;
|
||||
if ($a->argc > 1) {
|
||||
$cid = intval($a->argv[1]);
|
||||
}
|
||||
|
||||
if (! $cid) {
|
||||
if (!$cid) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -34,7 +36,7 @@ function allfriends_content(App $a) {
|
|||
intval(local_user())
|
||||
);
|
||||
|
||||
if (! DBM::is_result($c)) {
|
||||
if (!DBM::is_result($c)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -43,32 +45,30 @@ function allfriends_content(App $a) {
|
|||
|
||||
$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']);
|
||||
|
||||
if (! DBM::is_result($r)) {
|
||||
if (!DBM::is_result($r)) {
|
||||
$o .= t('No friends to display.');
|
||||
return $o;
|
||||
}
|
||||
|
||||
$id = 0;
|
||||
|
||||
$entries = [];
|
||||
foreach ($r as $rr) {
|
||||
|
||||
//get further details of the contact
|
||||
$contact_details = Contact::getDetailsByURL($rr['url'], $uid, $rr);
|
||||
|
||||
$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
|
||||
// If the contact is not common to the user, Connect/Follow' will be added to the photo menu
|
||||
if ($rr[cid]) {
|
||||
$rr[id] = $rr[cid];
|
||||
$photo_menu = Contact::photoMenu ($rr);
|
||||
}
|
||||
else {
|
||||
if ($rr['cid']) {
|
||||
$rr['id'] = $rr['cid'];
|
||||
$photo_menu = Contact::photoMenu($rr);
|
||||
} else {
|
||||
$connlnk = System::baseUrl() . '/follow/?url=' . $rr['url'];
|
||||
$photo_menu = array(
|
||||
'profile' => array(t("View Profile"), zrl($rr['url'])),
|
||||
|
@ -78,7 +78,7 @@ function allfriends_content(App $a) {
|
|||
|
||||
$entry = array(
|
||||
'url' => $rr['url'],
|
||||
'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
|
||||
'itemurl' => defaults($contact_details, 'addr', $rr['url']),
|
||||
'name' => htmlentities($contact_details['name']),
|
||||
'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB),
|
||||
'img_hover' => htmlentities($contact_details['name']),
|
||||
|
@ -99,7 +99,7 @@ function allfriends_content(App $a) {
|
|||
|
||||
$tpl = get_markup_template('viewcontact_template.tpl');
|
||||
|
||||
$o .= replace_macros($tpl,array(
|
||||
$o .= replace_macros($tpl, array(
|
||||
//'$title' => sprintf( t('Friends of %s'), htmlentities($c[0]['name'])),
|
||||
'$tab_str' => $tab_str,
|
||||
'$contacts' => $entries,
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
use Friendica\App;
|
||||
|
||||
function amcd_content(App $a) {
|
||||
function amcd_content()
|
||||
{
|
||||
echo <<< JSON
|
||||
{
|
||||
"version":1,
|
||||
|
@ -47,4 +48,4 @@ function amcd_content(App $a) {
|
|||
}
|
||||
JSON;
|
||||
killme();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,69 +7,71 @@ require_once 'library/markdown.php';
|
|||
require_once 'include/bb2diaspora.php';
|
||||
require_once 'include/html2bbcode.php';
|
||||
|
||||
function visible_lf($s) {
|
||||
function visible_lf($s)
|
||||
{
|
||||
return str_replace("\n", '<br />', $s);
|
||||
}
|
||||
|
||||
function babel_content(App $a) {
|
||||
$o .= '<h1>Babel Diagnostic</h1>';
|
||||
function babel_content()
|
||||
{
|
||||
$o = '<h1>Babel Diagnostic</h1>';
|
||||
|
||||
$o .= '<form action="babel" method="post">';
|
||||
$o .= t('Source (bbcode) text:') . EOL;
|
||||
$o .= '<textarea name="text" cols="80" rows="10">' . htmlspecialchars($_REQUEST['text']) .'</textarea>' . EOL;
|
||||
$o .= '<textarea name="text" cols="80" rows="10">' . htmlspecialchars($_REQUEST['text']) . '</textarea>' . EOL;
|
||||
$o .= '<input type="submit" name="submit" value="Submit" /></form>';
|
||||
|
||||
$o .= '<br /><br />';
|
||||
|
||||
$o .= '<form action="babel" method="post">';
|
||||
$o .= t('Source (Diaspora) text to convert to BBcode:') . EOL;
|
||||
$o .= '<textarea name="d2bbtext" cols="80" rows="10">' . htmlspecialchars($_REQUEST['d2bbtext']) .'</textarea>' . EOL;
|
||||
$o .= '<textarea name="d2bbtext" cols="80" rows="10">' . htmlspecialchars($_REQUEST['d2bbtext']) . '</textarea>' . EOL;
|
||||
$o .= '<input type="submit" name="submit" value="Submit" /></form>';
|
||||
|
||||
$o .= '<br /><br />';
|
||||
|
||||
if (x($_REQUEST, 'text')) {
|
||||
$text = trim($_REQUEST['text']);
|
||||
$o .= '<h2>' . t('Source input: ') . '</h2>' . EOL. EOL;
|
||||
$o .= visible_lf($text) . EOL. EOL;
|
||||
$o .= '<h2>' . t('Source input: ') . '</h2>' . EOL . EOL;
|
||||
$o .= visible_lf($text) . EOL . EOL;
|
||||
|
||||
$html = bbcode($text);
|
||||
$o .= '<h2>' . t('bb2html (raw HTML): ') . '</h2>' . EOL. EOL;
|
||||
$o .= htmlspecialchars($html). EOL. EOL;
|
||||
$o .= '<h2>' . t('bb2html (raw HTML): ') . '</h2>' . EOL . EOL;
|
||||
$o .= htmlspecialchars($html) . EOL . EOL;
|
||||
|
||||
//$html = bbcode($text);
|
||||
$o .= '<h2>' . t('bb2html: ') . '</h2>' . EOL. EOL;
|
||||
$o .= $html. EOL. EOL;
|
||||
$o .= '<h2>' . t('bb2html: ') . '</h2>' . EOL . EOL;
|
||||
$o .= $html . EOL . EOL;
|
||||
|
||||
$bbcode = html2bbcode($html);
|
||||
$o .= '<h2>' . t('bb2html2bb: ') . '</h2>' . EOL. EOL;
|
||||
$o .= visible_lf($bbcode) . EOL. EOL;
|
||||
$o .= '<h2>' . t('bb2html2bb: ') . '</h2>' . EOL . EOL;
|
||||
$o .= visible_lf($bbcode) . EOL . EOL;
|
||||
|
||||
$diaspora = bb2diaspora($text);
|
||||
$o .= '<h2>' . t('bb2md: ') . '</h2>' . EOL. EOL;
|
||||
$o .= visible_lf($diaspora) . EOL. EOL;
|
||||
$o .= '<h2>' . t('bb2md: ') . '</h2>' . EOL . EOL;
|
||||
$o .= visible_lf($diaspora) . EOL . EOL;
|
||||
|
||||
$html = Markdown($diaspora);
|
||||
$o .= '<h2>' . t('bb2md2html: ') . '</h2>' . EOL. EOL;
|
||||
$o .= $html. EOL. EOL;
|
||||
$o .= '<h2>' . t('bb2md2html: ') . '</h2>' . EOL . EOL;
|
||||
$o .= $html . EOL . EOL;
|
||||
|
||||
$bbcode = diaspora2bb($diaspora);
|
||||
$o .= '<h2>' . t('bb2dia2bb: ') . '</h2>' . EOL. EOL;
|
||||
$o .= visible_lf($bbcode) . EOL. EOL;
|
||||
$o .= '<h2>' . t('bb2dia2bb: ') . '</h2>' . EOL . EOL;
|
||||
$o .= visible_lf($bbcode) . EOL . EOL;
|
||||
|
||||
$bbcode = html2bbcode($html);
|
||||
$o .= '<h2>' . t('bb2md2html2bb: ') . '</h2>' . EOL. EOL;
|
||||
$o .= visible_lf($bbcode) . EOL. EOL;
|
||||
$o .= '<h2>' . t('bb2md2html2bb: ') . '</h2>' . EOL . EOL;
|
||||
$o .= visible_lf($bbcode) . EOL . EOL;
|
||||
}
|
||||
|
||||
if (x($_REQUEST, 'd2bbtext')) {
|
||||
$d2bbtext = trim($_REQUEST['d2bbtext']);
|
||||
$o .= '<h2>' . t('Source input (Diaspora format): ') . '</h2>' . EOL. EOL;
|
||||
$o .= '<pre>' . $d2bbtext . '</pre>' . EOL. EOL;
|
||||
$o .= '<h2>' . t('Source input (Diaspora format): ') . '</h2>' . EOL . EOL;
|
||||
$o .= '<pre>' . $d2bbtext . '</pre>' . EOL . EOL;
|
||||
|
||||
$bb = diaspora2bb($d2bbtext);
|
||||
$o .= '<h2>' . t('diaspora2bb: ') . '</h2>' . EOL. EOL;
|
||||
$o .= '<pre>' . $bb . '</pre>' . EOL. EOL;
|
||||
$o .= '<h2>' . t('diaspora2bb: ') . '</h2>' . EOL . EOL;
|
||||
$o .= '<pre>' . $bb . '</pre>' . EOL . EOL;
|
||||
}
|
||||
|
||||
return $o;
|
||||
|
|
|
@ -7,7 +7,7 @@ use Friendica\Module\Login;
|
|||
require_once('include/conversation.php');
|
||||
require_once('include/items.php');
|
||||
|
||||
function bookmarklet_init(App $a)
|
||||
function bookmarklet_init()
|
||||
{
|
||||
$_GET["mode"] = "minimal";
|
||||
}
|
||||
|
|
217
mod/cal.php
217
mod/cal.php
|
@ -1,9 +1,10 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file mod/cal.php
|
||||
* @brief The calendar module
|
||||
* This calendar is for profile visitors and contains only the events
|
||||
* of the profile owner
|
||||
* This calendar is for profile visitors and contains only the events
|
||||
* of the profile owner
|
||||
*/
|
||||
use Friendica\App;
|
||||
use Friendica\Content\Feature;
|
||||
|
@ -17,34 +18,36 @@ use Friendica\Model\Group;
|
|||
require_once 'include/event.php';
|
||||
require_once 'include/redir.php';
|
||||
|
||||
function cal_init(App $a) {
|
||||
if($a->argc > 1)
|
||||
function cal_init(App $a)
|
||||
{
|
||||
if ($a->argc > 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;
|
||||
}
|
||||
|
||||
nav_set_selected('events');
|
||||
|
||||
$o = '';
|
||||
|
||||
if($a->argc > 1) {
|
||||
if ($a->argc > 1) {
|
||||
$nick = $a->argv[1];
|
||||
$user = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1",
|
||||
dbesc($nick)
|
||||
);
|
||||
|
||||
if(! count($user))
|
||||
if (!count($user)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$a->data['user'] = $user[0];
|
||||
$a->profile_uid = $user[0]['uid'];
|
||||
|
||||
// if it's a json request abort here becaus we don't
|
||||
// need the widget data
|
||||
if ($a->argv[2] === 'json')
|
||||
if ($a->argv[2] === 'json') {
|
||||
return;
|
||||
}
|
||||
|
||||
$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");
|
||||
|
||||
$vcard_widget .= replace_macros($tpl, array(
|
||||
$vcard_widget = replace_macros($tpl, array(
|
||||
'$name' => $profile['name'],
|
||||
'$photo' => $profile['photo'],
|
||||
'$addr' => (($profile['addr'] != "") ? $profile['addr'] : ""),
|
||||
|
@ -62,8 +65,9 @@ function cal_init(App $a) {
|
|||
|
||||
$cal_widget = widget_events();
|
||||
|
||||
if(! x($a->page,'aside'))
|
||||
if (!x($a->page, 'aside')) {
|
||||
$a->page['aside'] = '';
|
||||
}
|
||||
|
||||
$a->page['aside'] .= $vcard_widget;
|
||||
$a->page['aside'] .= $cal_widget;
|
||||
|
@ -72,17 +76,15 @@ function cal_init(App $a) {
|
|||
return;
|
||||
}
|
||||
|
||||
function cal_content(App $a) {
|
||||
function cal_content(App $a)
|
||||
{
|
||||
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
|
||||
$i18n = get_event_strings();
|
||||
|
||||
$htpl = get_markup_template('event_head.tpl');
|
||||
$a->page['htmlhead'] .= replace_macros($htpl,array(
|
||||
$a->page['htmlhead'] .= replace_macros($htpl, array(
|
||||
'$baseurl' => System::baseUrl(),
|
||||
'$module_url' => '/cal/' . $a->data['user']['nickname'],
|
||||
'$modparams' => 2,
|
||||
|
@ -90,128 +92,126 @@ function cal_content(App $a) {
|
|||
));
|
||||
|
||||
$etpl = get_markup_template('event_end.tpl');
|
||||
$a->page['end'] .= replace_macros($etpl,array(
|
||||
$a->page['end'] .= replace_macros($etpl, array(
|
||||
'$baseurl' => System::baseUrl(),
|
||||
));
|
||||
|
||||
$o ="";
|
||||
|
||||
$mode = 'view';
|
||||
$y = 0;
|
||||
$m = 0;
|
||||
$ignored = ((x($_REQUEST,'ignored')) ? intval($_REQUEST['ignored']) : 0);
|
||||
$ignored = ((x($_REQUEST, 'ignored')) ? intval($_REQUEST['ignored']) : 0);
|
||||
|
||||
if($a->argc == 4) {
|
||||
if($a->argv[2] == 'export') {
|
||||
$mode = 'export';
|
||||
$format = $a->argv[3];
|
||||
}
|
||||
$format = 'ical';
|
||||
if ($a->argc == 4 && $a->argv[2] == 'export') {
|
||||
$mode = 'export';
|
||||
$format = $a->argv[3];
|
||||
}
|
||||
|
||||
//
|
||||
// Setup permissions structures
|
||||
//
|
||||
|
||||
$contact = null;
|
||||
$remote_contact = false;
|
||||
$contact_id = 0;
|
||||
|
||||
$owner_uid = $a->data['user']['uid'];
|
||||
$nick = $a->data['user']['nickname'];
|
||||
|
||||
if(is_array($_SESSION['remote'])) {
|
||||
foreach($_SESSION['remote'] as $v) {
|
||||
if($v['uid'] == $a->profile['profile_uid']) {
|
||||
if (x($_SESSION, 'remote') && is_array($_SESSION['remote'])) {
|
||||
foreach ($_SESSION['remote'] as $v) {
|
||||
if ($v['uid'] == $a->profile['profile_uid']) {
|
||||
$contact_id = $v['cid'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($contact_id) {
|
||||
|
||||
$groups = [];
|
||||
if ($contact_id) {
|
||||
$groups = Group::getIdsByContactId($contact_id);
|
||||
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||
intval($contact_id),
|
||||
intval($a->profile['profile_uid'])
|
||||
);
|
||||
if (DBM::is_result($r)) {
|
||||
$contact = $r[0];
|
||||
$remote_contact = true;
|
||||
}
|
||||
}
|
||||
if(! $remote_contact) {
|
||||
if(local_user()) {
|
||||
$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)) {
|
||||
notice( t('Access to this profile has been restricted.') . EOL);
|
||||
$is_owner = local_user() == $a->profile['profile_uid'];
|
||||
|
||||
if ($a->profile['hidewall'] && (!$is_owner) && (!$remote_contact)) {
|
||||
notice(t('Access to this profile has been restricted.') . EOL);
|
||||
return;
|
||||
}
|
||||
|
||||
// get the permissions
|
||||
$sql_perms = item_permissions_sql($owner_uid,$remote_contact,$groups);
|
||||
$sql_perms = item_permissions_sql($owner_uid, $remote_contact, $groups);
|
||||
// we only want to have the events of the profile owner
|
||||
$sql_extra = " AND `event`.`cid` = 0 " . $sql_perms;
|
||||
|
||||
// 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
|
||||
if($mode == 'view') {
|
||||
|
||||
|
||||
$thisyear = datetime_convert('UTC',date_default_timezone_get(),'now','Y');
|
||||
$thismonth = datetime_convert('UTC',date_default_timezone_get(),'now','m');
|
||||
if(! $y)
|
||||
if ($mode == 'view') {
|
||||
$thisyear = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y');
|
||||
$thismonth = datetime_convert('UTC', date_default_timezone_get(), 'now', 'm');
|
||||
if (!$y) {
|
||||
$y = intval($thisyear);
|
||||
if(! $m)
|
||||
}
|
||||
|
||||
if (!$m) {
|
||||
$m = intval($thismonth);
|
||||
}
|
||||
|
||||
// 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.
|
||||
|
||||
if($y < 1901)
|
||||
if ($y < 1901) {
|
||||
$y = 1900;
|
||||
if($y > 2099)
|
||||
}
|
||||
|
||||
if ($y > 2099) {
|
||||
$y = 2100;
|
||||
}
|
||||
|
||||
$nextyear = $y;
|
||||
$nextmonth = $m + 1;
|
||||
if($nextmonth > 12) {
|
||||
$nextmonth = 1;
|
||||
if ($nextmonth > 12) {
|
||||
$nextmonth = 1;
|
||||
$nextyear ++;
|
||||
}
|
||||
|
||||
$prevyear = $y;
|
||||
if($m > 1)
|
||||
if ($m > 1) {
|
||||
$prevmonth = $m - 1;
|
||||
else {
|
||||
} else {
|
||||
$prevmonth = 12;
|
||||
$prevyear --;
|
||||
}
|
||||
|
||||
$dim = get_dim($y,$m);
|
||||
$start = sprintf('%d-%d-%d %d:%d:%d',$y,$m,1,0,0,0);
|
||||
$finish = sprintf('%d-%d-%d %d:%d:%d',$y,$m,$dim,23,59,59);
|
||||
$dim = get_dim($y, $m);
|
||||
$start = sprintf('%d-%d-%d %d:%d:%d', $y, $m, 1, 0, 0, 0);
|
||||
$finish = sprintf('%d-%d-%d %d:%d:%d', $y, $m, $dim, 23, 59, 59);
|
||||
|
||||
|
||||
if ($a->argv[2] === 'json'){
|
||||
if (x($_GET,'start')) $start = $_GET['start'];
|
||||
if (x($_GET,'end')) $finish = $_GET['end'];
|
||||
if ($a->argv[2] === 'json') {
|
||||
if (x($_GET, 'start')) {
|
||||
$start = $_GET['start'];
|
||||
}
|
||||
|
||||
if (x($_GET, 'end')) {
|
||||
$finish = $_GET['end'];
|
||||
}
|
||||
}
|
||||
|
||||
$start = datetime_convert('UTC','UTC',$start);
|
||||
$finish = datetime_convert('UTC','UTC',$finish);
|
||||
$start = datetime_convert('UTC', 'UTC', $start);
|
||||
$finish = datetime_convert('UTC', 'UTC', $finish);
|
||||
|
||||
$adjust_start = datetime_convert('UTC', date_default_timezone_get(), $start);
|
||||
$adjust_finish = datetime_convert('UTC', date_default_timezone_get(), $finish);
|
||||
|
||||
// put the event parametes in an array so we can better transmit them
|
||||
$event_params = array(
|
||||
'event_id' => (x($_GET,'id') ? $_GET["id"] : 0),
|
||||
'event_id' => (x($_GET, 'id') ? $_GET["id"] : 0),
|
||||
'start' => $start,
|
||||
'finish' => $finish,
|
||||
'adjust_start' => $adjust_start,
|
||||
|
@ -220,7 +220,7 @@ function cal_content(App $a) {
|
|||
);
|
||||
|
||||
// get events by id or by date
|
||||
if (x($_GET,'id')){
|
||||
if (x($_GET, 'id')) {
|
||||
$r = event_by_id($owner_uid, $event_params, $sql_extra);
|
||||
} else {
|
||||
$r = events_by_date($owner_uid, $event_params, $sql_extra);
|
||||
|
@ -231,57 +231,51 @@ function cal_content(App $a) {
|
|||
if (DBM::is_result($r)) {
|
||||
$r = sort_by_date($r);
|
||||
foreach ($r as $rr) {
|
||||
$j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j'));
|
||||
if (! x($links,$j)) {
|
||||
$j = (($rr['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $rr['start'], 'j') : datetime_convert('UTC', 'UTC', $rr['start'], 'j'));
|
||||
if (!x($links, $j)) {
|
||||
$links[$j] = System::baseUrl() . '/' . $a->cmd . '#link-' . $j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$events=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'){
|
||||
echo json_encode($events); killme();
|
||||
if ($a->argv[2] === 'json') {
|
||||
echo json_encode($events);
|
||||
killme();
|
||||
}
|
||||
|
||||
// links: array('href', 'text', 'extra css classes', 'title')
|
||||
if (x($_GET,'id')){
|
||||
$tpl = get_markup_template("event.tpl");
|
||||
if (x($_GET, 'id')) {
|
||||
$tpl = get_markup_template("event.tpl");
|
||||
} else {
|
||||
// if (Config::get('experimentals','new_calendar')==1){
|
||||
$tpl = get_markup_template("events_js.tpl");
|
||||
$tpl = get_markup_template("events_js.tpl");
|
||||
// } else {
|
||||
// $tpl = get_markup_template("events.tpl");
|
||||
// }
|
||||
}
|
||||
|
||||
// Get rid of dashes in key names, Smarty3 can't handle them
|
||||
foreach($events as $key => $event) {
|
||||
foreach ($events as $key => $event) {
|
||||
$event_item = array();
|
||||
foreach($event['item'] as $k => $v) {
|
||||
$k = str_replace('-','_',$k);
|
||||
foreach ($event['item'] as $k => $v) {
|
||||
$k = str_replace('-', '_', $k);
|
||||
$event_item[$k] = $v;
|
||||
}
|
||||
$events[$key]['item'] = $event_item;
|
||||
}
|
||||
|
||||
$o = replace_macros($tpl, array(
|
||||
'$baseurl' => System::baseUrl(),
|
||||
'$tabs' => $tabs,
|
||||
'$title' => t('Events'),
|
||||
'$view' => t('View'),
|
||||
'$previous' => array(System::baseUrl()."/events/$prevyear/$prevmonth", t('Previous'),'',''),
|
||||
'$next' => array(System::baseUrl()."/events/$nextyear/$nextmonth", t('Next'),'',''),
|
||||
'$calendar' => cal($y,$m,$links, ' eventcal'),
|
||||
|
||||
'$events' => $events,
|
||||
|
||||
'$baseurl' => System::baseUrl(),
|
||||
'$tabs' => $tabs,
|
||||
'$title' => t('Events'),
|
||||
'$view' => t('View'),
|
||||
'$previous' => array(System::baseUrl() . "/events/$prevyear/$prevmonth", t('Previous'), '', ''),
|
||||
'$next' => array(System::baseUrl() . "/events/$nextyear/$nextmonth", t('Next'), '', ''),
|
||||
'$calendar' => cal($y, $m, $links, ' eventcal'),
|
||||
'$events' => $events,
|
||||
"today" => t("today"),
|
||||
"month" => t("month"),
|
||||
"week" => t("week"),
|
||||
|
@ -289,21 +283,24 @@ function cal_content(App $a) {
|
|||
"list" => t("list"),
|
||||
));
|
||||
|
||||
if (x($_GET,'id')){ echo $o; killme(); }
|
||||
if (x($_GET, 'id')) {
|
||||
echo $o;
|
||||
killme();
|
||||
}
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
if($mode == 'export') {
|
||||
if(! (intval($owner_uid))) {
|
||||
notice( t('User not found'));
|
||||
if ($mode == 'export') {
|
||||
if (!(intval($owner_uid))) {
|
||||
notice(t('User not found'));
|
||||
return;
|
||||
}
|
||||
|
||||
// Test permissions
|
||||
// Respect the export feature setting for all other /cal pages if it's not the own profile
|
||||
if( ((local_user() !== intval($owner_uid))) && ! Feature::isEnabled($owner_uid, "export_calendar")) {
|
||||
notice( t('Permission denied.') . EOL);
|
||||
if (((local_user() !== intval($owner_uid))) && !Feature::isEnabled($owner_uid, "export_calendar")) {
|
||||
notice(t('Permission denied.') . EOL);
|
||||
goaway('cal/' . $nick);
|
||||
}
|
||||
|
||||
|
@ -311,17 +308,19 @@ function cal_content(App $a) {
|
|||
$evexport = event_export($owner_uid, $format);
|
||||
|
||||
if (!$evexport["success"]) {
|
||||
if($evexport["content"])
|
||||
notice( t('This calendar format is not supported') );
|
||||
else
|
||||
notice( t('No exportable data found'));
|
||||
if ($evexport["content"]) {
|
||||
notice(t('This calendar format is not supported'));
|
||||
} else {
|
||||
notice(t('No exportable data found'));
|
||||
}
|
||||
|
||||
// If it the own calendar return to the events page
|
||||
// otherwise to the profile calendar page
|
||||
if (local_user() === intval($owner_uid))
|
||||
if (local_user() === intval($owner_uid)) {
|
||||
$return_path = "events";
|
||||
else
|
||||
$returnpath = "cal/".$nick;
|
||||
} else {
|
||||
$return_path = "cal/" . $nick;
|
||||
}
|
||||
|
||||
goaway($return_path);
|
||||
}
|
||||
|
@ -329,7 +328,7 @@ function cal_content(App $a) {
|
|||
// If nothing went wrong we can echo the export content
|
||||
if ($evexport["success"]) {
|
||||
header('Content-type: text/calendar');
|
||||
header('content-disposition: attachment; filename="' . t('calendar') . '-' . $nick . '.' . $evexport["extension"] . '"' );
|
||||
header('content-disposition: attachment; filename="' . t('calendar') . '-' . $nick . '.' . $evexport["extension"] . '"');
|
||||
echo $evexport["content"];
|
||||
killme();
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file include/common.php
|
||||
*/
|
||||
|
@ -10,8 +11,8 @@ use Friendica\Model\GContact;
|
|||
require_once 'include/contact_selectors.php';
|
||||
require_once 'mod/contacts.php';
|
||||
|
||||
function common_content(App $a) {
|
||||
|
||||
function common_content(App $a)
|
||||
{
|
||||
$o = '';
|
||||
|
||||
$cmd = $a->argv[1];
|
||||
|
@ -19,8 +20,8 @@ function common_content(App $a) {
|
|||
$cid = intval($a->argv[3]);
|
||||
$zcid = 0;
|
||||
|
||||
if (! local_user()) {
|
||||
notice( t('Permission denied.') . EOL);
|
||||
if (!local_user()) {
|
||||
notice(t('Permission denied.') . EOL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -28,7 +29,7 @@ function common_content(App $a) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (! $uid) {
|
||||
if (!$uid) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -45,37 +46,36 @@ function common_content(App $a) {
|
|||
intval($uid)
|
||||
);
|
||||
/// @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']),
|
||||
'$photo' => $c[0]['photo'],
|
||||
'url' => 'contacts/' . $cid
|
||||
));
|
||||
|
||||
if (! x($a->page,'aside')) {
|
||||
if (!x($a->page, 'aside')) {
|
||||
$a->page['aside'] = '';
|
||||
}
|
||||
$a->page['aside'] .= $vcard_widget;
|
||||
}
|
||||
|
||||
if (! DBM::is_result($c)) {
|
||||
if (!DBM::is_result($c)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(! $cid) {
|
||||
if(get_my_url()) {
|
||||
$r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1",
|
||||
dbesc(normalise_link(get_my_url())),
|
||||
intval($profile_uid)
|
||||
if (!$cid && get_my_url()) {
|
||||
/// @todo : Initialize $profile_uid
|
||||
$r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1",
|
||||
dbesc(normalise_link(get_my_url())),
|
||||
intval($profile_uid)
|
||||
);
|
||||
if (DBM::is_result($r)) {
|
||||
$cid = $r[0]['id'];
|
||||
} else {
|
||||
$r = q("SELECT `id` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
|
||||
dbesc(normalise_link(get_my_url()))
|
||||
);
|
||||
if (DBM::is_result($r))
|
||||
$cid = $r[0]['id'];
|
||||
else {
|
||||
$r = q("SELECT `id` FROM `gcontact` WHERE `nurl` = '%s' LIMIT 1",
|
||||
dbesc(normalise_link(get_my_url()))
|
||||
);
|
||||
if (DBM::is_result($r))
|
||||
$zcid = $r[0]['id'];
|
||||
if (DBM::is_result($r)) {
|
||||
$zcid = $r[0]['id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -90,29 +90,27 @@ function common_content(App $a) {
|
|||
$t = GContact::countCommonFriendsZcid($uid, $zcid);
|
||||
}
|
||||
|
||||
if (count($t)) {
|
||||
if ($t > 0) {
|
||||
$a->set_pager_total($t);
|
||||
} else {
|
||||
notice(t('No contacts in common.') . EOL);
|
||||
return $o;
|
||||
}
|
||||
|
||||
|
||||
if ($cid) {
|
||||
$r = GContact::commonFriends($uid, $cid, $a->pager['start'], $a->pager['itemspage']);
|
||||
} else {
|
||||
$r = GContact::commonFriendsZcid($uid, $zcid, $a->pager['start'], $a->pager['itemspage']);
|
||||
}
|
||||
|
||||
|
||||
if (! DBM::is_result($r)) {
|
||||
if (!DBM::is_result($r)) {
|
||||
return $o;
|
||||
}
|
||||
|
||||
$id = 0;
|
||||
|
||||
$entries = [];
|
||||
foreach ($r as $rr) {
|
||||
|
||||
//get further details of the contact
|
||||
$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
|
||||
$rr['id'] = $rr['cid'];
|
||||
|
||||
$photo_menu = '';
|
||||
$photo_menu = Contact::photoMenu($rr);
|
||||
|
||||
$entry = array(
|
||||
'url' => $rr['url'],
|
||||
'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
|
||||
'itemurl' => defaults($contact_details, 'addr', $rr['url']),
|
||||
'name' => $contact_details['name'],
|
||||
'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB),
|
||||
'img_hover' => htmlentities($contact_details['name']),
|
||||
|
@ -140,7 +137,9 @@ function common_content(App $a) {
|
|||
$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);
|
||||
} else {
|
||||
$title = t('Common Friends');
|
||||
|
@ -148,7 +147,7 @@ function common_content(App $a) {
|
|||
|
||||
$tpl = get_markup_template('viewcontact_template.tpl');
|
||||
|
||||
$o .= replace_macros($tpl,array(
|
||||
$o .= replace_macros($tpl, array(
|
||||
'$title' => $title,
|
||||
'$tab_str' => $tab_str,
|
||||
'$contacts' => $entries,
|
||||
|
|
|
@ -5,22 +5,24 @@ use Friendica\Core\Config;
|
|||
use Friendica\Core\PConfig;
|
||||
use Friendica\Database\DBM;
|
||||
|
||||
function community_init(App $a) {
|
||||
function community_init(App $a)
|
||||
{
|
||||
if (!local_user()) {
|
||||
unset($_SESSION['theme']);
|
||||
unset($_SESSION['mobile-theme']);
|
||||
}
|
||||
}
|
||||
|
||||
function community_content(App $a, $update = 0) {
|
||||
function community_content(App $a, $update = 0)
|
||||
{
|
||||
$o = '';
|
||||
|
||||
if (Config::get('system','block_public') && !local_user() && !remote_user()) {
|
||||
if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
|
||||
notice(t('Public access denied.') . EOL);
|
||||
return;
|
||||
}
|
||||
|
||||
$page_style = Config::get('system','community_page_style');
|
||||
$page_style = Config::get('system', 'community_page_style');
|
||||
|
||||
if ($a->argc > 1) {
|
||||
$content = $a->argv[1];
|
||||
|
@ -60,21 +62,25 @@ function community_content(App $a, $update = 0) {
|
|||
$tabs = [];
|
||||
|
||||
if (local_user() || in_array($page_style, [CP_USERS_AND_GLOBAL, CP_USERS_ON_SERVER])) {
|
||||
$tabs[] = array('label'=>t('Community'),
|
||||
'url' => 'community/local',
|
||||
'sel' => $content == 'local' ? 'active' : '',
|
||||
'title' => t('Posts from local users on this server'),
|
||||
'id' => 'community-local-tab',
|
||||
'accesskey' => 'l');
|
||||
$tabs[] = array(
|
||||
'label' => t('Community'),
|
||||
'url' => 'community/local',
|
||||
'sel' => $content == 'local' ? 'active' : '',
|
||||
'title' => t('Posts from local users on this server'),
|
||||
'id' => 'community-local-tab',
|
||||
'accesskey' => 'l'
|
||||
);
|
||||
}
|
||||
|
||||
if (local_user() || in_array($page_style, [CP_USERS_AND_GLOBAL, CP_GLOBAL_COMMUNITY])) {
|
||||
$tabs[] = array('label' => t('Global Timeline'),
|
||||
'url' => 'community/global',
|
||||
'sel' => $content == 'global' ? 'active' : '',
|
||||
'title' => t('Posts from users of the federated network'),
|
||||
'id' => 'community-global-tab',
|
||||
'accesskey' => 'g');
|
||||
$tabs[] = array(
|
||||
'label' => t('Global Timeline'),
|
||||
'url' => 'community/global',
|
||||
'sel' => $content == 'global' ? 'active' : '',
|
||||
'title' => t('Posts from users of the federated network'),
|
||||
'id' => 'community-global-tab',
|
||||
'accesskey' => 'g'
|
||||
);
|
||||
}
|
||||
|
||||
$tab_tpl = get_markup_template('common_tabs.tpl');
|
||||
|
@ -103,9 +109,9 @@ function community_content(App $a, $update = 0) {
|
|||
// check if we serve a mobile device and get the user settings
|
||||
// accordingly
|
||||
if ($a->is_mobile) {
|
||||
$itemspage_network = PConfig::get(local_user(),'system','itemspage_mobile_network', 20);
|
||||
$itemspage_network = PConfig::get(local_user(), 'system', 'itemspage_mobile_network', 20);
|
||||
} else {
|
||||
$itemspage_network = PConfig::get(local_user(),'system','itemspage_network', 40);
|
||||
$itemspage_network = PConfig::get(local_user(), 'system', 'itemspage_network', 40);
|
||||
}
|
||||
|
||||
// now that we have the user settings, see if the theme forces
|
||||
|
@ -124,7 +130,7 @@ function community_content(App $a, $update = 0) {
|
|||
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')) {
|
||||
$count = 1;
|
||||
|
@ -133,7 +139,7 @@ function community_content(App $a, $update = 0) {
|
|||
$s = array();
|
||||
|
||||
do {
|
||||
foreach ($r AS $row=>$item) {
|
||||
foreach ($r as $item) {
|
||||
if ($previousauthor == $item["author-link"]) {
|
||||
++$numposts;
|
||||
} else {
|
||||
|
@ -141,14 +147,14 @@ function community_content(App $a, $update = 0) {
|
|||
}
|
||||
$previousauthor = $item["author-link"];
|
||||
|
||||
if (($numposts < $maxpostperauthor) && (sizeof($s) < $a->pager['itemspage'])) {
|
||||
if (($numposts < $maxpostperauthor) && (count($s) < $a->pager['itemspage'])) {
|
||||
$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);
|
||||
}
|
||||
} while ((sizeof($s) < $a->pager['itemspage']) && (++$count < 50) && (sizeof($r) > 0));
|
||||
} while ((count($s) < $a->pager['itemspage']) && ( ++$count < 50) && (count($r) > 0));
|
||||
} else {
|
||||
$s = $r;
|
||||
}
|
||||
|
@ -168,24 +174,25 @@ function community_content(App $a, $update = 0) {
|
|||
));
|
||||
}
|
||||
|
||||
function community_getitems($start, $itemspage, $content) {
|
||||
function community_getitems($start, $itemspage, $content)
|
||||
{
|
||||
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 `item` ON `item`.`id` = `thread`.`iid`
|
||||
AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
|
||||
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''".
|
||||
item_joins()." AND `contact`.`self`
|
||||
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''" .
|
||||
item_joins() . " AND `contact`.`self`
|
||||
WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
|
||||
AND NOT `thread`.`private` AND `thread`.`wall`
|
||||
ORDER BY `thread`.`received` DESC LIMIT ".intval($start).", ".intval($itemspage)
|
||||
ORDER BY `thread`.`received` DESC LIMIT " . intval($start) . ", " . intval($itemspage)
|
||||
);
|
||||
return dba::inArray($r);
|
||||
} elseif ($content == 'global') {
|
||||
$r = dba::p("SELECT ".item_fieldlists()." FROM `thread`
|
||||
INNER JOIN `item` ON `item`.`id` = `thread`.`iid` ".item_joins().
|
||||
"WHERE `thread`.`uid` = 0 AND `verb` = ?
|
||||
ORDER BY `thread`.`created` DESC LIMIT ".intval($start).", ".intval($itemspage),
|
||||
$r = dba::p("SELECT " . item_fieldlists() . " FROM `thread`
|
||||
INNER JOIN `item` ON `item`.`id` = `thread`.`iid` " . item_joins() .
|
||||
"WHERE `thread`.`uid` = 0 AND `verb` = ?
|
||||
ORDER BY `thread`.`created` DESC LIMIT " . intval($start) . ", " . intval($itemspage),
|
||||
ACTIVITY_POST
|
||||
);
|
||||
return dba::inArray($r);
|
||||
|
|
|
@ -11,6 +11,7 @@ function contactgroup_content(App $a)
|
|||
killme();
|
||||
}
|
||||
|
||||
$change = null;
|
||||
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",
|
||||
intval($a->argv[2]),
|
||||
|
@ -39,7 +40,7 @@ function contactgroup_content(App $a)
|
|||
}
|
||||
}
|
||||
|
||||
if ($change) {
|
||||
if (x($change)) {
|
||||
if (in_array($change, $preselected)) {
|
||||
Group::removeMember($group['id'], $change);
|
||||
} else {
|
||||
|
|
|
@ -60,6 +60,7 @@ class App {
|
|||
public $timezone;
|
||||
public $interactive = true;
|
||||
public $plugins;
|
||||
public $plugins_admin = array();
|
||||
public $apps = array();
|
||||
public $identities;
|
||||
public $is_mobile = false;
|
||||
|
|
|
@ -130,7 +130,7 @@ class Config
|
|||
*
|
||||
* @param string $family The category of the configuration value
|
||||
* @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
|
||||
*/
|
||||
|
|
|
@ -186,13 +186,22 @@ class DBStructure {
|
|||
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) {
|
||||
Config::set('system', 'maintenance', 1);
|
||||
Config::set('system', 'maintenance_reason', sprintf(t(': Database update'), DBM::date().' '.date('e')));
|
||||
}
|
||||
|
||||
$errors = false;
|
||||
$errors = '';
|
||||
|
||||
logger('updating structure', LOGGER_DEBUG);
|
||||
|
||||
|
|
|
@ -327,8 +327,8 @@ class GContact
|
|||
}
|
||||
|
||||
/**
|
||||
* @param object $uid user
|
||||
* @param object $cid cid
|
||||
* @param integer $uid user
|
||||
* @param integer $cid cid
|
||||
* @param integer $start optional, default 0
|
||||
* @param integer $limit optional, default 9999
|
||||
* @param boolean $shuffle optional, default false
|
||||
|
@ -365,8 +365,8 @@ class GContact
|
|||
}
|
||||
|
||||
/**
|
||||
* @param object $uid user
|
||||
* @param object $zcid zcid
|
||||
* @param integer $uid user
|
||||
* @param integer $zcid zcid
|
||||
* @param integer $start optional, default 0
|
||||
* @param integer $limit optional, default 9999
|
||||
* @param boolean $shuffle optional, default false
|
||||
|
@ -397,8 +397,8 @@ class GContact
|
|||
}
|
||||
|
||||
/**
|
||||
* @param object $uid user
|
||||
* @param object $cid cid
|
||||
* @param integer $uid user
|
||||
* @param integer $cid cid
|
||||
* @return integer
|
||||
*/
|
||||
public static function countAllFriends($uid, $cid)
|
||||
|
@ -420,11 +420,11 @@ class GContact
|
|||
}
|
||||
|
||||
/**
|
||||
* @param object $uid user
|
||||
* @param object $cid cid
|
||||
* @param integer $uid user
|
||||
* @param integer $cid cid
|
||||
* @param integer $start optional, default 0
|
||||
* @param integer $limit optional, default 80
|
||||
* @return object
|
||||
* @return array
|
||||
*/
|
||||
public static function allFriends($uid, $cid, $start = 0, $limit = 80)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue