Skip to content

Instantly share code, notes, and snippets.

@Baael
Created June 4, 2009 10:44
Show Gist options
  • Save Baael/123563 to your computer and use it in GitHub Desktop.
Save Baael/123563 to your computer and use it in GitHub Desktop.
def can_edit? site
value=permissions.find(:first,
:conditions => ["`permissions`.content_id = ? and `permissions`.content_type = ?",site.id, site.class.to_s ],
:order => 'FIND_IN_SET(`owner_type`, "user,section"), `permissions`.rank DESC'
) || ((section)? section.permissions.find(:first,
:conditions => ["`permissions`.content_id = ? and `permissions`.content_type = ?",site.id, site.class.to_s ],
:order => 'FIND_IN_SET(`owner_type`, "user,section"), `permissions`.rank DESC'
) : nil )
if !value.nil?
(value.rank > 2)
else
false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment