public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     self::$escape_text = true;
     $detailed = 1;
     $ui_conf_id = $this->getP("ui_conf_id", null);
     $widget = widget::createDefaultWidgetForPartner($partner_id, $subp_id, $ui_conf_id);
     $level = $detailed ? objectWrapperBase::DETAIL_LEVEL_DETAILED : objectWrapperBase::DETAIL_LEVEL_REGULAR;
     $this->addMsg("widget", objectWrapperBase::getWrapperClass($widget, $level));
 }
 private function createNewPartner($parnter_name, $contact, $email, $ID_is_for, $SDK_terms_agreement, $description, $website_url, $password = null, $partner = null)
 {
     $secret = md5($this->str_makerand(5, 10, true, false, true));
     $admin_secret = md5($this->str_makerand(5, 10, true, false, true));
     $newPartner = new Partner();
     if ($parnter_name) {
         $newPartner->setPartnerName($parnter_name);
     }
     $newPartner->setAdminSecret($admin_secret);
     $newPartner->setSecret($secret);
     $newPartner->setAdminName($contact);
     $newPartner->setAdminEmail($email);
     $newPartner->setUrl1($website_url);
     if ($ID_is_for === "commercial_use" || $ID_is_for === CommercialUseType::COMMERCIAL_USE) {
         $newPartner->setCommercialUse(true);
     } else {
         //($ID_is_for == "non-commercial_use") || $ID_is_for === CommercialUseType::NON_COMMERCIAL_USE)
         $newPartner->setCommercialUse(false);
     }
     $newPartner->setDescription($description);
     $newPartner->setKsMaxExpiryInSeconds(86400);
     $newPartner->setModerateContent(false);
     $newPartner->setNotify(false);
     $newPartner->setAppearInSearch(mySearchUtils::DISPLAY_IN_SEARCH_KALTURA_NETWORK);
     $newPartner->setIsFirstLogin(true);
     /* fix drupal5 module partner type */
     //var_dump($description);
     if ($this->partnerParentId) {
         // this is a child partner of some VAR/partner GROUP
         $newPartner->setPartnerParentId($this->partnerParentId);
         $newPartner->setMonitorUsage(0);
     }
     if (substr_count($description, 'Drupal module|')) {
         $newPartner->setType(102);
         if ($partner) {
             $partner->setType(102);
         }
     }
     if ($partner) {
         if ($partner->getType()) {
             $newPartner->setType($partner->getType());
         }
         if ($partner->getContentCategories()) {
             $newPartner->setContentCategories($partner->getContentCategories());
         }
         if ($partner->getPhone()) {
             $newPartner->setPhone($partner->getPhone());
         }
         if ($partner->getDescribeYourself()) {
             $newPartner->setDescribeYourself($partner->getDescribeYourself());
         }
         if ($partner->getAdultContent()) {
             $newPartner->setAdultContent($partner->getAdultContent());
         }
         if ($partner->getDefConversionProfileType()) {
             $newPartner->setDefConversionProfileType($partner->getDefConversionProfileType());
         }
         // new fields of registration form
         if ($partner->getFirstName()) {
             $newPartner->setFirstName($partner->getFirstName());
         }
         if ($partner->getLastName()) {
             $newPartner->setLastName($partner->getLastName());
         }
         if ($partner->getCountry()) {
             $newPartner->setCountry($partner->getCountry());
         }
         if ($partner->getState()) {
             $newPartner->setState($partner->getState());
         }
         if ($partner->getAdditionalParams() && is_array($partner->getAdditionalParams()) && count($partner->getAdditionalParams())) {
             $newPartner->setAdditionalParams($partner->getAdditionalParams());
         }
     }
     $newPartner->save();
     // if name was left empty - which should not happen - use id as name
     if (!$parnter_name) {
         $parnter_name = $newPartner->getId();
     }
     $newPartner->setPartnerName($parnter_name);
     $newPartner->setPrefix($newPartner->getId());
     $newPartner->setPartnerAlias(md5($newPartner->getId() . 'kaltura partner'));
     // set default conversion profile for trial accounts
     if ($newPartner->getType() == Partner::PARTNER_TYPE_KMC) {
         $newPartner->setDefConversionProfileType(ConversionProfile::DEFAULT_TRIAL_COVERSION_PROFILE_TYPE);
     }
     $newPartner->save();
     $partner_id = $newPartner->getId();
     widget::createDefaultWidgetForPartner($partner_id, $this->createNewSubPartner($newPartner));
     $fromPartner = PartnerPeer::retrieveByPK(kConf::get("template_partner_id"));
     if (!$fromPartner) {
         KalturaLog::log("Template content partner was not found!");
     } else {
         myPartnerUtils::copyTemplateContent($fromPartner, $newPartner, true);
     }
     $newPartner->setKmcVersion(kConf::get('new_partner_kmc_version'));
     $newPartner->save();
     return $newPartner;
 }
 /**
  * Function creates new partner, saves all the required data to it, and copies objects & filesyncs of template content to its ID.
  * @param string $partner_name
  * @param string $contact
  * @param string $email
  * @param CommercialUseType $ID_is_for
  * @param string $SDK_terms_agreement
  * @param string $description
  * @param string $website_url
  * @param string $password
  * @param Partner $partner
  * @param int $templatePartnerId
  * @return Partner
  */
 private function createNewPartner($partner_name, $contact, $email, $ID_is_for, $SDK_terms_agreement, $description, $website_url, $password = null, $newPartner = null, $templatePartnerId = null)
 {
     $secret = md5($this->str_makerand(5, 10, true, false, true));
     $admin_secret = md5($this->str_makerand(5, 10, true, false, true));
     if (!$newPartner) {
         $newPartner = new Partner();
     }
     if ($partner_name) {
         $newPartner->setPartnerName($partner_name);
     }
     $newPartner->setAdminSecret($admin_secret);
     $newPartner->setSecret($secret);
     $newPartner->setAdminName($contact);
     $newPartner->setAdminEmail($email);
     $newPartner->setUrl1($website_url);
     if ($ID_is_for === "commercial_use" || $ID_is_for === CommercialUseType::COMMERCIAL_USE) {
         $newPartner->setCommercialUse(true);
     } else {
         //($ID_is_for == "non-commercial_use") || $ID_is_for === CommercialUseType::NON_COMMERCIAL_USE)
         $newPartner->setCommercialUse(false);
     }
     $newPartner->setDescription($description);
     $newPartner->setKsMaxExpiryInSeconds(86400);
     $newPartner->setModerateContent(false);
     $newPartner->setNotify(false);
     $newPartner->setAppearInSearch(mySearchUtils::DISPLAY_IN_SEARCH_PARTNER_ONLY);
     $newPartner->setIsFirstLogin(true);
     /* fix drupal5 module partner type */
     //var_dump($description);
     if ($this->partnerParentId) {
         // this is a child partner of some VAR/partner GROUP
         $newPartner->setPartnerParentId($this->partnerParentId);
         $newPartner->setMonitorUsage(PartnerFreeTrialType::NO_LIMIT);
         $parentPartner = PartnerPeer::retrieveByPK($this->partnerParentId);
         $newPartner->setPartnerPackage($parentPartner->getPartnerPackage());
     }
     if (substr_count($description, 'Drupal module|')) {
         $newPartner->setType(102);
     }
     $newPartner->save();
     // if name was left empty - which should not happen - use id as name
     if (!$partner_name) {
         $partner_name = $newPartner->getId();
     }
     $newPartner->setPartnerName($partner_name);
     $newPartner->setPrefix($newPartner->getId());
     $newPartner->setPartnerAlias(md5($newPartner->getId() . 'kaltura partner'));
     // set default conversion profile for trial accounts
     if ($newPartner->getType() == Partner::PARTNER_TYPE_KMC) {
         $newPartner->setDefConversionProfileType(ConversionProfile::DEFAULT_TRIAL_COVERSION_PROFILE_TYPE);
     }
     $newPartner->save();
     // remove the default criteria from all peers and recreate it with the right partner id
     myPartnerUtils::resetAllFilters();
     myPartnerUtils::applyPartnerFilters($newPartner->getId(), true);
     $partner_id = $newPartner->getId();
     widget::createDefaultWidgetForPartner($partner_id, $this->createNewSubPartner($newPartner));
     $fromPartner = PartnerPeer::retrieveByPK($templatePartnerId ? $templatePartnerId : kConf::get("template_partner_id"));
     if (!$fromPartner) {
         KalturaLog::log("Template content partner was not found!");
     } else {
         $newPartner->setI18nTemplatePartnerId($templatePartnerId);
         myPartnerUtils::copyTemplateContent($fromPartner, $newPartner, true);
     }
     if ($newPartner->getType() == Partner::PARTNER_TYPE_WORDPRESS) {
         kPermissionManager::setPs2Permission($newPartner);
     }
     $newPartner->setKmcVersion(kConf::get('new_partner_kmc_version'));
     $newPartner->save();
     return $newPartner;
 }