Example #1
0
 protected function afterSave($wasNew)
 {
     if ($wasNew) {
         $this->acl->addGroup($this->id, Acl::READ_PERMISSION);
     }
     return parent::afterSave($wasNew);
 }
Example #2
0
 protected function afterSave($wasNew)
 {
     if (\GO::modules()->isInstalled('log')) {
         Log::create($wasNew ? Log::ACTION_ADD : Log::ACTION_UPDATE, 'Added ' . $this->contact->name . ' to addresslist ' . $this->addresslist->name, $this->className(), $this->contact_id . ':' . $this->addresslist_id);
     }
     return parent::afterSave($wasNew);
 }
Example #3
0
 protected function afterSave($wasNew)
 {
     if ($wasNew && $this->checkSlaves) {
         $this->field->checkTreeSelectSlaves();
     }
     return parent::afterSave($wasNew);
 }
Example #4
0
 protected function afterSave($wasNew)
 {
     $stmt = $this->group->calendars;
     foreach ($stmt as $calendar) {
         $calendar->acl->addUser($this->user_id, \GO\Base\Model\Acl::DELETE_PERMISSION);
     }
     return parent::afterSave($wasNew);
 }
Example #5
0
 protected function afterSave($wasNew)
 {
     if ($this->mainevent) {
         $this->mainevent->touch();
         $this->mainevent->setReminder();
     }
     return parent::afterSave($wasNew);
 }
Example #6
0
 protected function afterSave($wasNew)
 {
     // Only do this when it's a new model
     if ($wasNew) {
         $this->acl->addGroup(GO::config()->group_everyone);
     }
     return parent::afterSave($wasNew);
 }
Example #7
0
 protected function afterSave($wasNew)
 {
     if ($this->aclItem) {
         //Add log message for activitylog here
         if (\GO::modules()->isInstalled("log")) {
             \GO\Log\Model\Log::create("acl", $this->aclItem->description, $this->aclItem->className(), $this->aclItem->id);
         }
         $this->aclItem->touch();
     }
     return parent::afterSave($wasNew);
 }
Example #8
0
 protected function afterSave($wasNew)
 {
     $campaignModel = $this->campaign;
     if (!empty($campaignModel)) {
         $sentAdd = $this->isModified('sent') ? $this->sent - $this->getOldAttributeValue('sent') : 0;
         $errorAdd = $this->isModified('errors') ? $this->errors - $this->getOldAttributeValue('errors') : 0;
         $totalAdd = $this->isModified('total') ? $this->total - $this->getOldAttributeValue('total') : 0;
         $openedAdd = $this->isModified('opened') ? $this->opened - $this->getOldAttributeValue('opened') : 0;
         if ($sentAdd != 0 || $errorAdd != 0 || $totalAdd != 0 || $openedAdd != 0) {
             $campaignModel->n_sent += $sentAdd;
             $campaignModel->n_send_errors += $errorAdd;
             $campaignModel->n_total += $totalAdd;
             $campaignModel->n_opened += $openedAdd;
             $campaignModel->save();
         }
     }
     return parent::afterSave($wasNew);
 }
Example #9
0
 protected function afterSave($wasNew)
 {
     $sentMailingModel = $this->sentMailing;
     if (!empty($sentMailingModel)) {
         $sentNow = $this->sent ? 1 : 0;
         if ($this->isModified('sent')) {
             $sentBefore = $this->getOldAttributeValue('sent') ? 1 : 0;
         } else {
             $sentBefore = $sentNow;
         }
         $sentAdd = $sentNow - $sentBefore;
         $errorNow = $this->has_error ? 1 : 0;
         if ($this->isModified('has_error')) {
             $errorBefore = $this->getOldAttributeValue('has_error') ? 1 : 0;
         } else {
             $errorBefore = $errorNow;
         }
         $errorsAdd = $errorNow - $errorBefore;
         $openedNow = $this->campaigns_opened ? 1 : 0;
         if ($this->isModified('campaigns_opened')) {
             $openedBefore = $this->getOldAttributeValue('campaigns_opened') ? 1 : 0;
         } else {
             $openedBefore = $openedNow;
         }
         $openedAdd = $openedNow - $openedBefore;
         if ($sentAdd != 0 || $errorsAdd != 0 || $openedAdd != 0) {
             //				var_dump($this->contact_id.' , '.$this->sent_mailing_id);
             //				var_dump($sentNow);
             //			var_dump($sentBefore);
             //			exit();
             $sentMailingModel->sent += $sentAdd;
             $sentMailingModel->errors += $errorsAdd;
             $sentMailingModel->opened += $openedAdd;
             $sentMailingModel->save();
         }
     }
     return parent::afterSave($wasNew);
 }
