/** * @param Partner $fromPartner * @param Partner $toPartner */ protected function copyEventNotificationTemplates(Partner $fromPartner, Partner $toPartner, $permissionRequiredOnly = false) { $fromPartnerId = $fromPartner->getId(); $toPartnerId = $toPartner->getId(); KalturaLog::debug("Copy event-notification templates from [{$fromPartnerId}] to [{$toPartnerId}]"); $c = new Criteria(); $c->add(EventNotificationTemplatePeer::PARTNER_ID, $fromPartnerId); $systemNameCriteria = new Criteria(); $systemNameCriteria->add(EventNotificationTemplatePeer::PARTNER_ID, $toPartnerId); $systemNameCriteria->add(EventNotificationTemplatePeer::STATUS, EventNotificationTemplateStatus::ACTIVE); $eventNotificationTemplates = EventNotificationTemplatePeer::doSelect($c); foreach ($eventNotificationTemplates as $eventNotificationTemplate) { /* @var $eventNotificationTemplate EventNotificationTemplate */ if ($permissionRequiredOnly && !count($eventNotificationTemplate->getRequiredCopyTemplatePermissions())) { continue; } if (!myPartnerUtils::isPartnerPermittedForCopy($toPartner, $eventNotificationTemplate->getRequiredCopyTemplatePermissions())) { continue; } if ($eventNotificationTemplate->getSystemName()) { $c = clone $systemNameCriteria; $c->add(EventNotificationTemplatePeer::SYSTEM_NAME, $eventNotificationTemplate->getSystemName()); if (EventNotificationTemplatePeer::doCount($c)) { continue; } } $newEventNotificationTemplate = $eventNotificationTemplate->copy(); $newEventNotificationTemplate->setPartnerId($toPartnerId); $newEventNotificationTemplate->save(); } }
/** * Action lists the template partner event notification templates. * @action listTemplates * * @param KalturaEventNotificationTemplateFilter $filter * @param KalturaFilterPager $pager * @return KalturaEventNotificationTemplateListResponse */ public function listTemplatesAction(KalturaEventNotificationTemplateFilter $filter = null, KalturaFilterPager $pager = null) { if (!$filter) { $filter = new KalturaEventNotificationTemplateFilter(); } if (!$pager) { $pager = new KalturaFilterPager(); } $coreFilter = new EventNotificationTemplateFilter(); $filter->toObject($coreFilter); $criteria = new Criteria(); $coreFilter->attachToCriteria($criteria); $criteria->add(EventNotificationTemplatePeer::PARTNER_ID, PartnerPeer::GLOBAL_PARTNER); $count = EventNotificationTemplatePeer::doCount($criteria); $pager->attachToCriteria($criteria); $results = EventNotificationTemplatePeer::doSelect($criteria); $response = new KalturaEventNotificationTemplateListResponse(); $response->objects = KalturaEventNotificationTemplateArray::fromDbArray($results, $this->getResponseProfile()); $response->totalCount = $count; return $response; }