crshman's Profile Page

Tag-Archive for » Cakephp «

Tuesday, September 08th, 2009 | Author:

Hey All,

Long time no update, I know… Well I’ve been working on some projects that involve cPanel and its API so I decided to write a nifty little component for my fellow bakers. It makes extensive use of the php api library that can be found on the development forums, but I tweaked it a little bit to be more cake friendly.

Unlike my prior posts, this component is a little too long to post here. So head over to my git hub repository to pick up your slice of goodness.

As usual if you have any comments, concerns or questions feel free to get in touch!

Category: Development  | Tags: ,  | Comments off
Thursday, August 06th, 2009 | Author:

Hey Everyone,

So I went ahead and took up Mark Story on his challenge task and added the node deleting functionality that was missing from the original buildAcl action. I’m not sure if this was the best way to code it….but a few beers, and a lot of coding later I came up with this gem. Feel free to use this wherever you want.


/**
* Rebuild the Acl based on the current controllers in the application
*
* @return void
*/
function buildAcl() {
$log = array();
$methods = array();
$tempChildren = array();

$aco =& $this->Acl->Aco;
$root = $aco->node('controllers');
if (!$root) {
$aco->create(array('parent_id' => null, 'model' => null, 'alias' => 'controllers'));
$root = $aco->save();
$root['Aco']['id'] = $aco->id;
$log[] = 'Created Aco node for controllers';
} else {
$root = $root[0];
}

App::import('Core', 'File');
$Controllers = Configure::listObjects('controller');
$appIndex = array_search('App', $Controllers);
if ($appIndex !== false ) {
unset($Controllers[$appIndex]);
}
$baseMethods = get_class_methods('Controller');
$baseMethods[] = 'buildAcl';

// look at each controller in app/controllers
foreach ($Controllers as $ctrlName) {
App::import('Controller', $ctrlName);
$ctrlclass = $ctrlName . 'Controller';
$methods = get_class_methods($ctrlclass);

// find / make controller node
$controllerNode = $aco->node('controllers/'.$ctrlName);
if (!$controllerNode) {
$aco->create(array('parent_id' => $root['Aco']['id'], 'model' => null, 'alias' => $ctrlName));
$controllerNode = $aco->save();
$controllerNode['Aco']['id'] = $aco->id;
$log[] = 'Created Aco node for '.$ctrlName;
} else {
$controllerNode = $controllerNode[0];
// Get all the children of the current controller node
$children = $this->Acl->Aco->children($controllerNode['Aco']['id']);
$sizeChildren = sizeof($children);
}

//clean the methods. to remove those in Controller and private actions.
foreach ($methods as $k => $method) {
if (strpos($method, '_', 0) === 0) {
unset($methods[$k]);
continue;
}
if (in_array($method, $baseMethods)) {
unset($methods[$k]);
continue;
}
$methodNode = $aco->node('controllers/'.$ctrlName.'/'.$method);
if (!$methodNode) {
$aco->create(array('parent_id' => $controllerNode['Aco']['id'], 'model' => null, 'alias' => $method));
$methodNode = $aco->save();
$log[] = 'Created Aco node for '. $method;
}
}

$sizeMethods = sizeof($methods);

// More Aco's than methods
if($sizeChildren > $sizeMethods) {
foreach($children as $child) {
$tempChildren[] = $child['Aco']['alias'];
}
// Get the difference between Acos and methods
$diff = array_diff($tempChildren, $methods);
foreach($diff as $alias) {
$rogueAco = $aco->find('first',array(
'conditions' => array(
'alias' => $alias,
'parent_id' => $controllerNode['Aco']['id'],
)));
$aco->del($rogueAco['Aco']['id']);
$log[] = 'Deleted Aco node '.$controllerNode['Aco']['alias'].'/'.$alias;
}
}
}
debug($log);
}

Until next time, Laterz

Category: Development  | Tags: ,  | 3 Comments
Wednesday, July 29th, 2009 | Author:

Hey All,

Well I’ve been baking a lot of cake lately, and I’ve started to delve into the core a little….it’s not all that scary…kinda haha.

This post is being made in response to the infamous:

Warning (512): Cache not configured properly. Please check Cache::config(); in APP/config/core.php [CORE/cake/libs/configure.php, line 663]

I believe I found a fix/solution for this, and from what I can tell it’s quite portable (you can use it across different installations). This solution would be used in conjunction with providing the proper credentials to your cake installations “tmp” folder and all it’s sub-directories so that your web server can get down to business.

