Coder Social home page Coder Social logo

gleez / cms Goto Github PK

View Code? Open in Web Editor NEW
202.0 35.0 83.0 11.13 MB

GleezCMS - A Light, Simple, Flexible Content Management System

Home Page: www.gleezcms.org

PHP 79.63% CSS 4.07% JavaScript 15.50% Shell 0.05% Hack 0.76%
php hhvm gleez cms secure performance mysql wordpress drupal high-performance

cms's People

Contributors

azuya avatar calemsw avatar dishuostec avatar felixlandicho avatar jakimfett avatar sandeepone avatar sergeyklay avatar ultimateprogramer avatar zacharovds 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cms's Issues

Some problems with Assets

Hi @sandeepone!

I implemented some module and can't I to use therein Assets::css

Class

<?php defined('SYSPATH') OR die('No direct script access.');
/**
 * Trio Core class
 *
 * Acts as an object wrapper for three blocks with embedded PHP.
 *
 * @package    Trio
 * @author     Sergey Yakovlev - Gleez
 * @copyright  (c) 2011-2013 Gleez Technologies
 * @license    http://gleezcms.org/license Gleez CMS License
 */
class Trio_Core {

    /**
     * View filename
     * @var string
     */
    protected $_view;

    /**
     * Trio blocks
     * @var array
     */
    protected $_blocks;

    /**
     * Default filename
     * @var string
     */
    public $default = 'trio';

    /**
     * Returns a new Trio object
     *
     * If you do not define the `$file` parameter,
     * you must call [View::set_filename]
     *
     * @param   string  $file View filename [Optional]
     * @return  Trio_Core
     */
    public static function factory($file = NULL)
    {
        return new Trio($file);
    }

    /**
     * Class constructor
     * @param   string  $file  View filename [Optional]
     * @return  Trio_Core
     */
    public function __construct($file = NULL)
    {
        if (is_null($file))
        {
            $file = $this->default;
        }

        // Setting blocks
        $this->_set_blocks();

        // Setting views
        $this->set_filename($file);
    }

    /**
     * Renders Trio blocks
     *
     * Usage:<br>
     * <code>
     *     $trio->render();
     * </code>
     *
     * @return  Kohana_View
     * @uses    View::factory
     */
    public function render()
    {
        // NOTE THERE PLEASE
        Assets::css('trio/css', 'media/css/trio.css', array('style'), array('weight' => 15));
        Assets::js('trio/js', 'media/js/trio.js', array('jquery'), FALSE, array('weight' => 15));

        return View::factory($this->_view)->set('blocks', $this->_blocks);
    }

    /**
     * Gets blocks
     *
     * @uses  Cache::instance
     * @uses  ORM::factory
     */
    protected function _set_blocks()
    {
        $cache = Cache::instance();

        if( ! $this->_blocks = $cache->get('trio'))
        {
            Kohana::$log->add(LOG::DEBUG, 'Trio blocks loaded from database.');

            $this->_blocks = ORM::factory('trio');

            $cache->set('trio', $this->_blocks, DATE::WEEK);
        }
    }

    /**
     * Sets the view filename
     *
     * Usage:<br>
     * <code>
     *     $trio->set_filename($file);
     * </code>
     *
     * @param   string  $file  View filename
     * @return  Trio_Core
     * @throws  Trio_Exception
     * @uses    Kohana::find_file
     */
    public function set_filename($file)
    {
        if ((Kohana::find_file('views', $file)) === FALSE)
        {
            throw new Trio_Exception('The requested view :file could not be found', array(
                ':file' => $file,
            ));
        }

        // Store the file path locally
        $this->_view = $file;

        return $this;
    }
}

Do not include media/css/trio.css file. Nothing happens. As if I did not write anything. And everywhere where I use in the module

Assets::css('trio/css', 'media/css/trio.css', array('style'), array('weight' => 15));

same problem

File media/css/trio.css exists and if I use

Assets::css('trio/css', 'media/css/trio.css', array('style'), array('weight' => 15));

for example in template.php all works. Tell me, what could be the problem?

Tnx

about views...

It's should be helper method:

    <?php if (! empty($errors)): ?>
        <div id="formerrors" class="errorbox">
            <h3>Ошибка!</h3>
            <ol>
                <?php foreach($errors as $field => $message): ?>
                    <li>
            <?php echo $message ?>
                    </li>
                <?php endforeach ?>
            </ol>
        </div>
    <?php endif ?>

