public function render(Varien_Object $row) { if ($row->getType() == 1) { return "<span class='grid-severity-notice' title='" . $row->getUseragent() . "'><span>" . Mage::helper('watchlog')->__("Success") . "</span></span>"; } else { if ($row->getType() == 2) { return "<span class='grid-severity-minor' title='" . $row->getUseragent() . "'><span>" . Mage::helper('watchlog')->__("Blocked") . "</span></span>"; } else { return "<span class='grid-severity-critical' title='" . $row->getUseragent() . "'><span>" . Mage::helper('watchlog')->__("Failed") . "</span></span>"; } } }
public function render(Varien_Object $row) { // not logged in => use subscriber data if ($row->getType() != 2) { $value = $row->getSubscriberGender(); } elseif (Mage::getStoreConfig('newsletterextended/fields/customer_override')) { // fallback enabled => fallback to customer data if no data found in subscriber if (Mage::getStoreConfig('newsletterextended/fields/customer_fallback')) { $value = $row->getSubscriberGender() ? $row->getSubscriberGender() : $row->getCustomerGender(); } else { $value = $row->getSubscriberGender(); } } else { $value = $row->getCustomerGender(); } // fix strange values (dunno where they come from) $options = $this->getColumn()->getOptions(); if ($value == 123) { $value = 1; } else { if ($value == 124) { $value = 2; } } return isset($options[$value]) ? $options[$value] : '---'; }
public function render(Varien_Object $row) { $url = $this->getUrl('*/*/editConfig', array('theme_id' => $row->getId())); $tr_class = 'ConfigType-' . $row->getType(); return '<button class="edit-btn" data-parent-tr-class="' . $tr_class . '" type="button" title="Edit" onclick="return reloadTo(\'' . $url . '\');"><i class="fa fa-pencil-square-o"></i> ' . (Mage::getSingleton('admin/session')->isAllowed('meigee/thememanager/edit') ? Mage::helper('catalog')->__('Edit') : Mage::helper('catalog')->__('View')) . '</button>'; }
protected function _prepareForm() { $form = new Varien_Data_Form(); if (Mage::registry('gomage_feed')) { $item = Mage::registry('gomage_feed'); } else { $item = new Varien_Object(); } $this->setForm($form); $fieldset = $form->addFieldset('main_fieldset', array('legend' => $this->__('Item information'))); $headerBar = $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array('label' => Mage::helper('catalog')->__('Feed Pro Help'), 'class' => 'go', 'id' => 'feed_pro_help', 'onclick' => 'window.open(\'http://www.gomage.com/faq/extensions/feed-pro\')')); $fieldset->setHeaderBar($headerBar->toHtml()); $fieldset->addField('type', 'hidden', array('name' => 'type')); $fieldset->addField('name', 'text', array('name' => 'name', 'label' => $this->__('Name'), 'title' => $this->__('Name'), 'required' => true, 'note' => $this->__('e.g. "Google Base", "Yahoo! Store"...'))); if ($item->getId() && ($url = $item->getUrl())) { $fieldset->addField('comments', 'note', array('label' => $this->__('Access Url'), 'title' => $this->__('Access Url'), 'text' => '<a href="' . $url . '" target="_blank">' . $url . '</a>')); } $fieldset->addField('filename', 'text', array('name' => 'filename', 'label' => $this->__('Filename'), 'title' => $this->__('Filename'), 'required' => false, 'note' => $this->__('e.g. "productfeed.csv", "productfeed.xml"...'))); $fieldset->addField('store_id', 'select', array('label' => $this->__('Store View'), 'required' => true, 'name' => 'store_id', 'values' => Mage::getModel('gomage_feed/adminhtml_system_config_source_store')->getStoreValuesForForm())); if (!$item->getType() && $this->getRequest()->getParam('type')) { $item->setType($this->getRequest()->getParam('type')); } $form->setValues($item->getData()); return parent::_prepareForm(); }
public function render(Varien_Object $row) { if ($row->getType() == 1) { return 'Status Change'; } else { return 'Image Change'; } }
/** * Return the PayPal payment type * * @return mixed */ public function getPaymentType() { $object = new Varien_Object(); $object->setType($this->_getConfig('payment_type')); // Specific event for this method Mage::dispatchEvent('gene_paypal_get_payment_type', array('object' => $object)); return $object->getType(); }
public function render(Varien_Object $row) { if ($row->getType() != 2) { $value = $row->getThememanagerSubscriberLastname(); } else { $value = $row->getCustomerLastname() ? $row->getCustomerLastname() : $row->getThememanagerSubscriberLastname(); } return $value ? $value : '----'; }
public function render(Varien_Object $row) { $configuration = array(); if ($row->getType() == Xtento_OrderExport_Model_Destination::TYPE_LOCAL) { $configuration['directory'] = $row->getPath(); } if ($row->getType() == Xtento_OrderExport_Model_Destination::TYPE_FTP || $row->getType() == Xtento_OrderExport_Model_Destination::TYPE_SFTP) { $configuration['server'] = $row->getHostname() . ':' . $row->getPort(); $configuration['username'] = $row->getUsername(); $configuration['path'] = $row->getPath(); } if ($row->getType() == Xtento_OrderExport_Model_Destination::TYPE_EMAIL) { $configuration['from'] = $row->getEmailSender(); $configuration['to'] = $row->getEmailRecipient(); $configuration['subject'] = $row->getEmailSubject(); } if ($row->getType() == Xtento_OrderExport_Model_Destination::TYPE_CUSTOM) { $configuration['class'] = $row->getCustomClass(); } if ($row->getType() == Xtento_OrderExport_Model_Destination::TYPE_WEBSERVICE) { $configuration['class'] = 'Webservice'; $configuration['function'] = $row->getCustomFunction(); } if (!empty($configuration)) { $configurationHtml = ''; foreach ($configuration as $key => $value) { $configurationHtml .= Mage::helper('xtento_orderexport')->__(ucfirst($key)) . ': <i>' . Mage::helper('xtcore/core')->escapeHtml($value) . '</i><br/>'; } return $configurationHtml; } else { return '---'; } }
/** * {@inheritdoc} */ public function render(Varien_Object $row) { $id = $row->getMessageId(); $executed = $row->getExecuted(); if (!$id && $executed) { return __('Pending'); } if (!$id & $row->getType() == 'import') { $id = SixBySix_RealTimeDespatch_Model_Resource_Request_Line_Collection::getNextSequencesId($row->getEntity()); } if (!$id) { $id = __('Pending'); } return $id; }
public function render(Varien_Object $row) { // not logged in => use subscriber data if ($row->getType() != 2) { $value = $row->getSubscriberSuffix(); } elseif (Mage::getStoreConfig('newsletterextended/fields/customer_override')) { // fallback enabled => fallback to customer data if no data found in subscriber if (Mage::getStoreConfig('newsletterextended/fields/customer_fallback')) { $value = $row->getSubscriberSuffix() ? $row->getSubscriberSuffix() : $row->getCustomerSuffix(); } else { $value = $row->getSubscriberSuffix(); } } else { $value = $row->getCustomerSuffix(); } return $value ? $value : '---'; }
/** * Render information about menu item * * @param Varien_Object $row * @return string */ public function render(Varien_Object $row) { $helper = Mage::helper('menu'); switch ($row->getType()) { case VF_CustomMenu_Model_Resource_Menu_Attribute_Source_Type::LINK_INTERNAL: return '<strong>' . $helper->__('Path') . ':</strong> ' . $row->getUrl(); break; case VF_CustomMenu_Model_Resource_Menu_Attribute_Source_Type::LINK_EXTERNAL: return '<strong>' . $helper->__('Link') . ':</strong> ' . $row->getUrl(); break; case VF_CustomMenu_Model_Resource_Menu_Attribute_Source_Type::CATEGORY: return '<strong>' . $helper->__('Category') . ':</strong> ' . Mage::getModel('catalog/category')->load($row->getDefaultCategory(), array('name'))->getName() . ' <strong>' . $helper->__('Show Children') . ':</strong> ' . ($row->getShowChildren() ? $helper->__('Yes') : $helper->__('No')) . ($row->getUrl() ? ' <strong>' . $helper->__('Path') . ':</strong> ' . $row->getUrl() : ''); break; case VF_CustomMenu_Model_Resource_Menu_Attribute_Source_Type::ATTRIBUTE: return '<strong>' . $helper->__('Attribute code') . ':</strong> ' . $row->getSourceAttribute() . ' <strong>' . $helper->__('Category') . ':</strong> ' . Mage::getModel('catalog/category')->load($row->getDefaultCategory(), array('name'))->getName(); break; default: return ''; } }
public function assignData($data) { if (!$data instanceof Varien_Object) { $data = new Varien_Object($data); } $cardToken = $data->getCardToken(); $ipAddress = $data->getIpAddress(); $offlineTransId = $data->getOfflineTransactionId(); $type = $data->getType(); if (empty($cardToken) || empty($ipAddress)) { Mage::log('Payment could not be processed. Missing card token or IP', Zend_Log::ERR, self::$logFile); Mage::throwException(Mage::helper('pinpay')->__(self::GENERIC_PAYMENT_GATEWAY_ERROR)); } // Store the authorised card token and customer IP $this->getInfoInstance()->setAdditionalInformation("card_token", $data->getCardToken()); $this->getInfoInstance()->setAdditionalInformation("ip_address", $data->getIpAddress()); // Store the offline transaction ID if supplied if (Mage::app()->getStore()->isAdmin() && !empty($offlineTransId) && $type == self::OFFLINE) { $this->getInfoInstance()->setAdditionalInformation("offline_transaction_id", $offlineTransId); } return $this; }
protected function _prepareForm() { $form = new Varien_Data_Form(); if (Mage::registry('ranvi_feed')) { $item = Mage::registry('ranvi_feed'); } else { $item = new Varien_Object(); } $this->setForm($form); $fieldset = $form->addFieldset('main_fieldset', array('legend' => $this->__('Item information'))); $fieldset->addField('type', 'hidden', array('name' => 'type')); $fieldset->addField('name', 'text', array('name' => 'name', 'label' => $this->__('Name'), 'title' => $this->__('Name'), 'required' => true)); if ($item->getId() && ($url = $item->getUrl())) { $fieldset->addField('comments', 'note', array('label' => $this->__('Access Url'), 'title' => $this->__('Access Url'), 'text' => '<a href="' . $url . '" target="_blank">' . $url . '</a>')); } $fieldset->addField('filename', 'text', array('name' => 'filename', 'label' => $this->__('Filename'), 'title' => $this->__('Filename'), 'required' => false)); $fieldset->addField('store_id', 'select', array('label' => $this->__('Store View'), 'required' => true, 'name' => 'store_id', 'values' => Mage::getModel('ranvi_feed/adminhtml_system_config_source_store')->getStoreValuesForForm())); if (!$item->getType() && $this->getRequest()->getParam('type')) { $item->setType($this->getRequest()->getParam('type')); } $form->setValues($item->getData()); return parent::_prepareForm(); }
protected function _prepareForm() { $form = new Varien_Data_Form(); if (Mage::registry('gomage_custom_attribute')) { $item = Mage::registry('gomage_custom_attribute'); } else { $item = new Varien_Object(); } $this->setForm($form); $fieldset = $form->addFieldset('main_fieldset', array('legend' => $this->__('Attribute Information'))); $fieldset->addField('type', 'hidden', array('name' => 'type')); $headerBar = $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array('label' => Mage::helper('catalog')->__('Feed Pro Help'), 'class' => 'go', 'id' => 'feed_pro_help', 'onclick' => 'window.open(\'http://www.gomage.com/faq/extensions/feed-pro\')')); $fieldset->setHeaderBar($headerBar->toHtml()); $fieldset->addField('code', 'text', array('name' => 'code', 'label' => $this->__('Dynamic Attribute Code'), 'title' => $this->__('Dynamic Attribute Code'), 'required' => true, 'class' => 'validate-code', 'note' => $this->__('For internal use. Must be unique with no spaces'))); $fieldset->addField('name', 'text', array('name' => 'name', 'label' => $this->__('Name'), 'title' => $this->__('Name'), 'required' => true, 'note' => $this->__('e.g. "Custom Price", "Google Category"...'))); if (!$item->getType() && $this->getRequest()->getParam('type')) { $item->setType($this->getRequest()->getParam('type')); } if ($item->getId()) { $form->setValues($item->getData()); } return parent::_prepareForm(); }
public function processDownload($resource, Varien_Object $item) { $this->_resourceFile = $resource; $response = Mage::app()->getResponse(); $response->setHttpResponseCode(200)->setHeader('Pragma', 'public', true)->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)->setHeader('Content-type', $this->getContentType(), true); if ($fileSize = $this->_getHandle()->streamStat('size')) { $response->setHeader('Content-Length', $fileSize); } $contentDisposition = $this->getContentType() == 'application/pdf' || strtolower($item->getType()) == 'pdf' ? 'inline' : 'attachment'; $response->setHeader('Content-Disposition', $contentDisposition . '; filename=' . $this->getFileName($item)); $response->clearBody(); $response->sendHeaders(); $this->output(); }
/** * Add field to Options form based on parameter configuration * * @param Varien_Object $parameter * @return Varien_Data_Form_Element_Abstract */ protected function _addField($parameter) { $form = $this->getForm(); $fieldset = $this->getMainFieldset(); //$form->getElement('options_fieldset'); // prepare element data with values (either from request of from default values) $fieldName = $parameter->getKey(); $data = array('name' => $form->addSuffixToName($fieldName, 'parameters'), 'label' => $this->_translationHelper->__($parameter->getLabel()), 'required' => $parameter->getRequired(), 'class' => 'widget-option', 'note' => $this->_translationHelper->__($parameter->getDescription())); if ($values = $this->getWidgetValues()) { $data['value'] = isset($values[$fieldName]) ? $values[$fieldName] : ''; } else { $data['value'] = $parameter->getValue(); //prepare unique id value if ($fieldName == 'unique_id' && $data['value'] == '') { $data['value'] = md5(microtime(1)); } } // prepare element dropdown values if ($values = $parameter->getValues()) { // dropdown options are specified in configuration $data['values'] = array(); foreach ($values as $option) { $data['values'][] = array('label' => $this->_translationHelper->__($option['label']), 'value' => $option['value']); } } elseif ($sourceModel = $parameter->getSourceModel()) { $data['values'] = Mage::getModel($sourceModel)->toOptionArray(); } // prepare field type or renderer $fieldRenderer = null; $fieldType = $parameter->getType(); // hidden element if (!$parameter->getVisible()) { $fieldType = 'hidden'; } elseif (false !== strpos($fieldType, '/')) { $fieldRenderer = $this->getLayout()->createBlock($fieldType); $fieldType = $this->_defaultElementType; } // instantiate field and render html $field = $fieldset->addField($this->getMainFieldsetHtmlId() . '_' . $fieldName, $fieldType, $data); if ($fieldRenderer) { $field->setRenderer($fieldRenderer); } // extra html preparations if ($helper = $parameter->getHelperBlock()) { $helperBlock = $this->getLayout()->createBlock($helper->getType(), '', $helper->getData()); if ($helperBlock instanceof Varien_Object) { $helperBlock->setConfig($helper->getData())->setFieldsetId($fieldset->getId())->setTranslationHelper($this->_translationHelper)->prepareElementHtml($field); } } // dependencies from other fields $dependenceBlock = $this->getChild('form_after'); $dependenceBlock->addFieldMap($field->getId(), $fieldName); if ($parameter->getDepends()) { foreach ($parameter->getDepends() as $from => $row) { $values = isset($row['values']) ? array_values($row['values']) : (string) $row['value']; $dependenceBlock->addFieldDependence($fieldName, $from, $values); } } return $field; }
protected function _drawGiftwrapItem(Varien_Object $item, Zend_Pdf_Page $page, Mage_Sales_Model_Order $order) { $orderItem = $item->getOrderItem(); $renderer = $this->_getRenderer($item->getType()); $this->renderItem($item, $page, $order, $renderer); $transportObject = new Varien_Object(array('renderer_type_list' => array())); Mage::dispatchEvent('pdf_item_draw_after', array('transport_object' => $transportObject, 'entity_item' => $item)); foreach ($transportObject->getRendererTypeList() as $type) { $renderer = $this->_getRenderer($type); if ($renderer) { $this->renderItem($orderItem, $page, $order, $renderer); } } return $renderer->getPage(); }
public function getLicenseInfo($licensekey, $extensionName, $domain) { $licensekey = trim($licensekey); // check license for old license key if ($oldLicenseInfo = $this->_decrypt($licensekey)) { $license = Mage::getModel('magenotification/license')->loadByLicenseExtension($licensekey, $extensionName); if (!$license->getId()) { // Request first time when using old license key try { $xmlRpc = new Zend_XmlRpc_Client(self::SERVER_URL . 'api/xmlrpc/'); $session = $xmlRpc->call('login', array('username' => self::WEBSERVICE_USER, 'password' => self::WEBSERVICE_PASS)); $result = $xmlRpc->call('call', array('sessionId' => $session, 'apiPath' => 'licensemanager.active', 'args' => array($licensekey, $extensionName, $domain))); $dataObject = new Varien_Object($result); } catch (Exception $e) { return new Varien_Object(array('response_code' => 101)); } $license->setResponseCode($dataObject->getResponseCode())->setDomains($dataObject->getDomains()); if ($dataObject->getActivatedTime()) { $license->setActiveAt(substr($dataObject->getActivatedTime(), 0, 10)); } else { $license->setActiveAt(now(true)); } try { $license->setSumCode($this->_getSumCode($license)); $license->save(); } catch (Exception $e) { } return $dataObject; } $result = new Varien_Object($license->getData()); $result->addData(array('users' => 1, 'created_time' => date('Y-m-d H:m:s', $oldLicenseInfo['created_time']), 'activated_time' => $license->getActiveAt(), 'type' => $oldLicenseInfo['type'], 'status' => 1, 'expired_time' => $oldLicenseInfo['expired_time'])); if ($license->getSumCode() != $this->_getSumCode($license)) { try { $license->setResponseCode(self::GENERAL_ERROR); $license->setSumCode($this->_getSumCode($license))->save(); } catch (Exception $e) { } } elseif ($result->getType() == self::TRIAL_VERSION && $license->getResponseCode() > self::LIMITED_DOMAIN_ERROR) { $expiredTime = strtotime($license->getActiveAt()) + (int) $result->getExpiredTime() * 24 * 3600; if ($expiredTime < time()) { try { $license->setResponseCode(self::EXPIRED_TRIAL_LICENSE_KEY_ERROR); $license->setSumCode($this->_getSumCode($license))->save(); } catch (Exception $e) { } } } return $result->setResponseCode($license->getResponseCode()); } // check new license key if ($licenseInfo = $this->_newkeyDecrypt($licensekey, $extensionName, $domain)) { $license = Mage::getModel('magenotification/license')->loadByLicenseExtension($licensekey, $extensionName); if (!$license->getId()) { $license->setActiveAt(now(true))->setDomains($licenseInfo->getDomains()); $responseCode = self::NEW_DOMAIN_SUCCESS; $licenseDomain = strlen($domain) > 38 ? substr($domain, 0, 38) : $domain; if ($licenseDomain != $licenseInfo->getDomains()) { $responseCode = self::LIMITED_DOMAIN_ERROR; } try { $license->setResponseCode($responseCode); $license->setSumCode($this->_getSumCode($license))->save(); } catch (Exception $e) { } } $result = new Varien_Object($license->getData()); $createdTime = $licenseInfo->getCreatedDate() ? $licenseInfo->getCreatedDate() : $license->getActiveAt(); $result->addData(array('users' => 1, 'created_time' => date('Y-m-d H:m:s', strtotime($createdTime)), 'activated_time' => $license->getActiveAt(), 'type' => $this->getOldLicenseType($licenseInfo->getType()), 'status' => 1, 'expired_time' => $licenseInfo->getExpiredTime())); if ($license->getSumCode() != $this->_getSumCode($license)) { try { $license->setResponseCode(self::GENERAL_ERROR); $license->setSumCode($this->_getSumCode($license))->save(); } catch (Exception $e) { } } elseif (($result->getType() == self::TRIAL_VERSION || $result->getType() == self::DEVELOPMENT) && $license->getResponseCode() > self::LIMITED_DOMAIN_ERROR) { $expiredTime = strtotime($license->getActiveAt()) + (int) $result->getExpiredTime() * 24 * 3600; if ($expiredTime < time()) { try { $license->setResponseCode(self::EXPIRED_TRIAL_LICENSE_KEY_ERROR); $license->setSumCode($this->_getSumCode($license))->save(); } catch (Exception $e) { } } } return $result->setResponseCode($license->getResponseCode()); } return new Varien_Object(array('response_code' => self::GENERAL_ERROR)); }
/** * Save AirMail message action * * @return void */ public function saveMessageAction() { $data = $this->_filterPostData($this->getRequest()->getPost()); $isError = false; $message = false; if ($data) { try { $data = Mage::getModel('core/input_filter_maliciousCode')->filter($data); $template = $this->_initTemplate('template_id'); $message = $this->_initMessage(); if (!$template->getId() && !$message->getTemplateId()) { $this->_getSession()->addError($this->__('Template for new AirMail Message does not exist.')); $this->_redirect('*/*/queue'); return; } $temporaryObject = new Varien_Object(); $temporaryObject->setData($data); if ($temporaryObject->getTemplateId()) { $message->setTemplateId($temporaryObject->getTemplateId()); } else { $message->setTemplateId($template->getId()); } if (!$message->getId()) { // set status for new messages only $message->setStatus(Mage_XmlConnect_Model_Queue::STATUS_IN_QUEUE); } elseif ($message->getStatus() != Mage_XmlConnect_Model_Queue::STATUS_IN_QUEUE) { $this->_getSession()->addError($this->__('Message can be edited when status of the message is "IN QUEUE" only.')); $this->_redirect('*/*/queue'); return; } switch ($temporaryObject->getType()) { case Mage_XmlConnect_Model_Queue::MESSAGE_TYPE_AIRMAIL: $message->setData('type', Mage_XmlConnect_Model_Queue::MESSAGE_TYPE_AIRMAIL); break; case Mage_XmlConnect_Model_Queue::MESSAGE_TYPE_PUSH: default: $message->setData('type', Mage_XmlConnect_Model_Queue::MESSAGE_TYPE_PUSH); break; } if ($temporaryObject->getExecTime()) { $message->setExecTime(Mage::getSingleton('core/date')->gmtDate(null, $temporaryObject->getExecTime())); } else { $message->setExecTime(new Zend_Db_Expr('NULL')); } if ($template->getId()) { $message->setAppCode($template->getAppCode()); } $message->setPushTitle($temporaryObject->getPushTitle()); $message->setMessageTitle($temporaryObject->getMessageTitle()); $message->setContent($temporaryObject->getContent()); $message->save(); } catch (Mage_Core_Exception $e) { $this->_getSession()->addException($e, $e->getMessage()); $isError = true; } catch (Exception $e) { $this->_getSession()->addException($e, $this->__('Unable to save message.')); $isError = true; Mage::logException($e); } } if ($isError) { if ($isError) { Mage::getSingleton('adminhtml/session')->setLoadSessionFlag(true); } $redirectParams = array(); if ($message && $message->getId()) { $redirectParams['id'] = $message->getId(); } else { $redirectParams['template_id'] = (int) $this->getRequest()->getParam('template_id'); } $this->_redirect('*/*/queueMessage', $redirectParams); } else { $this->_redirect('*/*/queue'); } }
public function getFileName(Varien_Object $item) { return $this->prepareFileName($item->getName()) . '.' . strtolower($item->getType()); }
public function getOptionValues() { $data = array(); $optionsArr = ''; $session = Mage::getSingleton('adminhtml/session'); if ($data = $session->getData('customoptions_data')) { if (isset($data['general']['hash_options'])) { $optionsArr = $data['general']['hash_options']; } } elseif (Mage::registry('customoptions_data')) { $data = Mage::registry('customoptions_data')->getData(); if (isset($data['hash_options'])) { $optionsArr = $data['hash_options']; } } $groupId = (int) $this->getRequest()->getParam('group_id'); if ($optionsArr) { $optionsArr = unserialize($optionsArr); } $storeOptionsArr = array(); $groupStore = Mage::getSingleton('customoptions/group_store')->loadByGroupAndStore($groupId, $this->getStoreId()); if ($groupStore->getHashOptions()) { $storeOptionsArr = unserialize($groupStore->getHashOptions()); } $product = Mage::getSingleton('catalog/product_option'); if (!$this->_values && $optionsArr) { $values = array(); $sortOrder = array(); $scope = (int) Mage::app()->getStore()->getConfig(Mage_Core_Model_Store::XML_PATH_PRICE_SCOPE); $optionItemCount = count($optionsArr); foreach ($optionsArr as $optionId => $option) { $option = new Varien_Object($option); $value = array(); if ($option->getIsDelete() != '1') { $value['id'] = $option->getOptionId(); $value['item_count'] = $optionItemCount; $value['option_id'] = $option->getOptionId(); $value['title'] = $this->htmlEscape(isset($storeOptionsArr[$optionId]['title']) ? $storeOptionsArr[$optionId]['title'] : $option->getTitle()); $value['type'] = $option->getType(); $value['is_require'] = $option->getIsRequire(); $value['is_enabled'] = $option->getIsEnabled(); $value['is_dependent'] = $option->getIsDependent(); $value['code'] = $this->htmlEscape($option->getCode()); $value['option_code'] = $option->getOptionCode(); $value['customoptions_is_onetime'] = $option->getCustomoptionsIsOnetime(); $value['qnty_input'] = $option->getQntyInput() ? 'checked' : ''; $value['qnty_input_disabled'] = $option->getType() == 'drop_down' || $option->getType() == 'radio' || $option->getType() == 'checkbox' ? '' : 'disabled'; $value['description'] = $this->htmlEscape(isset($storeOptionsArr[$optionId]['description']) ? $storeOptionsArr[$optionId]['description'] : $option->getDescription()); $value['block_title'] = $this->htmlEscape(isset($storeOptionsArr[$optionId]['block_title']) ? $storeOptionsArr[$optionId]['block_title'] : $option->getBlockTitle()); if (Mage::helper('customoptions')->isCustomerGroupsEnabled() && $option->getCustomerGroups() != null) { $value['customer_groups'] = implode(',', $option->getCustomerGroups()); } $value['in_group_id'] = $option->getInGroupId(); $value['in_group_id_view'] = $option->getInGroupId(); $value['sort_order'] = $this->_getSortOrder($option); if ($this->getStoreId() != '0') { $value['checkboxScopeTitle'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'title', !isset($storeOptionsArr[$optionId]['title'])); $value['scopeTitleDisabled'] = !isset($storeOptionsArr[$optionId]['title']) ? 'disabled' : null; $value['checkboxScopeDescription'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'description', !isset($storeOptionsArr[$optionId]['description'])); $value['scopeDescriptionDisabled'] = !isset($storeOptionsArr[$optionId]['description']) ? 'disabled' : null; $value['checkboxScopeBlockTitle'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'block_title', !isset($storeOptionsArr[$optionId]['block_title'])); $value['scopeBlockTitleDisabled'] = !isset($storeOptionsArr[$optionId]['block_title']) ? 'disabled' : null; } if ($product->getGroupByType($option->getType()) == Mage_Catalog_Model_Product_Option::OPTION_GROUP_SELECT) { $countValues = count($option->getValues()); if ($countValues > 0) { foreach ($option->getValues() as $key => $_value) { $_value = new Varien_Object($_value); $_value->setOptionTypeId($key); if ($_value->getIsDelete() != '1') { $defaultArray = $option->getDefault() !== null ? $option->getDefault() : array(); $value['optionValues'][$key] = array('item_count' => $countValues, 'option_id' => $option->getOptionId(), 'option_type_id' => $_value->getOptionTypeId(), 'title' => $this->htmlEscape(isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['title']) ? $storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['title'] : $_value->getTitle()), 'price' => $this->getPriceValue(isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['price']) ? $storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['price'] : $_value->getPrice(), $_value->getPriceType()), 'price_type' => isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['price_type']) ? $storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['price_type'] : $_value->getPriceType(), 'sku' => $this->htmlEscape($_value->getSku()), 'code' => $this->htmlEscape($_value->getCode()), 'tier' => $_value->getTier(), 'sort_order' => $this->_getSortOrder($_value), 'customoptions_qty' => $_value->getCustomoptionsQty(), 'checked' => array_search($_value->getOptionTypeId(), $defaultArray) !== false ? 'checked' : '', 'default_type' => $option->getType() == 'checkbox' || $option->getType() == 'multiple' ? 'checkbox' : 'radio', 'in_group_id' => $_value->getInGroupId(), 'in_group_id_view' => $_value->getInGroupId(), 'dependent_ids' => $_value->getDependentIds()); $value['optionValues'][$key]['image_button_label'] = Mage::helper('customoptions')->__('Add Image'); $imgHtml = Mage::helper('customoptions')->getImgHtml($_value->getImagePath(), $option->getId(), $_value->getOptionTypeId()); if ($imgHtml) { $value['optionValues'][$key]['image'] = $imgHtml; $value['optionValues'][$key]['image_button_label'] = Mage::helper('customoptions')->__('Change Image'); } if ($this->getStoreId() != '0') { $value['optionValues'][$key]['checkboxScopeTitle'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'title', !isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['title']), $_value->getOptionTypeId()); $value['optionValues'][$key]['scopeTitleDisabled'] = !isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['title']) ? 'disabled' : null; if ($scope == Mage_Core_Model_Store::PRICE_SCOPE_WEBSITE) { $value['optionValues'][$key]['checkboxScopePrice'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'price', is_null($_value->getstorePrice()), $_value->getOptionTypeId()); $value['optionValues'][$key]['scopePriceDisabled'] = is_null($_value->getStorePrice()) ? 'disabled' : null; } } } } $value['optionValues'] = array_values($value['optionValues']); } } else { $value['price'] = $this->getPriceValue(isset($storeOptionsArr[$optionId]['price']) ? $storeOptionsArr[$optionId]['price'] : $option->getPrice(), $option->getPriceType()); $value['price_type'] = isset($storeOptionsArr[$optionId]['price_type']) ? $storeOptionsArr[$optionId]['price_type'] : $option->getPriceType(); $value['sku'] = $this->htmlEscape($option->getSku()); $value['code'] = $this->htmlEscape($option->getCode()); $value['max_characters'] = $option->getMaxCharacters(); $value['file_extension'] = $option->getFileExtension(); $value['image_size_x'] = $option->getImageSizeX(); $value['image_size_y'] = $option->getImageSizeY(); $value['image_button_label'] = Mage::helper('customoptions')->__('Add Image'); $imgHtml = Mage::helper('customoptions')->getImgHtml($option->getImagePath(), $option->getId()); if ($imgHtml) { $value['image'] = $imgHtml; $value['image_button_label'] = Mage::helper('customoptions')->__('Change Image'); } if ($this->getStoreId() != '0' && $scope == Mage_Core_Model_Store::PRICE_SCOPE_WEBSITE) { $value['checkboxScopePrice'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'price', is_null($option->getStorePrice())); $value['scopePriceDisabled'] = is_null($option->getStorePrice()) ? 'disabled' : null; } } $values[] = new Varien_Object($value); } } $this->_values = $values; } return $this->_values ? $this->_values : array(); }
public function getOptionValues() { $data = array(); $optionsArr = ''; $data = $this->getTemplateData(); if (isset($data['hash_options'])) { $optionsArr = $data['hash_options']; } $zendDate = new Zend_Date(); $dateFormat = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT); $helper = Mage::helper('customoptions'); $helper->getCustomerGroups(); // init customer_groups for sort prices $groupId = (int) $this->getRequest()->getParam('group_id'); if ($optionsArr) { $optionsArr = unserialize($optionsArr); } $store = Mage::app()->getStore($this->getStoreId()); $storeOptionsArr = array(); $groupStore = Mage::getSingleton('customoptions/group_store')->loadByGroupAndStore($groupId, $this->getStoreId()); if ($groupStore->getHashOptions()) { $storeOptionsArr = unserialize($groupStore->getHashOptions()); } //print_r($storeOptionsArr); exit; $optionModel = Mage::getSingleton('catalog/product_option'); if (!$this->_values && $optionsArr) { $values = array(); $sortOrder = array(); $scope = (int) Mage::app()->getStore()->getConfig(Mage_Core_Model_Store::XML_PATH_PRICE_SCOPE); $optionItemCount = count($optionsArr); foreach ($optionsArr as $optionId => $option) { $option = new Varien_Object($option); $value = array(); if ($option->getIsDelete() != '1') { $value['id'] = $option->getOptionId(); $value['item_count'] = $optionItemCount; $value['option_id'] = $option->getOptionId(); $value['title'] = $this->htmlEscape(isset($storeOptionsArr[$optionId]['title']) ? $storeOptionsArr[$optionId]['title'] : $option->getTitle()); // old view_mode = hidden => to new type = 'hidden'; if ($optionModel->getGroupByType($option->getType()) == Mage_Catalog_Model_Product_Option::OPTION_GROUP_SELECT && $option->getViewMode() == 2) { $option->setType('hidden'); $option->setViewMode(1); } $value['type'] = $option->getType(); $value['is_require'] = $option->getIsRequire(); $value['view_mode'] = isset($storeOptionsArr[$optionId]['view_mode']) ? $storeOptionsArr[$optionId]['view_mode'] : $option->getViewMode(); $value['is_dependent'] = $option->getIsDependent(); $value['div_class'] = $option->getDivClass(); $value['sku_policy'] = $option->getSkuPolicy(); $value['customoptions_is_onetime'] = $option->getCustomoptionsIsOnetime(); $value['qnty_input'] = $option->getQntyInput() ? 'checked' : ''; $value['qnty_input_disabled'] = $option->getType() == 'multiple' || $option->getType() == 'hidden' ? 'disabled' : ''; $value['image_mode'] = $option->getImageMode(); $value['image_mode_disabled'] = $optionModel->getGroupByType($option->getType()) != Mage_Catalog_Model_Product_Option::OPTION_GROUP_SELECT ? 'disabled' : ''; $value['exclude_first_image'] = $option->getExcludeFirstImage() ? 'checked' : ''; $value['description'] = $this->htmlEscape(isset($storeOptionsArr[$optionId]['description']) ? $storeOptionsArr[$optionId]['description'] : $option->getDescription()); if ($helper->isCustomerGroupsEnabled() && $option->getCustomerGroups() != null) { $value['customer_groups'] = implode(',', $option->getCustomerGroups()); } if ($helper->isStoreViewsEnabled() && $option->getStoreViews() != null) { $value['store_views'] = implode(',', $option->getStoreViews()); } $value['in_group_id'] = $option->getInGroupId(); $value['in_group_id_view'] = $option->getInGroupId(); $value['sort_order'] = $this->_getSortOrder($option); if ($this->getStoreId() != '0') { $value['checkboxScopeTitle'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'title', !isset($storeOptionsArr[$optionId]['title'])); $value['scopeTitleDisabled'] = !isset($storeOptionsArr[$optionId]['title']) ? 'disabled' : null; $value['checkboxScopeViewMode'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'view_mode', !isset($storeOptionsArr[$optionId]['view_mode'])); $value['scopeViewModeDisabled'] = !isset($storeOptionsArr[$optionId]['view_mode']) ? 'disabled' : null; $value['checkboxScopeDescription'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'description', !isset($storeOptionsArr[$optionId]['description'])); $value['scopeDescriptionDisabled'] = !isset($storeOptionsArr[$optionId]['description']) ? 'disabled' : null; } if ($optionModel->getGroupByType($option->getType()) == Mage_Catalog_Model_Product_Option::OPTION_GROUP_SELECT) { $countValues = count($option->getValues()); if ($countValues > 0) { foreach ($option->getValues() as $key => $_value) { $_value = new Varien_Object($_value); $_value->setOptionTypeId($key); if ($_value->getIsDelete() != '1') { $defaultArray = $option->getDefault() !== null ? $option->getDefault() : array(); if (isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['price'])) { $_value->setPrice(floatval($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['price'])); } if (isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['price_type'])) { $_value->setPriceType($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['price_type']); } // for support old format: if (isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['special_price'])) { $_value->setSpecialPrice(floatval($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['special_price'])); } if (isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['special_comment'])) { $_value->setSpecialComment($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['special_comment']); } if ($_value->getSpecialPrice()) { $_value->setSpecials(array(array('customer_group_id' => 32000, 'price' => $_value->getSpecialPrice(), 'price_type' => 'fixed', 'comment' => $_value->getSpecialComment(), 'date_from' => '', 'date_to' => ''))); } $helper->applyLinkedBySkuDataToOption($_value, $_value->getSku(), $store, 0); $helper->calculateOptionSpecialPrice($_value, null, $helper->isSpecialPriceEnabled()); $priceDisabled = $_value->getIsSkuPrice(); list($skuClass, $viewProductBySkuHtml) = $this->getViewSkuData($_value->getSku()); if (!$helper->isSkuQtyLinkingEnabled() || $helper->getProductIdBySku($_value->getSku()) == 0) { $customoptionsQty = $_value->getCustomoptionsQty(); } else { list($customoptionsQty, $backorders) = $helper->getCustomoptionsQty($_value->getCustomoptionsQty(), $_value->getSku(), 0, null, null, null, true); } $value['optionValues'][$key] = array('item_count' => $countValues, 'option_id' => $option->getOptionId(), 'option_type_id' => $_value->getOptionTypeId(), 'title' => $this->htmlEscape(isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['title']) ? $storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['title'] : $_value->getTitle()), 'price' => $this->getPriceValue($_value->getPrice(), $_value->getPriceType()), 'price_type' => $_value->getPriceType(), 'price_disabled' => $priceDisabled, 'description' => $this->htmlEscape(isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['description']) ? $storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['description'] : $_value->getDescription()), 'cost' => $this->getPriceValue($_value->getCost(), 'fixed'), 'cost_disabled' => $_value->getIsSkuCost() ? 'disabled' : '', 'customoptions_qty' => $customoptionsQty, 'customoptions_qty_disabled' => $helper->isSkuQtyLinkingEnabled() && $helper->getProductIdBySku($_value->getSku()) ? 'disabled="disabled"' : '', 'sku' => $this->htmlEscape($_value->getSku()), 'sku_class' => $skuClass, 'view_product_by_sku_html' => $viewProductBySkuHtml, 'image_button_label' => $helper->__('Add Image'), 'sort_order' => $this->_getSortOrder($_value), 'checked' => array_search($_value->getOptionTypeId(), $defaultArray) !== false ? 'checked' : '', 'default_type' => $option->getType() == 'checkbox' || $option->getType() == 'multiple' || $option->getType() == 'multiswatch' || $option->getType() == 'hidden' ? 'checkbox' : 'radio', 'in_group_id' => $_value->getInGroupId(), 'in_group_id_view' => $_value->getInGroupId(), 'dependent_ids' => $_value->getDependentIds(), 'weight' => number_format(floatval($_value->getWeight()), 4, null, ''), 'weight_disabled' => $_value->getIsSkuWeight() ? 'disabled' : ''); // getImages $images = $_value->getImages(); if ($images) { $imagePath = $groupId . DS . $option->getId() . DS . $_value->getOptionTypeId() . DS; foreach ($images as $fileName) { if (substr($fileName, 0, 1) == '#') { // color $colorArr = array('id' => $option->getId(), 'select_id' => $_value->getOptionTypeId(), 'image_file' => $fileName, 'option_type_image_id' => $fileName, 'source' => 2); $value['optionValues'][$key]['images'][] = $colorArr; } else { // file $imgArr = $helper->getImgData($imagePath . $fileName, $option->getId(), $_value->getOptionTypeId()); if ($imgArr) { $imgArr['option_type_image_id'] = $imgArr['file_name']; $value['optionValues'][$key]['images'][] = $imgArr; } } } } elseif ($_value->getImagePath()) { // old format $imgArr = $helper->getImgData($_value->getImagePath(), $option->getId(), $_value->getOptionTypeId()); if ($imgArr) { $imgArr['option_type_image_id'] = $imgArr['file_name']; $value['optionValues'][$key]['images'][] = $imgArr; } } else { $value['optionValues'][$key]['image_tr_style'] = 'display:none'; } //getOptionValueSpecialPrices $specialPrices = isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['specials']) ? $storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['specials'] : $_value->getSpecials(); if ($specialPrices) { foreach ($specialPrices as $specialKey => $specialPrice) { $specialPrices[$specialKey]['price'] = $this->getPriceValue($specialPrice['price'], $specialPrice['price_type']); if (isset($specialPrice['date_from']) && $specialPrice['date_from']) { $specialPrices[$specialKey]['date_from'] = $zendDate->setDate($specialPrice['date_from'], Varien_Date::DATE_INTERNAL_FORMAT)->toString($dateFormat); } else { $specialPrices[$specialKey]['date_from'] = ''; } if (isset($specialPrice['date_to']) && $specialPrice['date_to']) { $specialPrices[$specialKey]['date_to'] = $zendDate->setDate($specialPrice['date_to'], Varien_Date::DATE_INTERNAL_FORMAT)->toString($dateFormat); } else { $specialPrices[$specialKey]['date_to'] = ''; } } usort($specialPrices, array($helper, '_sortPrices')); $value['optionValues'][$key]['specials'] = $specialPrices; } //getOptionValueTierPrices $tierPrices = isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['tiers']) ? $storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['tiers'] : $_value->getTiers(); if ($tierPrices) { foreach ($tierPrices as $tierKey => $tierPrice) { $tierPrices[$tierKey]['price'] = $this->getPriceValue($tierPrice['price'], $tierPrice['price_type']); } usort($tierPrices, array($helper, '_sortPrices')); $value['optionValues'][$key]['tiers'] = $tierPrices; } if ($this->getStoreId() != '0') { $value['optionValues'][$key]['checkboxScopeTitle'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'title', !isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['title']), $_value->getOptionTypeId()); $value['optionValues'][$key]['scopeTitleDisabled'] = !isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['title']) ? 'disabled' : null; $value['optionValues'][$key]['checkboxScopeDescription'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'description', !isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['description']), $_value->getOptionTypeId()); $value['optionValues'][$key]['scopeDescriptionDisabled'] = !isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['description']) ? 'disabled' : null; //if ($scope == Mage_Core_Model_Store::PRICE_SCOPE_WEBSITE) { if (isset($storeOptionsArr[$optionId]['values'][$_value->getOptionTypeId()]['price'])) { $scopePrice = true; } else { $scopePrice = false; } if (!$priceDisabled) { $value['optionValues'][$key]['checkboxScopePrice'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'price', !$scopePrice, $_value->getOptionTypeId()); } $value['optionValues'][$key]['scopePriceDisabled'] = !$scopePrice ? 'disabled' : null; //} } } } $value['optionValues'] = array_values($value['optionValues']); } } else { if (isset($storeOptionsArr[$optionId]['price'])) { $option->setPrice(floatval($storeOptionsArr[$optionId]['price'])); } if (isset($storeOptionsArr[$optionId]['price_type'])) { $option->setPriceType($storeOptionsArr[$optionId]['price_type']); } $helper->applyLinkedBySkuDataToOption($option, $option->getSku(), $store, 0); $helper->calculateOptionSpecialPrice($option, null, false); $priceDisabled = $option->getIsSkuPrice(); list($skuClass, $viewProductBySkuHtml) = $this->getViewSkuData($option->getSku()); $value['price'] = $this->getPriceValue($option->getPrice(), $option->getPriceType()); $value['price_type'] = $option->getPriceType(); $value['price_disabled'] = $priceDisabled; $value['sku'] = $this->htmlEscape($option->getSku()); $value['sku_class'] = $skuClass; $value['view_product_by_sku_html'] = $viewProductBySkuHtml; $value['max_characters'] = $option->getMaxCharacters(); $value['default_text'] = $this->htmlEscape(isset($storeOptionsArr[$optionId]['default_text']) ? $storeOptionsArr[$optionId]['default_text'] : $option->getDefaultText()); $value['file_extension'] = $option->getFileExtension(); $value['image_size_x'] = $option->getImageSizeX(); $value['image_size_y'] = $option->getImageSizeY(); $value['image_button_label'] = $helper->__('Add Image'); $imgHtml = $helper->getImgHtml($helper->getImgData($option->getImagePath(), $option->getId())); if ($imgHtml) { $value['image'] = $imgHtml; $value['image_button_label'] = $helper->__('Change Image'); } if ($this->getStoreId() != '0') { //&& $scope == Mage_Core_Model_Store::PRICE_SCOPE_WEBSITE if (!$priceDisabled) { $value['checkboxScopePrice'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'price', !isset($storeOptionsArr[$optionId]['price'])); } $value['scopePriceDisabled'] = !isset($storeOptionsArr[$optionId]['price']) ? 'disabled' : null; $value['checkboxScopeDefaultText'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'default_text', !isset($storeOptionsArr[$optionId]['default_text'])); $value['scopeDefaultTextDisabled'] = !isset($storeOptionsArr[$optionId]['default_text']) ? 'disabled' : null; } } $values[] = new Varien_Object($value); } } $this->_values = $values; } return $this->_values ? $this->_values : array(); }
/** * Save AirMail message action * * @return null */ public function saveMessageAction() { $data = $this->_filterPostData($this->getRequest()->getPost()); $isError = false; $message = false; if ($data) { try { $data = Mage::getModel('core/input_filter_maliciousCode')->filter($data); $template = $this->_initTemplate('template_id'); $message = $this->_initMessage(); if (!$template->getId() && !$message->getTemplateId()) { $this->_getSession()->addError($this->__('Template for new AirMail Message does not exist.')); $this->_redirect('*/*/queue'); return; } /** @var $app Mage_XmlConnect_Model_Application */ $app = Mage::getModel('xmlconnect/application')->loadByCode($template->getAppCode()); $deviceType = Mage::helper('xmlconnect')->getDeviceType($app); if ($deviceType == Mage_XmlConnect_Helper_Data::DEVICE_TYPE_ANDROID && $data['type'] == Mage_XmlConnect_Model_Queue::MESSAGE_TYPE_AIRMAIL) { $this->_getSession()->addError($this->__('Android doesn\'t support AirMail message type.')); $redirectParams = $this->_getQueueMessageParams($message); $action = $message->getId() ? 'editQueue' : 'queueMessage'; $this->_redirect('*/*/' . $action, $redirectParams); return; } $temporaryObject = new Varien_Object(); $temporaryObject->setData($data); if ($temporaryObject->getTemplateId()) { $message->setTemplateId($temporaryObject->getTemplateId()); } else { $message->setTemplateId($template->getId()); } if (!$message->getId()) { // set status for new messages only $message->setStatus(Mage_XmlConnect_Model_Queue::STATUS_IN_QUEUE); } elseif ($message->getStatus() != Mage_XmlConnect_Model_Queue::STATUS_IN_QUEUE) { $this->_getSession()->addError($this->__('Message can be edited when status of the message is "In Queue" only.')); $this->_redirect('*/*/queue'); return; } switch ($temporaryObject->getType()) { case Mage_XmlConnect_Model_Queue::MESSAGE_TYPE_AIRMAIL: $message->setData('type', Mage_XmlConnect_Model_Queue::MESSAGE_TYPE_AIRMAIL); break; case Mage_XmlConnect_Model_Queue::MESSAGE_TYPE_PUSH: default: $message->setData('type', Mage_XmlConnect_Model_Queue::MESSAGE_TYPE_PUSH); break; } if ($temporaryObject->getExecTime()) { $execTime = Mage::getSingleton('core/date')->gmtDate(null, $temporaryObject->getExecTime()); $message->setExecTime($execTime ? $execTime : Mage::getSingleton('core/date')->gmtDate()); } else { $message->setExecTime(new Zend_Db_Expr('NULL')); } if ($template->getId()) { $message->setAppCode($template->getAppCode()); } $message->setPushTitle($temporaryObject->getPushTitle()); $message->setMessageTitle($temporaryObject->getMessageTitle()); $message->setContent($temporaryObject->getContent()); $message->save(); } catch (Mage_Core_Exception $e) { $this->_getSession()->addException($e, $e->getMessage()); $isError = true; } catch (Exception $e) { $this->_getSession()->addException($e, $this->__('Unable to save message.')); $isError = true; Mage::logException($e); } } if ($isError) { if ($isError) { Mage::getSingleton('adminhtml/session')->setLoadSessionFlag(true); } $redirectParams = $this->_getQueueMessageParams($message); $this->_redirect('*/*/queueMessage', $redirectParams); } else { $this->_redirect('*/*/queue'); } }
protected function _prepareArrayRow(Varien_Object $row) { $row->setData('option_extra_attr_' . $this->getRenderer('attribute')->calcOptionHash($row->getAttribute()), 'selected="selected"'); $row->setData('option_extra_attr_' . $this->getRenderer('type')->calcOptionHash($row->getType()), 'selected="selected"'); }
/** * Submit action * * @return string */ public function submitAction() { $params = $this->getRequest()->getParams(); $response = new Varien_Object(); try { $request = $this->_getRequestModel()->setRequest($params['request'])->dispatch(); $response->setStatus('OK'); $response->setRequest($params['request']); $response->setMessage($request->getMessage()); $response->setType($request->getType()); if ($request->getType() == MageHack_MageConsole_Model_Abstract::RESPONSE_TYPE_PROMPT) { $key = $this->_savePrompt($params['request']); $response->setId($key); } } catch (Exception $e) { $response->setStatus('ERROR'); $response->setType(MageHack_MageConsole_Model_Abstract::RESPONSE_TYPE_ERROR); $response->setMessage($e->getMessage()); } if ($response->getType() == 'FILE') { $requestDetails = preg_split('/\\s+/', $params['request']); $this->_prepareDownloadResponse($requestDetails[1] . '_export.csv', $response->getMessage()); } else { $this->getResponse()->setBody($response->toJson()); } }
/** * Do a flush on the ESI blocks * * Events: * adminhtml_cache_refresh_type * * @param Varien_Object $eventObject * @return null */ public function banCacheType($eventObject) { switch ($eventObject->getType()) { //note this is the name of the container xml tag in config.xml, // **NOT** the cache tag name case Mage::helper('turpentine/esi')->getMageCacheName(): if (Mage::helper('turpentine/esi')->getEsiEnabled()) { $result = $this->_getVarnishAdmin()->flushUrl('/turpentine/esi/getBlock/'); Mage::dispatchEvent('turpentine_ban_esi_cache', $result); $this->_checkResult($result); } break; case Mage::helper('turpentine/varnish')->getMageCacheName(): $this->banAllCache($eventObject); break; } }