88 lines
2.3 KiB
PHP
88 lines
2.3 KiB
PHP
<?php
|
|
|
|
require("../../config/config.php");
|
|
|
|
define('FRONKDB_SQLDEBUG', false);
|
|
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
|
|
|
|
require_once(LIBDIR . "/mvcfronk/mfRouter/mfRouter.php");
|
|
require_once(LIBDIR . "/mvcfronk/mfBase/mfBaseModel.php");
|
|
require_once(LIBDIR . "/mvcfronk/mfBase/mfBaseController.php");
|
|
|
|
$me = new User(154);
|
|
define("INTERNAL_USER_ID", $me->id);
|
|
define("INTERNAL_USER_USERNAME", $me->username);
|
|
|
|
$calendar = CalendarModel::search(array("checkSubscriptions" => 1));
|
|
$adminUser = array(89, 173, 167, 8, 6, 9, 5, 123);
|
|
|
|
|
|
$addcalendararray = array(38, 39);
|
|
|
|
foreach ($calendar as $cal) {
|
|
$data = [];
|
|
$update = 0;
|
|
$allCalendarUser = $allCalendar;
|
|
unset($newrights);
|
|
if (in_array($cal->user_id, $adminUser)) {
|
|
$admin = 1;
|
|
} else {
|
|
$admin = 0;
|
|
}
|
|
$insert = 1;
|
|
$rights = json_decode($cal->rights, true);
|
|
$groups = json_decode($cal->groups, true);
|
|
foreach ($addcalendararray as $addcal) {
|
|
|
|
|
|
foreach ($rights as $key => $right) {
|
|
if ($key == $addcal) {
|
|
$insert = 0;
|
|
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
if ($insert == 1) {
|
|
if ($admin == 1) {
|
|
$rights[$addcal] = "all";
|
|
} else {
|
|
$rights[$addcal] = "read";
|
|
}
|
|
|
|
|
|
foreach ($groups as $key => $group) {
|
|
if ($group['name'] == "Persönlich") {
|
|
$count = count($groups[$key]['calendars']);
|
|
|
|
$groups[$key]['calendars'][$count]['calendar_id'] = $addcal;
|
|
$groups[$key]['calendars'][$count]['checked'] = 0;
|
|
$groups[$key]['calendars'][$count]['origin'] = 1;
|
|
break;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
// echo $insert;
|
|
// var_dump($groups);
|
|
if (!$groups) {
|
|
echo $cal->user_id;
|
|
}
|
|
if ($insert == 1) {
|
|
if ($groups) {
|
|
$data['groups'] = json_encode($groups, JSON_UNESCAPED_UNICODE);
|
|
}
|
|
$data['rights'] = json_encode($rights, JSON_UNESCAPED_UNICODE);
|
|
// var_dump(json_encode($groups, JSON_UNESCAPED_UNICODE));
|
|
// var_dump(json_encode($rights, JSON_UNESCAPED_UNICODE));
|
|
$cal->update($data);
|
|
echo "save" . $cal->id . "\n";
|
|
$cal->save();
|
|
}
|
|
|
|
|
|
} |