Installer 2.0

Hi!

I suggest to rewrite the installer, make it easier, more stable and transparent.

Please see my gist example.
This listing shows how you can simplify the process of creating database tables.

Best regards,

Not works without APC

After installation on localhost, first launch
in logs :
ERROR: PHP APC extension is not available

Kohana 3.4 support

I propose instead of 3.3 branches begin immediately with 3.4.
Who could deal with this task?

404 Exception when adding page

Hi,
did a fresh installation and when I create my first page I'm getting 404 exception for the new page alias as well as for page/2. Also cannot see how to add "categories", so I disabled this in the page settings before I could save a page...?

Do I need to add routes? How to do this? I'm using xampp on windows.

Thanks in advance,
robob

Some important errors in the Model_Auth_User

Hi @sandeepone !

It looks like that we have some problems with the Model_Auth_User

  • It seems that method confirm_signup() in Model_Auth_User doesn't work.
    This problem is related to the validation of $token
    • On my localhost I have excluded the login value from $token and I have no problem with confirm_signup().
    • May be necessary to reconsider the code in Model_Auth_User?
  • Also I see that the methods signup() and reset_password() have fundamentally wrong comments for variable $token. These comments do not help, on the contrary - they confuse.
  • I believe that the views in User Module to send mail should also be rewritten with using the variables

As long as you do not correct the issue with widgets, I could deal with this problem, if you assign it to me

Best regards,

Date class not found

hi, Fatal error: Class 'Date' not found in c:\www\gleezcms\system\classes\kohana\log.php on line 144, while I just install with git and suff happen.

I got no idea to fixed it , thank u

New Logo/Icon

We need a good icon and logo for Gleez Organization in Github homepage

A strange theming mechanism

Hi!

@sandeepone I think with the themes we have a problem.

Can you explain me how generally you intends to implement the mechanism of themes?
Now I can't use the theme for the administrator, regardless of the main theme.

After running the Theme::load_theme() method Kohana::modules() returned both paths...

Gleez Media module

We have a separate routing for this module

if (! Route::cache())
{
  // Image resize
  Route::set('resize', 'media/imagecache/<type>/<dimensions>(/<file>)',
    array(
      'dimensions' => '\d+x\d+',
      'type' => 'crop|ratio|resize',
      'file' => '.+'
    ))
    ->defaults(array(
        'controller' => 'resize',
        'action' => 'image'
  ));

  // Static file serving (CSS, JS, images)
  Route::set('media', 'media/<file>',
    array(
      'file' => '.+'
    ))
    ->defaults(array(
      'controller' => 'media',
      'action' => 'serve',
      'file' => NULL
  ));
}

What do you think about this?

gCons

gCons for my theme

I created the gCons sprite image from Comprehensive collection of 100 creative, open source and multi-purpose icons in 2 colors for the web and desktop applications)

CSS may be so:

