/**
  * Action permettant de récupérer l'arbre des jeux de données.
  *
  * @param sfWebRequest $request
  */
 public function execute($request)
 {
     $this->logger = sfContext::getInstance()->getLogger();
     $this->logger->info("----------------------------------------------------------");
     $this->logger->info("---   DEBUT RECUPERATION ARBRE DATA SET");
     $this->getResponse()->setContentType('application/json');
     $this->setLayout(false);
     try {
         $this->getUser()->signIn($this->user, true);
         /** @var EiNodeTable $tableEiNode */
         $tableEiNode = Doctrine_Core::getTable("EiNode");
         // Récupération du noeud du scénario.
         $node = $this->scenario->getEiNode();
         // Recherche de la structure des fichiers des jeux de données.
         $rootFolder = Doctrine_Core::getTable('EiNode')->findOneByRootIdAndType($node->getId(), 'EiDataSetFolder');
         // On récupère ensuite la structure brute des dossiers.
         $structureBrute = $tableEiNode->getStructureDataSets($rootFolder);
         $structureBrute["root"]["name"] = "Root";
         // Puis on la retravaille.
         //            $structure = $this->getReorderedStructure(array(), $structureBrute);
         $response = json_encode(array("tree" => array($structureBrute)));
     } catch (Exception $e) {
         $response = array();
     }
     return $this->renderText($response);
 }
 /**
  * Surcharge de la méthode save permettant de mettre à jour la table EiNode.
  *
  * @param Doctrine_Connection $conn
  */
 public function save(Doctrine_Connection $conn = null)
 {
     $this->logger = sfContext::getInstance()->getLogger();
     $this->logger->info("----------------------------------------------------------");
     $this->logger->info("---   DEBUT SAUVEGARDE TEMPLATE");
     $isNew = $this->isNew();
     /** @var EiNode $ei_node */
     if ($isNew) {
         if ($this->getEiNode() == null) {
             $ei_node = new EiNode();
             $this->setEiNode($ei_node);
         } else {
             $ei_node = $this->getEiNode();
         }
     }
     parent::save($conn);
     if ($isNew) {
         $ei_node->setType(EiNode::$TYPE_DATASET_TEMPLATE);
         $ei_node->setObjId($this->getId());
         $ei_node->setName($this->getName());
         $ei_node->save($conn);
     } elseif (!$isNew) {
         $ei_node = $this->getEiNode();
         $ei_node->setName($this->getName());
         $ei_node->save($conn);
     }
     $this->updateCampaignGraphDataSet($conn);
     $this->logger->info("----------------------------------------------------------");
     $this->logger->info("---   FIN SAUVEGARDE TEMPLATE");
 }
/**
 * Return the HTML code for an unordered list showing opinions that can be voted (no AJAX)
 * If the user has already voted, then a message appears
 * 
 * @param  BaseObject  $object   Propel object instance to vote
 * @param  string      $message  a message string to be displayed in the voting-message block
 * @param  array       $options  Array of HTML options to apply on the HTML list
 * @return string
 **/
function depp_prioritiser($object, $message = '', $options = array())
{
    if (is_null($object)) {
        sfLogger::getInstance()->debug('A NULL object cannot be prioritised');
        return '';
    }
    $user_id = sfContext::getInstance()->getUser()->getId();
    try {
        $options = _parse_attributes($options);
        if (!isset($options['id'])) {
            $options = array_merge($options, array('id' => 'prioritising-items'));
        }
        $object_id = $object->getPrioritisableReferenceKey();
        $list_content = '';
        $object_priority = is_null($object->getPriorityValue()) ? 1 : $object->getPriorityValue();
        for ($i = $object->allowsNullPriority() ? 0 : 1; $i <= $object->getMaxPriority(); $i++) {
            if ($object_priority == $i) {
                if ($object->getPriorityLastUser() != 0) {
                    $label = sprintf('Priorit&agrave; impostata da user_id:%d il %s alle %s', $object->getPriorityLastUser(), $object->getPriorityLastUpdate('d/m/Y'), $object->getPriorityLastUpdate('h:i'));
                } else {
                    $label = 'Priorit&agrave; di default';
                }
                $list_content .= content_tag('li', content_tag('span', $i, array('title' => $label)), array('class' => 'current'));
            } else {
                $label = sprintf(__('Set priority to %d'), $i);
                $list_content .= content_tag('li', link_to($i, sprintf('deppPrioritising/prioritise?object_id=%d&object_model=%s&priority=%d', $object->getId(), get_class($object), $i), array('title' => $label, 'post' => true)));
            }
        }
        return content_tag('ul', $list_content, $options) . content_tag('div', $message, array('id' => 'priority-message'));
    } catch (Exception $e) {
        sfLogger::getInstance()->err('Exception catched from deppPrioritising helper: ' . $e->getMessage());
    }
}
예제 #4
0
 public static function highlight($raw_body)
 {
     $body = sfMarkdown::doConvert($raw_body);
     $matches = array();
     $langs = array();
     preg_match_all("/<pre><code>\\[(\\w*)\\](\\r?\\n)+(.+)(\\r?\\n)+<\\/code><\\/pre>/isU", $body, $matches, PREG_SET_ORDER);
     if (sizeof($matches) > 0) {
         $service = new SnippetServiceClient();
         $cnt = 1;
         foreach ($matches as $match) {
             sfLogger::getInstance()->info("From myUtils: " . $match[3]);
             $languageLower = $match[1];
             $languageUpper = strtoupper($match[1]);
             sfLogger::getInstance()->info("myUtils languages: {$languageLower} {$languageUpper}" . sizeof(self::$languages));
             if (in_array($languageUpper, self::$languages)) {
                 $highlighted = $service->highlight($languageUpper, htmlspecialchars_decode($match[3]));
                 $highlighted['snippet'] = "<div class=\"code-wrapper\">{$highlighted['snippet']}</div>";
                 $body = str_replace($match[0], $highlighted['snippet'], $body, $cnt);
                 $langs[$languageLower] = $langs[$languageLower] ? $langs[$languageLower] + 1 : 1;
             } else {
                 sfLogger::getInstance()->info("myUtils : {$languageLower} is not supported.");
                 $langs[$languageLower] = $langs[$languageLower] ? $langs[$languageLower] + 1 : 1;
                 $body = str_replace($match[0], "<div class=\"code-wrapper\"><pre><code>{$match[3]}</code></pre></div>", $body, $cnt);
             }
         }
     }
     return array('body' => $body, 'langs' => $langs);
 }
