Beispiel #1
0
function get_member_custom_property_value_for_listing($cp, $member_id, $cp_vals = null)
{
    if (is_null($cp_vals)) {
        $cp_vals = MemberCustomPropertyValues::getMemberCustomPropertyValues($member_id, $cp->getId());
    }
    $val_to_show = "";
    foreach ($cp_vals as $cp_val) {
        if (in_array($cp->getType(), array('contact', 'user')) && $cp_val instanceof MemberCustomPropertyValue) {
            $cp_contact = Contacts::findById($cp_val->getValue());
            if ($cp_contact instanceof Contact) {
                $cp_val->setValue($cp_contact->getObjectName());
            } else {
                $cp_val->setValue("");
            }
        }
        if ($cp->getType() == 'date' && $cp_val instanceof MemberCustomPropertyValue) {
            $format = user_config_option('date_format');
            Hook::fire("custom_property_date_format", null, $format);
            $tmp_date = DateTimeValueLib::dateFromFormatAndString(DATE_MYSQL, $cp_val->getValue());
            if (str_starts_with($cp_val->getValue(), EMPTY_DATE)) {
                $formatted = "";
            } else {
                if (str_ends_with($cp_val->getValue(), "00:00:00")) {
                    $formatted = $tmp_date->format(user_config_option('date_format'));
                } else {
                    $formatted = $tmp_date->format($format);
                }
            }
            $cp_val->setValue($formatted);
        }
        if ($cp->getType() == 'address' && $cp_val instanceof MemberCustomPropertyValue) {
            $values = str_replace("\\|", "%%_PIPE_%%", $cp_val->getValue());
            $exploded = explode("|", $values);
            foreach ($exploded as &$v) {
                $v = str_replace("%%_PIPE_%%", "|", $v);
                $v = str_replace("'", "\\'", $v);
            }
            if (count($exploded) > 0) {
                $address_type = array_var($exploded, 0, '');
                $street = array_var($exploded, 1, '');
                $city = array_var($exploded, 2, '');
                $state = array_var($exploded, 3, '');
                $country = array_var($exploded, 4, '');
                $zip_code = array_var($exploded, 5, '');
                $country_name = CountryCodes::getCountryNameByCode($country);
                $tmp = array();
                if ($street != '') {
                    $tmp[] = $street;
                }
                if ($city != '') {
                    $tmp[] = $city;
                }
                if ($state != '') {
                    $tmp[] = $state;
                }
                if ($zip_code != '') {
                    $tmp[] = $zip_code;
                }
                if ($country_name != '') {
                    $tmp[] = $country_name;
                }
                $cp_val->setValue(implode(' - ', $tmp));
            }
        }
        $val_to_show .= ($val_to_show == "" ? "" : ", ") . ($cp_val instanceof MemberCustomPropertyValue ? $cp_val->getValue() : "");
    }
    $val_to_show = html_to_text($val_to_show);
    return $val_to_show;
}
 /**
  * This function will return paginated result. Result is an array where first element is 
  * array of returned object and second populated pagination object that can be used for 
  * obtaining and rendering pagination data using various helpers.
  * 
  * Items and pagination array vars are indexed with 0 for items and 1 for pagination
  * because you can't use associative indexing with list() construct
  *
  * @access public
  * @param array $arguments Query argumens (@see find()) Limit and offset are ignored!
  * @param integer $items_per_page Number of items per page
  * @param integer $current_page Current page number
  * @return array
  */
 function paginate($arguments = null, $items_per_page = 10, $current_page = 1)
 {
     if (isset($this) && instance_of($this, 'MemberCustomPropertyValues')) {
         return parent::paginate($arguments, $items_per_page, $current_page);
     } else {
         return MemberCustomPropertyValues::instance()->paginate($arguments, $items_per_page, $current_page);
     }
     // if
 }
 /**
  * Return manager instance
  *
  * @access protected
  * @param void
  * @return MemberCustomPropertyValue 
  */
 function manager()
 {
     if (!$this->manager instanceof MemberCustomPropertyValues) {
         $this->manager = MemberCustomPropertyValues::instance();
     }
     return $this->manager;
 }
 static function getMemberCustomPropertyMultipleValueByCode($code, $member_id)
 {
     if (!Plugins::instance()->isActivePlugin('member_custom_properties')) {
         return array();
     }
     $values = array();
     $cp = MemberCustomProperties::instance()->findOne(array('conditions' => "code='{$code}'"));
     if ($cp instanceof MemberCustomProperty) {
         $cpvalues = MemberCustomPropertyValues::getMemberCustomPropertyValues($member_id, $cp->getId());
         foreach ($cpvalues as $cpvalue) {
             $values[] = $cpvalue->getValue();
         }
     }
     return $values;
 }
                 $html .= "og.renderAddressInput('cp" . $customProp->getId() . "', '{$name}', '" . $genid . "addresscontainer-cp" . $customProp->getId() . "', '{$address_type}', {$sel_data_str});";
             } else {
                 $html .= "og.renderAddressInput('cp" . $customProp->getId() . "', '{$name}', '" . $genid . "addresscontainer-cp" . $customProp->getId() . "', '', {});";
             }
         }
     } else {
         $html .= "og.renderAddressInput('cp" . $customProp->getId() . "', '{$name}', '" . $genid . "addresscontainer-cp" . $customProp->getId() . "', '', {});";
     }
     $html .= '});</script>';
     echo $html;
     break;
 case 'user':
 case 'contact':
     $value = '0';
     $contact = null;
     $cp_value = MemberCustomPropertyValues::getMemberCustomPropertyValue($member->getId(), $customProp->getId());
     if ($cp_value instanceof MemberCustomPropertyValue && is_numeric($cp_value->getValue())) {
         $value = $cp_value->getValue();
         $contact = Contacts::findById($value);
     }
     $emtpy_text = lang('select contact');
     Hook::fire('member_contact_cp_filters', array('cp' => $customProp, 'member' => $member), $filters);
     if ($customProp->getType() == 'user') {
         $filters['is_user'] = 1;
         if ($member_is_new) {
             $filters['has_permissions'] = $parent_member;
         } else {
             $filters['has_permissions'] = $member->getId();
         }
         $emtpy_text = lang('select user');
     }