-
Notifications
You must be signed in to change notification settings - Fork 0
/
task.php
137 lines (112 loc) · 3.36 KB
/
task.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
/**
* Contao Open Source CMS
*
* Copyright (C) 2005-2012 Leo Feyer
*
* @package Core
* @link http://contao.org
* @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL
*/
/**
* Initialize the system
*/
define('TL_MODE', 'BE');
require_once '../../initialize.php';
/**
* Class DiffController
*
* Show the difference between two versions of a record.
* @copyright Leo Feyer 2005-2012
* @author Leo Feyer <http://contao.org>
* @package Core
*/
class TaskController extends Backend
{
/**
* Initialize the controller
*
* 1. Import the user
* 2. Call the parent constructor
* 3. Authenticate the user
* 4. Load the language files
* DO NOT CHANGE THIS ORDER!
*/
public function __construct()
{
$this->import('BackendUser', 'User');
parent::__construct();
$this->User->authenticate();
$this->import('Database');
$this->loadLanguageFile('default');
$this->loadLanguageFile('modules');
$this->loadLanguageFile('tl_task');
}
/**
* Run the controller
*/
public function run()
{
$strTable = Input::get('table');
$strModule = Input::get('do');
$intId = Input::get('id');
if(!strlen($strTable) || !strlen($intId) || !strlen($strModule))
{
$this->log('Required attributes not set', 'TaskController run()', TL_ERROR);
$this->redirect('contao/main.php?act=error');
}
// load Data Container so that permission is check
$this->loadDataContainer($strTable);
$dc = new DC_Table($strTable);
$objTask = $this->Database->prepare('SELECT id FROM tl_task WHERE draftPid=? AND draftPtable=?')->execute($intId, $strTable);
if($objTask->numRows < 1)
{
$objResult = $this->Database->prepare('SELECT * FROM ' . $strTable . ' WHERE id=?')->execute($intId);
$strTitle = $objResult->title === null ? ($objResult->headline === null ? '' : $objResult->headline) : $objResult->title;
$strTitle = sprintf($GLOBALS['TL_LANG']['tl_task']['draftTaskTitle'],
$GLOBALS['TL_LANG']['MOD'][$strModule][0],
$intId,
$strTitle != '' ? $strTitle : $GLOBALS['TL_LANG']['tl_task']['draftTaskNoTitle']
);
// Insert task
$arrSet = array
(
'tstamp' => time(),
'createdBy' => $this->User->id,
'title' => $strTitle,
'draftPid' => $intId,
'draftPtable' => $strTable,
'draftModule' => $strModule,
'deadline' => time() + $GLOBALS['TL_CONFIG']['draftTaskDefaultDeadline'] * 86400,
);
$objTask = $this->Database->prepare("INSERT INTO tl_task %s")->set($arrSet)->execute();
$intTaskId = $objTask->insertId;
}
else
{
$intTaskId = $objTask->id;
}
Input::setGet('do', 'tasks');
Input::setGet('act', 'edit');
Input::setGet('table', null);
Input::setGet('id', $intTaskId);
TemplateLoader::addFiles(array
(
'be_task_edit' => 'system/modules/drafts/templates/'
));
$this->Template = new BackendTemplate('be_drafts_task');
$this->getBackendModule('tasks');
$this->Template->theme = $this->getTheme();
$this->Template->base = Environment::get('base');
$this->Template->language = $GLOBALS['TL_LANGUAGE'];
$this->Template->title = specialchars($GLOBALS['TL_LANG']['MSC']['filepicker']);
$this->Template->charset = $GLOBALS['TL_CONFIG']['characterSet'];
$GLOBALS['TL_CONFIG']['debugMode'] = false;
$this->Template->output();
}
}
/**
* Instantiate the controller
*/
$objController = new TaskController();
$objController->run();