Giter Club home page Giter Club logo

utility's Introduction

Utility v1.7.1

A collection of CakePHP utility components, behaviors, datasources, models, helpers and more all packaged into a single plugin.

Requirements

  • PHP 5.3.0
    • Multibyte
  • CakePHP 2
  • Composer

Dependencies

Libraries

Components

  • AjaxHandler - Provides support for AJAX request and response
  • AutoLogin - An auth auto-login and persistent remember me

Controllers

  • Sitemap - Generates a sitemap.xml for search engines

Models

  • Aggregator - Convenience model that uses the FeedSource

Behaviors

  • Cacheable - Automatic database query caching
  • Convertable - Converts between types before and after database queries
  • Enumerable - Provides enumerable support for database columns
  • Filterable - Apply automatic filters and escaping to fields
  • Sluggable - Generate a slug based off another field
  • SpamBlocker - Validates comments against a point system and flags as spam
  • Validateable - Allows for multiple sets of validation rules as well as message translation

Datasources

  • Feed - RSS, RDF, Atom and XML parser through the model layer

Helpers

  • Breadcrumb - Basic breadcrumb and sitemap generation
  • OpenGraph - Generate meta tags for the OpenGraph protocol
  • Decoda - BBcode markup parsing with the Decoda library
  • Utility - Provides utility helper methods that integrate with the plugins other classes

Shells

  • CacheKill - Clear cache from the command line
  • BaseInstall - An abstract shell that provides installation functionality for plugins
  • BaseUpgrade - An abstract shell that provides version upgrade migration functionality for plugins

Documentation

Thorough documentation can be found here: http://milesj.me/code/cakephp/utility

utility's People

Contributors

ali1 avatar ecoreng avatar idev247 avatar milesj avatar phantomwatson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

utility's Issues

Sitemap returns nothing

I've

  • installed Utility in CakePHP 2.2.7,
  • loaded it in bootstrap,
  • set Configure::write('debug', 0); and require_once dirname(__DIR__) . '/Vendor/autoload.php'; in core (autoload.php is in Vendor),
  • and gone to sitemap.xml in my Web site.

Unfortunately, this is what is produced:

<response><name>Not Found</name><url>/sitemap.xml</url></response>

Can you give me any help with what I may be doing wrong?

Advanced Caching: pass $keys to callback

Hi Miles

I couldn't use the advanced caching for methods that require an id parameter as the id wouldn't get passed to the callback.

However if you change
$results = $callback($model);
to
$results = $callback($model, $keys);
in CacheableBehaviour.php around line 353

the the callback function can acquire the $id of the item being cached and be able to do an effective $this->find for single items.

Error in console panel for a website

new bitmap image
I opened my website: www.pcfunkies.com and after right-clicking and opening inspect element, I found 6 errors in the console panel. [please see the attachment for reference] So, what should i do to eradicate these errors and will these errors affect my website from being indexed by search engines? Please HELP !!

Sitemap not working for me

When I navigate to http://mysite.com/sitemap.xml, I'm getting the following error.

Controller class SitemapController could not be found.

For example: I've added the following to a controller.

public function _generateSitemap() {
        $sitemap = array(
            array(
                'loc' => array('controller' => 'cheeses', 'action' => 'view'),
                'changefreq' => 'hourly',
                'priority' => '1.0'
            )
        );

        $results = $this->Cheese->find('all', array(
                'conditions' => array(
                    'Cheese.active' => 1
                ),
                'fields' => array(
                    'id','name','modified'
                ),
                'recursive' => -1
            ));

        if ( $results ) {
            foreach ($results as $result) {
                $sitemap[] = array(
                    'loc' => array('controller' => 'cheeses', 'action' => 'view', $result['Cheese']['id']),
                    'lastmod' => $result['Cheese']['modified'],
                    'changefreq' => 'hourly',
                    'priority' => '1.0'
                );
            }
        }
        return $sitemap;
    }

And I've added the following to my bootstrap.

CakePlugin::load(array(
    'Utility' => array('bootstrap' => true, 'routes' => true),
...
));

Notes: I am using a custom Authenticate method for Auth and was thinking that this was having some effect on it, but still not sure.

$this->Auth->authenticate = array('Custom');

Utility.Cacheable: Cache negative results

Firstly, a big thank you Miles for this great plugin - it's been very handy indeed appreciate your efforts!

