why does my side menu bar permission does not follow the permission i set in serialized in the database i was trying to develop an restaurant pos and inventory system and i'm using a PHP with a codeigniter framework.
serialized permission in database: here with "viewFile" permission
a:33:{i:0;s:8:"viewFile";i:0;s:10:"createUser";i:1;s:10:"updateUser";i:2;s:8:"viewUser";i:3;s:10:"deleteUser";i:4;s:11:"createGroup";i:5;s:11:"updateGroup";i:6;s:9:"viewGroup";i:7;s:11:"deleteGroup";i:8;s:11:"createStore";i:9;s:11:"updateStore";i:10;s:9:"viewStore";i:11;s:11:"deleteStore";i:12;s:11:"createTable";i:13;s:11:"updateTable";i:14;s:9:"viewTable";i:15;s:11:"deleteTable";i:16;s:14:"createCategory";i:17;s:14:"updateCategory";i:18;s:12:"viewCategory";i:19;s:14:"deleteCategory";i:20;s:13:"createProduct";i:21;s:13:"updateProduct";i:22;s:11:"viewProduct";i:23;s:13:"deleteProduct";i:24;s:11:"createOrder";i:25;s:11:"updateOrder";i:26;s:9:"viewOrder";i:27;s:11:"deleteOrder";i:28;s:10:"viewReport";i:29;s:13:"updateCompany";i:30;s:11:"viewProfile";i:31;s:13:"updateSetting";}
serialized permission in database: here without the "viewfile"
a:32:{i:0;s:10:"createUser";i:1;s:10:"updateUser";i:2;s:8:"viewUser";i:3;s:10:"deleteUser";i:4;s:11:"createGroup";i:5;s:11:"updateGroup";i:6;s:9:"viewGroup";i:7;s:11:"deleteGroup";i:8;s:11:"createStore";i:9;s:11:"updateStore";i:10;s:9:"viewStore";i:11;s:11:"deleteStore";i:12;s:11:"createTable";i:13;s:11:"updateTable";i:14;s:9:"viewTable";i:15;s:11:"deleteTable";i:16;s:14:"createCategory";i:17;s:14:"updateCategory";i:18;s:12:"viewCategory";i:19;s:14:"deleteCategory";i:20;s:13:"createProduct";i:21;s:13:"updateProduct";i:22;s:11:"viewProduct";i:23;s:13:"deleteProduct";i:24;s:11:"createOrder";i:25;s:11:"updateOrder";i:26;s:9:"viewOrder";i:27;s:11:"deleteOrder";i:28;s:10:"viewReport";i:29;s:13:"updateCompany";i:30;s:11:"viewProfile";i:31;s:13:"updateSetting";}
code:
<?php if(in_array('viewReport', $user_permission)): ?>
<li class="treeview" id="FileMainNav">
<a href="#">
<i class="fa fa-file"></i>
<span>File Maintanance</span>
<span class="pull-right-container">
<i class="fa fa-angle-left pull-right"></i>
</span>
</a>
<?php endif; ?>
so my problem is if the user permission is equal to "viewReport" as i tried as a test it shows the sidebar menu.
but when i make it into "viewFile" it does not show the side bar menu
but i already set the value of viewFile here is some portion of the code:
<td>File Maintainance</td>
<td> - </td>
<td> - </td>
<td><input type="checkbox" name="permission[]" id="permission" value="viewFile"></td>
<td> - </td>
and here is the code in my controller:
public function __construct()
{
parent::__construct();
$group_data = array();
if(empty($this->session->userdata('logged_in'))) {
$session_data = array('logged_in' => FALSE);
$this->session->set_userdata($session_data);
}
else {
$user_id = $this->session->userdata('id');
$this->load->model('model_groups');
$group_data = $this->model_groups->getUserGroupByUserId($user_id);
$this->data['user_permission'] = unserialize($group_data['permission']);
$this->permission = unserialize($group_data['permission']);
}
}
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
CodeIgniter is a framework that is known for requiring a minimum amount of customization to get it up and running. This allows those who choose it to work at a good pace. It has been updated many times since its inception in 2006. Now the most recent version is 4.0.3.
https://www.codeigniter.com/
HTML (English "hyper text markup language" - hypertext markup language) is a special markup language that is used to create sites on the Internet.
Browsers understand html perfectly and can interpret it in an understandable way. In general, any page on the site is html-code, which the browser translates into a user-friendly form. By the way, the code of any page is available to everyone.
https://www.w3.org/html/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.