コード例 #1
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     // get the new properties for the ConversionProfile from the request
     $conv_profile = new ConversionProfile();
     $obj_wrapper = objectWrapperBase::getWrapperClass($conv_profile, 0);
     $fields_modified = baseObjectUtils::fillObjectFromMap($this->getInputParams(), $conv_profile, "conversionProfile_", $obj_wrapper->getUpdateableFields(), BasePeer::TYPE_PHPNAME, true);
     // check that mandatory fields were set
     if (count($fields_modified) > 0) {
         // search if partner already has a conversionProfile similar to the one just added - if exists - use it
         // if not - create it and return it.
         $partner_conv_profile = ConversionProfilePeer::retrieveSimilar($partner_id, $conv_profile);
         if (!$partner_conv_profile) {
             $conv_profile->setPartnerId($partner_id);
             $conv_profile->setEnabled(1);
             $conv_profile->save();
             $partner_conv_profile = $conv_profile;
         }
         // TODO - remove - no need to playaround with the updatedAt for ordering (in the listconversionprofiles service
         //			$partner_conv_profile->setUpdatedAt( time() );
         //			$partner_conv_profile->save();
         $partner = $this->getPartner();
         $partner_current_conversion_profile = $partner->getCurrentConversionProfileType();
         if ($partner_conv_profile->getId() != $partner_current_conversion_profile) {
             $partner->setCurrentConversionProfileType($partner_conv_profile->getId());
             $partner->save();
         }
         $this->addMsg("conversionProfile", objectWrapperBase::getWrapperClass($partner_conv_profile, objectWrapperBase::DETAIL_LEVEL_DETAILED));
         $this->addDebug("added_fields", $fields_modified);
     } else {
         $this->addError(APIErrors::NO_FIELDS_SET_FOR_CONVERSION_PROFILE);
     }
 }
コード例 #2
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $kshow_id = $this->getP("kshow_id", kshow::KSHOW_ID_USE_DEFAULT);
     $entry = null;
     if ($kshow_id == kshow::KSHOW_ID_USE_DEFAULT) {
         // see if the partner has some default kshow to add to
         $kshow = myPartnerUtils::getDefaultKshow($partner_id, $subp_id, $puser_kuser);
         if ($kshow) {
             $kshow_id = $kshow->getId();
         }
     } elseif ($kshow_id == kshow::KSHOW_ID_CREATE_NEW) {
         // if the partner allows - create a new kshow
         $kshow = myPartnerUtils::getDefaultKshow($partner_id, $subp_id, $puser_kuser, null, true);
         if ($kshow) {
             $kshow_id = $kshow->getId();
             $entry = $kshow->getShowEntry();
             // use the newly created kshow's roughcut
         }
     } else {
         $kshow = kshowPeer::retrieveByPK($kshow_id);
     }
     if (!$kshow) {
         // the partner is attempting to add an entry to some invalid or non-existing kwho
         $this->addError(APIErrors::INVALID_KSHOW_ID, $kshow_id);
         return;
     }
     if (!$entry) {
         $entry = $kshow->createEntry(entry::ENTRY_MEDIA_TYPE_SHOW, $kshow->getProducerId(), "&auto_edit.jpg", "");
     }
     $obj_wrapper = objectWrapperBase::getWrapperClass($entry, 0);
     $fields_modified = baseObjectUtils::fillObjectFromMap($this->getInputParams(), $entry, $this->getObjectPrefix() . "_", array("name", "tags", "groupId", "partnerData", "permissions", "screenName", "description", "indexedCustomData1"));
     $entry->save();
     $this->addMsg($this->getObjectPrefix(), objectWrapperBase::getWrapperClass($entry, objectWrapperBase::DETAIL_LEVEL_REGULAR));
     $this->addDebug("added_fields", $fields_modified);
 }
コード例 #3
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $allow_empty = $this->getP("allow_empty_field", false);
     if ($allow_empty == "false" || $allow_empty === 0) {
         $allow_empty = false;
     }
     $partner = new Partner();
     $obj_wrapper = objectWrapperBase::getWrapperClass($partner, 0);
     $updateable_fields = $obj_wrapper->getUpdateableFields();
     // TODO - use fillObjectFromMapOrderedByFields instead
     $fields_modified = baseObjectUtils::fillObjectFromMap($this->getInputParams(), $partner, "partner_", $updateable_fields, BasePeer::TYPE_PHPNAME, $allow_empty);
     // check that mandatory fields were set
     // TODO
     if (count($fields_modified) > 0) {
         $target_partner = PartnerPeer::retrieveByPK($partner_id);
         if ($partner && $target_partner) {
             if (@$fields_modified["adminEmail"] && $target_partner->getAdminEmail() != $fields_modified["adminEmail"]) {
                 myPartnerUtils::emailChangedEmail($partner_id, $target_partner->getAdminEmail(), $fields_modified["adminEmail"], $target_partner->getName(), PartnerPeer::KALTURAS_PARTNER_EMAIL_CHANGE);
             }
             $partner->setType($target_partner->getType());
             baseObjectUtils::fillObjectFromObject($updateable_fields, $partner, $target_partner, baseObjectUtils::CLONE_POLICY_PREFER_NEW, null, BasePeer::TYPE_PHPNAME, $allow_empty);
             $target_partner->save();
             $this->addMsg("partner", objectWrapperBase::getWrapperClass($target_partner, objectWrapperBase::DETAIL_LEVEL_DETAILED));
             $this->addDebug("added_fields", $fields_modified);
         } else {
             $this->addError(APIErrors::UNKNOWN_PARTNER_ID);
         }
     } else {
         $this->addError(APIErrors::NO_FIELDS_SET_FOR_PARTNER);
     }
 }
コード例 #4
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $user_id = $this->getPM("user_id");
     $target_puser_kuser = PuserKuserPeer::retrieveByPartnerAndUid($partner_id, null, $user_id, true);
     if (!$target_puser_kuser) {
         $this->addError(APIErrors::INVALID_USER_ID, $user_id);
     }
     $kuser = $target_puser_kuser->getKuser();
     // get the new properties for the kuser from the request
     $kuser_update_data = new kuser();
     $obj_wrapper = objectWrapperBase::getWrapperClass($kuser, 0);
     $fields_modified = baseObjectUtils::fillObjectFromMap($this->getInputParams(), $kuser_update_data, "user_", $obj_wrapper->getUpdateableFields());
     if (count($fields_modified) > 0) {
         if (!$partner_id) {
             $kuser_from_db = kuserPeer::getKuserByScreenName($kuser->getScreenName());
             // check if there is a kuser with such a name in the system (and this kuser is not the current one)
             if ($kuser_from_db && $kuser_from_db->getId() == $kuser->getId()) {
                 $this->addError(APIErrors::USER_ALREADY_EXISTS_BY_SCREEN_NAME, $kuser->getScreenName());
                 return;
             }
         }
         if ($kuser_update_data) {
             baseObjectUtils::fillObjectFromObject($obj_wrapper->getUpdateableFields(), $kuser_update_data, $kuser, baseObjectUtils::CLONE_POLICY_PREFER_NEW, null, BasePeer::TYPE_PHPNAME);
             $target_puser_kuser->setKuser($kuser);
         }
         $kuser->save();
     }
     $wrapper = objectWrapperBase::getWrapperClass($target_puser_kuser, objectWrapperBase::DETAIL_LEVEL_DETAILED);
     $wrapper->removeFromCache("kuser", $kuser->getId());
     $this->addMsg("user", $wrapper);
     $this->addDebug("modified_fields", $fields_modified);
 }
