Jump to content

kixe

Members
  • Posts

    803
  • Joined

  • Last visited

  • Days Won

    10

Posts posted by kixe

  1. On 7/2/2019 at 12:27 AM, Robin S said:

    @jonassalen, open the ProcessSetupPageName.module file in your code editor and try replacing this section at the top of the createFromFormat() method...

    
    if ($languageID == null && $this->languageSupport == true) $languageID = $this->wire('languages')->getDefault()->id;
    $langID = $this->wire('languages')->get($languageID)->isDefault()? null : $languageID;
    
    if ($this->languageSupport) {
    	$userLang = $this->wire('user')->language;
    	$this->wire('user')->language = $this->wire('languages')->get($languageID);
    }

    ...with...

    
    $langID = null;
    if ($this->languageSupport) {
    	if ($languageID == null) $languageID = $this->wire('languages')->getDefault()->id;
    	$langID = $this->wire('languages')->get($languageID)->isDefault()? null : $languageID;
    	$userLang = $this->wire('user')->language;
    	$this->wire('user')->language = $this->wire('languages')->get($languageID);
    }

     

    Sorry for not looking in here. I replaced the code as recommended by @Robin S without further testing and hope it works well now. I didn't use the module by myself for a long time. Stay healthy!

    • Like 1
  2. On 1/11/2020 at 3:00 PM, JFn said:

    Example with dutch locale: hsl(195, 96,2%, 59%);
    Should always be: hsl(195, 96.2%, 59%); no matter the chosen locale.

    This bug is fixed now. Current module version 1.1.4

    • Like 1
  3. Do not use FieldtypeInteger for Phonenumbers, because the Mysql Datatype is INT and therefore the value is limited to 4 bytes strings (32bit).
    You can use FieldtypeInteger only for numbers within the range from -2147483647 to 2147483647.

    Use builtin FieldtypeText or FieldtypePhone (3d Party Module) for Phonenumbers.
    The value of FieldtypePhone must be an instance of Phone (WireData derived object) otherwise it will be set to blank value. From the code:

        /**
         * If value not of instance Phone return empty instance
         */

     

    • Like 1
  4. As far I can see it is possible to change it in the DB. After a quick research I couldn't find any place where this would cause problems (maybe in 3d party modules?). But still I wouldn't do that.

    If you just want the value for the label, why not taking it from the homepage name, representing the language in the url.

    foreach ($languages as $l) echo $pages->get(1)->localName($l);

     

    • Like 2
  5. For the sake of completeness. Hooks in ProcessPageView are also possible if the hook is placed in the /site/init.php file.

    Example:

    // pick up $_GET['it'] (requested uri) before unset
    wire()->addHookBefore('ProcessPageView::execute', function($e) {
        var_dump($_GET['it']);
    });

     

    • Like 1
  6. 9 hours ago, Robin S said:

    That sounds like an issue that should perhaps be fixed in the core - when redirecting due to lack of access I don't think this should be permanent redirect because as you say the user may just need to log in and then they should have access. Maybe you can create a GitHub issue for this to get Ryan's take?

    I don't think this is a PW issue. I am playing around a bit with this behaviour. The problem is, browsers does not handle this consistent and there does not exist a proper status header. Something like a combination of 401 and 302 (e.g. "Moved Login required") would match this situation. Browsers should never cache those redirects and search engines should handle this also without disadvantages. This does not exist.

    Another workaround without redirect should work with the following hook in init.php

    // render login for guest users trying to access a disallowed page without redirect
    wire()->addHookAfter('ProcessPageView::ready', function($e) {
    	if ($this->wire('user')->isSuperuser() || $this->wire('user')->hasRole('client')) return;
    	$pid = $this->wire('page')->id;
    	$disallowedPageIDs = array(1582, 5584, 5342, 1133, 1607, 5374, 6075, 6605);
    	if (in_array($pid, $disallowedPageIDs)) {
    		$login = $this->wire('pages')->get('/login/');
    		$this->wire('page', $login);
    	}
    });

     

  7. I came across this post because I had this redirect problem in a production environment. I could reproduce this in Firefox. The problem also occurs in IE.

    I have a template that can only be viewed by users with a specific role.
    Based on the template settings, an unregistered user or a user who does not have the required role will be redirected to a different URL (301).
    This is done by ProcessPageView::execute().
    If the user tried to access the page before logging in and therefore has been redirected once, the redirect will also be performed when the user is logged in later because the browser has cached the redirect.

    Possible solutions:

    • Add a unique GET parameter (such as a timestamp) to the URL in the link.
    • Trigger the redirect via API in the template file:
      $session->redirect('/targeturl/', false); // 302

       

    • Paste this hook into your init.php
      wire()->addHookBefore('Session::redirect', function($e) {
      	$url = $e->arguments[0];
      	if ($url == '/login/') $e->arguments(1, false); // change to 302 if target is /login/
      });

     

    • Like 2
  8. Password is stored as a hash in the database. You cannot read it out. To set a new superuser (admin) password, put the following code in a template, or in your ready.php

    $users->get($config->superUserPageID)->setAndSave('pass', 'mynewpassword');

    Don't forget to remove the code later.

    • Like 3
  9. 4 hours ago, jploch said:

    After I updated to the new version, the permission 'trigger-db-backup' wasn't available.
    I created it manually and now it works. Maybe the permission wasn't created  because I updated, rather than installing a new copy? 

    Yes, the permission will be created on install only.

    • Like 1
  10. @horst

    Sorry for the very delayed answer. The module (FieldtypeSelectExtOption) is a fieldtype, not an inputfield. The fieldtype supports any Core Inputfieldtypes (Select, Radios, Checkboxes, SelectMultiple or ASMSelect) furthermore some 3d Party Inputfields like InputfieldChosenSelect. Read more about this in the README.md.

    I don't know if there exists an Inputfield module which extends InputfieldSelect or InputfieldSelectMultiple showing icons or thumbnails to select from. Let me know if you find a solution.

    • Like 1
  11. @jploch @horst

    Tonight a had a look in the module and I made an update to version 1.1.6

    • I removed any general permission from module. The Backup is triggered now by any user (if a time interval is set).
    • I added trigger option when a user logs in (thanks for the hint @horst).
    • I changed the name for the required permission (trigger on login or logout) from 'db-backup' to 'trigger-db-backup'. Also to prevent permission conflicts with ProcessDatabaseBackupsusing this permission.

     

    • Like 2
  12. You have several options in the backend:


    1.) Page based under Page > Settings
    Enable or disable every non default language. Trying to access an inactive page will result in an 404

    911768303_Bildschirmfoto2018-12-05um00_59_28.jpg.9f5ab001aa56c949e14b9b05ef54856b.jpg

     

    2.) Template based under Template > Advanced (bottom)

    540636816_Bildschirmfoto2018-12-05um01_02_54.jpg.007d611f9074bbf86b808ce5dc644364.jpg

     

    3.) Field based under Edit Field > Details

    2072876240_Bildschirmfoto2018-12-05um01_04_40.jpg.6a92592a5a89967efb23928067f31ce3.jpg

     

    • Like 2
×
×
  • Create New...