Jump to content

gebeer

Members
  • Posts

    1,391
  • Joined

  • Last visited

  • Days Won

    39

Everything posted by gebeer

  1. gebeer

    Text responsability

    I usually make clear in my offer/cost estimate whether I am responsible for the wording or the client. This helps to avoid problems at a later stage. Also to make clear that time I put into wording review and improvement will be charged extra. PS: maybe this should be moved to the dev talk thread?
  2. Hello, part of my new project is providing a RESTful webservice through PW. I am using clsource's REST Helper for ProcessWire which is working great. For the REST service part of the site I would like to suppress the setting of session cookie for $session->login and $session->logout because I don't need sessions and I don't want to have Set-Cookie in my response header. For user authentication in a PUT request I use $session->login() to verify username and password: $uId = $input->urlSegment1; $u = $users->get($uId); if ($session->login($u->name, $params["upass"])) { $session->logout(); //update user data } In the response header for that request I get: Set-Cookie: wire=ha6io723mkfc9v4scdib3oe8g7; path=/; HttpOnly wire=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT wire=1n8faeiva3vg7u13ijsrs24bt1; path=/; HttpOnly wire_challenge=YK0WRw0Wrd2ZAhKEUCLPOHd9iSySEPb91; expires=Tue, 07-Apr-2015 14:11:24 GMT; path=/; httponly wire=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT wire=u9m41s8b87d3ca1jp1jbl0r6k3; path=/; HttpOnly wire=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT wire=oidcbmht561qnvts2fjnq4b7p3; path=/; HttpOnly persist=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/ At the moment I get rid of it by doing header_remove("Set-Cookie"); But I would like to avoid setting of that cookie in the first place. I found the relevant methods ___login and ___logout in /wire/core/Session.php But searching Captain Hook for "logout" doesn't bring up those methods. I assume they should be hookable because they start with 3 underscores. Now how would I hook into those methods from my template file (not as an autoload module)? The webservice endpoint url is .../api/users/ and my temlate file for that is users.php What I've tried so far is wire()->addHookBefore('Session::logout', null, 'logoutNoCookie'); function logoutNoCookie($event) { $event->replace = true; $sessionName = session_name(); $_SESSION = array(); // if(isset($_COOKIE[$sessionName])) setcookie($sessionName, '', time()-42000, '/'); // if(isset($_COOKIE[$sessionName . "_challenge"])) setcookie($sessionName . "_challenge", '', time()-42000, '/'); session_destroy(); session_name($sessionName); $this->init(); session_regenerate_id(true); $_SESSION[$this->className()] = array(); $user = $this->wire('user'); $guest = $this->wire('users')->getGuestUser(); $this->wire('users')->setCurrentUser($guest); $this->trackChange('logout', $user, $guest); if($user) $this->logoutSuccess($user); $event->return = $this; } But this gives me an error: Fatal error: Using $this when not in object context because I'm placing my hook function outside the class context. What would be the correct way for calling the hook and placing my hook function?
  3. header_remove("Set-Cookie"); did the trick. I guess this is not the cleanest way of doing it. I opened a new thread to find out how I can suppress cookies in the first place as this is somewhat beyond the scope of this thread here.
  4. Thanks again for your help. I will give header_remove a try when I'm back at my office and report back here. Cheers Gerhard
  5. Thank you clsource! I would like to use PW built in functionality for authenticating my users rather than implementing my own. I am aware though, that the RESTful approach is supposed to work without server side session handling. That is why I only login the user to check if the correct password was sent and then logout of the session instantly. If there is a way to avoid the Cookie info in the response header, that would be what I'm looking for. If there is none, I will have to rethink my approach and use a token along with the password in the Authentication header. Also I'm a bit confused about the cookie data in the response header. wire cookies expire 1970 and there are several of them? So if anybody can think of a PW API method to suppress cookies, that would be great.
  6. @clsource Thank you for your REST helper. I'm using it for a project and it is working fine. For my project I'm using basic HTTP Authetication. I added some code to the params method to fetch username and password and merge it into the $params array. The altered code is here: https://gist.github.com/gebeer/5d1447ff76e17931d944#file-rest-php-L265 For a PUT request I use $session->login() to verify username and password. $uId = $input->urlSegment1; $u = $users->get($uId); if ($session->login($u->name, $params["upass"])) { $session->logout(); //update user data } In the response header of that request I get some PW cookie data: Set-Cookie: wire=ha6io723mkfc9v4scdib3oe8g7; path=/; HttpOnly wire=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT wire=1n8faeiva3vg7u13ijsrs24bt1; path=/; HttpOnly wire_challenge=YK0WRw0Wrd2ZAhKEUCLPOHd9iSySEPb91; expires=Tue, 07-Apr-2015 14:11:24 GMT; path=/; httponly wire=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT wire=u9m41s8b87d3ca1jp1jbl0r6k3; path=/; HttpOnly wire=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT wire=oidcbmht561qnvts2fjnq4b7p3; path=/; HttpOnly persist=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/ Can I avoid that somehow other than not using session? In the PW cheatsheet I couldn't find anything related to cookies.
  7. Thank you both, LostKobrakai and Soma ! I call my custom method with $user->saveprofile($params) and can access the data in my method with $userData = $event->arguments(0); PS: Missing the Solved Button
  8. Hello, I want to add a custom method to the user object and need to pass some data ( an array called $params) to the method when I call it. I will call the method like this $user->saveprofile($params); The method takes that data and saves it to a user profile page. Only I don't know how to pass that data to my custom method. This might be a silly question. Please forgive me, but I am fairly new to OOP and PW modules/hooks development. This is what I have so far (taken off examples from here): public function init() { // init() is called when the module is loaded. $this->addHook('User::saveprofile', $this, 'UserSaveProfile'); } public function UserSaveProfile($event) { //how to pass my $params array to this method // Get the user object $user = $event->object; // get user data - this is where I am stuck $userData = // condition and actions if($user->hasRole("frontend")) { //create and save user profile page $this->message("Userprofile page for user " . $user->name . "has been created"); } } I tried to find examples of how to do that but could not find anything related in the forum. Any help would be appreciated. Thank you.
  9. You define $tagnames as an empty string with $tagnames = ""; Later in your foreach loop you treat $tagnames as an array and add items to it in $tagnames[] = $tag->id; Maybe you should declare $tagnames as empty array in the first place, like $tagnames = array(); not sure though if this solves your problem... EDIT: Sorry, I just read in the PHP documentation So forget about what I said above...
  10. Hello, this looks exactly like what I need for a new project. Before I go and buy ProFields I'd like to know if it fits for what I want to do. In my case the multiplier field will be used on a frontend form. Is it possible through the API to show a fixed number of fields, depending on the context? Example: I have a template for servers. Depending on the server model, each server can have different number of channels. So I need to render a frontend form via the API that has either 4, 8, 10, 20 or 40 multipliers of the channel field depending on the server model. Is this possible and is there some documentation on how to save/retrieve values through the API? Thanks
  11. SOLVED It was a role/permission issue. ProcessExportProfile didn't export the permissions correctly for a custom role in my system that got assigned a custom permission. After reassigning those, I can finally access the page.
  12. Thanks for sharing. This looks interesting for putting together prototypes. Only thing that would keep me from using it is that I got used to a SASS workflow. Pinegrow automatically saves scss files along with css and less version, when you edit. But how do these scss files look like, just plain css with scss file extension? Maybe you have tried that already and could report back here. Thank you. PS: your cutegrid looks appealing. Will definitely have a look...
  13. Hello, I exported a profile of a running live site (PW 2.5.2) with ProcessExportProfile module. Then cloned latest stable branch 2.5.3 to my local vagrant box dev server, copied the exported profile folder into PW root and installed. Everything went smoothly so far. All my templates, fields, modules and template files are there. I can access all but one specific page of my site. That page always throws a 404 error. The page sits under /profile and has template userprofile assigned. It is published and not hidden. The template file site/templates/userprofile.php is there. Only difference to the working pages is that this /profile page requires login before it can be accessed. After successful login the user is redirected to the /profile page with if($user->isLoggedin()) $session->redirect($pages->get('/profile')->url); But also if I enter the URL path manually, I get the 404 error. On the live site /profile only throws a 404 if you enter the URL path manually and are not logged in. So on my local install the /profile page acts as if the user was not logged in even if the user is logged in. I checked that the user really is logged in with if($user->isLoggedin()) echo "LOGGEDIN"; and has the correct roles with if($user->isLoggedin()) echo $user->roles; I haven't made any changes to my userprofile.php or any other files in the fresh install. And the code in there is working perfectly fine on the live site and on a copy of the live site that runs in the same dev environment as the site I'm having problems with. Now I'm really lost and don't know which steps to take for debugging this (debug is set to true in config.php - no messages or errors). Any help would be greatly appreciated. EDIT: I also installed the site on a different non local server to be able to rule out server environment issues. But same behaviour. Still get 404 for profile site
  14. No, it is not really required to set it back to true.
  15. I'm also using this German hoster for some sites. In a nutshell, they are using rsnapshot for their backups. Their backup server is pulling data from the live server. The backups are mounted via NFS to the live server. I came from the Joomla universe to PW. Thus I'm familiar with Akeeba backup which is a great product. Using their free and well maintained standalone version makes backing up PW and other PHP applications a breeze.
  16. I had these problems once and tried all solutions I could find in the forum to no avail. Then I finally found out that it was a permission problem. The server was running wrong apache user/group. I know that with some hosting companies (eg hosteurope) you have to manually change the user/group of your FTP account to reflect the apache user/group. Maybe this is the cause in your case, too.
  17. You can do that in Linux with Sublime Text and Emmet LiveStyle plugin. EDIT: actually the LiveStyle plugin also works in the other direction. It writes changes that you make in the Chrome dev tools to your CSS file which is also a nice feature. Only major drawback is that it doesn't support SCSS/SASS/LESS atm.
  18. May I ask what the advantages of dreamweaver over ST are when developing a static site?
  19. I can browse your site, even the homepage. Only thing is that the header image had to be loaded again when browsing to another page. But it should have been in the browser cache already because it is the same across the site. This points to come caching issues in my opinion. I had strange issues one time, too. Not same as yours, though. Then I found that when zipping up the files/folders on my dev machine, the hidden files (starting with . ) did not get included in my zip file. Guess this is OS related to my Linux box. You obviously have the .htaccess on the live server and thus in your zip so this might not be the issue. But still you might want to check if all files ended up in your zip correctly.
  20. I've been working with virtualbox VMs for quite some time now and can say that they are very easy to setup and maintain. Getting OSX to run requires a bit more of an effort. But once things are setup it is running smoothly. I do all my development work on a Linux box and do all the IE and Safari debugging in VMs. For IE the images provided by modern.ie are great. For setting up OSX in a virtualbox VM see the link that I posted in #5
  21. I live here 6 month a year and work mainly for European/American companies
  22. You could also use a mac in a virtual machine for testing http://bit.ly/11xY5YN
  23. Hello all, I'm working on a travel directory site with locations of the region I live in in Thailand. This is a private fun learning project. I would like to assign an icon to each location. ATM I have a simple text input field in my location template where I manually type in the fontawesome class name for the icon I want to assign which is a bit tedious. So I am thinking about putting together an Inputfieldtype "Icon" which will surely aid in learning PW module development (and some more PHP along the way) My concept so far: -since people will hardly use all 500+ icons on their sites, I want to use an asm select in the field setup to search and select the icons that we want to use -the asm select should show both, the icon and it's class name for each icon -then use the selected icons to populate a select dropdown field as input field where the user can choose an icon. Which inputfield module could I have a look at that is using asm select in the field setup? I used import.io (which really is a fun tool) to create a data set with all fontawesome4.2.0 icon class names and their unicodes. If you're interested you can see the dataset here (you need to login/signup with them first). I can export the dataset as JSON and use that to populate the asm select for the field setup. These are my ideas so far. Yours are always welcome
  24. Thank you for that snippet. I'm using it for a project with Bootstrap 3 and updated it accordingly <ol class='breadcrumb' itemprop="breadcrumb"> <?php foreach($page->parents as $parent): ?> <li itemscope itemtype='http://data-vocabulary.org/Breadcrumb'> <a href='<?php echo $parent->url; ?>' itemprop='url'> <span itemprop='title'><?php echo $parent->title; ?></span></a></li> <?php endforeach ?> <li class="active"><?php echo $page->title; ?></li> </ol> And I added <body itemscope itemtype="http://schema.org/WebPage"> like suggested by teppo. Now it is being picked up by Google.
×
×
  • Create New...