當前位置: 首頁>>代碼示例>>PHP>>正文


PHP permissions::check_perms方法代碼示例

本文整理匯總了PHP中permissions::check_perms方法的典型用法代碼示例。如果您正苦於以下問題:PHP permissions::check_perms方法的具體用法?PHP permissions::check_perms怎麽用?PHP permissions::check_perms使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在permissions的用法示例。


在下文中一共展示了permissions::check_perms方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: route

 /**
  * Route all of the menus.
  */
 function route()
 {
     global $theme;
     // Get the current active path.
     $current_path = get_current_path();
     $permissions = new permissions();
     $check_permissions = $permissions->check_perms();
     // Setup some theme arguments.
     $error = false;
     $theme_args = array();
     if ($check_permissions) {
         // Now use it to route visitors :).
         if (isset($current_path) && $current_path != 'index') {
             // We need to parse all of the url files.
             $urls = $this->parse_urls();
             // Deal with wild cards in the URLs and return the active URL.
             $active_url = build_urls($urls);
             $current_path = $active_url['system'];
             // Now we parse the correct URL.
             // TODO: add some permission checks at some point.
             if (isset($urls[$current_path])) {
                 // Now we need to get the callback.
                 $callback = $urls[$current_path]['callback'];
                 $callback_array = explode('.', $callback);
                 // Check to see if we are calling a custom file.
                 if (isset($urls[$current_path]['file'])) {
                     include_once serum_get_path('module', $urls[$current_path]['module']) . '/' . $urls[$current_path]['file'];
                 }
                 // Now we call the module class and invoke the menu item.
                 ${$callback_array[0]} = new $callback_array[0]();
                 // Set the initial page title and description.
                 tpl_set('page_title', $urls[$current_path]['title']);
                 tpl_set('page_description', $urls[$current_path]['description']);
                 // Make sure that method does exist.
                 if (method_exists(${$callback_array[0]}, $callback_array[1])) {
                     ${$callback_array[0]}->{$callback_array[1]}();
                 } else {
                     // Otherwise just return a 404.
                     four_oh_four();
                     $error = true;
                     $tpl = 'erorr.tpl';
                 }
             } else {
                 // Return a 404 error.
                 $user->login();
                 $error = true;
                 $tpl = 'error.tpl';
             }
         } else {
             // If there is nothing in the menu we need to render the index page.
             $this->index();
         }
     } else {
         // Return the login form. Silly me.
         $permissions->login_form();
         $error = true;
         $tpl = 'login.tpl';
     }
     if (!$error) {
         $theme_args = array('header' => true, 'footer' => true);
     } else {
         $theme_args = array('template' => $tpl);
     }
     // Render the theme.
     $theme->engine->render($theme_args);
 }
開發者ID:noelharrisonza,項目名稱:serumcore,代碼行數:69,代碼來源:menu.class.php


注:本文中的permissions::check_perms方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。