I am mikek's Blog

The personal blog of Mike Karthauser, who you may know from Brightstorm Limited or the internet.

Disabling user interface code updates

If your site is relying on an external deployment system (perhaps with a staging and production workflow), you can disable all of the functionality that allows site administrators to install code through the administrative user interface by placing the following line in your site’s settings.php file:

$conf['allow_authorize_operations'] = FALSE;
You will still be able to run the Update manager to check the status of available updates, but you will not be able to install those updates or new modules and themes directly via the web interface.

From
https://www.drupal.org/documentation/modules/update

Advertisements

Filed under: development, drupal, ,

CakePHP virtual Fields

Something pretty useful in the CakePHP right now is VirtualFields.

A virtual field is a way to combine several fields to make a new ‘virtual’ one that exists when you read from the model. So with ‘firstname’ and ‘surname’ you can make a ‘full_name’ field which will allow you to use this within a find(‘list’) – a notoriously tricky task otherwise.

To do this on the User Model for example, just add the following to your app/models/user.php.

var $virtualFields = array(
'full_name' => 'CONCAT(User.firstname, " ", User.surname)'
);

Simple and powerful.

Available in CakePHP 1.3.*

Filed under: code snippets, , ,

New CakePHP has landed – 1.3.0-beta released

Today i wake to find the fantastic news that CakePHP 1.3 is now in beta. You can read more about that via cakephp.org

The bit that particularly tickles me about this new is the inclusion of something i’ve wanted since i first heard about it, virtual fields.

Virtual fields are a new feature in the Model for CakePHP 1.3. Virtual fields allow you to create arbitrary SQL expressions and assign them as fields in a Model. These fields cannot be saved, but will be treated like other model fields for read operations. They will be indexed under the model’s key alongside other model fields.

For anyone who has ever had to stitch together $firstname.’ ‘.$lastname to make $name fields and wondered why you couldn’t get that in a $this->Model->find(‘list’), this is for you.

Once again, many thanks to the fine work from CakePHP developers and contributors, especially Mark Story.

Top new year news indeed and looking forward to the full 1.3. stable release.

Filed under: development, , ,

Snow Leopard low down – my first days with 10.6

I’ve been eagerly awaiting the release of Snow Leopard – the new upgrade to Apples 10.* operating system. Now its released I’m curious about what hoops i’ll need to get my LAMP stack working again when i upgrade.

Below is a list of resources i’ve found from what others have said.

PowerbookMedic’s Snow Leopard review
http://www.powerbookmedic.com/wordpress/snow-leopard-review

Engadgets review
http://www.engadget.com/2009/08/26/snow-leopard-review/

Computer Shopper review
http://computershopper.com/software/reviews/mac-os-x-snow-leopard

PHP 5.3
http://www.brandonsavage.net/first-glance-apples-snow-leopard/

Installing macports under snow Leopard
http://forums.macrumors.com/showthread.php?t=720035

Snow Leopard Vs Windows 7 review
http://www.telegraph.co.uk/technology/microsoft/6087271/Microsoft-Windows-7-vs-Apple-Snow-Leopard.html

Getting Snow Leopards PHP 5.3 to play with CakePHP 1.3
http://dustinboling.com/blog/2009/09/cakephp-and-php-5-3-snow-leopard/

I’m heading off to our local Apple Store in Bristol today so will more than likely have a live install on my Mac by teatime.

Updated:

So I’ve run the backup onto Time Machine and also ensured that everything else got safely copied onto my usb drive. I did this just on the offchance i’d have to do a clean install. Remember to back up items you’ve told Time Machine to ignore (thanks @tomgidden). Also deregister your iTunes.

Installer has run and brought me through to the registration screen. I can’t tell you about any introduction screens as I was away from the mac when i ran it.

Things I’ve discovered about 10.6

  1. Terminal is now able to split panes so you can read what you’ve typed previously in the top pane whilst you continue to type at the bottom.
  2. I’ve got a bit of hard drive space back. Not sure how much but i’ve definitely got a few more GB back as promised.
  3. My Address Book is now working. Its been broken since 10.5.6 or so and was crashing everytime I tried to open it.
  4. Holding a Click down on Dashboard items now brings up Expose. Clicking on individual applications tiles their open windows. Pressing spacebar on a tile brings it full screen. Very nice.
  5. Time Machine is backing up quicker. I’ve shifted a GB over wireless in the last 10mins which is much faster. When i did the first 70GB backup on 10.5 i recall it took nearly a day.
  6. Mail has now got means to connect to Exchange. This means hooking up to Google Apps will be a treat which should also bring in shared Calendars for iCal.
  7. QuickTime has jumped from 7.6.* to 10.*. I’m sure this is to keep the revision in line with Windows Media Player numbers. The interface has been improved and there is no longer a distinction between Pro and non Pro versions. Apparently QuickTime 7 Pro can also be installed alongside it which is nice for those who export from it (and had paid for the upgrade). The Trim functionality is much improved and resembles the video trim interface on the iPhone 3GS which is super simple to use.