[class^="gcon-"],[class*=" gcon-"]{display:inline-block;width:32px;height:32px;*margin-right:.3em;line-height:32px;vertical-align:top;background-image:url("../img/gcons-grey.png");background-position:32px 32px;background-repeat:no-repeat;margin-top:1px}
.nav li>a:hover>[class^="gcon-"],.nav li>a:hover>[class*=" gcon-"]{background-image:url("../img/gcons-grey-inverse.png")}
.icon-grey-inverse{background-image:url("../img/gcons-grey-inverse.png")}
.nav li>a:hover>.icon-grey-inverse{background-image:url("../img/gcons-grey.png")}
.gcon-add-item{background-position: 0 0}
.gcon-addressbook{background-position: -32px  0}
.gcon-agent{background-position: -64px 0}
.gcon-apple{background-position: -96px 0}
.gcon-arrow-round{background-position: -128px 0}
.gcon-badge{background-position: -160px 0}
.gcon-bar-chart1{background-position: -192px 0}
.gcon-bar-chart2{background-position: -224px 0}
.gcon-battery-full{background-position: -256px 0}
.gcon-bird{background-position: -288px 0}
.gcon-boat{background-position: -320px 0}
.gcon-bookmark{background-position: -352px 0}
.gcon-briefcase{background-position: -384px 0}
.gcon-calculator{background-position: -416px 0}
.gcon-calendar{background-position: -448px 0}
.gcon-cassette{background-position: -480px 0}
.gcon-chain{background-position: -512px 0}
.gcon-chat1{background-position: -544px 0}
.gcon-chat2{background-position: -576px 0}
.gcon-cloud-filled{background-position: -608px 0}
.gcon-cloud-outline{background-position: 0 -32px}
.gcon-computer{background-position: -32px -32px}
.gcon-configuration1{background-position: -64px -32px}
.gcon-configuration2{background-position: -96px -32px}
.gcon-connected{background-position: -128px -32px}
.gcon-connections{background-position: -160px -32px}
.gcon-container{background-position: -192px -32px}
.gcon-copy-item{background-position: -224px -32px}
.gcon-database{background-position: -256px -32px}
.gcon-delete-item{background-position: -288px -32px}
.gcon-disc{background-position: -320px -32px}
.gcon-dollar{background-position: -352px -32px}
.gcon-download{background-position: -384px -32px}
.gcon-edit{background-position: -416px -32px}
.gcon-email{background-position: -448px -32px}
.gcon-fan{background-position: -480px -32px}
.gcon-fancy-globe{background-position: -512px -32px}
.gcon-female-user{background-position: -544px -32px}
.gcon-fire{background-position: -576px -32px}
.gcon-first-aid{background-position: -608px -32px}
.gcon-flag{background-position: 0 -64px}
.gcon-flower{background-position: -32px -64px}
.gcon-full-screen{background-position: -64px -64px}
.gcon-glasses{background-position: -96px -64px}
.gcon-globe{background-position: -128px -64px}
.gcon-happy-face{background-position: -160px -64px}
.gcon-headphone{background-position: -192px -64px}
.gcon-heart{background-position: -224px -64px}
.gcon-home{background-position: -256px -64px}
.gcon-id{background-position: -288px -64px}
.gcon-ipod{background-position: -320px -64px}
.gcon-lab{background-position: -352px -64px}
.gcon-lady{background-position: -384px -64px}
.gcon-lamp{background-position: -416px -64px}
.gcon-leaves{background-position: -448px -64px}
.gcon-light{background-position: -480px -64px}
.gcon-line-globe{background-position: -512px -64px}
.gcon-lock{background-position: -544px -64px}
.gcon-lookup{background-position: -576px -64px}
.gcon-male-user{background-position: -608px -64px}
.gcon-microphone{background-position: 0 -96px}
.gcon-mobile1{background-position: -32px -96px}
.gcon-mobile2{background-position: -64px -96px}
.gcon-mouse{background-position: -96px -96px}
.gcon-multi-agents{background-position: -128px -96px}
.gcon-music-node{background-position: -160px -96px}
.gcon-network{background-position: -192px -96px}
.gcon-network-pc{background-position: -224px -96px}
.gcon-next-item{background-position: -256px -96px}
.gcon-phone{background-position: -288px -96px}
.gcon-pie-chart{background-position: -320px -96px}
.gcon-pin{background-position: -352px -96px}
.gcon-plane{background-position: -384px -96px}
.gcon-print{background-position: -416px -96px}
.gcon-processing1{background-position: -448px -96px}
.gcon-processing2{background-position: -480px -96px}
.gcon-push-pin{background-position: -512px -96px}
.gcon-recycle-empty{background-position: -544px -96px}
.gcon-recycle-full{background-position: -576px -96px}
.gcon-reload{background-position: -608px -96px}
.gcon-rss{background-position: 0 -128px}
.gcon-satellite{background-position: -32px -128px}
.gcon-save{background-position: -64px -128px}
.gcon-scale{background-position: -96px -128px}
.gcon-scissors{background-position: -128px -128px}
.gcon-screen{background-position: -160px -128px}
.gcon-search{background-position: -192px -128px}
.gcon-server{background-position: -224px -128px}
.gcon-shield{background-position: -256px -128px}
.gcon-shut-down{background-position: -288px -128px}
.gcon-star{background-position: -320px -128px}
.gcon-tag{background-position: -352px -128px}
.gcon-tap{background-position: -384px -128px}
.gcon-tree{background-position: -416px -128px}
.gcon-umbrella{background-position: -448px -128px}
.gcon-unlock{background-position: -480px -128px}
.gcon-usb{background-position: -512px -128px}
.gcon-van{background-position: -544px -128px}
.gcon-wifi{background-position: -576px -128px}
.gcon-world{background-position: -608px -128px}

