Commits

Laurent Jouanneau  committed 7dbff4d

Fixed some bugs. changed the size of the filename field

  • Participants
  • Parent commits 52f3977

Comments (0)

Files changed (8)

File simplenews/simplenews/install/sql/install.mysql.sql

 `content` TEXT NOT NULL ,
 `date_create` DATETIME NOT NULL ,
 `online` TINYINT NOT NULL ,
-`photo` VARCHAR( 50 ) NULL,
-`attachment` VARCHAR(50) NULL,
+`photo` VARCHAR( 150 ) NULL,
+`attachment` VARCHAR(150) NULL,
 PRIMARY KEY ( `id_news` )
 ) ENGINE = MYISAM ;
 

File simplenews/simplenews/install/upgrade_to_1.1b1_filesize.php

+<?php
+/**
+* @package      simplenews
+* @author       Laurent Jouanneau
+* @copyright    2010 Laurent Jouanneau
+* @link         http://jelix.org
+* @licence      http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public Licence, see LICENCE file
+*/
+
+
+class simplenewsModuleUpgrader_filesize extends jInstallerModule {
+
+    function install() {
+        if ($this->firstDbExec()) {
+            $db = $this->dbConnection();
+            $db->exec('ALTER TABLE '.$db->prefixTable('simplenews').' CHANGE `photo` `photo` VARCHAR( 150 ) NULL DEFAULT NULL ,
+                        CHANGE `attachment` `attachment` VARCHAR( 150 )  NULL DEFAULT NULL');
+        }
+    }
+}

File simplenews/simplenews/module.xml

 <?xml version="1.0" encoding="UTF-8"?>
 <module xmlns="http://jelix.org/ns/module/1.0">
     <info id="simplenews@jelix.org" name="simplenews" createdate="2010-07-06">
-        <version>1.1a2</version>
+        <version>1.1b1</version>
         <label lang="en_EN">Simple news</label>
         <description lang="en_EN" />
         <license URL="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GNU General Public Licence</license>
     </info>
 
     <dependencies>
-        <jelix minversion="1.2pre.1578" maxversion="1.2pre.*"/>
+        <jelix minversion="1.2pre.1578" maxversion="1.2.*"/>
     </dependencies>
 </module>

File simplenews/simplenews_admin/controllers/default.classic.php

                 $p->label = jLocale::get('simplenews.remove.photo.label');
                 $form->addControlBefore($p, 'new_photo');
             }
+            else {
+                $form->setData('photo','');
+            }
 
             $fileName = $form->getData('attachment');
             $manager = jClasses::create('simplenews~simplenewsManager');
-            if ($fileName && file_exists($manager->getAttachment($formId, $fileName))) {
+            $fullFileName = $manager->getAttachment($formId, $fileName);
+            if ($fileName && file_exists($fullFileName)) {
                 $p = new jFormsControlCheckbox('remove_attachment');
                 $p->label = jLocale::get('simplenews.remove.attachment.label');
                 $form->addControlBefore($p, 'new_attachment');
             }
-
-
+            else {
+                $form->setData('attachment','');
+            }
         }
         return $form;
     }
         $path = $manager->getAttachmentPath($id);
         $frontPath = $manager->getAttachmentPath($id, true);
         $new_file = $form->getData('new_attachment');
-        $file = $manager->getPhotoFileName($id, $new_file);
+        $file = $manager->getAttachmentFileName($id, $new_file);
         $dao = jDao::get($this->dao);
         $rec = $dao->get($id);
 
                 $dao->update($rec);
             }
 
-            $file = $manager->getPhotoFileName($id, $form->getData('attachment'));
+            $file = $manager->getAttachmentFileName($id, $form->getData('attachment'));
 
             if ($form->getData('online')) {
                 // the news is online, we have to publish the file
                     unlink($frontPath.$file);
             }
         }
-
     }
 
-
-
     /**
      * you can do your own data check of a form by redefining this method.
      * You can also do some other things. It is called only if the $form->check() is ok.
      * @param boolean $calltype   true for an update, false for a create
      * @return boolean true if it is ok.
      */
