Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Tutorial problem: Developing MVC Component for Joomla!2.5
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 26 - 49 of 49 - Collapse all  -  Translate all to Translated (View all originals) < Older 
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
elin  
View profile  
 More options Aug 10 2012, 9:13 am
From: elin <elin.war...@gmail.com>
Date: Fri, 10 Aug 2012 06:13:24 -0700 (PDT)
Local: Fri, Aug 10 2012 9:13 am
Subject: Re: [jgen] Tutorial problem: Developing MVC Component for Joomla!2.5

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
TDZWeb  
View profile  
 More options Aug 10 2012, 2:22 pm
From: TDZWeb <webmas...@tdzwebdesign.no>
Date: Fri, 10 Aug 2012 11:22:09 -0700 (PDT)
Local: Fri, Aug 10 2012 2:22 pm
Subject: Re: [jgen] Tutorial problem: Developing MVC Component for Joomla!2.5

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 must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Herman Peeren  
View profile  
 More options Aug 10 2012, 4:05 pm
From: Herman Peeren <herman.pee...@gmail.com>
Date: Fri, 10 Aug 2012 13:05:04 -0700 (PDT)
Local: Fri, Aug 10 2012 4:05 pm
Subject: Re: [jgen] Tutorial problem: Developing MVC Component for Joomla!2.5

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.

Got a whole list of additions to the code in this Wiki-article now.
BTW: found this which also gives a recipe what to do to get this example
working: https://www.joomlajingle.com/blog/39-joomla-acl-for-developers

Ciao,
Herman


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
elin  
View profile  
 More options Aug 11 2012, 7:03 am
From: elin <elin.war...@gmail.com>
Date: Sat, 11 Aug 2012 04:03:36 -0700 (PDT)
Local: Sat, Aug 11 2012 7:03 am
Subject: Re: [jgen] Tutorial problem: Developing MVC Component for Joomla!2.5

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...

Elin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
TDZWeb  
View profile  
 More options Aug 11 2012, 8:18 am
From: TDZWeb <webmas...@tdzwebdesign.no>
Date: Sat, 11 Aug 2012 05:18:57 -0700 (PDT)
Local: Sat, Aug 11 2012 8:18 am
Subject: Re: [jgen] Tutorial problem: Developing MVC Component for Joomla!2.5

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*

<fieldset name="accesscontrol">
<field name="asset_id" type="hidden" filter="unset" />
<field name="rules"
type="rules"
label="JFIELD_RULES_LABEL"
translate_label="false"
filter="rules"
validate="rules"
class="inputbox"
component="com_helloworld"
section="message"
/>
</fieldset>

   - Adding a category section to* admin/access.xml*.

*<section name="category">*
* <action name="core.create" title="JACTION_CREATE"
description="COM_CATEGORIES_ACCESS_CREATE_DESC" />*
* <action name="core.delete" title="JACTION_DELETE"
description="COM_CATEGORIES_ACCESS_DELETE_DESC" />*
* <action name="core.edit" title="JACTION_EDIT"
description="COM_CATEGORIES_ACCESS_EDIT_DESC" />*
* <action name="core.edit.state" title="JACTION_EDITSTATE"
description="COM_CATEGORIES_ACCESS_EDITSTATE_DESC" />*
* <action name="core.edit.own" title="JACTION_EDITOWN"
description="COM_CATEGORIES_ACCESS_EDITOWN_DESC" />*
*</section>*

   - 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:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
elin  
View profile  
 More options Aug 11 2012, 9:14 am
From: elin <elin.war...@gmail.com>
Date: Sat, 11 Aug 2012 06:14:24 -0700 (PDT)
Local: Sat, Aug 11 2012 9:14 am
Subject: Re: Tutorial problem: Developing MVC Component for Joomla!2.5

Thanks Herman! That tutorial is really turning into a great collaborative
document.

Elin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Herman Peeren  
View profile  
 More options Aug 11 2012, 3:08 pm
