Welcome Guest, Not a member yet? Register   Sign In
MeNeedz Auth
#41

[eluser]louis w[/eluser]
Looks promising. But i would not want to place an if($this->auth->has_access('user') inside each one of my methods. You should try to move something like this into the constructor so it can be global to the controller.
#42

[eluser]charlie spider[/eluser]
i'm looking to redo my ACL for my current project and this is looking pretty good.

one simple question though, and maybe i just missed this somewhere, but do you have either a function or an SQL import statement i can use to build all of the necessary tables with the correct data types, lengths, etc ??? Or do i have to build everything from scratch and guess at what data types are best for each field ?? Not that this is hard to do, but i have a seemingly unending pile of projects in front of me and every time saver i can get is a beautiful thing.

thanks
#43

[eluser]davidbehler[/eluser]
Right now there is no sql script, but I have been thinkin about creating one to make it easier to use my library if you don't have your own tables yet.

I will post here again when I have updated the user guide.
#44

[eluser]charlie spider[/eluser]
i'm working on it now, will post some SQL when i'm done.


another question though...

in the user table, what data type is supposed to go in the user_group field ??

i'm assuming it's meant to be different from group_id ?
#45

[eluser]davidbehler[/eluser]
I have just created a small sql script that should get you going:

Code:
--
-- Table `group`
--

CREATE TABLE IF NOT EXISTS `group` (
  `group_id` varchar(20) NOT NULL,
  `group_level` tinyint(4) NOT NULL,
  PRIMARY KEY  (`group_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Table `member`
--

CREATE TABLE IF NOT EXISTS `member` (
  `member_id` smallint(6) NOT NULL auto_increment,
  `group` varchar(20) NOT NULL,
  `user_id` smallint(6) NOT NULL,
  PRIMARY KEY  (`member_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Table `right`
--

CREATE TABLE IF NOT EXISTS `right` (
  `right_id` smallint(6) NOT NULL auto_increment,
  `group` varchar(20) NOT NULL,
  `controller` varchar(50) NOT NULL,
  `function` varchar(50) NOT NULL,
  `access_right` varchar(10) NOT NULL,
  PRIMARY KEY  (`right_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Table `user`
--

CREATE TABLE IF NOT EXISTS `user` (
  `user_id` smallint(6) NOT NULL auto_increment,
  `user_name` varchar(30) NOT NULL,
  `user_password` varchar(40) NOT NULL,
  `user_salt` varchar(40) NOT NULL,
  `user_group` varchar(20) NOT NULL,
  `user_email` varchar(100) NOT NULL,
  PRIMARY KEY  (`user_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

@your last question:
Actually it depends on what you prefer to do Wink
First of all the field "user_group" in "user" table is only used if users can only be members of one group and not multiple. The datatype of the "user_group" field in the "user" group should always be the same as the one used as primary key in your "group" table. If you don't use database groups but have them in your config file, then the datatype must be choosen depending on the kind of index/group name you use in your config.

Does that help?
#46

[eluser]charlie spider[/eluser]
ummmm... so user_group is group_id, but it's not ?!?!

you're using varchar(20) for the data type for your group table primary key. how come ?
why not just use smallint(6) NOT NULL auto_increment like the other tables ?

i think i'm missing something here. (need more coffee)

in the tables i was building i had the group_id the same as all the other auto_increment primary keys. If it needs to be a string, i prolly would have missed that and wondered why things weren't working.

sorry for being a pain in the neck. just want to understand the inner workings of an evil mind Wink
#47

[eluser]charlie spider[/eluser]
oh, and nice to see you added the member_id field. i wuz gonna suggest that.
#48

[eluser]charlie spider[/eluser]
A PHP Error was encountered

Severity: Notice

Message: Undefined property: Welcome::$session

Filename: libraries/Auth.php

Line Number: 301
#49

[eluser]davidbehler[/eluser]
The problem for me is, that I don't know what kind of primary key the developer wants to use for this tables and that in the case of the group table it's even worth because he might not use the group table at all and have his groups in the config file with god knows what kind of key.

So I decided to make the group id a varchar(20) and keep it that way compatible to my example where the primary key of the groups are "user", "moderator" and "admin". If you know for sure that you won't use the groups in the config file, then you can choose smallint as datatype for the user_group field (even name it user_group_id) and change the primary key of the group table.
#50

[eluser]davidbehler[/eluser]
You propably haven't loaded the session library.
I will add that note to the user guide.




Theme © iAndrew 2016 - Forum software by © MyBB