Big Win!

  1. The upgrade from 10.5.* -> 10.6 appears to have left my MacPorts intact. I’ve rebooted Apache and started my Mysql server locally and my previously working apps still do. Fantastic.

Filed under: development, , , , , ,

Named arguments vs cakephp sessions

Trying to capture named arguments and store them into a session in CakePHP was returning some unexpected results when I subsequently printed the session data.

My code simplified is as follows:

if( !empty($this->data)){
$params = $this->Session->read('Media.params');
pr($params);
} else {
$named = $this->params['named'];
$this->Session->write('Media.params',$named);
}

If i feed it a url as such http://testApp.com/controller/action/named1:value1/named:value2

I would expect the pr($params) to return an array as such:

array(
[named1]=>[value1]
[named2]=>[value2]
)

Except it was only returning:

array(
[named1]=>[value1]
)

Funny eh?

After a bit of fiddling, I managed to get it to work by adding an additional slash as such:
http://testApp.com/controller/action/named1:value1/named:value2/
which gave me the full named argument array.

For more about Sessions in CakePHP, visit http://book.cakephp.org/view/173/Sessions
and http://justkez.com/understanding-cakephp-sessions.

There are a few issues affecting this still, specifically if i add a namedArg to the end of a
$html->link() .

I have compensated for that as follows:
echo $html->link(__('Upload Media', true), array('controller'=> 'media', 'action'=>'upload','/article_id:'.$article['Article']['id']."/ "));
Note hacky ."/ "

When i establish whats up, I’ll post a reply here. If you know more than me, please leave a comment below.

Follow up:

The correct way to do this would be:

echo $html->link(__('Upload Media', true), array('controller'=> 'media', 'action'=>'upload','article_id:'=>$article['Article']['id']));

(thanks jon)

Filed under: development, , ,

where am i?

Occasionally i need to capture the url of the a current view page in cakephp which i would do by

echo $this->params['url']['url']

A bit of googling today, now gives me a nicer way to do it.

echo $this->here;

sweet eh?

Filed under: development, , ,

Cake and eat it -> Release: 1.2.1.8004

After a fantastic christmas present of a stable release of cakephp 1.2, I’ve now found via the blogosphere, that there is new release to play with, cakephp release 1.2.1.8004.

You can read the announcement here or go get yourself a new download from cakeforge
. Which is where i am off to now.

Filed under: development, ,

Final cakephp 1.2 now here

The much anticipated cakephp 1.2 development framework is now stable.

The history of the CakePHP grows stronger. December 25, 2008 will be remembered as one of the most important points in this history. After exactly 2 yrs from the first development release, we can happily say we have the most stable and powerful web framework available. Please enjoy our big present to you, CakePHP 1.2 stable [1].

See the release notes here

Fantastic news.

Filed under: development, , , ,

Cakephp 1.2 RC4 Released

It won’t be long now until my favorite php framework becomes a full release, and todays announcement that the RC4 candidate is out fills me full of festive joy.

Well done to all the devs who made this possible. I look forward to trying out the improvements in this release and the imminent arrival of the full release.

You can read the announcement here.

Filed under: development, , ,

Making the change

Recently the BBC announced plans to build a new infrastructure.

Below repeats the architectural principals they are planning to adhere to:

Architectural principles

  1. Each project must have a clear customer and deliver a real benefit.
  2. Don’t Repeat Yourself (DRY). Life is too short to spend your time re-inventing things.
  3. Be as simple as possible. Just do what we need to do now.
  4. Be as open as possible. Assume that all services can be accessed from outside the [your company], by default.
  5. Start simple, then iterate. Build the smallest thing you could possibly need, deploy it, then build applications on top of it. Think building blocks, not monoliths.
  6. Don’t optimise prematurely. The service might not grow the way we think it will.
  7. Build to scale. Think stateless, think content delivery networks, think database resilience.
  8. Test often. So you know when you need to optimise. So you can maintain your code. So you can maintain your platform.
  9. Evolve. Teams, systems, support structures. The platform. These principles!
  10. Let it die. Be prepared to turn your system off, or change it unrecognisably.

Filed under: infrastructure, ,

what's hot

Flickr Photos

Sponsor Mike run the Bath Half marathon

mikek on twitter

Error: Twitter did not respond. Please wait a few minutes and refresh this page.