-
Posts
1,078 -
Joined
-
Last visited
-
Days Won
17
Everything posted by dotnetic
-
Your development environment should have the same prerequisites as on your server. You should have a local web server like Laragon (on Windows) or Xammp installed, and also mirror/replicate the ProcessWire installation with the database from your live server. Then you can make modifications to these local files and upload them to the live server as they are. No conversion needed anymore. I would recommend you to use a translator like deepl.com if you are not very good with english, so your questions can be understood better.
-
How to handle multi-user multi-task scenario?
dotnetic replied to Kiwi Chris's topic in General Support
Under permissions is a setting where you can archive that users can only edit their own created pages. Like I answered here: To prevent page editing and listing pages in a normal lister or ListerPro I use hooks (this can be made in a custom module or in _init.php): $this->addHookAfter('ProcessPageListActions::getActions', $this, 'restrictListerEditAccess'); $this->addHookAfter('ProcessPageEdit::buildForm', $this, 'removeTabs'); $this->addHookAfter('ProcessPageEdit::buildForm', $this, 'restrictEditAccess'); public function restrictEditAccess(HookEvent $event) { // don't do this for superusers if ($this->user->isSuperuser()) { return; } if ($this->config->ajax) { return; } // bd($event->return); $process = $event->object; $page = $process->getPage(); $form = $event->return; if ($condition !== true) { $this->error("Thou shall not pass"); //$this->removeSaveButton($form); return; } } /** * removes edit links from lister it the user has not the correct edit access * @param HookEvent $event * @throws WireException */ public function restrictListerEditAccess(HookEvent $event) { if ($this->user->isSuperuser()) { return; } $page = $event->arguments[0]; $editAccess = $this->hasEditAccess($page); // this is my own function for checking if the user has edit access, in the core there is $page->editable() if ($editAccess === false || $this->user->hasRole('someRole')) { $actions = $event->return; unset($actions['edit']); $event->return = $actions; } } /** * removes tabs in Edit form for specific roles * @param HookEvent $event */ public function removeTabs(HookEvent $event) { if ($this->user->isSuperuser()) return; $p = $event->object->getPage(); $form = $event->return; // bd($form); $fieldset = $form->find("id=ProcessPageEditChildren")->first(); if (is_object($fieldset)) { $form->remove($fieldset); $event->object->removeTab('ProcessPageEditChildren'); } $fieldset = $form->find("id=ProcessPageEditSettings")->first(); if (is_object($fieldset)) { $form->remove($fieldset); $event->object->removeTab('ProcessPageEditSettings'); } $fieldset = $form->find("id=ProcessPageEditDelete")->first(); if (is_object($fieldset)) { $form->remove($fieldset); $event->object->removeTab('ProcessPageEditDelete'); } // hide delete tab $fieldset = $form->find("id=ProcessPageEditDelete")->first(); if (is_object($fieldset)) { $form->remove($fieldset); $event->object->removeTab('ProcessPageEditDelete'); } } -
PW 3.0.142 – Core updates + FormBuilder v40
dotnetic replied to ryan's topic in News & Announcements
I hope I can report back soon, but I am still very busy. Multilanguage is also active in my system. Beside that I also use different hooks to restrict edit and view access, so this might be another culprit. -
Well, yeah, I am using path because of different reasons. Because my images are not available via URL (or only if logged in) as I use pagefileSecure in my config. So the process mPDF has no access to the images, and therefore I use the path.
-
You need to use the disk path instead of the URL foreach ($this->page->getUnformatted($fieldName) as $img) { echo "<img src='{$img->filename}'>"; }
-
Instead use <link href="<?php echo $config->urls->templates; ?>styles/assets/css/font-awesome.min.css" rel="stylesheet" /> and place them in the same folder on your local PC. Or you modfiy the url path to the templates folder in your site/config.php
-
Front End Editing Restricted To Page Creator?
dotnetic replied to prestoav's topic in General Support
Yes, there is a way. Just go to permissions -> add new permission. Then under "Install predefined system permissions" choose "page-edit-created" and maybe even "page-edit-trash-created" if you would like that users can trash their own created pages. After saving, add those permissions to the role/s you want to restrict. I did not checked if this is working in the Frontend editor or Fredi, it is working in the ProcessWire admin.- 2 replies
-
- 2
-
-
- front end edit
- user
-
(and 1 more)
Tagged with:
-
[SOLVED] How to add user and date to an uploaded file?
dotnetic replied to dotnetic's topic in Module/Plugin Development
@bernhard Yeah, I think I will add this. But I had to get it working first. Thanks for the suggestion. -
[SOLVED] How to add user and date to an uploaded file?
dotnetic replied to dotnetic's topic in Module/Plugin Development
Here is my working solution, which looks not exactly as in my example screenshot, because for that I had to use a str_replace. So I added the information below the file. The process is the following: User uploads file. The URL of the file and my custom information string are saved via $page->meta. Then before rendering the PageFile item the URL in the $page->meta is looked up and the custom information appended to the markup. I do this only on pages with a specific template. Here is the code: $this->addHookBefore("InputfieldFile::fileAdded", function ($event) { $pagefile = $event->arguments[0]; //$pagefile->description = "Hochgeladen von {$this->user->name} am " . date("Y-m-d H:i:s"); // not used, because description can be altered by users if ($event->object->data["hasPage"]) { $page = $event->object->data["hasPage"]; if ($page->template->name == "abteilung" || $page->template->name == "fachbereich") { $page->meta($pagefile->url, "Hochgeladen von {$this->user->name} am " . date("m.d.Y H:i:s")); } } }); $this->addHookAfter('InputfieldFile::renderItem', function ($event) { $url = $event->arguments[0]["url"]; $page = $event->object->data["hasPage"]; if ($page->template->name == "abteilung" || $page->template->name == "fachbereich") { $event->return .= "<p>{$page->meta($url)}</p>"; } }); -
[SOLVED] How to add user and date to an uploaded file?
dotnetic replied to dotnetic's topic in Module/Plugin Development
Thanks for your detailed answer, but I can not change the current behavior how or where files are added, because they are already there as pagefiles in thousands of pages. For the next project I think the recently added custom fields for pagefiles are the perfect solution, or the way you described with pages. Using page->meta would be not a good solution in my opinion, because it stores information about the file (uploaded by user) apart from the file itself. I think the best way would be to store the information who uploaded the file into the pagefiles metadata. Now I have to figure out, how to do that. -
[SOLVED] How to add user and date to an uploaded file?
dotnetic replied to dotnetic's topic in Module/Plugin Development
The best way to show the information in my case would be like in the following screenshot. Maybe this information could be saved in the file metadata, but how would I do that? Then I would hook into renderItem of InputfieldFile and change the displayed information. What do you guys think, is this even worth to be implemented into the core and one could choose if this information is shown or not? An option like "Show metadata on files and images". I also want to get the last file a specific user uploaded. So if multiple users uploaded files to one (same) page, I want to get the last file that user X has uploaded. -
[SOLVED] How to add user and date to an uploaded file?
dotnetic replied to dotnetic's topic in Module/Plugin Development
@bernhard Regarding a log module: I wrote a hook that logs all deletion of pages into a log file. This is very easy to accomplish. Depending on what you want to log, this can be a big task or a small one. Are you aware of MarkupActivityLog, which logs changes to a page? But maybe that's not what you want, as you talked about admin (superuser) related activities. -
[SOLVED] How to add user and date to an uploaded file?
dotnetic replied to dotnetic's topic in Module/Plugin Development
My goal is to show which user uploaded a file and when in the PW admin when editing a page. Custom fields for files/images in ProcessWire 3.0.142 seem to be a solution for this, but I have to test them a little bit more in my environment, but they seem to work fine in a fresh install. -
PW 3.0.142 – Core updates + FormBuilder v40
dotnetic replied to ryan's topic in News & Announcements
*Facepalm* I did not upload an image in the second example *ROFL* . It has been 3 long weeks without resting, please forgive me. After uploading an image, the fields appear. I will test it out further tomorrow. -
Hey @horst Your solution is very similar how scripts like https://github.com/aik099/PhpStormProtocol work. As mentioned before this is a workaround and a hacky way, and my solution provides a native alternative which works. I am not searching for another hacky solution, I just wanted to provide a native way of handling URI schemes in Tracy Debuger
-
PW 3.0.142 – Core updates + FormBuilder v40
dotnetic replied to ryan's topic in News & Announcements
First of all: Great additions and exactly what I just need for a project. But somehow the new custom fields for images and files do not seem to work correctly. I integrated them into an existing PW project and the fields appear for the superuser, and also for other roles... But: the other roles don't see the text that the superuser entered. Then I tried saving a value to a custom field with another user, and the value isn't saved. So I thought, because I have a complicated setup with many hooks and restrictions that hook into ProcessPage::buildForm I try out the new feature on a completely fresh PW installation. But in the new installation the custom fields don't even appear. Am I doing something wrong? Is this a bug? Here is a little screencast of my existing project (with audio) And here is a fresh PW install, where it do the setup process of the custom field, and then it does not show up (without audio): -
Try setting it to off "$config->sessionFingerprint = 0;" and see if you experience any differences
-
What did you write into your site/config.php?
-
Yes. If you look into the file https://github.com/aik099/PhpStormProtocol/blob/master/PhpStorm Protocol (Win)/run_editor.js there are two variables you have to change and if you are using Jetbrain Toolbox to install and update your IDE, then even the paths in https://github.com/aik099/PhpStormProtocol/blob/master/PhpStorm Protocol (Win)/run_editor.js#L22 are completely different.
-
It is up to you Adrian, but my solution is a native one and the other one is a hacky solution which also requires modifiying the .js file.
-
Yeah thought often about it, but PHPStorm offers me features that VScode does not have (yet) or are not that comfortable and that are important for me. And I don't switch my editor/IDE just because of this small issue.
-
Please read
-
Hello folks, I want to save the information which user uploaded a file and also a date in the PW admin. I thought I could use the description field for this information, but how do I set it via a hook and how do I prevent users from editing the description? I tried the following hook which does not set the content of the description field (seems to be not a property of the InputfieldFile, but an individual field). /** * if this is a fachbereich or abteilung add a hook to prevent file deletion * @param HookEvent $event */ public function hookPageFile(HookEvent $event) { // if ($this->user->isSuperuser() || $this->user->hasRole('restricted-admin')) { // return; // } $page = $event->object->getPage(); // Only use on pages with the raum template if (($page->template == 'fachbereich' || $page->template == 'abteilung') && !$page->isTrash()) { $this->addHookAfter('InputfieldFile::processInputFile', function(HookEvent $event) { // Get the object the event occurred on, if needed $InputfieldFile = $event->object; $InputfieldFile->description="no description"; bd($InputfieldFile, "processInputFile"); }); $this->addHookBefore('InputfieldFile::processInputDeleteFile', $this, 'preventFileDelete'); } } The hook should also be only executed on pages with a specific template, so that's why I use $this->addHookBefore('ProcessPageEdit::buildForm', $this, 'hookPageFile'); Is this even possible, or should I take a completely different route? Maybe save the inputfield_id, filename and created_user in a separate database table? But this would complicate things, because on the output side I have to query the custom database instead of using just the description field. Maybe I can use the just added custom fields for files/imags in ProcessWire 3.0.142 for this? But how do I set the values in the admin for them and prevent changing them by the user? Think I have to test this out. EDIT: Found a solution with the help of the nice guys in this forum. You can find it here: https://processwire.com/talk/topic/22411-how-to-add-user-and-date-to-an-uploaded-file-help-urgently-needed/?do=findComment&comment=192363
-
[SOLVED] How to set access toggles of a field via API?
dotnetic replied to dotnetic's topic in API & Templates
Thanks. This was also answered here: -
@bernhard The first solutions you provided does the same as Nette's script.