/**
 * Return the HTML code for an unordered list showing opinions that can be voted (no AJAX)
 * If the user has already voted, then a message appears
 * 
 * @param  BaseObject  $object   Propel object instance to vote
 * @param  string      $message  a message string to be displayed in the voting-message block
 * @param  array       $options  Array of HTML options to apply on the HTML list
 * @return string
 **/
function depp_omnibus_selector($object, $message = '', $options = array())
{
    if (is_null($object)) {
        sfLogger::getInstance()->debug('A NULL object cannot be flagged as Omnibus');
        return '';
    }
    $user_id = sfContext::getInstance()->getUser()->getId();
    try {
        $options = _parse_attributes($options);
        if (!isset($options['id'])) {
            $options = array_merge($options, array('id' => 'omnibus-flag'));
        }
        $object_is_omnibus = $object->getIsOmnibus();
        $object_will_be_omnibus = !$object_is_omnibus;
        $selector = '';
        if ($object_is_omnibus) {
            $status = "Questo atto &egrave; Omnibus";
            $label = "Marcalo come non-Omnibus";
        } else {
            $status = "Questo atto non &egrave; Omnibus";
            $label = "Marcalo come Omnibus";
        }
        $selector .= link_to($label, sprintf('atto/setOmnibusStatus?id=%d&status=%d', $object->getId(), $object_will_be_omnibus), array('post' => true));
        return content_tag('div', $status) . content_tag('div', $selector, $options);
    } catch (Exception $e) {
        sfLogger::getInstance()->err('Exception catched from deppOmnibus helper: ' . $e->getMessage());
    }
}
 /**
  * <p>Vote a propel object, un-ajax style</p>
  * 
  * @see  deppPropelActAsVotableBehavior API
  */
 public function executePrioritise()
 {
     try {
         if ($this->getRequest()->getMethod() !== sfRequest::POST) {
             $this->setError($this->messages['post_only']);
         }
         // Retrieve parameters from request
         $object_id = $this->getRequestParameter('object_id');
         $object_model = $this->getRequestParameter('object_model');
         $priority = $this->getRequestParameter('priority');
         // Retrieve ratable propel object
         if (is_null($priority) || is_null($object_id) || is_null($object_model)) {
             $this->setError($this->messages['missing_params']);
         }
         $object = deppPropelActAsPrioritisableBehaviorToolkit::retrievePrioritisableObject($object_model, $object_id);
         if (is_null($object)) {
             $this->setError($this->message['prioritisable_error']);
         }
         // User retrieval
         $user_id = sfContext::getInstance()->getUser()->getId();
         if (!$object->allowsNullPriority() && $priority == 0) {
             $msg = $this->messages['null_not_allowed'];
             sfLogger::getInstance()->warning($msg);
             $this->setError($msg);
         } else {
             $object->setPriorityValue((int) $priority, $user_id);
             $message = $this->messages['thank_you'];
         }
         $this->setFlash('depp_prioritising_message', $message);
         $this->redirect($this->getRequest()->getReferer());
     } catch (Exception $e) {
         $this->setError($e->getMessage());
     }
 }
 public function initialize(sfEventDispatcher $dispatcher, $options = array())
 {
     parent::initialize($dispatcher, $options);
     $ops = array_merge($this->defaults, $options);
     $this->r = new Redis($ops['host'], $ops['port']);
     $this->maxlogs = $ops['maxlogs'];
 }
 /**
  * Converts the log priority into its string representation.
  *
  * @param sfEvent $event
  * @param array $logEntry
  *
  * @return array
  */
 public static function convertLogPriority(sfEvent $event, array $logEntry)
 {
     if (is_int($logEntry['priority'])) {
         $logEntry['priority'] = sfLogger::getPriorityName($logEntry['priority']);
     }
     return $logEntry;
 }
 public function execute($filterChain)
 {
     $filterChain->execute();
     $response = $this->getContext()->getResponse();
     $request = $this->getContext()->getRequest();
     $controller = $this->getContext()->getController();
     // don't highlight:
     // * for XHR requests
     // * if 304
     // * if not rendering to the client
     // * if HTTP headers only
     if ($request->isXmlHttpRequest() || strpos($response->getContentType(), 'html') === false || $response->getStatusCode() == 304 || $controller->getRenderMode() != sfView::RENDER_CLIENT || $response->isHeaderOnly()) {
         return;
     }
     $timer = sfTimerManager::getTimer('Highlight Filter');
     try {
         if (!$this->highlight()) {
             $this->removeNotice();
         }
     } catch (sfSolrHighlighterException $e) {
         sfLogger::getInstance()->err('{sfSolrHighlightFilter} silently ignoring exception: ' . $e->getMessage());
         if ($this->testMode) {
             $timer->addTime();
             throw $e;
         }
     } catch (Exception $e) {
         $timer->addTime();
         throw $e;
     }
     $timer->addTime();
 }
