-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.php
More file actions
85 lines (81 loc) · 3.43 KB
/
Copy pathindex.php
File metadata and controls
85 lines (81 loc) · 3.43 KB
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
<?php
/**
* ownCloud - Journal
*
* @author Thomas Tanghus
* @copyright 2012 Thomas Tanghus <thomas@tanghus.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
$errors = array();
$l = new OC_L10N('journal');
OCP\User::checkLoggedIn();
$required_apps = array(
array('id' => 'tal', 'name' => 'TAL Page Templates'),
array('id' => 'journal', 'name' => 'Journal'),
array('id' => 'contacts', 'name' => 'Contacts'),
);
foreach($required_apps as $app) {
if(!OCP\App::isEnabled($app['id'])) {
$error = (string)$l->t('The %%s app isn\'t enabled! Please enable it here: <strong><a href="%%s?appid=%%s">Enable %%s app</a></strong>');
$errors[] = sprintf($error, $app['name'],OCP\Util::linkTo('settings', 'apps'), $app['id'], $app['name']);
}
}
if(count($errors) == 0) {
$categories = OC_Calendar_App::getCategoryOptions();
$calendars = array();
$singlecalendar = (bool)OCP\Config::getUserValue(OCP\User::getUser(), 'journal', 'single_calendar', false);
if($singlecalendar) {
$cid = OCP\Config::getUserValue(OCP\User::getUser(), 'journal', 'default_calendar', null);
$calendar = OC_Calendar_App::getCalendar($cid, true);
if(!$calendar) {
$error = (string)$l->t('The default calendar with ID %%s is either not owned by %%s or doesn\'t exist.');
$errors[] = sprintf($error, $cid, OCP\User::getUser());
OCP\Util::writeLog('journal', 'The default calendar '.$cid.' is either not owned by '.OCP\User::getUser().' or doesn\'t exist.', OCP\Util::WARN);
}
$calendars[] = $calendar;
} else {
$calendars = OC_Calendar_Calendar::allCalendars(OCP\User::getUser(), true);
}
if( count($calendars) == 0 ) {
$error = (string)$l->t('You have no calendars. Please add one at the <strong><a href="%%s">Calendar app</a></strong>');
$errors[] = sprintf($error, OCP\Util::linkTo('calendar', 'index.php'));
}
// Load a specific entry?
$id = isset( $_GET['id'] ) ? $_GET['id'] : null;
OCP\Util::addScript('3rdparty/timepicker', 'jquery.ui.timepicker');
OCP\Util::addScript('contacts','jquery.multi-autocomplete');
OCP\Util::addScript('','oc-vcategories');
OCP\Util::addScript('journal', 'jquery.rte');
OCP\Util::addScript('journal', 'jquery.textchange');
OCP\Util::addScript('journal', 'journal');
OCP\Util::addscript('tal','modernizr');
OCP\Util::addStyle('3rdparty/timepicker', 'jquery.ui.timepicker');
OCP\Util::addStyle('journal', 'rte');
OCP\Util::addStyle('journal', 'journal');
OCP\App::setActiveNavigationEntry('journal_index');
}
//$tmpl = new OCP\Template('journal', 'journals', 'user');
if($errors) {
$tmpl = new OCP\Template( "journal", "rtfm", "user" );
$tmpl->assign('errors',$errors, false);
} else {
$tmpl = new OC_TALTemplate('journal', 'index', 'user');
$tmpl->assign('categories', $categories);
$tmpl->assign('calendars', $calendars);
$tmpl->assign('singlecalendar',$singlecalendar);
$tmpl->assign('id',$id);
}
$tmpl->printPage();