*much* more usage of App::get_baseurl() instead of $a->get_baseurl() (coding convention applied)

Signed-off-by: Roland Häder <roland@mxchange.org>
This commit is contained in:
Roland Häder 2016-12-19 14:26:13 +01:00 committed by Roland Haeder
commit f8a213e23b
No known key found for this signature in database
GPG key ID: B72F8185C6C7BD78
19 changed files with 226 additions and 196 deletions

View file

@ -1851,12 +1851,12 @@ function admin_page_themes(App &$a){
* @param App $a
*/
function admin_page_logs_post(App &$a) {
if(x($_POST,"page_logs")) {
if (x($_POST,"page_logs")) {
check_form_security_token_redirectOnErr('/admin/logs', 'admin_logs');
$logfile = ((x($_POST,'logfile')) ? notags(trim($_POST['logfile'])) : '');
$debugging = ((x($_POST,'debugging')) ? true : false);
$loglevel = ((x($_POST,'loglevel')) ? intval(trim($_POST['loglevel'])) : 0);
$logfile = (x($_POST,'logfile')) ? notags(trim($_POST['logfile'])) : '');
$debugging = ((x($_POST,'debugging')) ? true : false);
$loglevel = ((x($_POST,'loglevel')) ? intval(trim($_POST['loglevel'])) : 0);
set_config('system','logfile', $logfile);
set_config('system','debugging', $debugging);

View file

@ -21,7 +21,6 @@ function delegate_content(App &$a) {
goaway(App::get_baseurl() . '/delegate');
}
$id = $a->argv[2];
$r = q("select `nickname` from user where uid = %d limit 1",
@ -45,12 +44,11 @@ function delegate_content(App &$a) {
if ($a->argc > 2 && $a->argv[1] === 'remove' && intval($a->argv[2])) {
// delegated admins can view but not change delegation permissions
if (x($_SESSION,'submanage') && intval($_SESSION['submanage'])) {
goaway(App::get_baseurl() . '/delegate');
}
q("delete from manage where uid = %d and mid = %d limit 1",
q("DELETE FROM `manage` WHERE `uid` = %d AND `mid` = %d LIMIT 1",
intval($a->argv[2]),
intval(local_user())
);

View file

@ -810,19 +810,17 @@ function dfrn_request_content(App &$a) {
// At first look if an address was provided
// Otherwise take the local address
if (x($_GET,'addr') AND ($_GET['addr'] != ""))
if (x($_GET,'addr') AND ($_GET['addr'] != "")) {
$myaddr = hex2bin($_GET['addr']);
elseif (x($_GET,'address') AND ($_GET['address'] != ""))
} elseif (x($_GET,'address') AND ($_GET['address'] != "")) {
$myaddr = $_GET['address'];
elseif (local_user()) {
} elseif (local_user()) {
if (strlen($a->path)) {
$myaddr = App::get_baseurl() . '/profile/' . $a->user['nickname'];
}
else {
} else {
$myaddr = $a->user['nickname'] . '@' . substr(z_root(), strpos(z_root(),'://') + 3 );
}
}
else {
} else {
// last, try a zrl
$myaddr = get_my_url();
}
@ -840,8 +838,7 @@ function dfrn_request_content(App &$a) {
if ($a->profile['page-flags'] == PAGE_NORMAL) {
$tpl = get_markup_template('dfrn_request.tpl');
}
else {
} else {
$tpl = get_markup_template('auto_request.tpl');
}
@ -850,10 +847,12 @@ function dfrn_request_content(App &$a) {
// see if we are allowed to have NETWORK_MAIL2 contacts
$mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
if(get_config('system','dfrn_only'))
$mail_disabled = 1;
if(! $mail_disabled) {
if (get_config('system','dfrn_only')) {
$mail_disabled = 1;
}
if (! $mail_disabled) {
$r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1",
intval($a->profile['uid'])
);

View file

@ -354,7 +354,7 @@ function events_content(App &$a) {
}
}
$events=array();
$events = array();
// transform the event in a usable array
if (dbm::is_result($r)) {

View file

@ -31,8 +31,7 @@ function group_post(App &$a) {
if ($r) {
goaway(App::get_baseurl() . '/group/' . $r);
}
}
else {
} else {
notice( t('Could not create group.') . EOL );
}
goaway(App::get_baseurl() . '/group');
@ -92,7 +91,7 @@ function group_content(App &$a) {
'$submit' => t('Save Group'),
);
if(($a->argc == 2) && ($a->argv[1] === 'new')) {
if (($a->argc == 2) && ($a->argv[1] === 'new')) {
return replace_macros($tpl, $context + array(
'$title' => t('Create a group of contacts/friends.'),

View file

@ -52,4 +52,3 @@ function hcard_init(App &$a) {
}
}

View file

@ -120,7 +120,7 @@ function invite_content(App &$a) {
if (strlen($dirloc)) {
if ($a->config['register_policy'] == REGISTER_CLOSED) {
$linktxt = sprintf( t('Visit %s for a list of public sites that you can join. Friendica members on other sites can all connect with each other, as well as with members of many other social networks.'), $dirloc . '/siteinfo');
} elseif($a->config['register_policy'] != REGISTER_CLOSED) {
} elseif ($a->config['register_policy'] != REGISTER_CLOSED) {
$linktxt = sprintf( t('To accept this invitation, please visit and register at %s or any other public Friendica website.'), App::get_baseurl())
. "\r\n" . "\r\n" . sprintf( t('Friendica sites all inter-connect to create a huge privacy-enhanced social web that is owned and controlled by its members. They can also connect with many traditional social networks. See %s for a list of alternate Friendica sites you can join.'),$dirloc . '/siteinfo');
}

View file

@ -454,7 +454,7 @@ function item_post(App &$a) {
$objecttype = ACTIVITY_OBJ_IMAGE;
foreach ($images as $image) {
if (! stristr($image,App::get_baseurl() . '/photo/')) {
if (! stristr($image,App::get_baseurl() . '/photo/'))
continue;
}
$image_uri = substr($image,strrpos($image,'/') + 1);
@ -620,16 +620,17 @@ function item_post(App &$a) {
continue;
$success = handle_tag($a, $body, $inform, $str_tags, (local_user()) ? local_user() : $profile_uid , $tag, $network);
if($success['replaced'])
if ($success['replaced']) {
$tagged[] = $tag;
if(is_array($success['contact']) && intval($success['contact']['prv'])) {
}
if (is_array($success['contact']) && intval($success['contact']['prv'])) {
$private_forum = true;
$private_id = $success['contact']['id'];
}
}
}
if(($private_forum) && (! $parent) && (! $private)) {
if (($private_forum) && (! $parent) && (! $private)) {
// we tagged a private forum in a top level post and the message was public.
// Restrict it.
$private = 1;
@ -639,8 +640,8 @@ function item_post(App &$a) {
$attachments = '';
$match = false;
if(preg_match_all('/(\[attachment\]([0-9]+)\[\/attachment\])/',$body,$match)) {
foreach($match[2] as $mtch) {
if (preg_match_all('/(\[attachment\]([0-9]+)\[\/attachment\])/',$body,$match)) {
foreach ($match[2] as $mtch) {
$r = q("SELECT `id`,`filename`,`filesize`,`filetype` FROM `attach` WHERE `uid` = %d AND `id` = %d LIMIT 1",
intval($profile_uid),
intval($mtch)

View file

@ -74,24 +74,24 @@ function profile_content(&$a, $update = 0) {
$category = $datequery = $datequery2 = '';
if($a->argc > 2) {
for($x = 2; $x < $a->argc; $x ++) {
if(is_a_date_arg($a->argv[$x])) {
if($datequery)
if ($a->argc > 2) {
for ($x = 2; $x < $a->argc; $x ++) {
if (is_a_date_arg($a->argv[$x])) {
if ($datequery) {
$datequery2 = escape_tags($a->argv[$x]);
else
} else {
$datequery = escape_tags($a->argv[$x]);
}
else
} else {
$category = $a->argv[$x];
}
}
}
if(! x($category)) {
if (! x($category)) {
$category = ((x($_GET,'category')) ? $_GET['category'] : '');
}
if(get_config('system','block_public') && (! local_user()) && (! remote_user())) {
if (get_config('system','block_public') && (! local_user()) && (! remote_user())) {
return login();
}
@ -106,32 +106,30 @@ function profile_content(&$a, $update = 0) {
$tab = 'posts';
$o = '';
if($update) {
if ($update) {
// Ensure we've got a profile owner if updating.
$a->profile['profile_uid'] = $update;
}
else {
if($a->profile['profile_uid'] == local_user()) {
} else {
if ($a->profile['profile_uid'] == local_user()) {
nav_set_selected('home');
}
}
$contact = null;
$remote_contact = false;
$contact_id = 0;
if(is_array($_SESSION['remote'])) {
foreach($_SESSION['remote'] as $v) {
if($v['uid'] == $a->profile['profile_uid']) {
if (is_array($_SESSION['remote'])) {
foreach ($_SESSION['remote'] as $v) {
if ($v['uid'] == $a->profile['profile_uid']) {
$contact_id = $v['cid'];
break;
}
}
}
if($contact_id) {
if ($contact_id) {
$groups = init_groups_visitor($contact_id);
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($contact_id),
@ -143,8 +141,8 @@ function profile_content(&$a, $update = 0) {
}
}
if(! $remote_contact) {
if(local_user()) {
if (! $remote_contact) {
if (local_user()) {
$contact_id = $_SESSION['cid'];
$contact = $a->contact;
}
@ -152,32 +150,29 @@ function profile_content(&$a, $update = 0) {
$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);
return;
}
if(! $update) {
if(x($_GET,'tab'))
if (! $update) {
if (x($_GET,'tab'))
$tab = notags(trim($_GET['tab']));
$o.=profile_tabs($a, $is_owner, $a->profile['nickname']);
if($tab === 'profile') {
if ($tab === 'profile') {
$o .= advanced_profile($a);
call_hooks('profile_advanced',$o);
return $o;
}
$o .= common_friends_visitor_widget($a->profile['profile_uid']);
if(x($_SESSION,'new_member') && $_SESSION['new_member'] && $is_owner)
if (x($_SESSION,'new_member') && $_SESSION['new_member'] && $is_owner) {
$o .= '<a href="newmember" id="newmember-tips" style="font-size: 1.2em;"><b>' . t('Tips for New Members') . '</b></a>' . EOL;
}
$commpage = (($a->profile['page-flags'] == PAGE_COMMUNITY) ? true : false);
$commvisitor = (($commpage && $remote_contact == true) ? true : false);
@ -185,7 +180,7 @@ function profile_content(&$a, $update = 0) {
$a->page['aside'] .= posted_date_widget(App::get_baseurl(true) . '/profile/' . $a->profile['nickname'],$a->profile['profile_uid'],true);
$a->page['aside'] .= categories_widget(App::get_baseurl(true) . '/profile/' . $a->profile['nickname'],(x($category) ? xmlify($category) : ''));
if(can_write_wall($a,$a->profile['profile_uid'])) {
if (can_write_wall($a,$a->profile['profile_uid'])) {
$x = array(
'is_owner' => $is_owner,
@ -215,7 +210,7 @@ function profile_content(&$a, $update = 0) {
$sql_extra = item_permissions_sql($a->profile['profile_uid'],$remote_contact,$groups);
if($update) {
if ($update) {
$r = q("SELECT distinct(parent) AS `item_id`, `item`.`network` AS `item_network`
FROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
@ -234,16 +229,16 @@ function profile_content(&$a, $update = 0) {
} else {
$sql_post_table = "";
if(x($category)) {
if (x($category)) {
$sql_post_table = sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
dbesc(protect_sprintf($category)), intval(TERM_OBJ_POST), intval(TERM_CATEGORY), intval($a->profile['profile_uid']));
//$sql_extra .= protect_sprintf(file_tag_file_query('item',$category,'category'));
}
if($datequery) {
if ($datequery) {
$sql_extra2 .= protect_sprintf(sprintf(" AND `thread`.`created` <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery))));
}
if($datequery2) {
if ($datequery2) {
$sql_extra2 .= protect_sprintf(sprintf(" AND `thread`.`created` >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(),'',$datequery2))));
}

View file

@ -133,9 +133,9 @@ function profile_photo_post(App &$a) {
require_once('include/profile_update.php');
profile_change();
}
else
} else {
notice( t('Unable to process image') . EOL);
}
}
goaway(App::get_baseurl() . '/profiles');
@ -146,11 +146,13 @@ function profile_photo_post(App &$a) {
$filename = basename($_FILES['userfile']['name']);
$filesize = intval($_FILES['userfile']['size']);
$filetype = $_FILES['userfile']['type'];
if ($filetype=="") $filetype=guess_image_type($filename);
if ($filetype == "") {
$filetype = guess_image_type($filename);
}
$maximagesize = get_config('system','maximagesize');
if(($maximagesize) && ($filesize > $maximagesize)) {
if (($maximagesize) && ($filesize > $maximagesize)) {
notice( sprintf(t('Image exceeds size limit of %s'), formatBytes($maximagesize)) . EOL);
@unlink($src);
return;
@ -159,7 +161,7 @@ function profile_photo_post(App &$a) {
$imagedata = @file_get_contents($src);
$ph = new Photo($imagedata, $filetype);
if(! $ph->is_valid()) {
if (! $ph->is_valid()) {
notice( t('Unable to process image.') . EOL );
@unlink($src);
return;
@ -168,7 +170,6 @@ function profile_photo_post(App &$a) {
$ph->orient($src);
@unlink($src);
return profile_photo_crop_ui_head($a, $ph);
}

View file

@ -113,7 +113,7 @@ function videos_post(App &$a) {
if (($a->argc == 2) && x($_POST,'delete') && x($_POST, 'id')) {
// Check if we should do HTML-based delete confirmation
if(!x($_REQUEST,'confirm')) {
if (!x($_REQUEST,'confirm')) {
if (x($_REQUEST,'canceled')) {
goaway(App::get_baseurl() . '/videos/' . $a->data['user']['nickname']);
}
@ -138,7 +138,6 @@ function videos_post(App &$a) {
$video_id = $_POST['id'];
$r = q("SELECT `id` FROM `attach` WHERE `uid` = %d AND `id` = '%s' LIMIT 1",
intval(local_user()),
dbesc($video_id)
@ -409,4 +408,3 @@ function videos_content(App &$a) {
$o .= paginate($a);
return $o;
}