Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/client work u ipatches #216

Merged
merged 7 commits into from
Nov 9, 2023
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

function display_favorites(\Web $w)
{
$results = FavoriteService::getInstance($w)->getFavoritesForUser(AuthService::getInstance($w)->user()->id);
$results = \FavoriteService::getInstance($w)
->getFavoritesForUser(\AuthService::getInstance($w)->user()->id);
$categorisedFavorites = array();
if (!empty($results)) {
foreach ($results as $k => $favorite) {
Expand Down
1 change: 1 addition & 0 deletions system/modules/file/actions/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@ function edit_GET(Web $w) {
$w->ctx("is_restricted", json_encode(empty($owner) ? false : true));
$w->ctx("viewers", json_encode($viewers));
$w->ctx("owner", json_encode(["id" => empty($owner) ? null : $owner->id, "name" => empty($owner) ? null : $owner->getFullName()]));
$w->ctx("show_restrict", Request::string("allowrestrictionui"));
$w->ctx("can_restrict", AuthService::getInstance($w)->user()->hasRole("restrict") ? "true" : "false");
}
1 change: 1 addition & 0 deletions system/modules/file/partials/actions/attachment_item.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ function attachment_item_GET(\Web $w, $params)
$w->ctx("owner", \RestrictableService::getInstance($w)->getOwner($params["attachment"]));
$w->ctx("redirect", $params["redirect"]);
$w->ctx("image_data_blocked", $params["hide_image_exif"] ?? false);
$w->ctx("edit_attachment_restrictions_blocked", $params["hide_edit_restriction"] ?? false);
$w->ctx("is_mutable", $params["is_mutable"] ?? true);
}
1 change: 1 addition & 0 deletions system/modules/file/partials/actions/listattachments.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function listattachments(\Web $w, $params)
"attachment" => $attachment,
"redirect" => $redirect,
"hide_image_exif" => $params["hide_image_exif"] ?? false,
"hide_edit_restriction" => $params["hide_edit_restriction"] ?? false,
"is_mutable" => $params["is_mutable"] ?? true,
], "file", "GET");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</div>
<div class="row-fluid">
<?php echo ($is_mutable)
? (Html::box("/file/edit/" . $attachment->id . "?redirect_url=" . urlencode($redirect), "Edit", true, null, null, null, null, null, "button expand secondary"))
? (Html::box("/file/edit/" . $attachment->id . "?allowrestrictionui=" . empty($edit_attachment_restrictions_blocked) . "&redirect_url=" . urlencode($redirect), "Edit", true, null, null, null, null, null, "button expand secondary"))
: ""; ?>
</div>
<div class="row-fluid">
Expand Down
3 changes: 2 additions & 1 deletion system/modules/file/templates/edit.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<label style="font-size: 18px;">Description
<input type="text" id="description" v-model="description"/>
</label><br>
<div v-if="can_restrict">
<div v-if="can_restrict && show_restrict">
<label class="cmfive__checkbox-container">Restricted
<input type="checkbox" v-model="is_restricted">
<span class="cmfive__checkbox-checkmark"></span>
Expand Down Expand Up @@ -47,6 +47,7 @@
return {
id: "<?php echo $id; ?>",
can_restrict: "<?php echo $can_restrict; ?>",
show_restrict: "<?php echo $show_restrict; ?>",
viewers: <?php echo empty($viewers) ? json_encode([]) : $viewers; ?>,
new_owner: <?php echo empty($new_owner) ? json_decode([]) : $new_owner; ?>,
title: "<?php echo $title; ?>",
Expand Down
11 changes: 10 additions & 1 deletion system/modules/form/partials/templates/listform.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
<thead>
<tr><?php echo $form->getTableHeaders(); ?>
<?php if ($display_only !== true) : ?>
<td>Actions</td><?php endif; ?></tr>
<td>Actions</td><?php endif; ?>
</tr>
</thead>
<tbody>
<tr v-if='!instances'>
Expand Down Expand Up @@ -63,6 +64,14 @@
watch: {
page: function() {
this.getInstances();
},
instances: function() {
this.$nextTick(() => {
document.querySelectorAll('#form_list_<?php echo $form->id; ?> [data-modal-target]').forEach(function(m) {
m.removeEventListener('click', boundModalListener);
m.addEventListener('click', boundModalListener);
})
});
}
},
created: function() {
Expand Down
184 changes: 95 additions & 89 deletions system/modules/help/actions/view.php
Original file line number Diff line number Diff line change
@@ -1,109 +1,115 @@
<?php
function view_GET(Web &$w) {
$p = $w->pathMatch("m","a");
// first see if we need to split into sub modules
$module = $p['m'];
$action = $p['a'];
function view_GET(Web &$w)
{
$p = $w->pathMatch("m", "a");
// first see if we need to split into sub modules
$module = $p['m'];
$action = $p['a'];

// check if help is allowed for this topic
if (!AuthService::getInstance($w)->allowed($p['m'].'/'.$p['a'])) {
$w->ctx("help_content","Sorry, there is no help for this topic.");
}
// check if help is allowed for this topic
if (!AuthService::getInstance($w)->allowed($p['m'] . '/' . $p['a'])) {
$w->ctx("help_content", "Sorry, there is no help for this topic.");
}

$submodule = "";
// check for submodule
if (strcontains($p['m'], array("-"))) {
$ms = explode("-", $p['m']);
$module = $ms[0];
$submodule = $ms[1];
}
$submodule = "";
// check for submodule
if (strcontains($p['m'], array("-"))) {
$ms = explode("-", $p['m']);
$module = $ms[0];
$submodule = $ms[1];
}

// find a module toc
$tocf = getHelpFileContent($w, $module,null,$module."_toc");
if ($tocf) {
$w->ctx("module_toc",$module.'/'.$module."_toc");
$w->ctx("module_title",HelpLib::extractTitle($tocf));
}
// find a module toc
$tocf = getHelpFileContent($w, $module, null, $module . "_toc");
if ($tocf) {
$w->ctx("module_toc", $module . '/' . $module . "_toc");
$w->ctx("module_title", HelpLib::extractTitle($tocf));
}

// load help file
$help_file = HelpLib::getHelpFilePath($w,$module,$submodule,$action);
$content = "Sorry, this help topic is not yet written.";
if (file_exists($help_file)) {
$content = file_get_contents($help_file);
}
// load help file
$help_file = HelpLib::getHelpFilePath($w, $module, $submodule, $action);
$content = "Sorry, this help topic is not yet written.";
if (!empty($help_file) && file_exists($help_file)) {
$content = file_get_contents($help_file);
}


// set context
$w->ctx("help_content",helpMarkup(pruneRestricted($w, $content),$module));
$w->ctx("module",$module);
$w->ctx("submodule",$submodule);
$w->ctx("action",$action);
// set context
$w->ctx("help_content", helpMarkup(pruneRestricted($w, $content), $module));
$w->ctx("module", $module);
$w->ctx("submodule", $submodule);
$w->ctx("action", $action);
}

/**
* Remove restricted paragraphs from help file
* So that only parts are left which the user is
* allowed to see
*
* restricted parts are marked as:
*
* [[restricted|role1,role2,role3...]]
* restricted text paragraph
* [[endrestricted]]
*
* @param Web $w
* @param string $content
*/
function pruneRestricted($w,$content) {
$c = "";
$restricted = false;
foreach (explode("\r\n", $content) as $l) {
if (preg_match_all("/\[\[restricted\|(.*?)\]\]/", $l, $matches)) {
$roles = explode(',',$matches[1][0]);
if (!AuthService::getInstance($w)->user()->hasAnyRole($roles)) {
$restricted = true;
}
} else if (startsWith($l, "[[endrestricted]]")) {
$restricted = false;
} else if (!$restricted) {
$c .= $l."\r\n";
}
}
return $c;
* Remove restricted paragraphs from help file
* So that only parts are left which the user is
* allowed to see
*
* restricted parts are marked as:
*
* [[restricted|role1,role2,role3...]]
* restricted text paragraph
* [[endrestricted]]
*
* @param Web $w
* @param string $content
*/
function pruneRestricted($w, $content)
{
$c = "";
$restricted = false;
foreach (explode("\r\n", $content) as $l) {
if (preg_match_all("/\[\[restricted\|(.*?)\]\]/", $l, $matches)) {
$roles = explode(',', $matches[1][0]);
if (!AuthService::getInstance($w)->user()->hasAnyRole($roles)) {
$restricted = true;
}
} else if (startsWith($l, "[[endrestricted]]")) {
$restricted = false;
} else if (!$restricted) {
$c .= $l . "\r\n";
}
}
return $c;
}

function replaceImage($content, $module) {
$img = '<img src="'.WEBROOT.'/help/media/'.$module.'/\\1" border="0"/>';
return preg_replace("/\[\[img\|(.*?)\]\]/", $img, $content);
function replaceImage($content, $module)
{
$img = '<img src="' . WEBROOT . '/help/media/' . $module . '/\\1" border="0"/>';
return preg_replace("/\[\[img\|(.*?)\]\]/", $img, $content);
}

function getHelpFileContent(Web &$w,$module,$submodule,$action) {
$p = HelpLib::getHelpFilePath($w,$module, $submodule, $action);
if ($p) {
return file_get_contents($p);
}
return null;
function getHelpFileContent(Web &$w, $module, $submodule, $action)
{
$p = HelpLib::getHelpFilePath($w, $module, $submodule, $action);
if ($p) {
return file_get_contents($p);
}
return null;
}


function replaceVideo($content,$module) {
$video = "<span style=\" -moz-border-radius: 6px;
-moz-box-shadow: 0 0 14px #123;
display: -moz-inline-stack;
display: inline-block;
border: 2px solid black;\">";
$video .= '<a href="'.WEBROOT.'/help/media/'.$module.'/\\2" style="display:block;width:700px;height:394px;" id="video\\1"></a>';
$video .= '<script language="JavaScript">flowplayer("video\\1", "'.WEBROOT.'/js/flowplayer/flowplayer-3.2.5.swf", {clip: {autoPlay:false, autoBuffering:true, scaling:"fit"}});</script>';
$video .= "</span>";
return preg_replace("/\[\[video\|(.*?)\|(.*?)\]\]/", $video, $content);
function replaceVideo($content, $module)
{
$video = "<span style=\" -moz-border-radius: 6px;
-moz-box-shadow: 0 0 14px #123;
display: -moz-inline-stack;
display: inline-block;
border: 2px solid black;\">";
$video .= '<a href="' . WEBROOT . '/help/media/' . $module . '/\\2" style="display:block;width:700px;height:394px;" id="video\\1"></a>';
$video .= '<script language="JavaScript">flowplayer("video\\1", "' . WEBROOT . '/js/flowplayer/flowplayer-3.2.5.swf", {clip: {autoPlay:false, autoBuffering:true, scaling:"fit"}});</script>';
$video .= "</span>";
return preg_replace("/\[\[video\|(.*?)\|(.*?)\]\]/", $video, $content);
}
function helpMarkup($content,$module) {
$content = str_replace("\r\n\r\n", "<p>", $content);
$content = preg_replace("/\[\[title\|(.*?)\]\]/", "<h2>\\1</h2>", $content);
$content = preg_replace("/\[\[button\|(.*?)\]\]/", "<button>\\1</button>", $content);
$content = preg_replace("/\[\[help\|(.*?)\|(.*?)\]\]/",'<a href="'.WEBROOT.'/help/view/\\1">\\2</a>', $content);
function helpMarkup($content, $module)
{
$content = str_replace("\r\n\r\n", "<p>", $content);
$content = preg_replace("/\[\[title\|(.*?)\]\]/", "<h2>\\1</h2>", $content);
$content = preg_replace("/\[\[button\|(.*?)\]\]/", "<button>\\1</button>", $content);
$content = preg_replace("/\[\[help\|(.*?)\|(.*?)\]\]/", '<a href="' . WEBROOT . '/help/view/\\1">\\2</a>', $content);

$content = replaceImage($content,$module);
$content = replaceVideo($content,$module);
return $content;
$content = replaceImage($content, $module);
$content = replaceVideo($content, $module);
return $content;
}
7 changes: 6 additions & 1 deletion system/modules/search/actions/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

function index_ALL(Web &$w) {
// $w->out(print_r(SearchService::getInstance($w)->getIndexes(),true));
$w->ctx("indexes", SearchService::getInstance($w)->getIndexes());
$indexes = SearchService::getInstance($w)->getIndexes();
$selIndexes = [];
foreach ($indexes as $k => $v) {
$selIndexes[] = [$k,$v];
}
$w->ctx("indexes", $selIndexes);

$tags = [];
if (Config::get('tag.active') == true) {
Expand Down
Loading