My_Custom_Downloadable_Product - Version 1.0.0

Version Notes

the extension already tested in site online

Download this release

Release Info

Developer elmarrouani said
Extension My_Custom_Downloadable_Product
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (27) hide show
  1. app/code/community/Arabgento/Freed/Block/Adminhtml/AClinks.php +21 -0
  2. app/code/community/Arabgento/Freed/Block/Adminhtml/Alinks.php +12 -0
  3. app/code/community/Arabgento/Freed/Block/Adminhtml/Clinks.php +15 -0
  4. app/code/community/Arabgento/Freed/Block/Adminhtml/Clinkstest.php +17 -0
  5. app/code/community/Arabgento/Freed/Block/Adminhtml/Freed.php +11 -0
  6. app/code/community/Arabgento/Freed/Block/Adminhtml/Freed/Grid.php +98 -0
  7. app/code/community/Arabgento/Freed/Block/Adminhtml/Freed/Grid1.php +60 -0
  8. app/code/community/Arabgento/Freed/Block/Adminhtml/PClinks.php +21 -0
  9. app/code/community/Arabgento/Freed/Block/Adminhtml/Plinks.php +15 -0
  10. app/code/community/Arabgento/Freed/Block/Adminhtml/Plinks1.php +15 -0
  11. app/code/community/Arabgento/Freed/Block/Privateproducts/Edit.php +60 -0
  12. app/code/community/Arabgento/Freed/Block/Privateproducts/List.php +163 -0
  13. app/code/community/Arabgento/Freed/Helper/Data.php +11 -0
  14. app/code/community/Arabgento/Freed/Model/Freed.php +29 -0
  15. app/code/community/Arabgento/Freed/Model/Mysql4/Freed.php +8 -0
  16. app/code/community/Arabgento/Freed/Model/Mysql4/Freed/Collection.php +8 -0
  17. app/code/community/Arabgento/Freed/Model/Observer.php +241 -0
  18. app/code/community/Arabgento/Freed/controllers/Adminhtml/FreedController.php +61 -0
  19. app/code/community/Arabgento/Freed/controllers/CusController.php +121 -0
  20. app/code/community/Arabgento/Freed/etc/config.xml +221 -0
  21. app/code/community/Arabgento/Freed/sql/freed_setup/mysql4-install-0.1.0.php +27 -0
  22. app/design/adminhtml/default/default/layout/freed.xml +31 -0
  23. app/design/frontend/base/default/layout/freed.xml +71 -0
  24. app/design/frontend/base/default/template/arabgento/customer/products/edit.phtml +60 -0
  25. app/design/frontend/base/default/template/arabgento/customer/products/list.phtml +78 -0
  26. app/etc/modules/Arabgento_FreedCommunity.xml +9 -0
  27. package.xml +19 -0
app/code/community/Arabgento/Freed/Block/Adminhtml/AClinks.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Arabgento_Freed_Block_Adminhtml_AClinks extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
3
+ {
4
+ public function render(Varien_Object $row)
5
+ {
6
+ $value = $row->getData($this->getColumn()->getIndex());
7
+ if($value==1)
8
+ {
9
+ return "<a href='".Mage::getUrl('freed/adminhtml_freed/grid', array('product_id' => $this->_getValue($row),'conv' => 0,'_current' => true,'_absolute' => true))."'>".Mage::helper('catalog')->__("Disable")."</a>";
10
+ }
11
+ else
12
+ {
13
+ return "<a href='".Mage::getUrl('freed/adminhtml_freed/grid', array('product_id' => $this->_getValue($row),'conv' => 1,'_current' => true,'_absolute' => true))."'>".Mage::helper('catalog')->__("Enable")."</a>";
14
+ }
15
+
16
+
17
+
18
+ }
19
+
20
+
21
+ }
app/code/community/Arabgento/Freed/Block/Adminhtml/Alinks.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Arabgento_Freed_Block_Adminhtml_Alinks extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
3
+ {
4
+ public function render(Varien_Object $row)
5
+ {
6
+ $value = $row->getData($this->getColumn()->getIndex());
7
+ return $value;
8
+
9
+ }
10
+
11
+
12
+ }
app/code/community/Arabgento/Freed/Block/Adminhtml/Clinks.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Arabgento_Freed_Block_Adminhtml_Clinks extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
3
+ {
4
+ public function render(Varien_Object $row)
5
+ {
6
+ $value = $row->getData($this->getColumn()->getIndex());
7
+ $actions=$this->getColumn()->getActions();
8
+ $key=Mage::getSingleton('adminhtml/url')->getSecretKey("customer","edit");
9
+
10
+ return "<a href='".Mage::getUrl('././admin/customer/edit', array('id' => $this->_getValue($row),'key' => $key,'_current' => true,'_absolute' => true))."'>".$value."</a>";
11
+
12
+ }
13
+
14
+
15
+ }
app/code/community/Arabgento/Freed/Block/Adminhtml/Clinkstest.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Arabgento_Freed_Block_Adminhtml_Clinkstest extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
3
+ {
4
+ public function render(Varien_Object $row)
5
+ {
6
+ $value = $row->getData($this->getColumn()->getIndex());
7
+ $value1 = $this->getColumn()->getGetter();
8
+ $value2 = $row->getData($value1["product_name"]);
9
+ return $value2;
10
+ die();
11
+
12
+ return $this->_getValue($row)." ".$value;
13
+
14
+ }
15
+
16
+
17
+ }
app/code/community/Arabgento/Freed/Block/Adminhtml/Freed.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Arabgento_Freed_Block_Adminhtml_Freed extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ $this->_controller = 'adminhtml_freed';
7
+ $this->_blockGroup = 'freed';
8
+ $this->_headerText = Mage::helper('freed')->__('Manage commande');
9
+ parent::__construct();
10
+ }
11
+ }
app/code/community/Arabgento/Freed/Block/Adminhtml/Freed/Grid.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Arabgento_Freed_Block_Adminhtml_Freed_Grid extends Mage_Adminhtml_Block_Widget_Grid
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+ $this->setId('freedGrid');
8
+ $this->setDefaultSort('product_id');
9
+ $this->setDefaultDir('Desc');
10
+ $this->setUseAjax(false);
11
+ $this->setSaveParametersInSession(true);
12
+ }
13
+
14
+
15
+ protected function _prepareCollection()
16
+ {
17
+
18
+ $collection = Mage::getModel('freed/freed')->getCollection();
19
+ $collection->setOrder('freed_create', 'DESC');
20
+ $this->setCollection($collection);
21
+
22
+ return parent::_prepareCollection();
23
+ }
24
+
25
+ protected function _prepareColumns()
26
+ {
27
+
28
+ $this->addColumn('product_name',
29
+ array(
30
+ 'header' => Mage::helper('freed')->__('Product Name'),
31
+ 'width' => '100',
32
+ 'type' => 'action',
33
+ 'getter' => 'getProductId',
34
+ 'renderer' => 'freed/adminhtml_Plinks',
35
+ 'actions' => array(
36
+ array(
37
+ 'field' => 'id'
38
+ )
39
+ ),
40
+ 'index' => 'product_name',
41
+ 'is_system' => true,
42
+ ));
43
+ $this->addColumn('product_link', array(
44
+ 'header' => Mage::helper('catalog')->__('Zip File'),
45
+ 'index' => 'product_link',
46
+ 'renderer' => 'freed/adminhtml_Alinks'
47
+
48
+ ));
49
+ $this->addColumn('costumer_name', array(
50
+ 'header' => Mage::helper('catalog')->__('Costumer Name'),
51
+ 'width' => '100',
52
+ 'type' => 'action',
53
+ 'getter' => 'getCostumerId',
54
+ 'renderer' => 'freed/adminhtml_Clinks',
55
+ 'actions' => array(
56
+ array(
57
+ 'field' => 'id'
58
+ )
59
+ ),
60
+ 'index' => 'costumer_name'
61
+ ));
62
+ $this->addColumn('pied_admin', array(
63
+ 'header' => Mage::helper('catalog')->__('Pied from admin'),
64
+ 'type' => 'action',
65
+ 'getter' => 'getProductId',
66
+ 'renderer' => 'freed/adminhtml_AClinks',
67
+ 'actions' => array(
68
+ array(
69
+ 'field' => 'id'
70
+ )
71
+ ),
72
+ 'index' => 'pied_admin'
73
+ ));
74
+ $this->addColumn('pied_client', array(
75
+ 'header' => Mage::helper('catalog')->__('Pied from client'),
76
+ 'renderer' => 'freed/adminhtml_PClinks',
77
+ 'index' => 'pied_client'
78
+ ));
79
+
80
+ $this->addColumn('freed_create', array(
81
+ 'header' => Mage::helper('catalog')->__('created'),
82
+ 'index' => 'freed_create'
83
+ ));
84
+ $this->addColumn('freed_modify', array(
85
+ 'header' => Mage::helper('catalog')->__('modified'),
86
+ 'index' => 'freed_modify'
87
+ ));
88
+
89
+ return parent::_prepareColumns();
90
+ }
91
+
92
+ public function getGridUrl()
93
+ {
94
+ return $this->getUrl('*/*/grid', array('_current'=>true));
95
+ }
96
+
97
+
98
+ }
app/code/community/Arabgento/Freed/Block/Adminhtml/Freed/Grid1.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Arabgento_Freed_Block_Adminhtml_Freed_Grid1 extends Mage_Adminhtml_Block_Widget_Grid
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+ $this->setId('freedGrid1');
8
+ $this->setDefaultSort('product_id');
9
+ $this->setDefaultDir('Desc');
10
+ $this->setUseAjax(false);
11
+ $this->setSaveParametersInSession(true);
12
+ }
13
+
14
+
15
+ protected function _prepareCollection()
16
+ {
17
+
18
+ $collection = Mage::getModel('catalog/product')->getCollection()
19
+ ->addFieldToFilter('nbrdownload', array('gt' =>0))
20
+ ->addAttributeToFilter('name', array('nin' =>array(Null)))
21
+ ->setOrder('nbrdownload', 'DESC');
22
+ $this->setCollection($collection);
23
+
24
+ return parent::_prepareCollection();
25
+ }
26
+
27
+ protected function _prepareColumns()
28
+ {
29
+
30
+ $this->addColumn('product_name',
31
+ array(
32
+ 'header' => Mage::helper('freed')->__('Product Name'),
33
+ 'type' => 'action',
34
+ 'getter' => 'getId',
35
+ 'renderer' => 'freed/adminhtml_Plinks1',
36
+ 'actions' => array(
37
+ array(
38
+ 'field' => 'id'
39
+ )
40
+ ),
41
+ 'index' => 'name',
42
+ 'is_system' => true,
43
+ ));
44
+ $this->addColumn('nbr_download', array(
45
+ 'header' => Mage::helper('catalog')->__('NBR Download'),
46
+ 'index' => 'nbrdownload',
47
+
48
+ ));
49
+
50
+
51
+ return parent::_prepareColumns();
52
+ }
53
+
54
+ public function getGridUrl()
55
+ {
56
+ return $this->getUrl('*/*/grid1', array('_current'=>true));
57
+ }
58
+
59
+
60
+ }
app/code/community/Arabgento/Freed/Block/Adminhtml/PClinks.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Arabgento_Freed_Block_Adminhtml_PClinks extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
3
+ {
4
+ public function render(Varien_Object $row)
5
+ {
6
+ $value = $row->getData($this->getColumn()->getIndex());
7
+ if($value==1)
8
+ {
9
+ return Mage::helper('catalog')->__('Want convert');
10
+ }
11
+ else
12
+ {
13
+ return Mage::helper('catalog')->__("Don't want convert");
14
+ }
15
+
16
+
17
+
18
+ }
19
+
20
+
21
+ }
app/code/community/Arabgento/Freed/Block/Adminhtml/Plinks.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Arabgento_Freed_Block_Adminhtml_Plinks extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
3
+ {
4
+ public function render(Varien_Object $row)
5
+ {
6
+ $value = $row->getData($this->getColumn()->getIndex());
7
+ $actions=$this->getColumn()->getActions();
8
+ $key=Mage::getSingleton('adminhtml/url')->getSecretKey("catalog_product","edit");
9
+
10
+ return "<a href='".Mage::getUrl('././admin/catalog_product/edit', array('id' => $this->_getValue($row),'key' => $key,'_current' => true,'_absolute' => true))."'>".$value."</a>";
11
+
12
+ }
13
+
14
+
15
+ }
app/code/community/Arabgento/Freed/Block/Adminhtml/Plinks1.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Arabgento_Freed_Block_Adminhtml_Plinks1 extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
3
+ {
4
+ public function render(Varien_Object $row)
5
+ {
6
+ $value = $row->getData($this->getColumn()->getIndex());
7
+ $actions=$this->getColumn()->getActions();
8
+ $key=Mage::getSingleton('adminhtml/url')->getSecretKey("catalog_product","edit");
9
+
10
+ return "<a href='".Mage::getUrl('././admin/catalog_product/edit', array('id' => $this->_getValue($row),'key' => $key,'_current' => true,'_absolute' => true))."'>".$value."</a>";
11
+
12
+ }
13
+
14
+
15
+ }
app/code/community/Arabgento/Freed/Block/Privateproducts/Edit.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Downloadable
23
+ * @copyright Copyright (c) 2011 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
+ * Block to display downloadable links bought by customer
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Downloadable
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Arabgento_Freed_Block_Privateproducts_Edit extends Mage_Core_Block_Template
35
+ {
36
+
37
+ public function getProduct()
38
+ {
39
+ $param=$this->getRequest()->getParam('product_id');
40
+ $prd=Mage::getModel('catalog/product')->load($param);
41
+ return $prd;
42
+ }
43
+ public function getProductFreed()
44
+ {
45
+ $param=$this->getRequest()->getParam('product_id');
46
+ $session = Mage::getSingleton('customer/session');
47
+ $prdpurs = Mage::getResourceModel('freed/freed_collection')
48
+ ->addFieldToFilter('costumer_id', $session->getCustomerId())
49
+ ->addFieldToFilter('product_id', $param);
50
+ $prdFreed=NULL;
51
+ foreach ($prdpurs as $prdpur) {
52
+ $prdFreed = $prdpur;
53
+ }
54
+ return $prdFreed;
55
+ }
56
+ public function getConfirmUrl()
57
+ {
58
+ return $this->getUrl('freed/cus/confirm');
59
+ }
60
+ }
app/code/community/Arabgento/Freed/Block/Privateproducts/List.php ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Downloadable
23
+ * @copyright Copyright (c) 2011 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
+ * Block to display downloadable links bought by customer
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Downloadable
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Arabgento_Freed_Block_Privateproducts_List extends Mage_Core_Block_Template
35
+ {
36
+
37
+ /**
38
+ * Class constructor
39
+ */
40
+ public function __construct()
41
+ {
42
+ parent::__construct();
43
+ $session = Mage::getSingleton('customer/session');
44
+ $purchased = Mage::getResourceModel('downloadable/link_purchased_collection')
45
+ ->addFieldToFilter('customer_id', $session->getCustomerId())
46
+ ->addOrder('created_at', 'desc');
47
+ $this->setPurchased($purchased);
48
+ $purchasedIds = array();
49
+ foreach ($purchased as $_item) {
50
+ $purchasedIds[] = $_item->getId();
51
+ }
52
+
53
+ if (empty($purchasedIds)) {
54
+ $purchasedIds = array(null);
55
+ }
56
+ $purchasedItems = Mage::getResourceModel('downloadable/link_purchased_item_collection')
57
+ ->addFieldToFilter('purchased_id', array('in' => $purchasedIds))
58
+ ->addFieldToFilter('product_id', array('in' => $this->getCust()))
59
+ ->setOrder('item_id', 'desc');
60
+ $this->setItems($purchasedItems);
61
+ }
62
+
63
+ protected function getCust()
64
+ {
65
+ $session = Mage::getSingleton('customer/session');
66
+ $purchasedPrivates = Mage::getResourceModel('freed/freed_collection')
67
+ ->addFieldToFilter('costumer_id', $session->getCustomerId());
68
+ $purchasedPrivateIds = array();
69
+ foreach ($purchasedPrivates as $_itemPrv) {
70
+ $purchasedPrivateIds[] = $_itemPrv->getProductId();
71
+ }
72
+ if (empty($purchasedPrivateIds)) {
73
+ $purchasedPrivateIds = array(null);
74
+ }
75
+ return $purchasedPrivateIds;
76
+ }
77
+ /**
78
+ * Enter description here...
79
+ *
80
+ * @return Mage_Downloadable_Block_Customer_Products_List
81
+ */
82
+ protected function _prepareLayout()
83
+ {
84
+ parent::_prepareLayout();
85
+ $pager = $this->getLayout()->createBlock('page/html_pager', 'downloadable.customer.products.pager')
86
+ ->setCollection($this->getItems());
87
+ $this->setChild('pager', $pager);
88
+ $this->getItems()->load();
89
+ foreach ($this->getItems() as $item) {
90
+ $item->setPurchased($this->getPurchased()->getItemById($item->getPurchasedId()));
91
+ }
92
+ return $this;
93
+ }
94
+
95
+ /**
96
+ * Return order view url
97
+ *
98
+ * @param integer $orderId
99
+ * @return string
100
+ */
101
+ public function getOrderViewUrl($orderId)
102
+ {
103
+ return $this->getUrl('sales/order/view', array('order_id' => $orderId));
104
+ }
105
+ /**
106
+ * Return order view url
107
+ *
108
+ * @param integer $orderId
109
+ * @return string
110
+ */
111
+ public function getEditUrl($productId)
112
+ {
113
+ return $this->getUrl('freed/cus/edit', array('product_id' => $productId));
114
+ }
115
+ /**
116
+ * Enter description here...
117
+ *
118
+ * @return string
119
+ */
120
+ public function getBackUrl()
121
+ {
122
+ if ($this->getRefererUrl()) {
123
+ return $this->getRefererUrl();
124
+ }
125
+ return $this->getUrl('customer/account/');
126
+ }
127
+
128
+ /**
129
+ * Return number of left downloads or unlimited
130
+ *
131
+ * @return string
132
+ */
133
+ public function getRemainingDownloads($item)
134
+ {
135
+ if ($item->getNumberOfDownloadsBought()) {
136
+ $downloads = $item->getNumberOfDownloadsBought() - $item->getNumberOfDownloadsUsed();
137
+ return $downloads;
138
+ }
139
+ return Mage::helper('downloadable')->__('Unlimited');
140
+ }
141
+
142
+ /**
143
+ * Return url to download link
144
+ *
145
+ * @param Mage_Downloadable_Model_Link_Purchased_Item $item
146
+ * @return string
147
+ */
148
+ public function getDownloadUrl($item)
149
+ {
150
+ return $this->getUrl('downloadable/download/link', array('id' => $item->getLinkHash(), '_secure' => true));
151
+ }
152
+
153
+ /**
154
+ * Return true if target of link new window
155
+ *
156
+ * @return bool
157
+ */
158
+ public function getIsOpenInNewWindow()
159
+ {
160
+ return Mage::getStoreConfigFlag(Mage_Downloadable_Model_Link::XML_PATH_TARGET_NEW_WINDOW);
161
+ }
162
+
163
+ }
app/code/community/Arabgento/Freed/Helper/Data.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Arabgento_Freed_Helper_Data extends Mage_Core_Helper_Abstract
4
+
5
+ {
6
+ public function getProductName()
7
+ {
8
+ return "ok";
9
+ }
10
+
11
+ }
app/code/community/Arabgento/Freed/Model/Freed.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Arabgento_Freed_Model_Freed extends Mage_Core_Model_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('freed/freed');
8
+ }
9
+ public function convertPiedClient($pi,$ci,$forsell)
10
+ {
11
+ $purchasedPrivates = Mage::getResourceModel('freed/freed_collection')
12
+ ->addFieldToFilter('costumer_id', $ci)
13
+ ->addFieldToFilter('product_id',$pi );
14
+ foreach ($purchasedPrivates as $_itemPrv) {
15
+ $_itemPrv->setPiedClient((int)$forsell);
16
+ $_itemPrv->save();
17
+ }
18
+ }
19
+ public function convertPiedAdmin($pi,$conv)
20
+ {
21
+ $purchasedPrivates = Mage::getResourceModel('freed/freed_collection')
22
+ ->addFieldToFilter('product_id',$pi);
23
+ foreach ($purchasedPrivates as $_itemPrv) {
24
+ $_itemPrv->setPiedAdmin((int)$conv);
25
+ $_itemPrv->save();
26
+ }
27
+ }
28
+
29
+ }
app/code/community/Arabgento/Freed/Model/Mysql4/Freed.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Arabgento_Freed_Model_Mysql4_Freed extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ $this->_init('freed/freed','freed_id');
7
+ }
8
+ }
app/code/community/Arabgento/Freed/Model/Mysql4/Freed/Collection.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Arabgento_Freed_Model_Mysql4_Freed_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ $this->_init('freed/freed');
7
+ }
8
+ }
app/code/community/Arabgento/Freed/Model/Observer.php ADDED
@@ -0,0 +1,241 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Arabgento_Freed_Model_Observer {
4
+
5
+ public function change_order($observer) {
6
+ $order = $observer->getEvent()->getOrder();
7
+ $items = $order->getAllItems();
8
+ //$items->removeItem($item->getId())->save();
9
+
10
+
11
+
12
+
13
+
14
+ foreach($items as $item)
15
+ {
16
+
17
+ //echo "<script type='text/javascript'>alert('".$item->getSku()."')</script>";
18
+ //die();
19
+
20
+
21
+ /**
22
+ if (isset($options['options'])) {
23
+ foreach ($options['options'] as $optionValues) {
24
+ if ($optionValues['value']) {
25
+ echo '&nbsp;<strong><i>'. $optionValues['label'].'</i></strong>: ';
26
+
27
+ $_printValue = isset($optionValues['print_value']) ? $optionValues['print_value'] : strip_tags($optionValues['value']);
28
+ $values = explode(', ', $_printValue);
29
+ foreach ($values as $value) {
30
+ if (is_array($value))
31
+ foreach ($value as $_value)
32
+ echo $_value;
33
+ else echo $value;
34
+ }
35
+ echo '<br />';
36
+ }
37
+ }
38
+ }
39
+ */
40
+
41
+
42
+ if($item->getSku()=="tiket1.0-tiket-file")
43
+ {
44
+
45
+ $pursh=array();
46
+ $allOptions=$item->getData('product_options');
47
+ $linkFile=array();
48
+ $options = unserialize($allOptions);
49
+ foreach ($options['options'] as $optionValues) {
50
+ //var_dump($optionValues);
51
+ $linkFile[]=$optionValues["value"];
52
+ }
53
+ $qte=$item->getQtyToInvoice();
54
+
55
+ for($i=0 ; $i<$qte ; $i++){
56
+ // product does not exist so we will be creating a new one.
57
+ // i noticed some fields will give a database error if they are set when existing. These are the fields I found to work successfully
58
+ $nmprd="down".time().rand(2,6);
59
+ $product = new Mage_Catalog_Model_Product();
60
+ $product->setAttributeSetId(4);
61
+ $product->setWebsiteIDs(array(1)); // your website ids
62
+ $product->setStoreIDs(array(1)); // your store ids
63
+ $product->setTypeId('downloadable');
64
+ $product->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE);
65
+ $product->setStatus(1);
66
+ $product->setSku($nmprd);
67
+ $product->setLinksPurchasedSeparately(0);
68
+ $product->setName($nmprd);
69
+ $product->setTaxClassId(0);
70
+ $product->setDescription('Description');
71
+ $product->setShortDescription('Short Description');
72
+ $product->setPrice(0);
73
+
74
+ $product->save();
75
+ $link =array( 'title' => 'Waiting not Ready', 'link' => 'http://www.Null.com' );
76
+
77
+ Mage::getModel('downloadable/link')->setData(array(
78
+ 'product_id' => $product->getId(),
79
+ 'sort_order' => 0,
80
+ 'number_of_downloads' => 0, // Unlimited downloads
81
+ 'is_shareable' => 2, // Not shareable
82
+ 'link_url' => $link['link'],
83
+ 'link_type' => 'url',
84
+ 'link_file' => '',
85
+ 'sample_url' => '',
86
+ 'sample_file' => '',
87
+ 'sample_type' => '',
88
+ 'use_default_title' => false,
89
+ 'title' => $link['title'],
90
+ 'default_price' => 0,
91
+ 'price' => 0,
92
+ ))->save();
93
+ $orderItem = Mage::getModel('sales/order_item')
94
+ ->setItemId(NULL)
95
+ ->setStoreId(1)
96
+ ->setIsVirtual(1)
97
+ ->setQuoteItemId(0)
98
+ ->setProductType('downloadable')
99
+ ->setQuoteParentItemId(NULL)
100
+ ->setProductId($product->getId())
101
+ ->setProductType($product->getTypeId())
102
+ ->setQtyBackordered(NULL)
103
+ ->setTotalQtyOrdered(1)
104
+ ->setQtyOrdered(1)
105
+ ->setName($product->getName())
106
+ ->setSku($product->getSku())
107
+ ->setPrice($product->getPrice());
108
+
109
+
110
+ $order->addItem($orderItem);
111
+ $order->save();
112
+ $orderItem->save();
113
+
114
+ $order1 = Mage::getModel('sales/order');
115
+ $order1->load(Mage::getSingleton('sales/order')->getLastOrderId());
116
+
117
+
118
+ $orderIncrementId = $order1->getIncrementId();
119
+
120
+ $orderPur = Mage::getModel('downloadable/link_purchased')
121
+ ->setPurchasedId(NULL)
122
+ ->setOrderItemId($orderItem->getItemId())
123
+ ->setOrderIncrementId($orderIncrementId)
124
+ ->setProductName($product->getName())
125
+ ->setProductSku($product->getSku())
126
+ ->setCustomerId($order->getCustomerId())
127
+ ->setOrderId($order->getId())
128
+ ->save();
129
+ $linkHash = strtr(base64_encode(microtime() . $orderPur->getId() . $orderItem->getId() . $product->getId()), '+/=', '-_,');
130
+ $orderPurItem = Mage::getModel('downloadable/link_purchased_item')
131
+ ->setPurchasedId($orderPur->getPurchasedId())
132
+ ->setOrderItemId($orderPur->getOrderItemId())
133
+ ->setLinkHash($linkHash)
134
+ ->setProductId($product->getId())
135
+ ->setLinkTitle($link['title'])
136
+ ->setLinkType('file')
137
+ ->setLinkFile(null)
138
+ ->setCreatedAt($orderItem->getCreatedAt())
139
+ ->setUpdatedAt($orderItem->getUpdatedAt())
140
+ ->setStatus(Mage_Downloadable_Model_Link_Purchased_Item::LINK_STATUS_PENDING)
141
+ ->save();
142
+ $pursh[]=$orderPur->getId();
143
+
144
+ $date = new DateTime();
145
+ $fprd = Mage::getModel('freed/freed')
146
+ ->setProductId($product->getId())
147
+ ->setOrderId($order->getId())
148
+ ->setProductName($product->getName())
149
+ ->setCostumerId($order->getCustomerId())
150
+ ->setProductLink($linkFile[0])
151
+ ->setCostumerName($order->getCustomerEmail())
152
+ ->setCondition('pending')
153
+ ->setPiedAdmin(0)
154
+ ->setPiedClient(0)
155
+ ->setFreedCreate($date->format('Y-m-d H:i:s'))
156
+ ->setFreedModify($date->format('Y-m-d H:i:s'))
157
+ ->save();
158
+
159
+
160
+
161
+
162
+ }
163
+ Mage::register('PurchasedIds', $pursh);
164
+
165
+ }
166
+
167
+
168
+ // $order->removeItem($item)->save();
169
+ //echo $item->getSku();
170
+ }
171
+ // Then we see if the product exists already, by SKU since that is unique to each product
172
+
173
+
174
+
175
+
176
+
177
+
178
+ // setting a Yes/No Attribute
179
+
180
+
181
+
182
+ }
183
+
184
+ public function change_pur($observer) {
185
+ $order = $observer->getEvent()->getOrder();
186
+ $purshs=Mage::registry('PurchasedIds');
187
+ if(!is_null($purshs))
188
+ {
189
+ foreach($purshs as $pursh){
190
+ $ordPursh=Mage::getModel('downloadable/link_purchased')->load($pursh);
191
+
192
+ $ordPursh->setOrderIncrementId($order->getIncrementId());
193
+ $ordPursh->save();
194
+ }
195
+
196
+ Mage::unregister('PurchasedIds');
197
+ $session = Mage::getSingleton('customer/session');
198
+ $emailTemplate = Mage::getModel('core/email_template')->loadDefault('freed_private_order');
199
+ //Create an array of variables to assign to template
200
+ $emailTemplateVariables = array();
201
+ $emailTemplateVariables['myvar2'] = $order->getIncrementId();
202
+ $processedTemplate = $emailTemplate->getProcessedTemplate($emailTemplateVariables);
203
+ $emailTemplate->setSenderName('abdo lah achakik');
204
+ $emailTemplate->setSenderEmail('achakik@gmail.com');
205
+ $emailTemplate->setTemplateSubject('New private ticket order');
206
+ $emailTemplate->send('achakik@gmail.com','abdo lah achakik', $emailTemplateVariables);
207
+
208
+ }
209
+ }
210
+ public function change_link($observer) {
211
+ $prd = $observer->getEvent()->getProduct();
212
+ if($prd->getTypeId()=="downloadable")
213
+ {
214
+ $date = new DateTime();
215
+
216
+ $prdPurItem = Mage::getModel('downloadable/link_purchased_item')->getCollection()
217
+ ->addFieldToFilter('product_id',$prd->getId());
218
+ if($prd->getTypeInstance(true)->hasLinks($prd)){
219
+ $fl=$prd->getTypeInstance(true)->getLinks($prd);
220
+ foreach($fl as $fl1){
221
+ if(!is_null($prdPurItem))
222
+ {
223
+ foreach ($prdPurItem as $_itemPur) {
224
+
225
+ $_itemPur->setLinkUrl(null)
226
+ ->setLinkId($fl1["link_id"])
227
+ ->setLinkType('file')
228
+ ->setLinkTitle("Ready For Download")
229
+ ->setStatus(Mage_Downloadable_Model_Link_Purchased_Item::LINK_STATUS_AVAILABLE)
230
+ ->setLinkFile($fl1["link_file"])
231
+ ->setUpdatedAt($date->format('Y-m-d H:i:s'))
232
+ ->save();
233
+
234
+ }
235
+ }
236
+ }
237
+ }
238
+ }
239
+
240
+ }
241
+ }
app/code/community/Arabgento/Freed/controllers/Adminhtml/FreedController.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Arabgento_Freed_Adminhtml_FreedController extends Mage_Adminhtml_Controller_action
4
+
5
+ {
6
+
7
+ protected function _initAction()
8
+
9
+ {
10
+
11
+ $this->loadLayout()
12
+
13
+ ->_setActiveMenu('arabgento/items')
14
+
15
+ ->_addBreadcrumb(Mage::helper('freed')->__('Manage Private Orders'),
16
+
17
+ Mage::helper('freed')->__('Manage Private Orders'));
18
+
19
+ return $this;
20
+
21
+ }
22
+
23
+ public function indexAction() {
24
+
25
+ $this->_initAction();
26
+
27
+ $this->renderLayout();
28
+
29
+ }
30
+ public function gridAction() {
31
+
32
+ $this->_initAction();
33
+ $productId=$this->getRequest()->getParam('product_id');
34
+ $conv=$this->getRequest()->getParam('conv');
35
+ if ($productId > 0)
36
+ {
37
+
38
+ $prd = Mage::getModel('catalog/product')->load($productId);
39
+ $currentStore = $prd->getStoreId();
40
+ Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
41
+ if($conv=="1")
42
+ $prd->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH);
43
+ else
44
+ $prd->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE);
45
+ $prd->save();
46
+ Mage::app()->setCurrentStore($currentStore);
47
+ $prdf = Mage::getModel('freed/freed');
48
+ $prdf->convertPiedAdmin($productId,$conv);
49
+ }
50
+ $this->renderLayout();
51
+
52
+ }
53
+ public function grid1Action() {
54
+
55
+ $this->_initAction();
56
+ $this->renderLayout();
57
+
58
+ }
59
+
60
+
61
+ }
app/code/community/Arabgento/Freed/controllers/CusController.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Arabgento_Freed_CusController extends Mage_Core_Controller_Front_Action
4
+ {
5
+
6
+ /**
7
+ * Check customer authentication
8
+ */
9
+ public function preDispatch()
10
+ {
11
+ parent::preDispatch();
12
+ $action = $this->getRequest()->getActionName();
13
+ $loginUrl = Mage::helper('customer')->getLoginUrl();
14
+
15
+ if (!Mage::getSingleton('customer/session')->authenticate($this, $loginUrl)) {
16
+ $this->setFlag('', self::FLAG_NO_DISPATCH, true);
17
+ }
18
+ }
19
+
20
+ /**
21
+ * Display downloadable links bought by customer
22
+ *
23
+ */
24
+ public function prprdAction()
25
+ {
26
+ $this->loadLayout();
27
+ $this->_initLayoutMessages('customer/session');
28
+ if ($block = $this->getLayout()->getBlock('freed_block_privateproducts_list')) {
29
+ $block->setRefererUrl($this->_getRefererUrl());
30
+ }
31
+ $headBlock = $this->getLayout()->getBlock('head');
32
+ if ($headBlock) {
33
+ $headBlock->setTitle(Mage::helper('downloadable')->__('My Private Orders'));
34
+ }
35
+ $this->renderLayout();
36
+ }
37
+ /**
38
+ * Display downloadable links bought by customer
39
+ *
40
+ */
41
+ public function editAction()
42
+ {
43
+ $this->loadLayout();
44
+ $this->_initLayoutMessages('customer/session');
45
+ if ($block = $this->getLayout()->getBlock('freed_block_privateproducts_edit')) {
46
+ $block->setRefererUrl($this->_getRefererUrl());
47
+ }
48
+ $headBlock = $this->getLayout()->getBlock('head');
49
+ if ($headBlock) {
50
+ $headBlock->setTitle(Mage::helper('downloadable')->__('My Private Orders'));
51
+ }
52
+ $session = Mage::getSingleton('customer/session');
53
+ $productId = $this->getRequest()->getParam('product_id');
54
+ $forsell = $this->getRequest()->getParam('for_sell');
55
+ $price = $this->getRequest()->getParam('price');
56
+ //echo $forsell;echo "/".$productId;
57
+ if($forsell!=null)
58
+ {
59
+ if ($productId > 0)
60
+ {
61
+ $purchasedPrivate = Mage::getModel('freed/freed');
62
+ $purchasedPrivate->convertPiedClient($productId,$session->getCustomerId(),$forsell);
63
+ if (!is_null($price))
64
+ {
65
+
66
+ if(is_numeric($price))
67
+ {
68
+ $prdprice = Mage::getModel('catalog/product')->load($productId);
69
+ $currentStore = $prdprice->getStoreId();
70
+ Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
71
+
72
+ $prdprice->setPrice($price);
73
+ $prdprice->save();
74
+ Mage::app()->setCurrentStore($currentStore);
75
+ }
76
+ }
77
+ }
78
+ }
79
+
80
+ $this->renderLayout();
81
+ }
82
+
83
+ public function confirmAction()
84
+ {
85
+ $this->loadLayout();
86
+ $this->_initLayoutMessages('customer/session');
87
+ if ($block = $this->getLayout()->getBlock('freed_block_privateproducts_edit')) {
88
+ $block->setRefererUrl($this->_getRefererUrl());
89
+ }
90
+ $headBlock = $this->getLayout()->getBlock('head');
91
+ if ($headBlock) {
92
+ $headBlock->setTitle(Mage::helper('downloadable')->__('My Private Orders'));
93
+ }
94
+ $session = Mage::getSingleton('customer/session');
95
+ $productId = $this->getRequest()->getParam('product_id');
96
+ $forsell = $this->getRequest()->getParam('for_sell');
97
+ $price = $this->getRequest()->getParam('price');
98
+ if ($productId > 0)
99
+ {
100
+ $purchasedPrivate = Mage::getModel('freed/freed');
101
+ $purchasedPrivate->convertPiedClient($productId,$session->getCustomerId(),$forsell);
102
+ if (!is_null($price))
103
+ {
104
+
105
+ if(is_numeric($price))
106
+ {
107
+ $prdprice = Mage::getModel('catalog/product')->load($productId);
108
+ $currentStore = $prdprice->getStoreId();
109
+ Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
110
+
111
+ $prdprice->setPrice($price);
112
+ $prdprice->save();
113
+ Mage::app()->setCurrentStore($currentStore);
114
+ }
115
+ }
116
+ }
117
+
118
+ $this->renderLayout();
119
+ }
120
+
121
+ }
app/code/community/Arabgento/Freed/etc/config.xml ADDED
@@ -0,0 +1,221 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Arabgento_Freed>
5
+ <version>1.0.0</version>
6
+ <depends>
7
+ <Mage_Core/>
8
+ </depends>
9
+ </Arabgento_Freed>
10
+ </modules>
11
+
12
+ <frontend>
13
+
14
+ <routers>
15
+ <freed>
16
+
17
+ <use>standard</use>
18
+ <args>
19
+ <module>Arabgento_Freed</module>
20
+ <frontName>freed</frontName>
21
+ </args>
22
+ </freed>
23
+ </routers>
24
+ <layout>
25
+ <updates>
26
+ <freed>
27
+ <file>freed.xml</file>
28
+ </freed>
29
+ </updates>
30
+ </layout>
31
+ </frontend>
32
+
33
+ <admin>
34
+
35
+ <routers>
36
+ <freed>
37
+
38
+ <use>admin</use>
39
+ <args>
40
+ <module>Arabgento_Freed</module>
41
+ <frontName>freed</frontName>
42
+ </args>
43
+ </freed>
44
+ </routers>
45
+ <layout>
46
+ <updates>
47
+ <freed>
48
+ <file>freed.xml</file>
49
+ </freed>
50
+ </updates>
51
+ </layout>
52
+ </admin>
53
+
54
+ <adminhtml>
55
+
56
+ <menu>
57
+
58
+ <arabgento module="freed">
59
+
60
+ <title>ArabGento</title>
61
+
62
+ <sort_order>71</sort_order>
63
+
64
+ <children>
65
+
66
+ <item1 module="freed">
67
+
68
+ <title>Manage Private Orders</title>
69
+
70
+ <sort_order>1</sort_order>
71
+
72
+ <action>freed/adminhtml_freed/grid</action>
73
+
74
+ </item1>
75
+ </children>
76
+
77
+
78
+
79
+
80
+
81
+ </arabgento>
82
+
83
+ </menu>
84
+
85
+ <acl>
86
+
87
+ <resources>
88
+
89
+ <all>
90
+
91
+ <title>Allow Everything</title>
92
+
93
+ </all>
94
+
95
+ <admin>
96
+
97
+ <children>
98
+
99
+ <freed>
100
+
101
+ <title>Freed Module</title>
102
+
103
+ <sort_order>10</sort_order>
104
+
105
+ </freed>
106
+
107
+ </children>
108
+
109
+ </admin>
110
+
111
+ </resources>
112
+
113
+ </acl>
114
+
115
+ <layout>
116
+
117
+ <updates>
118
+
119
+ <freed>
120
+
121
+ <file>freed.xml</file>
122
+
123
+ </freed>
124
+
125
+ </updates>
126
+
127
+ </layout>
128
+
129
+ </adminhtml>
130
+
131
+
132
+ <global>
133
+ <models>
134
+ <freed>
135
+ <class>Arabgento_Freed_Model</class>
136
+ <resourceModel>freed_mysql4</resourceModel>
137
+ </freed>
138
+ <freed_mysql4>
139
+ <class>Arabgento_Freed_Model_Mysql4</class>
140
+ <entities>
141
+ <freed>
142
+ <table>freed</table>
143
+ </freed>
144
+ </entities>
145
+ </freed_mysql4>
146
+ </models>
147
+ <resources>
148
+ <freed_setup>
149
+ <setup>
150
+ <module>Arabgento_Freed</module>
151
+ </setup>
152
+ <connection>
153
+ <use>core_setup</use>
154
+ </connection>
155
+ </freed_setup>
156
+ <freed_write>
157
+ <connection>
158
+ <use>core_write</use>
159
+ </connection>
160
+ </freed_write>
161
+ <freed_read>
162
+ <connection>
163
+ <use>core_read</use>
164
+ </connection>
165
+ </freed_read>
166
+ </resources>
167
+ <blocks>
168
+ <freed>
169
+ <class>Arabgento_Freed_Block</class>
170
+ </freed>
171
+
172
+
173
+ </blocks>
174
+
175
+ <helpers>
176
+ <freed>
177
+ <class>Arabgento_Freed_Helper</class>
178
+ </freed>
179
+ </helpers>
180
+
181
+ <events>
182
+ <sales_order_place_before>
183
+ <observers>
184
+ <change_order>
185
+ <type>singleton</type>
186
+ <class>freed/observer</class>
187
+ <method>change_order</method>
188
+ </change_order>
189
+ </observers>
190
+ </sales_order_place_before>
191
+ <sales_order_place_after>
192
+ <observers>
193
+ <change_pur>
194
+ <type>singleton</type>
195
+ <class>freed/observer</class>
196
+ <method>change_pur</method>
197
+ </change_pur>
198
+ </observers>
199
+ </sales_order_place_after>
200
+ <catalog_product_save_after>
201
+ <observers>
202
+ <change_link>
203
+ <type>singleton</type>
204
+ <class>freed/observer</class>
205
+ <method>change_link</method>
206
+ </change_link>
207
+ </observers>
208
+ </catalog_product_save_after>
209
+ </events>
210
+ <template>
211
+ <email>
212
+ <freed_private_order module="freed">
213
+ <label>custom email module</label>
214
+ <file>freed_private_order.html</file>
215
+ <type>html</type>
216
+ </freed_private_order>
217
+ </email>
218
+ </template>
219
+ </global>
220
+
221
+ </config>
app/code/community/Arabgento/Freed/sql/freed_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+ $installer->run("
5
+ SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
6
+ SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
7
+ SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';
8
+ DROP TABLE IF EXISTS {$this->getTable('freed')};
9
+ CREATE TABLE {$this->getTable('freed')}(
10
+ `freed_id` int(11) unsigned NOT NULL auto_increment,
11
+ `product_id` int(11) NOT NULL default 0,
12
+ `order_id` int(11) NOT NULL default 0,
13
+ `costumer_id` int(11) NOT NULL default 0,
14
+ `product_link` varchar(400) NOT NULL default '',
15
+ `product_name` varchar(400) NOT NULL default '',
16
+ `costumer_name` varchar(400) NOT NULL default '',
17
+ `condition` varchar(400) NOT NULL default '',
18
+ `pied_admin` tinyint NOT NULL default 0 ,
19
+ `pied_client` tinyint NOT NULL default 0,
20
+ `freed_create` datetime NULL,
21
+ `freed_modify` datetime NULL,
22
+ PRIMARY KEY (`freed_id`))
23
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;
24
+ SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
25
+ SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
26
+ ");
27
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/freed.xml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <freed_adminhtml_freed_grid>
4
+
5
+ <reference name="content">
6
+
7
+ <block type="freed/adminhtml_freed_grid" name="freed" />
8
+
9
+ </reference>
10
+
11
+ </freed_adminhtml_freed_grid>
12
+ <freed_adminhtml_freed_grid1>
13
+
14
+ <reference name="content">
15
+
16
+ <block type="freed/adminhtml_freed_grid1" name="freed1" />
17
+
18
+ </reference>
19
+
20
+ </freed_adminhtml_freed_grid1>
21
+ <freed_adminhtml_freed_conadmin>
22
+
23
+ <reference name="content">
24
+
25
+ <block type="freed/adminhtml_freed_grid" name="freed" />
26
+
27
+ </reference>
28
+
29
+ </freed_adminhtml_freed_conadmin>
30
+
31
+ </layout>
app/design/frontend/base/default/layout/freed.xml ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
19
+ * versions in the future. If you wish to customize Magento for your
20
+ * needs please refer to http://www.magentocommerce.com for more information.
21
+ *
22
+ * @category design
23
+ * @package base_default
24
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
25
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
26
+ */
27
+
28
+ Supported layout update handles (action):
29
+ - catalog_product_gallery
30
+ - catalog_product_compare_index
31
+
32
+ Supported layout update handles (special):
33
+ - default
34
+ - catalog_category_default
35
+ - catalog_category_layered
36
+ - catalog_product_view
37
+
38
+ -->
39
+ <layout version="0.1.0">
40
+
41
+ <!--
42
+ Category default layout
43
+ -->
44
+
45
+
46
+ <customer_account>
47
+ <reference name="customer_account_navigation">
48
+ <action method="addLink" translate="label" module="freed"><name>freed_cus_prprd</name><path>freed/cus/prprd</path><label>My Private Orders</label></action>
49
+ </reference>
50
+ </customer_account>
51
+ <freed_cus_prprd translate="label">
52
+ <label>Customer My Account Private Orders</label>
53
+ <update handle="customer_account"/>
54
+ <reference name="my.account.wrapper">
55
+ <block type="freed/privateproducts_list" name="freed_privateproducts_list" template="arabgento/customer/products/list.phtml" />
56
+ </reference>
57
+ <reference name="root">
58
+ <action method="setHeaderTitle" translate="title" module="downloadable"><title>My Private Orders</title></action>
59
+ </reference>
60
+ </freed_cus_prprd>
61
+ <freed_cus_edit translate="label">
62
+ <label>Customer My Account Private Orders</label>
63
+ <update handle="customer_account"/>
64
+ <reference name="my.account.wrapper">
65
+ <block type="freed/privateproducts_edit" name="freed_privateproducts_edit" template="arabgento/customer/products/edit.phtml" />
66
+ </reference>
67
+ <reference name="root">
68
+ <action method="setHeaderTitle" translate="title" module="downloadable"><title>My Private Orders</title></action>
69
+ </reference>
70
+ </freed_cus_edit>
71
+ </layout>
app/design/frontend/base/default/template/arabgento/customer/products/edit.phtml ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $prd=$this->getProduct(); ?>
2
+ <?php $prdFreed=$this->getProductFreed();
3
+ ?>
4
+
5
+ <?php if($prdFreed!=NULL){ ?>
6
+ <div class="page-title">
7
+
8
+ <h1><?php echo Mage::helper('downloadable')->__('Edit My Private Orders') ?></h1>
9
+ </div>
10
+ <form action="<?php echo $this->getUrl('freed/cus/edit'); ?>" method="post" id="form-validate">
11
+ <input type="hidden" name='product_id' value='<?php echo $prd->getId(); ?>' />
12
+ <div class="fieldset">
13
+ <h2 class="legend">Edit your product</h2>
14
+ <ul class="form-list">
15
+ <li class="fields">
16
+ <div class="customer-name">
17
+ <div class="field name-firstname">
18
+ <label for="firstname" class="required">Price</label>
19
+ <div class="input-box">
20
+ <input type="text" id="price" name="price" value="<?php echo number_format($prd->getPrice(), 2); ?>" title="First Name" class="input-text required-entry" />
21
+ </div>
22
+ </div>
23
+ <div class="field name-lastname">
24
+ <label for="lastname" class="required">offering for sell</label>
25
+ <div class="input-box">
26
+ <select id="for_sell" name="for_sell" title="offering for sell" >
27
+ <option value="0">No</option>
28
+ <option value="1">Yes</option>
29
+ </select>
30
+ <script type="text/javascript">
31
+ //<![CDATA[
32
+
33
+ document.getElementById("for_sell").value=<?php echo $prdFreed->getPiedClient(); ?>;
34
+ //]]>
35
+ </script>
36
+ </div>
37
+ </div>
38
+ </div>
39
+ <div class="actions">
40
+ <br /><br />
41
+ <button type="submit" title="Confirm" class="button btn-cart"><span><span>Confirm</span></span></button>
42
+ </div>
43
+ </div>
44
+
45
+ </li>
46
+ </ul>
47
+ </form>
48
+ <?php }else
49
+ {
50
+ ?>
51
+ <div class="page-title">
52
+ <h1><?php echo Mage::helper('downloadable')->__('Edit My Private Orders') ?></h1>
53
+ </div>
54
+
55
+ <?php
56
+ echo "its's not in your collection of private product";
57
+ }
58
+ ?>
59
+
60
+
app/design/frontend/base/default/template/arabgento/customer/products/list.phtml ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-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 design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ /**
29
+ * @see Mage_Downloadable_Block_Customer_Products_List
30
+ */
31
+
32
+ ?>
33
+ <?php $_items = $this->getItems(); ?>
34
+ <div class="page-title">
35
+ <h1><?php echo Mage::helper('downloadable')->__('My Private Orders') ?></h1>
36
+
37
+ </div>
38
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
39
+ <?php echo $this->getChildHtml('pager'); ?>
40
+ <?php if(count($_items)): ?>
41
+ <table class="data-table" id="my-downloadable-products-table">
42
+ <col width="1" />
43
+ <col width="1" />
44
+ <col />
45
+ <col width="1" />
46
+ <col width="1" />
47
+ <thead>
48
+ <tr>
49
+ <th><?php echo Mage::helper('downloadable')->__('Order #') ?></th>
50
+ <th><?php echo Mage::helper('downloadable')->__('Date') ?></th>
51
+ <th><?php echo Mage::helper('downloadable')->__('Title') ?></th>
52
+ <th><?php echo Mage::helper('downloadable')->__('Status') ?></th>
53
+ <th><span class="nobr"><?php echo Mage::helper('downloadable')->__('Remaining Downloads') ?></span></th>
54
+ <th><?php echo Mage::helper('downloadable')->__('Action') ?></th>
55
+ </tr>
56
+ </thead>
57
+ <tbody>
58
+ <?php $_odd = ''; ?>
59
+ <?php foreach ($_items as $_item): ?>
60
+ <tr>
61
+ <td><a href="<?php echo $this->getOrderViewUrl($_item->getPurchased()->getOrderId()) ?>" title="<?php echo Mage::helper('downloadable')->__('View Order') ?>"><?php echo $_item->getPurchased()->getOrderIncrementId() ?></a></td>
62
+ <td><span class="nobr"><?php echo $this->formatDate($_item->getPurchased()->getCreatedAt()) ?></span></td>
63
+ <td><?php echo $this->htmlEscape($_item->getPurchased()->getProductName()) ?> - <a href="<?php echo $this->getDownloadUrl($_item) ?>" title="<?php echo Mage::helper('downloadable')->__('Start Download') ?>" <?php echo $this->getIsOpenInNewWindow()?'onclick="this.target=\'_blank\'"':''; ?>><?php echo $_item->getLinkTitle() ?></a></td>
64
+ <td><em><?php echo Mage::helper('downloadable')->__(ucfirst($_item->getStatus())) ?></em></td>
65
+ <td><?php echo $this->getRemainingDownloads($_item) ?></td>
66
+ <td><a href="<?php echo $this->getEditUrl($_item->getProductId()) ?>" title="<?php echo Mage::helper('downloadable')->__('Edit'); ?>"><?php echo Mage::helper('downloadable')->__('Edit'); ?></a></td>
67
+ </tr>
68
+ <?php endforeach; ?>
69
+ </tbody>
70
+ </table>
71
+ <script type="text/javascript">decorateTable('my-downloadable-products-table')</script>
72
+ <?php else: ?>
73
+ <p><?php echo Mage::helper('downloadable')->__('You have not purchased any downloadable products yet.'); ?></p>
74
+ <?php endif; ?>
75
+ <?php echo $this->getChildHtml('pager'); ?>
76
+ <div class="buttons-set">
77
+ <p class="back-link"><a href="<?php echo $this->escapeUrl($this->getBackUrl()) ?>"><small>&laquo; </small><?php echo $this->__('Back') ?></a></p>
78
+ </div>
app/etc/modules/Arabgento_FreedCommunity.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Arabgento_Freed>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Arabgento_Freed>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>My_Custom_Downloadable_Product</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>manage and create custom downloadable product for your client (from info of client create the product)</summary>
10
+ <description>many marketplace need this extension by example your site create the 3d object but you need create custom object for many client , and you want receive he info from client as zip of images for knowing exactly the idea or object wanted by client , Ok My Custom Downloadable resolve this problem &#xD;
11
+ the client can create the ticket and order private downloadable product (with the ticket the client attached zip or rar file contain all image or all file needed by the marketplace ) ;after that your receive all private order sanded by all clients in the same place ; the client can't download just after finished the product and uploaded by your store ; the client have custom section in him account of private downloadable product and can sell him product in your store and can fix the price for product see the tutorials for more infos</description>
12
+ <notes>the extension already tested in site online</notes>
13
+ <authors><author><name>arabgento community</name><user>arabgento</user><email>contact@arabgento.com</email></author></authors>
14
+ <date>2012-11-07</date>
15
+ <time>21:03:54</time>
16
+ <contents><target name="magecommunity"><dir name="Arabgento"><dir name="Freed"><dir name="Block"><dir name="Adminhtml"><file name="AClinks.php" hash="cd7e563cc33928243faf991b1d94c431"/><file name="Alinks.php" hash="a4e54768b38130e87c68a449bbf9a337"/><file name="Clinks.php" hash="ecfe7df2b89d6ad6fecdb1024a2958dd"/><file name="Clinkstest.php" hash="6fb577b4557a389c5c24df0a5e008d5f"/><dir name="Freed"><file name="Grid.php" hash="0ddbaa4f967254f8e5f0c4fa342605fc"/><file name="Grid1.php" hash="18fb802c07debc8259803e0349e27ba1"/></dir><file name="Freed.php" hash="7c1e32f157292ffa58fa84b851ed76c3"/><file name="PClinks.php" hash="fd4e0b9e9e3a7bded7d8086147aeaa36"/><file name="Plinks.php" hash="df5c3d94ff450ed2b69fad423a7a0791"/><file name="Plinks1.php" hash="c4dd2fb461cfa82ae6b4959b3519efb5"/></dir><dir name="Privateproducts"><file name="Edit.php" hash="3b0d7cc2c919b49eef561f190086dbba"/><file name="List.php" hash="d59d7e751abf8acecc1d0ed65a37f4f2"/></dir></dir><dir name="Helper"><file name="Data.php" hash="30442bd74a05c28636f93b123f2e29f3"/></dir><dir name="Model"><file name="Freed.php" hash="8f4d518842d5b2e38ca9730df1c17643"/><dir name="Mysql4"><dir name="Freed"><file name="Collection.php" hash="70995c1fd7e33127fc536578b152e259"/></dir><file name="Freed.php" hash="e5257b578f508157a15d4e29d92db392"/></dir><file name="Observer.php" hash="be00b3521014eb5d650e948586ab9a77"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="FreedController.php" hash="5032edb4b0758fa2430c1dfb38d9ade8"/></dir><file name="CusController.php" hash="b72886df0baea8803654868ff1723ce1"/></dir><dir name="etc"><file name="config.xml" hash="203ea99dcf1157c2c84c607e5cf932a8"/></dir><dir name="sql"><dir name="freed_setup"><file name="mysql4-install-0.1.0.php" hash="ca9fef38b99a5d3d7967f8629b12a6b5"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Arabgento_FreedCommunity.xml" hash="407b198df80ba34de510f7c0567125d3"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="freed.xml" hash="4a949e0c4dfd5bbfb832ab7a3308c84d"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="freed.xml" hash="f28d46cc6b41b9ad21afbf9211551caa"/></dir><dir name="template"><dir name="arabgento"><dir name="customer"><dir name="products"><file name="edit.phtml" hash="c720b856cbd1e6a5d33c95732b1d0cfb"/><file name="list.phtml" hash="db194d636d303ad1b8dd3572cf23fdff"/></dir></dir></dir></dir></dir></dir></dir></target></contents>
17
+ <compatible/>
18
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
19
+ </package>