示例#1
0
 public static function dup($class_name, $old_id, $new_id)
 {
     $obj = self::select($class_name, "id={$old_id}");
     if (!$obj) {
         throw new Exception(__CLASS__ . ": error! did not find [{$class_name}] with {$old_id} to duplicate");
     }
     $temp_obj = self::select($class_name, "id={$new_id}");
     if ($temp_obj) {
         throw new Exception(__CLASS__ . ": error! [{$class_name}] with {$new_id} already exists in db. cannot duplicate");
     }
     $new_obj = $obj->copy();
     $new_obj->save();
     $stored_id = $new_obj->getId();
     //		echo "stored_id: $stored_id\n";
     $db_connection = Propel::getConnection();
     $db_connection->begin();
     $db_connection->executeUpdate("UPDATE {$class_name} set id={$new_id} WHERE id={$stored_id};");
     $db_connection->commit();
     //$db_connection->close();
     Propel::close();
 }
 public function execute()
 {
     requestUtils::handleConditionalGet();
     $flavorId = $this->getRequestParameter("flavorId");
     $shouldProxy = $this->getRequestParameter("forceproxy", false);
     $ks = $this->getRequestParameter("ks");
     $fileParam = $this->getRequestParameter("file");
     $referrer = base64_decode($this->getRequestParameter("referrer"));
     if (!is_string($referrer)) {
         // base64_decode can return binary data
         $referrer = '';
     }
     $flavorAsset = flavorAssetPeer::retrieveById($flavorId);
     if (is_null($flavorAsset)) {
         KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
     }
     $entry = entryPeer::retrieveByPK($flavorAsset->getEntryId());
     if (is_null($entry)) {
         KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
     }
     myPartnerUtils::blockInactivePartner($flavorAsset->getPartnerId());
     myPartnerUtils::enforceDelivery($flavorAsset->getPartnerId());
     //disabled enforce cdn because of rtmp delivery
     //requestUtils::enforceCdnDelivery($flavorAsset->getPartnerId());
     $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     if (!kFileSyncUtils::file_exists($syncKey, false)) {
         list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
         if (is_null($fileSync)) {
             KalturaLog::log("Error - no FileSync for flavor [" . $flavorAsset->getId() . "]");
             KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
         }
         // always dump remote urls so they will be cached by the cdn transparently
         $remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
         kFile::dumpUrl($remoteUrl, true, true);
     }
     $path = kFileSyncUtils::getReadyLocalFilePathForKey($syncKey);
     $flvWrapper = new myFlvHandler($path);
     $isFlv = $flvWrapper->isFlv();
     $clipFrom = $this->getRequestParameter("clipFrom", 0);
     // milliseconds
     $clipTo = $this->getRequestParameter("clipTo", 2147483647);
     // milliseconds
     if ($clipTo == 0) {
         $clipTo = 2147483647;
     }
     if (is_dir($path) && $fileParam) {
         $path .= "/{$fileParam}";
         //echo "path($path),file($fileParam)";
         kFile::dumpFile($path, null, null);
         die;
     } else {
         if (!$isFlv) {
             $limit_file_size = 0;
             if ($clipTo != 2147483647) {
                 $mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($flavorAsset->getId());
                 if ($mediaInfo && ($mediaInfo->getVideoDuration() || $mediaInfo->getAudioDuration() || $mediaInfo->getContainerDuration())) {
                     $duration = $mediaInfo->getVideoDuration() ? $mediaInfo->getVideoDuration() : ($mediaInfo->getAudioDuration() ? $mediaInfo->getAudioDuration() : $mediaInfo->getContainerDuration());
                     $limit_file_size = floor(@filesize($path) * ($clipTo / $duration));
                 }
             }
             kFile::dumpFile($path, null, null, $limit_file_size);
             die;
         }
     }
     $audioOnly = $this->getRequestParameter("audioOnly");
     // milliseconds
     if ($audioOnly === '0') {
         // audioOnly was explicitly set to 0 - don't attempt to make further automatic investigations
     } elseif ($flvWrapper->getFirstVideoTimestamp() < 0) {
         $audioOnly = true;
     }
     $seekFrom = $this->getRequestParameter("seekFrom", -1);
     if ($seekFrom <= 0) {
         $seekFrom = -1;
     }
     $seekFromBytes = $this->getRequestParameter("seekFromBytes", -1);
     if ($seekFromBytes <= 0) {
         $seekFromBytes = -1;
     }
     $bytes = 0;
     if ($seekFrom !== -1 && $seekFrom !== 0) {
         list($bytes, $duration, $firstTagByte, $toByte) = $flvWrapper->clip(0, -1, $audioOnly);
         list($bytes, $duration, $fromByte, $toByte, $seekFromTimestamp) = $flvWrapper->clip($seekFrom, -1, $audioOnly);
         $seekFromBytes = myFlvHandler::FLV_HEADER_SIZE + $flvWrapper->getMetadataSize($audioOnly) + $fromByte - $firstTagByte;
     } else {
         list($bytes, $duration, $fromByte, $toByte, $fromTs, $cuepointPos) = myFlvStaticHandler::clip($path, $clipFrom, $clipTo, $audioOnly);
     }
     $metadataSize = $flvWrapper->getMetadataSize($audioOnly);
     $dataOffset = $metadataSize + myFlvHandler::getHeaderSize();
     $totalLength = $dataOffset + $bytes;
     list($bytes, $duration, $fromByte, $toByte, $fromTs, $cuepointPos) = myFlvStaticHandler::clip($path, $clipFrom, $clipTo, $audioOnly);
     list($rangeFrom, $rangeTo, $rangeLength) = requestUtils::handleRangeRequest($totalLength);
     if ($totalLength < 1000) {
         // (actually $total_length is probably 13 or 143 - header + empty metadata tag) probably a bad flv maybe only the header - dont cache
         requestUtils::sendCdnHeaders("flv", $rangeLength, 0);
     } else {
         requestUtils::sendCdnHeaders("flv", $rangeLength);
     }
     header('Content-Disposition: attachment; filename="video.flv"');
     // dont inject cuepoint into the stream
     $cuepointTime = 0;
     $cuepointPos = 0;
     try {
         Propel::close();
     } catch (Exception $e) {
         $this->logMessage("serveFlavor: error closing db {$e}");
     }
     header("Content-Type: video/x-flv");
     $flvWrapper->dump(self::CHUNK_SIZE, $fromByte, $toByte, $audioOnly, $seekFromBytes, $rangeFrom, $rangeTo, $cuepointTime, $cuepointPos);
     die;
 }
 /**
  * Close the propel connection from initPropel
  */
 private function closePropel()
 {
     Propel::close();
     $this->initPropel = false;
     $this->initPropelRoot = false;
 }
 public function executeAccept_group(sfWebRequest $request)
 {
     $invitacion_id = $request->getParameter('invitacion');
     $token_seguridad = $request->getParameter('token');
     $email_token = $request->getParameter('email');
     $user_token = $request->getParameter('account');
     /*vamos a aceptar permanecer a un grupo
        aca realizo validacion en 5 capas
           1 reviso que la session de usuario exista
           2 que la el valor obtenido en la consulta sea un object(que la consulta sql resulte con el registro solicitado)
           3 el token de la solicitud sea correcto
           4 el email sea correcto
           5 que el usuario id sea correcto (este es id del usuario que envio la solicitud en md5)
       */
     $user = $this->getUser()->getAttribute(sfConfig::get('app_session_current_user'), null);
     if ($user != null) {
         $solicitud = SolicitudGrupoTrabajoScPeer::retrieveByPK($invitacion_id);
         if (is_object($solicitud)) {
             if ($token_seguridad == $solicitud->getToken()) {
                 if ($email_token == md5($user->getEmail())) {
                     if ($user_token == md5($solicitud->getUserId())) {
                         $solicitud->setRespondido(1);
                         $solicitud->setFlag(json_encode(array("estado" => false, "respuesta" => true)));
                         $solicitud->setUpdateAt(time());
                         $solicitud->save();
                         //falta cambiar los indicadores que esten relacionados al grupo
                         /*vamos a obtener todos los arboles que esten relacionados con el grupo
                           depues vamos a obtener todos los indicadores donde el usuario se encuentre
                           asignado y vamos a aumetar el ID en cada registro que encontremos*/
                         //admemas vamos hacer lo mismo en las asignaciones para tener un mejor indexacion
                         //a la hora de hacer las consultas.
                         $criterio_tree = new Criteria();
                         $criterio_tree->add(TreeScPeer::GRUPO_TRABAJO_ID, $solicitud->getGrupoId());
                         $list_tree = TreeScPeer::doSelect($criterio_tree);
                         foreach ($list_tree as $row) {
                             $con = Propel::getConnection();
                             $criterio_busqueda = new Criteria();
                             $criterio_busqueda->add(IndicatorsScPeer::EMAIL_RESPONSABLE, '%' . $solicitud->getEmail() . '%', Criteria::LIKE);
                             $criterio_busqueda->add(IndicatorsScPeer::TREE_ID, $row->getId());
                             $criterio_update = new Criteria();
                             $criterio_update->add(IndicatorsScPeer::RESPONSABLE_ID, $user->getId());
                             BasePeer::doUpdate($criterio_busqueda, $criterio_update, $con);
                             $con = Propel::close();
                         }
                         $con = Propel::getConnection();
                         $criterio_asignaciones = new Criteria();
                         $criterio_asignaciones->add(AsignacionScPeer::GRUPO_ID, $solicitud->getGrupoId());
                         $criterio_asignaciones->add(AsignacionScPeer::EMAIL, '%' . $user->getEmail() . '%', Criteria::LIKE);
                         $criterio_update = new Criteria();
                         $criterio_update->add(AsignacionScPeer::USER_ID, $user->getId());
                         BasePeer::doUpdate($criterio_asignaciones, $criterio_update, $con);
                         $con = Propel::close();
                         $grupo_trabajo = new DetalleGrupoTrabajoSc();
                         $grupo_trabajo->setEmail($user->getEmail());
                         $grupo_trabajo->setUserId($user->getId());
                         $grupo_trabajo->setGrupoId($solicitud->getGrupoId());
                         $grupo_trabajo->save();
                         $this->redirect('@list_working_groups');
                     } else {
                         return sfView::ERROR;
                     }
                 } else {
                     return sfView::ERROR;
                 }
             } else {
                 return sfView::ERROR;
             }
         } else {
             return sfView::ERROR;
         }
     } else {
         return sfView::ERROR;
     }
 }
 public function execute()
 {
     //entitlement should be disabled to serveFlavor action as we do not get ks on this action.
     KalturaCriterion::disableTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY);
     requestUtils::handleConditionalGet();
     $flavorId = $this->getRequestParameter("flavorId");
     $shouldProxy = $this->getRequestParameter("forceproxy", false);
     $fileName = $this->getRequestParameter("fileName");
     $fileParam = $this->getRequestParameter("file");
     $fileParam = basename($fileParam);
     $pathOnly = $this->getRequestParameter("pathOnly", false);
     $referrer = base64_decode($this->getRequestParameter("referrer"));
     if (!is_string($referrer)) {
         // base64_decode can return binary data
         $referrer = '';
     }
     $flavorAsset = assetPeer::retrieveById($flavorId);
     if (is_null($flavorAsset)) {
         KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
     }
     $entryId = $this->getRequestParameter("entryId");
     if (!is_null($entryId) && $flavorAsset->getEntryId() != $entryId) {
         KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
     }
     if ($fileName) {
         header("Content-Disposition: attachment; filename=\"{$fileName}\"");
         header("Content-Type: application/force-download");
         header("Content-Description: File Transfer");
     }
     $clipTo = null;
     $entry = $flavorAsset->getentry();
     if (!$entry) {
         KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
     }
     KalturaMonitorClient::initApiMonitor(false, 'extwidget.serveFlavor', $flavorAsset->getPartnerId());
     myPartnerUtils::enforceDelivery($entry, $flavorAsset);
     $version = $this->getRequestParameter("v");
     if (!$version) {
         $version = $flavorAsset->getVersion();
     }
     $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET, $version);
     if ($pathOnly && kIpAddressUtils::isInternalIp($_SERVER['REMOTE_ADDR'])) {
         $path = null;
         list($file_sync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, false, false);
         if ($file_sync) {
             $parent_file_sync = kFileSyncUtils::resolve($file_sync);
             $path = $parent_file_sync->getFullPath();
             if ($fileParam && is_dir($path)) {
                 $path .= "/{$fileParam}";
             }
         }
         $renderer = new kRendererString('{"sequences":[{"clips":[{"type":"source","path":"' . $path . '"}]}]}', 'application/json');
         if ($path) {
             $this->storeCache($renderer, $flavorAsset->getPartnerId());
         }
         $renderer->output();
         KExternalErrors::dieGracefully();
     }
     if (kConf::hasParam('serve_flavor_allowed_partners') && !in_array($flavorAsset->getPartnerId(), kConf::get('serve_flavor_allowed_partners'))) {
         KExternalErrors::dieError(KExternalErrors::ACTION_BLOCKED);
     }
     if (!kFileSyncUtils::file_exists($syncKey, false)) {
         list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
         if (is_null($fileSync)) {
             KalturaLog::log("Error - no FileSync for flavor [" . $flavorAsset->getId() . "]");
             KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
         }
         // always dump remote urls so they will be cached by the cdn transparently
         $remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
         kFileUtils::dumpUrl($remoteUrl);
     }
     $path = kFileSyncUtils::getReadyLocalFilePathForKey($syncKey);
     $isFlv = false;
     if (!$shouldProxy) {
         $flvWrapper = new myFlvHandler($path);
         $isFlv = $flvWrapper->isFlv();
     }
     $clipFrom = $this->getRequestParameter("clipFrom", 0);
     // milliseconds
     if (is_null($clipTo)) {
         $clipTo = $this->getRequestParameter("clipTo", self::NO_CLIP_TO);
     }
     // milliseconds
     if ($clipTo == 0) {
         $clipTo = self::NO_CLIP_TO;
     }
     if (!is_numeric($clipTo) || $clipTo < 0) {
         KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'clipTo must be a positive number');
     }
     $seekFrom = $this->getRequestParameter("seekFrom", -1);
     if ($seekFrom <= 0) {
         $seekFrom = -1;
     }
     $seekFromBytes = $this->getRequestParameter("seekFromBytes", -1);
     if ($seekFromBytes <= 0) {
         $seekFromBytes = -1;
     }
     if ($fileParam && is_dir($path)) {
         $path .= "/{$fileParam}";
         kFileUtils::dumpFile($path, null, null);
         KExternalErrors::dieGracefully();
     } else {
         if (!$isFlv || $clipTo == self::NO_CLIP_TO && $seekFrom < 0 && $seekFromBytes < 0) {
             $limit_file_size = 0;
             if ($clipTo != self::NO_CLIP_TO) {
                 if (strtolower($flavorAsset->getFileExt()) == 'mp4' && PermissionPeer::isValidForPartner(PermissionName::FEATURE_ACCURATE_SERVE_CLIPPING, $flavorAsset->getPartnerId())) {
                     $contentPath = myContentStorage::getFSContentRootPath();
                     $tempClipName = $version . '_' . $clipTo . '.mp4';
                     $tempClipPath = $contentPath . myContentStorage::getGeneralEntityPath("entry/tempclip", $flavorAsset->getIntId(), $flavorAsset->getId(), $tempClipName);
                     if (!file_exists($tempClipPath)) {
                         kFile::fullMkdir($tempClipPath);
                         $clipToSec = round($clipTo / 1000, 3);
                         $cmdLine = kConf::get("bin_path_ffmpeg") . " -i {$path} -vcodec copy -acodec copy -f mp4 -t {$clipToSec} -y {$tempClipPath} 2>&1";
                         KalturaLog::log("Executing {$cmdLine}");
                         $output = array();
                         $return_value = "";
                         exec($cmdLine, $output, $return_value);
                         KalturaLog::log("ffmpeg returned {$return_value}, output:" . implode("\n", $output));
                     }
                     if (file_exists($tempClipPath)) {
                         KalturaLog::log("Dumping {$tempClipPath}");
                         kFileUtils::dumpFile($tempClipPath);
                     } else {
                         KalturaLog::err('Failed to clip the file using ffmpeg, falling back to rough clipping');
                     }
                 }
                 $mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($flavorAsset->getId());
                 if ($mediaInfo && ($mediaInfo->getVideoDuration() || $mediaInfo->getAudioDuration() || $mediaInfo->getContainerDuration())) {
                     $duration = $mediaInfo->getVideoDuration() ? $mediaInfo->getVideoDuration() : ($mediaInfo->getAudioDuration() ? $mediaInfo->getAudioDuration() : $mediaInfo->getContainerDuration());
                     $limit_file_size = floor(@kFile::fileSize($path) * ($clipTo / $duration) * 1.2);
                 }
             }
             $renderer = kFileUtils::getDumpFileRenderer($path, null, null, $limit_file_size);
             if (!$fileName) {
                 $this->storeCache($renderer, $flavorAsset->getPartnerId());
             }
             $renderer->output();
             KExternalErrors::dieGracefully();
         }
     }
     $audioOnly = $this->getRequestParameter("audioOnly");
     // milliseconds
     if ($audioOnly === '0') {
         // audioOnly was explicitly set to 0 - don't attempt to make further automatic investigations
     } elseif ($flvWrapper->getFirstVideoTimestamp() < 0) {
         $audioOnly = true;
     }
     $bytes = 0;
     if ($seekFrom !== -1 && $seekFrom !== 0) {
         list($bytes, $duration, $firstTagByte, $toByte) = $flvWrapper->clip(0, -1, $audioOnly);
         list($bytes, $duration, $fromByte, $toByte, $seekFromTimestamp) = $flvWrapper->clip($seekFrom, -1, $audioOnly);
         $seekFromBytes = myFlvHandler::FLV_HEADER_SIZE + $flvWrapper->getMetadataSize($audioOnly) + $fromByte - $firstTagByte;
     } else {
         list($bytes, $duration, $fromByte, $toByte, $fromTs, $cuepointPos) = myFlvStaticHandler::clip($path, $clipFrom, $clipTo, $audioOnly);
     }
     $metadataSize = $flvWrapper->getMetadataSize($audioOnly);
     $dataOffset = $metadataSize + myFlvHandler::getHeaderSize();
     $totalLength = $dataOffset + $bytes;
     list($bytes, $duration, $fromByte, $toByte, $fromTs, $cuepointPos) = myFlvStaticHandler::clip($path, $clipFrom, $clipTo, $audioOnly);
     list($rangeFrom, $rangeTo, $rangeLength) = requestUtils::handleRangeRequest($totalLength);
     if ($totalLength < 1000) {
         // (actually $total_length is probably 13 or 143 - header + empty metadata tag) probably a bad flv maybe only the header - dont cache
         requestUtils::sendCdnHeaders("flv", $rangeLength, 0);
     } else {
         requestUtils::sendCdnHeaders("flv", $rangeLength);
     }
     // dont inject cuepoint into the stream
     $cuepointTime = 0;
     $cuepointPos = 0;
     try {
         Propel::close();
     } catch (Exception $e) {
         $this->logMessage("serveFlavor: error closing db {$e}");
     }
     header("Content-Type: video/x-flv");
     $flvWrapper->dump(self::CHUNK_SIZE, $fromByte, $toByte, $audioOnly, $seekFromBytes, $rangeFrom, $rangeTo, $cuepointTime, $cuepointPos);
     KExternalErrors::dieGracefully();
 }
 public function executeEspejo_reportes($tree_id, $list_data_indicador, $fecha_update)
 {
     // $tree_id = $request->getParameter('idTree');
     // $user = $this->getUser()->getAttribute(sfConfig::get('app_session_current_user'),null);
     if ($tree_id != 0) {
         $tree_espejo = TreeScPeer::retrieveByPK($tree_id);
         if (is_object($tree_espejo)) {
             try {
                 $conn = Propel::getConnection();
                 $conn->beginTransaction();
                 $tree_bean = new TmpTreeSc();
                 $tree_bean->setConfigureFlag($tree_espejo->getConfigureFlag());
                 $tree_bean->setFlag("ok");
                 $tree_bean->save();
                 $criterio = new Criteria();
                 $criterio->add(IndicatorsScPeer::TREE_ID, $tree_espejo->getId());
                 $criterio->add(IndicatorsScPeer::FLAG, '%habilitado%', Criteria::LIKE);
                 $criterio->addAscendingOrderByColumn(IndicatorsScPeer::ID);
                 $list_indicadores = IndicatorsScPeer::doSelect($criterio);
                 $list_relation = null;
                 foreach ($list_indicadores as $row) {
                     $indicator_bean = new TmpDataReports();
                     $indicator_bean->setIndicadorId($row->getId());
                     $indicator_bean->setValorMinimo($row->getValorMinimo());
                     $indicator_bean->setValorDeseado($row->getValorDeseado());
                     $indicator_bean->setValorOptimo($row->getValorOptimo());
                     $indicator_bean->setTreeId($tree_bean->getId());
                     $indicator_bean->setUltimoNodo($row->getUltimoNodo());
                     $indicator_bean->setUpdateAt($fecha_update);
                     $indicator_bean->setFlag("ok");
                     if ($row->getPreviousId() == 0) {
                         $indicator_bean->setPreviousId(0);
                     } else {
                         $id_relation = $this->return_relation_id($list_relation, $row->getPreviousId());
                         $indicator_bean->setPreviousId($id_relation);
                     }
                     if ($row->getParents() != "") {
                         $parents = $this->return_parent_relation($list_relation, $row->getParents());
                         $indicator_bean->setParents($parents);
                     }
                     //preguntar si es ultmo idicador
                     //->getUltimoNodo()
                     //si es ultimo nodo tengo que pasar la data actual
                     //a  data que se esta creando ->
                     $indicator_bean->setConectoresConfigure($row->getConectoresConfigure());
                     $indicator_bean->save();
                     //actualizo el valor actual entregado
                     $relation = array('array' => '' . $row->getId() . '-' . $indicator_bean->getId() . '');
                     $list_relation[] = $relation;
                 }
                 foreach ($list_data_indicador as $obj_data) {
                     $criteria = new Criteria();
                     $id = $this->return_relation_id($list_relation, $obj_data->getIndicadorId());
                     $criteria->add(TmpDataReportsPeer::ID, $id);
                     $obj_update_tmp = TmpDataReportsPeer::doSelectOne($criteria);
                     $obj_update_tmp->setData($obj_data->getData());
                     $obj_update_tmp->save();
                 }
                 $conn->commit();
                 $conn = Propel::close();
                 // VOY A DEVOLVER UN ARREGLO CON DOS VALORES 1) ID DEL TREE TEMPORAL, 2) LA LISTA DE LA RELACION
                 $result = array('array' => $tree_bean->getId(), "lista" => $list_relation);
                 return $result;
                 //$this->list_relation = $list_relation;
                 //$this->redirect('@edit_strategy?id_tree='.$tree_bean->getId());
             } catch (Exception $e) {
                 $conn->rollBack();
                 // $this->message = $e->getMessage();
                 $conn = Propel::close();
                 return sfView::ERROR;
             }
         } else {
             // $this->message = 'tree not definitive';
             $conn = Propel::close();
             return sfView::ERROR;
         }
     } else {
         //   $this->message = 'session expired';
         $conn = Propel::close();
         return sfView::ERROR;
     }
 }