Example #10
0
 protected function afterSave($wasNew)
 {
     $this->_addQuota();
     if ($wasNew) {
         $this->notifyUsers($this->folder_id, FolderNotificationMessage::ADD_FILE, $this->name, $this->folder->path);
     } else {
         if ($this->isModified() && !$this->isModified('name') && !$this->isModified('folder_id')) {
             $this->notifyUsers($this->folder_id, FolderNotificationMessage::UPDATE_FILE, $this->path);
         }
     }
     //touch the timestamp so it won't sync with the filesystem
     if ($this->isModified('folder_id')) {
         GO::debug("touching parent");
         $this->folder->touch();
         $oldParent = \GO\Files\Model\Folder::model()->findByPk($this->getOldAttributeValue('folder_id'));
         if ($oldParent) {
             GO::debug("touching old parent");
             $oldParent->touch();
         }
     }
     return parent::afterSave($wasNew);
 }
Example #11
0
 protected function afterSave($wasNew)
 {
     $c = new \GO\Base\Db\Connection();
     $c->createStatement()->update(Event::model()->tableName(), array('background' => $this->color), 'category_id=:category_id', array('category_id' => $this->id));
     return parent::afterSave($wasNew);
 }
Example #12
0
 protected function afterSave($wasNew)
 {
     if (!$wasNew && $this->updateRelatedParticipants && $this->isModified('status')) {
         $stmt = $this->getRelatedParticipants();
         foreach ($stmt as $participant) {
             $participant->updateRelatedParticipants = false;
             //prevent endless loop. Because it will also process this aftersave
             $participant->event->touch();
             // Touch the event to update its mtime.
             $participant->status = $this->status;
             $participant->save();
         }
         //$this->event->touch(); // Touch the event to update the modification date.
     }
     if ($wasNew && $this->event->is_organizer) {
         //add this participant to each existing event.
         if (!$this->dontCreateEvent && $this->user_id > 0 && !$this->is_organizer) {
             //			if ($this->user_id > 0 && !$this->is_organizer) {
             $newEvent = $this->event->createCopyForParticipant($this);
         }
         $stmt = $this->event->getRelatedParticipantEvents();
         foreach ($stmt as $event) {
             if (empty($newEvent) || $event->id != $newEvent->id) {
                 $p = Participant::model()->findSingleByAttributes(array('event_id' => $event->id, 'email' => $this->email));
                 if (!$p) {
                     $p = new Participant();
                     $p->setAttributes($this->getAttributes('raw'), false);
                     $p->event_id = $event->id;
                     $p->id = null;
                     $p->save();
                 }
             }
         }
         if (!$this->is_organizer && $this->contact) {
             $this->contact->link($this->event);
         }
     }
     return parent::afterSave($wasNew);
 }
Example #13
0
 protected function afterSave($wasNew)
 {
     $this->alterDatabase($wasNew);
     return parent::afterSave($wasNew);
 }
Example #14
0
 protected function afterSave($wasNew)
 {
     if (!$this->admin_menu) {
         $this->acl->addGroup(\GO::config()->group_internal);
     }
     if ($wasNew) {
         if ($this->moduleManager) {
             $this->moduleManager->install();
         }
     }
     return parent::afterSave($wasNew);
 }
