diff --git a/024-How-to-integrate-the-Create-User-Helper-Method-in-your-Components.md b/024-How-to-integrate-the-Create-User-Helper-Method-in-your-Components.md index 426873d..ad8ab24 100644 --- a/024-How-to-integrate-the-Create-User-Helper-Method-in-your-Components.md +++ b/024-How-to-integrate-the-Create-User-Helper-Method-in-your-Components.md @@ -5,19 +5,22 @@ What is the User Creation function? [00:00:18](https://www.youtube.com/watch?v=c ### Helper Class - If the repository is opened you will find Joomla Install, go to administrator. There is a Helper class for the front end of every component as well as for the back end. Looking in a back end, in component there is 'com_expertdatabase'. and under it 'expertdatabase.php'. [00:00:55](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m55s) Go to Helpers, that file(See video), is the Helper class. If it is opened the abstract 'expertdatabaseHelper' may be seen. That Helper class gets included into the component on every page. If the main back end file with that one 'expertdatabase' is opened, which get loaded by Joomla first. It includes that Helper file in every page. [00:01:28](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m28s) It means that everything in that class is available everywhere in the component. Returning to the interface, Component Builder Dashboard, and then go to components and to 'expertdatabase'. There can Library & Helpers be seen . The switch 'add create user helper method', had been set to 'yes'. [00:02:11](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m11s)<<<<<<<<<<<< + If the repository is opened you will find Joomla Install, go to administrator. There is a Helper class for the front end of every component as well as for the back end. Looking in a back end, in component there is 'com_expertdatabase'. and under it 'expertdatabase.php'. [00:00:55](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m55s) Go to Helpers, that file(See video), is the Helper class. If it is opened the abstract 'expertdatabaseHelper' may be seen. That Helper class gets included into the component on every page. If the main back end file with that one 'expertdatabase' is opened, which get loaded by Joomla first. It includes that Helper file in every page. [00:01:28](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m28s) It means that everything in that class is available everywhere in the component. Returning to the interface, Component Builder Dashboard, and then go to components and to 'expertdatabase'. There can Library & Helpers be seen . The switch 'add create user helper method', is in the 'yes' position. [00:02:11](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m11s) That is the switch that should be used, by which Component Builder is commanded that the Helper class that creates Users should be added to the Helper class of the front and back end of the component. + I'm going to close out here. I am going to go back to the code. Then I am going to do a simple . [00:02:44](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m44s) +If this area is closed and you return to the code and a simple search for user is done, quite a few users can be seen as well as Create User. - That is the switch that should be used, by which Component Builder knows that you actually want the helper class that creates users to be added to the helper class of your front and back end of your component. I'm going to close out here. I am going to go back to the code. Then I am going to do a simple search for user. [00:02:44](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m44s) ### Create User -Here is quite a few users, there it is create user. As you can see this is a public static function. So you would basically call it with that class name(expertdatabasehelper) then colon colon and the name of the function, which is create user. You will see that it is set to 'new'. [00:03:26](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m26s) Now new has in it a few variables is basically an array. You can go through this class and you'd see that it has a password, password2, it has a user name, it has a name, aswell as a e-mail. Then it creates the user, that's what this class does. It calls in the Joomla component users. [00:04:00](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m00s) It calls in it's registration model. And then it basically uses that model to create a user. That's what that switch does, it adds this class to your component. You can then use it in your component. It doesn't automatically just sets everything else in place, you still required to do as a developer to add to correct code. I'll show you what I have done and how I am using it. +This is a public static function. So you would basically call it with that class name 'expertdatabasehelper' then 'colon' 'colon' and the name of the function, which is Create User. It is set to '$new'. [00:03:26](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m26s) '$new' has in it a few variables, it is an array. In this class it may be noticed that it has a password: 'password2'. It has a user name, it has a name, aswell as a e-mail. Then it creates the user, that's what this class does. It calls in the Joomla component users. [00:04:00](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m00s) It calls in it's registration model and it uses that model to create a user. That's what that switch does, it adds this class to the component. The it may be used it in the component. It doesn't just sets everything else in place, It is still required of the developer to add to correct code as everything else is not automatically sets in place. ### Expert Field -There is a admin view called experts. It's in this view that I would actually like the option for someone to create a user. Let me first demonstrate how it works. I would go to expertdatabase and click on experts. Let's click on new. So you would see there is a [00:04:55](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m55s) field called expert which you can select users within a specific group. I will also explain some of that more later. But underneath there is this button create user. If you click on it, it basically has a pop-up where in you enter a user name. I am just going to say 'Testing123' as the username. [00:05:26](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m26s) And as the password, there we go, got the user name. So everything is testing123. If I click create, it basically has this nice effect where it is busy creating it, setting it up, sending out the email, doing all of that for you. And once it's done it lets you know that the user was created successfully and the login details was e-mailed to the user. Then it says here ready to select. [00:06:05](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m05s) You can now select testing123 that you just created from the user list in the above field. Simply click on the blue user icon. Click here and you can type in that testing123, click search. There is the user created and we click enter. You see that it basically used a very strange conversion here. Basically converting the username away from the numbers. Now you can you can fix that by clicking edit. [00:06:40](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m40s) Then changing it to 123 and say save the update. Clearly my little application doesn't want to allow you to use any numbers in the user name. That's not the point. The point is that we have this integrated user now that is connected to an expert. If you were to click there again, you can still select it, but once you select it, you can't create a new expert and select that user again. So it's basically one profile connecting to one user to set up a expert. [00:07:24](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m24s) So that's the feature I'm using it for there is different ways that I have implemented this. +There is a admin view called 'Experts'. For example: If there is a need in this view like the option for someone to create a User. To demonstrate how it works. Go to expertdatabase and click on 'Experts' and click on 'New'. [00:04:55](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h04m55s) A field called 'Expert' may be seen in which you can select users within a specific group. Underneath is the button Create User. <<<<<< + + If you click on it, it basically has a pop-up where in you enter a user name. I am just going to say 'Testing123' as the username. [00:05:26](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h05m26s) And as the password, there we go, got the user name. So everything is testing123. If I click create, it basically has this nice effect where it is busy creating it, setting it up, sending out the email, doing all of that for you. And once it's done it lets you know that the user was created successfully and the login details was e-mailed to the user. Then it says here ready to select. [00:06:05](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m05s) You can now select testing123 that you just created from the user list in the above field. Simply click on the blue user icon. Click here and you can type in that testing123, click search. There is the user created and we click enter. You see that it basically used a very strange conversion here. Basically converting the username away from the numbers. Now you can you can fix that by clicking edit. [00:06:40](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h06m40s) Then changing it to 123 and say save the update. Clearly my little application doesn't want to allow you to use any numbers in the user name. That's not the point. The point is that we have this integrated user now that is connected to an expert. If you were to click there again, you can still select it, but once you select it, you can't create a new expert and select that user again. So it's basically one profile connecting to one user to set up a expert. [00:07:24](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h07m24s) So that's the feature I'm using it for there is different ways that I have implemented this. Let me show you another one. Obviously you realise I'm using a lot of JavaScript on this page. I will show you some of that JavaScript but for the most part you need to write that yourself. For example over here I wrote this job tracking extension. Let's say we want to create a new job order, then I can say whether it's a new client or a existing. If it is an existing I simply select from this list. [00:08:04](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m04s) If it's new I click here(A new Client) I can enter all the details of the user and when I click save, it creates the user, stores the data in the user table, not in the job order table. Deletes all these values, that the job order table never stores any user values in the relation of this job order of course. And so that's another way that I have implemented. If we were to close this out, open a client, a new one. You would see it's basically it's the same values. [00:08:44](https://www.youtube.com/watch?v=ckFakaQ90JY&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h08m44s) So that's another way that we integrated this whole user integration. So there are really many different ways to this. The way I have done it I've just listen to my clients expectation. What I really would like to see and how they would like it to work, then simply make it happen that way. I personally prefer the Ajax way much more. It just seems to me easier.