예제 #10
0
 /**
  * @param Doctrine_Connection $conn
  */
 public function save(Doctrine_Connection $conn = null)
 {
     $this->logger = sfContext::getInstance()->getLogger();
     $this->logger->info("----------------------------------------------------------");
     $this->logger->info("---   DEBUT SAUVEGARDE DATA SET");
     $isNew = $this->isNew();
     if ($isNew) {
         if ($this->getEiNode() == null) {
             $ei_node = new EiNode();
             $this->setEiNode($ei_node);
         } else {
             $ei_node = $this->getEiNode();
         }
     }
     parent::save($conn);
     if ($isNew) {
         $ei_node->setType('EiDataSet');
         $ei_node->setObjId($this->getId());
         $ei_node->setName($this->getName());
         if ($this->getEiDataSetTemplate() != null) {
             $ei_node->setRootId($this->getEiDataSetTemplate()->getEiNode()->getId());
         }
         $ei_node->save($conn);
     } else {
         $ei_node = $this->getEiNode();
         $ei_node->setName($this->getName());
         $ei_node->save($conn);
     }
     $this->logger->info("----------------------------------------------------------");
     $this->logger->info("---   FIN SAUVEGARDE DATA SET");
 }
예제 #11
0
 public function initialize(sfEventDispatcher $dispatcher, $options = array())
 {
     if (isset($options['ident'])) {
         $this->ident = $options['ident'];
     }
     openlog($this->ident, LOG_PID | LOG_PERROR, LOG_KERN);
     return parent::initialize($dispatcher, $options);
 }
 /**
  * uses information in the $xml_user SimpleXML object to give attributes and permissions to the user
  * also sets remember or sso cookie, depending on the value of the $remember parameter
  *
  * @param $xml_user - SimpleXMLObject
  * @param $cookie - boolean
  * @return void
  * @author Guglielmo Celata
  **/
 public function signIn($xml_user, $cookie = 'none')
 {
     // legge i permission dall'xml user
     $permissions = array();
     foreach ($xml_user->permissions->permission as $perm) {
         $permissions[] = $perm;
     }
     $this->setAttribute('subscriber_id', (string) $xml_user->subscriber_id, 'subscriber');
     $this->setAuthenticated(true);
     $expiration_age = sfConfig::get('app_cookies_remember_key_expiration_age', 15 * 24 * 3600);
     $cookie_remember_name = sfConfig::get('app_cookies_remember_name', 'sfRemember');
     $cookie_sso_name = sfConfig::get('app_cookies_sso_name', 'sfSSO');
     $cookie_path = sfConfig::get('app_cookies_path', '/');
     $cookie_domain = sfConfig::get('app_cookies_domain', 'sfDomain.it');
     // if cookie argument was set to 'remember' or 'session' a cookie is set
     // this MUST only happen with signin invoked from validator (form)
     sfContext::getInstance()->getLogger()->info('xxx - signIn - cookie: ' . $cookie);
     if ($cookie == 'remember') {
         //save the key to the remember cookie
         sfContext::getInstance()->getLogger()->info('xxx - setting remember cookie: ' . (string) $xml_user->remember_key);
         sfContext::getInstance()->getResponse()->setCookie($cookie_remember_name, (string) $xml_user->remember_key, time() + $expiration_age, $cookie_path, $cookie_domain);
     } elseif ($cookie == 'session') {
         // save the hash to the sso cookie
         sfContext::getInstance()->getLogger()->info('xxx - setting sso cookie: ' . (string) $xml_user->remember_key);
         sfContext::getInstance()->getResponse()->setCookie($cookie_sso_name, (string) $xml_user->remember_key, 0, $cookie_path, $cookie_domain);
     }
     $this->addCredential('subscriber');
     if (in_array('moderatore', $permissions)) {
         $this->addCredential('moderator');
     }
     if (in_array('amministratore', $permissions)) {
         $this->addCredential('moderator');
         $this->addCredential('administrator');
     }
     // add all credentials from groups and direct permissions
     foreach ($permissions as $perm) {
         $this->addCredential((string) $perm);
     }
     $this->setAttribute('name', (string) $xml_user->name, 'subscriber');
     $this->setAttribute('firstname', (string) $xml_user->firstname, 'subscriber');
     $this->setAttribute('hash', (string) $xml_user->hash, 'subscriber');
     // read the last_login ts from the xml (it comes from the DB)
     $this->setAttribute('last_login', (string) $xml_user->last_login, 'subscriber');
     // store the new last_login ts (now) in the DB
     $remote_guard_host = sfConfig::get('sf_remote_guard_host', 'op_accesso.openpolis.it');
     $script = str_replace('fe', 'be', sfContext::getInstance()->getRequest()->getScriptName());
     if ($script == '/be.php') {
         $script = '/index.php';
     }
     $apikey = sfConfig::get('sf_internal_api_key', 'xxx');
     $last_login_url = sprintf("http://%s%s/setLastLogin/%s/%s/%s", $remote_guard_host, $script, $apikey, (string) $xml_user->hash, urlencode(date('Y-m-d H:i:s')));
     sfLogger::getInstance()->info('xxx: last_login_call: ' . $last_login_url);
     $xml = simplexml_load_file($last_login_url);
     if (!$xml->ok instanceof SimpleXMLElement) {
         sfLogger::getInstance()->info('xxx: error while setting last login: %s' . (string) $xml->error);
     }
 }