Example #15
0
 protected function afterSave($wasNew)
 {
     if ($wasNew) {
         $this->fsFolder->create();
         //sync parent timestamp
         if ($this->parent) {
             $this->parent->mtime = $this->parent->fsFolder->mtime();
             $this->parent->save(true);
             $this->notifyUsers($this->parent->id, FolderNotificationMessage::ADD_FOLDER, $this->name, $this->parent->getPath());
         }
     } else {
         $this->_path = null;
         if (!$this->fsFolder->exists()) {
             if ($this->isModified('parent_id')) {
                 Folder::model()->clearFolderCache();
                 //file will be moved so we need the old folder path.
                 $oldFolderId = $this->getOldAttributeValue('parent_id');
                 $oldFolder = Folder::model()->findByPk($oldFolderId, false, true);
                 $oldRelPath = $oldFolder->path;
                 $oldName = $this->isModified('name') ? $this->getOldAttributeValue('name') : $this->name;
                 $oldPath = \GO::config()->file_storage_path . $oldRelPath . '/' . $oldName;
                 $fsFolder = new \GO\Base\Fs\Folder($oldPath);
                 $newRelPath = $this->getPath(true);
                 $newFsFolder = new \GO\Base\Fs\Folder(\GO::config()->file_storage_path . dirname($newRelPath));
                 if (!$fsFolder->move($newFsFolder)) {
                     throw new \Exception("Could not rename folder on the filesystem");
                 }
                 $this->notifyUsers(array($this->id, $oldFolder->id, $this->parent->id), FolderNotificationMessage::MOVE_FOLDER, $oldRelPath . '/' . $oldName, $newRelPath);
             }
             //if the filesystem folder is missing check if we need to move it when the name or parent folder changes.
             if ($this->isModified('name')) {
                 Folder::model()->clearFolderCache();
                 \GO::debug("Renaming from " . $this->getOldAttributeValue('name') . " to " . $this->name);
                 $oldFsFolder = new \GO\Base\Fs\Folder(dirname($this->fsFolder->path()) . '/' . $this->getOldAttributeValue('name'));
                 $oldFsFolder->rename($this->name);
                 $this->notifyUsers(array($this->id, $this->parent->id), FolderNotificationMessage::RENAME_FOLDER, $this->parent->path . '/' . $this->getOldAttributeValue('name'), $this->parent->path . '/' . $this->name);
             }
         }
     }
     //sync parent timestamp
     if ($this->isModified('parent_id')) {
         if ($this->parent) {
             $oldFolderId = $this->getOldAttributeValue('parent_id');
             $oldFolder = \GO\Files\Model\Folder::model()->findByPk($oldFolderId, false, true);
             //so it won't sync the filesystem
             if ($oldFolder) {
                 GO::debug('touching old parent');
                 $oldFolder->touch();
             }
             GO::debug('touching parent');
             $this->parent->touch();
         }
     }
     return parent::afterSave($wasNew);
 }
Example #16
0
 protected function afterSave($wasNew)
 {
     $file = $this->getFilesystemFile();
     $folder = $file->parent();
     $folder->create();
     $this->file->fsFile->move($folder, $file->name());
     $this->file->folder->quotaUser->calculatedDiskUsage($this->size_bytes)->save(true);
     //user quota
     \GO::config()->save_setting("file_storage_usage", \GO::config()->get_setting('file_storage_usage') + $this->size_bytes);
     $this->_deleteOld();
     return parent::afterSave($wasNew);
 }
Example #17
0
 protected function afterSave($wasNew)
 {
     //add exception model for the original recurring event
     //		if ($wasNew && $this->exception_for_event_id > 0 && !empty($this->exception_date)) {
     //
     //			$newExeptionEvent = Event::model()->findByPk($this->exception_for_event_id);
     //			$newExeptionEvent->addException($this->exception_date, $this->id);
     //		}
     //
     //			//copy particpants to new \Exception
     //			$stmt = $newExeptionEvent->participants();
     //			while($participant = $stmt->fetch()){
     //				$newParticipant = new Participant();
     //				$newParticipant->setAttributes($participant->getAttributes());
     //				unset($newParticipant->id);
     //				$newParticipant->event_id=$this->id;
     //				if(!$newParticipant->is_organizer){
     //					$newParticipant->status=Participant::STATUS_PENDING;
     //				}
     //				$newParticipant->save();
     //			}
     //		}
     //if this event belongs to a recurring series we must touch the master event
     //too or it won't be synchronized with z-push or caldav
     if ($exceptionEvent = $this->_exceptionEvent) {
         $exceptionEvent->touch();
     }
     //move exceptions if this event was moved in time
     if (!$wasNew && !empty($this->rrule) && $this->isModified('start_time')) {
         $diffSeconds = $this->start_time - $this->getOldAttributeValue('start_time');
         $stmt = $this->exceptions();
         while ($exception = $stmt->fetch()) {
             $exception->time += $diffSeconds;
             $exception->save();
         }
     }
     if ($this->isResource()) {
         $adminUserIds = array();
         $groupAdminsStmt = $this->calendar->group->admins;
         while ($adminUser = $groupAdminsStmt->fetch()) {
             $adminUserIds[] = $adminUser->id;
         }
         if ((!in_array(\GO::user()->id, $adminUserIds) || $this->isModified('status')) && $this->end_time > time()) {
             $this->_sendResourceNotification($wasNew);
         }
     } else {
         if (!$wasNew && $this->hasModificationsForParticipants()) {
             $this->_updateResourceEvents();
         }
     }
     $this->setReminder();
     //update events that belong to this organizer event
     if ($this->is_organizer && !$wasNew && !$this->isResource()) {
         $updateAttr = array('name' => $this->name, 'start_time' => $this->start_time, 'end_time' => $this->end_time, 'location' => $this->location, 'description' => $this->description, 'rrule' => $this->rrule, 'status' => $this->status, 'repeat_end_time' => $this->repeat_end_time);
         if ($this->isModified(array_keys($updateAttr))) {
             $events = $this->getRelatedParticipantEvents();
             foreach ($events as $event) {
                 \GO::debug("updating related event: " . $event->id);
                 if ($event->id != $this->id && $this->is_organizer != $event->is_organizer) {
                     //this should never happen but to prevent an endless loop it's here.
                     $event->setAttributes($updateAttr, false);
                     $event->updatingRelatedEvent = true;
                     $event->save(true);
                     //						$stmt = $event->participants;
                     //						$stmt->callOnEach('delete');
                     //
                     //						$this->duplicateRelation('participants', $event);
                 }
             }
         }
     }
     if ($this->isModified()) {
         Calendar::versionUp($this->calendar_id);
     }
     return parent::afterSave($wasNew);
 }
Example #18
0
 protected function afterSave($wasNew)
 {
     //		 if($this->isModified('slug')){
     foreach ($this->children as $child) {
         $slugArray = explode('/', $child->slug);
         $ownSlug = array_pop($slugArray);
         $child->slug = $child->parent->slug;
         //					GO::debug("Parent SLUG: ".$child->slug);
         if (!empty($child->slug)) {
             $child->slug .= '/';
         }
         $child->slug .= $ownSlug;
         //					GO::debug("SLUG new: ".$child->slug);
         $child->save();
     }
     //		 }
     return parent::afterSave($wasNew);
 }
Example #19
0
 protected function afterSave($wasNew)
 {
     if ($wasNew) {
         if ($this->description != 'readonly') {
             $this->addGroup(\GO::config()->group_root, Acl::MANAGE_PERMISSION);
             $this->addUser($this->user_id, Acl::MANAGE_PERMISSION);
         }
     } elseif ($this->isModified('user_id')) {
         $this->addUser($this->user_id, Acl::MANAGE_PERMISSION);
     }
     return parent::afterSave($wasNew);
 }