From: Herman Peeren <herman.pee...@gmail.com>
Date: Sat, 11 Aug 2012 12:08:25 -0700 (PDT)
Local: Sat, Aug 11 2012 3:08 pm
Subject: Re: [jgen] Tutorial problem: Developing MVC Component for Joomla!2.5

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.  


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Swapnil Shah  
View profile  
 More options Aug 11 2012, 3:12 pm
From: Swapnil Shah <swapnilsha...@gmail.com>
Date: Sat, 11 Aug 2012 15:12:57 -0400
Local: Sat, Aug 11 2012 3:12 pm
Subject: Re: [jgen] Tutorial problem: Developing MVC Component for Joomla!2.5

Hey Herman / Elin,

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.

--
Sent from Gmail Mobile

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
TDZWeb  
View profile  
 More options Aug 11 2012, 3:19 pm
From: TDZWeb <webmas...@tdzwebdesign.no>
Date: Sat, 11 Aug 2012 12:19:56 -0700 (PDT)
Local: Sat, Aug 11 2012 3:19 pm
Subject: Re: [jgen] Tutorial problem: Developing MVC Component for Joomla!2.5

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:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Herman Peeren  
View profile  
 More options Aug 11 2012, 3:41 pm
From: Herman Peeren <herman.pee...@gmail.com>
Date: Sat, 11 Aug 2012 12:41:37 -0700 (PDT)
Local: Sat, Aug 11 2012 3:41 pm
Subject: Re: Tutorial problem: Developing MVC Component for Joomla!2.5

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.

Another Wiki-article about using item-level ACL:
http://docs.joomla.org/Adding_ACL_rules_to_your_component
Will put references in the footer of "our" ACL-article.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Herman Peeren  
View profile  
 More options Aug 11 2012, 3:45 pm
From: Herman Peeren <herman.pee...@gmail.com>
Date: Sat, 11 Aug 2012 12:45:47 -0700 (PDT)
Local: Sat, Aug 11 2012 3:45 pm
Subject: Re: [jgen] Tutorial problem: Developing MVC Component for Joomla!2.5

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...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Herman Peeren  
View profile  
 More options Aug 11 2012, 3:53 pm
From: Herman Peeren <herman.pee...@gmail.com>
Date: Sat, 11 Aug 2012 12:53:41 -0700 (PDT)
Local: Sat, Aug 11 2012 3:53 pm
Subject: Re: [jgen] Tutorial problem: Developing MVC Component for Joomla!2.5

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.

Ciao,
Herman


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Herman Peeren  
View profile  
 More options Aug 11 2012, 3:56 pm
From: Herman Peeren <herman.pee...@gmail.com>
Date: Sat, 11 Aug 2012 12:56:00 -0700 (PDT)
Subject: Re: [jgen] Tutorial problem: Developing MVC Component for Joomla!2.5

We can also once do a Skype chat or maybe a Google+ hangout with more
people about the subject.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Herman Peeren  
View profile  
 More options Aug 12 2012, 4:00 am
From: Herman Peeren <herman.pee...@gmail.com>
Date: Sun, 12 Aug 2012 01:00:55 -0700 (PDT)
Local: Sun, Aug 12 2012 4:00 am
Subject: Re: [jgen] Tutorial problem: Developing MVC Component for Joomla!2.5

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/

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
TDZWeb  
View profile  
 More options Aug 12 2012, 11:57 am
From: TDZWeb <webmas...@tdzwebdesign.no>
Date: Sun, 12 Aug 2012 08:57:43 -0700 (PDT)
Local: Sun, Aug 12 2012 11:57 am
Subject: Re: [jgen] Tutorial problem: Developing MVC Component for Joomla!2.5

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:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Herman Peeren  
View profile  
 More options Aug 12 2012, 1:14 pm
From: Herman Peeren <herman.pee...@gmail.com>
Date: Sun, 12 Aug 2012 10:14:36 -0700 (PDT)
Local: Sun, Aug 12 2012 1:14 pm
Subject: Re: [jgen] Tutorial problem: Developing MVC Component for Joomla!2.5

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul Orwig  
View profile  
 More options Aug 12 2012, 1:31 pm
