public function getScopedProviderJobData(kScope $scope = null) { $ret = new kEmailNotificationCategoryRecipientJobData(); if (!$this->categoryId) { return $ret; } if ($this->categoryId instanceof kStringField) { $this->categoryId->setScope($scope); } $implicitCategoryId = $this->categoryId->getValue(); $categoryUserFilter = new categoryKuserFilter(); $categoryUserFilter->set('_matchor_permission_names', PermissionName::CATEGORY_SUBSCRIBE); if ($this->categoryUserFilter) { $categoryUserFilter = $this->categoryUserFilter; } $categoryUserFilter->setCategoryIdEqual($implicitCategoryId); $ret->setCategoryUserFilter($categoryUserFilter); return $ret; }
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; }
protected function kuserDelete(kuser $kuser) { $filter = new categoryKuserFilter(); $filter->setUserIdEqual($kuser->getPuserId()); $c = new Criteria(); $c->add(categoryKuserPeer::PUSER_ID, $kuser->getPuserId()); if (categoryKuserPeer::doSelectOne($c)) { kJobsManager::addDeleteJob($kuser->getPartnerId(), DeleteObjectType::CATEGORY_USER, $filter); } if ($kuser->getType() == KuserType::USER) { // remove user from groups KuserKgroupPeer::deleteByKuserId($kuser->getId()); } elseif ($kuser->getType() == KuserType::GROUP) { // remove users from group $filter = new KuserKgroupFilter(); $filter->setGroupIdEqual($kuser->getPuserId()); $c = new Criteria(); $c->add(KuserKgroupPeer::PGROUP_ID, $kuser->getPuserId()); if (KuserKgroupPeer::doSelectOne($c)) { kJobsManager::addDeleteJob($kuser->getPartnerId(), DeleteObjectType::GROUP_USER, $filter); } } }
protected function addIndexCategoryKuserJob($categoryId = null, $shouldUpdate = true) { $featureStatusToRemoveIndex = new kFeatureStatus(); $featureStatusToRemoveIndex->setType(IndexObjectType::CATEGORY_USER); $featureStatusesToRemove = array(); $featureStatusesToRemove[] = $featureStatusToRemoveIndex; $filter = new categoryKuserFilter(); $filter->setCategoryIdEqual($categoryId); kJobsManager::addIndexJob($this->getPartnerId(), IndexObjectType::CATEGORY_USER, $filter, $shouldUpdate, $featureStatusesToRemove); }
require_once __DIR__ . '/../../bootstrap.php'; $criteria = new Criteria(); $criteria->add(EventNotificationTemplatePeer::STATUS, EventNotificationTemplateStatus::DELETED, Criteria::NOT_EQUAL); $criteria->add(EventNotificationTemplatePeer::SYSTEM_NAME, array('New_Item_Pending_Moderation', 'New_Item_Pending_Moderation_2', 'Entry_Was_Added_To_Channel'), Criteria::IN); $criteria->addAscendingOrderByColumn(EventNotificationTemplatePeer::ID); $criteria->setLimit(100); $eventNotificationTemplates = EventNotificationTemplatePeer::doSelect($criteria); $lastId = 0; $count = 0; while ($eventNotificationTemplates) { foreach ($eventNotificationTemplates as $eventNotificationTemplate) { /* @var $eventNotificationTemplate EmailNotificationTemplate */ $lastId = $eventNotificationTemplate->getId(); $categoryId = new kEvalStringField(); $categoryId->setCode('$scope->getEvent()->getObject()->getCategoryId()'); $categoryUserFilter = new categoryKuserFilter(); if ($eventNotificationTemplate->getSystemName() == 'Entry_Was_Added_To_Channel') { $categoryUserFilter->set('_matchor_permission_names', 'CATEGORY_SUBSCRIBE'); } else { $categoryUserFilter->set('_matchor_permission_names', 'CATEGORY_MODERATE'); } $bcc = new kEmailNotificationCategoryRecipientProvider(); $bcc->setCategoryId($categoryId); $bcc->setCategoryUserFilter($categoryUserFilter); $eventNotificationTemplate->setBcc($bcc); $eventNotificationTemplate->setTo(null); $eventNotificationTemplate->save(); $count++; } $criteria->add(EventNotificationTemplatePeer::ID, $lastId, Criteria::GREATER_THAN); $eventNotificationTemplates = EventNotificationTemplatePeer::doSelect($criteria);
protected function kuserDelete(kuser $kuser) { $filter = new categoryKuserFilter(); $filter->setUserIdEqual($kuser->getPuserId()); kJobsManager::addDeleteJob($kuser->getPartnerId(), DeleteObjectType::CATEGORY_USER, $filter); }