本文整理汇总了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');
}