Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis Berry committed Apr 8, 2012
1 parent c0fb119 commit 6e04647
Show file tree
Hide file tree
Showing 2,891 changed files with 586,121 additions and 1 deletion.
Binary file added .DS_Store
Binary file not shown.
5 changes: 5 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
34 changes: 34 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
CakePHP is a rapid development framework for PHP which uses commonly known design patterns like Active Record, Association Data Mapping, Front Controller and MVC. Our primary goal is to provide a structured framework that enables PHP users at all levels to rapidly develop robust web applications, without any loss to flexibility.

The Cake Software Foundation - promoting development related to CakePHP
http://cakefoundation.org/

CakePHP - the rapid development PHP framework
http://www.cakephp.org

Cookbook - user documentation for learning about CakePHP
http://book.cakephp.org

API - quick reference to CakePHP
http://api.cakephp.org

The Bakery - everything CakePHP
http://bakery.cakephp.org

The Show - live and archived podcasts about CakePHP and more
http://live.cakephp.org

CakePHP Google Group - community mailing list and forum
http://groups.google.com/group/cake-php

#cakephp on irc.freenode.net - chat with CakePHP developers
irc://irc.freenode.net/cakephp

CakeForge - open development for CakePHP
http://cakeforge.org

CakePHP gear
http://www.cafepress.com/cakefoundation

Recommended Reading
http://astore.amazon.com/cakesoftwaref-20/
101 changes: 101 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
Homkora | Time Tracking Made Simple
========
Created By: [Travis Berry][2]

