We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23491 ☆ A M B ☆
    • 1,056 Posts
    Quote from: pixelchutes at Sep 11, 2007, 11:25 PM


    With the next release, can ANY service be disabled via a snippet param?

    Example: Let’s say you want a locked down registration process (Added By Admins Only) AND you don’t want users to be able to see OTHER USER’s Profiles (thinking more along the lines of a user based application opposed to a traditional user based community website...)

    Will something like this be an option?
    &disableServices=`register,registernew,viewprofile`

    ...where the above example would prevent anyone from passing custom values via the URL to gain access to a WLPE service (as we discussed earlier in this thread)

    Or, maybe you just don’t want users to be able to delete their profiles just because WLPE is active/installed:
    &disableServices=`deleteprofile`
    



    Awesome! I am very excited to get running with this, especially with the ability to control what can/can’t happen (services) and also your work on the MODx Events...superb! I will try and remain patient a bit longer smiley

    Also, what’s the difference between the "register" and "registernew" services?
      Mike Reid - www.pixelchutes.com
      MODx Ambassador / Contributor
      [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
      ________________________________
      Where every pixel matters.
      • 26435
      • 1,193 Posts
      ScottyDelicious Reply #232, 19 years ago
      Quote from: pixelchutes at Sep 12, 2007, 12:04 AM

      Awesome! I am very excited to get running with this, especially with the ability to control what can/can’t happen (services) and also your work on the MODx Events...superb! I will try and remain patient a bit longer smiley
      Yeah, I am going to try and ship a few example plugins for use with the events, if nothing else, just to show how useful they can be.
      Example:
      When a user registers for a new account, one of the events that is invoked along the way is OnBeforeAddToGroup.
      Let’s say your form has a checkbox a user can check to be added to a mailing list. This checkbox’s name is "mailinglist" and in the plugin tied to the OnBeforeAddToGroup event, if the value of $_POST[’mailinglist’] is "on", then the group ’mailto’ (or whatever) is added to the array of groups to add the user to right before that part of the code is executed. If the checkbox is not checked, all that is skipped and adding to groups proceeds as originally planned.
      Quote from: pixelchutes at Sep 12, 2007, 12:04 AM

      Also, what’s the difference between the "register" and "registernew" services?
      A combination of semantics and laziness. After I started coding the register block, I realized I needed 2 services. One service to display the form (at the time I had called IT register) and one service to process the form input and add the user to the database.

      I just renamed the first service (display the form) "registernew" and called the service where the actual registration code happens "register".

      I am sure I could be more descriptive, but I was writing the class and thinking about bigger things at the time.

      -sD-
      Dr. Scotty Delicious, Scientist DFPA.
        Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
        All of the above... in no specific order.


        I send pointless little messages
        • 26435
        • 1,193 Posts
        ScottyDelicious Reply #233, 19 years ago
        Ok, this is mostly at pixelchutes, but I am sure it will be useful to many others as well.
        We talked about being able to conditionally disable services and I think I have the solution worked out.

        I have added ANOTHER new parameter &disableServices which will accept a comma separated list of services to disable.
        You can disable individual services like "deleteprofile" and "viewprofile" as well as entire types like "register" and "users".

        Examples:
        To disable deletion of profiles by individual users and the ability to view other profiles:
        [!WebLoginPE? &disableServices=`deleteprofile,users` !]


        If you want to disable front end registration (only the admin can add users):
        [!WebLoginPE? &disableServices=`register` !]


        How it works:
        WebLoginPE explodes &disableServices at the comma into an array.
        At every TYPE checkpoint and at every SERVICE, WebLoginPE checks to see if that type or service is in the array of disabled services. If it is, a return statement is issued and no code is executed.

        -sD-
        Dr. Scotty Delicious, Scientist DFPA.
          Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
          All of the above... in no specific order.


          I send pointless little messages
          • 7455
          • 2,204 Posts
          @ SD,

          I looked at the code and maybe I am wrong but you want to enter a username as file name like this:

          ---morecode--
          $currentWebUser = $modx->getWebUserInfo($modx->getLoginUserID());
          ---morecode--
          $userImageFilePath = $modx->config[’base_path’].’assets/snippets/webloginpe/userimages/’.str_replace(’ ’, ’_’, strtolower($currentWebUser[’username’])).$ext;
          ---morecode--
          imagejpeg($image_p, $userImageFilePath, 100);
          ---morecode--

          What I wonder is how you can use the $currentWebUser when the registration is not yet completed and the user is not logged in yet so there is no value in getLoginUserID()
          that would explain why it only wants to write a .jpg the user does not exist so no user info to use, somhowe you need to grab the post info for thin on new registrations.

          I changed the following to test:
          $userImageFilePath = $modx->config['base_path'].'assets/snippets/webloginpe/userimages/'.str_replace(' ', '_', strtolower($currentWebUser['username'])).$ext;
          $userImageFileURL = $modx->config['site_url'].'assets/snippets/webloginpe/userimages/'.str_replace(' ', '_', strtolower($currentWebUser['username'])).$ext;
          	
          to:
          	
          	$userImageFilePath = $modx->config['base_path'].'assets/snippets/webloginpe/userimages/dimmy'.$ext;
          	$userImageFileURL = $modx->config['site_url'].'assets/snippets/webloginpe/userimages/dimmy'.$ext;
          

          and this does work

          I hope this can help you out.

          greets Dimmy

            follow me on twitter: @dimmy01
            • 26435
            • 1,193 Posts
            ScottyDelicious Reply #235, 19 years ago
            Dimmy!
            It always takes someone else to look at your code to see what you are missing!

            I moved CreateUserImage() to AFTER all the verification of required fields, etc... in the Register() method and added

            $this->Username = $_POST[’username’];

            Then, in the CreateUserImage() method I changed it to
            <?php...
            $currentWebUser = $modx->getWebUserInfo($modx->getLoginUserID());
            if (!$currentWebUser)
            {
            	$currentWebUser['username'] = $this->Username;
            }
            


            So that should make sure it all works out.
            Sound good?

            Thank you so much for tracking the source of that bug down! I wasn’t thinking about initial registration and using $modx->getWebUserInfo($modx->getLoginUserID());
            It would NEVER work!  tongue

            -sD-
            Dr. Scotty Delicious, Scientist DFPA.
              Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
              All of the above... in no specific order.


              I send pointless little messages
              • 26435
              • 1,193 Posts
              ScottyDelicious Reply #236, 19 years ago
              Quote from: davidm at Sep 08, 2007, 04:15 AM

              Jaw dropping shocked

              AMAZING !

              I mean the templatable manager interface, the powerful &usersList paramater with filters, the active user thing... man, this is really awesome and such a quick update to the already great code you just fed us !

              While I am here, I forgot to say it the first time but amazing job documenting the snippet too grin
              Hats off Dr Scotty !
              Thanks David!
              Quote from: davidm at Sep 08, 2007, 04:15 AM

              Any url for an Amazon wishlist wink ?
              Just added it to my signature wink

              -sD-
              Dr. Scotty Delicious, Scientist DFPA.
                Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
                All of the above... in no specific order.


                I send pointless little messages
                • 7455
                • 2,204 Posts
                mm I understand what you did but could you attach your version? I tried it but must be doing something wrong.

                one thing I think of now is when you move the image part to the bottom, and the image is to big or something is wrong the new webuser is already created is it not?
                the image must be made just after the checks but before the actal creating of the webuser.

                Thank you so much.

                I really like this snippet, I am trying to connect this to the FDM Snippet so that a registered person can create 1 page and 1 only so i need an extra fields, one that holds the page id if there ia an id than that person can not make a new page using FDM. really nice all those cool snippets that can be mashed together using some homemade scripts.

                Dimmy
                  follow me on twitter: @dimmy01
                  • 6726
                  • 7,075 Posts
                  Quote from: Dr. at Sep 12, 2007, 03:46 AM
                  Just added it to my signature wink

                  <off topic>Duly noted, I’ll check that list out grin</off topic>
                    .: COO - Commerce Guys - Community Driven Innovation :.


                    MODx est l&#39;outil id
                    • 26435
                    • 1,193 Posts
                    ScottyDelicious Reply #239, 19 years ago
                    @Dimmy:
                    I moved this:
                    <?php...
                    
                                    if (!empty($_FILES['photo']['name']))
                    		{
                    			$photo = $this->CreateUserImage();
                    			if (!empty($this->Report))
                    			{
                    				return;
                    			}
                    		}
                    		else
                    		{
                    			$photo = $modx->config['site_url'].'assets/snippets/webloginpe/userimages/default_user.jpg';
                    		}
                    


                    to the point in the Register method right above:
                    		// If all that crap checks out, now we can create the account.
                    


                    I added a LOT of stuff, so I can’t give you line numbers right now, but I basically just made it so that the user image is the last thing done/checked for errors... before the user info starts getting stored into the various tables.

                    -sD-
                    Dr. Scotty Delicious, Scientist DFPA.
                      Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
                      All of the above... in no specific order.


                      I send pointless little messages
                      • 7455
                      • 2,204 Posts
                      MM ok, I cant get it to work, I also noticed that the fileupload field does not "remember" after an error that field is empty same goes for puldown menu for the coutry


                      I still get the error that it want to create a .jpg file (no prefix)

                      I even tested it by adding an extra if option here:
                      $currentWebUser = $modx->getWebUserInfo($modx->getLoginUserID());
                      if (!$currentWebUser)
                      {
                      	$currentWebUser['username'] = $this->Username;
                      }
                      {
                      	$currentWebUser['username'] = 'nousername';
                      }
                      


                      to no avail

                      I have no idea what goes wrong now.
                        follow me on twitter: @dimmy01