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


PHP MY_Controller::array_search_by_value方法代碼示例

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


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

示例1: refresh

 function refresh()
 {
     set_time_limit(0);
     $this->load->helper('file');
     //        @write_file(FCPATH . 'down', '');
     //        @unlink(FCPATH . 'up');
     $new_urls_array = array();
     foreach (glob(APPPATH . 'controllers/*') as $controller) {
         if (is_dir($controller)) {
             $dir_name = basename($controller, EXT);
             foreach (glob(APPPATH . 'controllers/' . $dir_name . '/*') as $sub_dir_controller) {
                 $sub_dir_controller_name = basename($sub_dir_controller, EXT);
                 if (!class_exists($sub_dir_controller_name)) {
                     $this->load->file($sub_dir_controller);
                 }
                 $sub_dir_controller_name_class = new ReflectionClass($sub_dir_controller_name);
                 foreach ($sub_dir_controller_name_class->getMethods() as $sub_dir_controller_name_methods) {
                     if ($sub_dir_controller_name_methods->class === $sub_dir_controller_name_class->name && $sub_dir_controller_name !== $sub_dir_controller_name_methods->name && substr($sub_dir_controller_name_methods->name, 0, 1) !== '_') {
                         array_push($new_urls_array, array('url_directory' => $dir_name, 'url_class' => $sub_dir_controller_name, 'url_method' => $sub_dir_controller_name_methods->name));
                     }
                 }
             }
         } else {
             if (pathinfo($controller, PATHINFO_EXTENSION) === "php") {
                 $controller_name = basename($controller, EXT);
                 if (!class_exists($controller_name)) {
                     $this->load->file($controller);
                 }
                 $controller_name_class = new ReflectionClass($controller_name);
                 foreach ($controller_name_class->getMethods() as $controller_name_methods) {
                     if ($controller_name_methods->class === $controller_name_class->name && $controller_name !== $controller_name_methods->name && substr($controller_name_methods->name, 0, 1) !== '_') {
                         array_push($new_urls_array, array('url_directory' => NULL, 'url_class' => $controller_name, 'url_method' => $controller_name_methods->name));
                     }
                 }
             }
         }
     }
     $old_group_urls_array = $this->Acl_model->get_group_urls();
     $old_user_urls_array = $this->Acl_model->get_user_urls();
     $old_urls_array = $this->Acl_model->get_urls();
     foreach ($new_urls_array as $key => $new_url) {
         $index = parent::array_search_by_value($old_urls_array, array('url_directory' => $new_url['url_directory'], 'url_class' => $new_url['url_class'], 'url_method' => $new_url['url_method']));
         if (count($index) === 1) {
             $new_urls_array[$key]['url_sets_id'] = $old_urls_array[$index[0]]['url_sets_id'];
         } else {
             $new_urls_array[$key]['url_sets_id'] = '0';
         }
     }
     $this->Acl_model->update_urls($new_urls_array);
     $urls_array = $this->Acl_model->get_urls();
     $groups_array = $this->Acl_model->get_groups();
     $new_group_urls_array = array();
     $new_user_urls_array = array();
     foreach ($groups_array as $group) {
         foreach ($urls_array as $url) {
             $group_url_permission = '0';
             foreach ($old_group_urls_array as $old_group_urls) {
                 if ($old_group_urls['groups_id'] === $group['group_id'] && $old_group_urls['url_directory'] === $url['url_directory'] && $old_group_urls['url_class'] === $url['url_class'] && $old_group_urls['url_method'] === $url['url_method']) {
                     $group_url_permission = $old_group_urls['group_url_permission'];
                 }
             }
             array_push($new_group_urls_array, array('groups_id' => $group['group_id'], 'urls_id' => $url['url_id'], 'group_url_permission' => $group_url_permission));
         }
     }
     $old_users = array();
     foreach ($old_user_urls_array as $old_user_urls) {
         if (!in_array($old_user_urls['users_id'], $old_users)) {
             array_push($old_users, $old_user_urls['users_id']);
         }
     }
     foreach ($old_users as $user) {
         foreach ($urls_array as $url) {
             $user_url_permission = '0';
             foreach ($old_user_urls_array as $old_user_urls) {
                 if ($old_user_urls['users_id'] === $user && $old_user_urls['url_directory'] === $url['url_directory'] && $old_user_urls['url_class'] === $url['url_class'] && $old_user_urls['url_method'] === $url['url_method']) {
                     $user_url_permission = $old_user_urls['user_url_permission'];
                     array_push($new_user_urls_array, array('users_id' => $user, 'urls_id' => $url['url_id'], 'user_url_permission' => $user_url_permission));
                 }
             }
         }
     }
     if ($this->Acl_model->update_group_urls($new_group_urls_array) && $this->Acl_model->update_user_urls($new_user_urls_array)) {
         redirect('acl/url-sets');
     }
     //        @write_file(FCPATH . 'up', '');
     //        @unlink(FCPATH . 'down');
 }
開發者ID:Erginus,項目名稱:demo,代碼行數:87,代碼來源:acl.php


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