示例#1
0
 public function saveUniversList($con = null)
 {
     if (!$this->isValid()) {
         throw $this->getErrorSchema();
     }
     if (!isset($this->widgetSchema['univers_list'])) {
         // somebody has unset this widget
         return;
     }
     if (null === $con) {
         $con = $this->getConnection();
     }
     $existing = $this->object->Univers->getPrimaryKeys();
     $values = $this->getValue('univers_list');
     if (!is_array($values)) {
         $values = array();
     }
     $unlink = array_diff($existing, $values);
     if (count($unlink)) {
         $this->object->unlink('Univers', array_values($unlink));
         // trace for synchro
         $delete_log = new DeleteLog();
         $delete_log->setGuid(Guid::generate());
         $delete_log->setExtra('medaille_id: "' . $this->getObject()->getGuid() . '"|univers_id: "' . implode('", "', array_values($unlink)) . '"');
         $delete_log->setModelName('UniversMedaille');
         $delete_log->save();
     }
     $link = array_diff($values, $existing);
     if (count($link)) {
         $this->object->link('Univers', array_values($link));
     }
 }
 public function configure()
 {
     $this->setValidator('guid', new sfValidatorString(array('max_length' => 255, 'required' => false)));
     $this->setDefault('guid', Guid::generate());
     $this->setWidget('visiteur_id', new sfWidgetFormInputText());
     unset($this['updated_at'], $this['created_at']);
 }
 public function saveLangueList($con = null)
 {
     if (!$this->isValid()) {
         throw $this->getErrorSchema();
     }
     if (!isset($this->widgetSchema['langue_list'])) {
         // somebody has unset this widget
         return;
     }
     if (null === $con) {
         $con = $this->getConnection();
     }
     $existing = $this->object->Langue->getPrimaryKeys();
     $values = $this->getValue('langue_list');
     if (!is_array($values)) {
         $values = array();
     }
     $unlink = array_diff($existing, $values);
     if (count($unlink)) {
         $this->object->unlink('Langue', array_values($unlink));
         $delete_log = new DeleteLog();
         $delete_log->setGuid(Guid::generate());
         $delete_log->setExtra('exposition_visiteurneeds_id: "' . $this->getObject()->getGuid() . '"|langue_id: "' . implode('", "', array_values($unlink)) . '"');
         $delete_log->setModelName('LangueExpositionVisiteurNeeds');
         $delete_log->save();
     }
     $link = array_diff($values, $existing);
     if (count($link)) {
         $this->object->link('Langue', array_values($link));
     }
 }
示例#4
0
 protected function doSave()
 {
     $this->object->setGuid(Guid::generate());
     $this->object->save();
     $this->output = $this->getSerializer()->serialize($this->object->getGuid());
     return sfView::SUCCESS;
 }
示例#5
0
 public function configure()
 {
     $this->setValidator('guid', new sfValidatorString(array('max_length' => 255, 'required' => false)));
     $this->setDefault('guid', Guid::generate());
     $this->setWidget('visiteur_id', new sfWidgetFormInputText());
     $this->getWidget('typologie_id')->setOption('order_by', array('libelle', 'asc'));
     unset($this['updated_at'], $this['created_at']);
 }
 public function __call($method, $arguments)
 {
     if ($method == 'setGuid') {
         return $this->set('guid', Guid::generate());
     } else {
         return parent::__call($method, $arguments);
     }
 }
示例#7
0
 public function save(Doctrine_Connection $conn = null)
 {
     if (empty($this->guid)) {
         $this->set('guid', Guid::generate());
     }
     $this->setIsTosync(1);
     parent::save($conn);
 }
 public function configure()
 {
     $this->validatorSchema->setOption('allow_extra_fields', true);
     //$this->validatorSchema->setOption('filter_extra_fields', false);
     $this->setValidator('guid', new sfValidatorString(array('max_length' => 255, 'required' => false)));
     $this->setDefault('guid', Guid::generate());
     unset($this['updated_at'], $this['created_at'], $this['is_tosync']);
     $this->widgetSchema['contexte_creation_id'] = new sfWidgetFormDoctrineChoice(array('model' => "Contexte", 'add_empty' => false));
     $this->validatorSchema['contexte_creation_id'] = new sfValidatorDoctrineChoice(array('model' => "Contexte", 'required' => false));
 }
示例#9
0
 public static function createXp($typologie_id, $visiteur_id, $score)
 {
     $xp = new Xp();
     $xp->setGuid(Guid::generate());
     $xp->setTypologieId($typologie_id);
     $xp->setScore($score);
     $xp->setVisiteurId($visiteur_id);
     $xp->save();
     return $xp->getGuid();
 }
 public static function createVisiteurMedaille($visiteur_id, $medaille_id, $univers_id, $contexte_id)
 {
     $new_visiteur_medaille = new VisiteurMedaille();
     $new_visiteur_medaille->setGuid(Guid::generate());
     $new_visiteur_medaille->setVisiteurId($visiteur_id);
     $new_visiteur_medaille->setUniversId($univers_id);
     $new_visiteur_medaille->setMedailleId($medaille_id);
     $new_visiteur_medaille->setContexteId($contexte_id);
     $new_visiteur_medaille->save();
     return $new_visiteur_medaille->getGuid();
 }