コード例 #5
0
 public function execute()
 {
     $this->forceSystemAuthentication();
     myDbHelper::$use_alternative_con = null;
     $this->ok_to_save = $this->getP("oktosave");
     $conv_profile_id = $this->getP("convprofile_id");
     if ($conv_profile_id < 0) {
         $conv_profile_id = "";
     }
     $this->message = "";
     $this->display_disabled = $this->getP("display_disabled");
     $command = $this->getP("command");
     if ($command == "removeCache") {
     } elseif ($command == "save") {
         $conv_profile = new ConversionProfile();
         $wrapper = objectWrapperBase::getWrapperClass($conv_profile, 0);
         $extra_fields = array("partnerId", "enabled");
         // add fields that cannot be updated using the API
         $allowed_params = array_merge($wrapper->getUpdateableFields(), $extra_fields);
         $fields_modified = baseObjectUtils::fillObjectFromMap($_REQUEST, $conv_profile, "convprofile_", $allowed_params, BasePeer::TYPE_PHPNAME, true);
         if ($conv_profile_id) {
             $conv_profile_from_db = ConversionProfilePeer::retrieveByPK($conv_profile_id);
             if ($conv_profile_from_db) {
                 baseObjectUtils::fillObjectFromObject($allowed_params, $conv_profile, $conv_profile_from_db, baseObjectUtils::CLONE_POLICY_PREFER_NEW, null, BasePeer::TYPE_PHPNAME, true);
             }
             $conv_profile_from_db->save();
         } else {
             $conv_profile->save();
             $conv_profile_id = $conv_profile->getId();
         }
     }
     $this->conv_profile = ConversionProfilePeer::retrieveByPK($conv_profile_id);
     $this->conv_profile_id = $conv_profile_id;
     if ($this->conv_profile) {
         $this->conv_profile_type = $this->conv_profile->getProfileType();
         $this->fallback_mode = array();
         $this->conv_params_list = ConversionParamsPeer::retrieveByConversionProfile($this->conv_profile, $this->fallback_mode, false);
         // to see if there are any disabled params - call again with true
         $tmp_fallback = array();
         $tmp_conv_params_list = ConversionParamsPeer::retrieveByConversionProfile($this->conv_profile, $tmp_fallback, true);
         if ($tmp_fallback["mode"] == $this->fallback_mode["mode"]) {
             $this->fallback_mode = $tmp_fallback;
             $this->conv_params_list = $tmp_conv_params_list;
         } else {
             if ($this->display_disabled) {
                 $this->fallback_mode = $tmp_fallback;
                 $this->conv_params_list = $tmp_conv_params_list;
                 $this->message = "This display is missleading due to [dispaly disabled=true]<br>It shows params that are disabled for this profile and WOULD NOT be used at run-time";
             }
         }
     } else {
         $this->conv_profile_type = null;
         $this->conv_params_list = null;
     }
 }
コード例 #6
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $prefix = $this->getObjectPrefix();
     if (!$puser_kuser) {
         $this->addError(APIErrors::INVALID_USER_ID, $puser_id);
         return;
     }
     $allow_empty = $this->getP("allow_empty_field", false);
     if ($allow_empty == "false" || $allow_empty === 0) {
         $allow_empty = false;
     }
     $entry_id = $this->getPM("{$prefix}_id");
     $entry = entryPeer::retrieveByPK($entry_id);
     if (!$entry) {
         $this->addError(APIErrors::INVALID_ENTRY_ID, $prefix, $entry_id);
         return;
     }
     $this->validateInputEntry($entry);
     // TODO - verify the user is allowed to modify the entry
     if (!$this->isOwnedBy($entry, $puser_kuser->getKuserId())) {
         $this->verifyEntryPrivileges($entry);
         // user was granted explicit permissions when initiatd the ks
     }
     // get the new properties for the kuser from the request
     $entry_update_data = new entry();
     // assume the type and media_type of the entry from the DB are the same as those of the one from the user - if not -they will be overriden
     $entry_update_data->setType($entry->getType());
     $entry_update_data->setMediaType($entry->getMediaType());
     $entry_update_data->setId($entry->getId());
     $entry_update_data->setPartnerId($entry->getPartnerId());
     $entry_update_data->setData($entry->getData(), true);
     $obj_wrapper = objectWrapperBase::getWrapperClass($entry_update_data, 0);
     $field_level = $this->isAdmin() ? 2 : 1;
     $updateable_fields = $obj_wrapper->getUpdateableFields($field_level);
     $fields_modified = baseObjectUtils::fillObjectFromMap($this->getInputParams(), $entry_update_data, "{$prefix}_", $updateable_fields, BasePeer::TYPE_PHPNAME, $allow_empty);
     if (count($fields_modified) > 0) {
         if ($entry_update_data) {
             // allow admins to set admin more fields
             baseObjectUtils::fillObjectFromObject($updateable_fields, $entry_update_data, $entry, baseObjectUtils::CLONE_POLICY_PREFER_NEW, null, BasePeer::TYPE_PHPNAME, $allow_empty);
         }
         $this->validateEntry($entry);
         // TODO - chack to see that the permissions changed, not just any attributes
         myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_UPDATE_PERMISSIONS, $entry);
         $entry->save();
     }
     $wrapper = objectWrapperBase::getWrapperClass($entry, objectWrapperBase::DETAIL_LEVEL_DETAILED);
     $wrapper->removeFromCache("entry", $entry->getId());
     $this->addMsg("{$prefix}", $wrapper);
     $this->addDebug("modified_fields", $fields_modified);
 }
コード例 #7
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     // get the new properties for the kuser from the request
     $dvd_entry = new entry();
     $this->getTypeAndMediaType($dvd_entry);
     // important to set type before the auto-fill so the setDataContent will work properly
     $dvd_entry->setLengthInMsecs(0);
     $obj_wrapper = objectWrapperBase::getWrapperClass($dvd_entry, 0);
     $fields_modified = baseObjectUtils::fillObjectFromMap($this->getInputParams(), $dvd_entry, $this->getObjectPrefix() . "_", $obj_wrapper->getUpdateableFields());
     // check that mandatory fields were set
     // TODO
     $new_widget = null;
     if (count($fields_modified) > 0) {
         $kshow_id = $this->getP("kshow_id", kshow::KSHOW_ID_USE_DEFAULT);
         if ($kshow_id == kshow::KSHOW_ID_USE_DEFAULT) {
             // see if the partner has some default kshow to add to
             $kshow = myPartnerUtils::getDefaultKshow($partner_id, $subp_id, $puser_kuser);
             if ($kshow) {
                 $kshow_id = $kshow->getId();
             }
         } elseif ($kshow_id == kshow::KSHOW_ID_CREATE_NEW) {
             // if the partner allows - create a new kshow
             $kshow = myPartnerUtils::getDefaultKshow($partner_id, $subp_id, $puser_kuser, null, true);
             if ($kshow) {
                 $kshow_id = $kshow->getId();
             }
         } else {
             $kshow = kshowPeer::retrieveByPK($kshow_id);
         }
         if (!$kshow) {
             // the partner is attempting to add an entry to some invalid or non-existing kwho
             $this->addError(APIErrors::INVALID_KSHOW_ID, $kshow_id);
             return;
         }
         // force the type and media type
         // TODO - set the kshow to some default kshow of the partner - maybe extract it from the custom_data of this specific partner
         $dvd_entry->setKshowId($kshow_id);
         $dvd_entry->setStatus(entryStatus::READY);
         $dvd_entry->setPartnerId($partner_id);
         $dvd_entry->setSubpId($subp_id);
         $dvd_entry->setKuserId($puser_kuser->getKuserId());
         $dvd_entry->setCreatorKuserId($puser_kuser->getKuserId());
         $dvd_entry->save();
         $this->addMsg($this->getObjectPrefix(), objectWrapperBase::getWrapperClass($dvd_entry, objectWrapperBase::DETAIL_LEVEL_DETAILED));
         $this->addDebug("added_fields", $fields_modified);
     } else {
         $this->addError(APIErrors::NO_FIELDS_SET_FOR_GENERIC_ENTRY, $this->getObjectPrefix());
     }
 }
