Skip to content

Commit

Permalink
Merge branch 'e107inc:master' into emailprint_button_template
Browse files Browse the repository at this point in the history
  • Loading branch information
rica-carv authored Jan 19, 2025
2 parents 1b16be7 + 61104c5 commit 613c3f7
Show file tree
Hide file tree
Showing 14 changed files with 137 additions and 34 deletions.
7 changes: 7 additions & 0 deletions class2.php
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,13 @@ function systemTimeZoneIsValid($zone = '')
define('e_REFERER_SELF', false);
}

if(deftrue('USER') && !e107::isCli())
{
if (check_class(varset($pref['user_audit_class']))) // Need to note in user audit trail
{
e107::getLog()->user_audit(USER_AUDIT_NAVIGATION, e_REQUEST_URI, USERID, USERNAME);
}
}

/**
* @deprecated Use e107::getRedirect()->go($url) instead.
Expand Down
6 changes: 3 additions & 3 deletions e107_admin/admin_log.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,10 +486,10 @@ function user_audit_opts($curVal,$mode)
// define('USER_AUDIT_BANNED', 22); // User banned
// define('USER_AUDIT_BOUNCE_RESET', 23); // User bounce reset
// define('USER_AUDIT_TEMP_ACCOUNT', 24); // User temporary account

$RL_LAN_136 = defset('RL_LAN_136', "User navigation trail");

$audit_checkboxes = array(USER_AUDIT_SIGNUP => RL_LAN_071, USER_AUDIT_EMAILACK => RL_LAN_072,
USER_AUDIT_LOGIN => LAN_AUDIT_LOG_013, USER_AUDIT_LOGOUT => LAN_AUDIT_LOG_014, // Logout is lumped in with login
USER_AUDIT_LOGIN => LAN_AUDIT_LOG_013, USER_AUDIT_LOGOUT => LAN_AUDIT_LOG_014, USER_AUDIT_NAVIGATION => $RL_LAN_136, // Logout is lumped in with login
USER_AUDIT_NEW_DN => RL_LAN_075, USER_AUDIT_NEW_PW => RL_LAN_076, USER_AUDIT_PW_RES => RL_LAN_078, USER_AUDIT_NEW_EML => RL_LAN_077, USER_AUDIT_NEW_SET => RL_LAN_079,
USER_AUDIT_ADD_ADMIN => RL_LAN_080, USER_AUDIT_MAIL_BOUNCE => RL_LAN_081, USER_AUDIT_BANNED => RL_LAN_082, USER_AUDIT_BOUNCE_RESET => RL_LAN_083,
USER_AUDIT_TEMP_ACCOUNT => RL_LAN_084);
Expand Down Expand Up @@ -683,7 +683,7 @@ function dblog_remarks($curVal,$mode)
{
$id = $this->getController()->getListModel()->get('dblog_id');
$ret ="<a class='e-expandit' href='#rem-".$id."'>".RL_LAN_087."</a>";
$ret .= "<div style='display:none;width:33vw' id='rem-".$id."'>";
$ret .= "<div class='logcanvas' style='display:none;width:33vw' id='rem-".$id."'>";
$text = str_replace("<br />","\n",$text);
$text = str_replace("&#092;","/",$text);

Expand Down
2 changes: 1 addition & 1 deletion e107_admin/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
// Required for a clean v1.x -> v2 upgrade.
$core = e107::getConfig();
$adminTheme = $core->get('admintheme');
if($adminTheme !== 'bootstrap3'/* && $adminTheme !== 'bootstrap5'*/)
if($adminTheme !== 'bootstrap3' && $adminTheme !== 'bs5')
{
$core->update('admintheme','bootstrap3');
$core->update('adminstyle','infopanel');
Expand Down
2 changes: 1 addition & 1 deletion e107_admin/image.php
Original file line number Diff line number Diff line change
Expand Up @@ -3079,7 +3079,7 @@ function avatarPage()
$text .= "</div>
<div class='col-md-12 spacer clearfix'>
<div class='row buttons-bar'>
<div class='buttons-bar'>
<input type='hidden' name='show_avatars' value='1' />
".$frm->admin_button('e_check_all', LAN_CHECKALL, 'action'). '
' .$frm->admin_button('e_uncheck_all', LAN_UNCHECKALL, 'action'). '
Expand Down
4 changes: 3 additions & 1 deletion e107_core/shortcodes/batch/admin_shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -2617,12 +2617,14 @@ public function sc_admin_menumanager($parm=null) // List all menu-configs for e
e107::setRegistry('core/e107/menu-manager/curLayout',$action);

$icon = e107::getParser()->toIcon('e-menus-24');
$caption = $icon. '<span>' .ADLAN_6. '</span>';
$caption = '<span>' .ADLAN_6. '</span>';

$diz = MENLAN_58;

$caption .= "<span class='e-help-icon pull-right'><a data-placement=\"bottom\" class='e-tip' title=\"".e107::getParser()->toAttribute($diz). '">' .defset('ADMIN_INFO_ICON'). '</a></span>';

$var['_extras_']['icon'] = e107::getParser()->toIcon('e-menus-24');

return e107::getNav()->admin($caption,$action, $var);


Expand Down
1 change: 1 addition & 0 deletions e107_handlers/admin_log_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public function __construct($options = array())
define('USER_AUDIT_BANNED', 22); // User banned
define('USER_AUDIT_BOUNCE_RESET', 23); // User bounce reset
define('USER_AUDIT_TEMP_ACCOUNT', 24); // User temporary account
define('USER_AUDIT_NAVIGATION', 25); // User signed up

}
// Init E_MESSAGE_* constants if not already done
Expand Down
39 changes: 36 additions & 3 deletions e107_handlers/e_parse_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -4395,10 +4395,18 @@ public function toAvatar($userData = null, $options = array())