예제 #13
0
 /**
  * Initializes this logger.
  *
  * Available options:
  *
  * - xdebug_logging: Whether to add xdebug trace to the logs (false by default).
  *
  * @param  sfEventDispatcher $dispatcher  A sfEventDispatcher instance
  * @param  array             $options     An array of options.
  *
  * @return Boolean           true, if initialization completes successfully, otherwise false.
  */
 public function initialize(sfEventDispatcher $dispatcher, $options = array())
 {
     $this->xdebugLogging = isset($options['xdebug_logging']) ? $options['xdebug_logging'] : false;
     // disable xdebug when an HTTP debug session exists (crashes Apache, see #2438)
     if (isset($_GET['XDEBUG_SESSION_START']) || isset($_COOKIE['XDEBUG_SESSION'])) {
         $this->xdebugLogging = false;
     }
     return parent::initialize($dispatcher, $options);
 }
예제 #14
0
 public function getPreference($preference)
 {
     if ($item = $this->getAttribute("app_preference_{$preference}")) {
         return $item;
     }
     $item = sfConfig::get("app_preference_{$preference}");
     sfLogger::getInstance()->info("Sending default preference for app_preference_{$preference}={$item}");
     return $item;
 }
예제 #15
0
 /**
  * Initializes this logger.
  *
  * Available options:
  *
  * - logger_service_id: The service id to use as the logger. Default: logger.psr
  * - auto_connect: If we must connect automatically to the context.load_factories to set the logger. Default: true
  *
  * @param sfEventDispatcher $dispatcher
  * @param array $options
  *
  * @return void
  */
 public function initialize(sfEventDispatcher $dispatcher, $options = array())
 {
     if (isset($options['logger_service_id'])) {
         $this->loggerServiceId = $options['logger_service_id'];
     }
     if (!isset($options['auto_connect']) || $options['auto_connect']) {
         $dispatcher->connect('context.load_factories', array($this, 'listenContextLoadFactoriesEvent'));
     }
     parent::initialize($dispatcher, $options);
 }
 /**
  * Action permettant de récupérer l'arbre des jeux de données.
  *
  * @param sfWebRequest $request
  */
 public function execute($request)
 {
     $this->logger = sfContext::getInstance()->getLogger();
     $this->logger->info("----------------------------------------------------------");
     $this->logger->info("---   DEBUT RECUPERATION ARBRE DATA SET");
     $this->getResponse()->setContentType('application/json');
     $this->setLayout(false);
     $response = array("error" => "An error occured when we try to create your directory.");
     try {
         $this->getUser()->signIn($this->user, true);
         /** @var EiNodeTable $tableEiNode */
         $tableEiNode = Doctrine_Core::getTable("EiNode");
         // Récupération des données.
         $nom = $request->getPostParameter("name");
         $parentNodeId = $request->getPostParameter("parent_node_id");
         if ($nom == null || $parentNodeId == null) {
             $response["error"] = "You have to select a parent directory and type a valid directory name";
         } else {
             /** @var EiNode $parentNode Récupération du noeud parent. */
             $parentNode = $tableEiNode->find($parentNodeId);
             if ($parentNode != null && $parentNode->getId() != "" && $parentNode->getEiScenarioNode()->getObjId() == $this->scenario->getId()) {
                 try {
                     $folder = new EiNode();
                     $folder->setName($nom);
                     $folder->setType(EiNode::$TYPE_DATASET_FOLDER);
                     $folder->setProjectId($parentNode->getProjectId());
                     $folder->setProjectRef($parentNode->getProjectRef());
                     $folder->setRootId($parentNode->getId());
                     $folder->save();
                     unset($response["error"]);
                     $response["id"] = $folder->getId();
                 } catch (Exception $exc) {
                     $response["error"] = "An error occured when we tried to create directory : " . $exc->getMessage();
                 }
             } else {
                 $response["error"] = "We are not able to accommodate your request.";
             }
         }
     } catch (Exception $e) {
         $response = array();
     }
     return $this->renderText(json_encode($response));
 }
