public function persist() { $bFloating = $this->floating(); # Persisted first, as Model users loads this data $this->oIdentityPrincipal->set("uri", "principals/" . $this->get("username")); $this->oIdentityPrincipal->persist(); parent::persist(); if ($bFloating) { # Creating default calendar for user $oDefaultCalendar = new \Baikal\Model\Calendar(); $oDefaultCalendar->set("principaluri", "principals/" . $this->get("username"))->set("displayname", "Default calendar")->set("uri", "default")->set("ctag", 1)->set("description", "Default calendar")->set("components", "VEVENT,VTODO"); $oDefaultCalendar->persist(); # Creating default address book for user $oDefaultAddressBook = new \Baikal\Model\AddressBook(); $oDefaultAddressBook->set("principaluri", "principals/" . $this->get("username"))->set("displayname", "Default Address Book")->set("uri", "default")->set("description", "Default Address Book for " . $this->get("displayname")); $oDefaultAddressBook->persist(); } }
protected function actionDelete() { $aParams = $this->getParams(); $iCalendar = intval($aParams["delete"]); if ($this->actionDeleteConfirmed() !== FALSE) { # catching Exception thrown when model already destroyed # happens when user refreshes page on delete-URL, for instance try { $oModel = new \Baikal\Model\Calendar($iCalendar); $oModel->destroy(); } catch (\Exception $e) { # already deleted; silently discarding } # Redirecting to admin home \Flake\Util\Tools::redirectUsingMeta($this->linkHome()); } else { $oModel = new \Baikal\Model\Calendar($iCalendar); $this->aMessages[] = \Formal\Core\Message::warningConfirmMessage("Check twice, you're about to delete " . $oModel->label() . "</strong> from the database !", "<p>You are about to delete a calendar and all it's scheduled events. This operation cannot be undone.</p><p>So, now that you know all that, what shall we do ?</p>", $this->linkDeleteConfirm($oModel), "Delete <strong><i class='" . $oModel->icon() . " icon-white'></i> " . $oModel->label() . "</strong>", $this->linkHome()); } }