Welcome Guest, Not a member yet? Register   Sign In
Application not finding a permissions object for one page, but is for another.
#11

[eluser]Rurik[/eluser]
Code:
//If the string contains q then search quote is added to the home menu
   $page_title = 'Pending quotes';
   $img = 'application/images/searchQuote.png';
   if($checked = strstr($privilege, 'q'))
   {
    $this->add_home_menu($page_title, 'quote', $img);
    $this->add_valid_page('quote');
   }
   $this->add_check_values('q', $checked, $page_title, $img);
  
   //If the string contains I then add invoice is added to the home menu
   $page_title = 'Add invoice';
   $img = 'application/images/addInvoice.png';
   if($checked = strstr($privilege, 'I'))
   {
    $this->add_home_menu($page_title, 'invoice/create', $img);
    $this->add_valid_page('invoice');
   }
   $this->add_check_values('I', $checked, $page_title, $img);
  
   //If the string contains i then search invoice is added to the home menu
   $page_title = 'Search invoice';
   $img = 'application/images/searchInvoice.png';
   if($checked = strstr($privilege, 'i'))
   {
    $this->add_home_menu($page_title, 'invoice', $img);
    $this->add_valid_page('invoice');
    $this->add_valid_page('invoice/view');
   }
   $this->add_check_values('i', $checked, $page_title, $img);
  
   //Adds logout/change_password button
   $this->add_menu('Change Password', 'main/change_password');
   $this->add_menu('Logout', 'main/logout');

   //Adds upload page button.
   $page_title = 'Upload File';
   $img = 'application/images/upload.png';
   $this->add_home_menu($page_title, 'upload/index', $img);
   $this->add_valid_page('upload/index');

   //Adds download page button.
   $page_title = 'Download Files';
   $img = 'application/images/upload.png';
   $this->add_home_menu($page_title, 'upload/search', $img);
   $this->add_valid_page('upload/search');
   $this->add_valid_page('upload/delete');
   $this->add_valid_page('upload/view');
  
   //Adds report page button.
   $page_title = 'Create Report';
   $img = 'application/images/upload.png';
   $this->add_home_menu($page_title, 'report/index', $img);
   $this->add_valid_page('report/index');
   $this->add_valid_page('report/createPier');
   $this->add_valid_page('report/createBlock');
   $this->add_valid_page('report/chooseType');
  
   $page_title = 'Download Reports';
   $img = 'application/images/upload.png';
   $this->add_home_menu($page_title, 'report/search', $img);
   $this->add_valid_page('report/search');
   $this->add_valid_page('report/delete');
}

/**
  * Adds a menu item to the user's menu
  * @param $name string Heading of the menu item
  * @param $url string Link of the menu item
  */
private function add_menu($name, $url)
{
  $position = count($this->menu);
  $this->menu[$position][] = $name;
  $this->menu[$position][] = $url;
}

/**
  * Adds a home menu item to the user's home menu
  * @param $name string Heading of the home menu item
  * @param $url string Link of the home menu item
  * @param $image string Link of the image for the home menu items
  */
private function add_home_menu($name, $url, $image)
{
  $position = count($this->home);
  $this->home[$position][] = $name;
  $this->home[$position][] = $url;
  $this->home[$position][] = $image;
}

/**
  * Adds a valid page for a user
  * @param $url string Link of the valid page
  */
private function add_valid_page($url)
{
  $this->valid_pages[] = $url;
}

/**
  * @param $char string The character of the item
  * @param $checked boolean If the item is checked
  * @param $name string The name of the item
  * @param $image string Link of the image for the check value
  */
private function add_check_values($char, $checked, $name, $image)
{
  $position = count($this->check_values);
  $this->check_values[$position][] = $char;
  $this->check_values[$position][] = $checked;
  $this->check_values[$position][] = $name;
  $this->check_values[$position][] = $image;
  
}
}
?>
#12

[eluser]LuckyFella73[/eluser]
Do you autoload the permission lib or in your controller via $this->load->library('permissions'); ?
#13

[eluser]Rurik[/eluser]
well there is nothing in the autoload file for permissions, but I know I dont load permissions in my reports system, which does work. I also dont load it in the upload system, which doesnt work. It doesnt seem to load it in the login controller, which is called by the index.php, or the main controller, which calls the main menu.

I honestly don't know where it calls that load... which raises a question, where does it do it?
#14

[eluser]Rurik[/eluser]
I think I found the problem, let me check something.
#15

[eluser]Rurik[/eluser]
Ok that was it, damnit what a stupid mistake. I was extending the CI_controller rather then MY_Controller. Thats what I get for copy pasting... Oh well, thanks for the help all, just happy that works now.




Theme © iAndrew 2016 - Forum software by © MyBB