public function postSave(PropelPDO $con = null) { if ($this->roleIdsChanged) { // delete old roles $c = new Criteria(); $c->addAnd(KuserToUserRolePeer::KUSER_ID, $this->getId(), Criteria::EQUAL); KuserToUserRolePeer::doDelete($c); // add new roles $idsArray = explode(',', $this->roleIds); foreach ($idsArray as $id) { if (!is_null($id) && $id != '') { $kuserToRole = new KuserToUserRole(); $kuserToRole->setUserRoleId($id); $kuserToRole->setKuserId($this->getId()); $kuserToRole->save(); } } } $this->roleIdsChanged = false; //update all categoryKuser object with kuser if (categoryKuserPeer::isCategroyKuserExistsForKuser($this->getId())) { $featureStatusToRemoveIndex = new kFeatureStatus(); $featureStatusToRemoveIndex->setType(IndexObjectType::CATEGORY_USER); $featureStatusesToRemove = array(); $featureStatusesToRemove[] = $featureStatusToRemoveIndex; $filter = new categoryKuserFilter(); $filter->setUserIdEqual($this->getPuserId()); kJobsManager::addIndexJob($this->getPartnerId(), IndexObjectType::CATEGORY_USER, $filter, true, $featureStatusesToRemove); } return parent::postSave(); }
public function postUpdate(PropelPDO $con = null) { if ($this->alreadyInSave) { return parent::postUpdate($con); } $objectUpdated = $this->isModified(); $objectDeleted = false; if ($this->isColumnModified(kuserPeer::STATUS) && $this->getStatus() == KuserStatus::DELETED) { $objectDeleted = true; } $oldLoginDataId = null; if ($this->isColumnModified(kuserPeer::LOGIN_DATA_ID)) { $oldLoginDataId = $this->oldColumnsValues[kuserPeer::LOGIN_DATA_ID]; } if ($this->isColumnModified(kuserPeer::EMAIL) && $this->getIsAccountOwner() && isset($this->oldColumnsValues[kuserPeer::EMAIL]) && !is_null($this->oldColumnsValues[kuserPeer::EMAIL])) { myPartnerUtils::emailChangedEmail($this->getPartnerId(), $this->oldColumnsValues[kuserPeer::EMAIL], $this->getEmail(), $this->getPartner()->getName(), PartnerPeer::KALTURAS_PARTNER_EMAIL_CHANGE); } if ($this->getIsAccountOwner() && ($this->isColumnModified(kuserPeer::EMAIL) || $this->isColumnModified(kuserPeer::FIRST_NAME) || $this->isColumnModified(kuserPeer::LAST_NAME))) { $partner = $this->getPartner(); $partner->setAccountOwnerKuserId($this->getId(), false); $partner->save(); } if ($this->isColumnModified(kuserPeer::SCREEN_NAME) && categoryKuserPeer::isCategroyKuserExistsForKuser($this->getId())) { $featureStatusToRemoveIndex = new kFeatureStatus(); $featureStatusToRemoveIndex->setType(IndexObjectType::CATEGORY_USER); $featureStatusesToRemove = array(); $featureStatusesToRemove[] = $featureStatusToRemoveIndex; $filter = new categoryKuserFilter(); $filter->setUserIdEqual($this->getPuserId()); kJobsManager::addIndexJob($this->getPartnerId(), IndexObjectType::CATEGORY_USER, $filter, true, $featureStatusesToRemove); } $ret = parent::postUpdate($con); if ($objectDeleted) { kEventsManager::raiseEvent(new kObjectDeletedEvent($this)); // if user is deleted - check if shoult also delete login data UserLoginDataPeer::notifyOneLessUser($this->getLoginDataId()); } if ($objectUpdated) { kEventsManager::raiseEvent(new kObjectUpdatedEvent($this)); if (!$objectDeleted && !is_null($oldLoginDataId) && is_null($this->getLoginDataId())) { // if login was disabled - check if should also delete login data UserLoginDataPeer::notifyOneLessUser($oldLoginDataId); } } return $ret; }