⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Image CRUD + Ion Auth = check users



Pakman
  • profile picture
  • Member

Posted 08 September 2013 - 21:43 PM

Hello, I'm doing test with image CRUD, how can I check if the active user (ion auth) is the owner of the album? If I use check_user the upload is wrong, but if I use check_user2 the upload is ok...any ideas? thanks!.

	function check_user($var)
	{
		if ( $var == 6 ) 
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	function check_user2($var)
	{
              return true;
	}

	public function num($album)
	{

		if ( $this->check_user($album) ) 
		{
			$image_crud = new image_CRUD();
			
			$image_crud->set_primary_key_field('id');
			
			$image_crud->set_url_field('url');
			
			$image_crud->set_table('galerias')
			->set_relation_field('folleto_id')
			->set_ordering_field('orden')
			->set_image_path('assets/uploads');
			
			$output = $image_crud->render();
		
			$this->_example_output($output);
		}
		else
		{

		}

	} 

davidoster
  • profile picture
  • Member

Posted 09 September 2013 - 04:28 AM

Hello [member=pakman].

Well the easiest way to say this is that you haven't thought about it a lot and the programming skills you have right now might not be enough for you to implement what you ask.

 

Many forum users ask about how to limit the access or the displaying data out of the grid or during some operation like edit.

But this is not something that Grocery CRUD and Image CRUD have being built to have internaly by default.

Especially for Image CRUD your options are quite limited, as opposed to Image CRUD that is.

 

All the above mean that you need to program most of the stuff in order to be able to have features like users' libraries.

 

First of all, the logic needs to start from the database.

- Does your database support the multiuser feature?

If you check the structure of the simplest table within the examples of Image CRUD library it uses an id and a url. If you need to support a multiuser image library you need to enhance your database to have at least a user_id.

 

Secondly, you need to figure out a way so when anybody uploads an image this image within the database is "marked" as it belongs to this user by e.g. storing the user's id to the user_id field.

- How can this be achieved by the current implementation of Image CRUD?

Well the answer is not that easy because Image CRUD isn't that sophisticated (like Grocery CRUD) so you could use a callback_insert to pass also to the database the user id as per image basis. So this is something that needs to be taken into account.

A skilfull programmer can impelment the above quite easily and quite fast but this is out of the scope of the purpose of this forum.

 

I hope someone has implemented it and will share his code with the community.

 

Good luck with your quests.


Pakman
  • profile picture
  • Member

Posted 09 September 2013 - 08:28 AM

Hello [member=pakman].

Well the easiest way to say this is that you haven't thought about it a lot and the programming skills you have right now might not be enough for you to implement what you ask.

 

Many forum users ask about how to limit the access or the displaying data out of the grid or during some operation like edit.

But this is not something that Grocery CRUD and Image CRUD have being built to have internaly by default.

Especially for Image CRUD your options are quite limited, as opposed to Image CRUD that is.

 

All the above mean that you need to program most of the stuff in order to be able to have features like users' libraries.

 

First of all, the logic needs to start from the database.

- Does your database support the multiuser feature?

If you check the structure of the simplest table within the examples of Image CRUD library it uses an id and a url. If you need to support a multiuser image library you need to enhance your database to have at least a user_id.

 

Secondly, you need to figure out a way so when anybody uploads an image this image within the database is "marked" as it belongs to this user by e.g. storing the user's id to the user_id field.

- How can this be achieved by the current implementation of Image CRUD?

Well the answer is not that easy because Image CRUD isn't that sophisticated (like Grocery CRUD) so you could use a callback_insert to pass also to the database the user id as per image basis. So this is something that needs to be taken into account.

A skilfull programmer can impelment the above quite easily and quite fast but this is out of the scope of the purpose of this forum.

 

I hope someone has implemented it and will share his code with the community.

 

Good luck with your quests.

 

Thank you very much davidoster! best regards.