コード例 #8
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     // get the new properties for the kuser from the request
     $widget = new widget();
     $obj_wrapper = objectWrapperBase::getWrapperClass($widget, 0);
     $fields_modified = baseObjectUtils::fillObjectFromMap($this->getInputParams(), $widget, "widget_", $obj_wrapper->getUpdateableFields());
     // check that mandatory fields were set
     // TODO
     $new_widget = null;
     if (count($fields_modified) > 0) {
         // see if to create a widget from a widget or from a kshow
         if ($widget->getSourceWidgetId()) {
             $widget_from_db = widgetPeer::retrieveByPK($widget->getSourceWidgetId());
             $new_widget = widget::createWidgetFromWidget($widget_from_db, $widget->getKshowId(), $widget->getEntryId(), $widget->getUiConfId(), $widget->getCustomData(), $widget->getPartnerData(), $widget->getSecurityType());
             if (!$new_widget) {
                 $this->addError(APIErrors::INVALID_KSHOW_AND_ENTRY_PAIR, $widget->getKshowId(), $widget->getEntryId());
                 return;
             }
         } else {
             $kshow_id = $widget->getKshowId();
             if ($kshow_id) {
                 $kshow = kshowPeer::retrieveByPK($kshow_id);
                 if (!$kshow) {
                     $this->addError(APIErrors::KSHOW_DOES_NOT_EXISTS);
                     // This field in unique. Please change ");
                     return;
                 }
             } else {
                 $kshow = new kshow();
                 $kshow->setId(0);
                 $kshow->setPartnerId($partner_id);
                 $kshow->setSubpId($subp_id);
             }
             $new_widget = widget::createWidget($kshow, $widget->getEntryId(), null, $widget->getUiConfId(), $widget->getCustomData(), $widget->getPartnerData(), $widget->getSecurityType());
         }
         $this->addMsg("widget", objectWrapperBase::getWrapperClass($new_widget, objectWrapperBase::DETAIL_LEVEL_DETAILED));
         $this->addDebug("added_fields", $fields_modified);
     } else {
         $this->addError(APIErrors::NO_FIELDS_SET_FOR_WIDGET);
     }
 }
コード例 #9
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $detailed = $this->getDetailed();
     //$this->getP ( "detailed" , false );
     $level = $detailed ? objectWrapperBase::DETAIL_LEVEL_DETAILED : objectWrapperBase::DETAIL_LEVEL_REGULAR;
     // get the new properties for the kuser from the request
     $entry = new entry();
     // this is called for the first time to set the type and media type for fillObjectFromMap
     $this->setTypeAndMediaType($entry);
     // important to set type before the auto-fill so the setDataContent will work properly
     $entry->setLengthInMsecs(0);
     $obj_wrapper = objectWrapperBase::getWrapperClass($entry, 0);
     $field_level = $this->isAdmin() ? 2 : 1;
     $updateable_fields = $obj_wrapper->getUpdateableFields($field_level);
     $fields_modified = baseObjectUtils::fillObjectFromMap($this->getInputParams(), $entry, $this->getObjectPrefix() . "_", $updateable_fields);
     // check that mandatory fields were set
     // TODO
     if (count($fields_modified) > 0) {
         $kshow_id = $this->getP("kshow_id", kshow::KSHOW_ID_USE_DEFAULT);
         $kshow = $this->getKshow($partner_id, $subp_id, $puser_kuser, $kshow_id, $entry);
         // force the type and media type
         // TODO - set the kshow to some default kshow of the partner - maybe extract it from the custom_data of this specific partner
         $entry->setKshowId($kshow_id);
         $entry->setStatus(entryStatus::READY);
         $entry->setPartnerId($partner_id);
         $entry->setSubpId($subp_id);
         $entry->setKuserId($puser_kuser->getKuserId());
         $entry->setCreatorKuserId($puser_kuser->getKuserId());
         // this is now called for the second time to force the type and media type
         $this->setTypeAndMediaType($entry);
         $this->validateEntry($entry);
         $entry->save();
         $this->addMsg($this->getObjectPrefix(), objectWrapperBase::getWrapperClass($entry, $level));
         $this->addDebug("added_fields", $fields_modified);
     } else {
         $this->addError(APIErrors::NO_FIELDS_SET_FOR_GENERIC_ENTRY, $this->getObjectPrefix());
     }
 }
コード例 #10
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $notifications_updated = 0;
     $notifications = array();
     for ($i = 0; $i <= 50; ++$i) {
         $index = $i === 0 ? "" : $i;
         // the first notification can be with no index
         $prefix = "notification{$index}";
         $notification_id = $this->getP("{$prefix}_id");
         if ($i >= 1 && empty($notification_id)) {
             break;
         }
         $target_notification = notificationPeer::retrieveByPK($notification_id);
         if (!$target_notification) {
             $this->addError(APIErrors::INVALID_NOTIFICATION_ID, $notification_id);
             continue;
         }
         $notification_update_data = new notification();
         $obj_wrapper = objectWrapperBase::getWrapperClass($notification_update_data, 0);
         $fields_modified = baseObjectUtils::fillObjectFromMap($this->getInputParams(), $notification_update_data, "{$prefix}_", $obj_wrapper->getUpdateableFields());
         if (count($fields_modified) > 0) {
             if ($notification_update_data) {
                 baseObjectUtils::fillObjectFromObject($obj_wrapper->getUpdateableFields(), $notification_update_data, $target_notification, baseObjectUtils::CLONE_POLICY_PREFER_NEW, null, BasePeer::TYPE_PHPNAME);
             }
             $target_notification->save();
         }
         //	$this->addMsg ( "{$prefix}" , objectWrapperBase::getWrapperClass( $target_notification , objectWrapperBase::DETAIL_LEVEL_DETAILED) );
         $notifications[] = $target_notification;
         $notifications_updated++;
     }
     $this->addMsg("notifications", objectWrapperBase::getWrapperClass($notifications, objectWrapperBase::DETAIL_LEVEL_DETAILED));
     if ($notifications_updated == 0) {
         $this->addError(APIErrors::NO_NOTIFICATIONS_UPDATED);
     } else {
         $this->addDebug("notifications_updated", $notifications_updated);
     }
 }
コード例 #11
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $prefix = $this->getObjectPrefix();
     $batchjob_id = $this->getPM("{$prefix}_id");
     $batchjob = BatchJobPeer::retrieveByPK($batchjob_id);
     if (!$batchjob) {
         $this->addError(APIErrors::INVALID_BATCHJOB_ID, $batchjob_id);
         return;
     }
     // get the new properties for the batchjob from the request
     $batchjob_update_data = new BatchJob();
     $obj_wrapper = objectWrapperBase::getWrapperClass($batchjob_update_data, 0);
     $fields_modified = baseObjectUtils::fillObjectFromMap($this->getInputParams(), $batchjob_update_data, "{$prefix}_", $obj_wrapper->getUpdateableFields());
     if (count($fields_modified) > 0) {
         if ($batchjob_update_data) {
             baseObjectUtils::fillObjectFromObject($obj_wrapper->getUpdateableFields(), $batchjob_update_data, $batchjob, baseObjectUtils::CLONE_POLICY_PREFER_NEW, null, BasePeer::TYPE_PHPNAME);
         }
         $batchjob->save();
     }
     $wrapper = objectWrapperBase::getWrapperClass($batchjob, objectWrapperBase::DETAIL_LEVEL_REGULAR);
     $wrapper->removeFromCache("batchjob", $batchjob->getId());
     $this->addMsg("{$prefix}", $wrapper);
     $this->addDebug("modified_fields", $fields_modified);
 }
コード例 #12
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     defPartnerservices2baseAction::disableCache();
     $partner = new Partner();
     $obj_wrapper = objectWrapperBase::getWrapperClass($partner, 0);
     $fields_modified = baseObjectUtils::fillObjectFromMap($this->getInputParams(), $partner, "partner_", $obj_wrapper->getUpdateableFields());
     $c = new Criteria();
     $c->addAnd(UserLoginDataPeer::LOGIN_EMAIL, $partner->getAdminEmail(), Criteria::EQUAL);
     $c->setLimit(1);
     $existingUser = UserLoginDataPeer::doCount($c) > 0;
     // check that mandatory fields were set
     // TODO
     if (count($fields_modified) > 0) {
         try {
             $cms_password = $this->getP("cms_password");
             $partner_registration = new myPartnerRegistration();
             list($pid, $subpid, $pass, $hashKey) = $partner_registration->initNewPartner($partner->getName(), $partner->getAdminName(), $partner->getAdminEmail(), $partner->getCommercialUse(), "yes", $partner->getDescription(), $partner->getUrl1(), $cms_password, $partner);
             $partner_from_db = PartnerPeer::retrieveByPK($pid);
             $partner_registration->sendRegistrationInformationForPartner($partner_from_db, false, $existingUser);
         } catch (SignupException $se) {
             $this->addError(APIErrors::PARTNER_REGISTRATION_ERROR, $se->getMessage());
             return;
         } catch (Exception $ex) {
             // this assumes the partner name is unique - TODO - remove key from DB !
             $this->addError(APIErrors::SERVERL_ERROR, "Partner with name already exists");
             $this->addError(APIErrors::SERVERL_ERROR, $ex->getMessage());
             return;
         }
         $this->addMsg("partner", objectWrapperBase::getWrapperClass($partner_from_db, objectWrapperBase::DETAIL_LEVEL_DETAILED));
         $this->addMsg("subp_id", $subpid);
         $this->addMsg("cms_password", $pass);
         $this->addDebug("added_fields", $fields_modified);
     } else {
         $this->addError(APIErrors::NO_FIELDS_SET_FOR_PARTNER);
     }
 }
