public static function addToModerationList($object, $moderator_kuser_id = null, $status = null)
 {
     if ($object instanceof entry) {
         $entry = $object;
         $moderation = new moderation();
         $moderation->setPartnerId($entry->getPartnerId());
         $moderation->setObjectId($entry->getId());
         $moderation->setObjectType(moderation::MODERATION_OBJECT_TYPE_ENTRY);
         if ($status == null) {
             $moderation->setStatus(moderation::MODERATION_STATUS_PENDING);
         } else {
             $moderation->setStatus($status);
         }
         $moderation->save();
     } elseif ($object instanceof kshow) {
         throw new exception("TO BE IMPLEMENTED addToModerationList - for type kshow");
     } else {
         // ERROR !
         throw new exception("TO BE IMPLEMENTED addToModerationList - for type unknown type");
     }
 }
 protected function fixModeration(moderation &$moderation)
 {
     $moderation->setObjectType(moderation::MODERATION_OBJECT_TYPE_KSHOW);
 }
Example #3
0
 protected function flagEntry(KalturaModerationFlag $moderationFlag, $entryType = null)
 {
     $moderationFlag->validatePropertyNotNull("flaggedEntryId");
     $entryId = $moderationFlag->flaggedEntryId;
     $dbEntry = kCurrentContext::initPartnerByEntryId($entryId);
     // before returning any error, let's validate partner's access control
     if ($dbEntry) {
         $this->validateApiAccessControl($dbEntry->getPartnerId());
     }
     if (!$dbEntry || $entryType !== null && $dbEntry->getType() != $entryType) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     $validModerationStatuses = array(KalturaEntryModerationStatus::APPROVED, KalturaEntryModerationStatus::AUTO_APPROVED, KalturaEntryModerationStatus::FLAGGED_FOR_REVIEW);
     if (!in_array($dbEntry->getModerationStatus(), $validModerationStatuses)) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_CANNOT_BE_FLAGGED);
     }
     $dbModerationFlag = new moderationFlag();
     $dbModerationFlag->setPartnerId($dbEntry->getPartnerId());
     $dbModerationFlag->setKuserId($this->getKuser()->getId());
     $dbModerationFlag->setFlaggedEntryId($dbEntry->getId());
     $dbModerationFlag->setObjectType(KalturaModerationObjectType::ENTRY);
     $dbModerationFlag->setStatus(KalturaModerationFlagStatus::PENDING);
     $dbModerationFlag->setFlagType($moderationFlag->flagType);
     $dbModerationFlag->setComments($moderationFlag->comments);
     $dbModerationFlag->save();
     $dbEntry->setModerationStatus(KalturaEntryModerationStatus::FLAGGED_FOR_REVIEW);
     $updateOccurred = $dbEntry->save();
     $moderationFlag = new KalturaModerationFlag();
     $moderationFlag->fromObject($dbModerationFlag, $this->getResponseProfile());
     // need to notify the partner that an entry was flagged - use the OLD moderation onject that is required for the
     // NOTIFICATION_TYPE_ENTRY_REPORT notification
     // TODO - change to moderationFlag object to implement the interface for the notification:
     // it should have "objectId", "comments" , "reportCode" as getters
     $oldModerationObj = new moderation();
     $oldModerationObj->setPartnerId($dbEntry->getPartnerId());
     $oldModerationObj->setComments($moderationFlag->comments);
     $oldModerationObj->setObjectId($dbEntry->getId());
     $oldModerationObj->setObjectType(moderation::MODERATION_OBJECT_TYPE_ENTRY);
     $oldModerationObj->setReportCode("");
     if ($updateOccurred) {
         myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_REPORT, $oldModerationObj, $dbEntry->getPartnerId());
     }
     return $moderationFlag;
 }
 protected function flagEntry(KalturaModerationFlag $moderationFlag, $entryType = null)
 {
     $moderationFlag->validatePropertyNotNull("flaggedEntryId");
     $entryId = $moderationFlag->flaggedEntryId;
     $dbEntry = entryPeer::retrieveByPKNoFilter($entryId);
     if (!$dbEntry || $entryType !== null && $dbEntry->getType() != $entryType) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     $validModerationStatuses = array(KalturaEntryModerationStatus::APPROVED, KalturaEntryModerationStatus::AUTO_APPROVED, KalturaEntryModerationStatus::FLAGGED_FOR_REVIEW);
     if (!in_array($dbEntry->getModerationStatus(), $validModerationStatuses)) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_CANNOT_BE_FLAGGED);
     }
     $dbModerationFlag = new moderationFlag();
     $dbModerationFlag->setPartnerId($dbEntry->getPartnerId());
     $dbModerationFlag->setKuserId($this->getKuser()->getId());
     $dbModerationFlag->setFlaggedEntryId($dbEntry->getId());
     $dbModerationFlag->setObjectType(KalturaModerationObjectType::ENTRY);
     $dbModerationFlag->setStatus(KalturaModerationFlagStatus::PENDING);
     $dbModerationFlag->setFlagType($moderationFlag->flagType);
     $dbModerationFlag->setComments($moderationFlag->comments);
     $dbModerationFlag->save();
     $dbEntry->setModerationStatus(KalturaEntryModerationStatus::FLAGGED_FOR_REVIEW);
     $dbEntry->incModerationCount();
     $dbEntry->save();
     $moderationFlag = new KalturaModerationFlag();
     $moderationFlag->fromObject($dbModerationFlag);
     // need to notify the partner that an entry was flagged - use the OLD moderation onject that is required for the
     // NOTIFICATION_TYPE_ENTRY_REPORT notification
     // TODO - change to moderationFlag object to implement the interface for the notification:
     // it should have "objectId", "comments" , "reportCode" as getters
     $oldModerationObj = new moderation();
     $oldModerationObj->setPartnerId($dbEntry->getPartnerId());
     $oldModerationObj->setComments($moderationFlag->comments);
     $oldModerationObj->setObjectId($dbEntry->getId());
     $oldModerationObj->setObjectType(moderation::MODERATION_OBJECT_TYPE_ENTRY);
     $oldModerationObj->setReportCode("");
     myNotificationMgr::createNotification(notification::NOTIFICATION_TYPE_ENTRY_REPORT, $oldModerationObj, $dbEntry->getPartnerId());
     return $moderationFlag;
 }
 protected function fixModeration(moderation &$moderation)
 {
     $moderation->setObjectType(moderation::MODERATION_OBJECT_TYPE_ENTRY);
     $entryPartner = $this->getPartner();
     myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_REPORT, $moderation, $entryPartner->getId());
 }
Example #6
0
 private static function initModerationTypeMap()
 {
     if (self::$MODERATION_TYPE_MAP == null) {
         self::$MODERATION_TYPE_MAP = array(self::MODERATION_OBJECT_TYPE_KSHOW => "kshow", self::MODERATION_OBJECT_TYPE_ENTRY => "entry", self::MODERATION_OBJECT_TYPE_USER => "user");
     }
 }
Example #7
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      moderation $value A moderation object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(moderation $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         if (isset(self::$instances[$key]) || count(self::$instances) < kConf::get('max_num_instances_in_pool')) {
             self::$instances[$key] = $obj;
             kMemoryManager::registerPeer('moderationPeer');
         }
     }
 }
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      moderation $value A moderation object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(moderation $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }