コード例 #1
0
 /**
  * @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();
     }
 }
コード例 #2
0
 /**
  * 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;
 }
コード例 #3
0
 /**
  * Retrieve event notification templates according to systemName
  * @param string $systemName
  * @param int $excludeId
  * @param PropelPDO $con
  * @return array<EventNotificationTemplate>
  */
 public static function retrieveBySystemName($systemName, $excludeId = null, PropelPDO $con = null)
 {
     $criteria = new Criteria(EventNotificationTemplatePeer::DATABASE_NAME);
     $criteria->add(EventNotificationTemplatePeer::STATUS, EventNotificationTemplateStatus::ACTIVE);
     $criteria->add(EventNotificationTemplatePeer::SYSTEM_NAME, $systemName);
     if ($excludeId) {
         $criteria->add(EventNotificationTemplatePeer::ID, $excludeId, Criteria::NOT_EQUAL);
     }
     $criteria->add(EventNotificationTemplatePeer::PARTNER_ID, kCurrentContext::getCurrentPartnerId());
     return EventNotificationTemplatePeer::doSelect($criteria);
 }
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(EventNotificationTemplatePeer::DATABASE_NAME);
         $criteria->add(EventNotificationTemplatePeer::ID, $pks, Criteria::IN);
         $objs = EventNotificationTemplatePeer::doSelect($criteria, $con);
     }
     return $objs;
 }
コード例 #5
0
 /**
  * Retrieve event notification tamplates according to event and object type
  *
  * @param      int $eventType
  * @param      int $objectType
  * @param      int $partnerId use null to retrieve from shared partner only
  * @param      PropelPDO $con the connection to use
  * @return     array<EventNotificationTemplate>
  */
 public static function retrieveByEventType($eventType, $objectType, $partnerId = null, PropelPDO $con = null)
 {
     $criteria = new Criteria(EventNotificationTemplatePeer::DATABASE_NAME);
     $criteria->add(EventNotificationTemplatePeer::STATUS, EventNotificationTemplateStatus::ACTIVE);
     $criteria->add(EventNotificationTemplatePeer::EVENT_TYPE, $eventType);
     $criteria->add(EventNotificationTemplatePeer::OBJECT_TYPE, $objectType);
     if ($partnerId) {
         $criteria->add(EventNotificationTemplatePeer::PARTNER_ID, array(PartnerPeer::GLOBAL_PARTNER, $partnerId), Criteria::IN);
     } else {
         $criteria->add(EventNotificationTemplatePeer::PARTNER_ID, PartnerPeer::GLOBAL_PARTNER);
     }
     return EventNotificationTemplatePeer::doSelect($criteria, $con);
 }
$criteria->add(EventNotificationTemplatePeer::STATUS, EventNotificationTemplateStatus::DELETED, Criteria::NOT_EQUAL);
$criteria->add(EventNotificationTemplatePeer::SYSTEM_NAME, array('New_Item_Pending_Moderation', 'New_Item_Pending_Moderation_2', 'Entry_Was_Added_To_Channel'), Criteria::IN);
$criteria->addAscendingOrderByColumn(EventNotificationTemplatePeer::ID);
$criteria->setLimit(100);
$eventNotificationTemplates = EventNotificationTemplatePeer::doSelect($criteria);
$lastId = 0;
$count = 0;
while ($eventNotificationTemplates) {
    foreach ($eventNotificationTemplates as $eventNotificationTemplate) {
        /* @var $eventNotificationTemplate EmailNotificationTemplate */
        $lastId = $eventNotificationTemplate->getId();
        $categoryId = new kEvalStringField();
        $categoryId->setCode('$scope->getEvent()->getObject()->getCategoryId()');
        $categoryUserFilter = new categoryKuserFilter();
        if ($eventNotificationTemplate->getSystemName() == 'Entry_Was_Added_To_Channel') {
            $categoryUserFilter->set('_matchor_permission_names', 'CATEGORY_SUBSCRIBE');
        } else {
            $categoryUserFilter->set('_matchor_permission_names', 'CATEGORY_MODERATE');
        }
        $bcc = new kEmailNotificationCategoryRecipientProvider();
        $bcc->setCategoryId($categoryId);
        $bcc->setCategoryUserFilter($categoryUserFilter);
        $eventNotificationTemplate->setBcc($bcc);
        $eventNotificationTemplate->setTo(null);
        $eventNotificationTemplate->save();
        $count++;
    }
    $criteria->add(EventNotificationTemplatePeer::ID, $lastId, Criteria::GREATER_THAN);
    $eventNotificationTemplates = EventNotificationTemplatePeer::doSelect($criteria);
}
KalturaLog::log('Done: updated ' . $count . ' templates');