Open up your core.php file and look for the following at the end of the file:


Cache::config('default', array('engine' => 'File');

and replace it with


Cache::config('default', array('engine' => 'File', 'path' => ROOT.'/app/tmp'));

That should do it!

Until next time, l8rz!

Category: Development  | Tags: ,  | 4 Comments
Thursday, December 11th, 2008 | Author:

Ok watch out….this post is most likely going to be an epic rant….you’ve been forewarned…..

Why in the HECK is it so difficult to find a pretty, simple, elegant and above all FUNCTIONAL source code management and bug/ticket tracking system????

I have tried unfuddle, assembla, 16bugs, the now defunct porchlight, beanstalk, sifter, codebase, fogbugz, bugja and have yet to find a system that I *truly* like.

Unfuddle almost took the cake, but they don’t allow for the public to submit tickets only team members….what’s that about!?

Assembla was great too, but they also didn’t allow for public submission of tickets. Assembla got REALLY close though, people can view the “Dashboard” of one of your projects and sign in to submit a ticket. Seems close to what I want right? The catch…..in order for a user to submit a ticket they need to have “edit” rights to the ENTIRE project…which means they can edit the wiki, all the ticket information, etc. Why can’t you make a permission set for public users to just create/comment on tickets??

Right now i’m trying to cobble something together using Lighthouse, my MediaTemple SVN account and a simple WebSVN page.

I did stumble upon github which is a pretty cool concept, it also integrates with Lighthouse. This is essentially the same as my above configuration (slightly more integrated because github combines my WebSVN page and a Git account) However going this route brings with it other issues:

  • Need to learn Git Source Versioning
  • The Git eclipse plugin leaves much to be desired

The two apps I did find that can do this are ironically free, trac and redmine. At this stage i’m not sure if redmine can do the public ticket submission, but it does handle multiple projects.

Trac:

Cons

  • Ugly as hell
  • Requires an account with Mongrel support
  • Doesn’t manage multiple projects

Pros

  • It’s free!
  • It essentially works for what I need

Redmine:

Cons

  • Not sure if it even supports public ticket submission
  • Requires RoRs/Mongrel support

Pros

  • It’s Free!
  • It can handle multiple projects

The problem with these two is that my MediaTemple account requires me to pay and ADDITIONAL $20/mo to simply add Ruby/Mongrel support….grr….I’m not really too exicted to change hosts at this point in time because that’s a lot of work (R&D plus the actual migration)

Some might ask, why not SourceForge or GoogleCode or any other free project management setup?

The problem with this is that I have projects that are not potentially opensource, they are private. I cannot host private projects on sites such as SF or GoogleCode. This is problematic for me. Sure I can create and host all my OSS projects at sites like these, but I would MUCH rather have a centralized project management system in which I can overview all my projects and what’s going on with them in one area rather than all over the internetz.

My Needs:

  • Bug/Ticket Tracking System
  • The aforementioned system MUST allow for public submission of tickets (and not allow the public to edit the whole dang site!)
  • Source Control system that integrates with SVN/Git/CVS/etc.
  • I would like the above so that I can link code to tickets
  • Also I would like to have the public able to see all my code revisions and edits (along with myself)
  • Support for multiple projects
  • I plan on doing many projects in my life time, I don’t want to have 10 different places where they are hosted. I want it centralized.

I’m seriously thinking about brewing up an app to fit this niche market because from my google-ing I found that a lot of small developers have very similar, if not the same needs as me.

*phew* /Rant

Until Next Time…..~RN

Saturday, December 06th, 2008 | Author:

Hey All,

Haven’t updated in a while…I know…..but who follows this thing anyways? Noone….

It’s a Saturday evening, didn’t really do any studing at all today…which is a VERY bad thing since I did horrible on most all of my midterms….*sigh*

Instead today I did the following:

  • Upgraded the fileserver kernel, which failed miserably so I reverted back
  • Found some old pictures on a dusty SD card and uploaded them to my gallery, which now contains 3,198 items! w00t
  • Worked on SCO2.0 a little bit…I have to rewrite that bad boy pretty much from the ground up, but oh well…the first time around was a HUGE learning experience….cakephp FTW!

Yeah, nothing overly exciting….and definately nothing pertaining to school *sigh* I’ll get to that….soon….

Category: General  | Tags: , ,  | Comments off