/** * List KalturaDropFolder objects * * @action list * @param KalturaDropFolderFilter $filter * @param KalturaFilterPager $pager * @return KalturaDropFolderListResponse */ public function listAction(KalturaDropFolderFilter $filter = null, KalturaFilterPager $pager = null) { if (!$filter) { $filter = new KalturaDropFolderFilter(); } $dropFolderFilter = $filter->toObject(); $c = new Criteria(); $dropFolderFilter->attachToCriteria($c); $count = DropFolderPeer::doCount($c); if (!$pager) { $pager = new KalturaFilterPager(); } $pager->attachToCriteria($c); $list = DropFolderPeer::doSelect($c); $response = new KalturaDropFolderListResponse(); $response->objects = KalturaDropFolderArray::fromDbArray($list, $this->getResponseProfile()); $response->totalCount = $count; return $response; }
/** * 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(DropFolderPeer::DATABASE_NAME); $criteria->add(DropFolderPeer::ID, $pks, Criteria::IN); $objs = DropFolderPeer::doSelect($criteria, $con); } return $objs; }
<?php chdir(__DIR__ . '/../'); require_once __DIR__ . '/../bootstrap.php'; $dropFoldersCriteria = new Criteria(); $dropFoldersCriteria->add(DropFolderPeer::STATUS, DropFolderStatus::ENABLED); $dropFoldersCriteria->add(DropFolderPeer::TYPE, DropFolderType::SFTP); $dropFolders = DropFolderPeer::doSelect($dropFoldersCriteria); KalturaLog::debug("Drop folders count [" . count($dropFolders) . "]"); foreach ($dropFolders as $dropFolder) { /* @var $dropFolder SftpDropFolder */ $dropFolderId = $dropFolder->getId(); $passed = true; $sftp = kFileTransferMgr::getInstance(kFileTransferMgrType::SFTP_SEC_LIB); /* @var $sftp sftpSecLibMgr */ $dropFolderPublicKeyFile = uniqid('sftp-pub-'); $dropFolderPrivateKeyFile = uniqid('sftp-pvt-'); try { if ($dropFolder->getSshPrivateKey()) { file_put_contents($dropFolderPublicKeyFile, $dropFolder->getSshPublicKey()); file_put_contents($dropFolderPrivateKeyFile, $dropFolder->getSshPrivateKey()); $sftp->loginPubKey($dropFolder->getSshHost(), $dropFolder->getSshUsername(), $dropFolderPublicKeyFile, $dropFolderPrivateKeyFile, $dropFolder->getSshPassPhrase(), $dropFolder->getSshPort()); unlink($dropFolderPublicKeyFile); unlink($dropFolderPrivateKeyFile); } else { $sftp->login($dropFolder->getSshHost(), $dropFolder->getSshUsername(), $dropFolder->getSshPassword(), $dropFolder->getSshPort()); } } catch (Exception $e) { KalturaLog::err("Drop folder [{$dropFolderId}] login failed: " . $e->getMessage()); if (file_exists($dropFolderPublicKeyFile)) { unlink($dropFolderPublicKeyFile);