00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 class Mage_Customer_Model_Customer_Attribute_Source_Store extends Mage_Eav_Model_Entity_Attribute_Source_Table
00035 {
00036 public function getAllOptions()
00037 {
00038 if (!$this->_options) {
00039 $collection = Mage::getResourceModel('core/store_collection');
00040 if ('store_id' == $this->getAttribute()->getAttributeCode()) {
00041 $collection->setWithoutDefaultFilter();
00042 }
00043 $this->_options = Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm();
00044 if ('created_in' == $this->getAttribute()->getAttributeCode()) {
00045 array_unshift($this->_options, array('value' => '0', 'label' => Mage::helper('customer')->__('Admin')));
00046 }
00047 }
00048 return $this->_options;
00049 }
00050
00051 public function getOptionText($value)
00052 {
00053 if(!$value)$value ='0';
00054 $isMultiple = false;
00055 if (strpos($value, ',')) {
00056 $isMultiple = true;
00057 $value = explode(',', $value);
00058 }
00059
00060 if (!$this->_options) {
00061 $collection = Mage::getResourceModel('core/store_collection');
00062 if ('store_id' == $this->getAttribute()->getAttributeCode()) {
00063 $collection->setWithoutDefaultFilter();
00064 }
00065 $this->_options = $collection->load()->toOptionArray();
00066 if ('created_in' == $this->getAttribute()->getAttributeCode()) {
00067 array_unshift($this->_options, array('value' => '0', 'label' => Mage::helper('customer')->__('Admin')));
00068 }
00069 }
00070
00071 if ($isMultiple) {
00072 $values = array();
00073 foreach ($value as $val) {
00074 $values[] = $this->_options[$val];
00075 }
00076 return $values;
00077 }
00078 else {
00079 return $this->_options[$value];
00080 }
00081 return false;
00082 }
00083 }