HTML may be so:

    <div id="photo" class="well">
      <ul class="nav nav-list">
        <li><a href="#"><i class="gcon-id icon-grey-inverse"></i> Change photo</a></li>
        <li><a href="#"><i class="gcon-agent icon-grey-inverse"></i> Modify profile</a></li>
        <li><a href="#"><i class="gcon-server icon-grey-inverse"></i> Change password</a></li>
      </ul>
    </div>

Icons are here: http://klay.me/i/icons/gcons/
Screenshot: see atachment
Sizes: http://vpaste.net/IDSO5

I would be happy if you come in handy

using-gcons-example

Kohana 3.3 support

I'm planning to merge Kohana 3.3, before making major changes, please rise your opinions. So we can stream line the new features and gain performance.

Thank you!

New OAuth icons

Maybe Gleez needs changing images for OAuth. I think they should be in one and the same style. It will be stylish...

See an example:
apiphany-developer-login

Magic in PRODUCTION mode

@sandeepone

Can you check at what would happen if in bootstrap.php instead of

if (isset($_SERVER['KOHANA_ENV']))
{
  Kohana::$environment = constant('Kohana::'.strtoupper($_SERVER['KOHANA_ENV']));
}
else
{
  Kohana::$environment = ($_SERVER['REMOTE_ADDR'] == '127.0.0.1' ? Kohana::DEVELOPMENT : Kohana::PRODUCTION);
}

use

Kohana::$environment = Kohana::PRODUCTION;

routing is no longer any way to work? o_O

Problem with the Controller_Resize

Hi!

I think I have a problem with the Controller_Resize::cache()

If I use this code to determine original image name:

$image_original_name = Kohana::find_file('media', $this->image_src, FALSE);

It works for the module Gleez User, for example, when viewing a user profile.
However it does not work for the module Gleez Slider.

If I use this code to determine original image name:

$image_original_name = Route::get('media')->uri(array('file' => $this->image_src));

It works for the module Gleez Slider, however it does not work for the module Gleez User.

ACL 2.0

I have some ideas on ACL...
I think I could improve it.
Let me move it in a separate module (may be Gleez ACL) to improve it

Upload Photo View

Please give an example of when this is done:

modules/user/views/user/photo.php

    <?php if ( ! empty($errors)): ?>
        <div id="formerrors" class="errorbox">
            <h3>Ooops!</h3>
            <ol>
                <?php foreach($errors as $field => $message): ?>
                    <li>    
                        <?php echo $field .': '.$message ?>
                    </li>
                <?php endforeach ?>
            </ol>
        </div>
    <?php endif ?>

Why can't we make this code easier?

include Kohana::find_file('views', 'errors/partial');

Why partial? :)

New publishing interface

Hi all!
Today, I has decided that the interface of publishing posts and pages, which is now, did not make me happy :)

At least now I've noticed some errors that must be corrected.

I'll rewrite the publishing system.
Do you have something to say?

How to translate cms?

Hi!
I liked GleezCMS!
How to translate cms?
May be i can help translate to my language?

Best regards!

Gleez Format Manager

Hi all
I'm started new Gleez Format Manager.

He is facilitates work with custom text format and abstracts the implementation of the interface.

Usage

To get all the text formats is enough to use a Format::get_all() method that returns an array of all formats. And would be nice to create an Format instance in Gleez_Template:

Gleez_Template

/** @var Format An Format instance  */
protected $_format;

    ...

$this->_format = Format::instance();

Controller_Admin_Format

$formats = $this->_format->get_all();

    ...

$view = View::factory('admin/format/list')
            ->set('formats', $formats);

$this->response->body($view);

For direct access to a specific format may use Format::get() method.
For example:

/** @type integer An format ID */
$id = 4;

    ...

$format = $this->_format->get($id, FALSE);

if ( ! $format)
{
    Message::error(__('Text Format doesn\'t exists!'));

    ...
}

Also it have ability of directly access:

Format::$instance;

For getting the amount of existing formats, you can use the Format::coun_all() method.
For example:

$total = $this->_format->count_all();

