/**
  * Returns a list of communication IDs for the specified membership.
  *
  * Possible values:
  *  null .. All communication IDs are returned.
  *  0 .. Global communication IDs are returned (defined in Settings page).
  *  <MembershipID> .. Communication IDs of that membership are returned.
  *
  * @since  1.0.1.0
  * @param  int $membership Indtifies a membership.
  * @return array List of communication IDs.
  */
 protected static function get_communication_ids($membership)
 {
     if (!isset(self::$Communication_IDs[0])) {
         self::$Communication_IDs = array(0 => array());
         $args = array('post_type' => self::get_post_type(), 'post_status' => 'any', 'fields' => 'ids', 'posts_per_page' => -1);
         MS_Factory::select_blog();
         $query = new WP_Query($args);
         $items = $query->posts;
         MS_Factory::revert_blog();
         foreach ($items as $id) {
             $comm = MS_Factory::load('MS_Model_Communication', $id);
             self::$Communication_IDs[$comm->membership_id][$comm->type] = $id;
         }
     }
     if ($membership instanceof MS_Model_Membership) {
         $key = $membership->id;
     } else {
         $key = $membership;
     }
     if (null === $key) {
         $result = self::$Communication_IDs;
     } elseif (isset(self::$Communication_IDs[$key])) {
         $result = self::$Communication_IDs[$key];
     } else {
         $result = array();
     }
     return $result;
 }