コード例 #13
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));
     }
 }
 public function execute()
 {
     $this->forceSystemAuthentication();
     myDbHelper::$use_alternative_con = null;
     $this->ok_to_save = $this->getP("oktosave");
     $this->error = "";
     $conv_params_id = $this->getP("convparams_id");
     $command = $this->getP("command");
     $this->close_after_save = $this->getP("close_after_save");
     if ($command == "removeCache") {
     } elseif ($command == "save" || $command == "fill") {
         $conv_params = new ConversionParams();
         $wrapper = objectWrapperBase::getWrapperClass($conv_params, 0);
         $extra_fields = array("partnerId", "ffmpegParams", "mencoderParams", "flixParams");
         // add fields that cannot be updated using the API
         $allowed_params = array_merge($wrapper->getUpdateableFields(), $extra_fields);
         $fields_modified = baseObjectUtils::fillObjectFromMap($_REQUEST, $conv_params, "convparams_", $allowed_params, BasePeer::TYPE_PHPNAME, true);
         if ($command == "save") {
             if ($conv_params_id) {
                 $conv_params_from_db = ConversionParamsPeer::retrieveByPK($conv_params_id);
                 if ($conv_params_from_db) {
                     baseObjectUtils::fillObjectFromObject($allowed_params, $conv_params, $conv_params_from_db, baseObjectUtils::CLONE_POLICY_PREFER_NEW, null, BasePeer::TYPE_PHPNAME, true);
                 }
                 $conv_params_from_db->save();
             } else {
                 $conv_params->save();
                 $conv_params_id = $conv_params->getId();
             }
         }
     }
     if ($command == "fill") {
         // when in command fill - don't fetch object from db
         $this->conv_params = $conv_params;
     } else {
         $this->conv_params = ConversionParamsPeer::retrieveByPK($conv_params_id);
         if (!$this->conv_params) {
             $this->error = "Cannot find ConversionParams [{$conv_params_id}]";
         }
     }
     $this->conv_params_id = $conv_params_id;
     $this->simulation = null;
     // will help simulate the conversion strings:
     if ($this->conv_params) {
         $conv_param_from_db = $this->conv_params;
         $conv_params = new kConversionParams();
         $conv_params->width = $conv_param_from_db->getName();
         $conv_params->width = $conv_param_from_db->getWidth();
         $conv_params->height = $conv_param_from_db->getHeight();
         $conv_params->aspect_ratio = $conv_param_from_db->getAspectRatio();
         $conv_params->gop_size = $conv_param_from_db->getGopSize();
         $conv_params->bitrate = $conv_param_from_db->getBitrate();
         $conv_params->qscale = $conv_param_from_db->getQscale();
         $conv_params->file_suffix = $conv_param_from_db->getFileSuffix();
         $conv_params->ffmpeg_params = $conv_param_from_db->getFfmpegParams();
         $conv_params->mencoder_params = $conv_param_from_db->getMencoderParams();
         $conv_params->flix_params = $conv_param_from_db->getFlixParams();
         $conv_params->comercial_transcoder = $conv_param_from_db->getCommercialTranscoder();
         // is not really used today per ConvParams
         $conv_params->framerate = $conv_param_from_db->getFramerate();
         $conv_params->audio_bitrate = $conv_param_from_db->getAudioBitrate();
         $conv_params->audio_sampling_rate = $conv_param_from_db->getAudioSamplingRate();
         $conv_params->audio_channels = $conv_param_from_db->getAudioChannels();
         $conv_params_list = array();
         $conv_cmd = new kConversionCommand();
         $conv_params_list[] = $conv_params;
         $conv_cmd->conversion_params_list = $conv_params_list;
         $this->simulation = kConversionEngineMgr::simulate($conv_cmd);
     }
 }
 public function execute()
 {
     ini_set("memory_limit", "64M");
     $this->forceSystemAuthentication();
     myDbHelper::$use_alternative_con = null;
     $partner_id = $this->getP("partner_id");
     $search_text = $this->getP("search_text");
     $command = $this->getP("command");
     if ($command == "removeCache") {
         PartnerPeer::resetPartnerInCache($partner_id);
         return $this->renderText("Removed partner [{$partner_id}] from cache");
     } elseif ($command == "save") {
         $partner = new Partner();
         $pw = objectWrapperBase::getWrapperClass($partner, 0);
         $extra_fields = array("partnerName", "description", "adminName", "adminEmail", "useDefaultKshow", "conversionString", "flvConversionString", "allowQuickEdit", "shouldForceUniqueKshow", "returnDuplicateKshow", "notificationsConfig", "notify", "allowMultiNotification", "appearInSearch", "mergeEntryLists", "allowLks", "allowAnonymousRanking", "isFirstLogin", "matchIp", "host", "cdnHost", "rtmpUrl", "defThumbOffset", "defThumbDensity", "landingPage", "userLandingPage", "status", "serviceConfigId", "moderateContent", "currentConversionProfileType", "monitorUsage", "templatePartnerId", "addEntryMaxFiles", "defaultConversionProfileId", "partnerGroupType", "partnerParentId", "enableAnalyticsTab", "liveStreamEnabled", "storageServePriority", "storageDeleteFromKaltura", "enableSilverLight", "partnerSpecificServices", "partnerSpecificServices", "enable508Players", "enableVast", "appStudioExampleEntry", "appStudioExamplePlayList0", "appStudioExamplePlayList1", "delivryBlockCountries", "deliveryRestrictions", "maxLoginAttempts", "loginBlockPeriod", "numPrevPassToKeep", "passReplaceFreq");
         $allowed_params = array_merge($pw->getUpdateableFields(), $extra_fields);
         $fields_modified = baseObjectUtils::fillObjectFromMap($_REQUEST, $partner, "partner_", $allowed_params, BasePeer::TYPE_PHPNAME, true);
         if (!isset($_REQUEST['partner_partnerParentId']) || $_REQUEST['partner_partnerParentId'] == '') {
             $partner->setPartnerParentId(null);
         }
         $partner_from_db = PartnerPeer::retrieveByPK($partner_id);
         if ($partner_from_db) {
             baseObjectUtils::fillObjectFromObject($allowed_params, $partner, $partner_from_db, baseObjectUtils::CLONE_POLICY_PREFER_NEW, null, BasePeer::TYPE_PHPNAME, true);
         }
         if (class_exists('MetadataPlugin')) {
             $partner_from_db->setPluginEnabled(MetadataPlugin::PLUGIN_NAME, $_REQUEST['partner_enableMetadata']);
         }
         if (class_exists('AuditPlugin')) {
             $partner_from_db->setPluginEnabled(AuditPlugin::PLUGIN_NAME, $_REQUEST['partner_enableAuditTrail']);
         }
         if (class_exists('AnnotationPlugin')) {
             $partner_from_db->setPluginEnabled(AnnotationPlugin::PLUGIN_NAME, $_REQUEST['partner_enableAnnotation']);
         }
         if (class_exists('VirusScanPlugin')) {
             $partner_from_db->setPluginEnabled(VirusScanPlugin::PLUGIN_NAME, $_REQUEST['partner_enableVirusScan']);
         }
         if ($partner_from_db->getServiceConfigId() == "") {
             $partner_from_db->setServiceConfigId(null);
         }
         if ($partner_from_db->getPartnerParentId() == -1000) {
             $partner_from_db->setPartnerParentId(null);
         }
         $partner_from_db->save();
         //			PartnerPeer::resetPartnerInCache ( $partner_id);
     }
     $c = new Criteria();
     if (true) {
         $c->add(PartnerPeer::ID, $partner_id);
     }
     if ($search_text) {
         $crit = $c->getNewCriterion(PartnerPeer::PARTNER_NAME, "%{$search_text}%", Criteria::LIKE);
         $crit->addOr($c->getNewCriterion(PartnerPeer::DESCRIPTION, "%{$search_text}%", Criteria::LIKE));
         $c->addAnd($crit);
     }
     $c->setLimit(1);
     //$this->partner = PartnerPeer::retrieveByPK( $partner_id );
     $this->partner_list = PartnerPeer::doSelect($c);
     if (count($this->partner_list) == 1) {
         $this->partner = $this->partner_list[0];
     } else {
         $this->partner = null;
     }
     $this->partner_id = $partner_id;
     $this->search_text = $search_text;
 }