if ($total == 0)
{
    Kohana::$log->add(Log::INFO, 'No formats found');
    $this->response->body(View::factory('admin/format/none'));

    return;
}

Get acquainted with the code is possible here: https://gist.github.com/sergeyklay/5112378

I will be glad with any amendments and rational criticism

Best regards,

Projects diff

We need some means for counting the amount of code that we are different from Kohana. I do not rule out the fact that when the differences will be quite a lot, we will cease to depend on Kohana

@todo 1.0

Part of Gleez 1.0 milestone

  • Add Gravatar support #482
  • Full oAuth2 / SSO support
  • More themes (minimum 2-3)
  • Media library support (similar WP media library) with file drag support
  • Visual Widget constructor/generator with more option (not only static)
  • Gleez Editor with full wysiwygs support #238 #214
  • Complete blog system for users #312 #316
  • Contact form #295
  • Internal correspondence users
  • The rating system
  • Slider #126
  • Polls
  • Full user profile with multiple fields
  • Minimum (At least) API documentation
  • Working and a full demo site http://demo.gleezcms.org
  • Roadmap milestone
  • Gleez Forum Module
  • News(RSS/Activity) Widget
  • Gleez Cart Module
  • Gleez Shop Module
  • Support many popular payments system
  • RSS #289, #290, #292, #293 #294, #404, #414, #418, #420
  • Corporate Blog Gleez CMS Blog
  • Verify.js — A powerful, customizable asynchronous form validation library
  • Add an event auto-hide each messages with nice effect if user does not close it
  • Page with permission by roles/users

This year we plan to implement most of these things.
I want to offer you to choose something from the list, the most needed now.

Google Analytics support

Hi all!

I want to propose an easy way to add Google Analytics support.
In order to add support for Google Analytics you need perform several steps.

1. First step

Add static method to Gleez Assets Core. For example:

    /**
     * Paste Google Analytics code for stats
     *
     * Example:<br>
     *  Assets::google_stats('UA-12345678-9');
     * <code>
     * </code>
     *
     * @param  string  $ua  User Agent ID in `UA-xxxxx-y` format 
     */
    public static function google_stats($ua)
    {
        Assets::codes('google-stats',
            "var _gaq = _gaq || [];".PHP_EOL.
            "_gaq.push(['_setAccount', '".$ua."']);".PHP_EOL.
            "_gaq.push(['_trackPageview']);".PHP_EOL.
            "(function() {".PHP_EOL.
            "var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;".PHP_EOL.
            "ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';".PHP_EOL.
            "var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);".PHP_EOL.
            "})();"
        );
    }

Probably PHP_EOL is not essential here. You can use it for make HTML output will be more readable

2. Second step

Add User Agent ID to your site config. For example:

    ...

    /**
     * Define Google User Agent ID
     * @var string
     */
    'google_ua' => 'UA-12345678-9',  // NOTE THERE

    ...
);
3. Third step

Add initial code to Gleez_Template class:

    if ($this->auto_render)
    {

        ...

        $ua = $this->_config->get('google_ua', FALSE);

        // Google stats
        if ($ua AND Kohana::PRODUCTION === Kohana::$environment)
        {
            Assets::google_stats($ua);
        }

        ...
    }

That's all :)

Yes, you can improve the method to add the desired functionality.
I hope my idea will be useful.

P.S. @sandeepone if it is good idea and it is possible, please add this features to Gleez (may be with your desired functionality)

Best regards,

Fatal Error in ACL

Only in production mode

class Gleez_ACL {
 ...
 ...
 ...
 public static function check($perm_name, Model_User $user = NULL)
 {
    if (is_null($user))
    {
      $user = User::active_user();
      echo Debug::vars($user);exit; // Attention here! $user is NULL
    }
 }

Tag Model

We have some problems with Tag Model.

Code in line 115:

   // Model specefic links; view, edit, delete url's.
   if ($field === 'url'  OR $field === 'link')
      return ($path = Path::load($this->rawurl) ) ? $path['alias'] : $this->rawurl;

calls $this->rawurl:

  if ($field === 'rawurl')
    return Route::get($this->type)->uri( array('action' => 'tag', 'id' => $this->id));

but we don't have requested route post

MongoDB Reader

Hi @sandeepone !

I wanted to ask you something about the MongoDB Reader module which you realized before. The fact is that I rewrite it again, without the deprecated methods ... Are you ready to answer some of my questions?

