public static function fromModerationFlagArray($arr)
 {
     $newArr = new KalturaModerationFlagArray();
     foreach ($arr as $obj) {
         $nObj = new KalturaModerationFlag();
         $nObj->fromObject($obj);
         $newArr[] = $nObj;
     }
     return $newArr;
 }
 public static function fromDbArray(array $arr = null, KalturaDetachedResponseProfile $responseProfile = null)
 {
     $newArr = new KalturaModerationFlagArray();
     foreach ($arr as $obj) {
         $nObj = new KalturaModerationFlag();
         $nObj->fromObject($obj, $responseProfile);
         $newArr[] = $nObj;
     }
     return $newArr;
 }
 function flag(KalturaModerationFlag $moderationFlag)
 {
     $kparams = array();
     $this->client->addParam($kparams, "moderationFlag", $moderationFlag->toParams());
     $this->client->queueServiceActionCall("media", "flag", $kparams);
     if ($this->client->isMultiRequest()) {
         return null;
     }
     $resultObject = $this->client->doQueue();
     $this->client->throwExceptionIfError($resultObject);
     $this->client->validateObjectType($resultObject, "null");
     return $resultObject;
 }
示例#4
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;
 }