Ejemplo n.º 1
0
 public function renderImage($attributes, $parameters)
 {
     // Get CAPTCHA parameters from the module form's preferences.
     $pref = ModuleService::getInstance()->getPreferencesDocument('form');
     if (!is_null($pref)) {
         foreach ($pref->getCaptchaParameters() as $name => $value) {
             // Parameters defined in the template overload the preferences' parameters.
             if (!isset($parameters[$name])) {
                 $parameters[$name] = $value;
             }
         }
     }
     self::generateCaptchaCode($parameters);
     $url = htmlentities(LinkHelper::getUrl('form', 'Captcha', $parameters), ENT_COMPAT, "utf-8");
     $code = "<script type=\"text/javascript\">\n//<![CDATA[\nCAPTCHA.imageURL = \"" . $url . "\";\n//]]>\n</script>\n";
     $code .= '<span class="captcha"><input type="image" src="' . $url . '"';
     if (!isset($attributes['title'])) {
         $attributes['title'] = f_Locale::translate("&modules.form.bo.general.Captcha-click-to-have-another-one;");
     }
     if (!isset($attributes['onclick'])) {
         $attributes['onclick'] = 'CAPTCHA.reload(this); return false;';
     }
     foreach ($attributes as $name => $value) {
         $code .= ' ' . $name . '="' . str_replace('"', '\\"', $value) . '"';
     }
     return $code . '/></span>';
 }
Ejemplo n.º 2
0
 public function getPermissions()
 {
     $module = new ModuleService();
     if (!$module->isWritableConfig()) {
         return array();
     }
     $configs = $module->getConfig();
     if (empty($configs['path'])) {
         return array();
     }
     $permissions = array();
     foreach ($configs['path'] as $path) {
         $permissions[$path] = array('type' => '可写', 'bool' => is_writable($path));
     }
     return $permissions;
 }
 /**
  * @name getAdherent($pParam)
  * return AfficheModificationAdherentResponse
  * @desc Retourne les informations pour l'adhérent.
  */
 public function getAdherent($pParam)
 {
     $lVr = AdherentValid::validAffiche($pParam);
     if ($lVr->getValid()) {
         $lIdAdherent = $pParam['id'];
         $lAdherentService = new AdherentService();
         $lResponse = new InfoCompteAdherentResponse();
         $lAdherent = $lAdherentService->get($lIdAdherent);
         $lResponse->setAdherent($lAdherent);
         $lResponse->setAutorisations($lAdherentService->getAutorisation($lIdAdherent));
         $lModuleService = new ModuleService();
         $lResponse->setModules($lModuleService->selectAllNonDefautVisible());
         $lCompteService = new CompteService();
         $lResponse->setAdherentCompte($lCompteService->getAdherentCompte($lAdherent->getAdhIdCompte()));
         return $lResponse;
     }
     return $lVr;
 }
