Skip to content
This repository has been archived by the owner on Dec 18, 2021. It is now read-only.

Rechte für Kalender und E-Mail #409

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion fragments/pz_screen_main.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ if(isset($this->javascript) && $this->javascript != "") {
echo $this->javascript;
}
if(pz::getUser()) {
echo 'pz_add_tracker("global", "/screen/tools/tracker/", 30000, 1);';
echo 'pz_add_tracker("global", "/screen/tracker/tracker/", 30000, 1);';
}
echo '

Expand Down
10 changes: 9 additions & 1 deletion lib/admin/admin_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@ class pz_admin_controller extends pz_controller
{
public function checkPerm()
{
if (pz::getUser() && pz::getUser()->isAdmin()) {
if (pz::getUser() && pz::getLoginUser()->isAdmin()) {

return true;
}

if ($this->getUserPerm('hasAdminPerm')) {

return true;
}


return false;
}
}
4 changes: 3 additions & 1 deletion lib/calendar/calendar_event.php
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,9 @@ public static function getAll(
', $params);

foreach ($sql as $row) {
$events[$row->getValue('id')] = new self($row->getRow());
if (pz::getUser() && (pz::getUser()->isMe() || pz::getUser()->getUserPerm()->hasCalendarReadPerm())) {
$events[$row->getValue('id')] = new self($row->getRow());
}
}

if (!$onlyJobs && $from) {
Expand Down
17 changes: 14 additions & 3 deletions lib/calendar/calendars_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,21 @@ public function checkPerm()
if (pz::getUser() && pz::getUser()->isMe()) {
return true;
}
if (pz::getUser() && pz::getUser()->getUserPerm()->hasCalendarReadPerm()) {

if ($this->hasReadPerm() || $this->hasWritePerm()) {
return true;
} else {
return false;
}

return false;
}

protected function hasReadPerm()
{
return (pz::getUser() && (pz::getUser()->isMe() || pz::getUser()->getUserPerm()->hasCalendarReadPerm()));
}

protected function hasWritePerm()
{
return (pz::getUser() && (pz::getUser()->isMe() || pz::getUser()->getUserPerm()->hasCalendarWritePerm()));
}
}
24 changes: 17 additions & 7 deletions lib/calendar/calendars_controller_screen.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,17 @@ private function getNavigation($p = [], $flyout = '')

// ------------------------------------------------------------------- Views

private function getEventPage($p)
private function getEventPage($p, $mode2 = '')
{
$mode = rex_request('mode', 'string');
$mode = rex_request('mode', 'string', $mode2);

$write = ['add_calendar_event'];

if (!$this->hasWritePerm() && in_array($mode, $write)) {
$mode = '';
}


switch ($mode) {

// edit / add
Expand Down Expand Up @@ -303,7 +311,8 @@ public function getDayPage($p = [])

$attandee_events = pz::getUser()->getAttandeeEvents($day, null, [pz_calendar_attendee::STATUS_ACCEPTED, pz_calendar_attendee::STATUS_TENTATIVE, pz_calendar_attendee::STATUS_DECLINED]);
$s1_content .= pz_calendar_event_screen::getAttendeeListView($p, $attandee_events);
$s1_content .= pz_calendar_event_screen::getAddForm($p);
$s1_content .= $this->getEventPage($p, 'add_calendar_event'); //pz_calendar_event_screen::getAddForm($p);

break;

}
Expand All @@ -314,6 +323,7 @@ public function getDayPage($p = [])
$f->setVar('function', $this->getNavigation($p), false);
$f->setVar('section_1', $s1_content, false);
$f->setVar('section_2', $s2_content, false);

return $f->parse('pz_screen_main.tpl');
}

Expand Down Expand Up @@ -354,8 +364,8 @@ public function getWeekPage($p = [])
$month_lastday = clone $day;
$month_lastday->modify('+1 month');
$month_lastday->modify('last day of this month');
// $events = pz::getUser()->getAllEvents($project_ids, $month_firstday, $month_lastday);
$events = pz_calendar_event::getAll($project_ids, $month_firstday, $month_lastday);
$events = pz::getUser()->getAllEvents($project_ids, $month_firstday, $month_lastday);
//$events = pz_calendar_event::getAll($project_ids, $month_firstday, $month_lastday);

$return = pz_calendar_event_screen::getSearch(
$project_ids,
Expand Down Expand Up @@ -432,7 +442,7 @@ public function getWeekPage($p = [])

$attandee_events = pz::getUser()->getAttandeeEvents($day, null, [pz_calendar_attendee::STATUS_ACCEPTED, pz_calendar_attendee::STATUS_TENTATIVE, pz_calendar_attendee::STATUS_DECLINED]);

$s1_content .= pz_calendar_event_screen::getAddForm($p);
$s1_content .= $this->getEventPage($p, 'add_calendar_event'); //pz_calendar_event_screen::getAddForm($p);
break;

}
Expand Down Expand Up @@ -586,7 +596,7 @@ public function getCustomerplanPage($p = [])

$attandee_events = pz::getUser()->getAttandeeEvents();
$s1_content .= pz_calendar_event_screen::getAttendeeListView($p, $attandee_events);
$s1_content .= pz_calendar_event_screen::getAddForm($p);
$s1_content .= $this->getEventPage($p, 'add_calendar_event'); //pz_calendar_event_screen::getAddForm($p);
break;

}
Expand Down
16 changes: 14 additions & 2 deletions lib/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,22 @@ public function getName()
public function checkPerm()
{
if (pz::getUser() && pz::getUser()->isMe()) {

return true;
} else {
return false;
}

return false;
}

protected function getUserPerm($perm)
{

if (pz::getUser() && pz::getUser()->getUserPerm()) {

return !empty(pz::getUser()->getUserPerm()->{$perm}());
}

return false;
}

public function controller($func)
Expand Down
20 changes: 17 additions & 3 deletions lib/email/emails_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,26 @@ class pz_emails_controller extends pz_controller
public function checkPerm()
{
if (pz::getUser() && pz::getUser()->isMe()) {

return true;
}
if (pz::getUser() && pz::getUser()->getUserPerm()->hasEmailReadPerm()) {

if ($this->hasReadPerm() || $this->hasWritePerm()) {

return true;
} else {
return false;
}

return false;
}


protected function hasReadPerm()
{
return (pz::getUser() && (pz::getUser()->isMe() || pz::getUser()->getUserPerm()->hasEmailReadPerm()));
}

protected function hasWritePerm()
{
return (pz::getUser() && (pz::getUser()->isMe() || pz::getUser()->getUserPerm()->hasEmailWritePerm()));
}
}
31 changes: 27 additions & 4 deletions lib/email/emails_controller_screen.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,38 @@ class pz_emails_controller_screen extends pz_emails_controller
{
public $name = 'emails';
public $function = '';
public $functions = ['inbox', 'outbox', 'trash', 'email', 'emails', 'create', 'search']; // "history", "spam", "search",
public $function_default = 'inbox';
public $navigation = ['inbox', 'outbox', 'trash', 'search']; // "history", "spam", "search",
public $functions = [/*'inbox', 'outbox', 'trash', 'email', 'emails', 'create', 'search'*/]; // "history", "spam", "search",

public $functions_read = ['inbox', 'outbox', 'trash', 'email', 'emails', 'search'];
public $functions_write = ['create'];

public $function_default = '';
public $navigation = []; // "history", "spam", "search",

private $emails_modes = ['unread_current_emails', 'read_current_emails', 'trash_current_emails', 'delete_current_emails', 'move_current_emails_to_project_id'];

public function __construct()
{
if ($this->hasReadPerm()) {
$this->functions = array_merge($this->functions, $this->functions_read);
$this->navigation = array_merge($this->navigation, ['inbox', 'outbox', 'trash', 'search']);
$this->function_default = 'inbox';
}

if ($this->hasWritePerm()) {
$this->functions = array_merge($this->functions, $this->functions_write);
$this->navigation = array_merge($this->navigation, ['create']);

if (!$this->hasReadPerm()) {
$this->function_default = 'create';
}
}
}


public function controller($function = '')
{
$this->navigation[] = 'create';


if (!in_array($function, $this->functions)) {
$function = $this->function_default;
Expand Down
2 changes: 1 addition & 1 deletion lib/email/eml.php
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ public static function parseAddressListAsArray($address)
if (isset($val->mailbox) && isset($val->host) && $val->host != '.SYNTAX-ERROR.' && $val->host != 'example.com') {
$return[] = [
'email' => strtolower($val->mailbox.'@'.$val->host),
'personal' => $val->personal
'personal' => empty($val->personal)? '' : $val->personal
];
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/screen.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static function getMainNavigation($p = [])
}
}
if ($temp_k != '') {
$items[$temp_k]['classes'] = $k.' last';
$items[$temp_k]['classes'] = $temp_k.' last';
}

$f = new pz_fragment();
Expand Down
2 changes: 1 addition & 1 deletion lib/screen_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class pz_screen_controller extends pz_controller
{
public static $controller = ['login', 'emails', 'projects', 'project', 'calendars', 'addresses', 'clipboard', 'tools', 'admin'];
public static $controller = ['login', 'emails', 'projects', 'project', 'calendars', 'addresses', 'tracker', 'clipboard', 'tools', 'admin'];
public static $controll = null;

public function controller($function)
Expand Down
4 changes: 3 additions & 1 deletion lib/tools/tools_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ class pz_tools_controller extends pz_controller
{
public function checkPerm()
{
if (pz::getUser()) {
if (pz::getUser() && pz::getUser()->isMe()) {

return true;
}

return false;
}
}
10 changes: 5 additions & 5 deletions lib/tools/tools_controller_screen.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class pz_tools_controller_screen extends pz_tools_controller
{
public $name = 'tools';
public $function = '';
public $functions = ['clean', 'profile', 'jobs', 'tracker', 'perms', 'emailsetup'];
public $functions = ['clean', 'profile', 'jobs', 'perms', 'emailsetup'];
public $function_default = 'profile';
public $navigation = ['profile', 'jobs', 'perms', 'emailsetup'];

Expand All @@ -15,10 +15,10 @@ public function controller($function)
if (!in_array($function, $this->functions)) {
$function = $this->function_default;
}
if (!pz::getUser()->isMe() && $function != 'tracker') {
/*if (!pz::getUser()->isMe() && $function != 'tracker') {
$function = 'clean';
$this->navigation = ['no_page'];
}
}*/

$this->function = $function;

Expand All @@ -28,8 +28,8 @@ public function controller($function)
$p['function'] = $this->function;

switch ($this->function) {
case('clean'): return $this->getCleanPage($p);
case('tracker'): return $this->getTracker($p);
//case('clean'): return $this->getCleanPage($p);
//case('tracker'): return $this->getTracker($p);
case('profile'): return $this->getProfilePage($p);
case('perms'): return $this->getPermsPage($p);
case('jobs'): return $this->getJobsPage($p);
Expand Down
14 changes: 14 additions & 0 deletions lib/tracker/tracker_controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

class pz_tracker_controller extends pz_controller
{
public function checkPerm()
{
if (pz::getUser()) {

return true;
}

return false;
}
}
76 changes: 76 additions & 0 deletions lib/tracker/tracker_controller_screen.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php

class pz_tracker_controller_screen extends pz_tracker_controller
{
public $name = 'tracker';
public $function = '';
public $functions = ['tracker'];
public $function_default = 'tracker';
public $navigation = [];
public $visible = false;


public function controller($function)
{
if (!in_array($function, $this->functions)) {
$function = $this->function_default;
}
$this->function = $function;

$p = [];
$p['mediaview'] = 'screen';
$p['controll'] = 'tracker';
$p['function'] = $this->function;

switch ($this->function) {
case('tracker'):
return $this->getTracker($p);
default:
return '';

}
}


public function getTracker()
{

$emails = pz::getUser()->countInboxEmails();
$attandees = pz::getUser()->countAttendeeEvents();

$title = '['.$emails.'] '.pz_screen::getPageTitle();
$return = '<script>
pz_updateInfocounter('.$emails.', '.$attandees.',"'.$title.'");
</script>';

// Problem

// Emails oder andere Dinge nachladen die ein neuerest Datum
// als das aktuellste haben und diese an oberste Stelle der aktuellen
// Liste stellen

// Bsp. Inbox / Outbox / Müll / Projektemails / Kalendertermine / jobs / Adressen
// immer in bestimmtem Kontext: Termine heute / 2 wochen ...

// regelmaessige prüfung, nachladen und anzeigen

// TODO: neue emails laden
// - im tracker die page mit übergeben
// -
/*
$filter = array();
$filter[] = array('type' => 'plain', 'value' => '( (project_id>0 AND status=0) || (project_id=0))');
$filter[] = array('type' => 'plain', 'value' => '( createdesc > )');
$emails = pz::getUser()->getInboxEmails($filter, array(), array('createdesc'), $pager);
*/

// - last trackingdate setzen
// - Datum vom letzten Trackeraufruf mit übergeben und im pz_tracker mit übergeben
// - prüfen ob auf email page
// - email/s nachladen


return $return;
}

}