CCRM-15821 Provide option to notify PCP owner
[civicrm-core.git] / CRM / PCP / BAO / PCP.php
index ebf0711af18ce664c20900729c00d17ef7840c67..754e5afd59046aa00703f6c6e83affce30629323 100644 (file)
@@ -401,6 +401,10 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0";
 
     $form->add('select', 'supporter_profile_id', ts('Supporter Profile'), array('' => ts('- select -')) + $profile, TRUE);
 
+    //CRM-15821 - To add new option for PCP "Owner" notification
+    $ownerNotifications = CRM_Core_OptionGroup::values('pcp_owner_notify');
+    $form->addRadio('owner_notify_id', ts('Owner Notification'), $ownerNotifications, NULL, NULL, TRUE);
+
     $form->addElement('checkbox', 'is_tellfriend_enabled', ts("Allow 'Tell a friend' functionality"), NULL, array('onclick' => "return showHideByValue('is_tellfriend_enabled',true,'tflimit','table-row','radio',false);"));
 
     $form->add('text',
@@ -913,4 +917,22 @@ INNER JOIN civicrm_uf_group ufgroup
     }
   }
 
+  /**
+   * Get owner notification id
+   *
+   * @param int $pcpId
+   * @param $component
+   *
+   *
+   * @return int
+   */
+  public static function getOwnerNotificationId($pcpId) {
+    $query = "
+         SELECT pb.owner_notify_id
+         FROM civicrm_pcp_block pb
+         LEFT JOIN civicrm_pcp pcp ON ( pb.id = pcp.pcp_block_id )
+         WHERE pcp.id = %1";
+    $params = array(1 => array($pcpId, 'Integer'));
+    return CRM_Core_DAO::singleValueQuery($query, $params);
+  }
 }