예제 #17
0
 /**
  * Returns the sfLogger instance.
  *
  * @return  object the sfLogger instance
  */
 public static function getInstance()
 {
     if (!sfLogger::$logger) {
         // the class exists
         $class = __CLASS__;
         sfLogger::$logger = new $class();
         sfLogger::$logger->initialize();
     }
     return sfLogger::$logger;
 }
예제 #18
0
 /**
  * Class constructor.
  *
  * @param string The error message
  * @param int    The error code
  */
 public function __construct($message = null, $code = 0)
 {
     if ($this->getName() === null) {
         $this->setName('sfException');
     }
     parent::__construct($message, $code);
     if (sfConfig::get('sf_logging_enabled') && $this->getName() != 'sfStopException') {
         sfLogger::getInstance()->err('{' . $this->getName() . '} ' . $message);
     }
 }
 /**
  * Méthode permettant de synchroniser les valeurs des paramètres du block dans le jeu de données du JDT.
  */
 public function synchronizeWithDataSet()
 {
     $this->logger = sfContext::getInstance()->getLogger();
     /** @var EiTestSetBlockParam[] $childs */
     $childs = $this->getNode()->getDescendants(1);
     $this->logger->info("----------------------------------------------------------");
     $this->logger->info("---   Parcours des " . count($childs) . " enfants.");
     if ($childs != null && (is_array($childs) || $childs instanceof Doctrine_Collection)) {
         // Parcourt des enfants du block.
         foreach ($childs as $child) {
             $this->logger->info("----------------------------------------------------------");
             $this->logger->info("---   Parcours de " . $child->getName() . ".");
             // On traite uniquement les paramètres à synchroniser.
             if ($child->getType() == EiVersionStructure::$TYPE_BLOCK_PARAM) {
                 // On récupère les éléments mappés avec le paramètre.
                 /** @var EiBlockDataSetMapping[] $mappings */
                 $mappings = $child->getEiVersionStructure()->getEiVersionStructureDataSetMapping();
                 if ($mappings->count() > 0) {
                     $this->logger->info("----------------------------------------------------------");
                     $this->logger->info("---   Mapping détecté.");
                     /** @var EiBlockDataSetMapping $mapping */
                     foreach ($mappings as $mapping) {
                         // On s'intéresse uniquement au cas où une synchronisation OUT a été définie.
                         // Si tel est le cas, on récupère l'élément du jeu de données du JDT correspondant.
                         if ($mapping->getType() == EiBlockDataSetMapping::$TYPE_OUT) {
                             $structure = $this->getEiVersionStructure();
                             $mappingDs = $mapping->getEiDataSetStructureMapping();
                             $isForeach = $structure->getType() == EiVersionStructure::$TYPE_FOREACH;
                             $this->logger->info("----------------------------------------------------------");
                             $this->logger->info("---   Mapping out détecté avec " . $mappingDs . " dans Foreach ? " . ($isForeach ? "Oui" : "Non") . ".");
                             if ($isForeach && !$mappingDs->getNode()->isDescendantOf($structure->getIteratorMapping()->getEiDataSetStructureMapping())) {
                                 /** @var EiTestSetDataSet $dataSetElement */
                                 $dataSetElement = EiTestSetDataSetTable::getInstance()->findOneByEiDataSetStructureIdAndIndexRepetitionAndEiTestSetId($mapping->getEiDatasetStructureId(), 1, $this->getEiTestSetId());
                             } else {
                                 /** @var EiTestSetDataSet $dataSetElement */
                                 $dataSetElement = EiTestSetDataSetTable::getInstance()->findOneByEiDataSetStructureIdAndParentIndexRepetitionAndEiTestSetId($mapping->getEiDatasetStructureId(), $this->getIndexRepetition(), $this->getEiTestSetId());
                             }
                             if ($dataSetElement != null) {
                                 sfContext::getInstance()->getLogger()->info("----------------------------------------------------------");
                                 sfContext::getInstance()->getLogger()->info("---   MATCHED SYNC WITH VALUE " . $child->getValue());
                                 // Puis, on le met à jour avec la valeur du paramètre du block.
                                 $dataSetElement->setValue($child->getValue());
                                 $dataSetElement->setIsModified(true);
                                 $dataSetElement->save();
                             }
                         }
                     }
                 } else {
                     $this->logger->info("----------------------------------------------------------");
                     $this->logger->info("---   Pas de mapping détecté.");
                 }
             }
         }
     }
 }
