daily pastebin goal
10%
SHARE
TWEET

PP: PF Podio Portal Demo 2

globiws Aug 11th, 2018 259 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. //config
  3. $user_app_id = 123456;
  4. $user_app_email_field = "title";
  5. $user_app_pass_field = "md5-password";
  6. $project_app_id = 234567;
  7. // end config
  8.  
  9. if ( $PFUI->context == "logout" ) $PFUI->clearSession();
  10.  
  11. // create account
  12. if ( @json_decode($pf_payload, true)["GET"]["action"] == "register" ) {
  13.     $PFUI->html('<h3>Reset Account</h3>');
  14.     $PFUI->html('<p>Use this Podio Webform to create a new account or reset the password of your current account.</p>');
  15.     $PFUI->html('<p>A new password will be emailed to you (via GlobiFlow).</p>');
  16.     $PFUI->html('<iframe src="https://podio.com/webforms/345678/456789" style="width:700px;height:500px;border:0">');
  17.     $PFUI->html('</iframe>');
  18.     $PFUI->render();
  19. }
  20.  
  21. // html to register
  22. $html = '<p style="margin-top: 25px; text-align: center"><a href="'.$PFUI->url.'?action=register">Create Account</a> or <a href="'.$PFUI->url.'?action=register">Reset Password</a></p>';
  23. $html .= '<p>Feel free to create an account and poke around. You can edit your profile, create projects, and view and comment on existing projects. Any projects you create will also be shared with you in Podio so that you can see both sides in action.</p>';
  24. $html .= '<p>The blog post that describes how to achieve this can be found <a href="http://pushingpodio.globi.ca/post/building-a-podio-user-portal-with-procfu-2" target="_blank">here</a></p>';
  25.  
  26. // require login
  27. $PFUI->requireAuth(["method"=>"password", "app_id"=>$user_app_id, "user_field_id"=>$user_app_email_field, "pass_field_id"=>$user_app_pass_field, "pass_type"=>"md5", "html_after"=>$html]);
  28. $userRecordId = $PFUI->getLoggedInItemId();
  29.  
  30. // OK - we're logged in
  31. $PFUI->html('<div>Logged in as: '.$PFUI->getLoggedInUsername().' ( ');
  32. $PFUI->link(["title"=>"Projects", "onclick"=>""]);
  33. $PFUI->html(" | ");
  34. $PFUI->link(["title"=>"Edit Profile", "onclick"=>"profile"]);
  35. $PFUI->html(" | ");
  36. $PFUI->link(["title"=>"Log Out", "onclick"=>"logout"]);
  37. $PFUI->html(" )</div><br>");
  38.  
  39. // edit profile
  40. if ( $PFUI->context == "profile" ) {
  41.     $PFUI->html("<h3>Edit Profile</h3>");
  42.     $PFUI->item(["mode"=>"edit", "app_id"=>$user_app_id, "item_id"=>$userRecordId, "fields"=>["title", "name", "about", "podio-user-type"], "readonly"=>["title"]]);
  43.     $PFUI->render();
  44. }
  45.  
  46. // page: view project
  47. if ( $PFUI->context == "project" ) {
  48.     $project = pf_podio_item_as_field_array($PFUI->getCurrentItem());
  49.     $PFUI->html('<h3>Project: '.$project['title'].'</h3>');
  50.     $PFUI->item(["mode"=>"view", "app_id"=>$project_app_id, "fields"=>["title", "status", "details"], "onsubmit"=>"", "showfiles"=>true, "showcomments"=>true, "allowcomment"=>true, "allowcommentfiles"=>true]);
  51.     $PFUI->render();
  52. }
  53.  
  54. // page: NEW project
  55. if ( $PFUI->context == "newproject" ) {
  56.     $PFUI->html("<h3>Create New Project</h3>");
  57.     $PFUI->html('<p>NOTE: This project will be shared with you automatically in Podio so that you can see both sides (public and in-Podio).
  58.     If the email address you\'re using is not connected to a Podio account, ignore the confirmation emails from Podio. You do NOT need a
  59.     Podio account to use the public part of this portal.</p>');
  60.  
  61.     $PFUI->item(["mode"=>"create", "app_id"=>$project_app_id, "fields"=>["title", "status", "details", "customer"], "values"=>["customer"=>$userRecordId, "status"=>"New"], "hidden"=>["customer", "status"], "onsubmit"=>"", "allowfiles"=>true]);
  62.  
  63.     $PFUI->render();
  64. }
  65.  
  66. $PFUI->html("<h3>Your Projects</h3>");
  67. $PFUI->startDelayed("projects");
  68. $PFUI->table(["type"=>"related", "item_id"=>$userRecordId, "app_id"=>$project_app_id, "fields"=>["title", "status"], "onclick"=>"project"]);
  69. $PFUI->button(["title"=>"+ Add Project", "onclick"=>"newproject"]);
  70. $PFUI->endDelayed();
  71.  
  72. $PFUI->render();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top