Ejemplo n.º 4
0
 public function execute($filterChain)
 {
     /* Populating enabled modules */
     $disabledModules = array();
     if ($this->getContext()->getUser()->hasAttribute("admin.disabledModules")) {
         $disabledModules = $this->getContext()->getUser()->getAttribute("admin.disabledModules");
     } else {
         $moduleService = new ModuleService();
         $disabledModuleList = $moduleService->getDisabledModuleList();
         foreach ($disabledModuleList as $module) {
             $disabledModules[] = $module->getName();
         }
         $this->getContext()->getUser()->setAttribute("admin.disabledModules", $disabledModules);
     }
     /* Checking request with disabled modules */
     $request = $this->getContext()->getRequest();
     if (in_array($request['module'], $disabledModules)) {
         header("HTTP/1.0 404 Not Found");
         die;
     }
     /* Continuing the filter chain */
     $filterChain->execute();
 }
 /**
  * @name afficher($pParam)
  * @return InfoCompteAdherentResponse
  * @desc Renvoie le Compte du controleur après avoir récupérer les informations dans la BDD en fonction de l'ID.
  */
 public function afficher($pParam)
 {
     $lVr = AdherentValid::validAffiche($pParam);
     if ($lVr->getValid()) {
         $lIdAdherent = $pParam['id'];
         $lAdherentService = new AdherentService();
         $lResponse = new InfoCompteAdherentResponse();
         $lAdherent = $lAdherentService->get($lIdAdherent);
         $lResponse->setAdherent($lAdherent);
         $lResponse->setAutorisations($lAdherentService->getAutorisation($lIdAdherent));
         $lResponse->setOperationAvenir($lAdherentService->getOperationAvenir($lIdAdherent));
         $lResponse->setOperationPassee($lAdherentService->getOperationPassee($lIdAdherent));
         $lModuleService = new ModuleService();
         $lResponse->setModules($lModuleService->selectAllNonDefautVisible());
         $lTypePaiementService = new TypePaiementService();
         $lResponse->setTypePaiement($lTypePaiementService->get());
         $lCompteService = new CompteService();
         $lResponse->setAdherentCompte($lCompteService->getAdherentCompte($lAdherent->getAdhIdCompte()));
         $lAdhesionService = new AdhesionService();
         $lResponse->setNbAdhesionEnCours($lAdhesionService->getNbAdhesionEnCoursSurAdherent($lIdAdherent));
         return $lResponse;
     }
     return $lVr;
 }
Ejemplo n.º 6
0
 /**
  * @return string
  */
 public function getSenderAddress()
 {
     $address = null;
     $pref = ModuleService::getPreferencesDocument('form');
     if ($pref !== null) {
         $sender = $pref->getSender();
         if ($sender !== null) {
             $addresses = $sender->getEmailAddresses();
             $address = $addresses[0];
         }
     }
     if ($address === null) {
         if (defined('MOD_NOTIFICATION_SENDER')) {
             $address = MOD_NOTIFICATION_SENDER;
         } else {
             $address = MOD_NOTIFICATION_DEFAULT_SENDER;
         }
     }
     return $address;
 }
 /**
  * @return form_persistentdocument_preferences
  */
 protected function initPersistentDocument()
 {
     $document = ModuleService::getInstance()->getPreferencesDocument('form');
     return $document !== null ? $document : form_PreferencesService::getInstance()->getNewDocumentInstance();
 }
 /**
  * @param form_persistentdocument_baseform $form
  */
 protected function getOverrideNotificationSender($form)
 {
     $defaultSender = ModuleService::getInstance()->getPreferenceValue('form', 'sender');
     if ($defaultSender !== null) {
         return f_util_ArrayUtils::firstElement($defaultSender->getEmailAddresses());
     }
     return null;
 }
 /**
  * @return form_persistentdocument_preferences
  */
 private function getPreferences()
 {
     return ModuleService::getInstance()->getPreferencesDocument('form');
 }
 /**
  * Creates the notification that is bound to the form.
  * @param form_persistentdocument_form $form
  */
 protected function createNotification($form)
 {
     $notification = notification_NotificationService::getInstance()->getNewDocumentInstance();
     $notification->setLabel($form->getLabel());
     $notification->setCodename($form->getFormid() . '_notification');
     $notification->setTemplate('default');
     $notification->setSubject($form->getLabel());
     $notification->setBody('{' . self::CONTENT_REPLACEMENT_NAME . '}');
     $notification->save(ModuleService::getInstance()->getSystemFolderId('notification', 'form'));
     $form->setNotification($notification);
 }
