andrzuk / FineCMS

PHP application using my own MVC architecture and PDO database interface.
http://my-notes.pl
15 stars 4 forks source link

Cheat Sheet to quickly create new post types #7

Closed danfolt closed 2 years ago

danfolt commented 7 years ago

not sure Andrzej if you will ever need it, but if you will ever need to quickly add a new post/page type (for example when you will get new job for Your client), (In my case I wanted to create new different styles, different post types - category structures (for example candidates will be portfolio type 3 rows/4columns)), here is a cheat sheet in excel I have created to quickly create a new 5 post types in Your application (15 files per post_type 3page, 3pages, 3category, 3categories, 3comments =75 all five new post types), with this cheat sheet following find and rename in all 15 candidate's files together it took 1 minute to create (with notepad++) 15 new files with agents, 15 new files with candidates as a model/view/controller/agent(s).php, candidate(s).php with their new agent comments, new agent categories etc, you will only have to rename it with your names, if you start to rename from first row to another it renames precisely, respectively I have also added new tables in DB, after this and some small edits in classes/page.php it worked, btw. similarly I will also prepare also strings for languages. inight.xlsx

andrzuk commented 7 years ago

Daniel, I wanted to create system as simple as possible. So I am using only basic templates and styles. But this system enables extending templates and styles. You can develop existing templates and styles, add additional templates - all according to your needs. I am glad that you are customizing templates system and developing functionality of app.

danfolt commented 7 years ago

Yes I know, everyday I appreciate this simple, perfectly organized (nicely repeating structured codes in every class) ultra fast system, I have already more functionalities with 0 conflicts than my ex. slow wordpress with 50 plugins (plugins with javascript incompactibility everyday issues for example (after updates). Only thing I am still trying to understand where were you inspired, which MVC framework is close to this (Laravel, Symphony, CI ? I know that Yours is custom, but some inspiration You should have before, every book I read is totally different than your script, every PHP author has very different approach, You never use "echo", also most developers from fiverr has very different approach, it seems really every piece of code is absolutely unique made from scratch created only in your head, no stackoverflow similar codes-traces (for example where were You inspired with ACL, I've been searching on Google for similar ACL function how to correctly add new role or group of persons to be also allowed to use methods in this code "if ($this->app->get_acl()->allowed('USER','NEWROLE'))" , I have found something similar with Phalcon, but at the end every structure, framework, design pattern till now I met is very different. PHP 100 styles, with your it is 101 :)

andrzuk commented 7 years ago

Some time ago I started to learn CodeIgniter framework. I liked it, but when I saw that framework uses Query Builder in Model, I realized that making complex DB queries in such way will be very difficult and maybe in some cases (user restrictions and so on) impossible. Then I decided to write my own framework, which will run exactly like I wish. My ACL system is as simple as I could imagine, because I didn't predict to expand it by dynamically adding new roles. If your website is managed by many admins who need individual access rights or if you need to have possibility of defining roles for new users, this app does not support it and you have to add appropriate mechanism.

danfolt commented 7 years ago

Practically I don't need it more complicated, I like it simple, that's why I copied all the sections independently (pages, categories, comments), so now I also have (agents, agent cats, agent_comments,) and (candidates, candidate categories, candidate_comments,) etc. all I want is that "agent" can only see his agent section(create its agent profile, comment and in admin panel edit his own agent comments, till now I think I can easily remain with your simple ACL system, because I will only change "if ($this->app->get_acl()->allowed(USER))" to "if ($this->app->get_acl()->allowed(AGENT))" when VIEW, EDIT, DELETE etc. , what I was searching for was how to do it and if this will work when in some sections (users.php and images.php can use everybody for example) or methods I will need more than one role to be allowed. Example: "if ($this->app->get_acl()->allowed('USER','AGENT', 'CANDIDATE'))". (In DB I have already added all new admin_functions and to users I have already added 1,0,0,1,0,1,1,0,0,0,0 etc.) Nothing dynamic, I like it hardcoded in config.php and in roles.php as it is, fixed.

andrzuk commented 7 years ago

It is good idea to allow access for several groups simultanously - by using array ('USER', 'AGENT', 'CANDIDATE') instead of one profile. In my solution I assumed that ADMIN has all rights of OPERATOR and USER, OPERATOR has all rights of USER (hierarchy structure). That's why I was using single profile. But when profiles become full-separate rather than hierarchical (not including others), then using array is better solution.

danfolt commented 7 years ago

Perfect, so I am happy that arrays will work. Yes, I have noticed that You use some kind of members inheritance (users, editors, moderators, admins) as a eg. forums use. CMS with various modules as yours if extended to host more than 2 groups where 1 Group has not more rights than the other one (only different) have to manage different sections (teachers, students | coaches,football players | real estate agents, sellers, buyers | doctors, patients or simply sellers x buyers, classifieds or jobboards as mine) would always need to use more separate permissions approach.