コード例 #16
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $target_puser_id = $this->getPM("user_id");
     $target_puser_kuser = PuserKuserPeer::retrieveByPartnerAndUid($partner_id, null, $target_puser_id);
     if ($target_puser_kuser) {
         $this->addDebug("puser_exists", $target_puser_kuser->getId());
         // might be that the puser_kuser exists but the kuser does not
         $kuser = kuserPeer::retrieveByPK($target_puser_kuser->getKuserId());
         if ($kuser) {
             $this->addError(APIErrors::DUPLICATE_USER_BY_ID, $target_puser_id);
             return;
         } else {
             // puser_kuser exists but need to create the ksuer...
         }
     } else {
         $target_puser_kuser = new PuserKuser();
         $target_puser_kuser->setPuserId($target_puser_id);
         $target_puser_kuser->setPartnerId($partner_id);
         $target_puser_kuser->save();
         $this->addDebug("Created_new_puser_kuser", $target_puser_kuser->getId());
     }
     // get the new properties for the kuser from the request
     $kuser = new kuser();
     $obj_wrapper = objectWrapperBase::getWrapperClass($kuser, 0);
     $fields_modified = baseObjectUtils::fillObjectFromMap($this->getInputParams(), $kuser, "user_", $obj_wrapper->getUpdateableFields());
     // check that mandatory fields were set
     // TODO
     if (count($fields_modified) > 0) {
         if (!$partner_id) {
             $kuser_from_db = kuserPeer::getKuserByScreenName($kuser->getScreenName());
             if ($kuser_from_db) {
                 $this->addError(APIErrors::DUPLICATE_USER_BY_SCREEN_NAME, $kuser->getScreenName());
                 return;
             }
         }
         $kuser->setPartnerId($partner_id);
         $kuser->setPuserId($target_puser_id);
         try {
             $kuser = kuserPeer::addUser($kuser);
         } catch (kUserException $e) {
             $code = $e->getCode();
             if ($code == kUserException::USER_ALREADY_EXISTS) {
                 $this->addException(APIErrors::DUPLICATE_USER_BY_ID, $kuser->getId());
                 return null;
             }
             if ($code == kUserException::LOGIN_ID_ALREADY_USED) {
                 $this->addException(APIErrors::DUPLICATE_USER_BY_LOGIN_ID, $kuser->getEmail());
                 return null;
             } else {
                 if ($code == kUserException::USER_ID_MISSING) {
                     $this->addException(APIErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL, 'id');
                     return null;
                 } else {
                     if ($code == kUserException::INVALID_EMAIL) {
                         $this->addException(APIErrors::INVALID_FIELD_VALUE);
                         return null;
                     } else {
                         if ($code == kUserException::INVALID_PARTNER) {
                             $this->addException(APIErrors::UNKNOWN_PARTNER_ID);
                             return null;
                         } else {
                             if ($code == kUserException::ADMIN_LOGIN_USERS_QUOTA_EXCEEDED) {
                                 $this->addException(APIErrors::ADMIN_LOGIN_USERS_QUOTA_EXCEEDED);
                                 return null;
                             } else {
                                 if ($code == kUserException::PASSWORD_STRUCTURE_INVALID) {
                                     $this->addException(APIErrors::PASSWORD_STRUCTURE_INVALID);
                                     return null;
                                 }
                             }
                         }
                     }
                 }
             }
             throw $e;
         } catch (kPermissionException $e) {
             $code = $e->getCode();
             if ($code == kPermissionException::ROLE_ID_MISSING) {
                 $this->addException(APIErrors::ROLE_ID_MISSING);
                 return null;
             }
             if ($code == kPermissionException::ONLY_ONE_ROLE_PER_USER_ALLOWED) {
                 $this->addException(APIErrors::ONLY_ONE_ROLE_PER_USER_ALLOWED);
                 return null;
             }
             throw $e;
         }
         // now update the puser_kuser
         $target_puser_kuser->setPuserName($kuser->getScreenName());
         $target_puser_kuser->setKuserId($kuser->getId());
         $target_puser_kuser->save();
         $this->addMsg("user", objectWrapperBase::getWrapperClass($target_puser_kuser, objectWrapperBase::DETAIL_LEVEL_DETAILED));
         $this->addDebug("added_fields", $fields_modified);
     } else {
         $this->addError(APIErrors::NO_FIELDS_SET_FOR_USER);
     }
 }
コード例 #17
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     // get the new properties for the kuser from the request
     $moderation = new moderation();
     $obj_wrapper = objectWrapperBase::getWrapperClass($moderation, 0);
     // allow setting extended updateable fields
     $field_level = $this->isAdmin() ? 2 : 1;
     $updateable_fields = $obj_wrapper->getUpdateableFields($field_level);
     $fields_modified = baseObjectUtils::fillObjectFromMap($this->getInputParams(), $moderation, "moderation_", $updateable_fields);
     // check that mandatory fields were set
     // TODO
     $this->fixModeration($moderation);
     $moderation->setPartnerId($partner_id);
     $moderation->setSubpId($subp_id);
     $moderation->setPuserId($puser_id);
     if (count($fields_modified) > 0) {
         if ($moderation->getObjectType() == moderation::MODERATION_OBJECT_TYPE_ENTRY) {
             $entry = $moderation->getObject();
             if (!$entry) {
                 $this->addError(APIErrors::MODERATION_OBJECT_NOT_EXISTS, $moderation->getObjectTypeAsString() . ":" . $moderation->getObjectId());
                 return;
             } else {
                 $entry_moderation = $entry->getModerate();
                 // avoid redundant save of entry
                 if (!$entry_moderation) {
                     $entry->setModerate(true);
                     $entry->save();
                 }
             }
         } elseif ($moderation->getObjectType() == moderation::MODERATION_OBJECT_TYPE_USER) {
             $user = $moderation->getObject();
             if (!$user) {
                 $this->addError(APIErrors::MODERATION_OBJECT_NOT_EXISTS, $moderation->getObjectTypeAsString() . ":" . $moderation->getObjectId());
                 return;
             }
         } else {
             $this->addError(APIErrors::MODERATION_ONLY_ENTRY, $moderation->getObjectTypeAsString());
             return;
         }
         // remove - there can be many moderations per object
         /*			
         		$moderation_from_db = moderationPeer::getByStatusAndObject( moderation::MODERATION_STATUS_PENDING  , $moderation->getObjectId() , $moderation->getObjectType() );
         		if ( $moderation_from_db )
         		{
         			$this->addMsg ( "moderation" , objectWrapperBase::getWrapperClass( $moderation_from_db , objectWrapperBase::DETAIL_LEVEL_DETAILED) );
         			$this->addDebug ( "already_moderated" , "1");
         			return;				
         		}
         */
         // TODO - decide how to describe the subject of the moderation
         //			$moderation->setPuserId( $puser_id );
         //			$moderation->setKuserId( $puser_kuser->getKuserId() );
         //			$moderation->setStatus( moderation::MODERATION_STATUS_PENDING )
         $new_status = $this->getStatusToUpdate($moderation);
         $moderation->updateStatus($new_status);
         $moderation->save();
         $this->addMsg("moderation", objectWrapperBase::getWrapperClass($moderation, objectWrapperBase::DETAIL_LEVEL_DETAILED));
         $this->addDebug("added_fields", $fields_modified);
     } else {
         $this->addError(APIErrors::MODERATION_EMPTY_OBJECT);
     }
 }