Re: Cacheable, there is no reason not to cache negative database result, where no results are found. Please consider the following small change.

CacheableBehaviour.php Line 250
} else if ($results) {
to
} else {

Feed order

I'm not able to get the sort order for the feeds to work. For some reason, maybe i'm doing something wrong, the feeds never order by date. It looks like it orders within the month correctly but the months and years are not.

I have this in my controller:

    $this->set('feed', $this->Aggregator->find('all', array(
            'conditions' => array(
                'cnn.com' => 'http://rss.cnn.com/rss/cnn_topstories.rss',
                'cnn.com' => 'http://rss.cnn.com/rss/cnn_tech.rss'
            )
    )));

And this is the result I'm getting:

array(
'Fri, 03 Aug 2012 11:59:24 EDT' => array(
'title' => 'An open letter to texting-mad teenagers',
'guid' => 'http://www.cnn.com/2012/08/01/tech/netiquette-open-letter-teenagers/index.html',
'date' => 'Fri, 03 Aug 2012 11:59:24 EDT',
'link' => 'http://rss.cnn.com/~r/rss/cnn_tech/~3/mFKZeL3oHyM/index.html',
'description' => 'Put your phone down for a second, teen texters -- there are some things you've got to hear.


', 'source' => 'cnn.com Top Stories' ), 'Fri, 04 Jan 2013 05:28:45 EST' => array( 'title' => 'Worst fast-food meals for sodium', 'guid' => 'http://www.cnn.com/2013/01/04/health/gallery/fast-food-worst-sodium-meals/index.html', 'date' => 'Fri, 04 Jan 2013 05:28:45 EST', 'link' => 'http://rss.cnn.com/~r/rss/cnn_topstories/~3/x1PcJu3Dom8/index.html', 'description' => 'Worst fast-food meals for sodium

', 'source' => 'cnn.com Tech' ), 'Fri, 04 Jan 2013 09:31:30 EST' => array( 'title' => 'Six gadget trends to look for at CES', 'guid' => 'http://www.cnn.com/2013/01/04/tech/innovation/ces-preview-trends/index.html', 'date' => 'Fri, 04 Jan 2013 09:31:30 EST', 'link' => 'http://rss.cnn.com/~r/rss/cnn_tech/~3/n5pXMRw6PXY/index.html', 'description' => 'Smartphones inch closer to becoming remote controls for your life at next week's 2013 Consumer Electronics Show in Las Vegas. The annual event is the largest gadget conference in the world, where major technology companies and scrappy startups can show off their latest innovations.

', 'source' => 'cnn.com Top Stories' ), 'Fri, 04 Jan 2013 10:20:34 EST' => array( 'title' => 'Make Create Innovate', 'guid' => 'http://www.cnn.com/2012/12/21/tech/innovation/raspberry-pi-computer-upton/index.html', 'date' => 'Fri, 04 Jan 2013 10:20:34 EST', 'link' => 'http://rss.cnn.com/~r/rss/cnn_tech/~3/2HMzKe6-YzI/index.html', 'description' => 'In a world where computers are increasingly powerful and are concealed within ever more glossy slabs of aluminum, the Raspberry Pi (RPi) offers surprising proof for the virtue of moderation.

', 'source' => 'cnn.com Top Stories' ), 'Fri, 04 Jan 2013 10:25:25 EST' => array( 'title' => 'Website tracks big beasts', 'guid' => 'http://www.cnn.com/2012/12/31/tech/web/kruger-latest-sightings-nadav-ossendryver/index.html', 'date' => 'Fri, 04 Jan 2013 10:25:25 EST', 'link' => 'http://rss.cnn.com/~r/rss/cnn_tech/~3/f6VWAKy1iFE/index.html', 'description' => 'A website is letting users post sightings of wildlife in Kruger National Park, so that tourists on safari have more chance of spotting elusive animals.

', 'source' => 'cnn.com Top Stories' ), 'Fri, 04 Jan 2013 11:10:04 EST' => array( 'title' => 'Apparently This Matters: Ruzzle', 'guid' => 'http://www.cnn.com/2013/01/04/tech/social-media/apparently-this-matters-ruzzle/index.html', 'date' => 'Fri, 04 Jan 2013 11:10:04 EST', 'link' => 'http://rss.cnn.com/~r/rss/cnn_tech/~3/cJ5l4WYWCXw/index.html', 'description' => 'On Sunday morning, a strange word suddenly started trending for me on Twitter. The word was Ruzzle. I had no idea what it meant, so I did the smart thing and asked my dog.

', 'source' => 'cnn.com Top Stories' ), 'Fri, 04 Jan 2013 11:16:21 EST' => array( 'title' => 'Apparently This Matters: Ruzzle', 'guid' => 'http://www.cnn.com/2013/01/04/tech/social-media/apparently-this-matters-ruzzle/index.html', 'date' => 'Fri, 04 Jan 2013 11:16:21 EST', 'link' => 'http://rss.cnn.com/~r/rss/cnn_tech/~3/cJ5l4WYWCXw/index.html', 'description' => 'On Sunday morning, a strange word suddenly started trending for me on Twitter. The word was Ruzzle. I had no idea what it meant, so I did the smart thing and asked my dog.

', 'source' => 'cnn.com Top Stories' ), 'Fri, 04 Jan 2013 11:47:48 EST' => array( 'title' => 'The secret to a better brain', 'guid' => 'http://www.cnn.com/2013/01/04/health/chopra-better-brain/index.html', 'date' => 'Fri, 04 Jan 2013 11:47:48 EST', 'link' => 'http://rss.cnn.com/~r/rss/cnn_topstories/~3/Js-KOonnz5w/index.html', 'description' => 'Chopra: Think your way to an inspired brain.

', 'source' => 'cnn.com Tech' ), 'Fri, 04 Jan 2013 11:52:32 EST' => array( 'title' => '2013's must-see TV', 'guid' => 'http://www.cnn.com/2013/01/04/showbiz/tv/2013-tv-preview/index.html', 'date' => 'Fri, 04 Jan 2013 11:52:32 EST', 'link' => 'http://rss.cnn.com/~r/rss/cnn_topstories/~3/hcKNy9qeloo/index.html', 'description' => 'Your favorite shows are almost back.

', 'source' => 'cnn.com Tech' ), 'Fri, 04 Jan 2013 15:00:52 EST' => array( 'title' => 'Jim McKelvey : 21st century Renaissance man', 'guid' => 'http://www.cnn.com/video/#/video/tech/2013/01/04/tnl-mckelvey-weekend.cnn', 'date' => 'Fri, 04 Jan 2013 15:00:52 EST', 'link' => 'http://rss.cnn.com/~r/rss/cnn_tech/~3/cB8dw2jvfVk/', 'description' => 'Jim McKelvey is an engineer, artist, community activist, and co-Founder of Square. See a profile of him on Sunday at 2 p.m. ET on CNN.

', 'source' => 'cnn.com Top Stories' ), 'Fri, 04 Jan 2013 15:02:22 EST' => array( 'title' => 'Have you heard of Snapchat?', 'guid' => 'http://www.cnn.com/2013/01/03/tech/mobile/snapchat/index.html', 'date' => 'Fri, 04 Jan 2013 15:02:22 EST', 'link' => 'http://rss.cnn.com/~r/rss/cnn_tech/~3/OwaVcq1GpDc/index.html', 'description' => 'You may not have heard of Snapchat. But if there are teenagers or 20-somethings in your life, it's a safe bet that they have.

', 'source' => 'cnn.com Top Stories' ), 'Fri, 04 Jan 2013 15:55:32 EST' => array( 'title' => 'Shark finning thrives on Hong Kong's roofs', 'guid' => 'http://www.cnn.com/2013/01/04/asia/gallery/hong-kong-roof-shark-fins/index.html', 'date' => 'Fri, 04 Jan 2013 15:55:32 EST', 'link' => 'http://rss.cnn.com/~r/rss/cnn_topstories/~3/0TuIW0k4giM/index.html', 'description' => 'Shark finning thrives on Hong Kong's rooftops

', 'source' => 'cnn.com Tech' ), 'Fri, 04 Jan 2013 17:40:28 EST' => array( 'title' => 'Time Has Come' for '60s singer', 'guid' => 'http://www.cnn.com/2012/12/24/tech/web/lester-chambers-kickstarter/index.html', 'date' => 'Fri, 04 Jan 2013 17:40:28 EST', 'link' => 'http://rss.cnn.com/~r/rss/cnn_tech/~3/OrtY7BsWRSc/index.html', 'description' => 'His song, "Time Has Come Today" is one of the enduring anthems of the turbulent 1960s. But in 2012, Lester Chambers had little to show for it when he turned to the Web for help.

', 'source' => 'cnn.com Top Stories' ), 'Fri, 04 Jan 2013 20:25:40 EST' => array( 'title' => '10 European hot spots', 'guid' => 'http://www.cnn.com/2013/01/04/travel/europe-top-destinations/index.html', 'date' => 'Fri, 04 Jan 2013 20:25:40 EST', 'link' => 'http://rss.cnn.com/~r/rss/cnn_topstories/~3/DT451tcmFPc/index.html', 'description' => 'Put these destinations on your travel radar

', 'source' => 'cnn.com Tech' ), 'Fri, 20 Apr 2012 09:38:33 EDT' => array( 'title' => 'Vanessa Williams' perfect man', 'guid' => 'http://www.cnn.com/video/#/video/showbiz/2012/04/20/piers-williams-love.cnn', 'date' => 'Fri, 20 Apr 2012 09:38:33 EDT', 'link' => 'http://rss.cnn.com/~r/rss/cnn_topstories/~3/XdISDjJ8ssM/', 'description' => 'Entertainer Vanessa Williams talks to CNN's Piers Morgan about "being properly in love" and relationships.

', 'source' => 'cnn.com Tech' ), 'Fri, 20 Apr 2012 09:38:44 EDT' => array( 'title' => 'Political dog tale duel', 'guid' => 'http://www.cnn.com/video/#/video/bestoftv/2012/04/20/ac-ridiculist-obama-romney-dogs.cnn', 'date' => 'Fri, 20 Apr 2012 09:38:44 EDT', 'link' => 'http://rss.cnn.com/~r/rss/cnn_topstories/~3/f2pQv1EmVbY/', 'description' => 'In the RidicuList, Anderson Cooper examines which candidate's dog tale will have a greater election impact.

', 'source' => 'cnn.com Tech' ), 'Fri, 20 Apr 2012 09:41:33 EDT' => array( 'title' => ''Only in America': Defending Axl Rose', 'guid' => 'http://www.cnn.com/video/#/video/bestoftv/2012/04/20/piers-morgan-only-in-america-in-defense-of-axl-rose.cnn', 'date' => 'Fri, 20 Apr 2012 09:41:33 EDT', 'link' => 'http://rss.cnn.com/~r/rss/cnn_topstories/~3/CE0-oIRG7AY/', 'description' => 'Piers Morgan defends Axl Rose for deciding not to attend the Rock'N'Roll Hall of Fame induction of Guns N' Roses.

', 'source' => 'cnn.com Tech' ), 'Fri, 20 Apr 2012 11:29:57 EDT' => array( 'title' => 'Man makes dating spreadsheet', 'guid' => 'http://www.cnn.com/video/#/video/bestoftv/2012/04/20/exp-get-real-dating-spreadsheet.cnn', 'date' => 'Fri, 20 Apr 2012 11:29:57 EDT', 'link' => 'http://rss.cnn.com/~r/rss/cnn_topstories/~3/vx0ARutyCFQ/', 'description' => 'Soledad O'Brien discusses the investment banker who created an elaborate spreadsheet to keep track of his dates.

', 'source' => 'cnn.com Tech' ), 'Fri, 20 Apr 2012 16:43:37 EDT' => array( 'title' => 'Working moms of CNN', 'guid' => 'http://www.cnn.com/video/#/video/bestoftv/2012/04/19/cnn-working-moms-share-their-stories.cnn', 'date' => 'Fri, 20 Apr 2012 16:43:37 EDT', 'link' => 'http://rss.cnn.com/~r/rss/cnn_topstories/~3/P9wFf4tbbyw/', 'description' => 'CNN goes behind the scenes with the working moms on Suzanne Malveaux's team to see how they juggle it all.

', 'source' => 'cnn.com Tech' ), 'Fri, 20 Apr 2012 16:43:45 EDT' => array( 'title' => 'Levon Helm remembered', 'guid' => 'http://www.cnn.com/video/#/video/bestoftv/2012/04/20/ac-levon-helm-obit.cnn', 'date' => 'Fri, 20 Apr 2012 16:43:45 EDT', 'link' => 'http://rss.cnn.com/~r/rss/cnn_topstories/~3/JYYIEYXqn34/', 'description' => 'Anderson Cooper takes a look back at the life of The Band's Levon Helm and his many contributions to music.

', 'source' => 'cnn.com Tech' ) )

Any help would be greatly appreciated.

Thanks

utility requires type-converter plugin without external code change

Today we updated our composer project and got two new versions from decoda and utility.
I see you droped support of utility but it now requires/uses type-converter without any change of the code on our side.

Our versions updated as follows:

Removing mjohnson/utility (1.6.10)

    Installing mjohnson/utility (1.7.0)
    Downloading: 100%

    Removing mjohnson/decoda (6.5.2)
    Installing mjohnson/decoda (6.6.1) Downloading: 100%

This can be a critical issue if you do not note the problem in the development environment. maybe you can have a look at and add it to the reqiurement instead of the suggestion.

Thank you.

This page contains the following errors: error on line 1 at column 1: Encoding error

I'm having a unique problem. When i'm trying to open my sitemap like this ::

  1. http://www.pcfunkies.com/sitemap.xml : It's working fine ....
    BUT
  2. http://www.pcfunkies.com/sitemap.xml.gz : Then its showing an error like this :
    "This page contains the following errors:

error on line 1 at column 1: Encoding error
Below is a rendering of the page up to the first error."

Now, while i was checking whether my robots.txt file worked fine
by this URL : http://www.pcfunkies.com/robots.txt then I'm getting the sitemap URL as the second one !! What Should I do ? Please tell me ... IT'S URGENT !!

Sluggable _makeUnique is buggy

_makeUnique functions checks the slug and append a count. This is not a correct way to make it unique.

e.g.

  1. save record 'abc', it generates slug 'abc'.
  2. save record 'abc', it generates slug 'abc-1'.
  3. delete record with slug 'abc'.
  4. save record 'abc', it generates slug 'abc-1'.
    BUG: now we have two records with slug 'abc-1'.

_autoLogin - sample request

I was wondering how do I work with the _autoLogin function that is available in the AuthLogin Component?

See below, how do I go from $user to getting the ID out and using it for the last_login field I have setup.

Thanks

I have the following in my AppController.php file. it doesn't seem to do anything at the moment. I also tried it in my User.php model and userControoler.php files but nothing seems to work.

public function _autoLogin($user) 
{
    $this->id = $user['User']['id']; // target correct record
           $this->User->saveField('last_login', date(DATE_ATOM)); // save login time
}   

I went though the component and tested the following:

get_class_methods($controller) = get_class_methods('users') = Produced NULL

While

get_class_methods($model) = get_class_methods('User') = Produced an array of the functions in my User.php Model.

So I am wondering does the _autoLogin function go into the User.php model and does the component need to be changed from get_class_methods($controller) to get_class_methods($model) ?

I did try this and it didn't seem to work still but I am having issue testing this with the cookie time delays etc.

Thanks

slugExists

The Sluggable behavior should have an exists method like CakeModel has for id. This will make it easier to convert scaffolded code to slug.

Here is a function that works (simplified version of CakeModel::exists)

    public function slugExists($slug = false) {
        if ($slug === false) {
            return false;
        }

        return (bool)$this->find('count', array(
            'conditions' => array(
                $this->alias . '.' . 'slug' => $slug
            ),
            'recursive' => -1,
            'callbacks' => false
        ));
    }

you can then in view action write:

    public function view($slug = null) {
        if (!$this->Asset->slugExists($slug)) {
            throw new NotFoundException(__('Invalid asset'));
        }
        $options = array('conditions' => array('Asset.' . 'slug' => $slug));
        $this->set('asset', $this->Asset->find('first', $options));
    }

Cookie Mismatch - autologin

Hi, I am still having issues with the autologin component, I keep getting cookie mismatch even after setting the cookie to rijndael as previously discussed. My mismatch error email is as follows:

CookieComponent Object
(
[name] => CakeCookie
[time] =>
[path] => /
[domain] =>
[secure] =>
[key] => DYhG93b0qyJffdgsdgdf5454bWwvniR2G0FgaC9mi
[httpOnly] =>
[_values:protected] => Array
    (
        [CakeCookie] => Array
            (
            )

    )

[_type:protected] => rijndael
[_reset:protected] =>
[_expires:protected] => 0
[_response:protected] => CakeResponse Object

etc etc

Any idea what might be going on? One thing to note is the system is using SSL, could this be causing any issues?

Thanks

Sluggable dynamic scope

I'm not sure how to approach this... How can I make the Sluggable's _makeUnique scope dynamic? I only know the scope once the beforeSave is called but the scope is set in the settings. Example of my scope:

$scope = array('StoreCollection.store_id' => $this->storeId);

Maybe I could change it so that when beforeSlug is called it also passes $this.The call would be like this:

$slug = $model->beforeSlug($this, $slug);

The model would have this:

public function beforeSlug($behavior, $slug) {
    $behavior->settings[$this->alias]['scope'] = array('StoreCollection.store_id' => $this->storeId);
    return $slug;
}

Would that work? Is there a better way? (sorry for the edits... github submitted the form when I hit return/enter)

FeedSource: always caching

Just a warning about line 147:

                $urlData = Cache::read($urlCacheKey, 'feeds');

This is happening regardless of whether $query['cache'] is true or false so essentially, everything is always cached.

Not sure if that is by design.

strict errors

Hi,

just to let you know. Getting warnings like this...

"Declaration of SluggableBehavior::beforeSave() should be compatible with ModelBehavior::beforeSave(Model $model, $options = Array) "

...due to strict error notifications on PHP 5.4

Debug-level overridden

The AjaxHandlerComponent::initialize() overrides the debug-level with a value of 0. Afterwards the setting is never reset to its original value. This behavior has a serious impact on other components, etc.
Is this piece of source code an artifact or necessary?

Class 'Sanitize' not found

Using CakePHP 2.4.1

Error: Class 'Sanitize' not found
File: \Plugin\Utility\Model\Behavior\FilterableBehavior.php
Line: 111

I'm guessing this is because the Sanitize class has been deprecated.

Adding App::uses('Sanitize', 'Utility'); fixes the issue.

[Deprecated] Why?

Hello,

Could you please explain why this projet is "deprecated"?

For which version of CakePHP, etc.

Sitemap - error on line 1 at column 6: XML declaration allowed only at the start of the document

Seems to generate a space at the start of the XML

http://localhost:8080/bidup/auctionshourly0.5http://localhost:8080/bidup/auctions/view/12013-11-29T11:24:00+00:00weekly0.9http://localhost:8080/bidup/auctions/view/22013-

Identified that it happens on the first pass thru :

    foreach ($controllers as $controller) {
        App::uses($controller, 'Controller');

        // Don't load AppController's, SitemapController or Controller's who can't be found
        if (strpos($controller, 'AppController') !== false || $controller === 'SitemapController' || !App::load($controller)) {
            continue;
        }
        $instance = new $controller($this->request, $this->response);
        $instance->constructClasses();

        if (method_exists($instance, '_generateSitemap')) {
            if ($data = $instance->_generateSitemap()) {
                $sitemap = array_merge($sitemap, $data);
            }
        }
    }

in the site map controller - but I cannot see why? we do have an admins controller which does not have the generate site map code - this seems to be where its being genreated?

AutoLogin component might be causing incorrect 301 redirects

I was trying to troubleshoot why a few of my CakePHP sites seemed to be causing Firefox to cache 301 redirects between unrelated pages for no reason, and I narrowed it down to probably being AutoLogin and the way Auth.redirect is stored in CakePHP's session. But I'd like someone who understands the codebase better than me to look into this as well, because I could be totally wrong.

The line in question in the AutoLogin component is currently line 177, and my reasoning is at the bottom of this question on webmasters.StackExchange after "Any login pages that redirect on success?".

If I'm right, it seems like a quick fix would be to change AutoLogin's 301 redirect to a 302 redirect.

Enum: validation

$this->enum is a pretty good method to get an array of enum key-value pairs but a method to use in $validate may also be handy. See example:

    public $validate = array(
        'country' => array(
            'checkEnum' => array(
                'rule'     => array('validateEnum'),
                'message'  => 'Please enter a valid country'
            ),
    );

Feel free to use this method which is working well for me.

    public function validateEnum($check){
        $field=key($check);
        $value=$check[$field];
        $values=$this->enum($field);
        if(empty($values)) return false;
        if(isset($values[$value])) return true;
        else return false;
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.