Jump to content

pout

Members
  • Posts

    41
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

pout's Achievements

Jr. Member

Jr. Member (3/6)

9

Reputation

  1. I am working on a course website where online courses can be held. I now have the problem of securing files. They should only be view/downloadable for the time the course lasts. These files are on a lection page. This is no problem for courses, that have a fixed start and end date. If the course/lection is unpubished, the files are not accesable with $config->pagefileSecure = true; in the config file. But there will be permanent courses a user can start at a wished date lasting for a defined period. So I have to make the lection(s) available for specific users at and for an individual time. Page structure: course |- lection 1 |- lection 2 |- ... abos |- abo 1 |- abo 2 (holds the data for one attendance of a course. Relation to user and course, and some other data like, when the course was started and will end) I thought of creating a role for every course and a template for the lections of each course. Course 1 has a seperate template for its lections and also the lections of course 2 have a separate template and so on. Then I could give the role for the course the view permission at the corresponding lection template and give the user, that attended a course, the matching role. Then the user has access to the lection(s) and files on this lectionpage(s) as long he has the role. This should work, I think. user1 -> roles: course1, course3 => access to lections with template1 and files of course1 and course3 user2 -> role: course2 => access to lections with template2 and files of course 2 But this could be hard to maintain. If I need another filed for lections, I would have to add it to each separate lection template of each course. I there a other way to manage this (page access control)?
  2. I did a pull request on github for my changes to LoginRegister. This changes will send a confirmation email if a user changes the email address in its profile. The new address is only set if it gets confirmed. Then also the username will change according his new email address. For the userpage I used @Zeka's idea in ready.php: wire()->addHookAfter('Pages::saved', function($event) { $page = $event->arguments(0); if($page->template == "user"){ $savedUser = $page; $parent = wire('pages')->get('/parentpage'); $userpage = wire('pages')->find("parent=".$parent.", name=user-".$savedUser->id); if ( count($userpage) == 0 ) { $p = new Page(); $p->template = 'Templatename'; $p->parent = $parent; $p->title = $savedUser->name; $p->name = wire('pages')->names()->uniquePageName('user-'.$savedUser->id, $parent); $p->save(); } else { $up = wire('pages')->get("parent=".$parent.", name=user-".$savedUser->id); $up->of(false); $up->title = $savedUser->name; $up->save(); } } });
  3. @cstevensjr I think, as this is related to the Module LoginRegister, it was in the right area. Or should it better move to "Module/Plugin Development"? But any area is fine for me. @Zeka Yes, thanks, this is good for creating userpages. I will adopt my code using your ideas. But the main thing for the LoginRegister module is: .) Should the username change after changing the users email. I think: no. Then I can not make the username depending on his email address. .) Should the username be created at the first saving/adding of the user. I think: yes. And this makes it, as far as I can see, impossible to use the id in the username. So my conclusion is using a prefix for the user (Standard: user, changeable in settings) and a counting number (with the possibility to overwrite the start number in settings). What do you (other) think? Maybe some using this module can give some input.
  4. protected function makeUniqueUserName() { $name = $this->wire('pages')->names()->uniquePageName($this->wire('sanitizer')->pageName('user'), $this->wire('pages')->get(29)); if ($name === 'user') $name = "user-1"; // to start with no 1 return $name; } This worked for the first time, but then the username returned is allways "user-1". (The sanitizer will get neccessary as soon as ther is a field for own prefix in settings.)
  5. Thanks for your input. I like the idea using the id. But I think there are some out there making a user-page with the username right after saving the new user (at least I do) in ready.php like this: wire()->addHookAfter('Pages::saved', function($event) { $page = $event->arguments(0); if($page->template == "user"){ $savedUser = $page; $userpage = wire('pages')->find("parent=/parentpage, name=".$savedUser->name); if ( count($userpage) == 0 ) { $page = new Page(); $page->template = 'Lektionen'; $page->parent = wire('pages')->get('/parentpage'); $page->title = $savedUser->name; $page->save(); } } }); To get the id of the new user I have to save the new user firts and then retrieve the user-id, set the name and save again. This will cause that the script above will make 2 pages. But your input is interesting in the way, that I think I would make the username unique this way: protected function emailToName($email) { $name = $this->wire('pages')->names()->uniquePageName($this->wire('sanitizer')->pageName($email, Sanitizer::translate, $maxLength=100)); return $name; } So I am sure to have a unique username. I would prefer a ID based name, but I think there is no way to get the new users ID before saving. The only think I am not happy with then: If someone populates a userpage made like in the first script to the world and the user changes the email-address, the page will still have his old email-address-alike name in name and title. Another idea is to make the user names just counted (user-1, user-2, user-3,...), maybe this would best way to make a neutral username. I could add a field to the settings to input to use an own prefix instead of "user-". //protected function emailToName($email) { protected function makeUniqueUserName() { $name = $this->wire('pages')->names()->uniquePageName($this->wire('sanitizer')->pageName('user-')); return $name; }
  6. At the moment I extend Ryans Code to make a new email validation, if a user changes his email in his profile. This works for now. But I ran into following Problem: If the login with email is allowed, the module generates a username out of the email address: email = mail@example.com username = mail-example.com If the user changes the email address in his profile, I have to change the username accordantly to the email. If the username is not changed, the old email address is blocked for new registration or the user can not change the email address back to his first email. But if I change the username, this could cause problems with selectors (e.g. pages are named to the usernames). So I think, it would be the best to generate random usernames, if the login/registration with email is active. What do you think? Which would be the best way to make random usernames?
  7. E-Mail-Client doesn't show a linked Image, so I want to try another content type header, but I don't get it overwritten. I tried: $headers = array("Content-Type" => "multipart/related; boundary=\"abcdef\"; type=\"application/xhtml+xml\""); if ($mail->mailHTML($to,$subject, $body, $headers)) { ... } (not sure about the type=\"application/xhtml+xml\" part) , but content type header still is: Content-Type: multipart/alternative; boundary="f73ea6d91e70b02e6c46d1cd4b36a0f1" or any other suggestions why <img src="https://'.$config->httpHost.$img->url.'" height="180" width="180"> in body is not loading image in e-mail client (Thunderbird and also Android K-9 Mail). In Webmail this is working. I do this in an external script for a cronjob.
  8. Thanks. I think I will give the blog module a try.
  9. Which Blog Module is used by processwire.com? Is there a recommendation for a module to extend an existing website with a blog? Thanks
  10. @adrian: I reportet this allready on github. I will also report @BitPoets change.
  11. @BitPoet: Yes you are right and yes, adding this line solved the issue also with the regular WireMail.
  12. Thanks! Using wireMail() instead of new WireMail() in line 677 made use of WireMailSmtp and this solved the other issues. I will post a bug report.
  13. Hi, I have a proplem with the registration confirmation mail from this module. When I try to register with a gmx.at e-mail, the multipart confirmation mail is not shown correctly. Using a hotmail.com address, the outlook.com interface is showing no bodytext. I tried to use WireMailSmtp and installed and configured the module. But it seems the e-mails are still send by the original WireMail. Don't know why. Here is the sourcecode of the e-mail shown by thunderbird: From - Thu Jan 24 18:15:36 2019 X-Account-Key: account4 X-UIDL: 1Mau6r-1hJrQE0cCB-00cSPh X-Mozilla-Status: 0001 X-Mozilla-Status2: 00000000 X-Mozilla-Keys: Return-Path: <postmaster@myhost.com> Received: from corvus.xxx.de ([ip]) by mx-ha.gmx.net (mxgmx015 [212.227.15.9]) with ESMTPS (Nemesis) id 1MWSVd-1ggHUV3pmd-00Xp8U for <newuser@gmx.at>; Thu, 24 Jan 2019 18:15:24 +0100 Received: (qmail 18646 invoked from network); 24 Jan 2019 17:15:24 -0000 Received: from localhost (HELO arcturus.xxx.de) (127.0.0.1) by corvus.xxx.de with SMTP; 24 Jan 2019 17:15:24 -0000 Received: (qmail 16911 invoked by uid 1434); 24 Jan 2019 17:15:23 -0000 Date: 24 Jan 2019 17:15:23 -0000 Message-ID: <20190124171523.16910.qmail@arcturus.xxx.de> To: newuser@gmx.at Subject: myhost.com Konto =?UTF-8?Q?best=C3=A4tigen?= X-PHP-Originating-Script: 1434:WireMail.php From: processwire@myhost.com X-Mailer: ProcessWire/WireMail MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="==Multipart_Boundary_x7bfa7a89930f498e5a91c658c9ec36acx" Envelope-To: <newuser@gmx.at> X-GMX-Antispam: 0 (Mail was not recognized as spam); Detail=V3; X-Spam-Flag: NO X-UI-Filterresults: notjunk:1;V03:K0:V2CsnrJkBGk=:yDYbM+J/8VAtWgrOXSZr8mKdPv r3syZlfeM3hGJvpI5LA+iqLR4CCri5VMng0f0UPpAIfz6ofyMYd7dz1wTP3I/KIVmJKRJlHHs Z3466LYl7AvMA1rl9ROa+BaAsX5x2wjSJyC3ITmmuAAeehGsgWpbbw0GSYj1vX1x/UYwovB3c lf+vYEtJyaeZyGvoX83D88huZnndfqbB3/kjGcM1iOKina3EeDcRjGaG8BRoGwikN4xqjYXel 8esBpl/phVAO/v/g3TZW4P3VNt1TDqgRr7oA34G4ihexENVVdYrzXVpW36OBn6lg2zaHzWZwT I88XqNasJl7dlrqLzuWD5W58IRp87J6DoUHj1P88Jh3yoddOQc52AaEk00RO6Hs6IBk5I2xL0 1PyCicddL3WMNmBywKGqbL9GElE1EFee1rzUQFLE0CmTH38bsv79hEf4REKqfdB1uMF0U6nnO zO5lXRIcuudJswlOdxPb6f0O3yITOgPXPEE7LtbSn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yyIGSetz7pFP4X8kFsOcf8eBGmk5+ifyLDmHBwXuspZeIYR 1nXo7Qzo6hrkNpiQGKkJp1O5IkhTDtYzLrOwtaosg9ttkiQl7HyUPylOTwWxHsxHYLsd3xZPH IQeqSld/jMgSiu0CKNwoCvLmx4pa9gsrPekZp+KVGR3jqEOjb32D86rs1r2+Tmjz5b21jEi6A 9zt9/wjK0W1OsuzdNcjhBioS1eLtSJIN/flONkaBRlAuH0IwXdZ1puBmaq63zzw1WoqWsi2uc umGq2cDqcLnIYvqDhlYnSsDeD84jjVdZlD0/v7NcnheS321rxjQY6OXCa48xXUAIB4iXjMX9T a+jkAhCc5mzqxnbrHg/8fG0A3x51FSflJKrOLx7h/wEKniXte7Td8Ge55EIeNkUrRst7DkxaO exxeswvYBqAz7wvaEsozOR7ptncw63nBeB9X9g4hClZY6w83B4mEzh/Aw4CIAGD3+bNbEvGWV tiLKJQhfO7Mq7hD2Q9SLlnVxVrkz6PAtT+913goPq/ This is a multi-part message in MIME format. --==Multipart_Boundary_x7bfa7a89930f498e5a91c658c9ec36acx Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Bitte klicken Sie auf den folgenden Link, um ihr Konto auf myho= st.com zu best=C3=A4tigen.=0A=0ABest=C3=A4tigungscode: uIqhuqIjchShXXX.w2ZtdH= K9J0l8dg0W/lnXA5N5=0A=0Ahttps://myhost.com/mitglieder/?register_c= onfirm=3DuIqhuqIjchShXXX.w2ZtdHK9J0l8dg0W%2FlnXA5N5 --==Multipart_Boundary_x7bfa7a89930f498e5a91c658c9ec36acx Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable <p>Bitte klicken Sie auf den folgenden Link, um ihr Konto auf myh= ost.com zu best=C3=A4tigen.</p>=0A=0A<p>Best=C3=A4tigungscode: uIqhuqIjchSh= XXX.w2ZtdHK9J0l8dg0W/lnXA5N5</p><p><a href=3D'https://myhost.com/= mitglieder/?register_confirm=3DuIqhuqIjchShXXX.w2ZtdHK9J0l8dg0W%2FlnXA5N5'>= Zum Best=C3=A4tigen anklicken</a></p> --==Multipart_Boundary_x7bfa7a89930f498e5a91c658c9ec36acx-- The bodyview in thunderbird shows everthing under the Line MIME-Version: 1.0 Content-Type: multipart/alternative; ..... Then I commented out the line 685 in LoginRegister.module to only send plain-Text. This worked with the gmx webinterface, but not in thunderbird (still shows source code in the bodypart) and outlook.com still showed an empty bodypart. Any ideas form the e-mail specialists out there? Thanks
×
×
  • Create New...