You can have a unique name as in the extensions table but if you do that you can't inherit in a straighforward name, you need to use something like com_categories to set up the inheritance. All inheritance happens via the nested sets in the assets table.
On Friday, August 10, 2012 2:14:24 AM UTC-4, Herman Peeren wrote:
> I'll add the asset_id column to the wiki too.
> Sorry, I thought it was only there for performance benefits. Still not > clear to me if it also worked without the asset_id (and have the unique > asset names manually constructed). I'll still play around with that to get > that crystal clear. Will report that here.
> Herman > ** > On Thursday, 9 August 2012 22:33:02 UTC+2, TDZWeb wrote:
>> I just added an *asset_id* column to the* #_helloworld* table, >> reinstalled and the system started using it by itself once you start >> changing and adding things. I imagine using a direct lookup via *asset_id >> * will have performance benefits over manually constructing the unique >> asset names.
Maybe this is a stupid question. If we have the asset_id in the components own table(s) and assuming the asset parent_id is correct, do we need the AssetName at all?
kl. 15:13:24 UTC+2 fredag 10. august 2012 skrev elin følgende:
> You can have a unique name as in the extensions table but if you do that > you can't inherit in a straighforward name, you need to use something like > com_categories to set up the inheritance. All inheritance happens via the > nested sets in the assets table.
> Elin
> On Friday, August 10, 2012 2:14:24 AM UTC-4, Herman Peeren wrote:
>> I'll add the asset_id column to the wiki too.
>> Sorry, I thought it was only there for performance benefits. Still not >> clear to me if it also worked without the asset_id (and have the unique >> asset names manually constructed). I'll still play around with that to get >> that crystal clear. Will report that here.
>> Herman
>> **
>> On Thursday, 9 August 2012 22:33:02 UTC+2, TDZWeb wrote:
>>> I just added an *asset_id* column to the* #_helloworld* table, >>> reinstalled and the system started using it by itself once you start >>> changing and adding things. I imagine using a direct lookup via *
>>> asset_id* will have performance benefits over manually constructing the >>> unique asset names.
Of course it is not a stupid question: we should pose all kinds of questions like that to get everything totally clear in the end. I 'd like to understand it completely and explain it clearly in the Wiki. Still playing around with these per item ACL settings. Unfortunately have to stop now, grrrr... to be continued (but not tomorrow). Does everything in your HelloWorld-code work as expected now? I mean: setting, saving and displaying of per item rights.
On Friday, 10 August 2012 20:22:09 UTC+2, TDZWeb wrote:
> Maybe this is a stupid question. If we have the asset_id in the components > own table(s) and assuming the asset parent_id is correct, do we need the > AssetName at all?
If you mean asset name in the asset table yes you do need a name of some kind. JAccess will automatically make it #__tablename.key but really I think you want something nicer looking. You should just pick a name for what an individual item is called.
https://github.com/joomla/joomla-platform/blob/staging/libraries/lega...
On Friday, August 10, 2012 2:22:09 PM UTC-4, TDZWeb wrote:
> Maybe this is a stupid question. If we have the asset_id in the components > own table(s) and assuming the asset parent_id is correct, do we need the > AssetName at all?
> kl. 15:13:24 UTC+2 fredag 10. august 2012 skrev elin følgende:
>> You can have a unique name as in the extensions table but if you do that >> you can't inherit in a straighforward name, you need to use something like >> com_categories to set up the inheritance. All inheritance happens via the >> nested sets in the assets table.
>> Elin
>> On Friday, August 10, 2012 2:14:24 AM UTC-4, Herman Peeren wrote:
>>> I'll add the asset_id column to the wiki too.
>>> Sorry, I thought it was only there for performance benefits. Still not >>> clear to me if it also worked without the asset_id (and have the unique >>> asset names manually constructed). I'll still play around with that to get >>> that crystal clear. Will report that here.
>>> Herman
>>> **
>>> On Thursday, 9 August 2012 22:33:02 UTC+2, TDZWeb wrote:
>>>> I just added an *asset_id* column to the* #_helloworld* table, >>>> reinstalled and the system started using it by itself once you start >>>> changing and adding things. I imagine using a direct lookup via *
>>>> asset_id* will have performance benefits over manually constructing >>>> the unique asset names.
I made a test user and tried with different access groups and it appears to be working. I have not tried every possible combination of rules and access groups. In the end he changes that I have made are:
- Adding *asset_id* column to the *#_helloworld* table.
ALTER TABLE`#__helloworld` ADD COLUMN `catid` int(11) NOT NULL DEFAULT '0';
- Adding the *rules* field to the *admin/models/forms/helloworld.xml*
- Modifying the *display* function of the helloworld view in *
admin/views/helloworld/view.html.php*, to define the property *canDo*.
public function display($tpl = null) {
// Assign the Data
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->script = $this->get('Script');
$this->canDo = HelloWorldHelper::getActions($this->item->id);
...
I think that pretty much covers it, but I have not made a tag for every step by going back and forth a little and debugging I must admit I may have lost track of all the modifications I made. I would have to start from scratch to be certain.
kl. 22:05:04 UTC+2 fredag 10. august 2012 skrev Herman Peeren følgende:
> Of course it is not a stupid question: we should pose all kinds of > questions like that to get everything totally clear in the end. I 'd like
> to understand it completely and explain it clearly in the Wiki. Still > playing around with these per item ACL settings. Unfortunately have to stop > now, grrrr... to be continued (but not tomorrow). Does everything in your > HelloWorld-code work as expected now? I mean: setting, saving and > displaying of per item rights.
> On Friday, 10 August 2012 20:22:09 UTC+2, TDZWeb wrote:
>> Maybe this is a stupid question. If we have the asset_id in the >> components own table(s) and assuming the asset parent_id is correct, do we >> need the AssetName at all?
> Adding ACL to the Helloworld view fails because the class > HelloWorldViewHelloWorld (extends JView) does not have the method 'canDo' > defined. The application exits when trying to add or edit a message and > gives an undefined method notice and then fatal undefined property of that > method as the view calls the get method: 'if > ($this->canDo->get('core.admin')):' and so on ( in the > admin/views/tmpl/edit.php file, line 59)
> The tutorial is massive compared to my skill level so I have no idea where > the class acquires this method. I think it it supposed to pick it up > automagically, but I pretty much feel like I am stumbling around in the > dark at the moment. While this is certainly one way to learn, I would > prefer if someone in the know took a look.
Thanks Ståle (is that your first name?)!. I also have the binding in the JTable and the missing of the ACL-part in the edit-layout in the downloadable zip. Plus some minor things like the missing language strings
and missing parameters in _getAssetParentId(). And of course we'll still have to elaborate on the story of parent_ids and put some best practices for J! 2.5 online. Will edit the text in the Wiki and after that also in the downloadable zip (for which there is also a second reference with a 404).
In HelloWorldTableHelloWorld::bind():
// Bind the rules.
if (isset($array['rules']) && is_array($array['rules']))
{
$rules = new JAccessRules($array['rules']);
$this->setRules($rules);
}
Parameters of _getAssetParentId: $table = null, $id = null
otherwise those variables are unknown in return parent::_getAssetParentId($table, $id);
Language strings in \admin\language\en-GB\en-GB.com_helloworld.ini:
COM_HELLOWORLD_FIELDSET_RULES="Message Permissions"
COM_HELLOWORLD_ACCESS_DELETE_DESC="Is this group allowed to edit this message?"
COM_HELLOWORLD_ACCESS_DELETE_DESC="Is this group allowed to delete this message?"
In Adrian Rosian's text on joomlajingle.com he also uses a hidden var "asset_id" in the edit-layout. Will investigate the necessity and rationale of that.
On Saturday, 11 August 2012 14:18:57 UTC+2, TDZWeb wrote:
> I made a test user and tried with different access groups and it appears > to be working. I have not tried every possible combination of rules and > access groups. In the end he changes that I have made are:
> - Adding *asset_id* column to the *#_helloworld* table.
> ALTER TABLE`#__helloworld` ADD COLUMN `catid` int(11) NOT NULL DEFAULT '0';
> - Adding the *rules* field to the *admin/models/forms/helloworld.xml*
> - Modifying the *display* function of the helloworld view in *
> admin/views/helloworld/view.html.php*, to define the property *canDo*.
> public function display($tpl = null) > {
> // Assign the Data
> $this->form = $this->get('Form');
> $this->item = $this->get('Item');
> $this->script = $this->get('Script');
> $this->canDo = HelloWorldHelper::getActions($this->item->id);
> ...
> I think that pretty much covers it, but I have not made a tag for every > step by going back and forth a little and debugging I must admit I may have > lost track of all the modifications I made. I would have to start from > scratch to be certain.
On Saturday, August 11, 2012, Herman Peeren wrote:
> Thanks Ståle (is that your first name?)!. I also have the binding in the
> JTable and the missing of the ACL-part in the edit-layout in the
> downloadable zip. Plus some minor things like the missing language strings
> and missing parameters in _getAssetParentId(). And of course we'll still
> have to elaborate on the story of parent_ids and put some best practices
> for J! 2.5 online. Will edit the text in the Wiki and after that also in
> the downloadable zip (for which there is also a second reference with a
> 404).
> In HelloWorldTableHelloWorld::bind():
> // Bind the rules.
> if (isset($array['rules']) && is_array($array['rules']))
> {
> $rules = new JAccessRules($array['rules']);
> $this->setRules($rules);
> }
> Parameters of _getAssetParentId: $table = null, $id = null
> otherwise those variables are unknown in return
> parent::_getAssetParentId($table, $id);
> Language strings in \admin\language\en-GB\en-GB.com_helloworld.ini:
> COM_HELLOWORLD_FIELDSET_RULES="Message Permissions"
> COM_HELLOWORLD_ACCESS_DELETE_DESC="Is this group allowed to edit this
> message?"
> COM_HELLOWORLD_ACCESS_DELETE_DESC="Is this group allowed to delete this
> message?"
> In Adrian Rosian's text on joomlajingle.com he also uses a hidden var
> "asset_id" in the edit-layout. Will investigate the necessity and rationale
> of that.
> On Saturday, 11 August 2012 14:18:57 UTC+2, TDZWeb wrote:
> I made a test user and tried with different access groups and it appears
> to be working. I have not tried every possible combination of rules and
> access groups. In the end he changes that I have made are:
> - Adding *asset_id* column to the *#_helloworld* table.
> ALTER TABLE`#__helloworld` ADD COLUMN `catid` int(11) NOT NULL DEFAULT '0';
> - Adding the *rules* field to the *admin/models/forms/helloworld.xml*
> - Modifying the *display* function of the helloworld view in *
> admin/views/helloworld/view.html.php*, to define the property *canDo*.
> --
> You received this message because you are subscribed to the Google Groups
> "Joomla! General Development" group.
> To view this discussion on the web, visit
> https://groups.google.com/d/msg/joomla-dev-general/-/0hsrIyHp0vAJ.
> To post to this group, send an email to
> joomla-dev-general@googlegroups.com <javascript:_e({}, 'cvml',
> 'joomla-dev-general@googlegroups.com');>.
> To unsubscribe from this group, send email to
> joomla-dev-general+unsubscribe@googlegroups.com <javascript:_e({},
> 'cvml', 'joomla-dev-general%2Bunsubscribe@googlegroups.com');>.
> For more options, visit this group at
> http://groups.google.com/group/joomla-dev-general?hl=en-GB.
Yes thank you both Elin and Herman, a nice crash course in ACL this thread! And yes my first name is Ståle (Norwegian). I tend to go with nicknames/usernames on forums in general as a force of habit. It is hard to find the line between prudence and paranoia these days :p
Cheers
Ståle
kl. 21:12:57 UTC+2 lørdag 11. august 2012 skrev Neil følgende:
> Elin I have found your posts and insight to extremely helpful. Thank you > for that.
> Herman I am going to have sometime next weekend if you want to compare > notes. We can set up a time and meet up on Skype.
> On Saturday, August 11, 2012, Herman Peeren wrote:
>> Thanks Ståle (is that your first name?)!. I also have the binding in the >> JTable and the missing of the ACL-part in the edit-layout in the >> downloadable zip. Plus some minor things like the missing language strings
>> and missing parameters in _getAssetParentId(). And of course we'll still >> have to elaborate on the story of parent_ids and put some best practices >> for J! 2.5 online. Will edit the text in the Wiki and after that also in >> the downloadable zip (for which there is also a second reference with a >> 404).
>> In HelloWorldTableHelloWorld::bind():
>> // Bind the rules.
>> if (isset($array['rules']) && is_array($array['rules']))
>> {
>> $rules = new JAccessRules($array['rules']);
>> $this->setRules($rules);
>> }
>> Parameters of _getAssetParentId: $table = null, $id = null
>> otherwise those variables are unknown in return >> parent::_getAssetParentId($table, $id);
>> Language strings in \admin\language\en-GB\en-GB.com_helloworld.ini:
>> COM_HELLOWORLD_FIELDSET_RULES="Message Permissions"
>> COM_HELLOWORLD_ACCESS_DELETE_DESC="Is this group allowed to edit this >> message?"
>> COM_HELLOWORLD_ACCESS_DELETE_DESC="Is this group allowed to delete this >> message?"
>> In Adrian Rosian's text on joomlajingle.com he also uses a hidden var >> "asset_id" in the edit-layout. Will investigate the necessity and rationale >> of that.
>> On Saturday, 11 August 2012 14:18:57 UTC+2, TDZWeb wrote:
>> I made a test user and tried with different access groups and it appears >> to be working. I have not tried every possible combination of rules and >> access groups. In the end he changes that I have made are:
>> - Adding *asset_id* column to the *#_helloworld* table.
>> ALTER TABLE`#__helloworld` ADD COLUMN `catid` int(11) NOT NULL DEFAULT >> '0';
>> - Adding the *rules* field to the *admin/models/forms/helloworld.xml*
>> - Modifying the *display* function of the helloworld view in *
>> admin/views/helloworld/view.html.php*, to define the property *canDo*.
>> -- >> You received this message because you are subscribed to the Google Groups >> "Joomla! General Development" group.
>> To view this discussion on the web, visit >> https://groups.google.com/d/msg/joomla-dev-general/-/0hsrIyHp0vAJ.
>> To post to this group, send an email to >> joomla-dev-general@googlegroups.com.
>> To unsubscribe from this group, send email to >> joomla-dev-general+unsubscribe@googlegroups.com.
>> For more options, visit this group at >> http://groups.google.com/group/joomla-dev-general?hl=en-GB.
On Saturday, 11 August 2012 15:14:24 UTC+2, elin wrote:
> Thanks Herman! That tutorial is really turning into a great collaborative > document.
Thanks to evereybody working on this. It is fun how everybody brings in a piece of the puzzle to finally understand Joomla!'s 2.5 ACL completely.
Some of my misunderstanding is because I didn't use much of the functionallity for ACL built in into JTable. Will have a look whether I can use some of that functionallity also when using Doctrine ORM instead of JTable (one of the things I'm still exploring).
Elin, you twice mentioned extending JAccess in your postings, but that probably referred to *JTable-extensions*. Joomla!'s ACL is not only in JAcess (and JAccessRule + JAccessRules), but also in JUser and JTable. And it is in your JTable-extensions that you have to override some methods.
I'm working on a wiki-article that explains the working of the core classes involved in ACL.
I go for: prudent paranoia. ;-)
Although I don't see any reason for paranoia when using your real name on a serious mailinglist.
How do you pronounce your name? For we don't have a å in our alphabeth...
On Saturday, 11 August 2012 21:12:57 UTC+2, Neil wrote:
> Herman I am going to have sometime next weekend if you want to compare > notes. We can set up a time and meet up on Skype.
Yes, great! I plan to have updated the text of this article (and the downloadable code) by then and also to have finished a wiki-article about the working of the various parts of the ACL (on the code level).I'm still figuring out the exact working of some parts and why things are done as they are. Looking forward meeting you.
On Saturday, 11 August 2012 21:45:47 UTC+2, Herman Peeren wrote:
> How do you pronounce your name? For we don't have a å in our alphabeth...
Sorry, will stay on topic and ask personal questions off-list. Further: lots of answers can be found on the web, so I better look it up before asking. E.g.: http://www.forvo.com/word/%C3%A5/
hehe np, was going to answer its pronounced like "awe". I am not in favour of always answering "google it". Didn't know about that site though. Interesting to hear the nuances between the Scandinavian languages. Good find.
Back on topic: I don't quite understand the role of categories in all this. I don't suppose anyone could explain to me exactly why the com_helloworld would fail without it?
kl. 10:00:55 UTC+2 søndag 12. august 2012 skrev Herman Peeren følgende:
> On Saturday, 11 August 2012 21:45:47 UTC+2, Herman Peeren wrote:
>> How do you pronounce your name? For we don't have a å in our alphabeth...
> Sorry, will stay on topic and ask personal questions off-list. Further: > lots of answers can be found on the web, so I better look it up before > asking. E.g.: http://www.forvo.com/word/%C3%A5/
On Sunday, 12 August 2012 17:57:43 UTC+2, TDZWeb wrote:
> I don't quite understand the role of categories in all this. I don't > suppose anyone could explain to me exactly why the com_helloworld would > fail without it?
That will be clear this week, I promise! At the moment I'm first updating the Wiki with all the changes we had (still busy with it). I also got access to the original zip on joomlacode.org, so I'll get that corrected too. And I'm still investigating everything around the working of JAccess and the relevant methods in JUser and especially JTable. I'll report it in a Wiki-article. I'm sure that it will be crystal clear then what the thing with those categories is.
It has something to do with setting the parent of the asset in the original _getAssetParentId() method of JTable: that always returns 1 (root-asset). If you have no categories, then the parent of the items should be the component itself. But if you don't override that menthod, the general root (asset_id = 0 or 1) is taken. I haven't figured it out exactly, but:
- I don't know yet if the only problem is in the original _getAssetParentId() method of JTable or (also) somewhere else - I don't know if the problem still exists if you override _getAssetParentId(), like we do in our example - maybe the problem is only that it is done a bit stange in JTableContent and some developers have taken that as an example (because it is the only core component using item-level ACL). In that case: we have no problem with our example. - it looks like it could introduce mistakes if the same root asset has both a 0 and a 1 as asset_id
See Elin's posting on https://groups.google.com/forum/?fromgroups#!topic/joomla-dev-platfor... Maybe she can explain some more about what the problem exactly is. And maybe explain something about the changes that have been made in the platform for that. That could save some looking-up time. All links to discussions and code welcome.
As said: we'll get that clear this week. Ciao, Herman
I decided to give the Hello World example a try when I first saw this
thread. Right now I am having a problem on step 9 but that's not the point
of my post.
The point of my post is just a word of thanks. Thanks to Christophe and
Ozgur for creating the original tutorial, thanks for those who updated it
since then, and thanks now to Herman and Elin for the way you have helped
in this thread, and also for the additional work that is going to be
applied to the Wiki.
A really well documented and comprehensive tutorial on this subject is a
powerful gift that will help introduce more to Joomla development. The
willingness to take time to share knowledge and help others is a great
example of what is special about our project and our community.
Thanks,
paul
On Sun, Aug 12, 2012 at 11:14 AM, Herman Peeren <herman.pee...@gmail.com>wrote:
> On Sunday, 12 August 2012 17:57:43 UTC+2, TDZWeb wrote:
>> I don't quite understand the role of categories in all this. I don't
>> suppose anyone could explain to me exactly why the com_helloworld would
>> fail without it?
> That will be clear this week, I promise! At the moment I'm first updating
> the Wiki with all the changes we had (still busy with it). I also got
> access to the original zip on joomlacode.org, so I'll get that corrected
> too. And I'm still investigating everything around the working of JAccess
> and the relevant methods in JUser and especially JTable. I'll report it in
> a Wiki-article. I'm sure that it will be crystal clear then what the thing
> with those categories is.
> It has something to do with setting the parent of the asset in theoriginal _getAssetParentId
> () method of JTable: that always returns 1 (root-asset). If you have no
> categories, then the parent of the items should be the component itself.
> But if you don't override that menthod, the general root (asset_id = 0 or
> 1) is taken. I haven't figured it out exactly, but:
> - I don't know yet if the only problem is in the original
> _getAssetParentId() method of JTable or (also) somewhere else
> - I don't know if the problem still exists if you override
> _getAssetParentId(), like we do in our example
> - maybe the problem is only that it is done a bit stange in
> JTableContent and some developers have taken that as an example (because it
> is the only core component using item-level ACL). In that case: we have no
> problem with our example.
> - it looks like it could introduce mistakes if the same root asset has
> both a 0 and a 1 as asset_id
> See Elin's posting on
> https://groups.google.com/forum/?fromgroups#!topic/joomla-dev-platfor... > Maybe she can explain some more about what the problem exactly is. And
> maybe explain something about the changes that have been made in the
> platform for that. That could save some looking-up time. All links to
> discussions and code welcome.
> As said: we'll get that clear this week.
> Ciao,
> Herman
> --
> You received this message because you are subscribed to the Google Groups
> "Joomla! General Development" group.
> To view this discussion on the web, visit
> https://groups.google.com/d/msg/joomla-dev-general/-/Qn4pqyAYlHIJ.
> To post to this group, send an email to
> joomla-dev-general@googlegroups.com.
> To unsubscribe from this group, send email to
> joomla-dev-general+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/joomla-dev-general?hl=en-GB.
Hey Paul, nice to meet you here too! And thank you for your kind words. Community attracts community... someone starts dancing and before you know it you have a JParty. See http://www.youtube.com/watch?v=GA8z7f7a2Pk
As for step 9: as you have probably seen, there was another question that seems related to that same step (problem was: delete button not working): https://groups.google.com/forum/#!msg/joomla-dev-general/OqoPiWfs_Eo/... Curious to what you encountered and hope to help you further, so you can join us at step 14 soon ;-)
Looking at the history of this HelloWorld tutorial I also saw a repository on joomlacode.org (by Antonie de Wilde) from 2008. This HelloWorld really is a long term community project. I also played around with *EasyCreator *since I'm into Joomla!. That project was started as a tool accompanying this tutorial. Christophe has done a lot on that too. It is now managed byNikolai Plath(Elkuku) and has "scaffolding" possibilities: it uses a kind of 'template' to set up the basic files of an extension. You 'only' have to transform it to your concrete needs. There were 'templates' for the then existing 1.5-HelloWorld series, but at the moment for 2.5 there are only 2 component-templates from this series (step 1 and step 12). When we have updated the steps of this tutorial, I'd like to add Easycreator-templates for the different steps in this 2.5 wiki-series. I think it can be of good help for educational purposes. See http://extensions.joomla.org/extensions/miscellaneous/development/5908, code on https://github.com/elkuku/EasyCreator
On Sunday, 12 August 2012 19:31:04 UTC+2, Paul Orwig wrote:
> Hi all,
> I decided to give the Hello World example a try when I first saw this > thread. Right now I am having a problem on step 9 but that's not the point > of my post.
> The point of my post is just a word of thanks. Thanks to Christophe and > Ozgur for creating the original tutorial, thanks for those who updated it > since then, and thanks now to Herman and Elin for the way you have helped > in this thread, and also for the additional work that is going to be > applied to the Wiki.
> A really well documented and comprehensive tutorial on this subject is a > powerful gift that will help introduce more to Joomla development. The > willingness to take time to share knowledge and help others is a great > example of what is special about our project and our community.
Thank you Herman for your kind words about EasyCreator, although you are not completely right about its history ;)
Yes, ATM there are only two templates for J 2.5 projects. I already heard some complaints about it. I am also about to drop the Joomla! 1.5 compatibility (there is a 3.0 branch on GitHub that already contains some work) so maybe this is a good time to update the templates.
So I would love to integrate some new templates for Joomla! 3.0. Feel free to fork/send pull requests to EasyCreators new home:
> Hey Paul, nice to meet you here too! And thank you for your kind words. > Community attracts community... someone starts dancing and before you know > it you have a JParty. See http://www.youtube.com/watch?v=GA8z7f7a2Pk
> As for step 9: as you have probably seen, there was another question that > seems related to that same step (problem was: delete button not working):
> Looking at the history of this HelloWorld tutorial I also saw a repository > on joomlacode.org (by Antonie de Wilde) from 2008. This HelloWorld really > is a long term community project. I also played around with *EasyCreator *since > I'm into Joomla!. That project was started as a tool accompanying this > tutorial. Christophe has done a lot on that too. It is now managed byNikolai Plath(Elkuku) and has "scaffolding" possibilities: it uses a kind of 'template' > to set up the basic files of an extension. You 'only' have to transform it > to your concrete needs. There were 'templates' for the then existing > 1.5-HelloWorld series, but at the moment for 2.5 there are only 2 > component-templates from this series (step 1 and step 12). When we have > updated the steps of this tutorial, I'd like to add Easycreator-templates > for the different steps in this 2.5 wiki-series. I think it can be of good > help for educational purposes. See > http://extensions.joomla.org/extensions/miscellaneous/development/5908, > code on https://github.com/elkuku/EasyCreator
> Ciao, > Herman
> On Sunday, 12 August 2012 19:31:04 UTC+2, Paul Orwig wrote:
>> Hi all,
>> I decided to give the Hello World example a try when I first saw this >> thread. Right now I am having a problem on step 9 but that's not the point >> of my post.
>> The point of my post is just a word of thanks. Thanks to Christophe and >> Ozgur for creating the original tutorial, thanks for those who updated it >> since then, and thanks now to Herman and Elin for the way you have helped >> in this thread, and also for the additional work that is going to be >> applied to the Wiki.
>> A really well documented and comprehensive tutorial on this subject is a >> powerful gift that will help introduce more to Joomla development. The >> willingness to take time to share knowledge and help others is a great >> example of what is special about our project and our community.
I'll make EasyCreator-templates together with updating the code in this series of articles. Then the deprecated stuff like JRequest and JError can at the same time be removed. I'll concentrate on 2.5 and send you the pull-requests. Maybe you could add a short history about EasyCreator in a readme-file in your repository; to correct my information and always nice for later reference. Thank you!
On Monday, 13 August 2012 03:57:39 UTC+2, El KuKu wrote:
> Thank you Herman for your kind words about EasyCreator, although you are > not completely right about its history ;)
> Yes, ATM there are only two templates for J 2.5 projects. I already heard > some complaints about it. > I am also about to drop the Joomla! 1.5 compatibility (there is a 3.0 > branch on GitHub that already contains some work) so maybe this is a good > time to update the templates.
> So I would love to integrate some new templates for Joomla! 3.0. > Feel free to fork/send pull requests to EasyCreators new home:
On Sunday, 12 August 2012 19:14:36 UTC+2, Herman Peeren wrote: > Maybe she can explain some more about what the problem exactly is. And > maybe explain something about the changes that have been made in the > platform for that. That could save some looking-up time. All links to > discussions and code welcome.
On Sunday, 12 August 2012 17:57:43 UTC+2, TDZWeb wrote:
> I don't quite understand the role of categories in all this. I don't > suppose anyone could explain to me exactly why the com_helloworld would > fail without it?
You can use item-level ACL with com_helloworld (or your own component) without using categories, but you have to adjust the code in _getAssetParentId() of your JTable-extension. In that method you have to return the asset_id of the parent of your item.
If you use categories, you have to return the asset_id of the category the item belongs to. If an item does not belong to a category, you'll have to return the asset_id of the (helloworld)component. If you wouldn't override _getAssetParentId(), the asset_id (normally 1) of the root-asset would be returned. You cannot just copy the code used in com_content for your override. Although that component is the only core-component that uses item-level ACL and you would expect it to be an example for developers, it's _getAssetParentId()-code cannot be just copied for a component with item-level ACL in general: it would return the asset_id of the root-asset if an item doesn't belong to a category. In com_content itself that is fixed by making "uncategorised" a category; so every item (article) belongs to a category.
The code for _getAssetParentId() that is now in the tutorial for com_helloworld is not working completely well for categories: the asset_id of com_helloworld is always returned, so when using categories, the permissions of the categories are not inherited. I'll adjust the code. It will partly be the code as used in com_content, but at the end it won't return the parent::_getAssetParentId(), which would always return 1, but instead we have to put there our current code of returning the com_helloworld asset_id. I'll add some comments to make it clear.
In an earlier posting I said that the root-asset could have asset_id 0 or 1: that is wrong! I hadn't read it carefully enough. The problem was that sometimes in the code the root-asset was identified by asset_id=1 and sometimes by parent_id=0. In the platform that code has been updated (by Elin's Pull Request 1416) to the more correct way of identifying the root-asset: by means of getRootId() of JTableAsset (which is a JTableNested).
I also said, that an asset_id wouldn't be a necessary field in your db-table. Well, it could be done, but especially the JTable-API uses it: in the constructor it sets the $_trackAssets boolean to true if an asset_id column is available in the table and that is a flag that you use item-level ACL. You would have to override quite some code to get it working withouit an asset_id column (and it won't improve the code). So, best practice is to just use it.
In the asset-table an asset is identified with 2 different keys: the asset_id and the name (= the string with the dots). You need both: the string is necessary to find the asset-record if you don't know the asset_id; you can easily compose it from the component-name, the item-name (including eventually "category") and the item-id. But the current name-string doesn't give information about the parent in the asset-hierarchy (other than the component itself); if you would for instance have an asset named com_helloworld.message.2, you cannot know from that name whether it is under a category or not. That is why you need the parent_id column in the assets-table. That column uses a asset_id (otherwise the lft and rgt would not work), so an asset_id is necessary too.
This weekend I'll be disconnected from internet due to family-obigations. Monday is spent to our very active JUG (in the afternoon before the JUG-evening we come together with a group of devs; we'll certainly discuss this thread too). I'll continue working on this from Tuesday onwards.
Almost finished. The code in the zip still has to be redone. And some minor changes. It remains work in progress. As an appetizer the article now starts with steps to get the minimum requirements for a component to comply to Joomla!'s ACL. After some research I didn't replace the JError-references, as explained in http://docs.joomla.org/Developing_a_Model-View-Controller_Component/2...
I changed the code of _getAssetParentId() in the HelloWorld-JTable a bit:
protected function _getAssetParentId() { // We will retrieve the parent-asset from the Asset-table $assetParent = JTable::getInstance('Asset'); // Default: if no asset-parent can be found we take the global asset $assetParentId = $assetParent->getRootId();
// Find the parent-asset if (($this->catid)&& !empty($this->catid)) { // The item has a category as asset-parent $assetParent->loadByName('com_helloworld.category.' . (int) $this->catid); } else { // The item has the component as asset-parent $assetParent->loadByName('com_helloworld'); }
// Return the found asset-parent-id if ($assetParent->id) { $assetParentId=$assetParent->id; } return $assetParentId; }
With this comment: This code for _getAssetParentId() above uses JTableAsset to retrieve the asset_id of the asset-parent. This is different from the code in the current version of com_content, where the asset_id of the category is retrieved from the #__categories database table. That is another possibility; many ways leading to Rome. In com_content however, if an item would not be under a category, then the asset_id of the global asset is returned. That would of course not be right, but is fixed there by providing a default category "uncategorised", so that an article is ''always'' under a category. That is why you cannot just copy the code of _getAssetParentId() in com_content to your own component. The code above is more general.
I will make the updated zip, dot some i's and cross some t's, before moving on to the next article. If you have any *suggestions to improve this article * or the series, please let me know.
I've also put up a skeleton for a Wiki-article about how the different parts of the ACL function and work together: http://docs.joomla.org/ACL_Technique_in_Joomla! Feel free to replace a TODO there with the wanted explanation.
> Almost finished. The code in the zip still has to be redone. And some
> minor changes. It remains work in progress.
> As an appetizer the article now starts with steps to get the minimum
> requirements for a component to comply to Joomla!'s ACL.
> After some research I didn't replace the JError-references, as explained
> in
> http://docs.joomla.org/Developing_a_Model-View-Controller_Component/2...
> I changed the code of _getAssetParentId() in the HelloWorld-JTable a bit:
> protected function _getAssetParentId()
> {
> // We will retrieve the parent-asset from the Asset-table
> $assetParent = JTable::getInstance('Asset');
> // Default: if no asset-parent can be found we take the global
> asset
> $assetParentId = $assetParent->getRootId();
> // Find the parent-asset
> if (($this->catid)&& !empty($this->catid))
> {
> // The item has a category as asset-parent
> $assetParent->loadByName('com_helloworld.category.' . (int)
> $this->catid);
> }
> else
> {
> // The item has the component as asset-parent
> $assetParent->loadByName('com_helloworld');
> }
> // Return the found asset-parent-id
> if ($assetParent->id)
> {
> $assetParentId=$assetParent->id;
> }
> return $assetParentId;
> }
> With this comment:
> This code for _getAssetParentId() above uses JTableAsset to retrieve the
> asset_id of the asset-parent. This is different from the code in the
> current version of com_content, where the asset_id of the category is
> retrieved from the #__categories database table. That is another
> possibility; many ways leading to Rome. In com_content however, if an item
> would not be under a category, then the asset_id of the global asset is
> returned. That would of course not be right, but is fixed there by
> providing a default category "uncategorised", so that an article is
> ''always'' under a category. That is why you cannot just copy the code of
> _getAssetParentId() in com_content to your own component. The code above is
> more general.
> I will make the updated zip, dot some i's and cross some t's, before
> moving on to the next article. If you have any *suggestions to improve
> this article* or the series, please let me know.
> I've also put up a skeleton for a Wiki-article about how the different
> parts of the ACL function and work together:
> http://docs.joomla.org/ACL_Technique_in_Joomla! > Feel free to replace a TODO there with the wanted explanation.
> To post to this group, send an email to
> joomla-dev-general@googlegroups.com.
> To unsubscribe from this group, send email to
> joomla-dev-general+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/joomla-dev-general?hl=en-GB.
-- Chris Davenport
Joomla Production Leadership Team