Ejemplo n.º 11
0
            return 'File is too large.';
        }
        $uploadDir = $this->getMainDirectory() . $_GET['module-name'] . '/';
        if (!is_dir($uploadDir)) {
            mkdir($uploadDir);
        }
        $name = Date('YmdHis') . '_' . $name;
        if (move_uploaded_file($tempName, $uploadDir . $name)) {
            return 'File uploaded.';
        } else {
            return 'There was an error uploading the file';
        }
    }
}
require __DIR__ . '/../../Publish/lib/service/ModuleService.php';
$module = new ModuleService();
$upload_path = '../../publishModules/upload/';
if ($module->isWritableConfig()) {
    $configs = $module->getConfig();
    if (isset($configs['path']['upload_path'])) {
        $upload_path = $configs['path']['upload_path'];
    }
}
//Instantiate the class
$bigUpload = new BigUpload($upload_path);
//Set the temporary filename
$tempName = null;
if (isset($_GET['key'])) {
    $tempName = $_GET['key'];
}
if (isset($_POST['key'])) {
Ejemplo n.º 12
0
 /**
  * @name update($pAdherent)
  * @param AdherentVO
  * @return AdherentVO
  * @desc Modifie un adherent
  */
 private function update($pAdherent)
 {
     $lAdherentActuel = AdherentManager::select($pAdherent->getId());
     // Si pas de liaison création d'un nouveau compte
     if ($pAdherent->getIdCompte() == 0) {
         // Création d'un nouveau compte
         $lCompte = new CompteVO();
         $lCompteService = new CompteService();
         $lCompte = $lCompteService->set($lCompte);
         $pAdherent->setIdCompte($lCompte->getId());
         // Laision avec l'adhérent
         $lCompte->setIdAdherentPrincipal($pAdherent->getId());
         // Positionnement de l'adhérent en adhérent principal du compte
         $lCompteService->set($lCompte);
     } else {
         if ($pAdherent->getIdCompte() != $lAdherentActuel->getIdCompte()) {
             // Liaison avec un autre compte
             $lAdhesionService = new AdhesionService();
             // Suppression des adhésions actuelles
             $lAdhesionService->deleteAdhesionAdherentByIdAdherent($pAdherent->getId());
             // Les adhérents du compte
             $lListeAdherent = $this->selectActifByIdCompte($pAdherent->getIdCompte());
             // Le premier adhérent
             $lAdherent = $lListeAdherent[0];
             // Les adhésions sur le premier adhérent
             $lAdhesions = $lAdhesionService->getAdhesionSurAdherent($lAdherent->getId());
             // Positionne les mêmes adhésions si elles existent
             foreach ($lAdhesions as $lAdhesion) {
                 $lAdhesionAdherentDetail = $lAdhesionService->getAdhesionAdherent($lAdhesion->getAdadId());
                 if ($lAdhesionAdherentDetail) {
                     $lAdhesionAdherent = $lAdhesionAdherentDetail->getAdhesionAdherent();
                     $lTypeAdhesion = $lAdhesionService->getTypeAdhesion($lAdhesionAdherent->getIdTypeAdhesion());
                     if ($lTypeAdhesion->getIdPerimetre() == 2) {
                         // Si type d'adhésion sur périmètre compte
                         $lAdhesionAdherent->setId('');
                         $lAdhesionAdherent->setIdAdherent($pAdherent->getId());
                         $lAdhesionService->setAdhesionAdherent($lAdhesionAdherent);
                     }
                 }
             }
         }
     }
     // Insertion de la date de mise à jour
     $pAdherent->setDateMaj(StringUtils::dateTimeAujourdhuiDb());
     // On reporte le numero dans la maj
     $pAdherent->setNumero($lAdherentActuel->getNumero());
     // L'adherent n'est pas supprimé
     $pAdherent->setEtat(1);
     // Mise en forme des données
     $pAdherent->setNom(StringUtils::formaterNom(trim($pAdherent->getNom())));
     $pAdherent->setPrenom(StringUtils::formaterPrenom(trim($pAdherent->getPrenom())));
     $pAdherent->setCourrielPrincipal(trim($pAdherent->getCourrielPrincipal()));
     $pAdherent->setCourrielSecondaire(trim($pAdherent->getCourrielSecondaire()));
     $pAdherent->setTelephonePrincipal(trim($pAdherent->getTelephonePrincipal()));
     $pAdherent->setTelephoneSecondaire(trim($pAdherent->getTelephoneSecondaire()));
     $pAdherent->setAdresse(trim($pAdherent->getAdresse()));
     $pAdherent->setCodePostal(trim($pAdherent->getCodePostal()));
     $pAdherent->setVille(StringUtils::formaterVille(trim($pAdherent->getVille())));
     $pAdherent->setCommentaire(trim($pAdherent->getCommentaire()));
     // Protection des dates vides
     if ($pAdherent->getDateNaissance() == '') {
         $pAdherent->setDateNaissance(StringUtils::FORMAT_DATE_NULLE);
     }
     if ($pAdherent->getDateAdhesion() == '') {
         $pAdherent->setDateAdhesion(StringUtils::FORMAT_DATE_NULLE);
     }
     if ($pAdherent->getDateMaj() == '') {
         $pAdherent->setDateMaj(StringUtils::FORMAT_DATE_NULLE);
     }
     // Maj de l'adherent dans la BDD
     $lRetour = AdherentManager::update($pAdherent);
     // Récupération des autorisations acutelles
     $lAutorisationsActuelles = AutorisationManager::selectByIdAdherent($pAdherent->getId());
     $lModuleService = new ModuleService();
     $lModulesDefaut = $lModuleService->selectAllDefautVisible();
     $lIdModuleDefaut = array();
     foreach ($lModulesDefaut as $lModule) {
         array_push($lIdModuleDefaut, $lModule->getId());
     }
     // Suppression des autorisations
     $lIdSuppAutorisation = array();
     foreach ($lAutorisationsActuelles as $lAutorisationActu) {
         // Suppression si ce n'est pas un module par defaut
         if (!in_array($lAutorisationActu->getIdModule(), $lIdModuleDefaut)) {
             $lSupp = true;
             foreach ($pAdherent->getListeModule() as $lIdModule) {
                 if ($lAutorisationActu->getIdModule() == $lIdModule) {
                     $lSupp = false;
                 }
             }
             if ($lSupp) {
                 array_push($lIdSuppAutorisation, $lAutorisationActu->getId());
             }
         }
     }
     if (!empty($lIdSuppAutorisation)) {
         AutorisationManager::deleteByArray($lIdSuppAutorisation);
     }
     // Ajout des nouvelles autorisations du compte
     $lAutorisations = array();
     foreach ($pAdherent->getListeModule() as $lIdModule) {
         $lAjout = true;
         foreach ($lAutorisationsActuelles as $lAutorisationActu) {
             if ($lAutorisationActu->getIdModule() == $lIdModule) {
                 $lAjout = false;
             }
         }
         if ($lAjout) {
             $lAutorisation = new AutorisationVO();
             $lAutorisation->setIdAdherent($pAdherent->getId());
             $lAutorisation->setIdModule($lIdModule);
             array_push($lAutorisations, $lAutorisation);
         }
     }
     if (!empty($lAutorisations)) {
         AutorisationManager::insertByArray($lAutorisations);
     }
     //Mise à jour des inscriptions de mailing liste
     $lMailingListeService = new MailingListeService();
     // Suppression des anciens mails
     if ($lAdherentActuel->getCourrielPrincipal() != "") {
         $lMailingListeService->delete($lAdherentActuel->getCourrielPrincipal());
     }
     if ($lAdherentActuel->getCourrielSecondaire() != "") {
         $lMailingListeService->delete($lAdherentActuel->getCourrielSecondaire());
     }
     // Ajout des nouveaux mails
     if ($pAdherent->getCourrielPrincipal() != "") {
         $lMailingListeService->insert($pAdherent->getCourrielPrincipal());
     }
     if ($pAdherent->getCourrielSecondaire() != "") {
         $lMailingListeService->insert($pAdherent->getCourrielSecondaire());
     }
     return $lRetour;
 }