当前位置: 首页>>代码示例>>PHP>>正文


PHP Permission::has方法代码示例

本文整理汇总了PHP中Permission::has方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::has方法的具体用法?PHP Permission::has怎么用?PHP Permission::has使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Permission的用法示例。


在下文中一共展示了Permission::has方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Create new shouts view.
  */
 public function __construct()
 {
     parent::__construct();
     $this->id = 'shouts';
     $this->title = HTML::anchor(Route::url('shouts'), __('Shouts'));
     $this->_can_shout = Permission::has(new Model_Shout(), Model_Shout::PERMISSION_CREATE);
 }
开发者ID:anqh,项目名称:anqh,代码行数:10,代码来源:shouts.php

示例2: content

 /**
  * Render view.
  *
  * @return  string
  */
 public function content()
 {
     ob_start();
     $foursquare = $this->venue->foursquare();
     if (!$foursquare) {
         echo new View_Alert(__('This venue has not been linked to Foursquare yet.'), null, View_Alert::INFO);
     } else {
         // Homepage
         echo HTML::anchor(Arr::path($foursquare, 'short_url'), HTML::image(Arr::path($foursquare, 'primarycategory.iconurl'), array('alt' => HTML::chars(Arr::path($foursquare, 'primarycategory.nodename')), 'title' => HTML::chars(Arr::path($foursquare, 'primarycategory.nodename')))) . ' ' . HTML::chars(Arr::path($foursquare, 'primarycategory.nodename'))), '<br />';
         // Mayor
         if ($mayor = Arr::path($foursquare, 'stats.mayor.user')) {
             echo __('Mayor: :mayor, :city', array(':mayor' => HTML::anchor('http://foursquare.com/user/' . Arr::get($mayor, 'id'), HTML::chars(Arr::get($mayor, 'firstname')) . ' ' . HTML::chars(Arr::get($mayor, 'lastname'))), ':city' => HTML::chars($mayor['homecity']))), '<br />';
         }
         // Checkins
         echo __('Check-ins: :checkins', array(':checkins' => '<var>' . Arr::path($foursquare, 'stats.checkins') . '</var>')), '<br />';
         // Here now
         echo __('Here now: :herenow', array(':herenow' => '<var>' . Arr::path($foursquare, 'stats.herenow') . '</var>')), '<br />';
         // Tips
         if ($tips = Arr::path($foursquare, 'tips')) {
             echo '<h5>', __('Tips (:tips)', array(':tips' => '<var>' . count($tips) . '</var>')), '</h5><dl>';
             foreach (array_slice($tips, 0, 5) as $tip) {
                 echo '<dt>', HTML::anchor('http://foursquare.com/user/' . Arr::path($tip, 'user.id'), HTML::chars(Arr::path($tip, 'user.firstname')) . ' ' . HTML::chars(Arr::path($tip, 'user.lastname'))), ', ', HTML::chars(Arr::path($tip, 'user.homecity')), ':</dt>';
                 echo '<dd>', Text::auto_p(HTML::chars(Arr::path($tip, 'text'))), '</dd>';
             }
             echo '</dl>';
         }
     }
     // Admin controls
     if (Permission::has($this->venue, Model_Venue::PERMISSION_UPDATE)) {
         echo HTML::anchor('#map', __('Link to Foursquare'), array('class' => 'action', 'id' => 'link-foursquare'));
         echo $this->form();
     }
     return ob_get_clean();
 }
开发者ID:anqh,项目名称:anqh,代码行数:39,代码来源:foursquare.php

示例3: action_edit

 /**
  * Action: edit
  */
 public function action_edit()
 {
     $this->history = false;
     // Load role
     $role_id = (int) $this->request->param('id', 0);
     if ($role_id) {
         $role = Model_Role::factory($role_id);
         if (!$role->loaded()) {
             throw new Model_Exception($role, $role_id);
         }
         Permission::required($role, Model_Role::PERMISSION_UPDATE, self::$user);
     } else {
         $role = Model_Role::factory();
         Permission::required($role, Model_Role::PERMISSION_CREATE, self::$user);
     }
     // Handle post
     $errors = array();
     if ($_POST) {
         $role->name = Arr::get($_POST, 'name');
         $role->description = Arr::get($_POST, 'description');
         try {
             $role->save();
             $this->request->redirect(Route::url('roles'));
         } catch (Validation_Exception $e) {
             $errors = $e->array->errors('validate');
         }
     }
     // Set title
     $this->view = View_Page::factory(__('Role') . ($role->name ? ': ' . $role->name : ''));
     // Set actions
     if ($role->loaded() && Permission::has($role, Model_Role::PERMISSION_DELETE, self::$user)) {
         $this->page_actions[] = array('link' => Route::model($role, 'delete') . '?token=' . Security::csrf(), 'text' => '<i class="icon-trash icon-white"></i> ' . __('Delete role'), 'class' => 'btn btn-danger role-delete');
     }
     $this->view->add(View_Page::COLUMN_MAIN, $this->section_role($role, $errors));
 }
