Zero1_Crondoctor - Version 1.0.0.0

Version Notes

Initial release.

Download this release

Release Info

Developer Arron Moss
Extension Zero1_Crondoctor
Version 1.0.0.0
Comparing to
See all releases


Version 1.0.0.0

app/code/community/Zero1/Crondoctor/Block/Adminhtml/Crondoctor.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Zero1_Crondoctor_Block_Adminhtml_Crondoctor extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+ $this->_removeButton('add');
8
+ }
9
+
10
+ public function _construct()
11
+ {
12
+ $this->_controller = 'adminhtml_crondoctor';
13
+ $this->_blockGroup = 'zero1_crondoctor';
14
+ $this->_headerText = Mage::helper('zero1_crondoctor')->__('Cron Doctor');
15
+ //$this->_addButtonLabel = Mage::helper('zero1_crondoctor')->__('test');
16
+ parent::_construct();
17
+ }
18
+ }
app/code/community/Zero1/Crondoctor/Block/Adminhtml/Crondoctor/Grid.php ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Zero1_Crondoctor_Block_Adminhtml_Crondoctor_Grid extends Mage_Adminhtml_Block_Widget_Grid
3
+ {
4
+ /**
5
+ * Initialize grid
6
+ */
7
+ public function __construct()
8
+ {
9
+ parent::__construct();
10
+
11
+ $this->setId('crondoctor');
12
+ $this->setDefaultSort('created_at');
13
+ $this->setDefaultDir('DESC');
14
+ //$this->setUseAjax(true);
15
+ }
16
+
17
+ /**
18
+ * Prepare related item collection
19
+ *
20
+ * @return Zero1_Crondoctor_Block_Adminhtml_Crondoctor_Grid
21
+ */
22
+ protected function _prepareCollection()
23
+ {
24
+ $collection = Mage::getModel('cron/schedule')->getCollection();
25
+
26
+ $this->setCollection($collection);
27
+ return parent::_prepareCollection();
28
+ }
29
+
30
+ /**
31
+ * Prepare grid columns
32
+ *
33
+ * @return Enterprise_GiftWrapping_Block_Adminhtml_Giftwrapping_Grid
34
+ */
35
+ protected function _prepareColumns()
36
+ {
37
+ $this->addColumn('schedule_id', array(
38
+ 'header' => Mage::helper('zero1_crondoctor')->__('ID'),
39
+ 'width' => '50px',
40
+ 'type' => 'number',
41
+ 'index' => 'schedule_id'
42
+ ));
43
+
44
+ $job_code_options = array();
45
+ $job_code_collection = Mage::getModel('cron/schedule')->getCollection();
46
+ $job_code_collection->getSelect()->group('job_code');
47
+ foreach($job_code_collection as $job_code)
48
+ $job_code_options[$job_code->getJobCode()] = ucwords(str_replace('_', ' ', $job_code->getJobCode()));
49
+
50
+ $this->addColumn('job_code', array(
51
+ 'header' => Mage::helper('zero1_crondoctor')->__('Job Code'),
52
+ 'index' => 'job_code',
53
+ 'type' => 'options',
54
+ 'options' => $job_code_options
55
+ ));
56
+
57
+ $this->addColumn('status', array(
58
+ 'header' => Mage::helper('zero1_crondoctor')->__('Status'),
59
+ 'index' => 'status',
60
+ 'type' => 'options',
61
+ 'options' => array(
62
+ Mage_Cron_Model_Schedule::STATUS_PENDING => Mage::helper('zero1_crondoctor')->__('Pending'),
63
+ Mage_Cron_Model_Schedule::STATUS_RUNNING => Mage::helper('zero1_crondoctor')->__('Running'),
64
+ Mage_Cron_Model_Schedule::STATUS_SUCCESS => Mage::helper('zero1_crondoctor')->__('Success'),
65
+ Mage_Cron_Model_Schedule::STATUS_MISSED => Mage::helper('zero1_crondoctor')->__('Missed'),
66
+ Mage_Cron_Model_Schedule::STATUS_ERROR => Mage::helper('zero1_crondoctor')->__('Error'),
67
+ )
68
+ ));
69
+
70
+ $this->addColumn('messages', array(
71
+ 'header' => Mage::helper('zero1_crondoctor')->__('Messages'),
72
+ 'index' => 'messages'
73
+ ));
74
+
75
+ $this->addColumn('created_at', array(
76
+ 'header' => Mage::helper('zero1_crondoctor')->__('Created At'),
77
+ 'type' => 'datetime',
78
+ 'index' => 'created_at'
79
+ ));
80
+
81
+ $this->addColumn('scheduled_at', array(
82
+ 'header' => Mage::helper('zero1_crondoctor')->__('Scheduled At'),
83
+ 'type' => 'datetime',
84
+ 'index' => 'scheduled_at'
85
+ ));
86
+
87
+ $this->addColumn('executed_at', array(
88
+ 'header' => Mage::helper('zero1_crondoctor')->__('Executed At'),
89
+ 'type' => 'datetime',
90
+ 'index' => 'executed_at'
91
+ ));
92
+
93
+ $this->addColumn('finished_at', array(
94
+ 'header' => Mage::helper('zero1_crondoctor')->__('Finished At'),
95
+ 'type' => 'datetime',
96
+ 'index' => 'finished_at'
97
+ ));
98
+
99
+ return parent::_prepareColumns();
100
+ }
101
+
102
+ /**
103
+ * Retrieve row url
104
+ *
105
+ * @return string
106
+ */
107
+ public function getRowUrl($row)
108
+ {
109
+ return $this->getUrl('*/*/edit', array(
110
+ 'id' => $row->getId()
111
+ ));
112
+ }
113
+
114
+ protected function _prepareMassaction()
115
+ {
116
+ $this->setMassactionIdField('schedule_id');
117
+ $this->getMassactionBlock()->setFormFieldName('crondoctor');
118
+ $this->setNoFilterMassactionColumn(true);
119
+
120
+ $this->getMassactionBlock()->addItem('delete', array(
121
+ 'label' => $this->__('Delete'),
122
+ 'url' => $this->getUrl('*/*/massDelete', array('_current' => true)),
123
+ 'confirm' => $this->__('Are you sure?')
124
+ ));
125
+
126
+ $this->getMassactionBlock()->addItem('change_status', array(
127
+ 'label' => $this->__('Change Status'),
128
+ 'url' => $this->getUrl('*/*/massChange', array('_current' => true)),
129
+ 'confirm' => $this->__('Are you sure?'),
130
+ 'additional' => array(
131
+ 'mode' => array(
132
+ 'name' => 'status',
133
+ 'type' => 'select',
134
+ 'class' => 'required-entry',
135
+ 'label' => Mage::helper('index')->__('Status'),
136
+ 'values' => array(
137
+ Mage_Cron_Model_Schedule::STATUS_PENDING => Mage::helper('zero1_crondoctor')->__('Pending'),
138
+ Mage_Cron_Model_Schedule::STATUS_RUNNING => Mage::helper('zero1_crondoctor')->__('Running'),
139
+ Mage_Cron_Model_Schedule::STATUS_SUCCESS => Mage::helper('zero1_crondoctor')->__('Success'),
140
+ Mage_Cron_Model_Schedule::STATUS_MISSED => Mage::helper('zero1_crondoctor')->__('Missed'),
141
+ Mage_Cron_Model_Schedule::STATUS_ERROR => Mage::helper('zero1_crondoctor')->__('Error'),
142
+ )
143
+ )
144
+ )
145
+ ));
146
+
147
+ return $this;
148
+ }
149
+ }
app/code/community/Zero1/Crondoctor/Block/Adminhtml/Crondoctor/Notice.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Zero1_Crondoctor_Block_Adminhtml_Crondoctor_Notice extends Mage_Adminhtml_Block_Template
3
+ {
4
+ protected $_errors;
5
+
6
+ public function _construct()
7
+ {
8
+ $this->_errors = array();
9
+
10
+ $cronjob_collection = Mage::getModel('cron/schedule')->getCollection();
11
+ $cronjob_collection->addFieldToFilter('status', array('eq' => Mage_Cron_Model_Schedule::STATUS_ERROR));
12
+ $cronjob_collection->getSelect()->group('job_code');
13
+
14
+ foreach($cronjob_collection as $cronjob)
15
+ {
16
+ $this->_errors[] = ucwords(str_replace('_', ' ', $cronjob->getJobCode()));
17
+ }
18
+
19
+ parent::_construct();
20
+ }
21
+
22
+ public function getErrors()
23
+ {
24
+ return $this->_errors;
25
+ }
26
+ }
app/code/community/Zero1/Crondoctor/Helper/Data.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ class Zero1_Crondoctor_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+
5
+ }
app/code/community/Zero1/Crondoctor/Model/Resource/Setup.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ class Zero1_Crondoctor_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
3
+ {
4
+ }
app/code/community/Zero1/Crondoctor/controllers/Adminhtml/CrondoctorController.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Zero1_Crondoctor_Adminhtml_CrondoctorController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+ protected function _initAction()
5
+ {
6
+ $this->loadLayout()
7
+ ->_setActiveMenu('system/zero1_crondoctor');
8
+
9
+ $this->_title(Mage::helper('zero1_crondoctor')->__('System'))->_title(Mage::helper('zero1_crondoctor')->__('Cron Doctor'));
10
+ return $this;
11
+ }
12
+
13
+ public function indexAction()
14
+ {
15
+ $this->_initAction()->renderLayout();
16
+ }
17
+
18
+ public function massDeleteAction()
19
+ {
20
+ $scheduleIds = $this->getRequest()->getParam('crondoctor');
21
+ $totalDeleted = 0;
22
+
23
+ try {
24
+ foreach($scheduleIds as $scheduleId) {
25
+ $job = Mage::getModel('cron/schedule')->load($scheduleId);
26
+ if ($job->getId()) {
27
+ $job->delete();
28
+ $totalDeleted++;
29
+ }
30
+ }
31
+
32
+ if ($totalDeleted > 0) {
33
+ $this->_getSession()->addSuccess(
34
+ $this->__('Total of %d jobs(s) have been deleted.', $totalDeleted)
35
+ );
36
+ } else {
37
+ $this->_getSession()->addError($this->__('No jobs were deleted.'));
38
+ }
39
+ } catch (Zend_Gdata_App_CaptchaRequiredException $e) {
40
+ $this->_getSession()->addError($e->getMessage());
41
+ $this->_redirectToCaptcha($e);
42
+ return;
43
+ } catch (Zend_Gdata_App_Exception $e) {
44
+ $this->_getSession()->addError($this->_parseGdataExceptionMessage($e->getMessage()));
45
+ } catch (Exception $e) {
46
+ $this->_getSession()->addError($e->getMessage());
47
+ }
48
+
49
+ $this->_redirect('*/*/index');
50
+ }
51
+
52
+ public function massChangeAction()
53
+ {
54
+ $scheduleIds = $this->getRequest()->getParam('crondoctor');
55
+ $totalChanged = 0;
56
+ $status = $this->getRequest()->getParam('status');
57
+ try {
58
+ foreach($scheduleIds as $scheduleId) {
59
+ $job = Mage::getModel('cron/schedule')->load($scheduleId);
60
+ if ($job->getId()) {
61
+ $job->setStatus($status);
62
+ $job->save();
63
+ $totalChanged++;
64
+ }
65
+ }
66
+
67
+ if ($totalChanged > 0) {
68
+ $this->_getSession()->addSuccess(
69
+ $this->__('Total of %d jobs(s) have been updated.', $totalChanged)
70
+ );
71
+ } else {
72
+ $this->_getSession()->addError($this->__('No jobs were updated.'));
73
+ }
74
+ } catch (Zend_Gdata_App_CaptchaRequiredException $e) {
75
+ $this->_getSession()->addError($e->getMessage());
76
+ $this->_redirectToCaptcha($e);
77
+ return;
78
+ } catch (Zend_Gdata_App_Exception $e) {
79
+ $this->_getSession()->addError($this->_parseGdataExceptionMessage($e->getMessage()));
80
+ } catch (Exception $e) {
81
+ $this->_getSession()->addError($e->getMessage());
82
+ }
83
+
84
+ $this->_redirect('*/*/index');
85
+ }
86
+ }
app/code/community/Zero1/Crondoctor/etc/adminhtml.xml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <menu>
3
+ <system>
4
+ <children>
5
+ <zero1_crondoctor translate="title" module="zero1_crondoctor">
6
+ <title>Cron Doctor</title>
7
+ <action>adminhtml/crondoctor</action>
8
+ <sort_order>99</sort_order>
9
+ </zero1_crondoctor>
10
+ </children>
11
+ </system>
12
+ </menu>
13
+ <acl>
14
+ <resources>
15
+ <admin>
16
+ <children>
17
+ <system>
18
+ <children>
19
+ <zero1_crondoctor translate="title" module="zero1_crondoctor">
20
+ <title>Cron Doctor</title>
21
+ <sort_order>99</sort_order>
22
+ </zero1_crondoctor>
23
+ </children>
24
+ </system>
25
+ </children>
26
+ </admin>
27
+ </resources>
28
+ </acl>
29
+ </config>
app/code/community/Zero1/Crondoctor/etc/config.xml ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <modules>
3
+ <Zero1_Crondoctor>
4
+ <version>1.0.0.0</version>
5
+ </Zero1_Crondoctor>
6
+ </modules>
7
+
8
+ <global>
9
+ <blocks>
10
+ <zero1_crondoctor>
11
+ <class>Zero1_Crondoctor_Block</class>
12
+ </zero1_crondoctor>
13
+ </blocks>
14
+
15
+ <helpers>
16
+ <zero1_crondoctor>
17
+ <class>Zero1_Crondoctor_Helper</class>
18
+ </zero1_crondoctor>
19
+ </helpers>
20
+
21
+ <models>
22
+ <zero1_crondoctor>
23
+ <class>Zero1_Crondoctor_Model</class>
24
+ <resourceModel>zero1_crondoctor_resource</resourceModel>
25
+ </zero1_crondoctor>
26
+
27
+ <zero1_crondoctor_resource>
28
+ <class>Zero1_Crondoctor_Model_Resource</class>
29
+ <entities>
30
+ <crondoctor>
31
+ <table>zero1_crondoctor</table>
32
+ </crondoctor>
33
+ </entities>
34
+ </zero1_crondoctor_resource>
35
+ </models>
36
+
37
+ <resources>
38
+ <zero1_crondoctor_setup>
39
+ <setup>
40
+ <module>Zero1_Crondoctor</module>
41
+ <class>Zero1_Crondoctor_Model_Resource_Setup</class>
42
+ </setup>
43
+ </zero1_crondoctor_setup>
44
+ </resources>
45
+ </global>
46
+
47
+ <admin>
48
+ <routers>
49
+ <adminhtml>
50
+ <args>
51
+ <modules>
52
+ <zero1_crondoctor before="Mage_Adminhtml">Zero1_Crondoctor_Adminhtml</zero1_crondoctor>
53
+ </modules>
54
+ </args>
55
+ </adminhtml>
56
+ </routers>
57
+ </admin>
58
+
59
+ <frontend>
60
+ <layout>
61
+ <updates>
62
+ <zero1_crondoctor>
63
+ <file>zero1/crondoctor.xml</file>
64
+ </zero1_crondoctor>
65
+ </updates>
66
+ </layout>
67
+ </frontend>
68
+
69
+ <adminhtml>
70
+ <layout>
71
+ <updates>
72
+ <zero1_crondoctor>
73
+ <file>zero1/crondoctor.xml</file>
74
+ </zero1_crondoctor>
75
+ </updates>
76
+ </layout>
77
+ </adminhtml>
78
+
79
+ <default>
80
+ <zero1_crondoctor>
81
+ <options>
82
+ <enabled>1</enabled>
83
+ </options>
84
+ </zero1_crondoctor>
85
+ </default>
86
+
87
+ <!--
88
+ <crontab>
89
+ <jobs>
90
+ <zero1_crondoctor>
91
+ <schedule>
92
+ <cron_expr>* * * * *</cron_expr>
93
+ </schedule>
94
+ <run>
95
+ <model>zero1_crondoctor/observer::updateRedirectionsCronJob</model>
96
+ </run>
97
+ </zero1_crondoctor>
98
+ </jobs>
99
+ </crontab>
100
+ -->
101
+ <crontab>
102
+ <jobs>
103
+ <zero1_crondoctor>
104
+ <schedule>
105
+ <cron_expr>* * * * *</cron_expr>
106
+ </schedule>
107
+ <run>
108
+ <model>zero1_crondoctor/observer::updateRedirectionsCronJob</model>
109
+ </run>
110
+ </zero1_crondoctor>
111
+ </jobs>
112
+ </crontab>
113
+ </config>
app/code/community/Zero1/Crondoctor/sql/zero1_crondoctor_setup/install-1.0.0.0.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+
5
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/crondoctor/crondoctor.xml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <adminhtml_crondoctor_index>
4
+ <reference name="content">
5
+ <block type="zero1_crondoctor/adminhtml_crondoctor" name="zero1_crondoctor" />
6
+ </reference>
7
+ </adminhtml_crondoctor_index>
8
+
9
+ <default>
10
+ <reference name="notifications">
11
+ <block type="zero1_crondoctor/adminhtml_crondoctor_notice" name="zero1_crondoctor_notice" template="crondoctor/notice.phtml" />
12
+ </reference>
13
+ </default>
14
+ </layout>
app/design/adminhtml/default/default/template/crondoctor/notice.phtml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php if(count($this->getErrors()) > 0) : ?>
2
+ <div class="notification-global">
3
+ <strong class="label">Cron errors with the following names:</strong>
4
+ <?php echo implode(', ', $this->getErrors()); ?>
5
+ </div>
6
+ <?php endif; ?>
app/etc/modules/Zero1_Crondoctor.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Zero1_Crondoctor>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Zero1_Crondoctor>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Zero1_Crondoctor</name>
4
+ <version>1.0.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://shop.zero1.co.uk/LICENSE.txt">Commercial</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Crondoctor</summary>
10
+ <description>Crondoctor&#xD;
11
+ </description>
12
+ <notes>Initial release.</notes>
13
+ <authors><author><name>Arron Moss</name><user>zero1limited</user><email>arron.moss@zero1.co.uk</email></author></authors>
14
+ <date>2012-09-14</date>
15
+ <time>13:17:11</time>
16
+ <contents><target name="magecommunity"><dir name="Zero1"><dir name="Crondoctor"><dir name="Block"><dir name="Adminhtml"><dir name="Crondoctor"><file name="Grid.php" hash="4c612a0cc272f21f8cb228052689a4a1"/><file name="Notice.php" hash="cb902ffee94b02dad0689fed02f1ca20"/></dir><file name="Crondoctor.php" hash="8cf6330d654400039ba4f6cbf4f72f81"/></dir></dir><dir name="Helper"><file name="Data.php" hash="4b85072f6909ba3f083c99814103a92a"/></dir><dir name="Model"><dir name="Resource"><file name="Setup.php" hash="eb67fad34e6d1239679a0c547c44ec85"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="CrondoctorController.php" hash="8a849b91ba3814b33d7e2e693c217524"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="774e8bf1d0181f8dc74855c1d74bd692"/><file name="config.xml" hash="6547f8516c7309e2da8c5c1e353ec915"/></dir><dir name="sql"><dir name="zero1_crondoctor_setup"><file name="install-1.0.0.0.php" hash="b68f44efb7ec07f29aa5b2449ec0ca87"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Zero1_Crondoctor.xml" hash="3ccefc4ae6efeecc2bfd7df6a59264f1"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="crondoctor"><file name="crondoctor.xml" hash="61e541ccd7156e8e7dad6197792b4315"/></dir></dir><dir name="template"><dir name="crondoctor"><file name="notice.phtml" hash="95575d8f09e623c05c0de950677346ce"/></dir></dir></dir></dir></dir></target></contents>
17
+ <compatible/>
18
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
19
+ </package>