/** * @return array */ public function AjaxCalendarShareUpdate() { $mResult = false; $oAccount = $this->getDefaultAccountFromParam(); $sCalendarId = $this->getParamValue('Id'); $bIsPublic = (bool) $this->getParamValue('IsPublic'); $aShares = @json_decode($this->getParamValue('Shares'), true); $bShareToAll = (bool) $this->getParamValue('ShareToAll', false); $iShareToAllAccess = (int) $this->getParamValue('ShareToAllAccess', \ECalendarPermission::Read); if (!$this->oApiCapability->isCalendarSupported($oAccount)) { throw new \ProjectCore\Exceptions\ClientException(\ProjectCore\Notifications::CalendarsNotAllowed); } // Share calendar to all users $aShares[] = array('email' => $this->oApiCalendar->getTenantUser($oAccount), 'access' => $bShareToAll ? $iShareToAllAccess : \ECalendarPermission::RemovePermission); // Public calendar $aShares[] = array('email' => $this->oApiCalendar->getPublicUser(), 'access' => $bIsPublic ? \ECalendarPermission::Read : \ECalendarPermission::RemovePermission); $mResult = $this->oApiCalendar->updateCalendarShares($oAccount, $sCalendarId, $aShares); return $this->DefaultResponse($oAccount, __FUNCTION__, $mResult); }