开发者ID:anqh,项目名称:core,代码行数:38,代码来源:roles.php

示例4: __construct

 /**
  * Create new shouts view.
  */
 public function __construct()
 {
     parent::__construct();
     $this->id = 'shouts';
     $this->title = __('Shouts');
     $this->_can_shout = Permission::has(new Model_Shout(), Model_Shout::PERMISSION_CREATE, self::$_user);
 }
开发者ID:anqh,项目名称:core,代码行数:10,代码来源:shouts.php

示例5: before

 /**
  * Construct controller
  */
 public function before()
 {
     parent::before();
     $this->page_title = __('Forum');
     // Generic page actions
     $this->page_actions['new-posts'] = array('link' => Route::url('forum'), 'text' => '<i class="icon-comment icon-white"></i> ' . __('New posts'));
     // Forum areas dropdown
     $groups = Model_Forum_Group::factory()->find_all();
     $areas = array();
     foreach ($groups as $group) {
         $divider = false;
         foreach ($group->areas() as $area) {
             if (Permission::has($area, Model_Forum_Area::PERMISSION_READ, self::$user)) {
                 $divider = true;
                 $areas[] = array('link' => Route::model($area), 'text' => HTML::entities($area->name));
             }
         }
         if ($divider) {
             $areas[] = array('divider' => true);
         }
     }
     array_pop($areas);
     $this->page_actions['areas'] = array('link' => Route::url('forum_group'), 'text' => '<i class="icon-folder-open icon-white"></i> ' . __('Areas'));
     $this->page_actions['area'] = array('link' => Route::url('forum_group'), 'text' => '', 'dropdown' => $areas);
     if (self::$user) {
         $this->page_actions['private-messages'] = array('link' => Forum::private_messages_url(), 'text' => '<i class="icon-envelope icon-white"></i> ' . __('Private messages'));
     }
 }
开发者ID:anqh,项目名称:forum,代码行数:31,代码来源:forum.php

示例6: add

 /**
  * Add a Notification.
  *
  * @static
  * @param   Model_User  $user
  * @param   Model_User  $target
  * @param   string      $class  e.g. 'user'
  * @param   string      $type   e.g. 'login'
  * @param   integer     $data_id
  * @param   string      $text   extra data
  * @return  boolean
  */
 protected static function add(Model_User $user, Model_User $target, $class, $type, $data_id = null, $text = null)
 {
     $notification = new Model_Notification();
     $notification->set_fields(array('user_id' => $user->id, 'target_id' => $target->id, 'class' => $class, 'type' => $type, 'data_id' => $data_id, 'text' => $text, 'stamp' => time()));
     if (!Permission::has($notification, Model_Notification::PERMISSION_CREATE, $user)) {
         return false;
     }
     $notification->save();
     return $notification->loaded();
 }
开发者ID:anqh,项目名称:anqh,代码行数:22,代码来源:notification.php

示例7: action_index

 /**
  * Controller default action
  */
 public function action_index()
 {
     $this->page_title = __('Welcome to :site', array(':site' => Kohana::config('site.site_name')));
     // Display news feed
     $newsfeed = new NewsFeed(self::$user);
     $newsfeed->max_items = 25;
     Widget::add('main', View_Module::factory('generic/newsfeed', array('newsfeed' => $newsfeed->as_array())));
     // Shout
     $shouts = Jelly::select('shout')->limit(10)->execute();
     Widget::add('side', View_Module::factory('generic/shout', array('mod_title' => __('Shouts'), 'shouts' => $shouts, 'can_shout' => Permission::has(new Model_Shout(), Model_Shout::PERMISSION_CREATE), 'errors' => array(), 'values' => array())));
 }
开发者ID:netbiel,项目名称:core,代码行数:14,代码来源:index.php

示例8: get_24hour_graph

 public static function get_24hour_graph()
 {
     /* Permission check. */
     if (Permission::has('operator_parking_usage')) {
         /* Select query. */
         $select = Database::query("SELECT rc.type_card, UNIX_TIMESTAMP(p.start_date) AS start_date, UNIX_TIMESTAMP(p.end_date) AS end_date FROM parking AS p INNER JOIN rfid_card AS rc ON rc.id = p.rfid_id WHERE start_date > (NOW() - INTERVAL 24 HOUR)");
         /* Controleren of query is gelukt. */
         if ($select) {
             /* Maak return array aan. */
             $return = array('totaal' => array(), 'ad-hoc' => array(), 'subscription' => array(), 'guest' => array());
             /* Maak database array aan. */
             $db_array = array();
             /* Doorloop alle items. */
             while ($obj = $select->fetch_object()) {
                 /* Zet object in array. */
                 $db_array[] = array('type' => $obj->type_card, 'start' => $obj->start_date, 'end' => $obj->end_date == null || $obj->end_date == '' ? time() : $obj->end_date);
             }
             /* Tel db_array. */
             $db_array_count = count($db_array);
             /* Loop 12 keer. */
             for ($i = 24; $i > -1; $i--) {
                 /* Bereken timestamp van $i * 2 uren terug. */
                 $from = strtotime('-' . $i . ' hours');
                 /* Stel de variabelen in, en zet ze op 0. */
                 $return['totaal'][$i] = 0;
                 $return['ad-hoc'][$i] = 0;
                 $return['subscription'][$i] = 0;
                 $return['guest'][$i] = 0;
                 /* Loop de hele db_array door. */
                 for ($j = 0; $j < $db_array_count; $j++) {
                     /* Var $item maken. */
                     $item = $db_array[$j];
                     /* Kijken of het huidige item tussen het start datum, en het eind datum van de meting valt. */
                     if ($item['start'] < $from && $item['end'] > $from) {
                         /* Dat valt dit item, dus tel + 1 bij het item op, en bij totaal. */
                         $return[strtolower($item['type'])][$i]++;
                         $return['totaal'][$i]++;
                     }
                 }
             }
             /* Return de return array. */
             return $return;
         } else {
             /* Foutmelding. */
             throw new Exception('Er ging wat fout bij het berekenen van het parkeer verbruik.');
         }
     } else {
         /* Geen rechten. */
         throw new Exception('U heeft geen rechten om het parkeer verbruik te mogen zien.');
     }
 }
开发者ID:roaldnefs,项目名称:parkingcity,代码行数:51,代码来源:class.parking.php

示例9: action_index

 /**
  * Action: index
  */
 public function action_index()
 {
     // Load groups
     $groups = Model_Forum_Group::factory()->find_all();
     // Build page
     $this->view = new View_Page(__('Forum'));
     $this->view->tab = 'areas';
     // Set actions
     if (Permission::has(new Model_Forum_Group(), Model_Forum_Group::PERMISSION_CREATE)) {
         $this->view->actions[] = array('link' => Route::url('forum_group_add'), 'text' => '<i class="icon-plus-sign icon-white"></i> ' . __('New group'));
     }
     $this->view->add(View_Page::COLUMN_CENTER, $this->section_groups($groups));
     $this->_side_views();
 }
开发者ID:anqh,项目名称:anqh,代码行数:17,代码来源:group.php

示例10: __construct

 /**
  * Create new view.
  *
  * @param  Model_Blog_Entry  $blog_entry
  * @param  boolean           $show_title
  */
 public function __construct(Model_Blog_Entry $blog_entry, $show_title = false)
 {
     parent::__construct();
     $this->blog_entry = $blog_entry;
     if ($show_title) {
         $author = $blog_entry->author();
         //			$this->avatar   = HTML::avatar($author['avatar'], $author['username']);
         $this->title = HTML::anchor(Route::model($blog_entry), HTML::chars($blog_entry->name));
         $this->subtitle = __('By :user, :date', array(':user' => HTML::user($author), ':date' => date('l ', $blog_entry->created) . Date::format(Date::DMY_SHORT, $blog_entry->created)));
         if (Permission::has($blog_entry, Model_Blog_Entry::PERMISSION_COMMENTS)) {
             $this->subtitle .= ' | ' . HTML::anchor(Route::model($blog_entry), __('Comments') . ' (' . (int) $blog_entry->comment_count . ')');
         }
     }
 }
开发者ID:anqh,项目名称:anqh,代码行数:20,代码来源:entry.php

示例11: has_permission

 /**
  * Check permission
  *
  * @param   string      $permission
  * @param   Model_User  $user
  * @return  boolean
  */
 public function has_permission($permission, $user)
 {
     switch ($permission) {
         case self::PERMISSION_READ:
             return Permission::has($this->topic(), Model_Forum_Topic::PERMISSION_READ, $user) && (!$user || !$user->is_ignored($this->author_id));
             // No permission if the author is ignored
             break;
             // Allow modifying and deleting also from locked topics, fyi
         // Allow modifying and deleting also from locked topics, fyi
         case self::PERMISSION_UPDATE:
         case self::PERMISSION_DELETE:
             return $user && ($user->id == $this->author_id || $user->has_role('admin'));
     }
     return false;
 }
开发者ID:anqh,项目名称:forum,代码行数:22,代码来源:post.php