if (!empty($options['base64'])) // embed image data into URL.
{
$content = e107::getFile()->getRemoteContent($url); // returns false during unit tests, works otherwise.
$content = e107::getFile()->getRemoteContent($url);
if (!empty($content))
{
$ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
if(!empty($file))
{
$ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
}
else
{
$ext = strtolower(pathinfo($url, PATHINFO_EXTENSION));
}

$url = 'data:image/' . $ext . ';base64,' . base64_encode($content);
}
}
Expand Down Expand Up @@ -4923,7 +4931,27 @@ public function toAudio($file, $parm = array())

$file = $this->replaceConstants($file, 'abs');

$mime = varset($parm['mime'], 'audio/mpeg');
$ext = pathinfo($file, PATHINFO_EXTENSION);

switch (strtolower($ext))
{

case 'wav':
$mime = 'audio/wav';
break;
case 'ogg':
$mime = 'audio/ogg';
break;
case 'mp3':
default:
$mime = 'audio/mpeg';
break;
}

if(!empty($parm['mime']))
{
$mime = $parm['mime'];
}

$autoplay = !empty($parm['autoplay']) ? 'autoplay ' : '';
$controls = !empty($parm['controls']) ? 'controls' : '';
Expand Down Expand Up @@ -5084,6 +5112,11 @@ public function toVideo($file, $parm = array())
$height = varset($parm['h'], 240);
$mime = varset($parm['mime'], 'video/mp4');

if($height === 0)
{
$height = 'auto';
}

