CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Extensions »
  • CiviVolunteer (Moderators: GinkgoFJG, Michael Z Daryabeygi) »
  • Filled shift still listed and allows new volunteers
Pages: [1]

Author Topic: Filled shift still listed and allows new volunteers  (Read 629 times)

SarahG (FountainTribe)

  • Ask me questions
  • ****
  • Posts: 782
  • Karma: 29
  • CiviCRM version: 4.4.7
  • CMS version: Drupal 6, Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Filled shift still listed and allows new volunteers
June 24, 2014, 05:20:25 am
When on the public volunteer sign up page ( ie http://mygroup.org/civicrm/volunteer/signup?reset=1&vid=5 ) there is a shift listed that already has the maximum number of volunteers signed up for that shift.  In trying to debug this,  I found the following section of code:

Code: [Select]
foreach ($this->_project->shifts as $id => $data) {
       
        $select->addOption($data['label'], $id, array('data-role' => $data['role_id']));
      }

(This is at line 150 in file /CRM/Volunteer/Form/VolunteerSignUp.php ) 

I inspected the variable $this->_project->shifts and it contains all shifts, including those which are already full. Where is this variable getting initialized?
Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

GinkgoFJG

  • Moderator
  • I post frequently
  • *****
  • Posts: 135
  • Karma: 4
    • Ginkgo Street Labs
Re: Filled shift still listed and allows new volunteers
June 24, 2014, 10:23:32 am
In the preprocess function, second line in, you'll see:

Code: [Select]
$this->_project = CRM_Volunteer_BAO_Project::retrieveByID($vid);
It should be noted that, for the initial releases of CiviVolunteer, we intentionally weren't checking to see if shifts were filled, so I wouldn't say you're dealing with a bug so much as a new feature. We didn't have a clear spec (or an abundance of funding), so we decided it was better not to refuse volunteer information (volunteers can be reassigned, after all), and to allow the volunteer coordinator to deal with the situation however she deemed best. Some folks may choose to use the additional volunteers as assigned, others may choose to reassign them, and others may want to hide the shift altogether (which they can do by unchecking the "public" box in the Define UI).

I would welcome input on what folks would like to see happen in future versions of CiviVolunteer. The status quo is the most flexible but also the least automated.
Are you a CiviVolunteer user? Join the CiviVolunteer 2.0 Matching Grant effort to help the project win $15,000 in grant funding.

SarahG (FountainTribe)

  • Ask me questions
  • ****
  • Posts: 782
  • Karma: 29
  • CiviCRM version: 4.4.7
  • CMS version: Drupal 6, Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Filled shift still listed and allows new volunteers
June 24, 2014, 04:14:38 pm
I would like to see this changed to only list the open shifts: the current behavior has the potential to create a tremendous amount of manual work for the volunteer organizer.   I think the existing config option "Allow users to sign up without specifying a shift." already gives enough flexibility to the person running the event to allow extra people to volunteer, even if all shifts are full.

What is the best way to fix the code to only show available shifts on the self-service page?  I am thinking an additional method such as "getAvailableShifts" on the class for the variable " $this->_project " would be needed. Then I can call the new method from VolunteerSignUp.php
Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

GinkgoFJG

  • Moderator
  • I post frequently
  • *****
  • Posts: 135
  • Karma: 4
    • Ginkgo Street Labs
Re: Filled shift still listed and allows new volunteers
June 26, 2014, 10:56:42 am
Hm, that's a good point about the existing config offering a lot of flexibility already.

So I just took a look at the code and I'm not crazy about some of the nomenclature/conventions we're using. CiviVolunteer introduces two new entities: projects and needs. "So what the heck is a shift?" you may be asking. Shifts are basically a view of needs that prioritizes the time component and excludes the "flexible" need. I'd kind of rather see methods for filtering the needs than introduce a pseudo-entity, but I digress...

I think a quick approach to hiding satisfied needs would be to modify CRM_Volunteer_BAO_Project->_get_needs() to output more information. It already provides the quantity (which is stored on the need object); we'd just need to do an extra lookup for each need to see how many slots are open.

If we preserve the shift pseudo-entity, then we need to modify CRM_Volunteer_BAO_Project->_get_shifts() to pass through the result of the above change. I'd recommend a new method CRM_Volunteer_BAO_Project->getAvailableShifts() which filters the shifts array, so that we don't have to do that all over the place. I assume that we'll want this list in other contexts.
Are you a CiviVolunteer user? Join the CiviVolunteer 2.0 Matching Grant effort to help the project win $15,000 in grant funding.

GinkgoFJG

  • Moderator
  • I post frequently
  • *****
  • Posts: 135
  • Karma: 4
    • Ginkgo Street Labs
Re: Filled shift still listed and allows new volunteers
June 26, 2014, 11:09:40 am
If we did that, however, we'd probably want to move _get_needs() from API calls to SQL. The performance would be much better.
Are you a CiviVolunteer user? Join the CiviVolunteer 2.0 Matching Grant effort to help the project win $15,000 in grant funding.

SarahG (FountainTribe)

  • Ask me questions
  • ****
  • Posts: 782
  • Karma: 29
  • CiviCRM version: 4.4.7
  • CMS version: Drupal 6, Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Filled shift still listed and allows new volunteers
July 26, 2014, 05:51:35 am
I have created a patch for this issue. See Pull Request at: https://github.com/civicrm/civivolunteer/pull/196

FYI: This patch fixes another issue where shifts occurring in the past were listed on the Volunteer sign up page.
Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Extensions »
  • CiviVolunteer (Moderators: GinkgoFJG, Michael Z Daryabeygi) »
  • Filled shift still listed and allows new volunteers

This forum was archived on 2017-11-26.