示例12: action_index

 /**
  * Action: latest posts
  */
 public function action_index()
 {
     $this->view = new View_Page(__('New posts'));
     $this->view->tab = 'areas';
     // Actions
     if (Permission::has(new Model_Forum_Group(), Model_Forum_Group::PERMISSION_CREATE)) {
         $this->view->actions[] = array('link' => Route::url('forum_group_add'), 'text' => '<i class="icon-plus-sign"></i> ' . __('New group'));
     }
     // New posts
     $this->view->add(View_Page::COLUMN_CENTER, $this->section_topics(Model_Forum_Topic::factory()->find_active(20)));
     // Areas
     $groups = Model_Forum_Group::factory()->find_all();
     $this->view->add(View_Page::COLUMN_RIGHT, $this->section_groups($groups));
     //		$this->_side_views();
 }
开发者ID:anqh,项目名称:anqh,代码行数:18,代码来源:forum.php

示例13: set_new_two_way

 public function set_new_two_way($accountId, $secret)
 {
     /* Controleren of de gebruiker rechten heeft. */
     if (Permission::has('panel_account_two_way')) {
         /* Update query uitvoeren om de secret in te stellen. */
         $update = Database::query("UPDATE customer SET secret = '" . Database::escape($secret) . "' WHERE id = " . Database::escape($accountId));
         /* Kijken of de query is gelukt. */
         if ($update) {
             /* Secret instellen zodat de two-way geactiveerd is in de huidige sessie. */
             $_SESSION['login']['secret'] = true;
         } else {
             /* Query ging fout, geef foutmelding terug. */
             throw new Exception(Database::error());
         }
     }
 }
开发者ID:roaldnefs,项目名称:parkingcity,代码行数:16,代码来源:class.two_way.php

示例14: content

    /**
     * Render view.
     *
     * @return  string
     */
    public function content()
    {
        ob_start();
        if ($this->gallery->links) {
            $links = explode("\n", $this->gallery->links);
            $count = 0;
            ?>

<ul class="list-unstyled">

	<?php 
            foreach ($links as $link) {
                list($user_id, $url) = explode(',', $link, 2);
                ?>
	<li>
		<?php 
                echo HTML::anchor($url, Text::limit_url($url, 75));
                ?>
 &copy; <?php 
                echo HTML::user($user_id);
                ?>
		<?php 
                if (Visitor::$user && $user_id == Visitor::$user->id || Permission::has($this->gallery, Model_Gallery::PERMISSION_UPDATE)) {
                    ?>
		<?php 
                    echo HTML::anchor(Route::model($this->gallery) . '?delete_link=' . $count . '&' . Security::csrf_query(), __('Remove'), array('class' => 'btn btn-danger btn-xs link-delete'));
                    ?>
		<?php 
                }
                ?>
	</li>
	<?php 
                $count++;
            }
            ?>

</ul>

<?php 
        }
        // Add new link
        if (Permission::has($this->gallery, Model_Gallery::PERMISSION_CREATE)) {
            echo HTML::anchor('#add-link', '<i class="fa fa-plus-circle"></i> ' . __('Add link'), array('data-toggle' => 'collapse', 'data-target' => '#form-link'));
            echo $this->form();
        }
        return ob_get_clean();
    }
开发者ID:anqh,项目名称:anqh,代码行数:52,代码来源:links.php

示例15: favorites

 /**
  * Render favorites.
  *
  * @return  string
  */
 public function favorites()
 {
     // Clickable favorites
     if (Permission::has($this->event, Model_Event::PERMISSION_FAVORITE, self::$_user)) {
         if ($this->event->is_favorite(self::$_user)) {
             // Favorite event, click to unfavorite
             return HTML::anchor(Route::model($this->event, 'unfavorite') . '?token=' . Security::csrf(), '<i class="icon-heart icon-white"></i> ' . $this->event->favorite_count, array('title' => __('Remove favorite'), 'class' => 'ajaxify btn btn-small btn-lovely active'));
         } else {
             // Non-favorite event, click to favorite
             if ($this->event->favorite_count) {
                 return HTML::anchor(Route::model($this->event, 'favorite') . '?token=' . Security::csrf(), '<i class="icon-heart icon-white"></i> ' . $this->event->favorite_count, array('title' => __('Add to favorites'), 'class' => 'ajaxify btn btn-small btn-inverse active'));
             } else {
                 return HTML::anchor(Route::model($this->event, 'favorite') . '?token=' . Security::csrf(), '<i class="icon-heart"></i>', array('title' => __('Add to favorites'), 'class' => 'ajaxify btn btn-small btn-inverse active'));
             }
         }
     }
     return $this->event->favorite_count ? '<span class="btn btn-small btn-inverse disabled"><i class="icon-heart icon-white"></i> ' . $this->event->favorite_count . '</a>' : '';
 }
开发者ID:anqh,项目名称:events,代码行数:23,代码来源:day.php


注:本文中的Permission::has方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。