return '
<div class="video-responsive">
<video width="' . $width . '" height="' . $height . '" controls>
Expand Down
3 changes: 2 additions & 1 deletion e107_handlers/media_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,8 @@ public function previewTag($default, $options=array())
{

case "video":
$preview = $tp->toVideo($default, array('w'=>$width, 'h'=> ($height - 50)));
$h = (!is_numeric($height) || $height < 1) ? 0 : ($height - 50);
$preview = $tp->toVideo($default, array('w'=>$width, 'h'=>$h ));
break;

case "audio":
Expand Down
6 changes: 3 additions & 3 deletions e107_handlers/theme_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2599,17 +2599,17 @@ function renderTheme($mode = 0, $theme = array())
$text .= "
<ul class='nav nav-tabs'>
<li class='active'><a data-toggle='tab' data-bs-toggle='tab' href='#core-thememanager-configure'>".LAN_CONFIGURE."</a></li>";
<li class='nav-item active'><a class='nav-link active' data-toggle='tab' data-bs-toggle='tab' href='#core-thememanager-configure'>".LAN_CONFIGURE."</a></li>";


if($this->themeConfigObj && call_user_func(array(&$this->themeConfigObj, 'config')) && $mode == self::RENDER_SITEPREFS)
{
$text .= "<li><a data-toggle='tab' data-bs-toggle='tab' href='#core-thememanager-customconfig'>".LAN_PREFS."</a></li>\n";
$text .= "<li class='nav-item'><a class='nav-link' data-toggle='tab' data-bs-toggle='tab' href='#core-thememanager-customconfig'>".LAN_PREFS."</a></li>\n";
}

if($this->themeConfigObj && call_user_func(array(&$this->themeConfigObj, 'help')))
{
$text .= "<li><a data-toggle='tab' data-bs-toggle='tab' href='#core-thememanager-help'>".LAN_HELP."</a></li>\n";
$text .= "<li class='nav-item'><a class='nav-link' data-toggle='tab' data-bs-toggle='tab' href='#core-thememanager-help'>".LAN_HELP."</a></li>\n";
}

$text .= "</ul>
Expand Down
2 changes: 2 additions & 0 deletions e107_languages/English/admin/lan_admin_log.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,7 @@
define("RL_LAN_133", "Notice");
define("RL_LAN_134", "Warning");
define("RL_LAN_135", "Fatal");

define("RL_LAN_136", "User navigation trail");
// define("RL_LAN_JS_CONFIRM", "Are you sure?");

2 changes: 1 addition & 1 deletion e107_languages/English/admin/lan_log_messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
define("LAN_AUDIT_LOG_022", "User banned");
define("LAN_AUDIT_LOG_023", "User bounce reset");
define("LAN_AUDIT_LOG_024", "User temporary status");

define("LAN_AUDIT_LOG_025", "User navigation trail");

// Admin log events
//-----------------
Expand Down
18 changes: 9 additions & 9 deletions e107_plugins/download/includes/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -1297,9 +1297,9 @@ function create_download()
$text = "
<ul class='nav nav-tabs'>
<li class='active'><a data-toggle='tab' data-bs-toggle='tab' href='#download-create'>".DOWLAN_175."</a></li>
<li><a data-toggle='tab' data-bs-toggle='tab' href='#download-edit-external'>".DOWLAN_176."</a></li>
<li><a data-toggle='tab' data-bs-toggle='tab' href='#download-edit-mirror'>".DOWLAN_128."</a></li>
<li class='nav-item active'><a class='nav-link active' data-toggle='tab' data-bs-toggle='tab' href='#download-create'>".DOWLAN_175."</a></li>
<li class='nav-item'><a class='nav-link' data-toggle='tab' data-bs-toggle='tab' href='#download-edit-external'>".DOWLAN_176."</a></li>
<li class='nav-item'><a class='nav-link' data-toggle='tab' data-bs-toggle='tab' href='#download-edit-mirror'>".DOWLAN_128."</a></li>
</ul>
<form method='post' action='".e_SELF."?".e_QUERY."' id='myform'>
<div class='tab-content'>
Expand Down Expand Up @@ -2181,11 +2181,11 @@ function show_download_options()
$text = "
<ul class='nav nav-tabs'>
<li class='active'><a data-toggle='tab' data-bs-toggle='tab' href='#core-download-download1'>".LAN_DL_DOWNLOAD_OPT_GENERAL."</a></li>
<li><a data-toggle='tab' data-bs-toggle='tab' href='#core-download-download2'>".LAN_DL_DOWNLOAD_OPT_BROKEN."</a></li>
<li><a data-toggle='tab' data-bs-toggle='tab' href='#core-download-download3'>".LAN_DL_DOWNLOAD_OPT_AGREE."</a></li>
<li><a data-toggle='tab' data-bs-toggle='tab' href='#core-download-download4'>".LAN_DL_DOWNLOAD_OPT_SECURITY."</a></li>
<li><a data-toggle='tab' data-bs-toggle='tab' href='#core-download-download5'>".LAN_DL_UPLOAD."</a></li>
<li class='nav-item active'><a class='nav-link active' data-toggle='tab' data-bs-toggle='tab' href='#core-download-download1'>".LAN_DL_DOWNLOAD_OPT_GENERAL."</a></li>
<li class='nav-item'><a class='nav-link' data-toggle='tab' data-bs-toggle='tab' href='#core-download-download2'>".LAN_DL_DOWNLOAD_OPT_BROKEN."</a></li>
<li class='nav-item'><a class='nav-link' data-toggle='tab' data-bs-toggle='tab' href='#core-download-download3'>".LAN_DL_DOWNLOAD_OPT_AGREE."</a></li>
<li class='nav-item'><a class='nav-link' data-toggle='tab' data-bs-toggle='tab' href='#core-download-download4'>".LAN_DL_DOWNLOAD_OPT_SECURITY."</a></li>
<li class='nav-item'><a class='nav-link' data-toggle='tab' data-bs-toggle='tab' href='#core-download-download5'>".LAN_DL_UPLOAD."</a></li>
</ul>
<form method='post' action='".e_SELF."?".e_QUERY."'>\n
Expand Down Expand Up @@ -2657,7 +2657,7 @@ public function afterDelete($deleted_data, $id, $deleted_check)
public function renderHelp()
{
$help_text = str_replace("[br]", "<br />", DOWLAN_HELP_11);
$help_text = str_replace(array("[", "]"), array("<a href='".e_ADMIN_ABS."notify.php'>"), $help_text);
$help_text = str_replace(array("[", "]"), array("<a href='".e_ADMIN_ABS."notify.php'>", "</a>"), $help_text);

return array('caption' => LAN_HELP, 'text' => $help_text);
}
Expand Down
2 changes: 1 addition & 1 deletion e107_plugins/forum/forum_admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ public function afterDelete($deleted_data, $id, $deleted_check)
public function renderHelp()
{
$help_text = str_replace("[br]", "<br />", FORLAN_189);
$help_text = str_replace(array("[", "]"), array("<a href='".e_ADMIN_ABS."notify.php'>"), $help_text);
$help_text = str_replace(array("[", "]"), array("<a href='".e_ADMIN_ABS."notify.php'>", "</a>"), $help_text);

return array('caption' => LAN_HELP, 'text' => $help_text);
}
Expand Down
77 changes: 67 additions & 10 deletions e107_tests/tests/unit/e_parseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2433,16 +2433,24 @@ public function testToAvatar()
'alt="mytitle"',
)
),
/** @fixme - doesn't pass under CLI */
/*

7 => array(
'input' => array('user_image'=>'avatartest.png'),
'parms' => array('w'=>50, 'h'=>50, 'crop'=>true, 'base64'=>true, 'shape'=>'circle'),
'expected' => array(
"src='data:image/png;base64,",
"class='img-circle user-avatar'"
"class='img-circle rounded-circle user-avatar'"
)
),

8 => array(
'input' => array('user_image'=>'https://e107.org/e107_images/generic/blank_avatar.jpg'), // Test remote avatar
'parms' => array('w'=>50, 'h'=>50, 'crop'=>true, 'base64'=>true, 'shape'=>'circle'),
'expected' => array(
"src='data:image/jpg;base64,",
"class='img-circle rounded-circle user-avatar'"
)
),*/
),


);
Expand All @@ -2452,7 +2460,7 @@ public function testToAvatar()
$result = $this->tp->toAvatar($var['input'], $var['parms']);
foreach ($var['expected'] as $str)
{
$this->assertStringContainsString($str, $result, "Failed on index #" . $index);
self::assertStringContainsString($str, $result, "Failed on index #" . $index);
}
}

Expand Down Expand Up @@ -2651,15 +2659,64 @@ public function testtoAudio()
</audio>';

$result = $this->tp->toAudio('{e_MEDIA}myfile.mp3');
$this->assertEquals($expected, $result);
self::assertEquals($expected, $result);

$expected = '<audio controls style="max-width:100%" >
<source src="/e107_media/000000test/myfile.wav" type="audio/wav">
Your browser does not support the audio tag.
</audio>';

$result = $this->tp->toAudio('{e_MEDIA}myfile.wav');
self::assertEquals($expected, $result);

// Override mime.
$expected = '<audio controls style="max-width:100%" >
<source src="/e107_media/000000test/myfile.php" type="audio/wav">
Your browser does not support the audio tag.
</audio>';

$result = $this->tp->toAudio('{e_MEDIA}myfile.php', ['mime' => 'audio/wav']);
self::assertEquals($expected, $result);

}

/*
public function testToVideo()
{

}*/
public function testToVideo()
{
$tests = [
0 => [
'file' => '{e_MEDIA}myfile.mp4',
'parms' =>[],
'expected' => '<video width="320" height="240" controls>'
],

1 => [
'file' => '{e_MEDIA}myfile.mp4',
'parms' =>['w'=>500],
'expected' => '<video width="500" height="240" controls>'
],

2 => [
'file' => '{e_MEDIA}myfile.mp4',
'parms' =>['w'=>300, 'h'=>0],
'expected' => '<video width="300" height="auto" controls>'
],

3 => [
'file' => '{e_MEDIA}myfile.mp4',
'parms' =>['w'=>300, 'h'=>'auto'],
'expected' => '<video width="300" height="auto" controls>'
],
];

foreach ($tests as $index => $var)
{
$result = $this->tp->toVideo($var['file'], $var['parms']);
self::assertStringContainsString($var['expected'], $result, 'Failed on index #'.$index);
}


}

public function testMakeClickable()
{
Expand Down

0 comments on commit 613c3f7

Please sign in to comment.