예제 #20
0
 private static function getLogger()
 {
     if (!self::$logger) {
         if (class_exists('sfLogger')) {
             self::$logger = sfLogger::getInstance();
         } else {
             self::$logger = KalturaLog::getInstance();
         }
     }
     return self::$logger;
 }
예제 #21
0
 /**
  * Initializes this logger.
  *
  * Available options:
  *
  * - loggers: Logger objects that extends sfLogger.
  *
  * @param  sfEventDispatcher $dispatcher  A sfEventDispatcher instance
  * @param  array             $options     An array of options.
  *
  * @return Boolean      true, if initialization completes successfully, otherwise false.
  */
 public function initialize(sfEventDispatcher $dispatcher, $options = array())
 {
     $this->dispatcher = $dispatcher;
     if (isset($options['loggers'])) {
         if (!is_array($options['loggers'])) {
             $options['loggers'] = array($options['loggers']);
         }
         $this->addLoggers($options['loggers']);
     }
     return parent::initialize($dispatcher, $options);
 }
예제 #22
0
 public function save($conn = null)
 {
     $this->logger = sfContext::getInstance()->getLogger();
     $this->logger->info("----------------------------------------------------------");
     $this->logger->info("---   SAVE DATA SET FORM");
     parent::save($conn);
     if ($this->isNew()) {
         $file = $this->getValue('file');
         if ($file != null) {
             $filename = 'uploaded_' . sha1($file->getOriginalName());
             $extension = $file->getExtension($file->getOriginalExtension());
             $fullName = sfConfig::get('sf_upload_dir') . '/' . $filename . $extension;
             $file->save($fullName);
             $this->getObject()->createDataLines($fullName);
             unlink($fullName);
         } else {
             $this->getObject()->createEmptyDataLines($conn, false);
         }
     }
 }
