failing to create ACL tables using console - cakephp

i have used the cake schema create DbAcl before, succesfully at that. for some reason the output that i am now getting is not that which i require. the shell is returning some help options but will not create the aros and acos tables. help

I had to copy the path to the console folder to my environmental variables and restarted the command line. that did the trick

Related

How to create files on grails with specific permissions

I'm creating an app using grails that generates multiple files as a process output, and put them on some folders that later will be access by ftp by other people.
Everything works great except that in production the new created files are created with access only for the user that runs tomcat, meaning that when somebody connects to the folder using ftp the files can't be open because they don't have permission.
is there any way to set permissions from grails or configure tomcat in a way that every output can be access by other users?.
This might help. You can also look into executing shell commands but that may not be the best option.
I found out that there is actually a method for the class File that changes the permissions for an instance of file, I was trying to use it but I notice only changed the permissions for the owner, but with a slight change on the parameters you can tell it to apply to other users too.
File.setReadable(boolean readable)
File.setReadable(boolean readable,boolean ownerOnly)
So in my case file.setReadable true,false made the trick.
Check out the class methods for more info java.io.File

CakePHP 2.x Acl

I am using CakePHP 2.3.6. In a project, I implemented Acl. I followed the official tutorial given, populated the acos table by cake's shell scripting,used AclExtras plugin, then populated the aros_acos table using "customized" initDb function.
Everything is ok now, the tables are populated successfully. So, I thought I don't need the allow()/deny() functions, which I used before for Authorization. So I deleted these functions from the beforeFilter() functions from the corresponding controllers. But, when I deleted them, I cant access any page(fucnction) in my whole project.
To populate the acos table I used this command :
./Console/cake AclExtras.AclExtras aco_sync
To populate the aros_acos table I customized the initDB() and put it in the Users controller and run it.
All tables are populated, everything is good, but its not working the allow()/deny() functions defined before I implemented ACL.
My question is, if I use Acl, if I have all AROs & ACOs stored in the database, and if I define all permissions in the database, then why do I need those allow()/deny() functions ? And if I need those, then why should I use Acl ? My project was fine without the Acl implementation, with the allow()/deny() functions.
So, what should I do ?
Can anyone help me please ?
Thanks.
Ok,
Finally I got the ACL working. I found that its so easy, I just had to know the shellscrpting. I always knew that its implemented well in CakePHP, I just have to make it working in my project.
First of all, we have to make PHP and CakePHP executable from our shell/command prompt. I did it in Windows(7), will try for Linux & MAC later.
First, if you dont have PHP executable from your command prompt, go to My Computer->Properties->Environment Variables(forgot exact path, but you will get it easily). Then paste this c:\wamp\bin\php\php5.3.13; in the Environment Variable, where php5.3.13 is version-specific.
After that, paste this in the same place : cakephp\lib\Cake\Console. You can copy the cakephp folder to your htdocs/www permanently, for later use.
Now, run this in your command prompt : cake bake all, and follow the instructions. You must have to have a database, configured in your config.php file.
By now, you should be ready with the newly created project. Now follow the CakePHP documentation for ACL.
Remember, which functions/methods you want to be open for all kind of users, allow them explicitly by allow(), in AppController, or in the specific controller.
Suppose, you want pages/index,users/login,users/signUp - these 3 pages/functions to be open for all. So, allow() them in the AppController or in Pages & Users controllers.

How to use Minion Task Migrations for Database Migrations

I am running Kohana 3.3 and wanting to add database migrations to my project.
I have added the following moulde https://github.com/kohana-minion/tasks-migrations but not sure how to get it working.
I can see the help file running ./minion migrations:new --help but I don't understand what group value is required. From the docs it says:
--group=group_name
This is a required config option, use it specify in which group the
migration should be stored. Migrations are stored in a `migrations`
directory followed by the group name specified. By default, the `migrations`
directory is created in `APPPATH` but that can be changed with `--location`
--location=modules/auth
Specified the path of the migration (without the `migrations` directory).
This value is defaulted to `APPPATH`
# The migration will be created in `modules/myapp/migrations/myapp/`
--group=myapp --location=modules/myapp
--description="Description of migration here"
This is an arbitrary description of the migration, used to build the
filename. It is required but can be changed manually later on without
affecting the integrity of the migration.
I've been searching for examples but yet to find one. I have an existing database, so I would like to grab the schema from that as my base and then run further migrations after. Is this how tasks-migrations module works?
The group method is used to tell you what kind of migrations it are. If it are migrations of your core application then the group core would be suitable.
But maybe you build yourself a module for your application that had it's own tables and thus its own migrations. thus it would be better to use the group module_name.
This way you can split your migrations in more suitable parts and are able to easily check only the migrations of your modules without having to search through all other migrations.
Make new migrations
./minion migrations:new --group=core
Run migrations
./minion migrations:run
PS: Dont forget to add the migrations table to the database
The group was the migration version number e.g.
./minion migrations:new --group=0-1
Created a folder and migration file in application/migrations/0.1 with the up and down methods.

how to setup environment of 'cake bake' for multiple applications?

I am stuck in setting up environment for running cake bake.
In my development machine (using WAMP), I have several applications:
/{wwwroot}
/myapp-1
/myapp-2
/myapp-3
According to some tutorial online, in order to use 'cake' in command prompt, I have to add 'cake/console/' directory as 'PATH' environment variable.
Therefore, I add '{wwwroot}/myapp-1/cake/console' as one of the 'PATH' variables.
But the problem is, when I am going to 'cake bake' some models/controllers for 'myapp-2' or 'myapp-3', the system said something about database table not found and a like.
After some tracing, I suspect that the 'cake bake' is using the 'config' of 'myapp-1' because I am using the 'cake/console' there.
So, what is the proper structure of the environment 'cake bake' multiple applications?
Many thanks!
I would go to your appropriate app folder and directly reference the cake script. It should then use the correct config.
../cake/console/cake bake
there is also a parameter -app that you could use to specify which app you would like to use.

Empty my Sqlite3 database in RoR

I am working on a Ruby on Rails 3 web application using sqlite3. I have been testing my application on-the-fly creating and destroying things in the Database, sometimes through the new and edit actions and sometimes through the Rails console.
I am interested in emptying my Database totally and having only the empty tables left. How can I achieve this? I am working with a team so I am interested in two answers:
1) How do I empty the Database only by me?
2) How can I (if possible empty) it by the others (some of which are not using sqlite3 but MySql)? (we are all working on an the same project through a SVN repository)
To reset your database, you can run:
rake db:schema:load
Which will recreate your database from your schema.rb file (maintained by your migrations). This will additionally protect you from migrations that may later fail due to code changes.
Your dev database should be distinct to your environment - if you need certain data, add it to your seed.rb file. Don't share a dev database, as you'll quickly get into situations where other changes make your version incompatible.
Download sqlitebrower here http://sqlitebrowser.org/
Install it, run it, click open database (top left) to locationOfYourRailsApp/db/development.sqlite3
Then switch to Browse data tab, there you can delete or add data.
I found that by deleting the deployment.sqlite3 file from the db folder and inserting the command rake db:migrate in the command line, it solves the problem for all of my team working on sqlite3.
As far as I know there is no USER GRANT management in sqlite so it is difficult to control access.
You only can protect the database by file access.
If you want to use an empty database for test purpose.
Generate it once and copy the file somewhere.
and use a copy of this file just before testing.

Resources