Esempio n. 1
0
 /**
  * Adds a new mix.
  * If the dataContent is null, a default timeline will be created.
  * 
  * @action add
  * @param KalturaMixEntry $mixEntry Mix entry metadata
  * @return KalturaMixEntry The new mix entry
  */
 function addAction(KalturaMixEntry $mixEntry)
 {
     $mixEntry->validatePropertyMinLength("name", 1);
     $mixEntry->validatePropertyNotNull("editorType");
     $dbEntry = $mixEntry->toObject(new entry());
     $this->checkAndSetValidUser($mixEntry, $dbEntry);
     $this->checkAdminOnlyInsertProperties($mixEntry);
     $this->validateAccessControlId($mixEntry);
     $this->validateEntryScheduleDates($mixEntry);
     $kshow = $this->createDummyKShow();
     $dbEntry->setKshowId($kshow->getId());
     $dbEntry->setPartnerId($this->getPartnerId());
     $dbEntry->setSubpId($this->getPartnerId() * 100);
     $dbEntry->setStatus(KalturaEntryStatus::READY);
     $dbEntry->setMediaType(entry::ENTRY_MEDIA_TYPE_SHOW);
     // for backward compatibility
     if (!$dbEntry->getThumbnail()) {
         $dbEntry->setThumbnail("&auto_edit.jpg");
     }
     $dbEntry->save();
     // we need the id for setDataContent
     // set default data if no data given
     if ($mixEntry->dataContent === null) {
         myEntryUtils::modifyEntryMetadataWithText($dbEntry, "", 0);
     } else {
         $dbEntry->setDataContent($mixEntry->dataContent, true, true);
         $dbEntry->save();
     }
     $kshow->setShowEntry($dbEntry);
     $kshow->save();
     $mixEntry->fromObject($dbEntry);
     myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_ADD, $dbEntry);
     return $mixEntry;
 }
Esempio n. 2
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $kshows_from_db = null;
     // works in one of 2 ways:
     // 1. get no requested name - will create a new kshow and return its details
     // 2. get some name - tries to fetch by name. if already exists - return it
     // get the new properties for the kuser from the request
     $kshow = new kshow();
     $allow_duplicate_names = $this->getP("allow_duplicate_names", true, true);
     if ($allow_duplicate_names === "false" || $allow_duplicate_names === 0) {
         $allow_duplicate_names = false;
     }
     $return_metadata = $this->getP("metadata", false);
     $detailed = $this->getP("detailed", false);
     $level = $detailed ? objectWrapperBase::DETAIL_LEVEL_DETAILED : objectWrapperBase::DETAIL_LEVEL_REGULAR;
     $obj_wrapper = objectWrapperBase::getWrapperClass($kshow, 0);
     $fields_modified = baseObjectUtils::fillObjectFromMap($this->getInputParams(), $kshow, "kshow_", $obj_wrapper->getUpdateableFields());
     // check that mandatory fields were set
     // TODO
     $kshow->setName(trim($kshow->getName()));
     // ASSUME - the name is UNIQUE per partner_id !
     if ($kshow->getName()) {
         if (myPartnerUtils::shouldForceUniqueKshow($partner_id, $allow_duplicate_names)) {
             // in this case willsearch for an existing kshow with this name and return with an error if found
             $kshows_from_db = kshowPeer::getKshowsByName(trim($kshow->getName()));
             if ($kshows_from_db) {
                 $kshow_from_db = $kshows_from_db[0];
                 $this->addDebug("already_exists_objects", count($kshows_from_db));
                 $this->addError(APIErrors::DUPLICATE_KSHOW_BY_NAME, $kshow->getName());
                 // This field in unique. Please change ");
                 if (myPartnerUtils::returnDuplicateKshow($partner_id)) {
                     $this->addMsg("kshow", objectWrapperBase::getWrapperClass($kshow_from_db, $level));
                 }
                 return;
             }
         }
     }
     // the first kuser to create this kshow will be it's producer
     $producer_id = $puser_kuser->getKuserId();
     $kshow->setProducerId($producer_id);
     // moved to the update - where there is
     $kshow->setPartnerId($partner_id);
     $kshow->setSubpId($subp_id);
     $kshow->setViewPermissions(kshow::KSHOW_PERMISSION_EVERYONE);
     // by default the permissions should be public
     if ($kshow->getPermissions() === null) {
         $kshow->setPermissions(myPrivilegesMgr::PERMISSIONS_PUBLIC);
     }
     // have to save the kshow before creating the default entries
     $kshow->save();
     $show_entry = $kshow->createEntry(entry::ENTRY_MEDIA_TYPE_SHOW, $producer_id, "&auto_edit.jpg", $kshow->getName());
     // roughcut
     $kshow->createEntry(entry::ENTRY_MEDIA_TYPE_VIDEO, $producer_id);
     // intro
     /*
     		$sample_text = $kshow->getName();
     		$host = requestUtils::getHost();
     */
     $sample_text = "";
     myEntryUtils::modifyEntryMetadataWithText($show_entry, $sample_text, "");
     // set the roughcut to false so the update iwll override with better data
     $kshow->setHasRoughcut(false);
     $kshow->initFromTemplate($producer_id, $sample_text);
     $kshow->save();
     myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_KSHOW_ADD, $kshow);
     $this->addMsg("kshow", objectWrapperBase::getWrapperClass($kshow, $level));
     if ($return_metadata) {
         $this->addMsg("metadata", $kshow->getMetadata());
     }
     $this->addDebug("added_fields", $fields_modified);
     if ($kshows_from_db) {
         $this->addDebug("already_exists_objects", count($kshows_from_db));
     }
 }
Esempio n. 3
0
 public function initFromTemplate($kuser_id, $sample_text = null)
 {
     if (!$this->getHasRoughcut() && $sample_text != null) {
         $show_entry = $this->getShowEntry();
         if (!$show_entry) {
             // have to save the kshow before creating the default entries
             $show_entry = $this->createEntry(entry::ENTRY_MEDIA_TYPE_SHOW, $kuser_id, null, $this->getName());
             // roughcut
         }
         if (!$this->getIntroId()) {
             $this->createEntry(entry::ENTRY_MEDIA_TYPE_VIDEO, $kuser_id);
             // intro
         }
         // this text should be placed in the partner-config
         KalturaLog::info("before modifyEntryMetadataWithText:\n{$sample_text}");
         myEntryUtils::modifyEntryMetadataWithText($show_entry, $sample_text, 0, true);
         // override the current entry
         $this->setHasRoughcut(false);
     }
 }