  1. How are you going to record system events in a Logs? Give me an example please
  2. In the View you have the following code:
User::lookup((int) $log['user'])

I looked at the logs and not found in it what or mention of some user ids. What can you say about this?
3. You could provide for this case a separate branch (or mb new repo)?
4. I plan to create a module that will be independent and will be connected separately. How do you feel about that?
5. Assign to me this issue please
6. Here is an example of the Logs with which to begin, I would like to work:

db.Logs.insert(
  {
    time:   '2013-01-11 00:09:37',
    type:   'DEBUG',
    body:   'This site is running on the localhost. Caching is disabled.',
    host:   '127.0.0.1',
    agent:  'Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11',
    url:    'admin/module/confirm'
  }
)

db.Logs.insert(
  {
    time:   '2013-01-11 00:09:38',
    type:   'INFO',
    body:   'Deactivated module mongo.',
    host:   '127.0.0.1',
    agent:  'Opera/9.80 (X11; Linux i686) Presto/2.12.388 Version/12.12',
    url:    'admin/module/confirm'
  }
)

db.Logs.insert(
  {
    time:   '2013-01-11 00:57:07',
    type:   'ERROR',
    body:   'ErrorException [ 1 ]: Call to undefined method Mongo::instance() ~ MODPATH/mongo/classes/controller/admin/log.php [ 33 ]',
    host:   '127.0.0.1',
    agent:  'Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11',
    url:    'admin/logs'
  }
)

db.Logs.insert(
  {
    time:   '2013-01-11 12:31:02',
    type:   'STRACE',
    body:   'This site is running on the localhost. Caching is disabled.',
    host:   '127.0.0.1',
    agent:  'Opera/9.80 (X11; Linux i686) Presto/2.12.388 Version/12.12',
    url:    'media/js/slider.js'
  }
)

I think it is necessary to minimize writing data entry. For example time is best for as a timestamp format - it is shorter.

To be continued ..

Best regards,

Remake the ACL::required() method

Maybe makes sense remake the ACL::required method?
For example:

/**
 * If the active user does not have this permission,
 * failed with an Exception_403.
 *
 * @throws  Exception_403 If the user doesn't have permission.
 * @param   string        $perm_name
 * @param   object        User object
 * @param   callable      $callbak         What to run if there is no privilege
 * @return  boolean
 */
public static function required($perm_name, Model_User $user = NULL, $callback = NULL)
{
  if ( ! ACL::check($perm_name, $user) )
  {
    if( ! is_null($callback) )
    {
      call_user_func($callback);
    }

    // If the action is set and the role hasn't been matched,
    // the user doesn't have permission.
    throw new HTTP_Exception_403('Unauthorised access attempt to action :act.',
      array(
        ':act' => $perm_name
      )
    );

  }
}

It is necessary for ease of use:

<?php defined('SYSPATH') OR die('No direct script access.');

class Controller_Admin extends Template {

  public function before()
  {
    // Inform that we're in admin section for themers/developers
    Theme::$is_admin = TRUE;

    ACL::required('administer site', NULL, Request::$current->redirect(Route::get('user')->uri(array('action' => 'login'))));
    parent::before();
  }

  public function index()
  {
    $this->response->body(__('Welcome to admin'));
  }
}

or

ACL::required('administer site', NULL, Kohana::$log->add(Log::ERROR, 'An attempt of unauthorized access'));

I'm not sure that's a good idea, but can you suggest a better idea?

Using braces in actions list

Explain to me the difference between

  Route::set('user', 'user(/<action>)(/<id>)(/<token>)',
    array(
      'action'        => 'edit|login|logout|view|register|confirm|password|profile|photo',
      'id'            => '\d+',
    ))
    ->defaults(
      array(
        'controller'  => 'user',
        'action'      => 'view',
        'token'       => NULL,
  ));

and

  Route::set('user', 'user(/<action>)(/<id>)(/<token>)',
    array(
      'action'        => '(edit|login|logout|view|register|confirm|password|profile|photo)',
      'id'            => '\d+',
    ))
    ->defaults(
      array(
        'controller'  => 'user',
        'action'      => 'view',
        'token'       => NULL,
  ));

Note the parentheses in the second example.
I understand that work equally well both examples. Then why do we need braces?

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.