Create default shares with random IDs instead of the user name as the ID.
Instead of checking if a user has write access to share, check if the user owns a share, to determine whether to create a new one.
editing permissions on their shares. This will keep a user from granting
other users (or guests) access to their address book, notebook, calendar,
etc.">false</configboolean>
+ <configboolean name="auto_create" required="false" desc="Automatically
+ create personal default shares for any users that don't own any
+ shares?">true</configboolean>
<configboolean name="world" required="false" desc="If you enable this
option, users will be able to share their resources with all (authenticated
and guest) users on the system.">true</configboolean>
v4.0-cvs
--------
+[jan] Add a configuration switch for automatic creation of default shares.
[cjh] Move from Net_DNS to Net_DNS2.
[jan] Translations for the framework packages are now bundled with those
packages.
$vars = Horde_Variables::getDefaultVariables();
$calendar_id = $vars->get('c');
-if ($calendar_id == $GLOBALS['registry']->getAuth()) {
- $notification->push(_("This calendar cannot be deleted."), 'horde.warning');
- Horde::url('calendars/', true)->redirect();
-}
if (Kronolith::showAjaxView()) {
Horde::url('', true)->setAnchor('calendar:internal|' . $calendar_id)->redirect();
v3.0-git
--------
+[jan] Default calendars no longer have the user name as the ID.
+[jan] Create a default calendar if the user doesn't own any yet.
[jan] Add CalDAV client support (Request #8525).
[jan] Send agenda emails with HTML part and convert to Horde_View.
[mjr] More complete handling of recurring event exceptions when dealing with the
}
}
return $json;
- }
+ }
/**
* Returns all the alarms active on a specific date.
}
$GLOBALS['prefs']->setValue('display_external_cals', serialize($GLOBALS['display_external_calendars']));
- /* If an authenticated user has no calendars visible and their
- * personal calendar doesn't exist, create it. */
- if ($GLOBALS['registry']->getAuth() &&
- !count($GLOBALS['display_calendars']) &&
- !$GLOBALS['kronolith_shares']->exists($GLOBALS['registry']->getAuth())) {
+ /* If an authenticated doesn't own a calendar, create it. */
+ if (!empty($GLOBALS['conf']['share']['auto_create']) &&
+ $GLOBALS['registry']->getAuth() &&
+ !count(Kronolith::listInternalCalendars(true))) {
$identity = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create();
- $name = $identity->getValue('fullname');
- if (trim($name) == '') {
- $name = $GLOBALS['registry']->getAuth('original');
- }
- $share = $GLOBALS['kronolith_shares']->newShare($GLOBALS['registry']->getAuth(), $GLOBALS['registry']->getAuth());
- $share->set('name', sprintf(_("%s's Calendar"), $name));
+ $share = $GLOBALS['kronolith_shares']->newShare($GLOBALS['registry']->getAuth(), strval(new Horde_Support_Randomid()));
+ $share->set('name', sprintf(_("Calendar of %s"), $identity->getName()));
$GLOBALS['kronolith_shares']->addShare($share);
$GLOBALS['all_calendars'][$GLOBALS['registry']->getAuth()] = new Kronolith_Calendar_Internal(array('share' => $share));
-
- /* Make sure the personal calendar is displayed by default. */
- if (!in_array($GLOBALS['registry']->getAuth(), $GLOBALS['display_calendars'])) {
- $GLOBALS['display_calendars'][] = $GLOBALS['registry']->getAuth();
- }
+ $GLOBALS['display_calendars'][] = $share->getName();
/* Calendar auto-sharing with the user's groups */
if ($GLOBALS['conf']['autoshare']['shareperms'] != 'none') {
*/
public static function deleteShare($calendar)
{
- if ($calendar->getName() == $GLOBALS['registry']->getAuth()) {
- throw new Kronolith_Exception(_("This calendar cannot be deleted."));
- }
-
if (!$GLOBALS['registry']->getAuth() ||
($calendar->get('owner') != $GLOBALS['registry']->getAuth() &&
(!is_null($calendar->get('owner')) || !$GLOBALS['registry']->isAdmin()))) {
v3.0-cvs
--------
+[jan] Default notepads no longer have the user name as the ID.
+[jan] Create a default notepad if the user doesn't own any yet.
[jan] Try to create ISO-8859-1 encoded PDFs if this matches the user's language.
[jan] Add script to convert notes to UTF-8 in the backend.
}
}
- // Make sure we still own at least one notepad.
- if (count(Mnemo::listNotepads(true)) == 0) {
- // If the default share doesn't exist then create it.
- if (!$GLOBALS['mnemo_shares']->exists($GLOBALS['registry']->getAuth())) {
-
- $identity = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create();
- $name = $identity->getValue('fullname');
- if (trim($name) == '') {
- $name = $GLOBALS['registry']->getAuth();
- }
- try {
- $notepad = $GLOBALS['mnemo_shares']->newShare($GLOBALS['registry']->getAuth(), $GLOBALS['registry']->getAuth());
- } catch (Horde_Share_Exception $e) {
- return;
- }
- $notepad->set('name', sprintf(_("%s's Notepad"), $name));
- $GLOBALS['mnemo_shares']->addShare($notepad);
- }
- }
-
return true;
}
}
}
- if (count($GLOBALS['display_notepads']) == 0) {
- $lists = Mnemo::listNotepads(true);
- if (!$GLOBALS['registry']->getAuth()) {
- /* All notepads for guests. */
- $GLOBALS['display_notepads'] = array_keys($lists);
- } else {
- /* Make sure at least the default notepad is visible. */
- $default_notepad = Mnemo::getDefaultNotepad(Horde_Perms::READ);
- if ($default_notepad) {
- $GLOBALS['display_notepads'] = array($default_notepad);
- }
+ /* All tasklists for guests. */
+ if (!count($GLOBALS['display_notepads']) &&
+ !$GLOBALS['registry']->getAuth()) {
+ $GLOBALS['display_tasklists'] = array_keys($_all);
+ }
- /* If the user's personal notepad doesn't exist, then create it. */
- if (!$GLOBALS['mnemo_shares']->exists($GLOBALS['registry']->getAuth())) {
- $identity = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create();
- $name = $identity->getValue('fullname');
- if (trim($name) == '') {
- $name = $GLOBALS['registry']->getAuth();
- }
- $share = $GLOBALS['mnemo_shares']->newShare($GLOBALS['registry']->getAuth(), $GLOBALS['registry']->getAuth());
- $share->set('name', sprintf(_("%s's Notepad"), $name));
- $GLOBALS['mnemo_shares']->addShare($share);
-
- /* Make sure the personal notepad is displayed by default. */
- if (!in_array($GLOBALS['registry']->getAuth(), $GLOBALS['display_notepads'])) {
- $GLOBALS['display_notepads'][] = $GLOBALS['registry']->getAuth();
- }
- }
- }
+ /* If the user doesn't own a notepad, create one. */
+ if (!empty($GLOBALS['conf']['share']['auto_create']) &&
+ $GLOBALS['registry']->getAuth() &&
+ !count(Mnemo::listNotepads(true))) {
+ $identity = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create();
+ $share = $GLOBALS['mnemo_shares']->newShare($GLOBALS['registry']->getAuth(), strval(new Horde_Support_Randomid()));
+ $share->set('name', sprintf(_("Notepad of %s"), $identity->getName()));
+ $GLOBALS['mnemo_shares']->addShare($share);
+ $GLOBALS['display_notepads'][] = $share->getName();
}
$GLOBALS['prefs']->setValue('display_notepads', serialize($GLOBALS['display_notepads']));
$vars = Horde_Variables::getDefaultVariables();
$notepad_id = $vars->get('n');
-if ($notepad_id == $GLOBALS['registry']->getAuth()) {
- $notification->push(_("This notepad cannot be deleted"), 'horde.warning');
- Horde::url('notepads/', true)->redirect();
-}
try {
$notepad = $mnemo_shares->getShare($notepad_id);
} catch (Horde_Share_Exception $e) {
v3.0-git
--------
+[jan] Default task lists no longer have the user name as the ID.
+[jan] Create a default task list if the user doesn't own any yet.
[jan] Add start date to possible colums in task list (Joel Smith
<js-horde@jk1.net>, Request #9083).
[jan] Add system task lists (Request #2059).
*/
public static function deleteTasklist($tasklist)
{
- if ($tasklist->getName() == $GLOBALS['registry']->getAuth()) {
- throw new Horde_Exception_PermissionDenied(_("This task list cannot be deleted."));
- }
-
if (!$GLOBALS['registry']->getAuth() ||
($tasklist->get('owner') != $GLOBALS['registry']->getAuth() &&
(!is_null($tasklist->get('owner')) || !$GLOBALS['registry']->isAdmin()))) {
}
}
- if (count($GLOBALS['display_tasklists']) == 0) {
- $lists = Nag::listTasklists(true);
- if (!$GLOBALS['registry']->getAuth()) {
- /* All tasklists for guests. */
- $GLOBALS['display_tasklists'] = array_keys($lists);
- } else {
- /* Make sure at least the default tasklist is visible. */
- $default_tasklist = Nag::getDefaultTasklist(Horde_Perms::READ);
- if ($default_tasklist) {
- $GLOBALS['display_tasklists'] = array($default_tasklist);
- }
-
- /* If the user's personal tasklist doesn't exist, then create it. */
- if (!$GLOBALS['nag_shares']->exists($GLOBALS['registry']->getAuth())) {
- $identity = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create();
- $name = $identity->getValue('fullname');
- if (trim($name) == '') {
- $name = $GLOBALS['registry']->getAuth('original');
- }
- $share = $GLOBALS['nag_shares']->newShare($GLOBALS['registry']->getAuth(), $GLOBALS['registry']->getAuth());
- $share->set('name', sprintf(_("%s's Task List"), $name));
- $GLOBALS['nag_shares']->addShare($share);
+ /* All tasklists for guests. */
+ if (!count($GLOBALS['display_tasklists']) &&
+ !$GLOBALS['registry']->getAuth()) {
+ $GLOBALS['display_tasklists'] = array_keys($GLOBALS['all_tasklists']);
+ }
- /* Make sure the personal tasklist is displayed by default. */
- if (!in_array($GLOBALS['registry']->getAuth(), $GLOBALS['display_tasklists'])) {
- $GLOBALS['display_tasklists'][] = $GLOBALS['registry']->getAuth();
- }
- }
- }
+ /* If the user doesn't own a task list, create one. */
+ if (!empty($GLOBALS['conf']['share']['auto_create']) &&
+ $GLOBALS['registry']->getAuth() &&
+ !count(Nag::listTasklists(true))) {
+ $identity = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create();
+ $share = $GLOBALS['nag_shares']->newShare($GLOBALS['registry']->getAuth(), strval(new Horde_Support_Randomid()));
+ $share->set('name', sprintf(_("Task list of %s"), $identity->getName()));
+ $GLOBALS['nag_shares']->addShare($share);
+ $GLOBALS['display_tasklists'][] = $share->getName();
}
$GLOBALS['prefs']->setValue('display_tasklists', serialize($GLOBALS['display_tasklists']));
$vars = Horde_Variables::getDefaultVariables();
$tasklist_id = $vars->get('t');
-if ($tasklist_id == $GLOBALS['registry']->getAuth()) {
- $notification->push(_("This task list cannot be deleted."), 'horde.warning');
- Horde::url('tasklists/', true)->redirect();
-}
try {
$tasklist = $nag_shares->getShare($tasklist_id);
} catch (Horde_Share_Exception $e) {
v3.0-git
--------
+[jan] Create a default address book if the user doesn't own any yet.
[jan] Rename sources.php to backends.php.
[mjr] If default addressbook is not browsable, try one from the addressbook pref
(Request: 6536).
*/
function getConfigFromShares($sources)
{
- global $notification;
-
try {
$shares = Turba::listShares();
} catch (Horde_Share_Exception $e) {
- // Notify the user if we failed, but still return the $cfgSource array.
- $notification->push($e, 'horde.error');
+ // Notify the user if we failed, but still return the $cfgSource
+ // array.
+ $GLOBALS['notification']->push($e, 'horde.error');
return $sources;
}
$sortedShares = $defaults = $vbooks = array();
- $defaults = array();
- foreach (array_keys($shares) as $name) {
+ $personal = false;
+ foreach ($shares as $name => &$share) {
if (isset($sources[$name])) {
continue;
}
- $params = @unserialize($shares[$name]->get('params'));
+ $personal |= $share->get('owner') == $GLOBALS['registry']->getAuth();
+
+ $params = @unserialize($share->get('params'));
if (isset($params['type']) && $params['type'] == 'vbook') {
// We load vbooks last in case they're based on other shares.
- $params['share'] = $shares[$name];
+ $params['share'] = $share;
$vbooks[$name] = $params;
} elseif (!empty($params['source']) &&
!empty($sources[$params['source']]['use_shares'])) {
if (empty($params['name'])) {
$params['name'] = $name;
- $shares[$name]->set('params', serialize($params));
- $shares[$name]->save();
+ $share->set('params', serialize($params));
+ $share->save();
}
- // Default share?
- if (empty($defaults[$params['source']])) {
- try {
- $driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($params['source']);
- if ($driver->hasPermission(Horde_Perms::EDIT)) {
- $defaults[$params['source']] = $driver->checkDefaultShare(
- $shares[$name],
- $sources[$params['source']]
- );
- }
- } catch (Turba_Exception $e) {
- $notification->push($e, 'horde.error');
- }
- }
-
- $share = $sources[$params['source']];
- $share['params']['config'] = $sources[$params['source']];
- $share['params']['config']['params']['share'] = $shares[$name];
- $share['params']['config']['params']['name'] = $params['name'];
- $share['title'] = $shares[$name]->get('name');
- $share['type'] = 'share';
- $share['use_shares'] = false;
- $sortedSources[$params['source']][$name] = $share;
+ $info = $sources[$params['source']];
+ $info['params']['config'] = $sources[$params['source']];
+ $info['params']['config']['params']['share'] = $share;
+ $info['params']['config']['params']['name'] = $params['name'];
+ $info['title'] = $share->get('name');
+ $info['type'] = 'share';
+ $info['use_shares'] = false;
+ $sortedSources[$params['source']][$name] = $info;
}
}
if (isset($sortedSources[$source])) {
$newSources = array_merge($newSources, $sortedSources[$source]);
}
- if ($GLOBALS['registry']->getAuth() && empty($defaults[$source])) {
+ if ($GLOBALS['registry']->getAuth() && !$personal) {
// User's default share is missing.
try {
$driver = $GLOBALS['injector']->getInstance('Turba_Driver')->getDriver($source);
} catch (Turba_Exception $e) {
- $notification->push($driver, 'horde.error');
+ $GLOBALS['notification']->push($driver, 'horde.error');
continue;
}
- $sourceKey = strval(new Horde_Support_RandomId());
+ $sourceKey = strval(new Horde_Support_Randomid());
try {
$share = $driver->createShare(
$sourceKey,
$source_config = $sources[$source];
$source_config['params']['share'] = $share;
$newSources[$sourceKey] = $source_config;
+ $personal = true;
}
}
if (!isset($params['name'])) {
/* Sensible default for empty display names */
$identity = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create();
- $name = $identity->getValue('fullname');
- if (trim($name) == '') {
- $name = $GLOBALS['registry']->getAuth('original');
- }
- $name = sprintf(_("%s's Address Book"), $name);
+ $name = sprintf(_("Address book of %s"), $identity->getName());
} else {
$name = $params['name'];
unset($params['name']);