Esempio n. 1
0
 /**
  * returns the list of fields that can be exported
  *
  * @access public
  * return array
  * @static
  */
 static function &export($prefix = false)
 {
     if (!self::$_export) {
         self::$_export = array();
         $fields = self::fields();
         foreach ($fields as $name => $field) {
             if (CRM_Utils_Array::value('export', $field)) {
                 if ($prefix) {
                     self::$_export['volunteer_need'] =& $fields[$name];
                 } else {
                     self::$_export[$name] =& $fields[$name];
                 }
             }
         }
     }
     return self::$_export;
 }
Esempio n. 2
0
 /**
  * Delete a need, reassign its activities to the project's default flexible need
  * @param $id
  * @return bool
  */
 static function del($id)
 {
     $need = civicrm_api3('volunteer_need', 'getsingle', array('id' => $id));
     // TODO: What do we do with associated activities when deleting a flexible need?
     if (empty($need['is_flexible'])) {
         // Lookup the flexible need
         $flexibleNeedId = CRM_Volunteer_BAO_Project::getFlexibleNeedID($need['project_id']);
         // Reassign any activities back to the flexible need
         $acts = civicrm_api3('volunteer_assignment', 'get', array('volunteer_need_id' => $id));
         $status = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'status_id', 'Available');
         foreach ($acts['values'] as $act) {
             civicrm_api3('volunteer_assignment', 'create', array('id' => $act['id'], 'volunteer_need_id' => $flexibleNeedId, 'status_id' => $status, 'time_scheduled_minutes' => 0));
         }
     }
     $dao = new CRM_Volunteer_DAO_Need();
     $dao->id = $id;
     if ($dao->find()) {
         while ($dao->fetch()) {
             $dao->delete();
         }
     } else {
         return FALSE;
     }
     return TRUE;
 }