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();
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
 public function addFeaturesStatus($type, $value = 1)
 {
     $newFeatureStatus = new kFeatureStatus();
     $newFeatureStatus->setType($type);
     $newFeatureStatus->setValue($value);
     $this->putInCustomData($type, $newFeatureStatus, 'featuresStatuses');
     $this->save();
 }
 public function addIndexCategoryInheritedTreeJob($fullIdsStartsWithCategoryId)
 {
     $featureStatusToRemoveIndex = new kFeatureStatus();
     $featureStatusToRemoveIndex->setType(IndexObjectType::CATEGORY);
     $featureStatusesToRemove = array();
     $featureStatusesToRemove[] = $featureStatusToRemoveIndex;
     $filter = new categoryFilter();
     $filter->setFullIdsStartsWith($fullIdsStartsWithCategoryId);
     $filter->setInheritanceTypeEqual(InheritanceType::INHERIT);
     $c = KalturaCriteria::create(categoryPeer::OM_CLASS);
     $filter->attachToCriteria($c);
     KalturaCriterion::disableTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY);
     $categories = categoryPeer::doSelect($c);
     KalturaCriterion::restoreTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY);
     if (count($categories)) {
         kJobsManager::addIndexJob($this->getPartnerId(), IndexObjectType::CATEGORY, $filter, true, $featureStatusesToRemove);
     }
 }
Ejemplo n.º 5
0
 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);
 }
 public function resetFeaturesStatusByType($type)
 {
     $openStatuses = array(BatchJob::BATCHJOB_STATUS_ALMOST_DONE, BatchJob::BATCHJOB_STATUS_RETRY, BatchJob::BATCHJOB_STATUS_PENDING, BatchJob::BATCHJOB_STATUS_QUEUED, BatchJob::BATCHJOB_STATUS_PROCESSING, BatchJob::BATCHJOB_STATUS_PROCESSED, BatchJob::BATCHJOB_STATUS_MOVEFILE);
     $criteria = new Criteria();
     $criteria->add(BatchJobPeer::PARTNER_ID, $this->getId());
     $criteria->add(BatchJobPeer::JOB_TYPE, BatchJobType::INDEX);
     $criteria->add(BatchJobPeer::JOB_SUB_TYPE, $type);
     $criteria->add(BatchJobPeer::STATUS, $openStatuses, Criteria::IN);
     $batchJob = BatchJobPeer::doSelectOne($criteria);
     $featuresStatuses = $this->getFeaturesStatus();
     if ($batchJob) {
         $newFeatureStatus = new kFeatureStatus();
         $newFeatureStatus->setType($type);
         $newFeatureStatus->setValue(1);
         $featuresStatuses[$type] = $newFeatureStatus;
     } elseif (isset($featuresStatuses[$type])) {
         unset($featuresStatuses[$type]);
     }
     $this->setFeaturesStatus($featuresStatuses);
     $this->setUpdatedAt(time());
     $this->save();
 }