Logs for #cakephp

Page 14 of 36,922, showing 100 records out of 3,692,143 total, starting on record 1,301, ending on 1,400

# At Username Text
# Jul 8th 2021, 10:50 paolo.bragagni $lingue = $this->Libri->Lingue->find('list',['conditions' => ['id' => $libro->lingua_id]]);
# Jul 8th 2021, 10:50 paolo.bragagni In my edit.twig I'd like to make something like this
# Jul 8th 2021, 08:10 erwane Thanks
# Jul 8th 2021, 07:44 dereuromark Range() and loop + translation inside a helper
# Jul 8th 2021, 07:26 kevin.pfeifer You can create a custom view helper if you want
# Jul 8th 2021, 07:20 erwane There is a simple way to create a select of weekdays ? (monday, tuesday, ..) Except creating an array with all days and pass to options ;)
# Jul 7th 2021, 19:58 steinkel you can add generic logic to AppController beforeFilter and use `allow` if you check the controller name and action. BUT it would be much better to have the allow per controller in the respective beforeFilter
# Jul 7th 2021, 19:57 steinkel which version are you using? would be possibly for you to upgrade?
# Jul 7th 2021, 17:36 kevin.pfeifer you can also use mass assignment for the accessible array https://book.cakephp.org/4/en/orm/entities.html#mass-assignment and just set those to false which shouldn't be accessible (like here) https://github.com/dereuromark/cakephp-queue/blob/master/src/Model/Entity/QueueProcess.php
# Jul 7th 2021, 17:31 tyler.adam.lazenby but now it is fixed
# Jul 7th 2021, 17:31 tyler.adam.lazenby ungh I have spent way too long trying to track that down
# Jul 7th 2021, 17:30 tyler.adam.lazenby Thank you so much!!!!
# Jul 7th 2021, 17:20 greg138 `'customer_id' => false,`
# Jul 7th 2021, 17:10 tyler.adam.lazenby and I am not sure why
# Jul 7th 2021, 17:10 tyler.adam.lazenby it saves the user but the customer ID is being saved as null
# Jul 7th 2021, 17:09 tyler.adam.lazenby ```$validator ->scalar('customer_id') ->maxLength('customer_id', 255) ->requirePresence('customer_id', 'create') ->notEmptyString('customer_id');```
# Jul 7th 2021, 17:09 tyler.adam.lazenby ```class User extends Entity implements IdentityInterface, \Authorization\IdentityInterface { use LazyLoadEntityTrait; /** * Fields that can be mass assigned using newEntity() or patchEntity(). * * Note that when '*' is set to true, this allows all unspecified fields to * be mass assigned. For security purposes, it is advised to set '*' to false * (or remove it), and explicitly make
# Jul 7th 2021, 17:09 slackebot2 individual fields accessible as needed. * * @var array */ protected $_accessible = [ 'user_username' => true, 'user_email' => true, 'user_first_name' => true, 'user_last_name' => true, 'user_password' => true, 'user_type' => true, 'operator_id' => true, 'state_owner_id' => true, 'forgot_pw_token_ts' => true, 'time_created' => true,
# Jul 7th 2021, 17:09 slackebot2 'time_updated' => true, 'forgot_pw_token' => true, 'customer_id' => false, 'user_type_id' => true, 'operator' => true, 'state_owner' => true, 'new_user_type' => true, 'authority' => true, ];```
# Jul 7th 2021, 17:09 tyler.adam.lazenby ```$customer = $this->Woocommerce->createCustomer($woo_data); if (!$customer->id) { $this->Flash->error(__('The user could not be created on the shop. Please try again. If this problem persists please contact support.')); } else { $data['customer_id'] = $customer->id; debug($data); $user = $this->Users->patchEntity($user, $data, ['associations' => ['Operators']]); dd($user); if
# Jul 7th 2021, 17:09 slackebot2 ($this->Users->save($user)) { $this->Flash->success(__('The user has been saved.')); return $this->redirect(['action' => 'index']); } $this->Flash->error(__('The user could not be saved. Please, try again.')); }```
# Jul 7th 2021, 17:09 tyler.adam.lazenby I am trying to set a unique value called customer_id into my users table. It is for a woocommerce data and it isn't saving
# Jul 7th 2021, 16:20 dereuromark yeah, it is about the files in git :) so in the end it should completely not matter what the folders are, if they are created in the right env anyway.
# Jul 7th 2021, 16:16 bato I don't think git tracks directory permissions. Anyway stay close to prod evn makes sense
# Jul 7th 2021, 16:11 kevin.pfeifer indeed
# Jul 7th 2021, 16:11 dereuromark yeah, which is not relevant for normal files :)
# Jul 7th 2021, 16:11 kevin.pfeifer git ignores/forgets executable bit by default as far as i know
# Jul 7th 2021, 16:10 dereuromark either way, staying local more close to prod env is a plus. that includes the creation of files and folders, which in return takes all issues away about permissions
# Jul 7th 2021, 16:10 dereuromark but yeah, depends on the deploy strategy.
# Jul 7th 2021, 16:10 dereuromark git doesnt lose permissions when checking it out :) at least for me it doesnt
# Jul 7th 2021, 16:06 bato :thinking_face: I think the `i18n` shell script is intended to be used in "dev" instance (local, docker, container, etc...) to create translations. Then it will be pushed to a (probably) git repository. When the repository is cloned that permissions are lost. So I can't figure out why there is need of 770 permissions, but maybe it's my limitations. Thanks for the support as usual ;)
# Jul 7th 2021, 14:52 dereuromark https://stackoverflow.com/questions/19547085/differences-between-chmod-755-vs-750-permissions-set => why would world need access to those if the servers are properly (securely) configured?
# Jul 7th 2021, 14:52 dereuromark linux :) which means local PC but internet apps (which means not so local apps on the web) are not targeting you yourself on your computer, but on remote servers
# Jul 7th 2021, 14:47 bato in linux system the folder created are 775 by default, why it should be 770?
# Jul 7th 2021, 14:44 dereuromark yeah, I didnt have any issues so far, and I run multiple apps through the same container.
# Jul 7th 2021, 14:43 dereuromark i dont think it is a bug, the permissions shouldnt be larger by default for any folder. any if you use the tools I mentioned there will never be such issues.
# Jul 7th 2021, 14:42 bato devilbox seems cool also if missing PHP 7.4 and 8. Anyway I think it's a bug, I'll try to open a PR later
# Jul 7th 2021, 14:35 dereuromark devilbox is just awesome. works ootb (pun intended).
# Jul 7th 2021, 14:34 dereuromark thats why you always use a box (vm or docker) :)
# Jul 7th 2021, 14:30 bato If missing `Locale`folder `bin/cake i18n extract` create new one with permissions `770` If web server isn't the creator or doesn't belong to the group, it can't access to that folder
# Jul 7th 2021, 14:24 bato solved... it was a permission issue on `Locale` folder
# Jul 7th 2021, 14:11 bmudda @alamnaryab you can try this plugin for populating created and modified by attributes: https://github.com/UseMuffin/Footprint
# Jul 7th 2021, 13:59 dereuromark I would debug the __d() function and what it looks up in the end, what language it tries to find etc
# Jul 7th 2021, 13:59 dereuromark cake generates the mo file, no need to do anything from normal po usage
# Jul 7th 2021, 13:57 kevin.pfeifer So you edit the `my_plugin.po` with something like PoEdit and generate a `my_plugin.mo` from it, right?
# Jul 7th 2021, 13:55 bato Uhm... so should it work automatically? No need to configure anything else in plugin?
# Jul 7th 2021, 13:51 dereuromark well, 2 should also be fine. https://github.com/cakephp/localized/tree/3.x/src/Locale
# Jul 7th 2021, 13:50 dereuromark I always used 3 letter iso codes in cake3 ( https://github.com/dereuromark/cakephp-tools/tree/cake3/src/Locale ), not sure if that makes a difference in the end.
# Jul 7th 2021, 13:36 bato Hi all, I need some help with localization in a plugin for CakePHP 3.9. I have a plugin named `MyPlugin` and I made translations using `__d()` and domain `my_plugin`. Then I have extracted transaltions with `./bin/cake I18n extract --plugin MyPlugin` generating `my_plugin.pot` file inside the plugin `src/Locale` directory. I have generated `src/Locale/it/my_plugin.po` file with `./bin/cake i18n init it -p MyPlugin` To test it I'm
# Jul 7th 2021, 13:36 slackebot2 forcing locale `I18n::setLocale('it')` but the strings aren't translated. Do I need to add/load a translator for the plugin?
# Jul 7th 2021, 13:14 dereuromark As only the controller should have access to request data.
# Jul 7th 2021, 13:13 dereuromark Usually you would pass in that data from the controller layer into the model layer and then the behavior can use that.
# Jul 7th 2021, 13:13 dereuromark I think Utils one contains one. Well, they are also cheating a bit using global auth forwarding :) But better than nothing. https://github.com/cakemanager/cakephp-utils/blob/master/src/Model/Behavior/WhoDidItBehavior.php
# Jul 7th 2021, 13:11 dereuromark At the very least a session class wrapper would be appropriate here.
# Jul 7th 2021, 13:11 alamnaryab no, how can I use the default one?
# Jul 7th 2021, 13:11 dereuromark See awesome list. The main problem with yours is that you directly access super global $_SESSION, which is very bad.
# Jul 7th 2021, 13:10 dereuromark Why? :) You do know that it already exists, right?
# Jul 7th 2021, 13:06 alamnaryab I have created a `CreatedbyBehavior` to auto populate `created_by` and `modified_by` fields ```class CreatedbyBehavior extends Behavior { public function beforeSave(EventInterface $event, EntityInterface $entity, ArrayObject $options) { $loggedin_user_id = isset($_SESSION['Auth']->id)?$_SESSION['Auth']->id:-1; if($entity->isNew()){ $entity->created_by = $loggedin_user_id;
# Jul 7th 2021, 13:06 slackebot2 $entity->modified_by = $loggedin_user_id; }else{ $entity->modified_by = $loggedin_user_id; } } }``` How can I improve it?
# Jul 7th 2021, 13:02 info315 @alamnaryab I think your Controller has to pass the current user id to the Table, which pass it to the Behavior
# Jul 7th 2021, 12:39 ndm You could use a result formatter on the query to modify the data that lands in the entity, or add a virtual field to the user entity that extracts the information on the fly.
# Jul 7th 2021, 12:07 alamnaryab Hi How can I get logged-in user id inside Behavior I used Authentication Plugin following cake4 cms tutorial
# Jul 7th 2021, 11:52 paolo.bragagni usingfoc bootstrap-ui but my require fields are not styled
# Jul 7th 2021, 08:37 dereuromark But are u also using it as in docs? :)
# Jul 7th 2021, 08:24 rudy1976s I am using @dereuromark Tags plugin, I configured it as described in the docs, but I cannot save: I always get the following error: `Cannot convert value of type array to string.` The stack is not helping: anyone got same issue ?
# Jul 7th 2021, 08:22 rudy1976s good morning !!!
# Jul 6th 2021, 22:17 itmpls makes sense, yeah
# Jul 6th 2021, 22:06 dereuromark blacklisting instead of whitelisting is usually considered a security risk. add any new method/controller without thinking about it and you exposed too much by accident.
# Jul 6th 2021, 21:14 itmpls Apparently my version doesn't support bypassAuth - by AppController logic did you mean just specifying a beforeFilter and conditioning off $this->name to specify $this->Auth->allow? That's what I just discovered
# Jul 6th 2021, 19:57 alamnaryab Respected @ndm I tried this, but there is still an issue I have 4 tables `Users` `Students` `Roles` and `UserRoles` I am expecting ```$this->Authentication->getIdentityData('roles') = array('sa','admin',....);``` ```public function findForAuthentication(\Cake\ORM\Query $query, array $options): \Cake\ORM\Query { return $query->contain( [ 'Students', 'UserRoles.Roles'
# Jul 6th 2021, 19:57 slackebot2 ] ); }``` It Returns `Roles` insde `UserRoles` object. while I want it as plain array of roles as property of `User` object so that I can make check easily for roles as below ```if(in_array('admin',$this->Authentication->getIdentityData('roles') ){ //show admin dashboard }else if(array_intersect( ['sa','owner'],$this->Authentication->getIdentityData('roles') ){ //show owner dashboard } ```
# Jul 6th 2021, 18:53 steinkel you can add some logic to AppController too
# Jul 6th 2021, 18:53 steinkel bypassAuth OR use `$this->Auth->allow(...)` to set the action as public in your controller
# Jul 6th 2021, 18:52 itmpls with 8.x. and I saw 'bypassAuth' was a thing but I don't think it's in that version?
# Jul 6th 2021, 18:51 itmpls you know how you do $this->Auth->allow([ ]); within each controller to bypass user permissions? is there a way to specify say, allow unregistered users to access all EXCEPT these in config/permissions?
# Jul 6th 2021, 18:47 steinkel @itmpls I don't get your use-case could you provide an example?
# Jul 6th 2021, 18:09 itmpls Is there a reverse to cakedc/users where I can allow all routes through permissions except some if the reverse is the default?
# Jul 6th 2021, 15:52 kiwi_13 cakephp-orm-json is exactly what I was looking for :) Thanks!
# Jul 6th 2021, 15:51 kiwi_13 Thanks a lot.
# Jul 6th 2021, 15:50 ewbarnard I see Authentication+Authorization training is offered this Thursday July 8. Are any "getting started with CakePHP 4" courses currently scheduled? I don't see anything on the web site. We have a new employee!
# Jul 6th 2021, 15:47 kevin.pfeifer I would guess you can start at https://github.com/liqueurdetoile/cakephp-orm-json
# Jul 6th 2021, 15:47 ndm Depends on what work you need to do. CakePHP ships JSON column support out of the box as far as type conversion is concerned (DB to PHP and vice versa), but that's about it.
# Jul 6th 2021, 15:37 kiwi_13 Hi, what is the best way to work with json-columns (mariadb) in cakephp orm? Couldn't find any documentation on the cake book
# Jul 6th 2021, 15:28 charolastra or look in /etc/apache/modules-enabled
# Jul 6th 2021, 15:28 charolastra no idea about centos but usually you can use a2enmod
# Jul 6th 2021, 15:27 nayakvradhit @charolastra how to enable php 7 module in centos 7 in apache
# Jul 6th 2021, 14:13 charolastra also maby you need to enable the module itself
# Jul 6th 2021, 14:01 kevin.pfeifer google is usually your friend here
# Jul 6th 2021, 14:00 kevin.pfeifer but as charolastra said you could also use PHP in apache via CGI or FPM
# Jul 6th 2021, 14:00 kevin.pfeifer if its using the apache built in PHP module then it should suffice to ```LoadModule php7_module modules/libphp7.so <FilesMatch \.php$> SetHandler application/x-httpd-php </FilesMatch>```
# Jul 6th 2021, 13:56 nayakvradhit I am using apache webserver
# Jul 6th 2021, 12:34 charolastra and how it interfaces to PHP. there's CGI, FPM, ..
# Jul 6th 2021, 11:40 kevin.pfeifer depends on your used webserver
# Jul 6th 2021, 11:33 nayakvradhit Ok then how can I interpret php
# Jul 6th 2021, 11:17 charolastra sounds like your webserver doesn't interpret it as PHP at all
# Jul 6th 2021, 10:50 nayakvradhit Hi can anyone please tell me when I run the file test.php contains phpinfo, Output I am not getting php information instead it outputs the php code? Any idea why
# Jul 6th 2021, 10:05 paolo.bragagni ok thanks
# Jul 6th 2021, 10:04 paolo.bragagni $linguaarray = $lingua->toArray();
# Jul 6th 2021, 10:04 info315 @paolo.bragagni My controllers are doing it like so: https://github.com/it-novum/openITCOCKPIT/blob/development/src/Controller/CommandsController.php#L112-L147 My App is 100% API driven. Basically it's: receive data from post call patch entity return the entity via CakePHP auto json serialize method: https://book.cakephp.org/4/en/views/json-and-xml-views.html
# Jul 6th 2021, 09:55 charolastra if Datasource->timezone is UTC but App->defaultTimezone is something different, should the dates be automaticly converted?