CRM/Event add comments
[civicrm-core.git] / CRM / Event / BAO / Event.php
index 4aa095d33c88c9b601417dd153cb16a1c88c41a4..c7261128ec291cf772dce6ec4fe8475e11540c47 100644 (file)
@@ -809,6 +809,12 @@ WHERE civicrm_event.is_active = 1
     }
 
     // check 'view event info' permission
+    //@todo - per CRM-14626 we have resolved that 'view event info' means 'view ALL event info'
+    // and passing in the specific permission here will short-circuit the evaluation of permission to
+    // see specific events (doesn't seem relevant to this call
+    // however, since this function is accessed only by a convoluted call from a joomla block function
+    // it seems safer not to touch here. Suggestion is that CRM_Core_Permission::check(array or relevant permissions) would
+    // be clearer & safer here
     $permissions = CRM_Core_Permission::event(CRM_Core_Permission::VIEW);
 
     // check if we're in shopping cart mode for events
@@ -1766,6 +1772,9 @@ WHERE  id = $cfID
    *
    * @return array $events array of all events.
    */
+  /**
+   * @return array
+   */
   static function getLocationEvents() {
     $events = array();
 
@@ -1786,6 +1795,11 @@ ORDER BY sp.name, ca.city, ca.street_address ASC
     return $events;
   }
 
+  /**
+   * @param $locBlockId
+   *
+   * @return int|null|string
+   */
   static function countEventsUsingLocBlockId($locBlockId) {
     if (!$locBlockId) {
       return 0;
@@ -1800,15 +1814,27 @@ WHERE  ce.loc_block_id = $locBlockId";
     return CRM_Core_DAO::singleValueQuery($query);
   }
 
-  static function validRegistrationRequest($values, $contactID) {
+  /**
+   * Check if event registration is valid according to permissions AND Dates
+   *
+   * @param array $values
+   * @param integer $eventID
+   * @return boolean
+   */
+  static function validRegistrationRequest($values, $eventID) {
     // check that the user has permission to register for this event
     $hasPermission = CRM_Core_Permission::event(CRM_Core_Permission::EDIT,
-      $contactID
+      $eventID, 'register for events'
     );
 
     return $hasPermission && self::validRegistrationDate($values);
   }
 
+  /**
+   * @param $values
+   *
+   * @return bool
+   */
   static function validRegistrationDate(&$values) {
     // make sure that we are between  registration start date and registration end date
     $startDate = CRM_Utils_Date::unixTime(CRM_Utils_Array::value('registration_start_date', $values));
@@ -1835,6 +1861,11 @@ WHERE  ce.loc_block_id = $locBlockId";
    * @return boolean true if allow registration otherwise false
    * @access public
    */
+  /**
+   * @param $values
+   *
+   * @return bool
+   */
   static function showHideRegistrationLink($values) {
 
     $session           = CRM_Core_Session::singleton();
@@ -1867,6 +1898,11 @@ WHERE  ce.loc_block_id = $locBlockId";
    * @return boolean $alreadyRegistered true/false
    * @access public
    */
+  /**
+   * @param $params
+   *
+   * @return bool
+   */
   static function checkRegistration($params) {
     $alreadyRegistered = FALSE;
     if (empty($params['contact_id'])) {
@@ -2043,6 +2079,11 @@ LEFT  JOIN  civicrm_price_field_value value ON ( value.id = lineItem.price_field
    *
    * @return $defaults an array of custom data defaults.
    */
+  /**
+   * @param $templateId
+   *
+   * @return array
+   */
   static function getTemplateDefaultValues($templateId) {
     $defaults = array();
     if (!$templateId) {
@@ -2064,6 +2105,11 @@ LEFT  JOIN  civicrm_price_field_value value ON ( value.id = lineItem.price_field
     return $defaults;
   }
 
+  /**
+   * @param $event_id
+   *
+   * @return object
+   */
   static function get_sub_events($event_id) {
     $params = array('parent_event_id' => $event_id);
     $defaults = array();
@@ -2077,6 +2123,10 @@ LEFT  JOIN  civicrm_price_field_value value ON ( value.id = lineItem.price_field
    * @params int $eventCampaignID campaign id of that event
    *
    */
+  /**
+   * @param $eventID
+   * @param $eventCampaignID
+   */
   static function updateParticipantCampaignID($eventID, $eventCampaignID) {
     $params = array();
     $params[1] = array($eventID, 'Integer');