[http://twitter.com/homkora][9]

Usage:
===============
The code specific to this app is released under an [unlicense][10]. I would like it if you kept the link to my site at the bottom, but you don't have to.

[CakePHP][3] Licensed under [The MIT License][4]

LoggableBehavior by [alkemann][11]

ACL plugin by [interlock][12]

Awesome Icons from [http://blog.twg.ca/2009/09/free-iphone-toolbar-icons/][7]

Fantastic stopwatch jquery plugin was made by [kellishaver][8]

PHamlP from [chris.l.yates][13]

PHP Markdown by [michel.fortin][14]


Download:
=========
Download latest version from [http://github.com/ninetwentyfour/Homkora/zipball/master][1]

Install:
=========
Follow the instruction for setting up a new CakPHP install [here][5].

Change database.php config file like [so][6].

Do lots of other things I'm too lazy to type at the moment.

????

Profit

Todo:
========================

<del>Only show user projects and timers in add timer drop downs - only shows user data everywhere else</del>

<del>Make timers editable starting with saved time</del>

<del>FAQ About Privacy Contact and Instruction pages</del>

<del>Add page for users to modify password and account details</del>

Redirect with warning if new user creates timer with no projects first

Documentation for API

Add users - Edit Users - APIs

<del>Flash Message colors</del>

<del>Hide Flash Message after period of time</del>

<del>Delete timers associated with projects on project delete</del>

<del>Form validation - custom error messages</del>

<del>Add checks and redirect/show message on user attempt to edit/view other user data</del>

<del>Add email to User table</del>

<del>Confirm user account with email</del>

Generate graphs of time records

Premium accounts

<del>Improved event logging</del>

<del>Export data as a csv</del>

<del>Pretty much everything at this point.</del>


Disclaimer:
===========
I'm in no way responsible for anything you do with this. If this breaks anything of yours, I'm not responsible for that either.

[1]: http://github.com/ninetwentyfour/Homkora/zipball/master
[2]: http://www.travisberry.com
[3]: http://cakephp.org/
[4]: http://www.opensource.org/licenses/mit-license.php
[5]: http://book.cakephp.org/view/914/Production
[6]: http://book.cakephp.org/view/922/Database-Configuration
[7]: http://blog.twg.ca/2009/09/free-iphone-toolbar-icons/
[8]: https://github.com/kellishaver/stopwatch
[9]: http://twitter.com/homkora
[10]: http://unlicense.org/
[11]: http://bakery.cakephp.org/articles/alkemann/2008/10/21/logablebehavior
[12]: https://github.com/interlock/acl_plugin
[13]: http://code.google.com/p/phamlp/
[14]: http://michelf.com/projects/php-markdown/
24 changes: 24 additions & 0 deletions UNLICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <http://unlicense.org/>
5 changes: 5 additions & 0 deletions app/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
175 changes: 175 additions & 0 deletions app/app_controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
<?php
class AppController extends Controller {
var $components = array('Acl', 'Auth', 'Session','Email','Security','RequestHandler');
var $helpers = array('Html', 'Form', 'Session', 'Cycle','Cache');
var $persistModel = true;
var $cacheAction = array('view' => '1 hour','profile' => '2 days');
var $view = 'Haml';

function beforeFilter() {
//check for api calls
$this->__checkAPI();

//Configure AuthComponent
//$this->Auth->actionPath = 'controllers/';
$this->Auth->allowedActions = array('display','activate','logout','publicAdd','login');
//$this->Auth->authorize = 'actions';
//$this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
//$this->Auth->logoutRedirect = '/login';
$this->Auth->loginRedirect = array('controller' => 'projects', 'action' => 'index');
if ($this->data) {
if ($this->action == 'login') {
// Retrieve user data
$this->loadModel('User');
$params = array('conditions' => array('username' => $this->data['User']['username']));
$results = $this->User->find('first',$params);
// Check to see if the UserÕs account isnÕt active
if ($results['User']['active'] == "0") {
// Uh Oh!
$this->Session->setFlash('Your account has not been activated yet!', 'default', array('class' => 'flash_bad'));
$this->Auth->logout();
$this->redirect($this->Auth->logout());
}
// Cool, user is active, redirect post login
else {
if($this->Auth->login($this->data)){
$this->redirect('/projects/index');
}
}

}
}

//logable
if(isset($this->Session)){
if (sizeof($this->uses) && $this->{$this->modelClass}->Behaviors->attached('Logable')) {
$this->{$this->modelClass}->setUserData($this->Session->read('Auth'));
}
}

//security compnent
if ($this->action == 'addTime') {
// don't check this form. this is ajax on project view
$this->Security->validatePost = false;
}
$this->Security->blackHoleCallback='invalidSecurity';
//must ignore the time field in edit and add timers. these are hidden and supposed to change
$this->Security->disabledFields = array('time');
$this->Security->requireAuth('delete', 'add','edit','publicAdd');
}

function beforeRender(){
if ($this->action == 'profile') {
$gravatar2 = $this->get_gravatar($_SESSION['Auth']['User']['email'],'80');
$this->set('gravatar2', $gravatar2);
}
if(isset($_SESSION['Auth']['User'])){
$gravatar = $this->get_gravatar($_SESSION['Auth']['User']['email'],'20');
$this->set('gravatar', $gravatar);
}
}

//this gets the group of the current user to check in admin/acl to see if they have permission
function entityName(){
//the loadModel way
$this->loadModel('User');
$user = $this->Auth->user();
if($user!=null){
$actual_user = $this->User->findByUsername($user['User']['username']);
debug($actual_user['Group']['name']);
return $actual_user['Group']['name'];
}
}

//if security is invalid do this
function invalidSecurity(){
$this->Session->setFlash('There was a security problem with your request. Please try again.', 'default', array('class' => 'flash_bad'));
$this->redirect('/');
}

/**
* Get either a Gravatar URL or complete image tag for a specified email address.
*
* @param string $email The email address
* @param string $s Size in pixels, defaults to 80px [ 1 - 512 ]
* @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ]
* @param string $r Maximum rating (inclusive) [ g | pg | r | x ]
* @param boole $img True to return a complete IMG tag False for just the URL
* @param array $atts Optional, additional key/value attributes to include in the IMG tag
* @return String containing either just a URL or a complete image tag
* @source http://gravatar.com/site/implement/images/php/
*/
function get_gravatar( $email, $s = 80, $d = 'identicon', $r = 'pg', $img = true, $atts = array() ) {
$url = 'http://www.gravatar.com/avatar/';
$url .= md5( strtolower( trim( $email ) ) );
$url .= "?s=$s&d=$d&r=$r";
if ( $img ) {
$url = '<img align="left" style="border:1px solid #444;margin:0px 5px 0px 0px;" src="' . $url . '"';
foreach ( $atts as $key => $val )
$url .= ' ' . $key . '="' . $val . '"';
$url .= ' />';
}

return $url;
}

//check for partner api key for api access
function __checkAPI(){
if(isset($this->params['url']['partner'])){ //if partner param for url is set
$this->loadModel('ApiKey');
$tag = $this->params['url']['partner'];
$params = array(
'conditions' => array('key' => (string)$tag)
);
$api = $this->ApiKey->find('all',$params); // see if that key exists in the db
$this->loadModel('User');
$params2 = array(
'conditions' => array('_id' => (string)$api[0]['ApiKey']['user_id'])
);
$user = $this->User->find('all',$params2);
if(!empty($api)){
//write a user to the session for authentication
$this->Session->write('Auth.User._id', $user[0]['User']['_id']);
$this->Session->write('Auth.User.email', $user[0]['User']['email']);
$this->Session->write('Auth.User.username', $user[0]['User']['username']);
$this->Session->write('Auth.User.group_id', $user[0]['User']['group_id']);
$this->Session->write('Auth.User.active', $user[0]['User']['active']);
$this->Session->write('Auth.User.created', $user[0]['User']['created']);
$this->Session->write('Auth.User.modified', $user[0]['User']['modified']);
}
}
}

function createIndextankClient(){
App::import('Vendor', 'indextank_client');
$API_URL = 'http://:[email protected]';
$client = new ApiClient($API_URL);
return $client;
}

function addIndextank($indexType,$id,$data){
//send project to indextank
$client = $this->createIndextankClient();
$index = $client->get_index($indexType);
$doc_id = $id;
$index->add_document($doc_id, $data);
}

function deleteIndextank($indexType,$id){
//delete indextank document
$client = $this->createIndextankClient();
$index = $client->get_index($indexType);
$index->delete_document($id);
}

function searchIndextank($indexType,$query){
//search indextank
$client = $this->createIndextankClient();
$index = $client->get_index($indexType);
$index->add_function(2, "relevance");
$res = $index->search($query);
return $res;
}

}
?>
28 changes: 28 additions & 0 deletions app/app_model.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
class AppModel extends Model {
var $cacheQueries = true;
var $entity_id;//not sure what this does, was in example. doesn;t seem to do anything

//this limits the amount of data returned to the user based on the user
function beforeFind($queryData) {
if(isset($_SESSION['Auth']['User'])){
$group = $_SESSION['Auth']['User']['group_id'];//read the entity id from the session
$user = $_SESSION['Auth']['User']['_id'];
if($group!='1'){// only limit data if it's not a admin user. needs to be based on name in future
if(isset($this->_schema['user_id'])) {
//use a condition to limit data
$queryData['conditions'][$this->name.'.user_id'] = $user;
return $queryData;
}
}else{
//Do nothing
return $queryData;
}
}else{
//Do nothing
return $queryData;
}
}

}
?>
Loading

0 comments on commit 6e04647

Please sign in to comment.