예제 #23
0
 /**
  * @param $campagneId
  * @param $positionId
  * @param $ei_log_st
  * @param $execution_id
  * @param EiLog $ei_log
  * @return EiCampaignGraph|null
  */
 private function searchAndUpdateCampaignGraphState($campagneId, $positionId, $ei_log_st, $execution_id, $ei_log = null)
 {
     $campagneGraph = null;
     /** @var EiTestSetTable $tableEiTestSet */
     $tableEiTestSet = Doctrine_Core::getTable("EiTestSet");
     /** @var EiCampaignExecutionGraph $executionGraph */
     $executionGraph = $execution_id != null ? Doctrine_Core::getTable("EiCampaignExecutionGraph")->findOneByExecutionIdAndGraphId($execution_id, $positionId) : null;
     // Si les deux ne sont pas nuls, on tente une mise à jour du statut.
     if ($campagneId !== null && $positionId !== null) {
         /** @var EiCampaignGraph $campagneGraph */
         $campagneGraph = Doctrine_Core::getTable("EiCampaignGraph")->getCampaignGraphStep($positionId);
         // Si une exécution est spécifiée, on met à jour l'élément de l'exécution.
         if ($executionGraph !== null || is_bool($executionGraph) && $executionGraph == true) {
             $graph = $executionGraph;
             $campagneIdG = $graph->getEiCampaignGraph()->getCampaignId();
         } else {
             $graph = $campagneGraph;
             $campagneIdG = $graph->getCampaignId();
         }
         if ($graph != null && $campagneIdG == intval($campagneId)) {
             // Mise à jour du statut en fonction des résultats des logs.
             if ($ei_log_st == null && $graph->getEiTestSetId() != "") {
                 $this->logger->info("----------------------------------------------------------");
                 $this->logger->info("---   CASE ST NULL & TEST SET NOT NULL");
                 $ts = $tableEiTestSet->findTestSet($graph->getEiTestSetId());
                 $ei_log_st = $ts->getStatusName() == StatusConst::STATUS_TEST_OK_DB ? StatusConst::STATUS_OK_DB : ($ts->getStatusName() == StatusConst::STATUS_TEST_KO_DB ? StatusConst::STATUS_KO_DB : StatusConst::STATUS_NA_DB);
                 $this->logger->info("---   EI LOG ST : " . $ei_log_st . " / " . $ts->getStatusName());
                 $this->logger->info("----------------------------------------------------------");
             }
             if ($ei_log_st != null && $ei_log_st == StatusConst::STATUS_OK_DB) {
                 $graph->setState(sfConfig::get("app_campaigngraphstateok"));
             } elseif ($ei_log_st != null && $ei_log_st == StatusConst::STATUS_KO_DB) {
                 $graph->setState(sfConfig::get("app_campaigngraphstateko"));
             } elseif ($ei_log_st != null && $ei_log_st == StatusConst::STATUS_PROCESSING_DB) {
                 $graph->setState(sfConfig::get("app_campaigngraphstateprocessing"));
             } elseif ($ei_log_st != null && $ei_log_st == StatusConst::STATUS_NA_DB) {
                 $graph->setState(sfConfig::get("app_campaigngraphstateaborted"));
             } else {
                 $graph->setState(sfConfig::get("app_campaigngraphstateblank"));
             }
             if ($ei_log != null) {
                 $graph->setEiTestSetId($ei_log->getEiTestSetId());
                 // Mise à jour du mode du JDT si <> Campagne
                 if ($ei_log->getEiTestSet()->getMode() != EiTestSetModeConst::MODE_CAMPAGNE) {
                     $ei_log->getEiTestSet()->setMode(EiTestSetModeConst::MODE_CAMPAGNE);
                     $ei_log->getEiTestSet()->save();
                 }
             }
             $graph->save();
         }
     }
     return $campagneGraph;
 }
 /**
  * Initializes this logger.
  *
  * Available options:
  *
  * - stream: A PHP stream
  *
  * @param  sfEventDispatcher $dispatcher  A sfEventDispatcher instance
  * @param  array             $options     An array of options.
  *
  * @return Boolean      true, if initialization completes successfully, otherwise false.
  */
 public function initialize(sfEventDispatcher $dispatcher, $options = array())
 {
     if (!isset($options['stream'])) {
         throw new sfConfigurationException('You must provide a "stream" option for this logger.');
     } else {
         if (is_resource($options['stream']) && 'stream' != get_resource_type($options['stream'])) {
             throw new sfConfigurationException('The provided "stream" option is not a stream.');
         }
     }
     $this->stream = $options['stream'];
     return parent::initialize($dispatcher, $options);
 }
 /**
  * Action permettant de récupérer l'arbre des jeux de données.
  *
  * @param sfWebRequest $request
  */
 public function execute($request)
 {
     $this->logger = sfContext::getInstance()->getLogger();
     $this->logger->info("----------------------------------------------------------");
     $this->logger->info("---   DEBUT RECUPERATION ARBRE DATA SET");
     $this->getResponse()->setContentType('application/json');
     $this->setLayout(false);
     $response = array("error" => "An error occured when we try to delete your directory.");
     try {
         $this->getUser()->signIn($this->user, true);
         /** @var EiNodeTable $tableEiNode */
         $tableEiNode = Doctrine_Core::getTable("EiNode");
         // Récupération des données.
         $nodeId = $request->getPostParameter("node_id");
         if ($nodeId == null) {
             $response["error"] = "You have to select a directory";
         } else {
             /** @var EiNode $node Récupération du noeud à modifier. */
             $node = $tableEiNode->find($nodeId);
             if ($node != null && $node->getId() != "" && $node->getEiScenarioNode()->getObjId() == $this->scenario->getId()) {
                 try {
                     if ($node->getNodes(true, true, true)->count() == 0) {
                         unset($response["error"]);
                         $node->delete();
                         $response["status"] = "OK";
                     } else {
                         $response["error"] = "We are not able to accommodate your request because the directory is not empty.";
                     }
                 } catch (Exception $exc) {
                     $response["error"] = "An error occured when we tried to delete directory : " . $exc->getMessage();
                 }
             } else {
                 $response["error"] = "We are not able to accommodate your request.";
             }
         }
     } catch (Exception $e) {
         $response = array();
     }
     return $this->renderText(json_encode($response));
 }
 /**
  * Initializes the cache.
  *
  * @param array An array of options
  * Available options:
  *  - database:                database name
  *  - automaticCleaningFactor: disable / tune automatic cleaning process (int)
  *
  */
 public function initialize($options = array())
 {
     if (isset($options['database'])) {
         $this->setDatabase($options['database']);
         unset($options['database']);
     }
     $availableOptions = array('automaticCleaningFactor');
     foreach ($options as $key => $value) {
         if (!in_array($key, $availableOptions) && sfConfig::get('sf_logging_enabled')) {
             sfLogger::getInstance()->err(sprintf('sfSQLiteCache cannot take "%s" as an option', $key));
         }
         $this->{$key} = $value;
     }
 }
 /**
  * @param null $con
  * @param null $forms
  */
 public function saveEmbeddedForms($con = null, $forms = null)
 {
     $this->logger = sfContext::getInstance()->getLogger();
     $this->logger->info("----------------------------------------------------------");
     $this->logger->info("---   SAVE EMBEDDED TEMPLATE FORM");
     if ($this->isNew()) {
         foreach ($this->embeddedForms as $name => $form) {
             /** @var EiDataSet $object */
             $object = $form->getObject();
             /** @var EiDataSetTemplate $template */
             $template = $this->getObject();
             $object->setEiDataSetTemplate($this->getObject());
             $object->setName($template->getName());
             $node = $object->getEiNode();
             $node->setProjectId($template->getEiNode()->getProjectId());
             $node->setProjectRef($template->getEiNode()->getProjectRef());
             $object->setRootStr($template->getRootStr());
             $form->save($con);
             $template->setEiDataSet($object);
             $template->save($con);
         }
     }
     return parent::saveEmbeddedForms($con, $forms);
 }
