Sunday, January 31, 2016

Re: Bug: flaws in email validation/sending

Please open a ticket at https://github.com/cakephp/cakephp/issues
This is just a discission board, not a bug tracker.

Mark


Am Samstag, 30. Januar 2016 05:33:10 UTC+1 schrieb Kim:
  • CakePHP's email validation allows non-ASCII letter characters, e.g. รก, in the  local part of the email address (by the \p{L} unicode category construct). This should not be allowed, see https://en.wikipedia.org/wiki/Email_address#Local_part.
  • It also allows non-ASCII letter characters in the domain part. This allows Internationalized Domain Names (IDN). The problem here lies in the fact that this is not supported by the SmtpTransport. An SMTP client should convert them to so called punycode ASCII, according to https://lists.exim.org/lurker/message/20140812.120609.bf764769.en.html. MTA exim does not accept the SMTP sequence. By the way, conversion to punycode can be done by PHP's idn_to_ascii().
This issues have been tested in the current 2.7 branch, but a quick code inspection confirms that they are also present in the master branch. As a workaround I have switched back to validation by PHP's filter_var(), used in a wrapper validation method.

The first issue can be fixed easily, although the right RFCs have to be consulted. For the second issue, we have to decide if we support IDN for email and if we do, support it (maybe not only in the SmtpTransport).

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Re: Amazon AWS S3

https://github.com/burzum/cakephp-file-storage

Works with S3 and a ton of other storage backends.

On Saturday, January 30, 2016 at 5:32:01 AM UTC+1, fga...@medianet.com.ve wrote:
Hi, I am developing a cakephp 3 in AWS, I want to integratewith amazon aws s3, but I cannot find the plugin as I did in 

cakephp 2, can you help me?

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Sorting paginated data by string length in cakephp 3.x

Hi,

I'd like to use Paginator sorting function, but for sorting by string length like mysql LENGTH(title)

$this->Paginator->sort('title')

How to do that in cakephp 3?

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Saturday, January 30, 2016

CakePHP 3.2.1 and 3.1.10 released

The CakePHP core team is pleased to announce the immediate availability of CakePHP 3.1.10 and 3.2.1. These maintenance releases fix a regression with yesterday's release of 3.1.9 and 3.2.0.

Bugfixes
--------