コード例 #18
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     if (!$puser_kuser) {
         $this->addError(APIErrors::INVALID_USER_ID, $puser_id);
         return;
     }
     // get the new properties for the kshow from the request
     $kshow_update_data = new kshow();
     $start_obj_creation = microtime(true);
     $kshow = new kshow();
     $obj_wrapper = objectWrapperBase::getWrapperClass($kshow, 0);
     //		$this->addDebug ( "timer_getWrapperClass1" , ( microtime( true ) - $start_obj_creation ) );
     $timer = microtime(true);
     $fields_modified = baseObjectUtils::fillObjectFromMap($this->getInputParams(), $kshow, "kshow_", $obj_wrapper->getUpdateableFields());
     //		$this->addDebug ( "timer_fillObjectFromMap" , ( microtime( true ) - $timer ) );
     $kshow->setName(trim($kshow->getName()));
     $kshow_id = $this->getPM("kshow_id");
     $detailed = $this->getP("detailed", false);
     $allow_duplicate_names = $this->getP("allow_duplicate_names", true, true);
     if ($allow_duplicate_names === "false" || $allow_duplicate_names === 0) {
         $allow_duplicate_names = false;
     }
     if (count($fields_modified) > 0) {
         $timer = microtime(true);
         $kshow_from_db = kshowPeer::retrieveByPK($kshow_id);
         if (!$kshow_from_db) {
             // kshow with this id does not exists in the DB
             $this->addError(APIErrors::INVALID_KSHOW_ID, $kshow_id);
             return;
         }
         if (!$this->isOwnedBy($kshow_from_db, $puser_kuser->getKuserId())) {
             $this->verifyPrivileges("edit", $kshow_id);
         }
         // user was granted explicit permissions when initiatd the ks
         if (myPartnerUtils::shouldForceUniqueKshow($partner_id, $allow_duplicate_names)) {
             $kshow_with_name_from_db = kshowPeer::getFirstKshowByName($kshow->getName());
             if ($kshow_with_name_from_db && $kshow_with_name_from_db->getId() != $kshow_id) {
                 $this->addError(APIErrors::DUPLICATE_KSHOW_BY_NAME, $kshow->getName());
                 $level = $detailed ? objectWrapperBase::DETAIL_LEVEL_DETAILED : objectWrapperBase::DETAIL_LEVEL_REGULAR;
                 if (myPartnerUtils::returnDuplicateKshow($partner_id)) {
                     $this->addMsg("kshow", objectWrapperBase::getWrapperClass($kshow_from_db, $level));
                 }
                 return;
             }
         }
         $this->addMsg("old_kshow", objectWrapperBase::getWrapperClass($kshow_from_db->copy(), objectWrapperBase::DETAIL_LEVEL_REGULAR));
         //			$this->addDebug ( "timer_db_retrieve" , ( microtime( true ) - $timer ) );
         $timer = microtime(true);
         // copy relevant fields from $kshow -> $kshow_update_data
         baseObjectUtils::fillObjectFromObject($obj_wrapper->getUpdateableFields(), $kshow, $kshow_from_db, baseObjectUtils::CLONE_POLICY_PREFER_NEW, null, BasePeer::TYPE_PHPNAME);
         //			$this->addDebug ( "timer_fillObjectFromObject" , ( microtime( true ) - $timer ) );
         $timer = microtime(true);
         // TODO - move to some generic place myKshowUtils / kshow.php
         // TODO - this should be called only for the first time or whenever the user wants to force overriding the sample_text
         $force_sample_text = $this->getP("force_sample_text", false);
         $force_sample_text = false;
         $kuser_id = $puser_kuser->getKuserId();
         /*
         			$sample_text = "This is a collaborative video for &#xD;'" . $kshow_from_db->getIndexedCustomData3() . "'.&#xD;Click 'Add to Video' to get started";
         			$kshow_from_db->initFromTemplate ( $kuser_id ,$sample_text );
         */
         // be sure to save the $kshow_from_db and NOT $kshow - this will create a new entry in the DB
         $kshow_from_db->save();
         // update the name of the roughcut too
         $show_entry_id = $kshow_from_db->getShowEntryId();
         $showEntry = entryPeer::retrieveByPK($show_entry_id);
         if ($showEntry) {
             $showEntry->setName($kshow_from_db->getName());
             $showEntry->save();
         }
         // TODO - decide which of the notifications should be called
         myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_KSHOW_UPDATE_INFO, $kshow_from_db);
         // or
         //myNotificationMgr::createNotification( notification::NOTIFICATION_TYPE_KSHOW_UPDATE_PERMISSIONS , $kshow_from_db );
         //			$this->addDebug ( "timer_db_save" , ( microtime( true ) - $timer ) );
         $end_obj_creation = microtime(true);
         $this->addDebug("obj_creation_time", $end_obj_creation - $start_obj_creation);
     } else {
         $kshow_from_db = $kshow;
         // no fiends to update !
     }
     // see if trying to rollback
     $desired_version = $this->getP("kshow_version");
     if ($desired_version) {
         $result = $kshow_from_db->rollbackVersion($desired_version);
         if (!$result) {
             $this->addError(APIErrors::ERROR_KSHOW_ROLLBACK, $kshow_id, $desired_version);
         }
     }
     $this->addMsg("kshow", objectWrapperBase::getWrapperClass($kshow_from_db, objectWrapperBase::DETAIL_LEVEL_REGULAR));
     $this->addDebug("modified_fields", $fields_modified);
 }