예제 #28
0
 /**
  * Initializes this logger.
  *
  * @param  sfEventDispatcher $dispatcher  A sfEventDispatcher instance
  * @param  array             $options     An array of options.
  *
  * @return Boolean      true, if initialization completes successfully, otherwise false.
  */
 public function initialize(sfEventDispatcher $dispatcher, $options = array())
 {
     $this->context = sfContext::getInstance();
     $this->dispatcher = $dispatcher;
     $class = isset($options['web_debug_class']) ? $options['web_debug_class'] : 'sfWebDebug';
     $this->webDebug = new $class($dispatcher);
     $dispatcher->connect('response.filter_content', array($this, 'filterResponseContent'));
     if (isset($options['xdebug_logging'])) {
         $this->xdebugLogging = $options['xdebug_logging'];
     }
     // disable xdebug when an HTTP debug session exists (crashes Apache, see #2438)
     if (isset($_GET['XDEBUG_SESSION_START']) || isset($_COOKIE['XDEBUG_SESSION'])) {
         $this->xdebugLogging = false;
     }
     return parent::initialize($dispatcher, $options);
 }
/**
 * Return the HTML code for an unordered list showing opinions that can be voted
 * If the user has already voted, then a message appears
 * 
 * @param  BaseObject  $object   Propel object instance to vote
 * @param  string      $domid    unique css identifier for the block (div) containing the voter tool
 * @param  string      $message  a message string to be displayed in the voting-message block
 * @param  array       $options  Array of HTML options to apply on the HTML list
 * @return string
 **/
function depp_voter($object, $domid = 'depp-voter-block', $message = '', $options = array())
{
    if (is_null($object)) {
        sfLogger::getInstance()->debug('A NULL object cannot be voted');
        return '';
    }
    $user_id = deppPropelActAsVotableBehaviorToolkit::getUserId();
    // anonymous votes
    if ((is_null($user_id) || $user_id == '') && !$object->allowsAnonymousVoting()) {
        return __('Anonymous voting is not allowed') . ", " . __('please') . " " . link_to('login', '/login');
    }
    try {
        $voting_range = $object->getVotingRange();
        $options = _parse_attributes($options);
        if (!isset($options['id'])) {
            $options = array_merge($options, array('id' => 'voting-items'));
        }
        if ($object instanceof sfOutputEscaperObjectDecorator) {
            $object_class = get_class($object->getRawValue());
        } else {
            $object_class = get_class($object);
        }
        $object_id = $object->getReferenceKey();
        $token = deppPropelActAsVotableBehaviorToolkit::addTokenToSession($object_class, $object_id);
        // already voted
        if ($object->hasBeenVotedByUser($user_id)) {
            $message .= "&nbsp;" . link_to_remote(__('Take your vote back'), array('url' => sprintf('deppVoting/unvote?domid=%s&token=%s', $domid, $token), 'update' => $domid, 'script' => true, 'complete' => visual_effect('appear', $domid) . visual_effect('highlight', $domid)));
        }
        $list_content = '';
        for ($i = -1 * $voting_range; $i <= $voting_range; $i++) {
            if ($i == 0 && !$object->allowsNeutralPosition()) {
                continue;
            }
            $text = sprintf("[%d]", $i);
            $label = sprintf(__('Vote %d!'), $i);
            if ($object->hasBeenVotedByUser($user_id) && $object->getUserVoting($user_id) == $i) {
                $list_content .= content_tag('li', $text);
            } else {
                $list_content .= '  <li>' . link_to_remote($text, array('url' => sprintf('deppVoting/vote?domid=%s&token=%s&voting=%d', $domid, $token, $i), 'update' => $domid, 'script' => true, 'complete' => visual_effect('appear', $domid) . visual_effect('highlight', $domid)), array('title' => $label)) . '</li>';
            }
        }
        $results = get_component('deppVoting', 'votingDetails', array('object' => $object));
        return content_tag('ul', $list_content, $options) . content_tag('div', $message, array('id' => 'voting-message')) . content_tag('div', $results, array('id' => 'voting-results'));
    } catch (Exception $e) {
        sfLogger::getInstance()->err('Exception catched from sf_rater helper: ' . $e->getMessage());
    }
}
 protected function initialize()
 {
     $this->logger = sfLogger::getInstance();
     if (sfConfig::get('sf_logging_enabled')) {
         $this->logger->info('{sfContext} initialization');
     }
     if (sfConfig::get('sf_use_database')) {
         // setup our database connections
         $this->databaseManager = new sfDatabaseManager();
         $this->databaseManager->initialize();
     }
     // create a new action stack
     $this->actionStack = new sfActionStack();
     // include the factories configuration
     require sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_config_dir_name') . '/factories.yml');
     // register our shutdown function
     register_shutdown_function(array($this, 'shutdown'));
 }