When scheduling it seems that a natural extension to the conflict requirement is availability on a resource. This patch aims to add availability support to the resource via the date repeat api. To use:
* Add a date field with repeat api enabled onto the resource node type (the type where the events are scheduled on to - the node type that is referenced). Then that should present an admin screen under resource conflict on the CCK config (same place as other admin tasks)
* Enable availability and choose which repeat field will represent the availability on that node.
* When scheduling an event if the resource is availability enabled - the validation will check for conflict and if the even fit within the dates specified on the resource.

Comments

nhck’s picture

Hej Chris,

I only came across this module a couple of days ago - now I am wondering if I understand this correctly: You would like to add the feature that a resources is only available during a certain time slot. For example a room where the building is locked during the night?

If it isn't that I don't understand what it is you are doing.

Thanks :-)

christianchristensen’s picture

Yes.

This patch aims to add availability to a resource: ex: a room that is only available 8am-5pm M-F and can only have one reservation in at a time. So the availability would be 8-5 repeating weekly M-F and then the resource conflict would be setup like normal.

Rob_Feature’s picture

+1 on this feature....seems like a useful addition!

deviantintegral’s picture

Status: Needs review » Needs work

This sounds like a very useful addition - thanks for the patch.

  • I added a date repeat field, but didn't enable it for availability, but availability errors were thrown as if it was added.
  • There is a break; that is commented out and should be removed if needed.
  • The help message for enabling availability should indicate what needs to be done to make it work, instead of just the message that it can't be turned on.
  • Why are we doing a dsm() instead of a form_set_error()? Shouldn't unavailable times be blocked entirely?
  • The error message for an unavailable time needs to be wrapped in t()
  • While we're at it, we should rename $tmp and $tmp2 to be something a little more useful.
  • There are some minor code style issues with comments and PHPDoc.
christianchristensen’s picture

StatusFileSize
new16.51 KB

Thanks for the comments - would love to see this incorporated!

I added a date repeat field, but didn't enable it for availability, but availability errors were thrown as if it was added.
- yes - I actually noticed this as a bug just the other day - should be updated in new patch

There is a break; that is commented out and should be removed if needed.
- the reason I removed the break is that "if" statement was just there to break the switch logic...whats the point?

The help message for enabling availability should indicate what needs to be done to make it work, instead of just the message that it can't be turned on.
- putting more text there

Why are we doing a dsm() instead of a form_set_error()? Shouldn't unavailable times be blocked entirely?
- Re: #791864 -- yes this should be a form_set_error - I think this was from a patch where I was trying to allow for warnings and errors. Eventually if the warning patch were accepted this would need to be updated to check that variable.

The error message for an unavailable time needs to be wrapped in t()
- done

While we're at it, we should rename $tmp and $tmp2 to be something a little more useful.
- I think $tmp was in the 2.x dev source previously - I added $tmp2 to do a similar temporary task, to pass in function args??

There are some minor code style issues with comments and PHPDoc.
- suggestions?

deviantintegral’s picture

Thanks for the update.

christianchristensen’s picture

StatusFileSize
new19.67 KB

Wow - some of these were kind-of egregious - one more time... :)

The 'validate' nodeapi case has been shifted back by two spaces - it should be indented twice from the switch.
- fixed and related to the next item

Actually, as an improvement from the original code - how about we negate the if statement, and remove the else entirely?
- nice call - should have done that myself

Let's do it as a form error for now, and then we can change it in #791864: Admin page (and variable setting) to set whether the form errors or warns on conflict later if needed.
- fair enough - it is a form error right now

$tmp was in the source, but could stand to be improved anyways. How about $resource_overlaps and $resource_availability?
- went ahead and passed the function in the call itself - makes the line a little longer, but really those were temp variables anyway...

For code style, take a look at http://drupal.org/project/coder, and http://drupal.org/coding-standards.
- cleaned up my poor spacing style -- now coder seems happy (caught a couple of other items just laying around - spacing only) :)

'#description' => t('sdkfjhlksfdjskfdjhasf') needs to be fixed.
- Ugh - that is disgusting - mea culpa - my bad!

patch attached - FTW!!

deviantintegral’s picture

StatusFileSize
new20.74 KB

Here is an updated patch that:

  • Removing lines consisting only of whitespace.
  • Clean up some comment standards.
  • Fixed some further indentation issues.

Haven't tested functionality yet, will get to that soon.

nikro’s picture

Hey guys,

This is my 1st patch so I will lovely accept all of your comments and advices :)

In my case, I had to apply a patch to the 6.x-2.x for date repeats (with timespans) and later develop an availability approach that would satisfy all the possible availability cases.

So this patch includes this one:
http://drupal.org/node/641850#comment-3145876 - http://drupal.org/files/issues/641850_node_repeat_19.patch

As it was based of an older version so I had to walk through 1000+ lines and mix them correctly together.

Anyway, I also changed the caching model to a hashed one (as we won't have only one timespan).

Regarding the availability, I give users opportunity to use a specific view that will have start and end rows in its results. I did ahah way of specifying what way should the availability be used and changed some error messages.
I also give the opportunity to alter the view with hook_resource_conflict_view_alter($view, $display_id, $node).

I've attached an image of how it should work (general concept) and the patch itself.

I'll eagerly wait for your replies.

nikro’s picture

Made some unix-clean-up with the right endings (previous was giving me some errors in linux system).

nikro’s picture

And again, I've made some small fixes.

nhck’s picture

Niko, it its generally not a good idea to mix multiple patches. So if its possible I'd suggest that you try and keep this focused on the task.

Also you backport some Drupal7-functionallity: Is this really really necessary?

nikro’s picture

How could I integrate caching and OG awareness to this patch? I mean that I had to modify those as well.
Backporting some of the Drupal7-functionalities was a part of other patch.

I've forgot to clean-up the variables on uninstall.

nhck’s picture

Why does caching need to be integrated for this patch?

Why does this patch need to make resource_conflict og_aware?

You realize - someone has to actually go through and check every line in this patch? It makes more sense if it just completes this one functionallity. :-/ Sorry to say this ~ especially since the maintainer doesn't seem active at the moment.

nikro’s picture

Doesn't that somehow slowdown considerably the development and new features integration?
Original caching patch would be useless if we apply the node repeats patch, and og awarness also loses it's meaning there.
It doesn't make resource_conflict og_aware out of the box, it gives this option to users, if they want to.

I don't know, who would apply node repeats + availability if it makes all other patches useless?
Or we have to wait until the maintainer would actually apply the node repeats + availability, and only then open 2-3 more issues in the issue tracker regarding making it og_aware and caching and stuff? Would that take ages?(

Nah, if I'm doing something wrong and there are better ways to do this all, I'll collaborate :)

Thanks.

nhck’s picture

Quality and security are also important factors.
Your patch has has over 1100 lines adressing multiple different issues adding undocumented (nor discussed) features. Who is supposed to review that?

The issue queues idea basically is to provide patches towards the modules code in order to have it improved - not an feature repository for the users.. The maintainer reviews the patch and gets it into the development-version. Thus if you have new features and/or new bugs you open additional issues. If your patch depends on other patches you mark your patch "postponed"

You can also read here http://drupal.org/patch/submit

So I'd suggest you open multiple issues or ask deviantintegral to become a maintainer :-)

ohthehugemanatee’s picture

Status: Needs work » Closed (won't fix)

This is addressed in the coming 6.x-3 and the current 7.x-3 branch - you can set availability with Rules.