-    /*protected function _checkData($form, $calltype){
-        return true;
-    }*/
+    protected function _checkData($form, $calltype){
+        $ret = true;
+        $new_file = $form->getData('new_attachment');
+        if ($new_file && strlen($new_file) > 150) {
+            $form->setErrorOn('new_attachment',jLocale::get('simplenews.form.newattachment.bad.filename'));
+            $ret = false;
+        }
+        $new_photo = $form->getData('new_photo');
+        if ($new_photo && strlen($new_photo) > 150) {
+            $form->setErrorOn('new_photo',jLocale::get('simplenews.form.newphoto.bad.filename'));
+            $ret = false;
+        }
+        return $ret;
+    }
 
     /**
      * redefine this method if you wan to do additionnal things on the response and on the list template

File simplenews/simplenews_admin/forms/simplenews.form.xml

                   labelproperty="label" valueproperty="id_news_category"/>
 </menulist>
 
-<htmleditor ref="summary" config="wymbasic">
+<htmleditor ref="summary" config="wymbasic" required="true">
 	<label locale="simplenews_admin~simplenews.form.summary" />
 </htmleditor>
 

File simplenews/simplenews_admin/locales/en_EN/simplenews.UTF-8.properties

 form.online=Online
 form.ok=OK
 form.category=Category
+form.label=Label
+form.date_create.invalid = Invalid Date
+
 form.photo=Photo
 form.newphoto=New photo
 form.newphoto.help=Only jpeg images, 100ko max
 form.newphoto.invalid=Invalid image
-form.label=Label
-
-form.date_create.invalid = Invalid Date
-
+form.newphoto.bad.filename=The filename of the image is too long
 no.photo= No photo
 remove.photo.label = Remove the existing photo
 
 form.newattachment=New attachment
 form.newattachment.help=Any files
 form.newattachment.invalid=Invalid file
-
+form.newattachment.bad.filename=The filename of the attachment is too long
 no.attachment= No attachment
 remove.attachment.label = Remove the existing attachment
 

File simplenews/simplenews_admin/locales/fr_FR/simplenews.UTF-8.properties

 form.online=En ligne
 form.ok=Sauver
 form.category=Catégorie
+form.label=Libellé
+form.date_create.invalid = Date invalide ou incomplète
+
 form.photo=Photo
 form.newphoto=Nouvelle Photo
 form.newphoto.help=Format de l'image : jpeg, 100ko maximum
 form.newphoto.invalid=Image invalide
-form.label=Libellé
-
-form.date_create.invalid = Date invalide ou incomplète
-
+form.newphoto.bad.filename=Le nom du fichier de la photo est trop long 
+no.photo= Pas de photo
 remove.photo.label = Enlever la photo existante
-no.photo= Pas de photo
 
 form.attachment=Pièce jointe
 form.newattachment=Nouvelle pièce jointe
 form.newattachment.help=Tout fichiers
 form.newattachment.invalid=Fichier invalide
+form.newattachment.bad.filename=Le nom du fichier de la pièce jointe est trop long
 
 no.attachment= Pas de pièce jointe
 remove.attachment.label = Enlever la pièce jointe existante
 
+
 list.title=Gestion de l'actualité
 list.cat.label = Categories :
 list.cat.all = Toutes

File simplenews/simplenews_admin/module.xml

 <?xml version="1.0" encoding="UTF-8"?>
 <module xmlns="http://jelix.org/ns/module/1.0">
     <info id="simplenews_admin@jelix.org" name="simplenews_admin" createdate="2010-07-06">
-        <version>1.1a2</version>
+        <version>1.1b1</version>
         <label lang="en_EN">Management of simple news</label>
         <description lang="en_EN" />
         <license URL="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GNU General Public Licence</license>
         <homepageURL>http://jelix.org</homepageURL>
     </info>
     <dependencies>
-        <jelix minversion="1.2pre.1578" maxversion="1.2pre.*"/>
+        <jelix minversion="1.2pre.1578" maxversion="1.2.*"/>
         <module name="master_admin" />
-        <module name="simplenews" />
+        <module name="simplenews" minversion="1.1b1"/>
         <module name="jacl2db" />
     </dependencies>
 </module>