INFRA-132 - Docblock formatting fixes
[civicrm-core.git] / CRM / PCP / BAO / PCP.php
index 27fd350273c394ebcc369a3a8665492af2fd8480..64f8c9615e2c16340ef0012f14f0f168d33bba3c 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -43,24 +43,24 @@ class CRM_PCP_BAO_PCP extends CRM_PCP_DAO_PCP {
   static $_pcpLinks = NULL;
 
   /**
-   *
    */
-  function __construct() {
+  public function __construct() {
     parent::__construct();
   }
 
   /**
-   * function to add or update either a Personal Campaign Page OR a PCP Block
+   * Add or update either a Personal Campaign Page OR a PCP Block
    *
-   * @param array $params reference array contains the values submitted by the form
-   * @param bool $pcpBlock if true, create or update PCPBlock, else PCP
+   * @param array $params
+   *   Reference array contains the values submitted by the form.
+   * @param bool $pcpBlock
+   *   If true, create or update PCPBlock, else PCP.
    *
-   * @access public
    * @static
    *
    * @return object
    */
-  static function add(&$params, $pcpBlock = TRUE) {
+  public static function add(&$params, $pcpBlock = TRUE) {
     if ($pcpBlock) {
       // action is taken depending upon the mode
       $dao = new CRM_PCP_DAO_PCPBlock();
@@ -80,7 +80,7 @@ class CRM_PCP_BAO_PCP extends CRM_PCP_DAO_PCP {
 
     // set currency for CRM-1496
     if (!isset($dao->currency)) {
-      $config = & CRM_Core_Config::singleton();
+      $config = &CRM_Core_Config::singleton();
       $dao->currency = $config->defaultCurrency;
     }
 
@@ -89,15 +89,16 @@ class CRM_PCP_BAO_PCP extends CRM_PCP_DAO_PCP {
   }
 
   /**
-   * function to get the Display  name of a contact for a PCP
+   * Get the Display  name of a contact for a PCP
    *
-   * @param  int $id      id for the PCP
+   * @param int $id
+   *   Id for the PCP.
    *
-   * @return null|string     Dispaly name of the contact if found
+   * @return null|string
+   *   Dispaly name of the contact if found
    * @static
-   * @access public
    */
-  static function displayName($id) {
+  public static function displayName($id) {
     $id = CRM_Utils_Type::escape($id, 'Integer');
 
     $query = "
@@ -110,15 +111,15 @@ WHERE  civicrm_pcp.contact_id = civicrm_contact.id
   }
 
   /**
-   * Function to return PCP  Block info for dashboard
+   * Return PCP  Block info for dashboard
    *
-   * @param $contactId
+   * @param int $contactId
    *
-   * @return array     array of Pcp if found
-   * @access public
+   * @return array
+   *   array of Pcp if found
    * @static
    */
-  static function getPcpDashboardInfo($contactId) {
+  public static function getPcpDashboardInfo($contactId) {
     $links = self::pcpLinks();
 
     $query = "
@@ -220,6 +221,7 @@ ORDER BY target_entity_type, target_entity_id
       $pcpBlock[] = array(
         'pageId' => $pcpBlockDao->target_entity_id,
         'pageTitle' => $pageTitle,
+        'component' => $pcpBlockDao->target_entity_type,
         'action' => $action,
       );
     }
@@ -228,16 +230,17 @@ ORDER BY target_entity_type, target_entity_id
   }
 
   /**
-   * function to show the total amount for Personal Campaign Page on thermometer
+   * Show the total amount for Personal Campaign Page on thermometer
    *
-   * @param array $pcpId  contains the pcp ID
+   * @param array $pcpId
+   *   Contains the pcp ID.
    *
-   * @access public
    * @static
    *
-   * @return total amount
+   * @return total
+   *   amount
    */
-  static function thermoMeter($pcpId) {
+  public static function thermoMeter($pcpId) {
     $query = "
 SELECT SUM(cc.total_amount) as total
 FROM civicrm_pcp pcp
@@ -250,16 +253,16 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0";
   }
 
   /**
-   * function to show the amount, nickname on honor roll
+   * Show the amount, nickname on honor roll
    *
-   * @param array $pcpId contains the pcp ID
+   * @param array $pcpId
+   *   Contains the pcp ID.
    *
-   * @access public
    * @static
    *
-   * @return array $honor
+   * @return array
    */
-  static function honorRoll($pcpId) {
+  public static function honorRoll($pcpId) {
     $query = "
             SELECT cc.id, cs.pcp_roll_nickname, cs.pcp_personal_note,
                    cc.total_amount, cc.currency
@@ -282,10 +285,11 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0";
   /**
    * Get action links
    *
-   * @return array (reference) of action links
+   * @return array
+   *   (reference) of action links
    * @static
    */
-  static function &pcpLinks() {
+  public static function &pcpLinks() {
     if (!(self::$_pcpLinks)) {
       $deleteExtra = ts('Are you sure you want to delete this Personal Campaign Page?') . '\n' . ts('This action cannot be undone.');
 
@@ -348,14 +352,13 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0";
   }
 
   /**
-   * Function to Delete the campaign page
+   * Delete the campaign page
    *
-   * @param int $id campaign page id
+   * @param int $id
+   *   Campaign page id.
    *
    * @return null
-   * @access public
    * @static
-   *
    */
   public static function deleteById($id) {
     CRM_Utils_Hook::pre('delete', 'Campaign', $id, CRM_Core_DAO::$_nullArray);
@@ -373,12 +376,12 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0";
   }
 
   /**
-   * Function to build the form
+   * Build the form object
    *
-   * @param object $form form object
+   * @param CRM_Core_Form $form
+   *   Form object.
    *
    * @return void
-   * @access public
    */
   public static function buildPCPForm($form) {
     $form->addElement('checkbox', 'pcp_active', ts('Enable Personal Campaign Pages?'), NULL, array('onclick' => "return showHideByValue('pcp_active',true,'pcpFields','block','radio',false);"));
@@ -393,7 +396,7 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0";
     }
     CRM_Core_DAO::commonRetrieveAll('CRM_Core_DAO_UFGroup', 'is_cms_user', $isUserRequired, $profiles, array(
       'title',
-      'is_active'
+      'is_active',
     ));
     if (!empty($profiles)) {
       foreach ($profiles as $key => $value) {
@@ -425,15 +428,14 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0";
   }
 
 
-  /*
-   * Add PCP form elements to a form
-   */
   /**
-   * @param integer $pcpId
+   * Add PCP form elements to a form
+   *
+   * @param int $pcpId
    * @param CRM_Core_Page $page
    * @param null $elements
    */
-  function buildPcp($pcpId, &$page, &$elements = NULL) {
+  public function buildPcp($pcpId, &$page, &$elements = NULL) {
 
     $prms = array('id' => $pcpId);
     CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $prms, $pcpInfo);
@@ -441,14 +443,14 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0";
       if ($pcpInfo['page_type'] == 'event') {
         $pcp_supporter_text = ts('This event registration is being made thanks to effort of <strong>%1</strong>, who supports our campaign. ', array(1 => $pcpSupporter));
         $text = CRM_PCP_BAO_PCP::getPcpBlockStatus($pcpInfo['page_id'], 'event');
-        if(!empty($text)) {
+        if (!empty($text)) {
           $pcp_supporter_text .= "You can support it as well - once you complete the registration, you will be able to create your own Personal Campaign Page!";
         }
       }
       else {
         $pcp_supporter_text = ts('This contribution is being made thanks to effort of <strong>%1</strong>, who supports our campaign. ', array(1 => $pcpSupporter));
         $text = CRM_PCP_BAO_PCP::getPcpBlockStatus($pcpInfo['page_id'], 'contribute');
-        if(!empty($text)) {
+        if (!empty($text)) {
           $pcp_supporter_text .= "You can support it as well - once you complete the donation, you will be able to create your own Personal Campaign Page!";
         }
       }
@@ -465,8 +467,8 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0";
       );
       $extraOption = array('onclick' => "return pcpAnonymous( );");
       $elements = array();
-      $elements[] = & $page->createElement('radio', NULL, '', ts('Include my name and message'), 0, $extraOption);
-      $elements[] = & $page->createElement('radio', NULL, '', ts('List my support anonymously'), 1, $extraOption);
+      $elements[] = &$page->createElement('radio', NULL, '', ts('Include my name and message'), 0, $extraOption);
+      $elements[] = &$page->createElement('radio', NULL, '', ts('List my support anonymously'), 1, $extraOption);
       $page->addGroup($elements, 'pcp_is_anonymous', NULL, '&nbsp;&nbsp;&nbsp;');
       $page->_defaults['pcp_is_anonymous'] = 0;
 
@@ -478,11 +480,10 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0";
     }
   }
 
-  /*
-   * Process a PCP contribution/
-   */
   /**
-   * @param $pcpId
+   * Process a PCP contribution
+   *
+   * @param int $pcpId
    * @param $component
    * @param $entity
    *
@@ -525,7 +526,7 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0";
     }
 
     // define redirect url back to contrib page or event if needed
-    $url = CRM_Utils_System::url($urlBase, "reset=1&id={$pcpBlock['entity_id']}", FALSE, NULL, FALSE, TRUE );
+    $url = CRM_Utils_System::url($urlBase, "reset=1&id={$pcpBlock['entity_id']}", FALSE, NULL, FALSE, TRUE);
 
     if ($pcpBlock['target_entity_id'] != $entity['id']) {
       $statusMessage = ts('This page is not related to the Personal Campaign Page you have just visited. However you can still make a contribution here.');
@@ -582,17 +583,17 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0";
   }
 
   /**
-   * Function to Approve / Reject the campaign page
+   * Approve / Reject the campaign page
    *
-   * @param int $id campaign page id
+   * @param int $id
+   *   Campaign page id.
    *
    * @param $is_active
    *
    * @return null
-   * @access public
    * @static
    */
-  static function setIsActive($id, $is_active) {
+  public static function setIsActive($id, $is_active) {
     switch ($is_active) {
       case 0:
         $is_active = 3;
@@ -613,7 +614,7 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0";
 
     CRM_Core_Session::setStatus(ts("%1 status has been updated to %2.", array(
       1 => $pcpTitle,
-      2 => $pcpStatus
+      2 => $pcpStatus,
     )), 'Status Updated', 'success');
 
     // send status change mail
@@ -625,22 +626,23 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0";
   }
 
   /**
-   * Function to send notfication email to supporter
+   * Send notfication email to supporter
    * 1. when their PCP status is changed by site admin.
    * 2. when supporter initially creates a Personal Campaign Page ($isInitial set to true).
    *
-   * @param int $pcpId campaign page id
-   * @param int $newStatus pcp status id
+   * @param int $pcpId
+   *   Campaign page id.
+   * @param int $newStatus
+   *   Pcp status id.
    * @param bool|int $isInitial is it the first time, campaign page has been created by the user
    *
    * @param string $component
    *
    * @throws Exception
    * @return null
-   * @access public
    * @static
    */
-  static function sendStatusUpdate($pcpId, $newStatus, $isInitial = FALSE, $component = 'contribute') {
+  public static function sendStatusUpdate($pcpId, $newStatus, $isInitial = FALSE, $component = 'contribute') {
     $pcpStatusName = CRM_Core_OptionGroup::values("pcp_status", FALSE, FALSE, FALSE, NULL, 'name');
     $pcpStatus = CRM_Core_OptionGroup::values("pcp_status");
     $config = CRM_Core_Config::singleton();
@@ -724,31 +726,29 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0";
   }
 
   /**
-   * Function to Enable / Disable the campaign page
+   * Enable / Disable the campaign page
    *
-   * @param int $id campaign page id
+   * @param int $id
+   *   Campaign page id.
    *
    * @param $is_active
    * @return null
-   * @access public
    * @static
    */
-  static function setDisable($id, $is_active) {
+  public static function setDisable($id, $is_active) {
     return CRM_Core_DAO::setFieldValue('CRM_PCP_DAO_PCP', $id, 'is_active', $is_active);
   }
 
   /**
-   * Function to get pcp block is active
+   * Get pcp block is active
    *
-   * @param $pcpId
+   * @param int $pcpId
    * @param $component
-   * @internal param int $id campaign page id
    *
    * @return int
-   * @access public
    * @static
    */
-  static function getStatus($pcpId, $component) {
+  public static function getStatus($pcpId, $component) {
     $query = "
          SELECT pb.is_active
          FROM civicrm_pcp pcp
@@ -763,17 +763,15 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0";
   }
 
   /**
-   * Function to get pcp block is enabled for component page
+   * Get pcp block is enabled for component page
    *
-   * @param $pageId
+   * @param int $pageId
    * @param $component
-   * @internal param int $id contribution page id
    *
-   * @return String
-   * @access public
+   * @return string
    * @static
    */
-  static function getPcpBlockStatus($pageId, $component) {
+  public static function getPcpBlockStatus($pageId, $component) {
     $query = "
      SELECT pb.link_text as linkText
      FROM civicrm_pcp_block pb
@@ -788,16 +786,15 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0";
   }
 
   /**
-   * Function to find out if the PCP block is in use by one or more PCP page
+   * Find out if the PCP block is in use by one or more PCP page
    *
-   * @param int $id pcp block id
+   * @param int $id
+   *   Pcp block id.
    *
    * @return Boolean
-   * @access public
    * @static
-   *
    */
-  static function getPcpBlockInUse($id) {
+  public static function getPcpBlockInUse($id) {
     $query = "
      SELECT count(*)
      FROM civicrm_pcp pcp
@@ -809,17 +806,15 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0";
   }
 
   /**
-   * Function to get email is enabled for supporter's profile
+   * Get email is enabled for supporter's profile
    *
-   * @param $profileId
-   *
-   * @internal param int $id supporter's profile id
+   * @param int $profileId
+   *   Supporter's profile id.
    *
    * @return boolean
-   * @access public
    * @static
    */
-  static function checkEmailProfile($profileId) {
+  public static function checkEmailProfile($profileId) {
     $query = "
 SELECT field_name
 FROM civicrm_uf_field
@@ -834,18 +829,15 @@ WHERE field_name like 'email%' And is_active = 1 And uf_group_id = %1";
   }
 
   /**
-   * Function to obtain the title of page associated with a pcp
+   * Obtain the title of page associated with a pcp
    *
-   * @param $pcpId
+   * @param int $pcpId
    * @param $component
    *
-   * @internal param int $id campaign page id
-   *
    * @return int
-   * @access public
    * @static
    */
-  static function getPcpPageTitle($pcpId, $component) {
+  public static function getPcpPageTitle($pcpId, $component) {
     if ($component == 'contribute') {
       $query = "
   SELECT cp.title
@@ -866,18 +858,15 @@ WHERE field_name like 'email%' And is_active = 1 And uf_group_id = %1";
   }
 
   /**
-   * Function to get pcp block & entity id given pcp id
+   * Get pcp block & entity id given pcp id
    *
-   * @param $pcpId
+   * @param int $pcpId
    * @param $component
    *
-   * @internal param int $id campaign page id
-   *
    * @return String
-   * @access public
    * @static
    */
-  static function getPcpBlockEntityId($pcpId, $component) {
+  public static function getPcpBlockEntityId($pcpId, $component) {
     $entity_table = self::getPcpEntityTable($component);
 
     $query = "
@@ -896,17 +885,14 @@ WHERE pcp.id = %1";
   }
 
   /**
-   * Function to get pcp entity table given a component.
+   * Get pcp entity table given a component.
    *
    * @param $component
    *
-   * @internal param int $id campaign page id
-   *
    * @return String
-   * @access public
    * @static
    */
-  static function getPcpEntityTable($component) {
+  public static function getPcpEntityTable($component) {
     $entity_table_map = array(
       'event' => 'civicrm_event',
       'civicrm_event' => 'civicrm_event',
@@ -917,15 +903,12 @@ WHERE pcp.id = %1";
   }
 
   /**
-   * Function to get supporter profile id
+   * Get supporter profile id
    *
-   * @param $component_id
+   * @param int $component_id
    * @param string $component
    *
-   * @internal param int $contributionPageId contribution page id
-   *
    * @return int
-   * @access public
    * @static
    */
   public static function getSupporterProfileId($component_id, $component = 'contribute') {
@@ -949,4 +932,3 @@ INNER JOIN civicrm_uf_group ufgroup
     }
   }
 }
-