From: Paul Orwig <paul.or...@opensourcematters.org>
Date: Sun, 12 Aug 2012 11:31:04 -0600
Local: Sun, Aug 12 2012 1:31 pm
Subject: Re: [jgen] Tutorial problem: Developing MVC Component for Joomla!2.5

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.

Thanks,

paul

On Sun, Aug 12, 2012 at 11:14 AM, Herman Peeren <herman.pee...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Herman Peeren  
View profile  
 More options Aug 12 2012, 2:51 pm
From: Herman Peeren <herman.pee...@gmail.com>
Date: Sun, 12 Aug 2012 11:51:20 -0700 (PDT)
Local: Sun, Aug 12 2012 2:51 pm
Subject: Re: [jgen] Tutorial problem: Developing MVC Component for Joomla!2.5

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

Ciao,
Herman


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
El KuKu  
View profile  
 More options Aug 12 2012, 9:57 pm
From: El KuKu <der.el.k...@gmail.com>
Date: Sun, 12 Aug 2012 18:57:39 -0700 (PDT)
Local: Sun, Aug 12 2012 9:57 pm
Subject: Re: [jgen] Tutorial problem: Developing MVC Component for Joomla!2.5

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:

https://github.com/elkuku/EasyCreator

Regards,
Nikolai

Am Sonntag, 12. August 2012 13:51:20 UTC-5 schrieb Herman Peeren:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Herman Peeren  
View profile  
 More options Aug 13 2012, 2:02 am
From: Herman Peeren <herman.pee...@gmail.com>
Date: Sun, 12 Aug 2012 23:02:28 -0700 (PDT)
Local: Mon, Aug 13 2012 2:02 am
Subject: Re: [jgen] Tutorial problem: Developing MVC Component for Joomla!2.5

Hi Nikolai,

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!

Kind regards,
Herman


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Herman Peeren  
View profile  
 More options Aug 13 2012, 2:05 am
From: Herman Peeren <herman.pee...@gmail.com>
Date: Sun, 12 Aug 2012 23:05:00 -0700 (PDT)
Subject: Re: [jgen] Tutorial problem: Developing MVC Component for Joomla!2.5

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.

 There is a lot of information in
https://github.com/joomla/joomla-platform/pull/1416, including the 2
patches.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Herman Peeren  
View profile   Translate to Translated (View Original)
 More options Aug 17 2012, 2:58 pm
From: Herman Peeren <herman.pee...@gmail.com>
Date: Fri, 17 Aug 2012 11:58:45 -0700 (PDT)
Local: Fri, Aug 17 2012 2:58 pm
Subject: Re: [jgen] Tutorial problem: Developing MVC Component for Joomla!2.5

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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Herman Peeren  
View profile  
 More options Aug 26 2012, 10:31 am
From: Herman Peeren <herman.pee...@gmail.com>
Date: Sun, 26 Aug 2012 07:31:54 -0700 (PDT)
Local: Sun, Aug 26 2012 10:31 am
Subject: Re: [jgen] Tutorial problem: Developing MVC Component for Joomla!2.5

I've updated this MVC-tutorial article #14:
http://docs.joomla.org/Developing_a_Model-View-Controller_Component/2...

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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris Davenport  
View profile  
 More options Aug 26 2012, 4:32 pm
From: Chris Davenport <chris.davenp...@joomla.org>
Date: Sun, 26 Aug 2012 21:32:28 +0100
Local: Sun, Aug 26 2012 4:32 pm
Subject: Re: [jgen] Tutorial problem: Developing MVC Component for Joomla!2.5

Hi Herman,

Thanks for the fantastic work you've been doing on improving the MVC
tutorial.  It's great to see the progress that's been made on it recently.

Keep up the good work,
Chris.

On 26 August 2012 15:31, Herman Peeren <herman.pee...@gmail.com> wrote:

--
Chris Davenport
Joomla Production Leadership Team

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages < Older 
« Back to Discussions « Newer topic     Older topic »