コード例 #19
0
 /**
 Will allow creation of multiple entries
 ASSUME - the prefix of the entries is entryX_ where X is the index starting at 1
 */
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     //        $logger = sfLogger::getInstance();
     self::$escape_text = true;
     /*		if ( !$puser_kuser )
             {
                 $this->addError( "No such user ..." );
                 return;
     
             }
         */
     // TODO - validate if the user can add entries to this kshow
     $kshow_id = $this->getP("kshow_id");
     $show_entry_id = $this->getP("show_entry_id");
     $conversion_quality = $this->getP("conversionquality");
     // must be all lower case
     // for now - by default use quick_edit
     $partner = PartnerPeer::retrieveByPK($partner_id);
     for ($i = 0; $i <= $partner->getAddEntryMaxFiles(); ++$i) {
         if ($i == 0) {
             $prefix = $this->getObjectPrefix() . "_";
         } else {
             $prefix = $this->getObjectPrefix() . "{$i}" . "_";
         }
         $source = $this->getP($prefix . "source");
         $filename = $this->getP($prefix . "filename");
         if ($source != entry::ENTRY_MEDIA_SOURCE_WEBCAM || !$filename) {
             continue;
         }
         $content = myContentStorage::getFSContentRootPath();
         $entryFullPath = "{$content}/content/webcam/{$filename}.flv";
         if (!file_exists($entryFullPath)) {
             $remoteDCHost = kDataCenterMgr::getRemoteDcExternalUrlByDcId(1 - kDataCenterMgr::getCurrentDcId());
             if ($remoteDCHost) {
                 kFileUtils::dumpApiRequest($remoteDCHost);
             }
             $this->addError(APIErrors::INVALID_FILE_NAME, $filename);
             return;
         }
     }
     if (strpos($kshow_id, 'entry-') !== false && !$show_entry_id) {
         $show_entry_id = substr($kshow_id, 6);
     }
     $screen_name = $this->getP("screen_name");
     $site_url = $this->getP("site_url");
     $null_kshow = true;
     if ($show_entry_id) {
         // in this case we have the show_entry_id (of the relevant roughcut) - it suppresses the kshow_id
         $show_entry = entryPeer::retrieveByPK($show_entry_id);
         if ($show_entry) {
             $kshow_id = $show_entry->getKshowId();
         } else {
             $kshow_id = null;
         }
     }
     if ($kshow_id === kshow::SANDBOX_ID) {
         $this->addError(APIErrors::SANDBOX_ALERT);
         return;
     }
     $default_kshow_name = $this->getP("entry_name", null);
     if (!$default_kshow_name) {
         $default_kshow_name = $this->getP("entry1_name", null);
     }
     if ($kshow_id == kshow::KSHOW_ID_USE_DEFAULT) {
         // see if the partner has some default kshow to add to
         $kshow = myPartnerUtils::getDefaultKshow($partner_id, $subp_id, $puser_kuser, null, false, $default_kshow_name);
         $null_kshow = false;
         if ($kshow) {
             $kshow_id = $kshow->getId();
         }
     } elseif ($kshow_id == kshow::KSHOW_ID_CREATE_NEW) {
         // if the partner allows - create a new kshow
         $kshow = myPartnerUtils::getDefaultKshow($partner_id, $subp_id, $puser_kuser, null, true, $default_kshow_name);
         $null_kshow = false;
         if ($kshow) {
             $kshow_id = $kshow->getId();
         }
     } else {
         $kshow = kshowPeer::retrieveByPK($kshow_id);
     }
     if (!$kshow) {
         // the partner is attempting to add an entry to some invalid or non-existing kwho
         $this->addError(APIErrors::INVALID_KSHOW_ID, $kshow_id);
         return;
     }
     // find permissions from kshow
     $permissions = $kshow->getPermissions();
     $kuser_id = $puser_kuser->getKuserId();
     // TODO - once the CW
     $quick_edit = myPolicyMgr::getPolicyFor("allowQuickEdit", $kshow, $partner);
     // let the user override the quick_edit propery
     if ($this->getP("quick_edit") == '0' || $this->getP("quick_edit") == "false") {
         $quick_edit = false;
     }
     if ($quick_edit == '0' || $quick_edit === "false" || !$quick_edit || $quick_edit == false) {
         KalturaLog::err('$quick_edit: [' . $quick_edit . ']');
         $quick_edit = false;
         //$quick_edit = true;
     }
     // 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
     $new_entry_count = 0;
     $entries = array();
     $notification_ids = array();
     $notifications = array();
     $field_level = $this->isAdmin() ? 2 : 1;
     $updateable_fields = null;
     $imported_entries_count = 0;
     for ($i = 0; $i <= $partner->getAddEntryMaxFiles(); ++$i) {
         if ($i == 0) {
             $prefix = $this->getObjectPrefix() . "_";
         } else {
             $prefix = $this->getObjectPrefix() . "{$i}" . "_";
         }
         $file_name = $this->getP($prefix . "realFilename");
         if (!($this->getP($prefix . "name") || $file_name)) {
             continue;
         }
         // get the new properties for the kuser from the request
         $entry = new entry();
         $obj_wrapper = objectWrapperBase::getWrapperClass($entry, 0);
         if (!$updateable_fields) {
             $updateable_fields = $obj_wrapper->getUpdateableFields($field_level);
         }
         // fill the entry from request
         $fields_modified = baseObjectUtils::fillObjectFromMap($this->getInputParams(), $entry, $prefix, $updateable_fields);
         // check that mandatory fields were set
         // TODO
         KalturaLog::err("addentry: fields_modified: " . print_r($fields_modified, true));
         $entry_source = $entry->getSource();
         if (!$entry->getType()) {
             // this is the default for backward compatiblity
             $entry->setType(entryType::MEDIA_CLIP);
         }
         $token = $this->getKsUniqueString();
         $entry_full_path = "";
         if ($entry_source == entry::ENTRY_MEDIA_SOURCE_FILE) {
             $entry->setSourceLink($file_name);
             $file_alias = $this->getP($prefix . "filename");
             $file_extension = strtolower(pathinfo($this->getP($prefix . "realFilename"), PATHINFO_EXTENSION));
             $entry_full_path = myUploadUtils::getUploadPath($token, $file_alias, null, $file_extension);
             if (!file_exists($entry_full_path)) {
                 KalturaLog::err("Invalid UPLOAD PATH [" . $entry_full_path . "] while trying to add entry for partner id [" . $partner_id . "] with token [" . $token . "] & original name [" . $this->getP($prefix . "name") . "]");
                 $this->addError(APIErrors::INVALID_FILE_NAME);
                 continue;
             }
             myEntryUtils::setEntryTypeAndMediaTypeFromFile($entry, $entry_full_path);
         }
         //            No reason to rais the error
         //            Remarked by Tan-Tan
         //
         //            // when we reached this point the type and media type must be set
         //            if ($entry->getType() == entryType::AUTOMATIC || $entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_AUTOMATIC)
         //            {
         //				$this->addError ( APIErrors::CANNOT_USE_ENTRY_TYPE_AUTO_IN_IMPORT );
         //            	continue;
         //            }
         // limit two kinds of media
         // 1. not images - video/audio which are big files
         // 2. media which wasnt directly uploaded by the owner (the owner real content)
         if ($entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_IMAGE && $entry_source != entry::ENTRY_MEDIA_SOURCE_FILE) {
             if ($imported_entries_count >= 4) {
                 continue;
             }
             ++$imported_entries_count;
         }
         // the conversion_quality is set once for the whole list of entries
         if ($conversion_quality) {
             $entry->setConversionQuality($conversion_quality);
         } else {
             // HACK - if the conversion_quality was not set in the proper way -
             // see if the partner_data holds a hack - string that starts with conversionQuality= - this is set when the CW is opened in the KMC
             // the conversionQuality is of format conversionQuality=XXX;<the rest of the text>
             //
             if (kString::beginsWith($entry->getPartnerData(), "conversionQuality:")) {
                 $partner_data_arr = explode(";", $entry->getPartnerData(), 2);
                 $conversion_quality_arr = explode(":", $partner_data_arr[0]);
                 $conversion_quality = @$conversion_quality_arr[1];
                 // the value of the conversion_quality
                 $entry->setPartnerData(@$partner_data_arr[1]);
                 // the rest of the string
                 $entry->setConversionQuality($conversion_quality);
             }
         }
         $insert = true;
         $entry_modified = false;
         $create_entry = true;
         // I don't remember why we set the kshow to null every time ...
         // but when we fetched it automatically - hang on to it !
         if ($null_kshow) {
             $kshow = null;
         }
         if ($entry_source == entry::ENTRY_MEDIA_SOURCE_KALTURA_USER_CLIPS || $entry_source == "100") {
             if ($entry_source == "100") {
                 $entry_id = $this->getP("media{$i}_id");
             } else {
                 $entry_id = $this->getP($prefix . "id");
             }
             // $this->getP ( $prefix . "url" );
             if ($entry_id === null) {
                 $entry_id = $entry->getMediaId();
             }
             if ($entry_id) {
                 $entry = entryPeer::retrieveByPK($entry_id);
                 if ($entry) {
                     $create_entry = false;
                     $insert = false;
                 } else {
                     $this->addError(APIErrors::INVALID_ENTRY_ID, $this->getObjectPrefix(), $entry_id);
                     return;
                 }
             }
         }
         $new_entry_count++;
         if ($create_entry) {
             $entry->setPartnerId($partner_id);
             $entry->setSubpId($subp_id);
             $entry->setKuserId($kuser_id);
             $entry->setCreatorKuserId($kuser_id);
             $entry->setKshowId($kshow_id);
             $entry->setSiteUrl($site_url);
             $entry->setScreenName($screen_name);
             if ($this->getGroup()) {
                 $entry->setGroupId($this->getGroup());
             }
             if ($entry->getPermissions() === null) {
                 $entry->setPermissions($permissions);
             }
             // inherited from the enclosing kshow
             $entry->setDefaultModerationStatus();
             $entry->save();
             $entry_modified = true;
             if (!$entry->getName()) {
                 if ($file_name) {
                     // TODO - fix the file_name to fit
                     $entry->setName($file_name);
                 } else {
                     $entry->setName($partner_prefix . $entry->getId());
                 }
                 $entry_modified = true;
             }
             // TODO - decide on file naming mechanism !!
             // there are 3 types of insert:
             // 1. upload - the file is assumed to be in the upload directory and it's name is explicitly set in the fname$i param
             // 2. webcam - the file is assumed to be in the webcam directory and it's name is explicitly set in the fname$i param
             // 3. URL - the url is given in the entry_url$i param
             /*
                         $media_source = $this->getParam('entry_media_source');
                         $media_type = $this->getParam('entry_media_type');
                         $entry_url = $this->getParam('entry_url');
                         $entry_source_link = $this->getParam('entry_source_link');
                         $entry_fileName = $this->getParam('entry_data');
                         $entry_thumbNum = $this->getParam('entry_thumb_num', 0);
                         $entry_thumbUrl  = $this->getParam('entry_thumb_url', '');
                         $entry_from_time  = $this->getParam('entry_from_time', 0);
                         $entry_to_time  = $this->getParam('entry_to_time', 0);
             
                         $should_copy = $this->getParam('should_copy' , false );
                         $skip_conversion = $this->getParam('skip_conversion' , false );
             */
             $paramsArray = array('entry_media_source' => $entry->getSource(), 'entry_media_type' => $entry->getMediaType());
             //			$entry_source = $entry->getSource() ;
             if ($entry_source == entry::ENTRY_MEDIA_SOURCE_FILE) {
                 $paramsArray["entry_full_path"] = $entry_full_path;
             } elseif ($entry_source == entry::ENTRY_MEDIA_SOURCE_WEBCAM) {
                 $file_alias = $this->getP($prefix . "filename");
                 $paramsArray["webcam_suffix"] = $file_alias;
                 $paramsArray['entry_from_time'] = $this->getP($prefix . "fromTime", 0);
                 $paramsArray['entry_to_time'] = $this->getP($prefix . "toTime", 0);
             } elseif ($entry_source == entry::ENTRY_MEDIA_SOURCE_KALTURA || $entry_source == entry::ENTRY_MEDIA_SOURCE_KALTURA_PARTNER || $entry_source == entry::ENTRY_MEDIA_SOURCE_KALTURA_PARTNER_KSHOW || $entry_source == entry::ENTRY_MEDIA_SOURCE_KALTURA_KSHOW || $entry_source == entry::ENTRY_MEDIA_SOURCE_KALTURA_USER_CLIPS) {
                 // optimize - no need to actually go through the import and conversion phase
                 // find the source entry_id from the url
                 /*
                                     $entry_url = $this->getP ( $prefix . "url" );
                                     $entry_thumb_url = $this->getP ( $prefix .  "thumbUrl" );
                 
                                     if ( myEntryUtils::copyData( $entry_url , $entry_thumb_url , $entry ) )
                 */
                 $source_entry_id = $this->getP("media{$i}_id");
                 // $this->getP ( $prefix . "url" );
                 if ($source_entry_id === null) {
                     $source_entry_id = $entry->getMediaId();
                 }
                 if (myEntryUtils::copyData($source_entry_id, $entry)) {
                     // copy worked ok - no need to use insertEntryHelper
                     //$entry->setStatus ( entryStatus::READY );
                     // force the data to be ready even if the policy is to moderate - this is kaltura's content and was already approved
                     // (roman) true argument removed, so kaltura's content will be moderated according to partner's moderation settings
                     $entry->setStatusReady();
                     $insert = false;
                     $entry_modified = true;
                     $entry->save();
                 }
             } elseif ($entry_source == entry::ENTRY_MEDIA_SOURCE_URL || in_array($entry_source, myMediaSourceFactory::getAllMediaSourceProvidersIds())) {
                 // the URL is relevant
                 $paramsArray["entry_url"] = $this->getP($prefix . "url");
                 $paramsArray["entry_thumb_url"] = $this->getP($prefix . "thumbUrl");
                 // TODO - these fields are already set in the entry -
                 // the code in myInsertEntryHelper is redundant
                 $paramsArray["entry_license"] = $entry->getLicenseType();
                 $paramsArray["entry_credit"] = $entry->getCredit();
                 $paramsArray["entry_source_link"] = $entry->getSourceLink();
                 $paramsArray["entry_tags"] = $entry->getTags();
             } else {
                 $this->addError(APIErrors::UNKNOWN_MEDIA_SOURCE, $entry->getSource());
                 $insert = false;
             }
             if ($insert) {
                 KalturaLog::err("paramsArray" . print_r($paramsArray, true));
                 $insert_entry_helper = new myInsertEntryHelper($this, $kuser_id, $kshow_id, $paramsArray);
                 $insert_entry_helper->setPartnerId($partner_id, $subp_id);
                 $insert_entry_helper->insertEntry($token, $entry->getType(), $entry->getId(), $entry->getName(), $entry->getTags(), $entry);
                 $insert_entry_helper->getEntry();
                 $this->addDebug("added_entry{$i}", $entry->getName());
             }
         }
         // create_entry = true
         KalturaLog::err('id: ' . $entry->getId() . ' $quick_edit:' . $quick_edit);
         if ($quick_edit) {
             KalturaLog::info("quick edit with kshow_id [{$kshow_id}]");
             if (!$kshow) {
                 $kshow = kshowPeer::retrieveByPK($kshow_id);
             }
             // this i
             if (!$kshow) {
                 // BAD - this shount not be !
                 $this->addError(APIErrors::INVALID_KSHOW_ID, $kshow_id);
                 return;
             }
             $metadata = $kshow->getMetadata();
             if ($metadata !== null) {
                 KalturaLog::info("Having metadata");
                 $relevant_kshow_version = 1 + $kshow->getVersion();
                 // the next metadata will be the first relevant version for this new entry
                 $version_info = array();
                 $version_info["KuserId"] = $puser_kuser->getKuserId();
                 $version_info["PuserId"] = $puser_id;
                 $version_info["ScreenName"] = $puser_kuser->getPuserName();
                 $new_metadata = myMetadataUtils::addEntryToMetadata($metadata, $entry, $relevant_kshow_version, $version_info);
                 $entry_modified = true;
                 if ($new_metadata) {
                     // TODO - add thumbnail only for entries that are worthy - check they are not moderated !
                     $thumb_modified = myKshowUtils::updateThumbnail($kshow, $entry, false);
                     if ($thumb_modified) {
                         $new_metadata = myMetadataUtils::updateThumbUrlFromMetadata($new_metadata, $entry->getThumbnailUrl());
                     }
                     // it is very important to increment the version count because even if the entry is deferred
                     // it will be added on the next version
                     if (!$kshow->getHasRoughcut()) {
                         // make sure the kshow now does have a roughcut
                         $kshow->setHasRoughcut(true);
                         $kshow->save();
                     }
                     $kshow->setMetadata($new_metadata, true);
                 }
                 // no need to save kshow - the modification of the metadata was done to the show_entry which will propagate any chages to the kshow in it's own save method
             }
         }
         if ($entry_modified) {
             $entry->save();
         }
         $not_id = null;
         // send a synch notification
         @(list($not_id, $not, $url, $params, $serialized_params) = myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_ADD, $entry, null, null));
         if ($not_id) {
             $notification_ids[] = $not_id;
             $notifications[] = array("url" => $url, "params" => $serialized_params);
         }
         $wrapper = objectWrapperBase::getWrapperClass($entry, objectWrapperBase::DETAIL_LEVEL_REGULAR);
         $entries[$prefix] = $wrapper;
         //$this->addMsg ( $prefix , $wrapper);
         // because the kshow's entrys field was changes do to this update, we have to remove object from cahce
         // TODO - think of some reverse way to automatically remove from the cache from within the wrapper
         // call some - update cache where the kshow_id plays a part in the update
         $wrapper->removeFromCache("kshow", $kshow_id, "entrys");
         $this->addDebug("added_fields", $fields_modified, $prefix);
     }
     $this->addMsg("entries", $entries);
     if (count($notification_ids) > 0) {
         $this->addMsg("notifications", $notifications);
     }
     if ($new_entry_count < 1) {
         $this->addError(APIErrors::NO_ENTRIES_ADDED);
         $this->addDebug("no_new_entries", "You have to have at least one new entry with a field called 'entry1_name'");
     }
     $this->addMsg("new_entry_count", $new_entry_count);
 }