示例#11
0
 public function executeCopy(sfWebRequest $request)
 {
     $parcours = $this->getRoute()->getObject();
     $interactifs = $parcours->Interactif->getPrimaryKeys();
     $parcours_copy = $parcours->copy();
     $parcours_copy->setGuid(Guid::generate());
     $parcours_copy->setLibelle($parcours->getLibelle() . "-copie");
     $parcours_copy->setCreatedAt(date('Y-m-d H:i:s'));
     $parcours_copy->setUpdatedAt(date('Y-m-d H:i:s'));
     $parcours_copy->link('Interactif', array_values($interactifs));
     $parcours_copy->save();
     return $this->redirect($this->getController()->genUrl('parcours/edit?guid=' . $parcours_copy->getGuid()));
 }
示例#12
0
 public function configure()
 {
     $this->setValidator('guid', new sfValidatorString(array('max_length' => 255, 'required' => false)));
     $this->setDefault('guid', Guid::generate());
     $this->getWidget('flotte_id')->setOption('order_by', array('libelle', 'asc'));
     //$this->setWidget('start_at',new sfWidgetFormI18nDateTime(array('culture' => 'fr')));
     $this->setWidget('interactif_id', new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Interactif'), 'add_empty' => false, 'order_by' => array('libelle', 'asc'))));
     ///^[0-9]+$/
     //$this->validatorSchema['adresse_mac'] = new sfValidatorRegex(array('pattern' => '/^([0-9A-F]{2}[:-]){5}([0-9A-F]{2})$/'));
     $this->validatorSchema['adresse_mac'] = new sfValidatorString(array('required' => true));
     $this->validatorSchema['adresse_ip'] = new sfValidatorRegex(array('pattern' => '/^\\b(?:\\d{1,3}\\.){3}\\d{1,3}\\b$/', 'required' => false));
     /* ^([0-9A-F]{2}[:-]){5}([0-9A-F]{2})$ */
     unset($this['updated_at'], $this['created_at']);
 }
示例#13
0
 public function configure()
 {
     $this->setValidator('guid', new sfValidatorString(array('max_length' => 255, 'required' => false)));
     $this->setDefault('guid', Guid::generate());
     $this->setWidget('date_naissance', new sfWidgetFormJqueryDateVip(array('empty_values' => array('year' => '', 'month' => '', 'day' => ''), 'can_be_empty' => true, 'date_range' => array('min' => date('Y') - 100, 'max' => date('Y')))));
     $this->getWidget('preference_media_list')->setOption('renderer_class', 'sfWidgetFormSelectDoubleList');
     $this->getWidget('preference_media_list')->setOption('renderer_options', array('label_unassociated' => 'Disponibles', 'label_associated' => 'Séléctionnés'));
     $this->setDefault('langue_id', '');
     $this->getWidget('langue_id')->setOption('add_empty', true);
     $this->setValidator('password_son', new sfValidatorString(array('max_length' => 255, 'required' => true)));
     $this->setValidator('pseudo_son', new sfValidatorString(array('max_length' => 255, 'required' => true)));
     $this->setValidator('email', new sfValidatorEmail(array('max_length' => 255, 'required' => true)));
     unset($this['updated_at'], $this['created_at'], $this['is_tosync']);
 }
示例#14
0
 public function executeCopy(sfWebRequest $request)
 {
     $exposition = $this->getRoute()->getObject();
     $parcours = $exposition->Parcours->getPrimaryKeys();
     $exposition_copy = $exposition->copy();
     $exposition_copy->setGuid(Guid::generate());
     $exposition_copy->setLibelle($exposition->getLibelle() . '-COPY');
     $exposition_copy->setCreatedAt(date('Y-m-d H:i:s'));
     $exposition_copy->setUpdatedAt(date('Y-m-d H:i:s'));
     $exposition_copy->setOrganisateurDiffuseurId(null);
     $exposition_copy->setContexteId(null);
     $exposition_copy->link('Parcours', array_values($parcours));
     $exposition_copy->save();
     return $this->redirect($this->getController()->genUrl('exposition/edit?guid=' . $exposition_copy->getGuid()));
 }
示例#15
0
 /**
  * Initialise la syncro
  * Récupération de la dernière date de synchro + création dateNowSync + génération Guid synchro
  * - Récupération de la dernière date de synchro dans le modèle syncLog
  * - On fige une date de synchro courante
  * - On génére un guid de synchro qui sera servira d'identifiant au modèle syncLog et de nom de fichier du dump
  * - Insère en BDD les paramètres de syncho dans le modèle syncLog
  * @param sfApplicationConfiguration $configuration
  * @param SyncLog $sync_log
  * @param string $type
  */
 public function __construct($configuration, $sync_log = null, $type = 'intranet')
 {
     if (!$sync_log) {
         $this->log("Contruction des paramètres de la synchro {$type}");
         $this->sync_log = new SyncLog();
         $this->sync_log->setGuid(Guid::generate());
         $this->sync_log->setOrigin(sfConfig::get('app_sync_name'));
         $this->sync_log->setFromDatetimeSync($this->getLastSyncDate());
         $this->sync_log->setToDatetimeSync(date('Y-m-d H:i:s'));
         $this->log("Date du " . $this->getLastSyncDate() . " au " . $this->sync_log->getToDatetimeSync());
     } else {
         $this->sync_log = $sync_log;
     }
     $this->type = $type;
     $this->configuration = $configuration;
 }
 /**
  * Send notification through websocket server
  *
  * @param $type string
  * @param $dest array array of notification's recipients (visiteur:<guid> ,visite:<guid>, exposition:<guid>, parcours:<guid>)
  * @param $options array array of notification's parameters
  * @param $model array -> array('model' => '', 'model_id' => '')
  */
 public function sendNotification($type, $dest, $options, $model = null)
 {
     // This is our new stuff
     $context = new \ZMQContext();
     $socket = $context->getSocket(\ZMQ::SOCKET_PUSH, 'ServerVip pusher');
     $socket->connect($this->uri);
     $vars = array();
     $explode1 = explode(",", $dest);
     foreach ($explode1 as $values) {
         $data = explode(":", $values);
         $key = trim($data[0]);
         $value = trim($data[1]);
         $vars[$key] = $value;
     }
     if (isset($vars['visiteur']) && trim($vars['visiteur']) != '') {
         $visiteur_id = $vars['visiteur'];
     } else {
         throw new sfException('You must specify visiteur.');
         $visiteur_id = 'NULL';
     }
     if (isset($vars['visite'])) {
         $visite_id = $vars['visite'];
     } else {
         $visite_id = 'NULL';
     }
     if ($visiteur_id && strpos($option, 'stdClass') === false) {
         $notif = new Notification();
         $notif->setGuid(Guid::generate());
         $notif->setLibelle($options['title']);
         $notif->setVisiteurId($visiteur_id);
         $notif->setVisiteId($visite_id);
         if (isset($model['model'])) {
             $notif->setFromModel($model['model']);
         }
         if (isset($model['model_id'])) {
             $notif->setFromModelId($model['model_id']);
         }
         $notif->setParameter(json_encode((array) $options));
         $notif->save();
     }
     $socket->send(json_encode(array('command' => 'notification.send', 'data' => array('dest' => $dest, 'type' => $type, 'options' => $options, 'model' => $model))));
 }
 public static function setNewVisiteurUniversStatus($new_univers_status, $univers_id, $visiteur_id, $gain_id = null, $gain_expiration_days = 0, $contexte_id = null)
 {
     $new_visiteur_status = new VisiteurUniversStatusGain();
     $new_visiteur_status->setGuid(Guid::generate());
     $new_visiteur_status->setUniversStatusId($new_univers_status);
     $new_visiteur_status->setVisiteurId($visiteur_id);
     $new_visiteur_status->setGainId($gain_id);
     $new_visiteur_status->setUniversId($univers_id);
     $new_visiteur_status->setContexteId($contexte_id);
     if ($gain_expiration_days === 0) {
         $new_visiteur_status->setStatusGain(null);
         $new_visiteur_status->setExpirationGainDate(null);
     } else {
         $new_visiteur_status->setStatusGain('waiting');
         $date = date_create(date('Y-m-d'));
         date_add($date, date_interval_create_from_date_string($gain_expiration_days . ' days'));
         $new_visiteur_status->setExpirationGainDate(date_format($date, 'Y-m-d'));
     }
     $new_visiteur_status->save();
 }
示例#18
0
 public function save(Doctrine_Connection $conn = null)
 {
     if ($this->isNew()) {
         $this->createDataFolder();
         if ($this->getGuid() == null && $this->getLibelle() != '') {
             $this->setGuid(Guid::generate());
             /*
             if($this->getLibelle() == ''){
                 $referer = $_SERVER["HTTP_REFERER"];
                 $request = ($_SERVER['REQUEST_URI']);
                 $get = print_r($_GET, true);
                 $post = print_r($_POST, true);
                 //die("referer=".$referer."\n<br/>"."request=".$request."\n<br/>"."get=".$get."\n<br/>"."post=".$post);
                 mail('sredeuil@clever-age.com;s.etheve@cap-sciences.net', '[SERVERVIP] interactif null', "referer=".$referer."\n<br/>"."request=".$request."get=".$get."\n<br/>"."post=".$post);
             }
             */
         }
     }
     $this->setIsTosync(1);
     parent::save($conn);
 }
示例#19
0
 public static function createLogVisite($visiteur_id, $score, $contexte_id, $visite_id = null, $interactif_id = null, $exposition_id = null)
 {
     $log_visite = new LogVisite();
     $log_visite->setGuid(Guid::generate());
     $log_visite->setVisiteurId($visiteur_id);
     $log_visite->setContexteId($contexte_id);
     if ($interactif_id != null) {
         $log_visite->setInteractifId($interactif_id);
     } else {
         $log_visite->setInteractif(null);
         $log_visite->setInteractifId(null);
     }
     if ($visite_id != null) {
         $log_visite->setVisiteId($visite_id);
     }
     if ($exposition_id != null) {
         $log_visite->setExpositionId($exposition_id);
     }
     $log_visite->setScore($score);
     $log_visite->save();
     return $log_visite->getGuid();
 }
示例#20
0
 public function configure()
 {
     unset($this['updated_at'], $this['created_at'], $this['visiteur_list'], $this['is_tosync']);
     $this->validatorSchema->setOption('allow_extra_fields', true);
     $this->validatorSchema->setOption('filter_extra_fields', false);
     $this->setValidator('guid', new sfValidatorString(array('max_length' => 255, 'required' => false)));
     $this->setDefault('guid', Guid::generate());
     $this->getValidator('libelle')->setOption('required', true);
     $count = '';
     if ($this->isNew()) {
         $univers = Doctrine_Query::create()->from('Univers')->limit(1)->orderBy('libelle asc')->fetchOne();
         if ($univers) {
             $count = $univers->getMedaille()->count();
         }
     } else {
         if ($this->getObject()->getUniversId()) {
             $count = $this->getObject()->getUnivers()->getMedaille()->count();
         }
     }
     $this->setWidget('gain_id', new sfWidgetFormDoctrineChoice(array('model' => 'Gain', 'order_by' => array('libelle', 'asc'), 'add_empty' => true)));
     $this->getWidgetSchema()->moveField('gain_id', sfWidgetFormSchema::AFTER, 'univers_id');
     $this->setValidator('gain_id', new sfValidatorDoctrineChoice(array('model' => 'Gain', 'column' => 'guid', 'required' => false)));
     $this->getWidget('univers_id')->setOption('order_by', array('libelle', 'asc'));
     $this->getWidget('level')->setDefault('1');
     $this->getWidget('level')->setAttribute('style', 'width:40px');
     $this->getWidget('nb_medaille')->setAttribute('style', 'width:40px');
     if (!$this->isNew()) {
         $this->widgetSchema['image1'] = new sfWidgetFormInputFileEditable(array('label' => 'Image 1', 'delete_label' => 'Supprimer le fichier ?', 'file_src' => '/univers_status/' . $this->getObject()->getImage1(), 'is_image' => true, 'edit_mode' => !$this->isNew(), 'template' => '<div>%file%<br />%input%<br />%delete_label% %delete%</div>'));
         $this->validatorSchema['image1'] = new sfValidatorFile(array('required' => false, 'path' => sfConfig::get('sf_web_dir') . "/univers_status/", 'mime_types' => array('image/jpeg', 'image/png', 'image/jpg')), array('invalid' => 'Please select only a jpeg or png file for upload.', 'required' => 'Select a file to upload.', 'mime_types' => 'The file must be a png / jpeg file .'));
         $this->widgetSchema['image2'] = new sfWidgetFormInputFileEditable(array('label' => 'Image 2', 'delete_label' => 'Supprimer le fichier ?', 'file_src' => '/univers_status/' . $this->getObject()->getImage2(), 'is_image' => true, 'edit_mode' => !$this->isNew(), 'template' => '<div>%file%<br />%input%<br />%delete_label% %delete%</div>'));
         $this->validatorSchema['image2'] = new sfValidatorFile(array('required' => false, 'path' => sfConfig::get('sf_web_dir') . "/univers_status/", 'mime_types' => array('image/jpeg', 'image/png', 'image/jpg')), array('invalid' => 'Please select only a jpeg or png file for upload.', 'required' => 'Select a file to upload.', 'mime_types' => 'The file must be a png / jpeg file .'));
         $this->widgetSchema['image3'] = new sfWidgetFormInputFileEditable(array('label' => 'Image 3', 'delete_label' => 'Supprimer le fichier ?', 'file_src' => '/univers_status/' . $this->getObject()->getImage3(), 'is_image' => true, 'edit_mode' => !$this->isNew(), 'template' => '<div>%file%<br />%input%<br />%delete_label% %delete%</div>'));
         $this->validatorSchema['image3'] = new sfValidatorFile(array('required' => false, 'path' => sfConfig::get('sf_web_dir') . "/univers_status/", 'mime_types' => array('image/jpeg', 'image/png', 'image/jpg')), array('invalid' => 'Please select only a jpeg or png file for upload.', 'required' => 'Select a file to upload.', 'mime_types' => 'The file must be a png / jpeg file .'));
     } else {
         unset($this->widgetSchema['image1']);
         unset($this->widgetSchema['image2']);
         unset($this->widgetSchema['image3']);
     }
 }
示例#21
0
 public function configure()
 {
     $this->validatorSchema->setOption('allow_extra_fields', true);
     $this->validatorSchema->setOption('filter_extra_fields', false);
     unset($this['updated_at'], $this['created_at'], $this['is_tosync'], $this['visiteur_list']);
     $this->setValidator('guid', new sfValidatorString(array('max_length' => 255, 'required' => false)));
     $this->setDefault('guid', Guid::generate());
     $this->setWidget('start_at', new sfWidgetFormJqueryDateVip(array('empty_values' => array('year' => '', 'month' => '', 'day' => ''), 'can_be_empty' => true)));
     $this->setWidget('end_at', new sfWidgetFormJqueryDateVip(array('empty_values' => array('year' => '', 'month' => '', 'day' => ''), 'can_be_empty' => true)));
     $this->validatorSchema->setPostValidator(new sfValidatorOr(array(new sfValidatorAnd(array(new sfValidatorSchemaCompare('start_at', sfValidatorSchemaCompare::NOT_EQUAL, null), new sfValidatorSchemaCompare('end_at', sfValidatorSchemaCompare::EQUAL, null))), new sfValidatorSchemaCompare('start_at', sfValidatorSchemaCompare::LESS_THAN_EQUAL, 'end_at', array('throw_global_error' => false), array('invalid' => 'The start date ("%left_field%") must be before the end date ("%right_field%")')))));
     if (!$this->isNew()) {
         $this->widgetSchema['image'] = new sfWidgetFormInputFileEditable(array('label' => 'Image', 'delete_label' => 'Supprimer le fichier ?', 'file_src' => '/gain/' . $this->getObject()->getImage(), 'is_image' => true, 'edit_mode' => !$this->isNew(), 'template' => '<div>%file%<br />%input%<br />%delete_label% %delete%</div>'));
         $this->validatorSchema['image'] = new sfValidatorFile(array('required' => false, 'path' => sfConfig::get('sf_web_dir') . "/gain/", 'mime_types' => array('image/jpeg', 'image/png', 'image/jpg')), array('invalid' => 'Please select only a jpeg or png file for upload.', 'required' => 'Select a file to upload.', 'mime_types' => 'The file must be a png / jpeg file .'));
         //$this->widgetSchema['image_delete'] = new sfWidgetFormInputCheckbox(array('value_attribute_value'=> 'on') );
         //$this->validatorSchema['image_delete'] = new sfValidatorString();
     } else {
         unset($this->widgetSchema['image']);
     }
     $this->setWidget('send_email_visiteur_template_id', new sfWidgetFormDoctrineChoice(array('model' => 'TemplateMail', 'order_by' => array('key_search', 'asc'), 'add_empty' => true)));
     $this->setWidget('send_email_admin_template_id', new sfWidgetFormDoctrineChoice(array('model' => 'TemplateMail', 'order_by' => array('key_search', 'asc'), 'add_empty' => true)));
     $this->setValidator('send_email_visiteur_template_id', new sfValidatorDoctrineChoice(array('model' => 'TemplateMail', 'column' => 'guid', 'required' => false)));
     $this->setValidator('send_email_admin_template_id', new sfValidatorDoctrineChoice(array('model' => 'TemplateMail', 'column' => 'guid', 'required' => false)));
 }
示例#22
0
 protected function doSave()
 {
     if ($this->object->getGuid() == "" || $this->object->getGuid() == null) {
         $this->object->setGuid(Guid::generate());
     }
     $this->object->save();
     Resque::enqueue('default', 'Job_Typologie', array("visiteur_id" => $this->object->getVisiteurId()));
     $this->getRequest()->setParameter('visiteur_id', $this->object->getVisiteurId());
     $this->getRequest()->setParameter('typologie_id', $this->object->getTypologieId());
     $this->getRequest()->setMethod("GET");
     //return $this->redirect($this->getController()->genUrl('?visiteur_id='.$this->object->getVisiteurId()."&typologie_id=".$this->object->getTypologieId()));
     return $this->forward("xp", "index");
 }
示例#23
0
 protected function createObject()
 {
     $object = new $this->model();
     $object->setGuid(Guid::generate());
     return $object;
 }
示例#24
0
 private function registerLuaApi(Lua $lua)
 {
     // Map getEntity
     $lua->registerCallback('getEntity', function ($type, $guid) {
         $objectTable = call_user_func(array($type . 'Table', 'getInstance'));
         $object = call_user_func(array($objectTable, 'find'), array($guid));
         return $object->toArray();
     });
     // Map sendNotification
     $lua->registerCallback('sendNotification', function ($type, $dest, $options, $model) {
         caNotificationsTools::getInstance()->sendNotification($type, $dest, $options, $model);
     });
     // Map sendMail
     $lua->registerCallback('sendMail', function ($dest, $subject, $message) {
         sfContext::getInstance()->getMailer()->composeAndSend('*****@*****.**', $dest, $subject, $message);
     });
     // Map createMedailleVisiteur
     $lua->registerCallback('createVisiteurMedaille', function ($visiteur_id, $medaille_id, $connection = 'insitu') {
         $medaille = Doctrine_Core::getTable('Medaille')->findOneByGuid($medaille_id);
         $visiteur_medaille = new VisiteurMedaille();
         $visiteur_medaille->setGuid(Guid::generate());
         $visiteur_medaille->setMedailleId($medaille_id);
         $visiteur_medaille->setVisiteurId($visiteur_id);
         $visiteur_medaille->setConnection($connection);
         if (!($visiteur_medaille->hasAlreadyMedaille($connection) && $medaille->getIsUnique())) {
             $visiteur_medaille->save();
         }
     });
     // Map date
     $lua->registerCallback('date', function ($format) {
         return date($format);
     });
     // Map varDump
     $lua->registerCallback('varDump', function ($data) {
         return var_dump($data);
     });
     // Map isBestScoreInteractif
     $lua->registerCallback('isBestScoreInteractif', function ($logVisiteObj) {
         $interactif_id = $logVisiteObj['interactif_id'];
         $log_visite_guid = $logVisiteObj['guid'];
         $visiteur_id = $logVisiteObj['visiteur_id'];
         $score = $logVisiteObj['score'];
         $log_visite_highscore = LogVisiteTable::getInstance()->getHighScoreByInteractif($interactif_id);
         // $log_visite =  Doctrine_Core::getTable('LogVisite')->findOneByGuid($log_visite_guid);
         if ($score == $log_visite_highscore['highscore']) {
             return true;
         }
         return false;
     });
     // Map isUserBestScoreInteractif
     $lua->registerCallback('isVisiteurBestScoreInteractif', function ($logVisiteObj) {
         $interactif_id = $logVisiteObj['interactif_id'];
         $log_visite_guid = $logVisiteObj['guid'];
         $visiteur_id = $logVisiteObj['visiteur_id'];
         $score = $logVisiteObj['score'];
         //$log_visite =  Doctrine_Core::getTable('LogVisite')->findOneByGuid($log_visite_guid);
         $log_visite_highscore = LogVisiteTable::getInstance()->getVisiteurHighScoreByInteractif($interactif_id, $visiteur_id);
         if ($score == $log_visite_highscore['highscore'] && $visiteur_id == $log_visite_highscore['visiteur_id']) {
             return true;
         }
         return false;
     });
     // Map nbLogVisiteExposition
     $lua->registerCallback('nbLogVisiteExposition', function ($exposition_id, $visiteur_id) {
         $count_log_visite = LogVisiteTable::getInstance()->countLogVisiteByExposition($exposition_id, $visiteur_id);
         return $count_log_visite;
     });
     // Map nbLogVisiteExposition
     $lua->registerCallback('hasVisiteMultiPlateforme', function ($logVisiteObj) {
         $interactif_id = $logVisiteObj['interactif_id'];
         $visiteur_id = $logVisiteObj['visiteur_id'];
         $count_log_visite = LogVisiteTable::getInstance()->hasLogVisiteMultiPlateforme($interactif_id, $visiteur_id);
         return $count_log_visite;
     });
     // Map getTotalXP
     $lua->registerCallback('getTotalScore', function () {
         $capscience_total_score = XpTable::getInstance()->getTotalScore();
         return $capscience_total_score;
     });
     // Map nbLogVisiteExposition
     $lua->registerCallback('getTotalScoreByVisiteur', function ($visiteur_id) {
         $visiteur = Doctrine_Core::getTable('Visiteur')->findOneByGuid($visiteur_id);
         $visiteur_score = $visiteur->getTotalXp();
         return $visiteur_score;
     });
     // Map nbLogVisiteExposition
     $lua->registerCallback('getTotalScoreByTypologieAndVisiteur', function ($typologie_id, $visiteur_id) {
         $visiteur_score_by_typlogie = XpTable::getInstance()->getTotalScoreByTypologieAndVisiteur($typologie_id, $visiteur_id);
         return $visiteur_score_by_typlogie;
     });
     // create new notification
     $lua->registerCallback('createNotification', function ($visiteur_id, $libelle, $params = array()) {
         $notif = new Notification();
         $notif->setLibelle($libelle);
         $notif->setVisiteurId($visiteur_id);
         if (isset($params['visite_id'])) {
             $notif->setVisiteId($params['visite_id']);
         }
         if (isset($params['from_model'])) {
             $notif->setFromModel($params['from_model']);
         }
         if (isset($params['from_model_id'])) {
             $notif->setFromModelId($params['from_model_id']);
         }
         if (isset($params['parameter'])) {
             $notif->setParameter(json_encode((array) $params['parameter']));
         }
         $notif->save();
     });
 }
示例#25
0
 public function configure()
 {
     //interactif_image1_delete
     $this->validatorSchema->setOption('allow_extra_fields', true);
     $this->validatorSchema->setOption('filter_extra_fields', false);
     $this->setDefault('guid', Guid::generate());
     unset($this['is_tosync']);
     $typologies = Doctrine_Core::getTable('Typologie')->findAll();
     $score = $this->getObject()->getScore();
     $decode_score = json_decode($score);
     foreach ($typologies as $typologie) {
         $id = 'score_' . $typologie->getGuid();
         $this->widgetSchema[$id] = new sfWidgetFormInputText();
         $this->widgetSchema[$id]->setLabel("Score " . $typologie->getLibelle());
         if ($typologie->getGuid() && is_object($decode_score)) {
             $this->setDefault($id, $decode_score->{$typologie->getGuid()});
         }
     }
     $this->widgetSchema['file'] = new sfWidgetFormInputFile();
     $this->validatorSchema['file'] = new sfValidatorFile(array('required' => false, 'path' => sfConfig::get('sf_web_dir') . "/interactif/", 'mime_types' => array('application/zip', 'application/x-zip', 'application/octet-stream', 'application/x-zip-compressed')), array('invalid' => 'Please select only a zip file for upload.', 'required' => 'Select a file to upload.', 'mime_types' => 'The file must be a zip file .'));
     $this->getWidgetSchema()->moveField('refresh_deploiement', sfWidgetFormSchema::AFTER, 'file');
     $this->getWidgetSchema()->moveField('url_fichier_interactif', sfWidgetFormSchema::AFTER, 'refresh_deploiement');
     if (!$this->isNew()) {
         $this->widgetSchema['image1'] = new sfWidgetFormInputFileEditable(array('label' => 'Package Image 1', 'delete_label' => 'Supprimer le fichier ?', 'file_src' => '/interactif/' . $this->getObject()->getGuid() . '/' . $this->getObject()->getImage1(), 'is_image' => true, 'edit_mode' => !$this->isNew(), 'template' => '<div>%file%<br />%input%<br />%delete_label% %delete%</div>'));
         $this->validatorSchema['image1'] = new sfValidatorFile(array('required' => false, 'path' => sfConfig::get('sf_web_dir') . "/interactif/" . $this->getObject()->getGuid(), 'mime_types' => array('image/jpeg', 'image/png', 'image/jpg')), array('invalid' => 'Please select only a jpeg or png file for upload.', 'required' => 'Select a file to upload.', 'mime_types' => 'The file must be a png / jpeg file .'));
         $this->widgetSchema['image2'] = new sfWidgetFormInputFileEditable(array('label' => 'Package Image 2', 'delete_label' => 'Supprimer le fichier ?', 'file_src' => '/interactif/' . $this->getObject()->getGuid() . '/' . $this->getObject()->getImage2(), 'is_image' => true, 'edit_mode' => !$this->isNew(), 'template' => '<div>%file%<br />%input%<br />%delete_label% %delete%</div>'));
         $this->validatorSchema['image2'] = new sfValidatorFile(array('required' => false, 'path' => sfConfig::get('sf_web_dir') . "/interactif/" . $this->getObject()->getGuid(), 'mime_types' => array('image/jpeg', 'image/png')), array('invalid' => 'Please select only a jpeg or png file for upload.', 'required' => 'Select a file to upload.', 'mime_types' => 'The file must be a png / jpeg file .'));
         $this->widgetSchema['image3'] = new sfWidgetFormInputFileEditable(array('label' => 'Package Image 3', 'delete_label' => 'Supprimer le fichier ?', 'file_src' => '/interactif/' . $this->getObject()->getGuid() . '/' . $this->getObject()->getImage3(), 'is_image' => true, 'edit_mode' => !$this->isNew(), 'template' => '<div>%file%<br />%input%<br />%delete_label% %delete%</div>'));
         $this->validatorSchema['image3'] = new sfValidatorFile(array('required' => false, 'path' => sfConfig::get('sf_web_dir') . "/interactif/" . $this->getObject()->getGuid(), 'mime_types' => array('image/jpeg', 'image/png')), array('invalid' => 'Please select only a jpeg or png file for upload.', 'required' => 'Select a file to upload.', 'mime_types' => 'The file must be a png / jpeg file .'));
     } else {
         unset($this->widgetSchema['image1']);
         unset($this->widgetSchema['image2']);
         unset($this->widgetSchema['image3']);
     }
     $this->setWidget('date_diff', new sfWidgetFormJqueryDateVip(array('empty_values' => array('year' => '', 'month' => '', 'day' => ''), 'can_be_empty' => true)));
     $this->setDefault('is_visiteur_needed', null);
     $this->setDefault('is_logvisite_needed', null);
     $this->setDefault('is_logvisite_verbose_needed', false);
     $this->setDefault('is_parcours_needed', null);
     $this->setValidator('libelle', new sfValidatorString(array('max_length' => 255, 'required' => true)));
     $choices = array(0 => 'Choix multiple', 1 => 'Courant', 2 => 'Tous');
     $this->setWidget('url_interactif_type', new sfWidgetFormSelectRadio(array('choices' => $choices)));
     $this->setDefault('url_interactif_type', 1);
     $this->setValidator('url_interactif_type', new sfValidatorChoice(array('choices' => array_keys($choices), 'required' => false)));
     $interactifs = Doctrine_Core::getTable('Interactif')->findAll();
     $choices_interactifs = array();
     foreach ($interactifs as $interactif) {
         $choices_interactifs[$interactif->getGuid()] = $interactif->getLibelle();
     }
     asort($choices_interactifs);
     $this->setWidget('url_interactif_choice', new sfWidgetFormChoice(array('multiple' => true, 'choices' => $choices_interactifs, 'renderer_class' => 'sfWidgetFormSelectDoubleList')));
     $this->getWidget('url_interactif_choice')->setOption('renderer_options', array('label_unassociated' => 'Disponibles', 'label_associated' => 'Séléctionnés'));
     $this->setValidator('url_interactif_choice', new sfValidatorChoice(array('multiple' => true, 'required' => false, 'choices' => array_keys($choices_interactifs))));
     $choices = array(0 => 'Courant', 1 => 'Tous');
     $this->setWidget('url_visiteur_type', new sfWidgetFormSelectRadio(array('choices' => $choices)));
     $this->setDefault('url_visiteur_type', 1);
     $this->setValidator('url_visiteur_type', new sfValidatorChoice(array('choices' => array_keys($choices), 'required' => false)));
     $choices = array('m' => 'Minutes', 'h' => 'Heures', 'j' => 'Jours', 's' => 'Semaines', 'm' => 'Mois');
     $this->setWidget('url_start_at_type', new sfWidgetFormSelect(array('choices' => $choices)));
     $this->setValidator('url_start_at_type', new sfValidatorChoice(array('choices' => array_keys($choices), 'required' => false)));
     $this->setWidget('url_end_at_type', new sfWidgetFormSelect(array('choices' => $choices)));
     $this->setValidator('url_end_at_type', new sfValidatorChoice(array('choices' => array_keys($choices), 'required' => false)));
     unset($this['updated_at'], $this['created_at'], $this['parcours_list']);
     $this->setValidator('guid', new sfValidatorString(array('max_length' => 255, 'required' => false)));
     $this->setDefault('guid', Guid::generate());
     $this->validatorSchema->setPostValidator(new sfValidatorCallback(array('callback' => array($this, 'checkValidator'))));
     if (!sfContext::getInstance()->getUser()->hasPermission('admin')) {
         $this->widgetSchema->setHelp('libelle', '<b>Attention :</b> l\'interactif ne sera visible dans le listing que pendant 8h après l\'enregistrement. Il sera définitivement visible une fois attaché à une exposition.');
     }
     $this->getWidgetSchema()->moveField('is_logvisite_needed', sfWidgetFormSchema::BEFORE, 'url_interactif_type');
     $this->getWidgetSchema()->moveField('is_logvisite_verbose_needed', sfWidgetFormSchema::BEFORE, 'url_interactif_type');
     //if(!$this->isNew()){
     //$this->validatorSchema->setPostValidator(
     //   new sfValidatorSchemaCompare('date_diff', sfValidatorSchemaCompare::GREATER_THAN_EQUAL, 'created_at',array('throw_global_error' => false), array('invalid' => 'The start date ("%left_field%") must be before the end date ("%right_field%")' ))
     //);
     //}
 }
示例#26
0
 public function createAnonymous($context_creation_id = null)
 {
     $this->setGuid(Guid::generate());
     $this->setIsAnonyme(1);
     if (isset($context_creation_id)) {
         $this->setContexteCreationId($context_creation_id);
     }
     return $this;
 }
示例#27
0
 /**
  * PrinceObject constructor.
  * @param $guid
  */
 public function __construct()
 {
     $this->guid = Guid::generate();
 }
示例#28
0
 public function configure()
 {
     unset($this['updated_at'], $this['created_at'], $this['is_tosync']);
     $this->setValidator('guid', new sfValidatorString(array('max_length' => 255, 'required' => false)));
     $this->setDefault('guid', Guid::generate());
 }
示例#29
0
 protected function createObject()
 {
     $new_vusg = new $this->model();
     $new_vusg->setGuid(Guid::generate());
     return $new_vusg;
 }
示例#30
0
 /**
  * Updates a Visite object
  * @param   sfWebRequest   $request a request object
  * @return  string
  */
 public function executeUpdateMarket(sfWebRequest $request)
 {
     $this->forward404Unless($request->isMethod(sfRequest::POST));
     $content = $request->getContent();
     // Restores backward compatibility. Content can be the HTTP request full body, or a form encoded "content" var.
     if (strpos($content, 'content=') === 0) {
         $content = $request->getParameter('content');
     }
     $parameters = $this->parsePayload($content, true);
     if (isset($parameters['connexion_id'])) {
         $connexion_id = $parameters['connexion_id'];
         unset($parameters['connexion_id']);
     }
     $serializer = $this->getSerializer();
     $content = $serializer->serialize($parameters);
     $request->setRequestFormat('html');
     try {
         $this->validateUpdateMarket($content);
         $this->object = Doctrine_Core::getTable($this->model)->findOneByConnexionId($connexion_id);
     } catch (Exception $e) {
         $this->getResponse()->setStatusCode(406);
         $serializer = $this->getSerializer();
         $this->getResponse()->setContentType($serializer->getContentType());
         $error = $e->getMessage();
         // event filter to enable customisation of the error message.
         $result = $this->dispatcher->filter(new sfEvent($this, 'sfDoctrineRestGenerator.filter_error_output'), $error)->getReturnValue();
         if ($error === $result) {
             $error = array(array('message' => $error));
             $this->output = $serializer->serialize($error, 'error');
         } else {
             $this->output = $serializer->serialize($result);
         }
         return sfView::SUCCESS;
     }
     if (!$this->object) {
         $this->object = $this->createObject();
         $this->object->set('guid', Guid::generate());
     }
     // update and save it
     $this->updateObjectFromRequest($content);
     $response = $this->doSave();
     if (isset($connexion_id) && !empty($connexion_id)) {
         // Notify websocket server
         caNotificationsTools::getInstance()->notifyAuth($this->object['guid'], $connexion_id);
     }
     if (isset($is_ending) && $is_ending == true) {
         // Notify websocket server
         caNotificationsTools::getInstance()->notifyReset($this->object['guid']);
     }
     return $response;
 }