1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: 28: 29: 30: 31: 32: 33:
34: class Mage_Customer_Model_Customer_Attribute_Source_Store extends Mage_Eav_Model_Entity_Attribute_Source_Table
35: {
36: public function getAllOptions()
37: {
38: if (!$this->_options) {
39: $collection = Mage::getResourceModel('core/store_collection');
40: if ('store_id' == $this->getAttribute()->getAttributeCode()) {
41: $collection->setWithoutDefaultFilter();
42: }
43: $this->_options = Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm();
44: if ('created_in' == $this->getAttribute()->getAttributeCode()) {
45: array_unshift($this->_options, array('value' => '0', 'label' => Mage::helper('customer')->__('Admin')));
46: }
47: }
48: return $this->_options;
49: }
50:
51: public function getOptionText($value)
52: {
53: if(!$value)$value ='0';
54: $isMultiple = false;
55: if (strpos($value, ',')) {
56: $isMultiple = true;
57: $value = explode(',', $value);
58: }
59:
60: if (!$this->_options) {
61: $collection = Mage::getResourceModel('core/store_collection');
62: if ('store_id' == $this->getAttribute()->getAttributeCode()) {
63: $collection->setWithoutDefaultFilter();
64: }
65: $this->_options = $collection->load()->toOptionArray();
66: if ('created_in' == $this->getAttribute()->getAttributeCode()) {
67: array_unshift($this->_options, array('value' => '0', 'label' => Mage::helper('customer')->__('Admin')));
68: }
69: }
70:
71: if ($isMultiple) {
72: $values = array();
73: foreach ($value as $val) {
74: $values[] = $this->_options[$val];
75: }
76: return $values;
77: }
78: else {
79: return $this->_options[$value];
80: }
81: return false;
82: }
83: }
84: