Skip to content

Instantly share code, notes, and snippets.

View kaiohken1982's full-sized avatar

Sergio Rinaudo kaiohken1982

View GitHub Profile
@kaiohken1982
kaiohken1982 / gist:7419430
Created November 11, 2013 20:04
Zend Framework 1 Acl implementation #3
<?php
/**
* Ci da la possibilità di effettuare queries all'oggetto ACL
*
* @author Sergio Rinaudo
*/
class My_Controller_Action_Helper_Acl
extends Zend_Controller_Action_Helper_Abstract
{
protected $_acl = null;
@kaiohken1982
kaiohken1982 / gist:7419371
Last active December 28, 2015 01:19
Zend Framework 1 Acl implementation #2
<?php
class My_Controller_Plugin_Acl
extends Zend_Controller_Plugin_Abstract
{
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$acl = My_Acl::getInstance();
$auth = Zend_Auth::getInstance();
$identity = $auth->getIdentity();
$role = null !== $identity ? $identity->role : My_Acl::ROLE_GUEST;
@kaiohken1982
kaiohken1982 / gist:7419301
Created November 11, 2013 19:55
Zend Framework 1 Acl implementation #1
<?php
class My_Acl extends Zend_Acl
{
protected static $_instance = null;
const ROLE_GUEST = 'guest';
const ROLE_MEMBER_STANDARD = 'member-standard';
const ROLE_MEMBER_PREMIUM = 'member-premium';
const ROLE_ADMIN = 'admin';
@kaiohken1982
kaiohken1982 / gist:7368317
Created November 8, 2013 09:02
First server phpmyadmin config
/*
* First server
*/
$i++;
/* Authentication type and info */
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['extension'] = 'mysql';
@kaiohken1982
kaiohken1982 / gist:7122132
Created October 23, 2013 16:43
Check login angularjs using rootScope
.run(['$rootScope', 'LoggedInLoader', 'CategoriesLoader', 'LocationsLoader',
function($rootScope, LoggedInLoader, CategoriesLoader, LocationsLoader) {
// All GLOBAL here
$rootScope.redirectionDelay = 2500;
$rootScope.checkedLogged = false;
$rootScope.logged = false;
$rootScope.username = '';
$rootScope.check = function() {
$rootScope.resource = new LoggedInLoader({});
@kaiohken1982
kaiohken1982 / gist:6805083
Created October 3, 2013 04:39
ZF2 navigation using custom rendering function example
if(!function_exists('renderMenu')) {
function renderMenu($container, $obj, $step = 0) {
$html = '';
if(null !== $container && $container->count()) {
if(!$step) {
$html.= '<ul class="nav ">' . PHP_EOL;
$step++;
} elseif($step == 1) {
$html.= '<ul class="dropdown-menu">' . PHP_EOL;
@kaiohken1982
kaiohken1982 / gist:6565694
Created September 14, 2013 21:13
Doctrine 2 "category" TermTaxonomy ordered resultset example -- not best practice
$qb = $this->_em->createQueryBuilder();
$qb->select(array(
'a.termTaxonomyId',
'b.name',
'a.parentId',
'COALESCE(a.parentId, a.termTaxonomyId) AS HIDDEN fld')
);
$qb->from('\My\Entity\TermTaxonomy', 'a');
$qb->leftJoin('\My\Entity\Term', 'b', 'WITH', 'b.termId = a.termId');
$qb->andWhere($qb->expr()->eq('a.taxonomy', ':taxonomy'));
@kaiohken1982
kaiohken1982 / gist:6112983
Created July 30, 2013 13:37
Getting breadcrumbs using fragment
public function breadcrumbsAction()
{
$default = 'dashboard';
$id = $this->getRequest()->getQuery('id', $default);
$pos = strpos($id, '/');
$id = false !== $pos ? substr($id, 0, $pos) : $id;
$view = $this->getServiceLocator()->get('Zend\View\Renderer\PhpRenderer');
$navigation = $view->navigation('navigation');
$container = $navigation->getContainer();
$page = $container->findOneBy('fragment', $id);
@kaiohken1982
kaiohken1982 / gist:6087916
Created July 26, 2013 10:38
ZFTool Is64Bit test on 64Bit Windows OS with 32Bit Apache
<?php
namespace Application\Test;
use ZFTool\Diagnostics\Test\AbstractTest;
use ZFTool\Diagnostics\Result\Success;
use ZFTool\Diagnostics\Result\Failure;
use ZFTool\Diagnostics\Result\Warning;
class Is64Bit
@kaiohken1982
kaiohken1982 / gist:5661445
Created May 28, 2013 08:53
ZF2 PhpRenderer Service
use Zend\View\Model\ViewModel;
[...]
// within the constructor
$this->viewmodel = new ViewModel();
$this->viewmodel->setVariable('myobj', $this); // object assigned to view model will be available
// within the view script using $this->myobj
[...]
public function render()