1: <?php
2: /**
3: * Magento
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * that is bundled with this package in the file LICENSE.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-3.0.php
11: * If you did not receive a copy of the license and are unable to
12: * obtain it through the world-wide-web, please send an email
13: * to license@magentocommerce.com so we can send you a copy immediately.
14: *
15: * DISCLAIMER
16: *
17: * Do not edit or add to this file if you wish to upgrade Magento to newer
18: * versions in the future. If you wish to customize Magento for your
19: * needs please refer to http://www.magentocommerce.com for more information.
20: *
21: * @category Mage
22: * @package Mage_Connect
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27:
28: /**
29: * Auth session model
30: *
31: * @category Mage
32: * @package Mage_Connect
33: * @author Magento Core Team <core@magentocommerce.com>
34: */
35: class Mage_Connect_Model_Session extends Mage_Core_Model_Session_Abstract
36: {
37:
38: /**
39: * Contructor
40: */
41: public function __construct()
42: {
43: $this->init('adminhtml');
44: }
45:
46: /**
47: * Retrieve parameters of extension from session.
48: * Compatible with old version extension info file.
49: *
50: * @return array
51: */
52: public function getCustomExtensionPackageFormData()
53: {
54: $data = $this->getData('custom_extension_package_form_data');
55: /* convert Maintainers to Authors */
56: if (!isset($data['authors']) || count($data['authors']) == 0) {
57: if (isset($data['maintainers'])) {
58: $data['authors']['name'] = array();
59: $data['authors']['user'] = array();
60: $data['authors']['email'] = array();
61: foreach ($data['maintainers']['name'] as $i => $name) {
62: if (!$data['maintainers']['name'][$i] && !$data['maintainers']['handle'][$i] && !$data['maintainers']['email'][$i]) {
63: continue;
64: }
65: array_push($data['authors']['name'], $data['maintainers']['name'][$i]);
66: array_push($data['authors']['user'], $data['maintainers']['handle'][$i]);
67: array_push($data['authors']['email'], $data['maintainers']['email'][$i]);
68: }
69: // Convert channel from previous version for entire package
70: if (isset($data['channel'])) {
71: $data['channel'] = Mage::helper('connect')->convertChannelFromV1x($data['channel']);
72: }
73: // Convert channel from previous version for each required package
74: $nRequiredPackages = count($data['depends']['package']['channel']);
75: for ($i = 0; $i < $nRequiredPackages; $i++) {
76: $channel = $data['depends']['package']['channel'][$i];
77: if ($channel) {
78: $data['depends']['package']['channel'][$i] = Mage::helper('connect')->convertChannelFromV1x($channel);
79: }
80: }
81: }
82: }
83:
84: /* convert Release version to Version */
85: if (!isset($data['version'])) {
86: if (isset($data['release_version'])) {
87: $data['version'] = $data['release_version'];
88: }
89: }
90: /* convert Release stability to Stability */
91: if (!isset($data['stability'])) {
92: if (isset($data['release_stability'])) {
93: $data['stability'] = $data['release_stability'];
94: }
95: }
96: /* convert contents */
97: if (!isset($data['contents']['target'])) {
98: $data['contents']['target'] = $data['contents']['role'];
99: }
100: return $data;
101: }
102:
103: }
104: