Re: [fw-general] How to escape forward slash in paginator?
On Tue, Jun 16, 2009 at 12:49 AM, Matthew Ratzloff wrote: > You can replace it with a substitute token. There are a variety of > perfectly valid ways to go about it. > -Matt Ok I read the documentation and now I understand that my problem could be solved with custom filter (or probably Escapers). The thing that is not clear to me now is how to implement this. 1. Where does my custom filter code go? controller? or form? 2. After that how to add in filter chain and how to add that custom filter in my form field? My directory structure is: application captcha config controllers forms layouts scripts models dbtable views scripts Currently in my form, the search field is implemented as follows: public function init() { $mysearch = New Zend_Form_Element_Text('srchstr'); $mysearch->setLabel('Search For:'); $mysearch->setAttrib('size', '30'); $mysearch->addFilter('StringTrim'); ... ... ... } Its kind of confusing. Any suggestion (or code sample) greatly appreciated. Thanks again
Re: [fw-general] Zend_Db and the now() keyword?
Hi, Try using Zend_Db_Expr: $data = array( 'orders_status' => (int)$orders_status, 'last_modified' => new Zend_Db_Expr('NOW()')); Regards Håkan Medin On Tue, Jun 16, 2009 at 2:46 AM, Kendall Bennett wrote: > Ok, I am struggling to find a solution to this problem using the Zend_Db > interface. I want to do the following: > > $data = array( > 'orders_status' => (int)$orders_status, > 'last_modified' => 'now()'); > $db->update(TABLE_ORDERS, $data, 'orders_id = ' . (int)$orders_id) > > But the update() method does not understand the now() string and sends it > in the SQL as a string literal, because it gets quoted. Instead I have to do > this: > > $now = date('Y-m-d H:i:s'); > $data = array( > 'orders_status' => (int)$orders_status, > 'last_modified' => $now); > $db->update(TABLE_ORDERS, $data, 'orders_id = ' . (int)$orders_id) > > This works of course, but the problem is I really need to set the value to > the current date time that the query is executed, so it gets the date time > stamp on the DB server, not on the PHP application server. Even though the > values are going to be close, if the database is on a separate server the > timestamps can be slightly different. Worse, if this code was running on a > server farm for the PHP servers, each server could have slightly different > timestamps, and if you are relying on the timestamps to be sequential, you > can run into problems. > > Now clearly I can hand code the SQL inserts, but that defeats the purpose > of having the insert() function. In our existing code the insert() wrapper > special cases the now() string, and passes it through literally. > > Is there any way to do that with Zend_Db? > > Regards, > > *Kendall Bennett, CEO > *A Main Hobbies > 424 Otterson Drive, Suite 160 > Chico, CA 95928 > 1-800-705-2215 (Toll-Free) > 1-530-894-0797 (Int'l & Local) > 1-530-894-9049 (Fax) > *http://www.amainhobbies.com* >
[fw-general] Zend_Tool: Messes up my controller code?
Hello, I have been creating new actions (with views) using zf.sh and noticed that tabs and newlines are inserted into my existing controller file. In short, it is messing up the formatting. Can anyone confirm this? Is this an existing problem in ZF? Thanks, Wenbert - http://blog.ekini.net -- View this message in context: http://www.nabble.com/Zend_Tool%3A-Messes-up-my-controller-code--tp24048388p24048388.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Of 3 methods to centralize code used in all/many controllers which do you use when?
why can't it be all three? seriously though, i'm doing mostly 1, then 3 and 2. On Tue, Jun 16, 2009 at 1:35 PM, joedevon wrote: > > The following question on Stack Overflow prompted this post: > > > http://stackoverflow.com/questions/866367/how-do-i-centralize-code-from-my-init-functions-in-all-controllers/866517 > > "How do I centralize code from my init functions in all controllers?" > > Three answers all work I believe: > > 1. Extend Zend_Controller_Action and have your controllers extend from > THERE > > 2. Write a plugin by extending Zend_Controller_Plugin_Abstract > > 3. Create an Action Helper > > I assume there are situations where each one of those is the best solution. > I've been doing answer 1 mostly, but thinking about switching to answer 3 > for future projects. > > But I'd like to know what the recommended situations are for each solution. > > Thanks. > -- > View this message in context: > http://www.nabble.com/Of-3-methods-to-centralize-code-used-in-all-many-controllers-which-do-you-use-when--tp24047991p24047991.html > Sent from the Zend Framework mailing list archive at Nabble.com. > >
[fw-general] Of 3 methods to centralize code used in all/many controllers which do you use when?
The following question on Stack Overflow prompted this post: http://stackoverflow.com/questions/866367/how-do-i-centralize-code-from-my-init-functions-in-all-controllers/866517 "How do I centralize code from my init functions in all controllers?" Three answers all work I believe: 1. Extend Zend_Controller_Action and have your controllers extend from THERE 2. Write a plugin by extending Zend_Controller_Plugin_Abstract 3. Create an Action Helper I assume there are situations where each one of those is the best solution. I've been doing answer 1 mostly, but thinking about switching to answer 3 for future projects. But I'd like to know what the recommended situations are for each solution. Thanks. -- View this message in context: http://www.nabble.com/Of-3-methods-to-centralize-code-used-in-all-many-controllers-which-do-you-use-when--tp24047991p24047991.html Sent from the Zend Framework mailing list archive at Nabble.com.
[fw-general] Autoloader best practices
I just started to migrate my main application to ZF 1.8.x, I love Zend_Application since it promotes reuse and configuration made all using config.ini. (A note about this, IMHO you should standardize also the name and the location of the configuration file). I rewrote all my previous bootstrap code using only the configuration file, so my bootstrap class now it's almost empty. The only thing I cannot make work is the autoloader since the documentation about that is pretty undetailed. What I want to do is to standardize my classes using a consistent namespace convention, since i have to refactor most of the classes of my app, I want to ask which is the better way to do it before starting. Which I am trying to do is to have modules resources (such as forms, models and so on) inside respective module directory and call a class something like Admin_Model_User or Admin_Form_Login in a structure like this one: application + modules + admin + controllers + forms + Login.php + modules + User.php + views and a library direcotory with common code shared and used across applications with classes named something like Company_Exception_Permission, Company_Plugin_Foo, Company_View_Helper_Date, Company_Form_Validator_Bar or Company_Action_Helper_Log in a structure like this one: application + library + Company + Action + Helper + Log.php + Exception + Permission.php + Form + Validator + Bar.php + Plugin + Foo.php + View + Helper + Date.php How to achieve this using Zend_Loader_Autoloader?? I'm pretty confused about its usage. And one more question, in the configuration file I loaded my plugins and action helpers in this way: ;resources.frontController.plugins.10 = "Company_Plugin_Translator" ;resources.frontController.plugins.20 = "Company_Plugin_DbProfiler" ;resources.frontController.actionhelperpaths.Zenit_Action_Helper_ = APPLICATION_PATH "/var/lib/helpers/action" and in the Bootstrap file I've only this: class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { public function _initAutoloader() { $moduleLoader = new Zend_Application_Module_Autoloader( array ('namespace' => 'Company_', 'basePath' => APPLICATION_PATH . '/var/lib')); return $moduleLoader; } } So it found Company_Plugin_Translator under var/lib/plugins path, but I think this is wrong, because in this way I cannot put resources into modules directory under application. And the last thing: in the index.php file I have this // Ensure library/ is on include_path set_include_path( implode(PATH_SEPARATOR, array ( realpath(APPLICATION_PATH . '/var/lib'), get_include_path(; /** Zend_Application */ require_once 'Zend/Application.php'; // Create application, bootstrap, and run $application = new Zend_Application(APPLICATION_ENV, array ( 'config' => APPLICATION_PATH . '/configs/application.ini', 'pluginPaths' => array ('Company_Application_Resources' => 'resources'))); // run the application $application->bootstrap()->run(); Since I wrote a couple of resource classes, for example to configure logfiles properties via application.ini and I want to reuse them as well, in a new application, I'd like to keep them under the Company directory of the lib folder instead of the resources folder So instead of application + var + lib + resources + Log.php I'd like: application + var + lib + Company + Application + Resources + Log.php I know these are a lot of questions, but please help me, because I'm completly stucked with this thing, and I cannot proceed with development before I solve it. Thanks for any help. -- View this message in context: http://www.nabble.com/Autoloader-best-practices-tp24045941p24045941.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Zend_Db and the now() keyword?
The following example in the documentation should illustrate this: http://framework.zend.com/manual/en/zend.db.html#zend.db.adapter.write.insert.example2 Teddy On Mon, Jun 15, 2009 at 8:46 PM, Kendall Bennett wrote: > Ok, I am struggling to find a solution to this problem using the Zend_Db > interface. I want to do the following: > > $data = array( > 'orders_status' => (int)$orders_status, > 'last_modified' => 'now()'); > $db->update(TABLE_ORDERS, $data, 'orders_id = ' . (int)$orders_id) > > But the update() method does not understand the now() string and sends it > in the SQL as a string literal, because it gets quoted. Instead I have to do > this: > > $now = date('Y-m-d H:i:s'); > $data = array( > 'orders_status' => (int)$orders_status, > 'last_modified' => $now); > $db->update(TABLE_ORDERS, $data, 'orders_id = ' . (int)$orders_id) > > This works of course, but the problem is I really need to set the value to > the current date time that the query is executed, so it gets the date time > stamp on the DB server, not on the PHP application server. Even though the > values are going to be close, if the database is on a separate server the > timestamps can be slightly different. Worse, if this code was running on a > server farm for the PHP servers, each server could have slightly different > timestamps, and if you are relying on the timestamps to be sequential, you > can run into problems. > > Now clearly I can hand code the SQL inserts, but that defeats the purpose > of having the insert() function. In our existing code the insert() wrapper > special cases the now() string, and passes it through literally. > > Is there any way to do that with Zend_Db? > > Regards, > > *Kendall Bennett, CEO > *A Main Hobbies > 424 Otterson Drive, Suite 160 > Chico, CA 95928 > 1-800-705-2215 (Toll-Free) > 1-530-894-0797 (Int'l & Local) > 1-530-894-9049 (Fax) > *http://www.amainhobbies.com* >
[fw-general] Zend_Db and the now() keyword?
Ok, I am struggling to find a solution to this problem using the Zend_Db interface. I want to do the following: $data = array( 'orders_status' => (int)$orders_status, 'last_modified' => 'now()'); $db->update(TABLE_ORDERS, $data, 'orders_id = ' . (int)$orders_id) But the update() method does not understand the now() string and sends it in the SQL as a string literal, because it gets quoted. Instead I have to do this: $now = date('Y-m-d H:i:s'); $data = array( 'orders_status' => (int)$orders_status, 'last_modified' => $now); $db->update(TABLE_ORDERS, $data, 'orders_id = ' . (int)$orders_id) This works of course, but the problem is I really need to set the value to the current date time that the query is executed, so it gets the date time stamp on the DB server, not on the PHP application server. Even though the values are going to be close, if the database is on a separate server the timestamps can be slightly different. Worse, if this code was running on a server farm for the PHP servers, each server could have slightly different timestamps, and if you are relying on the timestamps to be sequential, you can run into problems. Now clearly I can hand code the SQL inserts, but that defeats the purpose of having the insert() function. In our existing code the insert() wrapper special cases the now() string, and passes it through literally. Is there any way to do that with Zend_Db? Regards, Kendall Bennett, CEO A Main Hobbies 424 Otterson Drive, Suite 160 Chico, CA 95928 1-800-705-2215 (Toll-Free) 1-530-894-0797 (Int'l & Local) 1-530-894-9049 (Fax) http://www.amainhobbies.com
Re: [fw-general] Placeholder view helpers in partials don't work for layouts?
dmitrybelyakov wrote: Hi, Today i came across an issue that i couldn’t find a nice solution for. In short it stated in the subject, placeholder view helpers like headScript() don’t work for partials (or any custom view helpers) when in layout context. Like in this example: headLink(); ?> partial('blogposts.phtml')? ... //partial.phtml headLink()->appendStylesheet('partial.css')> ?> So this will not work for the obvious reason - the partial is executed after the placeholder aggregator, so anything appended in the partial view will never get to the head. After some research i see it’s a well-known issue that many people encounter. So my question is - will this issue be addressed in the future versions? Because all the methods like the one described in this thread: http://www.nabble.com/Using-HeadLink-from-a-view-helper-(in-the-layout)-tt20892525.html just seem ... well... not very ‘clean’. Also maybe there’s a known solution that i can use in front controller plugin (for example) that will take care of the issue, or any other approach how this may be implemented. Thanks in advance and good luck. Dmitry. I would say that is not using the paradigm in the way it was intended. Either call the partial in the view, or if the the partial is meant to be the layout of everything, put it directly in the layout.phtml. Layout is the final assembling point for all the other sections. If you have already echo'ed a section into its place then you can't add anymore to the section and expect it to update the already output code.
[fw-general] Placeholder view helpers in partials don't work for layouts?
Hi, Today i came across an issue that i couldn’t find a nice solution for. In short it stated in the subject, placeholder view helpers like headScript() don’t work for partials (or any custom view helpers) when in layout context. Like in this example: headLink(); ?> partial('blogposts.phtml')? ... //partial.phtml headLink()->appendStylesheet('partial.css')> ?> So this will not work for the obvious reason - the partial is executed after the placeholder aggregator, so anything appended in the partial view will never get to the head. After some research i see it’s a well-known issue that many people encounter. So my question is - will this issue be addressed in the future versions? Because all the methods like the one described in this thread: http://www.nabble.com/Using-HeadLink-from-a-view-helper-(in-the-layout)-tt20892525.html just seem ... well... not very ‘clean’. Also maybe there’s a known solution that i can use in front controller plugin (for example) that will take care of the issue, or any other approach how this may be implemented. Thanks in advance and good luck. Dmitry. -- View this message in context: http://www.nabble.com/Placeholder-view-helpers-in-partials-don%27t-work-for-layouts--tp24042045p24042045.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Zend_Application and autoloading
Here's the "default" autoloader as output from xdebug...note that is using a namespace of 'My_' in the Zend_Application_Module_Autoloader object (so not exactly default). Hopefully a cleaned up explanation of this will make it into the online manual soon: object(Zend_Application_Module_Autoloader)[7] protected '_basePath' => string '../application' (length=14) protected '_components' => array 'My_Model_DbTable' => string '../application/models/DbTable' (length=29) 'My_Form' => string '../application/forms' (length=20) 'My_Model' => string '../application/models' (length=21) 'My_Plugin' => string '../application/plugins' (length=22) 'My_Service' => string '../application/services' (length=23) 'My_View_Helper' => string '../application/views/helpers' (length=28) 'My_View_Filter' => string '../application/views/filters' (length=28) protected '_defaultResourceType' => string 'model' (length=5) protected '_namespace' => string 'My' (length=2) protected '_resourceTypes' => array 'dbtable' => array 'namespace' => string 'My_Model_DbTable' (length=16) 'path' => string '../application/models/DbTable' (length=29) 'form' => array 'namespace' => string 'My_Form' (length=7) 'path' => string '../application/forms' (length=20) 'model' => array 'namespace' => string 'My_Model' (length=8) 'path' => string '../application/models' (length=21) 'plugin' => array 'namespace' => string 'My_Plugin' (length=9) 'path' => string '../application/plugins' (length=22) 'service' => array 'namespace' => string 'My_Service' (length=10) 'path' => string '../application/services' (length=23) 'viewhelper' => array 'namespace' => string 'My_View_Helper' (length=14) 'path' => string '../application/views/helpers' (length=28) 'viewfilter' => array 'namespace' => string 'My_View_Filter' (length=14) 'path' => string '../application/views/filters' (length=28) spaceage wrote: > > Joe--I have to study this more closely, but from the table you have > provided, it would appear that certain assumptions are being made by the > autoloader I'm not aware of...too bad this table isn't in the docs ;-) > Thanks--I will study your suggestions and see if I can end my 2 day loss > of time. > > > > > joedevon wrote: >> >> >> spaceage wrote: >>> >>> I should add that 'model' and 'models' were being used interchangeably >>> in both of our posts, and I've updated everything to be >>> 'models'/'Models' throughout... >>> >> I don't know how I missed this post...I wasn't using model and models >> interchangeably...You need to remove plural from new Models_Login to >> Model_Login and also no plural in the class >> >> Taking from Rob's excellent tutorial: >> >> The module autoloader will autoload classes with a certain prefix that >> are in >> certain directories within application/ as per this table: >> >> Directory|Prefix| Example >> = >> api | Api_ | Api_Rest >> forms | Form_ | Form_Login >> models | Model_ | Model_News >> models/DbTable | Model_DbTable_ | Model_DbTable_News >> plugins | Plugin_ |Plugin_ >> >> Hope that table comes out ok...so according to this, the autoloader looks >> in the file and reads the class name, so putting zend form in the models >> directory is messing you up unless I read Rob incorrectly >> > > -- View this message in context: http://www.nabble.com/Zend_Application-and-autoloading-tp23987637p24039315.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Re: [fw-auth] Re: [fw-general] Problem with Zend_Acl
You can gain some performance by adding only the roles you really need for the requested page: http://codeutopia.net/blog/2009/02/18/zend_acl-part-3- creating-and-storing-dynamic-acls/ Regards, Jurian -- Jurian Sluiman Soflomo.com Op Monday 15 June 2009 18:06:29 schreef Hector Virgen: > Try registering your actual App_User and App_GameSheet objects with your > ACL instead of generic role/resource objects. > Change this: > > $acl->addRole(new Zend_Acl_Role('editor')); > $acl->add(new Zend_Acl_Resource('App_GameSheet'); > > to this: > > $acl->addRole(new App_User()); > $acl->add(new App_GameSheet()); > > Internally, Zend_Acl creates a registry of roles/resources and uses the > roleid/resourceid to retrieve the objects from the registry when checking > assertions. > > The only difficulty in this design is that you have to register each > user/resource (unless they can all be grouped into one). > > -Hector > > On Sun, Jun 14, 2009 at 5:11 AM, Abraham Block wrote: > > I wrote a workaround on my blog > > http://www.aviblock.com/blog/2009/03/19/acl-in-zend-framework/#comments > > > > On Sun, Jun 14, 2009 at 5:54 AM, Mon Zafra wrote: > >> Ooops, read the date incorrectly. It's actually 23 months old :p > >> > >>-- Mon > >> > >> On Sun, Jun 14, 2009 at 5:52 PM, Mon Zafra wrote: > >>> That's how I expected assertions to work as well. Transforming the > >>> roles and resources into normal Zend_Acl_Role/Resource really limits > >>> the usefulness of assertions. This issue is exactly two years old now. > >>> There are some workarounds in > >>> http://framework.zend.com/issues/browse/ZF-1721 and related issues. > >>> > >>>-- Mon > >>> > >>> On Sun, Jun 14, 2009 at 4:55 PM, Stefan Gehrig wrote: > Dear all, > > I just started to use Zend_Acl for authorization in one of our > projects but > either I do have some real problem understanding the use of assertions > or > there is some flaw in the assertion design. > I don't know if some other developers stumbled upon this issue - > perhaps it's just that I don't understand the purpose of assertion > correctly. Let's say, we have the following domain models: > > class App_User implements Zend_Acl_Role > { > //... > > public function getId() > { > return $this->_userId; > } > > public function getRoleId() > { > return $this->_group; > } > > //... > } > > class App_GameSheet implements Zend_Acl_Resource > { > //... > > public function getHomeTeamAdminId() > { > return $this->_homeTeamAdminId; > } > > public function getLeagueAdminId() > { > return $this->_leagueAdminId; > } > > public function getResourceId() > { > return __CLASS__; > } > > //... > } > > class App_Acl_GameSheetAssertion implements Zend_Acl_Assert_Interface > { > public function assert(Zend_Acl $acl, Zend_Acl_Role_Interface $role > = null, > Zend_Acl_Resource_Interface $resource = null, $privilege = > null) { > if (($resource instanceof App_GameSheet) && ($role instanceof > App_User)) { > $userId = $role->getId(); > $leagueAdmin = $resource->getLeagueAdminId (); > $homeTeamAdmin = $resource->getHomeTeamAdminId (); > if (in_array($userId, array($leagueAdmin, $homeTeamAdmin))) > { return true; > } else { > return false; > } > } > return null; > } > } > > I though, I could do the following: > > $acl = new Zend_Acl(); > $acl->addRole(new Zend_Acl_Role('editor')); > $acl->addRole(new Zend_Acl_Role('admin'), 'editor); > $acl->add(new Zend_Acl_Resource('App_GameSheet'); > $acl->allow('admin', null, null, null); > $acl->allow('editor', 'App_GameSheet', null, new > App_Acl_GameSheetAssertion()); > > $gameSheet = App_GameSheet::load(123); > $user = App_User::load(456); > var_dump($acl->isAllowed($user, $gameSheet, null)); > > The problem now is that Zend_Acl changes $role and $resource to simple > Zend_Acl_Role and Zend_Acl_Resource objects before passing them into > the assertion. > Am I totally wrong in my understanding of how this should work? I > personally > think that the preceding solution would be a very elegant way to cope > with > such issues. > > Should this be considered a bug or rather an idea for improvement (as > this > surely would break BC it would have to wait until ZF 2.0 I assume)? > Is there
Re: [fw-general] How to escape forward slash in paginator?
You can replace it with a substitute token. There are a variety of perfectly valid ways to go about it. -Matt On Mon, Jun 15, 2009 at 1:57 AM, Deepak wrote: > On Mon, Jun 15, 2009 at 3:56 PM, Deepak wrote: > > On Sun, Jun 14, 2009 at 11:48 PM, Matthew > > Ratzloff wrote: > >> I assume you mean you're using Form's Filter integration. Look into > using > >> Zend_Filter_Callback or writing your own. It's about the same level of > >> effort either way. These pages should help: > >> > http://framework.zend.com/manual/en/zend.form.elements.html#zend.form.elements.filters > >> > http://framework.zend.com/manual/en/zend.filter.set.html#zend.filter.set.callback > >> http://framework.zend.com/manual/en/zend.filter.writing_filters.html > >> -Matt > > > > I am going to try it. I guess this could solve the problem. > > Thanks! > > > > By the way I need some hint (some logical or conceptual steps > explained in plain English). > > My concern is if I modify the query string in any way (such as > removing the slash) may result in different query than that intended > by the user, which might not get the result he/she wants. So if > possible I want to maintain the search string intact but let Apache > mod_rewrite ignore that portion as not the URL but the query string. > > Given the countless numbers of CMS in development, somebody must have > encountered this issue when implementing the particular CMS with > mod_rewrite enabled mode. How do they overcome this issue? > > Thank you again for your valuable time >
[fw-general] Re: [fw-auth] Re: [fw-general] Problem with Zend_Acl
Try registering your actual App_User and App_GameSheet objects with your ACL instead of generic role/resource objects. Change this: $acl->addRole(new Zend_Acl_Role('editor')); $acl->add(new Zend_Acl_Resource('App_GameSheet'); to this: $acl->addRole(new App_User()); $acl->add(new App_GameSheet()); Internally, Zend_Acl creates a registry of roles/resources and uses the roleid/resourceid to retrieve the objects from the registry when checking assertions. The only difficulty in this design is that you have to register each user/resource (unless they can all be grouped into one). -Hector On Sun, Jun 14, 2009 at 5:11 AM, Abraham Block wrote: > > I wrote a workaround on my blog > http://www.aviblock.com/blog/2009/03/19/acl-in-zend-framework/#comments > > > On Sun, Jun 14, 2009 at 5:54 AM, Mon Zafra wrote: > >> Ooops, read the date incorrectly. It's actually 23 months old :p >> >>-- Mon >> >> >> >> On Sun, Jun 14, 2009 at 5:52 PM, Mon Zafra wrote: >> >>> That's how I expected assertions to work as well. Transforming the roles >>> and resources into normal Zend_Acl_Role/Resource really limits the >>> usefulness of assertions. This issue is exactly two years old now. There are >>> some workarounds in http://framework.zend.com/issues/browse/ZF-1721 and >>> related issues. >>> >>>-- Mon >>> >>> >>> >>> On Sun, Jun 14, 2009 at 4:55 PM, Stefan Gehrig wrote: >>> Dear all, I just started to use Zend_Acl for authorization in one of our projects but either I do have some real problem understanding the use of assertions or there is some flaw in the assertion design. I don't know if some other developers stumbled upon this issue - perhaps it's just that I don't understand the purpose of assertion correctly. Let's say, we have the following domain models: class App_User implements Zend_Acl_Role { //... public function getId() { return $this->_userId; } public function getRoleId() { return $this->_group; } //... } class App_GameSheet implements Zend_Acl_Resource { //... public function getHomeTeamAdminId() { return $this->_homeTeamAdminId; } public function getLeagueAdminId() { return $this->_leagueAdminId; } public function getResourceId() { return __CLASS__; } //... } class App_Acl_GameSheetAssertion implements Zend_Acl_Assert_Interface { public function assert(Zend_Acl $acl, Zend_Acl_Role_Interface $role = null, Zend_Acl_Resource_Interface $resource = null, $privilege = null) { if (($resource instanceof App_GameSheet) && ($role instanceof App_User)) { $userId = $role->getId(); $leagueAdmin = $resource->getLeagueAdminId (); $homeTeamAdmin = $resource->getHomeTeamAdminId (); if (in_array($userId, array($leagueAdmin, $homeTeamAdmin))) { return true; } else { return false; } } return null; } } I though, I could do the following: $acl = new Zend_Acl(); $acl->addRole(new Zend_Acl_Role('editor')); $acl->addRole(new Zend_Acl_Role('admin'), 'editor); $acl->add(new Zend_Acl_Resource('App_GameSheet'); $acl->allow('admin', null, null, null); $acl->allow('editor', 'App_GameSheet', null, new App_Acl_GameSheetAssertion()); $gameSheet = App_GameSheet::load(123); $user = App_User::load(456); var_dump($acl->isAllowed($user, $gameSheet, null)); The problem now is that Zend_Acl changes $role and $resource to simple Zend_Acl_Role and Zend_Acl_Resource objects before passing them into the assertion. Am I totally wrong in my understanding of how this should work? I personally think that the preceding solution would be a very elegant way to cope with such issues. Should this be considered a bug or rather an idea for improvement (as this surely would break BC it would have to wait until ZF 2.0 I assume)? Is there any other workaround or design that solves this problem using Zend_Acl? I really thought that I found the philosopher's stone for this problem ;-) Thanks to all of you! Best regards Stefan >>> >> >
Re: [fw-general] Delete Query doesnt work with Zend
Sorry, didn't notice you already provided the delete sql in your original email. It's still early. Anyways, that is not the same as what you are asking zend_db to do. Zend DB will create something like this: "DELETE FROM old_passwords874 WHERE Date_of_Changing = dateval" What you might want is: $db->query('DELETE FROM old_passwords874 WHERE username=? ORDER BY Date_of_Changing ASC LIMIT 1',$user); Mark On Mon, Jun 15, 2009 at 8:50 AM, salma rayan wrote: > I used $sq="DELETE FROM 'old_passwords874' WHERE username='$user' > ORDER BY Date_of_Changing ASC LIMIT 1"; > it works in php my admin but it doesnt work with Zend, > it needs to be quoted because it has a value from the datebase like > 13/5/1988 for example > > > On Mon, Jun 15, 2009 at 5:38 PM, Mark Wright > wrote: >> >> What is the normal sql delete query that you used? Does $dateval need >> to be quoted? >> >> >> Mark >> >> On Mon, Jun 15, 2009 at 8:00 AM, salmarayan wrote: >> > >> > I want to delete a row from the database, when a certain condition >> > occurs >> > so I made a query >> > $db= Zend_Registry::get('db'); >> > $sql="SELECT Date_of_Changing FROM old_passwords874 WHERE username = >> > '$user' >> > ORDER BY Date_of_Changing ASC LIMIT 1"; >> > $result=$db->fetchCol($sql); >> > $dateval=$result[0]; >> > $n= $db->delete('old_passwords874','Date_of_Changing ='.$dateval); >> > >> > The Select query gets the results, but the delete doesnt work there is >> > an >> > error with the where condition of the delete query. >> > i tried the nomral sql delete query >> > $sql="DELETE FROM 'old_passwords874' WHERE username='$user' ORDER BY >> > Date_of_Changing ASC LIMIT 1"; >> > >> > But it doesnt not work with Zend, Please Help.. Thanks in advance. >> > -- >> > View this message in context: >> > http://www.nabble.com/Delete-Query-doesnt-work-with-Zend-tp24035172p24035172.html >> > Sent from the Zend Framework mailing list archive at Nabble.com. >> > >> > >> >> >> >> -- >> Have fun or die trying - but try not to actually die. > > -- Have fun or die trying - but try not to actually die.
Re: [fw-general] Tricky Router Question
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I'd suggest that you extend the dispatcher and check inside there, if an overring controller exists (and also make sure, that it extends the original controller). Then additionally, cache the result of the check (memcached if possible) so you avoid too many disk stats. ... : ___ _ ___ ___ ___ _ ___: : | \ /_\ / __| _ \ _ (_) \ : : | |) / _ \\__ \ _/ / | |) | : : |___/_/:\_\___/_| |_|_\_|___/ : ::: : Web: http://www.dasprids.de : : E-mail : m...@dasprids.de : : Jabber : jab...@dasprids.de : : ICQ: 105677955 : ::: jlevy schrieb: > Or perhaps it's the most basic... > > Allow me to give you some background. > > The directory structure of my application has gone through various different > incarnations over time. The current directory structure is pretty much the > final form I intend on going with. Here's what I've got: > > application/ > /modules/ > /models/ > /helpers/ > /plugins/ > extensions/ > /client_1 > /client_2 > > The rationale behind this structure is quite simple: Some of our clients > like to (or will soon be) writing their own controllers, views, models, etc. > We determined the safest way to do this was to create a directory outside of > the main application code, and set up a jailed FTP system for the users to > connect to and deposit their code. (The old way had client modules resident > in the applications/modules directory, this caused headaches galore) > > Anyway. Now that you have some understanding of the basic directory > structure, I'd like to inchworm toward the real question: "What is the best > way to override controllers in the default module for particular calls?" IE: > The default module (which is housed underneath application/modules/default), > contains about 2 dozen controllers. For example: > - application/modules/default/userController.php > - application/modules/default/productController.php > etc. > In some situations, a client may wish to 'override' a default controller, > say, > extensions/client_1/controllers/userController.php > Note: userController.php extends Default_UserController.php <<< > > What I'm trying to figure out is this: Presently, I can route to an > 'overridden' controller thus: http://foo.server.com/client_1/user/index. > This works great. But what I want to do, and I think this is set up in my > bootstrapper, is "detect" if that userController exists in the > client_1/controller director, thus, providing an override. Ie: Instead of > http://foo.server.com/client_1/user/index -- I want > http://foo.server.com/user/index. > > Right now, this simply routes the client to the default User controller. > > I'm having a devil of a time trying to determine what to do to get the ZF to > actually route to the extensions/client_1/controller/userController ... > > If anyone can point out some obvious idiocies in my question, please, let me > know. I'll be watching this thread like a Nun at Sunday School. > > Thanks! > -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAko2YGcACgkQ0HfT5Ws789C4JwCfaboMtmYdWGvvrW171iNOAUpS vl0AoJxnHsn7vztZZpPpu4wHCWc5WDD/ =llPb -END PGP SIGNATURE-
Re: [fw-general] Delete Query doesnt work with Zend
What is the normal sql delete query that you used? Does $dateval need to be quoted? Mark On Mon, Jun 15, 2009 at 8:00 AM, salmarayan wrote: > > I want to delete a row from the database, when a certain condition occurs > so I made a query > $db= Zend_Registry::get('db'); > $sql="SELECT Date_of_Changing FROM old_passwords874 WHERE username = '$user' > ORDER BY Date_of_Changing ASC LIMIT 1"; > $result=$db->fetchCol($sql); > $dateval=$result[0]; > $n= $db->delete('old_passwords874','Date_of_Changing ='.$dateval); > > The Select query gets the results, but the delete doesnt work there is an > error with the where condition of the delete query. > i tried the nomral sql delete query > $sql="DELETE FROM 'old_passwords874' WHERE username='$user' ORDER BY > Date_of_Changing ASC LIMIT 1"; > > But it doesnt not work with Zend, Please Help.. Thanks in advance. > -- > View this message in context: > http://www.nabble.com/Delete-Query-doesnt-work-with-Zend-tp24035172p24035172.html > Sent from the Zend Framework mailing list archive at Nabble.com. > > -- Have fun or die trying - but try not to actually die.
[fw-general] Delete Query doesnt work with Zend
I want to delete a row from the database, when a certain condition occurs so I made a query $db= Zend_Registry::get('db'); $sql="SELECT Date_of_Changing FROM old_passwords874 WHERE username = '$user' ORDER BY Date_of_Changing ASC LIMIT 1"; $result=$db->fetchCol($sql); $dateval=$result[0]; $n= $db->delete('old_passwords874','Date_of_Changing ='.$dateval); The Select query gets the results, but the delete doesnt work there is an error with the where condition of the delete query. i tried the nomral sql delete query $sql="DELETE FROM 'old_passwords874' WHERE username='$user' ORDER BY Date_of_Changing ASC LIMIT 1"; But it doesnt not work with Zend, Please Help.. Thanks in advance. -- View this message in context: http://www.nabble.com/Delete-Query-doesnt-work-with-Zend-tp24035172p24035172.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Zend_Navigation: visible in sitemap, not in menu
Hi all, I finally managed to override the Zend_Navigation helpers. I think the Zend_Navigation hasn't seen some serious design flaws, because this implementation made it impossible to create your own navigation classes based on existing classes! The Zend_View_Helper_Navigation adds a new helper path, defined in a constant. Now this path is the latest added, so it'd *always* find its classes because it's the latest namespace in the plugin loader. To avoid it, you have to create your own navigation helper, override the const NS *and* copy/paste the whole findHelper() method. Now you can create your own classes and they will be loaded correctly. Isn't it possible to try to load a navigation helper, and when it fails *then* you add the new scriptpath and tries it again? That will solve a lot of trouble e.g. when extending the sitemap helper. Regards, Jurian -- Jurian Sluiman Soflomo.com Op Monday 15 June 2009 10:36:39 schreef Jurian Sluiman: > Hi all, > I'd have a menu created by Zend_Navigation. These menu items can be visible > or not. I use the breadcrumbs and sitemap helpers as well. > > I'd like to show the breadcrumbs correctly with the full path even if the > page isn't visible. The same for the sitemap: not al navigation items > should show up in the menu, but be accessible at the sitemap for sure. > > How is this possible to manage? Should I file a patch which provides a > method showInvisible() which is used in the HelperAbstract::accept() method > (the accept() determines whether a page is shown or not). > > Regards, Jurian > -- > Jurian Sluiman > Soflomo.com
[fw-general] Tricky Router Question
Or perhaps it's the most basic... Allow me to give you some background. The directory structure of my application has gone through various different incarnations over time. The current directory structure is pretty much the final form I intend on going with. Here's what I've got: application/ /modules/ /models/ /helpers/ /plugins/ extensions/ /client_1 /client_2 The rationale behind this structure is quite simple: Some of our clients like to (or will soon be) writing their own controllers, views, models, etc. We determined the safest way to do this was to create a directory outside of the main application code, and set up a jailed FTP system for the users to connect to and deposit their code. (The old way had client modules resident in the applications/modules directory, this caused headaches galore) Anyway. Now that you have some understanding of the basic directory structure, I'd like to inchworm toward the real question: "What is the best way to override controllers in the default module for particular calls?" IE: The default module (which is housed underneath application/modules/default), contains about 2 dozen controllers. For example: - application/modules/default/userController.php - application/modules/default/productController.php etc. In some situations, a client may wish to 'override' a default controller, say, extensions/client_1/controllers/userController.php >>> Note: userController.php extends Default_UserController.php <<< What I'm trying to figure out is this: Presently, I can route to an 'overridden' controller thus: http://foo.server.com/client_1/user/index. This works great. But what I want to do, and I think this is set up in my bootstrapper, is "detect" if that userController exists in the client_1/controller director, thus, providing an override. Ie: Instead of http://foo.server.com/client_1/user/index -- I want http://foo.server.com/user/index. Right now, this simply routes the client to the default User controller. I'm having a devil of a time trying to determine what to do to get the ZF to actually route to the extensions/client_1/controller/userController ... If anyone can point out some obvious idiocies in my question, please, let me know. I'll be watching this thread like a Nun at Sunday School. Thanks! -- View this message in context: http://www.nabble.com/Tricky-Router-Question-tp24034338p24034338.html Sent from the Zend Framework mailing list archive at Nabble.com.
[fw-general] Blank Error Page
Hi, I'm porting my application to another server, I have some problem doing this because I get a blank error page. Also my applicationErrors.txt is blank. This server has the capabilities to show error set to true. Also, I put phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1 on my application.ini file. I've got this error in the past and was caused by a non-writeable data that needs to be writeable ( lucene index, uploads, cache.. ) but it is not this tha cause as I have the right permissions on these files. Is there any way to show what's happening in my application? I just want to see an error :) Advices are really appreciated Thanks Sergio Rinaudo _ Quante ne sai? Gioca con Crosswire e mettiti alla prova! http://livesearch.games.msn.com/crosswire/default_it/
Re: [fw-general] How to escape forward slash in paginator?
On Mon, Jun 15, 2009 at 3:56 PM, Deepak wrote: > On Sun, Jun 14, 2009 at 11:48 PM, Matthew > Ratzloff wrote: >> I assume you mean you're using Form's Filter integration. Look into using >> Zend_Filter_Callback or writing your own. It's about the same level of >> effort either way. These pages should help: >> http://framework.zend.com/manual/en/zend.form.elements.html#zend.form.elements.filters >> http://framework.zend.com/manual/en/zend.filter.set.html#zend.filter.set.callback >> http://framework.zend.com/manual/en/zend.filter.writing_filters.html >> -Matt > > I am going to try it. I guess this could solve the problem. > Thanks! > By the way I need some hint (some logical or conceptual steps explained in plain English). My concern is if I modify the query string in any way (such as removing the slash) may result in different query than that intended by the user, which might not get the result he/she wants. So if possible I want to maintain the search string intact but let Apache mod_rewrite ignore that portion as not the URL but the query string. Given the countless numbers of CMS in development, somebody must have encountered this issue when implementing the particular CMS with mod_rewrite enabled mode. How do they overcome this issue? Thank you again for your valuable time
[fw-general] Zend_Navigation: visible in sitemap, not in menu
Hi all, I'd have a menu created by Zend_Navigation. These menu items can be visible or not. I use the breadcrumbs and sitemap helpers as well. I'd like to show the breadcrumbs correctly with the full path even if the page isn't visible. The same for the sitemap: not al navigation items should show up in the menu, but be accessible at the sitemap for sure. How is this possible to manage? Should I file a patch which provides a method showInvisible() which is used in the HelperAbstract::accept() method (the accept() determines whether a page is shown or not). Regards, Jurian -- Jurian Sluiman Soflomo.com
[fw-general] Autoloader confusion
Hi, I feel I'm missing something with Zend_Loader_Autoload, as I can't make it do what I want! I think the relevant points are: 1) my models are are in a models directory and are not prefixed - models/SomeTable.php contains class SomeTable extends Zend_Db_Table_Abstract, etc. 2) I'm using a 3rd-party library which has it's own autoloader, and also does not use prefixes (DOMPDF), living in /library/DOMPDF 3) My models are loaded fine by Zend_Loader with no intervention on my part, all very straighforward. However, when I need to use the 3rd-party library, I want to be able to register the new autoloader such that classes are autoloaded first from my models directory or failing that, from /library/DOMPDF. So I can call $class = new SomeTable() (using Zend_Loader) or $class = new class_in_DOMPDF() (using DomPDF::autoload()) and have them both work. The only way I have been able to make this work is to unregister Zend_Loader::autoload and register DOMPDF::autoload; after I've finished with the class, I have to unregister DOMPDF::autoload & re-register Zend_Loader::autoload. If I don't do this, then I get errors from one autoloader or the other about not being able to find classes which should properly be loaded by the other autoloader. I don't want to prefix my models with anything (because it would be a huge amount of work to retrofit this), and I don't want to have to prefix every class in DOMPDF (as it will be a huge amount of work and also break on upgrades). How should I do this? I'm certain my approach is missing the point fairly badly! Cheers, Mark -- View this message in context: http://www.nabble.com/Autoloader-confusion-tp24030297p24030297.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] How to escape forward slash in paginator?
On Sun, Jun 14, 2009 at 11:48 PM, Matthew Ratzloff wrote: > I assume you mean you're using Form's Filter integration. Look into using > Zend_Filter_Callback or writing your own. It's about the same level of > effort either way. These pages should help: > http://framework.zend.com/manual/en/zend.form.elements.html#zend.form.elements.filters > http://framework.zend.com/manual/en/zend.filter.set.html#zend.filter.set.callback > http://framework.zend.com/manual/en/zend.filter.writing_filters.html > -Matt I am going to try it. I guess this could solve the problem. Thanks!