示例#7
0
 public static function closeDbConnections()
 {
     // close all opened db connetion while we end an action with a long executing operation such as dumping a file.
     // this will limit the number of concurrent db connections as dumping a file make take a long time
     try {
         Propel::close();
     } catch (Exception $e) {
         $this->logMessage("closeDbConnections: error closing db {$e}");
     }
 }
 public function execute()
 {
     requestUtils::handleConditionalGet();
     $entry_id = $this->getRequestParameter("entry_id");
     $ks_str = $this->getRequestParameter("ks");
     $base64_referrer = $this->getRequestParameter("referrer");
     $referrer = base64_decode($base64_referrer);
     if (!is_string($referrer)) {
         // base64_decode can return binary data
         $referrer = "";
     }
     $clip_from = $this->getRequestParameter("clip_from", 0);
     // milliseconds
     $clip_to = $this->getRequestParameter("clip_to", 2147483647);
     // milliseconds
     if ($clip_to == 0) {
         $clip_to = 2147483647;
     }
     $request = $_SERVER["REQUEST_URI"];
     // remove dynamic fields from the url so we'll request a single url from the cdn
     $request = str_replace("/referrer/{$base64_referrer}", "", $request);
     $request = str_replace("/ks/{$ks_str}", "", $request);
     // workaround the filter which hides all the deleted entries -
     // now that deleted entries are part of xmls (they simply point to the 'deleted' templates), we should allow them here
     $entry = entryPeer::retrieveByPKNoFilter($entry_id);
     if (!$entry) {
         KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
     }
     myPartnerUtils::blockInactivePartner($entry->getPartnerId());
     // set the memory size to be able to serve big files in a single chunk
     ini_set("memory_limit", "64M");
     // set the execution time to be able to serve big files in a single chunk
     ini_set("max_execution_time", 240);
     if ($entry->getType() == entryType::MIX && $entry->getStatus() == entryStatus::DELETED) {
         // because the fiter was turned off - a manual check for deleted entries must be done.
         die;
     } else {
         if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) {
             $version = $this->getRequestParameter("version", null);
             $width = $this->getRequestParameter("width", -1);
             $height = $this->getRequestParameter("height", -1);
             $crop_provider = $this->getRequestParameter("crop_provider", null);
             $bgcolor = $this->getRequestParameter("bgcolor", "ffffff");
             $type = $this->getRequestParameter("type", 1);
             $quality = $this->getRequestParameter("quality", 0);
             $src_x = $this->getRequestParameter("src_x", 0);
             $src_y = $this->getRequestParameter("src_y", 0);
             $src_w = $this->getRequestParameter("src_w", 0);
             $src_h = $this->getRequestParameter("src_h", 0);
             $vid_sec = $this->getRequestParameter("vid_sec", -1);
             $vid_slice = $this->getRequestParameter("vid_slice", -1);
             $vid_slices = $this->getRequestParameter("vid_slices", -1);
             if ($width == -1 && $height == -1) {
                 $width = 640;
                 $height = 480;
             } else {
                 if ($width == -1) {
                     // if only either width or height is missing reset them to zero, and convertImage will handle them
                     $width = 0;
                 } else {
                     if ($height == -1) {
                         $height = 0;
                     }
                 }
             }
             $tempThumbPath = myEntryUtils::resizeEntryImage($entry, $version, $width, $height, $type, $bgcolor, $crop_provider, $quality, $src_x, $src_y, $src_w, $src_h, $vid_sec, $vid_slice, $vid_slices);
             kFile::dumpFile($tempThumbPath, null, strpos($tempThumbPath, "_NOCACHE_") === false ? null : 0);
         }
     }
     $audio_only = $this->getRequestParameter("audio_only");
     // milliseconds
     $flavor = $this->getRequestParameter("flavor", 1);
     //
     $flavor_param_id = $this->getRequestParameter("flavor_param_id", null);
     //
     $streamer = $this->getRequestParameter("streamer");
     //
     if (substr($streamer, 0, 4) == "rtmp") {
         // the fms may add .mp4 to the end of the url
         $streamer = "rtmp";
     }
     // grab seek_from_bytes parameter and normalize url
     $seek_from_bytes = $this->getRequestParameter("seek_from_bytes", -1);
     $request = str_replace("/seek_from_bytes/{$seek_from_bytes}", "", $request);
     if ($seek_from_bytes <= 0) {
         $seek_from_bytes = -1;
     }
     // grab seek_from parameter and normalize url
     $seek_from = $this->getRequestParameter("seek_from", -1);
     $request = str_replace("/seek_from/{$seek_from}", "", $request);
     if ($seek_from <= 0) {
         $seek_from = -1;
     }
     $this->dump_from_byte = 0;
     // reset accurate seek from timestamp
     $seek_from_timestamp = -1;
     // backward compatibility
     if ($flavor === "0") {
         // for edit version
         $flavor = "edit";
     }
     if ($flavor === "1" || $flavor === 1) {
         // for play version
         $flavor = null;
     }
     // when flavor is null, we will get a default flavor
     if ($flavor == "edit") {
         $flavorAsset = flavorAssetPeer::retrieveBestEditByEntryId($entry->getId());
     } elseif (!is_null($flavor)) {
         $flavorAsset = flavorAssetPeer::retrieveById($flavor);
         // when specific asset was request, we don't validate its tags
         if ($flavorAsset && ($flavorAsset->getEntryId() != $entry->getId() || $flavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_READY)) {
             $flavorAsset = null;
         }
         // we will throw an error later
     } elseif (is_null($flavor) && !is_null($flavor_param_id)) {
         $flavorAsset = flavorAssetPeer::retrieveByEntryIdAndFlavorParams($entry->getId(), $flavor_param_id);
         if ($flavorAsset && $flavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_READY) {
             $flavorAsset = null;
         }
         // we will throw an error later
     } else {
         if ($entry->getSource() == entry::ENTRY_MEDIA_SOURCE_WEBCAM) {
             $flavorAsset = flavorAssetPeer::retrieveOriginalByEntryId($entry->getId());
         } else {
             $flavorAsset = flavorAssetPeer::retrieveBestPlayByEntryId($entry->getId());
         }
         if (!$flavorAsset) {
             $flavorAssets = flavorAssetPeer::retreiveReadyByEntryIdAndTag($entry->getId(), flavorParams::TAG_WEB);
             if (count($flavorAssets) > 0) {
                 $flavorAsset = $flavorAssets[0];
             }
         }
     }
     if (is_null($flavorAsset)) {
         KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
     }
     $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     if (kFileSyncUtils::file_exists($syncKey, false)) {
         $path = kFileSyncUtils::getReadyLocalFilePathForKey($syncKey);
     } else {
         list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
         if (is_null($fileSync)) {
             KalturaLog::log("Error - no FileSync for flavor [" . $flavorAsset->getId() . "]");
             KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
         }
         $remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
         $this->redirect($remoteUrl);
     }
     $flv_wrapper = new myFlvHandler($path);
     $isFlv = $flv_wrapper->isFlv();
     // scrubbing is not allowed within mp4 files
     if (!$isFlv) {
         $seek_from = $seek_from_bytes = -1;
     }
     if ($seek_from !== -1 && $seek_from !== 0) {
         if ($audio_only === '0') {
             // audio_only was explicitly set to 0 - don't attempt to make further automatic investigations
         } elseif ($flv_wrapper->getFirstVideoTimestamp() < 0) {
             $audio_only = true;
         }
         list($bytes, $duration, $first_tag_byte, $to_byte) = $flv_wrapper->clip(0, -1, $audio_only);
         list($bytes, $duration, $from_byte, $to_byte, $seek_from_timestamp) = $flv_wrapper->clip($seek_from, -1, $audio_only);
         $seek_from_bytes = myFlvHandler::FLV_HEADER_SIZE + $flv_wrapper->getMetadataSize($audio_only) + $from_byte - $first_tag_byte;
     }
     // the direct path without a cdn is "http://s3kaltura.s3.amazonaws.com".$entry->getDataPath();
     $extStorageUrl = $entry->getExtStorageUrl();
     if ($extStorageUrl && substr_count($extStorageUrl, 's3kaltura')) {
         // if for some reason we didnt set our accurate $seek_from_timestamp reset it to the requested seek_from
         if ($seek_from_timestamp == -1) {
             $seek_from_timestamp = $seek_from;
         }
         $request_host = parse_url($extStorageUrl, PHP_URL_HOST);
         $akamai_url = str_replace($request_host, "cdns3akmi.kaltura.com", $extStorageUrl);
         $akamai_url .= $seek_from_bytes == -1 ? "" : "?aktimeoffset=" . floor($seek_from_timestamp / 1000);
         header("Location: {$akamai_url}");
         die;
     } elseif ($extStorageUrl) {
         // if for some reason we didnt set our accurate $seek_from_timestamp reset it to the requested seek_from
         if ($seek_from_timestamp == -1) {
             $seek_from_timestamp = $seek_from;
         }
         $extStorageUrl .= $seek_from_bytes == -1 ? "" : "?aktimeoffset=" . floor($seek_from_timestamp / 1000);
         header("Location: {$extStorageUrl}");
         die;
     }
     // use headers to detect cdn
     $cdn_name = "";
     $via_header = @$_SERVER["HTTP_VIA"];
     if (strpos($via_header, "llnw.net") !== false) {
         $cdn_name = "limelight";
     } else {
         if (strpos($via_header, "akamai") !== false) {
             $cdn_name = "akamai";
         } else {
             if (strpos($via_header, "Level3") !== false) {
                 $cdn_name = "level3";
             }
         }
     }
     // setting file extension - first trying frrom flavor asset
     $ext = $flavorAsset->getFileExt();
     // if failed, set extension according to file type (isFlv)
     if (!$ext) {
         $ext = $isFlv ? "flv" : "mp4";
     }
     $flv_extension = $streamer == "rtmp" ? "?" : "/a.{$ext}?novar=0";
     // dont check for rtmp / and for an already redirect url
     if ($streamer != "rtmp" && strpos($request, $flv_extension) === false) {
         // check security using ks
         $securyEntryHelper = new KSecureEntryHelper($entry, $ks_str, $referrer);
         if ($securyEntryHelper->shouldPreview()) {
             $this->checkForPreview($securyEntryHelper, $clip_to);
         } else {
             $securyEntryHelper->validateForPlay($entry, $ks_str);
         }
     } else {
         // if needs security check using cdn authentication mechanism
         // for now assume this is a cdn request and don't check for security
     }
     // use limelight mediavault if either security policy requires it or if we're trying to seek within the video
     if ($entry->getSecurityPolicy() || $seek_from_bytes !== -1) {
         // we have three options:
         // arrived through limelight mediavault url - the url is secured
         // arrived directly through limelight (not secured through mediavault) - enforce ks and redirect to mediavault url
         // didnt use limelight - enforce ks
         // the cdns are configured to authenticate request for /s/....
         // check if we're already in a redirected secure link using the "/s/" prefix
         $secure_request = substr($request, 0, 3) == "/s/";
         if ($secure_request && ($cdn_name == "limelight" || $cdn_name == "level3")) {
             // request was validated by cdn let it through
         } else {
             // extract ks
             $ks_str = $this->getRequestParameter("ks", "");
             if ($entry->getSecurityPolicy()) {
                 if (!$ks_str) {
                     $this->logMessage("flvclipper - no KS");
                     die;
                 }
                 $ks = kSessionUtils::crackKs($ks_str);
                 if (!$ks) {
                     $this->logMessage("flvclipper - invalid ks [{$ks_str}]");
                     die;
                 }
                 $matched_privs = $ks->verifyPrivileges("sview", $entry_id);
                 $this->logMessage("flvclipper - verifyPrivileges name [sview], priv [{$entry_id}] [{$matched_privs}]");
                 if (!$matched_privs) {
                     $this->logMessage("flvclipper - doesnt not match required privlieges [{$ks_str}]");
                     die;
                 }
             }
             if ($cdn_name == "limelight") {
                 $ll_url = requestUtils::getCdnHost() . "/s{$request}" . $flv_extension;
                 $secret = kConf::get("limelight_madiavault_password");
                 $expire = "&e=" . (time() + 120);
                 $ll_url .= $expire;
                 $fs = $seek_from_bytes == -1 ? "" : "&fs={$seek_from_bytes}";
                 $ll_url .= "&h=" . md5("{$secret}{$ll_url}") . $fs;
                 //header("Location: $ll_url");
                 $this->redirect($ll_url);
             } else {
                 if ($cdn_name == "level3") {
                     $level3_url = $request . $flv_extension;
                     if ($entry->getSecurityPolicy()) {
                         $level3_url = "/s{$level3_url}";
                         // set expire time in GMT hence the date("Z") offset
                         $expire = "&nva=" . strftime("%Y%m%d%H%M%S", time() - date("Z") + 30);
                         $level3_url .= $expire;
                         $secret = kConf::get("level3_authentication_key");
                         $hash = "0" . substr(self::hmac('sha1', $secret, $level3_url), 0, 20);
                         $level3_url .= "&h={$hash}";
                     }
                     $level3_url .= $seek_from_bytes == -1 ? "" : "&start={$seek_from_bytes}";
                     header("Location: {$level3_url}");
                     die;
                 } else {
                     if ($cdn_name == "akamai") {
                         $akamai_url = $request . $flv_extension;
                         // if for some reason we didnt set our accurate $seek_from_timestamp reset it to the requested seek_from
                         if ($seek_from_timestamp == -1) {
                             $seek_from_timestamp = $seek_from;
                         }
                         $akamai_url .= $seek_from_bytes == -1 ? "" : "&aktimeoffset=" . floor($seek_from_timestamp / 1000);
                         header("Location: {$akamai_url}");
                         die;
                     }
                 }
             }
             // a seek request without a supporting cdn - we need to send the answer from our server
             if ($seek_from_bytes !== -1 && $via_header === null) {
                 $this->dump_from_byte = $seek_from_bytes;
             }
         }
     }
     // always add the file suffix to the request (needed for scrubbing by some cdns,
     // and also breaks without extension on some corporate antivirus).
     // we add the the novar paramter since a leaving a trailing "?" will be trimmed
     // and then the /seek_from request will result in another url which level3
     // will try to refetch from the origin
     // note that for streamer we dont add the file extension
     if ($streamer != "rtmp" && strpos($request, $flv_extension) === false) {
         // a seek request without a supporting cdn - we need to send the answer from our server
         if ($seek_from_bytes !== -1 && $via_header === null) {
             $request .= "/seek_from_bytes/{$seek_from_bytes}";
         }
         requestUtils::sendCdnHeaders("flv", 0);
         header("Location: {$request}" . $flv_extension);
         die;
     }
     // mp4
     if (!$isFlv) {
         kFile::dumpFile($path);
     }
     $this->logMessage("flvclipperAction: serving file [{$path}] entry_id [{$entry_id}] clip_from [{$clip_from}] clip_to [{$clip_to}]", "warning");
     if ($audio_only === '0') {
         // audio_only was explicitly set to 0 - don't attempt to make further automatic investigations
     } elseif ($flv_wrapper->getFirstVideoTimestamp() < 0) {
         $audio_only = true;
     }
     //$start = microtime(true);
     list($bytes, $duration, $from_byte, $to_byte, $from_ts, $cuepoint_pos) = myFlvStaticHandler::clip($path, $clip_from, $clip_to, $audio_only);
     $metadata_size = $flv_wrapper->getMetadataSize($audio_only);
     $this->from_byte = $from_byte;
     $this->to_byte = $to_byte;
     //$end1 = microtime(true);
     //$this->logMessage( "flvclipperAction: serving file [$path] entry_id [$entry_id] bytes [$bytes] duration [$duration] [$from_byte]->[$to_byte]" , "warning" );
     //$this->logMessage( "flvclipperAction: serving file [$path] t1 [" . ( $end1-$start) . "]");
     $data_offset = $metadata_size + myFlvHandler::getHeaderSize();
     // if we're returning a partial file adjust the total size:
     // substract the metadata and bytes which are not delivered
     if ($this->dump_from_byte >= $data_offset && !$audio_only) {
         $bytes -= $metadata_size + max(0, $this->dump_from_byte - $data_offset);
     }
     $this->total_length = $data_offset + $bytes;
     //echo " $bytes , $duration ,$from_byte , $to_byte, $cuepoint_pos\n"; die;
     $this->cuepoint_time = 0;
     $this->cuepoint_pos = 0;
     if ($streamer == "chunked" && $clip_to != 2147483647) {
         $this->cuepoint_time = $clip_to - 1;
         $this->cuepoint_pos = $cuepoint_pos;
         $this->total_length += myFlvHandler::CUEPOINT_TAG_SIZE;
     }
     //$this->logMessage( "flvclipperAction: serving file [$path] entry_id [$entry_id] bytes with header & md [" . $this->total_length . "] bytes [$bytes] duration [$duration] [$from_byte]->[$to_byte]" , "warning" );
     $this->flv_wrapper = $flv_wrapper;
     $this->audio_only = $audio_only;
     try {
         Propel::close();
     } catch (Exception $e) {
         $this->logMessage("flvclipperAction: error closing db {$e}");
     }
     return sfView::SUCCESS;
 }
 /**
  * Returns a writable propel connection to the database of the Crontab.
  *
  * @param bool $reconnect Whether to force a new connection.
  *
  * @return PDO
  */
 protected function getPropelConnection($reconnect = false)
 {
     static $connection;
     if ($reconnect or empty($connection)) {
         if ($reconnect) {
             Propel::close();
         }
         $connection = Propel::getConnection(CrontabPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     return $connection;
 }
示例#10
0
 public static function shutdown()
 {
     Propel::close();
 }
示例#11
0
 /**
  * Fork the process into two
  * You can create an optional method called preFork() which is called before the fork
  * Also an optional method called postFork() which is called after the fork on any remaining processes
  * (ie if you choose to daemonize then the original foreground process will not call the postFork() method)
  *
  * @param bool $daemonize kill the parent (original) process and let the new child run
  *
  * @return void
  */
 protected function fork($daemonize = false)
 {
     if ($this->node !== 0) {
         return false;
     }
     // call any user created preFork method
     if (method_exists($this, 'preFork')) {
         $this->preFork();
     }
     // force Propel to close connections so that it will reconnect on next query
     if (class_exists('\\Propel')) {
         \Propel::close();
     }
     $pid = pcntl_fork();
     switch ($pid) {
         case -1:
             Logger::emergency('Unable to fork process');
             return;
         case 0:
             // this is the child
             $this->node++;
             break;
         default:
             // we are the original process
             if ($this->node == 0) {
                 \Cli\line('Child node : pid=%y%s%n', $pid);
                 if ($daemonize) {
                     //                        exit;
                 } else {
                     $this->pid[] = $pid;
                 }
                 return;
             }
     }
     // promote the daemon process so it doesn't die because the parent has
     if ($daemonize && posix_setsid() === -1) {
         Logger::critical('Error creating daemon as session leader');
         exit(1);
     }
     fclose(STDIN);
     fclose(STDOUT);
     fclose(STDERR);
     $this->stdIn = fopen('/dev/null', 'r');
     // set fd/0
     $this->stdOut = fopen('/dev/null', 'w');
     // set fd/1
     $this->stdErr = fopen('php://stdout', 'w');
     // a hack to duplicate fd/1 to 2
     // Silence any console output from the logger
     Logger::setSilentConsole(true);
     // call any user created postFork method
     if (method_exists($this, 'postFork')) {
         $this->postFork();
     }
 }
 private function evaluar_solicitud($email, $grupo, $userBean)
 {
     //solo puede enviar otra solicitud a la misma persona si
     //-es otra solicitud de otro grupo
     //-si el flag es 2 == Solicitud vencida
     $criterio_solicitud = new Criteria();
     $criterio_solicitud->add(SolicitudGrupoTrabajoScPeer::GRUPO_ID, $grupo);
     $criterio_solicitud->add(SolicitudGrupoTrabajoScPeer::EMAIL, '%' . $email . '%', Criteria::LIKE);
     //FLAG,'1' == activa
     $criterio_solicitud->add(SolicitudGrupoTrabajoScPeer::FLAG, '%estado":true%', Criteria::LIKE);
     $cantidad_registros = SolicitudGrupoTrabajoScPeer::doCount($criterio_solicitud);
     try {
         $con = Propel::getConnection();
         $con->beginTransaction();
         if ($cantidad_registros > 0) {
             //no le envio solicitud
             $obj = array("success" => true, "message" => "no le envio solicitud");
             $con = Propel::close();
             return $obj;
         } else {
             $solicitudBean = new SolicitudGrupoTrabajoSc();
             $solicitudBean->setGrupoId($grupo);
             $solicitudBean->setEmail($email);
             $solicitudBean->setCreateAt(time());
             $solicitudBean->setUpdateAt(time());
             $solicitudBean->setUserId($userBean->getId());
             //formar el token
             $token = md5($grupo . $email . rand($userBean->getId(), 1000));
             $solicitudBean->setToken($token);
             $solicitudBean->setFlag(json_encode(array("estado" => true, "respuesta" => false)));
             $solicitudBean->setRespondido(0);
             $solicitudBean->save();
             try {
                 $message = $this->getMailer()->compose();
                 $message->setSubject('Te invintaron a unirte a practil-scoredcard');
                 $message->setTo($email);
                 $message->setFrom(array('*****@*****.**' => 'Practil'));
                 $html = $this->getPartial('send_email/send_invitation_group', array('uri' => sfConfig::get('app_url_scorecard') . 'confirmation/confirmation_group?token=' . $token . '&email=' . $email . '&group_id=' . $grupo));
                 $message->setBody($html, 'text/html');
                 $this->getMailer()->send($message);
                 $con->commit();
                 $con = Propel::close();
                 $obj = array("success" => true, "message" => "le envie solicitud");
                 return $obj;
             } catch (Exception $e) {
                 $con->rollBack();
                 $con = Propel::close();
                 $obj = array("success" => false, "message" => $e->getMessage());
                 return $obj;
             }
         }
     } catch (Exception $e) {
         $con->rollBack();
         $con = Propel::close();
         $obj = array("success" => false, "message" => "se general");
         return $obj;
     }
 }
示例#13
0
 public static function dbShutdown()
 {
     $databaseManager = new sfDatabaseManager();
     $databaseManager->shutdown();
     Propel::close();
 }
 public function executeCreate_mirror_tree(sfWebRequest $request)
 {
     $tree_id = $request->getParameter('idTree');
     $user = $this->getUser()->getAttribute(sfConfig::get('app_session_current_user'), null);
     if ($user != null) {
         $tree_current = TreeScPeer::retrieveByPK($tree_id);
         if (is_object($tree_current)) {
             try {
                 $conn = Propel::getConnection();
                 $conn->beginTransaction();
                 $tree_bean = new TreeSc();
                 $tree_bean->setName($tree_current->getName());
                 $tree_bean->setUserId($tree_current->getUserId());
                 $tree_bean->setConfigureFlag($tree_current->getConfigureFlag());
                 $tree_bean->setConfigureDesign($tree_current->getConfigureDesign());
                 $tree_bean->setCreateAt(time());
                 $tree_bean->setUpdateAt(time());
                 $tree_bean->setFlag($tree_current->getFlag());
                 $tree_bean->setProduccion('not');
                 $tree_bean->setGrupoTrabajoId($tree_current->getGrupoTrabajoId());
                 $tree_bean->setPeriodoId($tree_current->getPeriodoId());
                 $tree_bean->save();
                 $tree_user_bean = new TreeUser();
                 $tree_user_bean->setUserId($tree_bean->getUserId());
                 $tree_user_bean->setTreeId($tree_bean->getId());
                 $tree_user_bean->save();
                 $criterio = new Criteria();
                 $criterio->add(IndicatorsScPeer::TREE_ID, $tree_current->getId());
                 $criterio->add(IndicatorsScPeer::FLAG, '%habilitado%', Criteria::LIKE);
                 $criterio->addAscendingOrderByColumn(IndicatorsScPeer::ID);
                 $list_indicadores = IndicatorsScPeer::doSelect($criterio);
                 $list_relation = null;
                 foreach ($list_indicadores as $row) {
                     $indicator_bean = new IndicatorsSc();
                     $indicator_bean->setTitulo($row->getTitulo());
                     $indicator_bean->setDescripcion($row->getDescripcion());
                     $indicator_bean->setValorMinimo($row->getValorMinimo());
                     $indicator_bean->setValorDeseado($row->getValorDeseado());
                     $indicator_bean->setValorOptimo($row->getValorOptimo());
                     $indicator_bean->setResponsableId($row->getResponsableId());
                     $indicator_bean->setTreeId($tree_bean->getId());
                     $indicator_bean->setEmailResponsable($row->getEmailResponsable());
                     $indicator_bean->setUltimoNodo($row->getUltimoNodo());
                     $indicator_bean->setDetNetworkAttributeId($row->getDetNetworkAttributeId());
                     $indicator_bean->setUsernameInNetwork($row->getUsernameInNetwork());
                     $indicator_bean->setGaFecIni($row->getGaFecIni());
                     $indicator_bean->setGaFecFin($row->getGaFecFin());
                     if ($row->getPreviousId() == 0) {
                         $indicator_bean->setPreviousId(0);
                     } else {
                         $id_relation = $this->return_relation_id($list_relation, $row->getPreviousId());
                         $indicator_bean->setPreviousId($id_relation);
                     }
                     if ($row->getParents() != "") {
                         $parents = $this->return_parent_relation($list_relation, $row->getParents());
                         $indicator_bean->setParents($parents);
                     }
                     $indicator_bean->setFlag($row->getFlag());
                     $indicator_bean->setConectoresConfigure($row->getConectoresConfigure());
                     $indicator_bean->save();
                     $relation = array('array' => '' . $row->getId() . '-' . $indicator_bean->getId() . '');
                     $list_relation[] = $relation;
                 }
                 //  $conn->rollBack();
                 $tree_current->setFlag(2);
                 $tree_current->save();
                 $conn->commit();
                 $conn = Propel::close();
                 $this->list_relation = $list_relation;
                 $this->redirect('@edit_strategy?id_tree=' . $tree_bean->getId());
             } catch (Exception $e) {
                 $conn->rollBack();
                 $this->message = $e->getMessage();
                 $conn = Propel::close();
                 return sfView::ERROR;
             }
         } else {
             $this->message = 'tree not definitive';
             $conn = Propel::close();
             return sfView::ERROR;
         }
     } else {
         $this->message = 'session expired';
         $conn = Propel::close();
         return sfView::ERROR;
     }
 }
 public static function closeDbConnections()
 {
     // close all opened db connetion while we are dumping the file.
     // this will limit the number of concurrent connections as the dumpFile make take
     // a long time
     try {
         Propel::close();
     } catch (Exception $e) {
         $this->logMessage("dumpFile: error closing db {$e}");
     }
 }
 public function is_the_last_record($data)
 {
     $connection = Propel::getConnection();
     $query = 'SELECT MAX(group_data) AS max FROM data_indicadores WHERE indicador_id = ' . $data->getIndicadorId();
     $statement = $connection->prepare($query);
     $statement->execute();
     $row = $statement->fetch();
     $ultimo = $row['max'];
     $connection = Propel::close();
     if ($ultimo == $data->getGroupData()) {
         return true;
     } else {
         return false;
     }
 }