You can read all of the [changes in 3.1.10](http://cakephp.org/changelogs/3.1.10) and the [changes in 3.2.1](http://cakephp.org/changelogs/3.1.10) in the respective changelogs.

* A regression nested prefix routes being incorrectly inflected has been corrected. (@ADmad)

As always, a big thanks to all the community members that helped make this release happen by reporting issues and submitting pull requests.

Download a [packaged release on github](https://github.com/cakephp/cakephp/releases).

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

the web server returns ERR_EMPTY_RESPONSE and crash down when i try to add some data to my model

Hello
the web server returns ERR_EMPTY_RESPONSE and them crash down when i try to add some data to my model from a form
it only happens with one model, not with the other ones.
do you have any idea of why this happens??

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

CakePHP 2.xx rendering view of original method after saving pdf through second method

I am using CakePHP 2.xx and the following component - https://github.com/segy/Mpdf to render pdf's.


I have 2 Controller methods, the first method request_pdf calls a second method send_pdf in the same Controller. The second method creates and saves a pdf to file, and will then email the pdf (but for simplicity I have omitted this part of the code).


Once the second method send_pdf finishes creating the pdf control should be passed back to the first method request_pdf where it should then render on screen the view file in view/Documents/request_pdf.


The pdf correctly saves to the TMP directory, BUT when request_pdf renders in the browser, it renders the pdf on screen. The saving of the pdf seems to interfere with the rendering of the view.


Here is my Controller code


App::uses('AppController', 'Controller');
App::uses('CakeEmail', 'Network/Email');

class DocumentsController extends AppController {

   
public $components = array('Mpdf');

// --------------------------------------------------
// beforeFilter
// --------------------------------------------------

   
public function beforeFilter()
   
{
        parent
::beforeFilter();
   
}

   
function request_pdf()
   
{
        $this
->send_pdf();

       
// have also tried this as described by the author of Mpdf component
       
// $result = $this->requestAction(array('action' => 'send_pdf/'), array('return', 'bare' => false));
   
}

   
function send_pdf()
   
{
        $this
->layout = null;
        $this
->Mpdf->init();

        $response
= $this->render('send_pdf');

        $thebody
= $response->body();
        $this
->Mpdf->WriteHTML($thebody);
        $this
->Mpdf->Output(TMP.'requested_pdf.pdf', 'F');

       
// have also tried this
       
// $this->Mpdf->setFilename(TMP.'requested_pdf.pdf');
       
// $this->Mpdf->setOutput('F');
   
}
}


I'm sure that it is something simple that I'm over looking here regarding the rendering of the original view, but I can't work it out.


I have also tried calling different methods in both the first and second methods without success,


$this->layout  $this->view  $this->viewPath  $this->render  $This->autoRender


If I remove $this->layout = null from send_pdf then I get both the pdf AND view from request_pdfrendered on the screen overlaying each other.


All help appreciated.


--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Friday, January 29, 2016

CakePHP 3.2.0 Released

The CakePHP core team is happy to announce the immediate availability of CakePHP 3.2.0. This is the first stable release for the 3.2 branch. Going forward 3.1 will only receive security updates. 3.2 is a backwards compatible release with 3.1 and 3.0 and provides new features and performance improvements.

Minimum PHP 5.5 Required
------------------------

CakePHP 3.2 requires at least PHP 5.5.9. By adopting PHP 5.5 we can provide better Date and Time libraries and remove dependencies on password compatibility libraries.

Deprecations
------------

As we continue to improve CakePHP, certain features are deprecated as they are replaced with better solutions. Deprecated features will not be removed until 4.0:

* ``Shell::error()`` is deprecated because its name does not clearly indicate that it both outputs a message and stops execution. Use ``Shell::abort()`` instead.
* ``Cake\Database\Expression\QueryExpression::type()`` is deprecated. Use ``tieWith()`` instead.
* ``Cake\Database\Type\DateTimeType::$dateTimeClass`` is deprecated.  Use DateTimeType::useMutable() or DateTimeType::useImmutable() instead.
* ``Cake\Database\Type\\DateType::$dateTimeClass`` is deprecated.  Use
  ``DateTimeType::useMutable()`` or ``DateType::useImmutable()`` instead.
* ``Cake\ORM\ResultSet::_calculateTypeMap()`` is now unused and deprecated.
* ``Cake\ORM\ResultSet::_castValues()`` is now unused and deprecated.

Disabling Deprecation Warnings
------------------------------

Upon upgrading you may encounter several deprecation warnings. These warnings are emitted by methods, options and functionality that will be removed in CakePHP 4.x, but will continue to exist throughout the lifetime of 3.x. While we recommend addressing deprecation issues as they are encountered, that is not always possible. If you'd like to defer fixing deprecation notices, you can disable them in your **config/app.php**:

```php
    'Error' => [
        'errorLevel' => E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED,
    ]
```

The above error level will suppress deprecation warnings from CakePHP.

Carbon Replaced with Chronos
----------------------------

The Carbon library has been replaced with [cakephp/chronos] (https://github.com/cakephp/chronos). This new library is a fork of Carbon with no additional dependencies. It also offer a calendar date object, and immutable versions of both date and datetime objects.

New Date Object
---------------

The ``Date`` class allows you to cleanly map ``DATE`` columns into PHP objects.  Date instances will always fix their time to ``00:00:00 UTC``. By default the ORM creates instances of ``Date`` when mapping ``DATE`` columns now.

New Immutable Date and Time Objects
-----------------------------------

The ``FrozenTime``, and ``FrozenDate`` classes were added. These classes offer the same API as the ``Time`` object has. The frozen classes provide immutable variants of ``Time`` and ``Date``.  By using immutable objects, you can prevent accidental mutations. Instead of in-place modifications, modifier methods return *new* instances:

```php
use Cake\I18n\FrozenTime;

$time = new FrozenTime('2016-01-01 12:23:32');
$newTime = $time->modify('+1 day');
```

In the above code ``$time`` and ``$newTime`` are different objects. The ``$time`` object retains its original value, while ``$newTime`` has the modified value. As of 3.2, the ORM can map date/datetime columns into immutable objects as well.

CorsBuilder Added
-----------------

In order to make setting headers related to Cross Origin Requests (CORS) easier, a new ``CorsBuilder`` has been added. This class lets you define CORS related headers with a fluent interface.

RedirectRoute raises an exception on redirect
---------------------------------------------

``Router::redirect()`` now raises ``Cake\Network\Routing\RedirectException`` when a redirect condition is reached. This exception is caught by the routing filter and converted into a response. This replaces calls to ``response->send()`` and allows dispatcher filters to interact with redirect responses.

ORM Improvements
----------------

* Containing the same association multiple times now works as expected, and the query builder functions are now stacked.
* Function expressions now correctly cast their results. This means that expressions like ``$query->func()->current_date()`` will return datetime instances.
* Field data that fails validation can now be accessed in entities via the ``invalid()`` method.
* Entity accessor method lookups are now cached and perform better.


Improved Validator API
----------------------

The Validator object has a number of new methods that make building validators less verbose. For example adding validation rules to a username field can now look like:

```php
$validator->email('username')
    ->ascii('username')
    ->lengthBetween('username', [4, 8]);
```

Console Improvements
--------------------

* ``Shell::info()``, ``Shell::warn()`` and ``Shell::success()`` were added.  These helper methods make using commonly used styling simpler.
* ``Cake\Console\Exception\StopException`` was added.
* ``Shell::abort()`` was added to replace ``error()``.


StopException Added
-------------------

``Shell::_stop()`` and ``Shell::error()`` no longer call ``exit()``. Instead they raise ``Cake\Console\Exception\StopException``. If your shells/tasks are catching ``\Exception`` where these methods would have been called, those catch blocks will need to be updated so they don't catch the ``StopException``. By not calling ``exit()`` testing shells should be easier and require fewer mocks. 

Helpers initialize()
--------------------

Helpers can now implement an ``initialize(array $config)`` hook method like other class types.

FormHelper
----------

The ``action`` key for ``FormHelper::create()`` has been deprecated. You should use the ``url`` key directly.

Fatal Error Memory Limit Handling
----------------------------------------------------

A new configuration option ``Error.extraFatalErrorMemory`` can be set to the number of megabytes to increase the memory limit by when a fatal error is encountered. This allows breathing room to complete logging or error handling.

Development on 3.3 will now start. The [Roadmap](https://github.com/cakephp/cakephp/wiki/3.3-Roadmap) for 3.3 is still incomplete, so if there is a feature or improvement you'd like to see reach out on IRC and github.  The documentation for 3.2.0 is currently available in the [book](http://book.cakephp.org/3.0/en) and the [API](http://api.cakephp.org/3.2).

As always, a huge thanks to all the community members that helped make this release happen by reporting issues and sending pull requests.

Download a [packaged release on github](https://github.com/cakephp/cakephp/releases).

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

How to do CSRF protection in cakephp

Hi,
         I am new to cakephp and now I am working on a new project with cakephp by studying. My current doing task is to do CSRF protection for overall project.I have read official cakephp 2 cookbook and I did as explained in that book. But, now I am facing 

The request has been black-holed

Error: The requested address '/admin/accounts/add' was not found on this server. 

every time the new user add form is submitted.
My code is :
//////////////////////////////////////////////////////////////////////////////////////////////////

public $components = array(
'Security' => array(
'csrfExpires' => '+1 hour'
),
'Search.Prg' => array(
'commonProcess' => array(
'paramType' => 'named',
'filterEmpty' => true
))

);

///////////////////////////////////////////////////////////////////

public function beforeFilter() {
parent::beforeFilter();
$this->layout = 'admin';
$this->Security->blackHoleCallback = '_blackHole';
}

////////////////////////////////////////////////////////////////////

public function _blackHole($error) {
die($error);
}

/////////////////////////////////////////////////////////////////////

By doing so, 'auth' error has appeared.

How should I do?
Please help me.I have googled but it was just the waste of time.I have no way to do.
Please help me.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Cakephp 3 SOAPclient

Hello,

got this Script in PHP running and what to turn it in Capephp 3 with the Http Client

$client = new soapclient($url);
$arrResult = array();
$arrFilter[] = array('field'=>'id', 'operator'=>'bigger', 'value'=>20);
$arrSort = array('field'=>'customer', 'direction'=>'asc');
$arrResult = $client->getCustomers($strAPIKey, $arrFilter,$arrSort,10,0);

Is it posible with the Cakephp 3 Http Client? Thx for help :)

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Thursday, January 28, 2016

how to send mail in cake php using phpmailer libraray

hi,  just want to know how to send email using phpmailer library  in cakephp 3.0.15

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Bug: flaws in email validation/sending

  • CakePHP's email validation allows non-ASCII letter characters, e.g. รก, in the  local part of the email address (by the \p{L} unicode category construct). This should not be allowed, see https://en.wikipedia.org/wiki/Email_address#Local_part.
  • It also allows non-ASCII letter characters in the domain part. This allows Internationalized Domain Names (IDN). The problem here lies in the fact that this is not supported by the SmtpTransport. An SMTP client should convert them to so called punycode ASCII, according to https://lists.exim.org/lurker/message/20140812.120609.bf764769.en.html. MTA exim does not accept the SMTP sequence. By the way, conversion to punycode can be done by PHP's idn_to_ascii().
This issues have been tested in the current 2.7 branch, but a quick code inspection confirms that they are also present in the master branch. As a workaround I have switched back to validation by PHP's filter_var(), used in a wrapper validation method.

The first issue can be fixed easily, although the right RFCs have to be consulted. For the second issue, we have to decide if we support IDN for email and if we do, support it (maybe not only in the SmtpTransport).

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Re: Upgrade CakePHP from 2.1 to 2.7+

moved the question here: http://stackoverflow.com/questions/35060114/upgrade-cakephp-from-2-1-to-2-8

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Re: Upgrade CakePHP from 2.1 to 2.7+

or should I say 2.8+

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Upgrade CakePHP from 2.1 to 2.7+

I'm sure I should upgrade my project from 2.1 to 2.7+
But how hard would it be? Anyone have some experience like this?
Are there any "dos and don'ts" I should know (apart those from the man)?

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Wednesday, January 27, 2016

Hash::get() & Hash::extract()

Hi,

I am a noob at CakePHP. I have the following array:

$fooArray = Array
(
    [0] => Array
        (
            [Foo] => Array
                (
                    [foo_id] => 100
                    [foo_role_id] => 10
                )

        )

)

I looked at the Hash::get() & Hash::extract() methods. I would like to extract the value of 'foo_id' where 'foo_role_id' is 10.

I was using the below statement but it doesn't work:
Hash::extract($fooArray, '{n}.Foo[foo_role_id = 10].foo_id');


Please help me correct the above statement.

Thanks!

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Re: cakephp3 model reconnect after "MySql Server has gone away"

Found the Answer by myself. It seems, a dedicated disconnect is needed after the server was gone away.

        try {
            $newE = $this->newEntity($newRecA);
            $retVal = $this->save($newE);
        } catch (\PDOException $ex) {
            $this->connection()->disconnect();
        }

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Tuesday, January 26, 2016

cakephp3 model reconnect after "MySql Server has gone away"

hello, In a Cakephp3-Shell I need to handle the Exception "MySQL Server has gone away".
How do I my model after such an Exception? Even if the MySQL Server is available again, I get this message
thanks in advance

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Re: How To / Example of OO Inheritance for CakePHP 3

I have done the tutorials. I posted because it is not totally clear. Reading the docs has let me to believe there should be a model for every database table. but if i would do that i would end up with a model for Customer and a model for Manager both containing the , more or less, same fields and the same method. That seems strange to me and that is why i posted the question. Sometimes things just get more clear with a simple example. 


so to rephrase: if somebody would come to you with this specific UML how would you create this setup using CakePHP. 

tx



On Monday, January 25, 2016 at 4:50:52 PM UTC+1, Willem wrote:

how would one create a CakePHP3 app and what database tabels would i need to create an app that uses inheritance.

for example fictional setup:

[Person] <--- [Customer]
[Person]<--- [Manager]

All Persons have "name". Customer has "order_amount". Manager has "sales_total". 

Person has a method "getName()" , which is avavailable through inheritance in Customer and manager.

Person is the parent class and Customer and manager are the child-classes.

How would i implement this in CakePHP?

I could create a customer and manager database table and bake this to two models. but that would mean that the getName() function would be implemented in both classes. 

Could somebody help me grasp this in cakephp? thanks.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Re: How To / Example of OO Inheritance for CakePHP 3

Do the official Tutorials, they'll teach you how to work with CakePHP.

http://book.cakephp.org/3.0/en/tutorials-and-examples.html

The level of abstraction in CakePHP is higher than what you describe, you don't implement these methods on model or table objects, entities represent data. They represent data objects and you can implement accessors and mutators to implement more specific behavior than a simple getter and setter. I highly recommend you to read the documentation.

On Monday, January 25, 2016 at 4:50:52 PM UTC+1, Willem wrote:

how would one create a CakePHP3 app and what database tabels would i need to create an app that uses inheritance.

for example fictional setup:

[Person] <--- [Customer]
[Person]<--- [Manager]

All Persons have "name". Customer has "order_amount". Manager has "sales_total". 

Person has a method "getName()" , which is avavailable through inheritance in Customer and manager.

Person is the parent class and Customer and manager are the child-classes.

How would i implement this in CakePHP?

I could create a customer and manager database table and bake this to two models. but that would mean that the getName() function would be implemented in both classes. 

Could somebody help me grasp this in cakephp? thanks.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Monday, January 25, 2016

get dates between 2 dates and create entry for each excluding weekends and public holidays


HI,

I need some help as to how can i get the business dates from start date and end date and creating entry in the mysql database for the calculated business dates between start and end date.

I'm a newbie and any form of help is much appreciated.


Thanks
Para

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Amazon AWS S3

Hi, I am developing a cakephp 3 in AWS, I want to integratewith amazon aws s3, but I cannot find the plugin as I did in 

cakephp 2, can you help me?

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

How To / Example of OO Inheritance for CakePHP 3


how would one create a CakePHP3 app and what database tabels would i need to create an app that uses inheritance.

for example fictional setup:

[Person] <--- [Customer]
[Person]<--- [Manager]

All Persons have "name". Customer has "order_amount". Manager has "sales_total". 

Person has a method "getName()" , which is avavailable through inheritance in Customer and manager.

Person is the parent class and Customer and manager are the child-classes.

How would i implement this in CakePHP?

I could create a customer and manager database table and bake this to two models. but that would mean that the getName() function would be implemented in both classes. 

Could somebody help me grasp this in cakephp? thanks.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Sunday, January 24, 2016

Adding multiple events

Hi,

I'm working on a project which creates entries on individual working days from the start date and the end date selected. I have done the calculation to get no. of working days between the dates selected, however, i dont have any idea how will i go about inserting into the DB, taking out start date and end date for individual working days from the calculated no. of working days.

Below is my code to where I'm up to currently. Any bit of help is much appreciated since i'm a newbie to cakephp

public function add_multiple() {
        if ($this->request->is('post')) {
            $this->Leave->create();
            $user = $this->Session->read('Auth.User');
            $this->request->data['Leave']['created_by'] = $user['name'];
            $this->request->data['Approval'][0]['user_id'] = $user['id'];
            $this->request->data['Approval'][0]['state_id'] = 2;
           
           
            $startTime = $this->request->data['Leave']['event_date'];
            $endTime = $this->request->data['Leave']['event_stop_time'];
            $daysweekly = $this->request->data['Leave']['days_weekly'] ;
                                       
               
            $start = strtotime($startTime); //Convert to unix time
            $end = strtotime($endTime); //Convert to unix time             
           
            $days = ($end - $start) / 86400 + 1;

            $no_full_weeks = floor($days / 7);
            $no_remaining_days = fmod($days, 7);
           
             //returns 1 for Monday,7 for Sunday
            $the_first_day_of_week = date("N", $start);
            $the_last_day_of_week = ($start - $daysweekly);
           
            //First case, interval within a week..Second case, interval falls in two weeks
            if ($the_first_day_of_week <= $the_last_day_of_week) {
                if ($the_first_day_of_week <= 6 && 6 <= $the_last_day_of_week)
                        $no_remaining_days--;
                if ($the_first_day_of_week <= 7 && 7 <= $the_last_day_of_week)
                        $no_remaining_days--;
    }
    else {
       
        // the day of the week for start is later than the day of the week for end
        if ($the_first_day_of_week == 7) {
            // if the start date is a Sunday, definitely subtract 1 day
            $no_remaining_days--;

            if ($the_last_day_of_week == 6) {
                // if the end date is a Saturday, subtract another day
                $no_remaining_days--;
            }
        }
        else {
            // the start date was a Saturday (or earlier), end date was (Mon..Fri)
            // skip an entire weekend and subtract 2 days
            $no_remaining_days -= 2;
        }
    }

    //working days: (no. of weeks between the 2 dates) * (days per week) + the remainder
    //february in none leap years gives a remainder of 0, still calculated weekends between first and last day
   $workingDays = $no_full_weeks * $daysweekly;
    if ($no_remaining_days > 0 )
    {
      $workingDays += $no_remaining_days;
    }
   
    //calculate holidays
    $holidays = $this->Leave->find ('all', array('conditions'=>array('DATE_FORMAT(Leave.event_date,"%Y/%m/%d")'=>'public_holidays.SetDate')));
   
     foreach($holidays as $holiday){
        $time_stamp=strtotime($holiday);
        //If the holiday doesn't fall in weekend
        if ($start <= $time_stamp && $time_stamp <= $end && date("N",$time_stamp) != 6 && date("N",$time_stamp) != 7)
            $workingDays--;
        }
               
        return $workingDays;
}

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Thursday, January 21, 2016

cakephp 3.0 and snelg/cakephp-3-oracle [ Error: [Cake\Database\Exception] Cannot describe s_i18_n. It has 0 columns.]

When i try to perform bake command i receive this exception

Exception: Cannot describe s_i18_n. It has 0 columns. in [/var/www/html/3.0/app-master/vendor/cakephp/cakephp/src/Database/Schema/Collection.php, line 98]
2016-01-21 15:07:24 Error: [Cake\Database\Exception] Cannot describe s_i18_n. It has 0 columns.
Stack Trace:
#0 /var/www/html/3.0/app-master/vendor/cakephp/cakephp/src/Database/Schema/CachedCollection.php(64): Cake\Database\Schema\Collection->describe('s_i18_n', Array)
#1 /var/www/html/3.0/app-master/vendor/cakephp/cakephp/src/ORM/Table.php(423): Cake\Database\Schema\CachedCollection->describe('s_i18_n')
#2 /var/www/html/3.0/app-master/vendor/cakephp/cakephp/src/ORM/Table.php(499): Cake\ORM\Table->schema()
#3 /var/www/html/3.0/app-master/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(194): Cake\ORM\Table->primaryKey()
#4 /var/www/html/3.0/app-master/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(110): Bake\Shell\Task\ModelTask->getAssociations(Object(Cake\ORM\Table))
#5 /var/www/html/3.0/app-master/vendor/cakephp/bake/src/Shell/Task/ModelTask.php(96): Bake\Shell\Task\ModelTask->bake('SI18N')
#6 /var/www/html/3.0/app-master/vendor/cakephp/bake/src/Shell/BakeShell.php(250): Bake\Shell\Task\ModelTask->main('SI18N')
#7 /var/www/html/3.0/app-master/vendor/cakephp/cakephp/src/Collection/CollectionTrait.php(51): Bake\Shell\BakeShell->Bake\Shell\{closure}('SI18N', 0)
#8 /var/www/html/3.0/app-master/vendor/cakephp/bake/src/Shell/BakeShell.php(253): Cake\Collection\Collection->each(Object(Closure))
#9 [internal function]: Bake\Shell\BakeShell->all('SI18N')
#10 /var/www/html/3.0/app-master/vendor/cakephp/cakephp/src/Console/Shell.php(443): call_user_func_array(Array, Array)
#11 /var/www/html/3.0/app-master/vendor/cakephp/cakephp/src/Console/ShellDispatcher.php(212): Cake\Console\Shell->runCommand(Array, true, Array)
#12 /var/www/html/3.0/app-master/vendor/cakephp/cakephp/src/Console/ShellDispatcher.php(179): Cake\Console\ShellDispatcher->_dispatch(Array)
#13 /var/www/html/3.0/app-master/vendor/cakephp/cakephp/src/Console/ShellDispatcher.php(126): Cake\Console\ShellDispatcher->dispatch(Array)
#14 /var/www/html/3.0/app-master/bin/cake.php(33): Cake\Console\ShellDispatcher::run(Array)
#15 {main}


is somebody know how to fix this?

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Wednesday, January 20, 2016

Auth Component works in dev, but not in production

I am getting a blank page when I try and use the Auth Component.

The code is straight out of the blog tutorial.

http://book.cakephp.org/3.0/en/tutorials-and-examples/blog-auth-example/auth.html

It works in dev, but I get a blank page in production.

Any ideas anyone?

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Tuesday, January 19, 2016

Beforefinder call function is not work in cakephp 3.x

Hi,
   I have used beforefinder call function into the model file
       
public function beforeFind(Query $query){      return $query->where('User.status'=>0)  }
We don't need that record when the user status is '0',How to write the common query in table file
How to use
'beforeFind' call back function in cakephp 3.0.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Re: how to deploy i18n translations ?

One year later and I have this exactly problem.

Messages in __("English") are translated as expected in WAMP development environment. But not in Fedora FC21 Linux Using same apache+php versions...




--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Monday, January 18, 2016

create an optgroup with cakephp 3.x

i'm novice in cakephp, and i'm having dificulties in something like this:

starting with this sql query:

select service_group.name as service_group_name, service_group.id as service_group_id, campaign.name as campaign_name, campaign.id as campaign_id        from group_service        join group_service_campaign on group.service.id = group_service_campaign.group_service_id        join campaign on group_service_campaign.campaign_id = campaign.id        where campaign.active = 'Y'        and campaign.id in ($in)        and campaign.company_id = ${_SESSION['companyId']}        order by group_service.name, campaign.name


In result, i have something like this:

service_group_name | service_group_id | campaign_name | campaign_id |
service_1 | 01 | travel to sicilia | 14 |
service_1 | 01 | travel to greece | 15 |
service_2 | 02 | play the xyz game | 22 |
service_2 | 02 | play the return of xyz game | 234 |


and so on....

I converted it to this in my controller:

$var_campaign = $this->loadModel('Service_Group');  $var_campaign = $this->Group_Service->find('list', ['keyfield' => 'campaign_id', 'valueField' => 'campaign_name', 'groupField' => 'service_group_name'])              ->join(['table' => 'service_group_campaign',                  'type' => 'inner',                  'conditions' => 'Service_Group.id = service_group_campaign.service_group_id'              ])              ->join(['table' => 'campaign',          'type' => 'inner',          'conditions' => 'service_group_campaign.campaign_id = campaign.id'      ]);      $var_campaign->where(['campaign.active' => 'Y']);      $var_campaign->order(['grou_service.name,campaign.name']);

As can see, one thing i don't found an equivalent AS in querybuilder in cake, this is my first difficult.


My other difficult is to how use this to create an select form element with optgroup.

I've searched for examples and questions similar, but all i tried don't work.


My view:


echo $this->Form->create();
echo $this
->Form->input('id', array('label' => 'Services :', 'type' => 'select', 'empty'=> '-- Select --', 'options' => $var_campaign));
echo $this
->Form->select("field", $var_campanha);
echo $this
->Form->end();

When i use find('list' ...) in query statement, i get a blank response, if i use find('all' ...) i get a not complete response, because all campaign names dont come in response, only the services group names with their id's.


My optgroup show a plain text like:


{"id": -1, "name": "Active Proposals","mod": "W","company_id": 10}


and so on.


Where i'm going wrong ?


thanks in advance.



--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Sunday, January 17, 2016

$this->render('index');

I have tried for two days now to figure out why $this->render('index'); is not working on my controller method,here is the controller action I am running $this->render('index');
Thanks.
public function search(){
if($this->request->is('put') || $this->request->is('post')){
return $this->redirect(array(
'?'=>array(
'q'=>$this->request->data('User.searchQuery')
)
));
$this->User->recursive = 0;
$searchQuery=$this->request->query('q');
$this->Paginator->settings = array(
 'User'=>array(
   'findType'=>'search',
 'searchQuery'=> $searchQuery
 )
 );
$this->set('users',$this->Paginator->paginate());
$this->set('searchQuery',$searchQuery);
//$this->autoRender = false;
   $this->render('index');
}
}

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Re: Regarding App.Namespace

Hi all,

So this is no longer a problem for I have found a solution via the https://github.com/cakephp/cakephp/pull/8055 .

I hope you guys will consider merging as soon as possible so I / others can benefit from it.

Thank you

Hari K T

You can ring me : +91 9388 75 8821

Skype  : kthari85
Twitter : harikt

On Sun, Jan 17, 2016 at 10:15 PM, Hari K T <kthari85@gmail.com> wrote:
Hi all,

I was using Cakephp orm as a standalone tool.

One thing that I need to do was configure the App.namespace .

Configure::write('App.namespace', 'App');

Recently I came across something. I need to build a package, and the namespace of the package is different.

Say Hkt\Blog . Now I could read it if I have put the App.namespace to Hkt .

But if I kept the App.namespace to App for my default application it will load the base Entity and base Table class . By base I mean (Cake\ORM\Entity , Cake\ORM\Table ) .

Application

src/App/Model/Table/UsersTable.php
src/App/Model/Entity/User.php

Library

vendor/hkt/blog/src/Model/Table/PostsTable.php
vendor/hkt/blog/src/Model/Entity/Post.php

TableRegistry::get('Users') => Need to load App/Model/Table/UsersTable
TableRegistry::get('Posts') => Need to load Hkt/Blog/Model/Table/PostsTable , currently this loads Cake\ORM\Table .

Is there is a way to achieve what I am trying to do so I can have many vendor libraries that work with Cake orm can be installed. I know there may be something I missed or can do for it works for plugins in cakephp framework.

Thank you

Hari KT

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to a topic in the Google Groups "CakePHP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cake-php/FfZxFz6vaX8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Regarding App.Namespace

Hi all,

I was using Cakephp orm as a standalone tool.

One thing that I need to do was configure the App.namespace .

Configure::write('App.namespace', 'App');

Recently I came across something. I need to build a package, and the namespace of the package is different.

Say Hkt\Blog . Now I could read it if I have put the App.namespace to Hkt .

But if I kept the App.namespace to App for my default application it will load the base Entity and base Table class . By base I mean (Cake\ORM\Entity , Cake\ORM\Table ) .

Application

src/App/Model/Table/UsersTable.php
src/App/Model/Entity/User.php

Library

vendor/hkt/blog/src/Model/Table/PostsTable.php
vendor/hkt/blog/src/Model/Entity/Post.php

TableRegistry::get('Users') => Need to load App/Model/Table/UsersTable
TableRegistry::get('Posts') => Need to load Hkt/Blog/Model/Table/PostsTable , currently this loads Cake\ORM\Table .

Is there is a way to achieve what I am trying to do so I can have many vendor libraries that work with Cake orm can be installed. I know there may be something I missed or can do for it works for plugins in cakephp framework.

Thank you

Hari KT

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Saturday, January 16, 2016

Re: Cakephp find order by then group by

Thankz a lot sir, Your procedure has helped me solve a problem in live tracking issue....

On Friday, October 19, 2012 at 2:41:18 PM UTC+6, Vanja Dizdareviฤ‡ wrote:
Seemingly simple task, but not quite, eh...

Solving this with a single query is possible, but you would have to do a manual query (with Model::query), something like:

SELECT Message.* FROM messages as Message
  RIGHT JOIN (SELECT MAX(created) as last_created, user_id FROM messages GROUP BY user_id)
  as latest
  ON Message.created = latest.last_created AND Message.user_id = latest.user_id
 GROUP BY Message.user_id
 ORDER BY Message.created DESC;

You cannot instruct MySQL how to decide which row to use when grouping (yeah, i know...), so you would have to use MAX. The problem with this query is that you get ambiguous results if you happen to have 2 messages with same timestamp, user_id, receiver_id, so you would somehow need to sort by created and Message.id too.

Complex queries can become expensive quickly, so it's maybe better to find last message separately for each user.

$senders = $this->Message->find->('all', array(
'fields' => array(
'DISTINCT Message.user_id'
)
'conditions'=>array(
'receiver_id' => $user_id
)));
$newMessages = array();
foreach($senders as $sender) {
$newMessages[] = $this->Messages->find('first', array(
'conditions' => array('user_id' => $sender['Message']['user_id'], 'receiver_id' => $user_id), 
'order'=>array('created'=>'desc', 'id'=>'desc')
));
}

Another crazy idea is to create a Message.last boolean column and update this field when you insert a new record:

- run "UPDATE messages SET last = 0 WHERE user_id = $user_id AND receiver_id=$receiver_id";
- Create new message with Message.last = 1

... and then get last messages with find-all query with condition Message.last = 1.

I wished a thousand times that MySQL had a way of doing this properly in a single query.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at https://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.