public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser) { $allow_empty = $this->getP("allow_empty_field", false); if ($allow_empty == "false" || $allow_empty === 0) { $allow_empty = false; } $partner = new Partner(); $obj_wrapper = objectWrapperBase::getWrapperClass($partner, 0); $updateable_fields = $obj_wrapper->getUpdateableFields(); // TODO - use fillObjectFromMapOrderedByFields instead $fields_modified = baseObjectUtils::fillObjectFromMap($this->getInputParams(), $partner, "partner_", $updateable_fields, BasePeer::TYPE_PHPNAME, $allow_empty); // check that mandatory fields were set // TODO if (count($fields_modified) > 0) { $target_partner = PartnerPeer::retrieveByPK($partner_id); if ($partner && $target_partner) { if (@$fields_modified["adminEmail"] && $target_partner->getAdminEmail() != $fields_modified["adminEmail"]) { myPartnerUtils::emailChangedEmail($partner_id, $target_partner->getAdminEmail(), $fields_modified["adminEmail"], $target_partner->getName(), PartnerPeer::KALTURAS_PARTNER_EMAIL_CHANGE); } $partner->setType($target_partner->getType()); baseObjectUtils::fillObjectFromObject($updateable_fields, $partner, $target_partner, baseObjectUtils::CLONE_POLICY_PREFER_NEW, null, BasePeer::TYPE_PHPNAME, $allow_empty); $target_partner->save(); $this->addMsg("partner", objectWrapperBase::getWrapperClass($target_partner, objectWrapperBase::DETAIL_LEVEL_DETAILED)); $this->addDebug("added_fields", $fields_modified); } else { $this->addError(APIErrors::UNKNOWN_PARTNER_ID); } } else { $this->addError(APIErrors::NO_FIELDS_SET_FOR_PARTNER); } }
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() && !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(); } $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; }
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; }