Example #20
0
 protected function afterSave($wasNew)
 {
     if ($wasNew) {
         $everyoneGroup = Group::model()->findByPk(GO::config()->group_everyone);
         $everyoneGroup->addUser($this->id);
         $this->acl->user_id = $this->id;
         $this->acl->save();
         if (!empty(GO::config()->register_user_groups)) {
             $groups = explode(',', GO::config()->register_user_groups);
             foreach ($groups as $groupName) {
                 $group = Group::model()->findByName($groupName);
                 if ($group) {
                     $group->addUser($this->id);
                 }
             }
         }
         $this->_setVisibility();
     }
     if (!$this->skip_contact_update && ($this->isNew || $this->isModified(array('first_name', 'middle_name', 'last_name', 'email')))) {
         $this->createContact();
     }
     return parent::afterSave($wasNew);
 }
Example #21
0
 protected function afterSave($wasNew)
 {
     if (!$wasNew && $this->isModified('addressbook_id')) {
         //make sure contacts and companies are in the same addressbook.
         $whereCriteria = \GO\Base\Db\FindCriteria::newInstance()->addCondition('company_id', $this->id)->addCondition('addressbook_id', $this->addressbook_id, '!=');
         $findParams = \GO\Base\Db\FindParams::newInstance()->ignoreAcl()->criteria($whereCriteria);
         $stmt = Contact::model()->find($findParams);
         while ($contact = $stmt->fetch()) {
             $contact->addressbook_id = $this->addressbook_id;
             $contact->save();
         }
     }
     return parent::afterSave($wasNew);
 }
Example #22
0
 public function afterSave($wasNew)
 {
     if ($this->isModified('reminder')) {
         $this->deleteReminders();
         if ($this->reminder > 0) {
             if ($this->reminder > time() && $this->status != 'COMPLETED') {
                 $this->addReminder($this->name, $this->reminder, $this->tasklist->user_id);
             }
         }
     }
     if ($this->isModified('project_id') && $this->project) {
         $this->link($this->project);
     }
     if ($this->isModified('project_id') && !empty($this->project2)) {
         $this->link($this->project2);
     }
     if ($this->isModified()) {
         Tasklist::versionUp($this->tasklist_id);
     }
     return parent::afterSave($wasNew);
 }
Example #23
0
 protected function afterSave($wasNew)
 {
     if (!empty($this->_session_password)) {
         if (!isset(\GO::session()->values['emailModule']) || !isset(\GO::session()->values['emailModule']['accountPasswords']) || !is_array(\GO::session()->values['emailModule']['accountPasswords'])) {
             \GO::session()->values['emailModule']['accountPasswords'] = array();
         }
         \GO::session()->values['emailModule']['accountPasswords'][$this->id] = $this->_session_password;
     }
     if (!empty($this->_session_smtp_password)) {
         if (!isset(\GO::session()->values['emailModule']) || !isset(\GO::session()->values['emailModule']['smtpPasswords']) || !is_array(\GO::session()->values['emailModule']['smtpPasswords'])) {
             \GO::session()->values['emailModule']['smtpPasswords'] = array();
         }
         \GO::session()->values['emailModule']['smtpPasswords'][$this->id] = $this->_session_smtp_password;
     }
     if ($wasNew) {
         Label::model()->createDefaultLabels($this->id);
     }
     return parent::afterSave($wasNew);
 }
Example #24
0
 protected function afterSave($wasNew)
 {
     $this->updateAclMtime();
     return parent::afterSave($wasNew);
 }
Example #25
0
 protected function afterSave($wasNew)
 {
     if (!$wasNew && $this->isModified('addressbook_id') && ($company = $this->company())) {
         //make sure company is in the same addressbook.
         $company->addressbook_id = $this->addressbook_id;
         $company->save();
     }
     if (!$this->skip_user_update && $this->isModified(array('first_name', 'middle_name', 'last_name', 'email')) && $this->goUser) {
         $this->goUser->first_name = $this->first_name;
         $this->goUser->middle_name = $this->middle_name;
         $this->goUser->last_name = $this->last_name;
         $this->goUser->email = $this->email;
         $this->goUser->skip_contact_update = true;
         if ($this->goUser->isModified()) {
             $this->goUser->save(true);
         }
     }
     return parent::afterSave($wasNew);
 }