Esempio n. 1
0
 public function clearMemory()
 {
     accessControlPeer::clearInstancePool();
     BatchJobPeer::clearInstancePool();
     BulkUploadResultPeer::clearInstancePool();
     categoryPeer::clearInstancePool();
     EmailIngestionProfilePeer::clearInstancePool();
     entryPeer::clearInstancePool();
     FileSyncPeer::clearInstancePool();
     flavorAssetPeer::clearInstancePool();
     flavorParamsConversionProfilePeer::clearInstancePool();
     flavorParamsOutputPeer::clearInstancePool();
     flavorParamsPeer::clearInstancePool();
     kshowPeer::clearInstancePool();
     mediaInfoPeer::clearInstancePool();
     moderationFlagPeer::clearInstancePool();
     moderationPeer::clearInstancePool();
     notificationPeer::clearInstancePool();
     roughcutEntryPeer::clearInstancePool();
     SchedulerConfigPeer::clearInstancePool();
     SchedulerPeer::clearInstancePool();
     SchedulerStatusPeer::clearInstancePool();
     SchedulerWorkerPeer::clearInstancePool();
     StorageProfilePeer::clearInstancePool();
     syndicationFeedPeer::clearInstancePool();
     TrackEntryPeer::clearInstancePool();
     uiConfPeer::clearInstancePool();
     UploadTokenPeer::clearInstancePool();
     // TODO clear default filters
     // TODO call all memory cleaner plugins
     if (function_exists('gc_collect_cycles')) {
         // php 5.3 and above
         gc_collect_cycles();
     }
 }
 public function execute()
 {
     $this->forceSystemAuthentication();
     $this->pid = $this->getRequestParameter("pid", null);
     if ($this->getRequestParameter("advanced")) {
         $this->getResponse()->setCookie('email-ingestion-advanced', 'yes');
         $this->advanced = true;
     } else {
         if ($this->getRequest()->getCookie('email-ingestion-advanced') === 'yes') {
             $this->advanced = true;
         } else {
             $this->advanced = false;
         }
     }
     myDbHelper::$use_alternative_con = null;
     $this->editEmailIngestionProfile = null;
     $this->formaction = '';
     if ($this->getRequestParameter("id")) {
         $this->editEmailIngestionProfile = EmailIngestionProfilePeer::retrieveByPK($this->getRequestParameter("id"));
         if ($this->getRequestParameter("delete")) {
             if ($this->advanced) {
                 $this->editEmailIngestionProfile->setStatus(EmailIngestionProfile::EMAIL_INGESTION_PROFILE_STATUS_INACTIVE);
                 $this->editEmailIngestionProfile->save();
             }
             $this->redirect("system/emailingestionprofiles?pid=" . $this->pid);
         }
         if ($this->getRequest()->getMethod() == sfRequest::POST) {
             $partnerId = $this->getRequestParameter("partner-id");
             if ($this->advanced) {
                 $this->editEmailIngestionProfile->setPartnerId($partnerId);
             } else {
                 if ($partnerId != 0) {
                     $this->editEmailIngestionProfile->setPartnerId($partnerId);
                 }
             }
             $this->editEmailIngestionProfile->setName($this->getRequestParameter("name"));
             $this->editEmailIngestionProfile->setDescription($this->getRequestParameter("description"));
             $this->editEmailIngestionProfile->setDefaultTags($this->getRequestParameter("default-tags"));
             $this->editEmailIngestionProfile->setDefaultAdminTags($this->getRequestParameter("default-admintags"));
             $this->editEmailIngestionProfile->setEmailAddress($this->getRequestParameter("email-address", false));
             $this->editEmailIngestionProfile->setMailboxId($this->getRequestParameter("mailbox-id"));
             $conversion_profile = $this->getRequestParameter("conversion-profile2-id", false);
             if ($conversion_profile) {
                 echo 'here';
                 die;
                 $this->editEmailIngestionProfile->setConversionProfile2Id($conversion_profile);
             } else {
                 //$this->editEmailIngestionProfile->setConversionProfile2Id(null);
             }
             $this->editEmailIngestionProfile->setModerationStatus($this->getRequestParameter("moderation-status"));
             $this->editEmailIngestionProfile->setDefaultCategory($this->getRequestParameter("default-category"));
             $this->editEmailIngestionProfile->setDefaultUserId($this->getRequestParameter("default-userid"));
             $this->editEmailIngestionProfile->setMaxAttachmentSizeKbytes($this->getRequestParameter("max-attachment-size-kbytes"));
             $this->editEmailIngestionProfile->setMaxAttachmentsPerMail($this->getRequestParameter("max-attachments-per-mail"));
             $this->editEmailIngestionProfile->save();
             $this->redirect("system/emailingestionprofiles?pid=" . $this->editEmailIngestionProfile->getPartnerId());
         }
     } elseif ($this->getRequestParameter('editing') == 'add') {
         $this->editEmailIngestionProfile = new EmailIngestionProfile();
         $this->formaction = 'system/emailingestionprofiles?addingnew=true';
     } elseif ($this->getRequestParameter('addingnew') == 'true' && $this->getRequest()->getMethod() == sfRequest::POST) {
         $this->editEmailIngestionProfile = new EmailIngestionProfile();
         $partnerId = $this->getRequestParameter("partner-id");
         $this->editEmailIngestionProfile->setPartnerId($partnerId);
         $this->editEmailIngestionProfile->setName($this->getRequestParameter("name"));
         $this->editEmailIngestionProfile->setDescription($this->getRequestParameter("description"));
         $this->editEmailIngestionProfile->setDefaultTags($this->getRequestParameter("default-tags"));
         $this->editEmailIngestionProfile->setDefaultAdminTags($this->getRequestParameter("default-admintags"));
         $this->editEmailIngestionProfile->setEmailAddress($this->getRequestParameter("email-address", false));
         $this->editEmailIngestionProfile->setMailboxId($this->getRequestParameter("mailbox-id"));
         $conversion_profile = $this->getRequestParameter("conversion-profile2-id", false);
         if ($conversion_profile) {
             echo 'here';
             die;
             $this->editEmailIngestionProfile->setConversionProfile2Id($conversion_profile);
         } else {
             //$this->editEmailIngestionProfile->setConversionProfile2Id(null);
         }
         $this->editEmailIngestionProfile->setModerationStatus($this->getRequestParameter("moderation-status"));
         $this->editEmailIngestionProfile->setDefaultCategory($this->getRequestParameter("default-category"));
         $this->editEmailIngestionProfile->setDefaultUserId($this->getRequestParameter("default-userid"));
         $this->editEmailIngestionProfile->setMaxAttachmentSizeKbytes($this->getRequestParameter("max-attachment-size-kbytes"));
         $this->editEmailIngestionProfile->setMaxAttachmentsPerMail($this->getRequestParameter("max-attachments-per-mail"));
         $this->editEmailIngestionProfile->save();
         $this->redirect("system/emailingestionprofiles?pid=" . $this->editEmailIngestionProfile->getPartnerId());
     }
     $c = new Criteria();
     if (!is_null($this->pid)) {
         $c->add(EmailIngestionProfilePeer::PARTNER_ID, $this->pid);
     }
     $this->EmailIngestionProfiles = EmailIngestionProfilePeer::doSelect($c);
     $this->entryModerationStatuses = self::getEnumValues("entry", "ENTRY_MODERATION_STATUS");
 }
 /**
  * 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(EmailIngestionProfilePeer::DATABASE_NAME);
         $criteria->add(EmailIngestionProfilePeer::ID, $pks, Criteria::IN);
         $objs = EmailIngestionProfilePeer::doSelect($criteria, $con);
     }
     return $objs;
 }
 /**
  * add KalturaMediaEntry from email ingestion
  *
  * @action addMediaEntry
  * @param KalturaMediaEntry $mediaEntry Media entry metadata
  * @param string $uploadTokenId Upload token id
  * @param int $emailProfId
  * @param string $fromAddress
  * @param string $emailMsgId
  *
  * @return KalturaMediaEntry
  *
  * @throws KalturaErrors::UPLOADED_FILE_NOT_FOUND_BY_TOKEN
  * @throws KalturaErrors::EMAIL_INGESTION_PROFILE_NOT_FOUND
  *
  */
 function addMediaEntryAction(KalturaMediaEntry $mediaEntry, $uploadTokenId, $emailProfId, $fromAddress, $emailMsgId)
 {
     try {
         // check that the uploaded file exists
         $entryFullPath = kUploadTokenMgr::getFullPathByUploadTokenId($uploadTokenId);
         if (!file_exists($entryFullPath)) {
             throw new KalturaAPIException(KalturaErrors::UPLOADED_FILE_NOT_FOUND_BY_TOKEN);
         }
         // get the email profile by the given id
         $existingEIP = EmailIngestionProfilePeer::retrieveByPK($emailProfId);
         if (!$existingEIP) {
             throw new KalturaAPIException(KalturaErrors::EMAIL_INGESTION_PROFILE_NOT_FOUND, $emailProfId);
         }
         $emailIP = new KalturaEmailIngestionProfile();
         $emailIP->fromObject($existingEIP, $this->getResponseProfile());
         // handle defaults for media entry metadata
         $this->changeIfNull($mediaEntry->tags, $emailIP->defaultTags);
         $this->changeIfNull($mediaEntry->adminTags, $emailIP->defaultAdminTags);
         $this->changeIfNull($mediaEntry->conversionProfileId, $emailIP->conversionProfile2Id);
         $this->changeIfNull($mediaEntry->userId, $emailIP->defaultUserId);
         if (is_null($mediaEntry->categories) || is_null(categoryPeer::getByFullNameExactMatch($mediaEntry->categories))) {
             $mediaEntry->categories = $emailIP->defaultCategory;
         }
         // validate the input object
         //$entry->validatePropertyMinLength("name", 1);
         if (!$mediaEntry->name) {
             $mediaEntry->name = $this->getPartnerId() . '_' . time();
         }
         // first copy all the properties to the db entry, then we'll check for security stuff
         $dbEntry = $mediaEntry->toObject(new entry());
         if ($emailIP->moderationStatus == KalturaEntryModerationStatus::PENDING_MODERATION) {
             $dbEntry->setModerate(true);
         }
         $dbEntry->setType(KalturaEntryType::MEDIA_CLIP);
         $dbEntry->setMediaType(entry::ENTRY_MEDIA_TYPE_AUTOMATIC);
         $this->checkAndSetValidUserInsert($mediaEntry, $dbEntry);
         $this->checkAdminOnlyInsertProperties($mediaEntry);
         $this->validateAccessControlId($mediaEntry);
         $this->validateEntryScheduleDates($mediaEntry, $dbEntry);
         $dbEntry->setPartnerId($this->getPartnerId());
         $dbEntry->setSubpId($this->getPartnerId() * 100);
         $dbEntry->setSourceId($uploadTokenId);
         $dbEntry->setSourceLink($entryFullPath);
         $dbEntry->setDefaultModerationStatus();
         $dbEntry->save();
         $te = new TrackEntry();
         $te->setEntryId($dbEntry->getId());
         $te->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_ADD_ENTRY);
         $te->setDescription(__METHOD__ . ":" . __LINE__ . "::ENTRY_MEDIA_SOURCE_EMAIL_INGESTION");
         $te->setParam1Str($fromAddress);
         $te->setParam2Str($emailMsgId);
         $te->setParam3Str($emailProfId . '::' . $emailIP->emailAddress . '::' . $emailIP->mailboxId);
         TrackEntry::addTrackEntry($te);
         $kshow = $this->createDummyKShow();
         $kshowId = $kshow->getId();
         myEntryUtils::setEntryTypeAndMediaTypeFromFile($dbEntry, $entryFullPath);
         // setup the needed params for my insert entry helper
         $paramsArray = array("entry_media_source" => KalturaSourceType::FILE, "entry_media_type" => $dbEntry->getMediaType(), "entry_full_path" => $entryFullPath, "entry_license" => $dbEntry->getLicenseType(), "entry_credit" => $dbEntry->getCredit(), "entry_source_link" => $dbEntry->getSourceLink(), "entry_tags" => $dbEntry->getTags());
         $token = $this->getKsUniqueString();
         $insert_entry_helper = new myInsertEntryHelper(null, $dbEntry->getKuserId(), $kshowId, $paramsArray);
         $insert_entry_helper->setPartnerId($this->getPartnerId(), $this->getPartnerId() * 100);
         $insert_entry_helper->insertEntry($token, $dbEntry->getType(), $dbEntry->getId(), $dbEntry->getName(), $dbEntry->getTags(), $dbEntry);
         $dbEntry = $insert_entry_helper->getEntry();
         kUploadTokenMgr::closeUploadTokenById($uploadTokenId);
         myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_ADD, $dbEntry);
         $mediaEntry->fromObject($dbEntry, $this->getResponseProfile());
         return $mediaEntry;
     } catch (kCoreException $ex) {
         if ($ex->getCode() == kUploadTokenException::UPLOAD_TOKEN_INVALID_STATUS) {
         }
         throw new KalturaAPIException(KalturaErrors::UPLOAD_TOKEN_INVALID_STATUS_FOR_ADD_ENTRY);
         throw $ex;
     }
 }
 /**
  * Builds a Criteria object containing the primary key for this object.
  *
  * Unlike buildCriteria() this method includes the primary key values regardless
  * of whether or not they have been modified.
  *
  * @return     Criteria The Criteria object containing value(s) for primary key(s).
  */
 public function buildPkeyCriteria()
 {
     $criteria = new Criteria(EmailIngestionProfilePeer::DATABASE_NAME);
     $criteria->add(EmailIngestionProfilePeer::ID, $this->id);
     if ($this->alreadyInSave && count($this->modifiedColumns) == 2 && $this->isColumnModified(EmailIngestionProfilePeer::UPDATED_AT)) {
         $theModifiedColumn = null;
         foreach ($this->modifiedColumns as $modifiedColumn) {
             if ($modifiedColumn != EmailIngestionProfilePeer::UPDATED_AT) {
                 $theModifiedColumn = $modifiedColumn;
             }
         }
         $atomicColumns = EmailIngestionProfilePeer::getAtomicColumns();
         if (in_array($theModifiedColumn, $atomicColumns)) {
             $criteria->add($theModifiedColumn, $this->getByName($theModifiedColumn, BasePeer::TYPE_COLNAME), Criteria::NOT_EQUAL);
         }
     }
     return $criteria;
 }
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = EmailIngestionProfilePeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setName($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setDescription($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setEmailAddress($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setMailboxId($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setPartnerId($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setConversionProfile2Id($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setModerationStatus($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setCustomData($arr[$keys[8]]);
     }
     if (array_key_exists($keys[9], $arr)) {
         $this->setStatus($arr[$keys[9]]);
     }
     if (array_key_exists($keys[10], $arr)) {
         $this->setCreatedAt($arr[$keys[10]]);
     }
     if (array_key_exists($keys[11], $arr)) {
         $this->setUpdatedAt($arr[$keys[11]]);
     }
 }