Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/jelix-1.7.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentj committed Mar 20, 2018
2 parents e2d75c7 + 3a960f9 commit 359a3a4
Show file tree
Hide file tree
Showing 43 changed files with 336 additions and 125 deletions.
Empty file modified bin/create-jelix-app.php
100644 → 100755
Empty file.
1 change: 1 addition & 0 deletions build/manifests/jelix-modules.mn
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ cd lib/jelix-modules/jacl2db/install
data.json
groups.json
users.json
users.groups.json
install.php
upgrade_localesmoved.php

Expand Down
6 changes: 3 additions & 3 deletions lib/Jelix/Core/Config/defaultconfig.ini.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,13 +412,13 @@

jforms_htmleditor_wymbasic.skin.default.css="$jelix/wymeditor/skins/default/skin.css"

jforms_htmleditor_ckdefault.js[]="$jelix/ckeditor/ckeditor.js"
jforms_htmleditor_ckdefault.js[]="ckeditor/ckeditor.js"
jforms_htmleditor_ckdefault.js[]="$jelix/js/jforms/htmleditors/ckeditor_default.js"

jforms_htmleditor_ckfull.js[]="$jelix/ckeditor/ckeditor.js"
jforms_htmleditor_ckfull.js[]="ckeditor/ckeditor.js"
jforms_htmleditor_ckfull.js[]="$jelix/js/jforms/htmleditors/ckeditor_full.js"

jforms_htmleditor_ckbasic.js[]="$jelix/ckeditor/ckeditor.js"
jforms_htmleditor_ckbasic.js[]="ckeditor/ckeditor.js"
jforms_htmleditor_ckbasic.js[]="$jelix/js/jforms/htmleditors/ckeditor_basic.js"

jforms_wikieditor_default.js[]="$jelix/markitup/jquery.markitup.js"
Expand Down
4 changes: 4 additions & 0 deletions lib/Jelix/Installer/Checker/installmessages.en.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
'module.upgrader.class.not.found'=>'The upgrade class %s for the module %s doesn\'t exist',
'module.error.delete.dependency' => 'Module %s, , needed by module %s, should be removed at the same time',
'module.error.install.dependency' => 'Module %s, should be removed because of the removal of one of its dependencies, module %s, but it asked to be install/upgrade at the same time',
'module.upgrader.missing.version'=>'Target version is missing for the upgrade script %s of the module %s',
'module.missing.version'=>'Version is missing from the module.xml file of the module %s',

'installer.ini.missing.version'=>'The previous version of the module %s is missing from the installer.ini.php file',

'install.entrypoint.start' =>'Installation starts for the entry point %s',
'install.entrypoint.end' =>'All modules are installed or upgraded for the entry point %s',
Expand Down
4 changes: 4 additions & 0 deletions lib/Jelix/Installer/Checker/installmessages.fr.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
'module.upgrader.class.not.found'=>'La classe de mise à jour %s pour le module %s n\'existe pas',
'module.error.delete.dependency' => 'Le module %s, qui est doit être désinstallé, est nécessaire au module %s',
'module.error.install.dependency' => 'Le module %s, que vous demandez d\'installer, doit être désinstallé à cause de la désinstallation du module %s',
'module.upgrader.missing.version'=>'La version cible est manquante pour le script de mise à jour %s du module %s',
'module.missing.version'=>'La version est manquante dans le fichier module.xml du module %s',

'installer.ini.missing.version'=>'La version précédente du module %s n\'est pas indiquée dans le fichier installer.ini.php',

'install.entrypoint.start' =>'Installation pour le point d\'entrée %s',
'install.entrypoint.end' =>'Tous les modules sont installés ou mis à jour pour le point d\'entrée %s',
Expand Down
4 changes: 2 additions & 2 deletions lib/Jelix/Installer/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function migrate() {
}

protected function migrate_1_7_0() {
$this->reporter->message('Start migration to 1.7.0', 'notice');
$this->reporter->message('Start migration to Jelix 1.7.0', 'notice');
$newConfigPath = App::appConfigPath();
if (!file_exists($newConfigPath)) {
$this->reporter->message('Create app/config/', 'notice');
Expand Down Expand Up @@ -125,7 +125,7 @@ protected function migrate_1_7_0() {
$this->migrateCoordPluginsConf_1_7_0(App::varConfigPath($configFile));
}

$this->reporter->message('Migration to 1.7.0 is done', 'notice');
$this->reporter->message('Migration to Jelix 1.7.0 is done', 'notice');
}

private function migrateProfilesIni_1_7_0(\Jelix\IniFile\IniModifier $profilesini) {
Expand Down
20 changes: 16 additions & 4 deletions lib/Jelix/Installer/ModuleInstallLauncher.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,13 @@ public function isInstalled($epId) {
}

public function isUpgraded($epId) {
return ($this->isInstalled($epId) &&
(VersionComparator::compareVersion($this->moduleInfos->version, $this->moduleStatuses[$epId]->version) == 0));
if (!$this->isInstalled($epId)) {
return false;
}
if ($this->moduleStatuses[$epId]->version == '') {
throw new Exception("installer.ini.missing.version", array($this->name));
}
return VersionComparator::compareVersion($this->moduleInfos->version, $this->moduleStatuses[$epId]->version) == 0;
}

public function isActivated($epId) {
Expand Down Expand Up @@ -257,11 +262,18 @@ function getUpgraders(EntryPoint $ep) {
if ($fileInfo[1] && count($upgrader->targetVersions) == 0) {
$upgrader->targetVersions = array($fileInfo[1]);
}
if (count($upgrader->targetVersions) == 0) {
throw new Exception("module.upgrader.missing.version",array($fileInfo[0], $this->moduleInfos->name));
}
$this->moduleUpgraders[] = $upgrader;
$upgrader->setGlobalSetup($this->globalSetup);
}
}

if (count($this->moduleUpgraders) && $this->moduleStatuses[$epId]->version == '') {
throw new Exception("installer.ini.missing.version", array($this->moduleInfos->name));
}

$list = array();
foreach($this->moduleUpgraders as $upgrader) {

Expand Down Expand Up @@ -325,9 +337,9 @@ function getUpgraders(EntryPoint $ep) {
return $list;
}

public function setAsCurrentModuleUpgraders(ModuleInstaller $upgrader, EntryPoint $ep) {
public function setAsCurrentModuleUpgrader(ModuleInstaller $upgrader, EntryPoint $ep) {
$epId = $ep->getEpId();
$upgrader->setParameters($this->moduleStatuses[$epId]->parameters);
$upgrader->setParameters($this->moduleInfos[$epId]->parameters);
$ep->_setCurrentModuleInstaller($upgrader);
$upgrader->initDbProfileForEntrypoint($this->moduleStatuses[$epId]->dbProfile);
}
Expand Down
16 changes: 14 additions & 2 deletions lib/Jelix/Installer/ModuleInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,20 @@ public function _execSQLScript ($name, $modulePath, $inTransaction = true) {
* @throws Exception
* @since 1.6.16
*/
final protected function insertDaoData($relativeSourcePath, $option) {
$file = $this->path.'install/'.$relativeSourcePath;
final protected function insertDaoData($relativeSourcePath, $option, $module = null) {

if ($module) {
$conf = $this->entryPoint->config->_modulesPathList;
if (!isset($conf[$module])) {
throw new Exception('insertDaoData : invalid module name');
}
$path = $conf[$module];
}
else {
$path = $this->path;
}

$file = $path.'install/'.$relativeSourcePath;
$dataToInsert = json_decode(file_get_contents($file), true);
if (!$dataToInsert) {
throw new Exception("Bad format for dao data file.");
Expand Down
1 change: 1 addition & 0 deletions lib/Jelix/Logger/Message/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public function getFormatedMessage() {
'%file%' => $this->file,
'%line%' => $this->line,
'%trace%' => $traceLog,
'%http_method%' => isset($_SERVER['REQUEST_METHOD'])?$_SERVER['REQUEST_METHOD']:'Unknown method',
'\t' =>"\t",
'\n' => "\n"
));
Expand Down
91 changes: 61 additions & 30 deletions lib/Jelix/Mailer/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ class Mailer extends \PHPMailer {
*/
protected $copyToFiles = false;

protected $htmlImageBaseDir = '';

protected $html2textConverter = false;

/**
* initialize some member
*/
Expand Down Expand Up @@ -117,12 +121,17 @@ function getAddrName($address, $kind = false) {
* @param string $selector
* @param boolean $isHtml true if the content of the template is html.
* IsHTML() is called.
* @param false|callable an html2text converter when the content is html.
* By default, it uses the converter of jMailer, html2textKeepLinkSafe(). (since 1.6.17)
* @param string $basedir Absolute path to a base directory to prepend to relative paths to images (since 1.6.17)
* @return jTpl the template object.
*/
public function Tpl( $selector, $isHtml = false ) {
public function Tpl( $selector, $isHtml = false, $html2textConverter = false, $htmlImageBaseDir='') {
$this->bodyTpl = $selector;
$this->tpl = new \jTpl();
$this->isHTML($isHtml);
$this->html2textConverter = $html2textConverter;
$this->htmlImageBaseDir = $htmlImageBaseDir;
return $this->tpl;
}

Expand All @@ -140,47 +149,36 @@ public function send() {
$mailtpl = $this->tpl;
$metas = $mailtpl->meta( $this->bodyTpl , ($this->ContentType == 'text/html'?'html':'text') );

if (isset($metas['Subject'])) {
if (isset($metas['Subject']) && is_string($metas['Subject'])) {
$this->Subject = $metas['Subject'];
}

if (isset($metas['Priority'])) {
if (isset($metas['Priority']) && is_numeric($metas['Priority'])) {
$this->Priority = $metas['Priority'];
}
$mailtpl->assign('Priority', $this->Priority );

if (isset($metas['Sender'])) {
if (isset($metas['Sender']) && is_string($metas['Sender'])) {
$this->Sender = $metas['Sender'];
}
$mailtpl->assign('Sender', $this->Sender );

if (isset($metas['to'])) {
foreach ($metas['to'] as $val) {
$this->getAddrName($val, 'to');
}
}
$mailtpl->assign('to', $this->to );

if (isset($metas['cc'])) {
foreach ($metas['cc'] as $val) {
$this->getAddrName($val, 'cc');
}
}
$mailtpl->assign('cc', $this->cc );

if (isset($metas['bcc'])) {
foreach ($metas['bcc'] as $val) {
$this->getAddrName($val, 'bcc');
}
}
$mailtpl->assign('bcc', $this->bcc);

if (isset($metas['ReplyTo'])) {
foreach ($metas['ReplyTo'] as $val) {
$this->getAddrName($val, 'Reply-To');
foreach (array('to'=>'to',
'cc'=>'cc',
'bcc'=>'bcc',
'ReplyTo'=>'Reply-To') as $prop=>$propName) {
if (isset($metas[$prop])) {
if (is_array($metas[$prop])) {
foreach ($metas[$prop] as $val) {
$this->getAddrName($val, $propName);
}
}
else if (is_string($metas[$prop])) {
$this->getAddrName($metas[$prop], $propName);
}
}
$mailtpl->assign($prop, $this->$prop );
}
$mailtpl->assign('ReplyTo', $this->ReplyTo );

if (isset($metas['From'])) {
$adr = $this->getAddrName($metas['From']);
Expand All @@ -191,7 +189,8 @@ public function send() {
$mailtpl->assign('FromName', $this->FromName );

if ($this->ContentType == 'text/html') {
$this->msgHTML($mailtpl->fetch( $this->bodyTpl, 'html'));
$converter = $this->html2textConverter ? $this->html2textConverter: array($this, 'html2textKeepLinkSafe');
$this->msgHTML($mailtpl->fetch( $this->bodyTpl, 'html'), $this->htmlImageBaseDir, $converter);
}
else
$this->Body = $mailtpl->fetch( $this->bodyTpl, 'text');
Expand Down Expand Up @@ -264,4 +263,36 @@ protected function copyMail($header, $body) {
$filename = $dir.'mail-'.$ip.'-'.date('Ymd-His').'-'.uniqid(mt_rand(), true);
\jFile::write ($filename, $header.$body);
}


/**
* Convert HTML content to Text.
*
* Basically, it removes all tags (strip_tags). For <a> tags, it puts the
* link in parenthesis, except <a> elements having the "notexpandlink".
* class.
* @param string $html
* @return string
* @since 1.6.17
*/
public function html2textKeepLinkSafe($html) {
$regexp = "/<a\\s[^>]*href\\s*=\\s*([\"\']??)([^\" >]*?)\\1([^>]*)>(.*)<\/a>/siU";
if(preg_match_all($regexp, $html, $matches, PREG_SET_ORDER)) {
foreach($matches as $match) {
if (strpos($match[3], "notexpandlink") !== false) {
continue;
}
// keep space inside parenthesis, because some email client my
// take parenthesis as part of the link
$html = str_replace($match[0], $match[4].' ( '.$match[2].' )', $html);
}
}
$html = preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/si', '', $html);

return html_entity_decode(
trim(strip_tags($html)),
ENT_QUOTES,
$this->CharSet
);
}
}
2 changes: 1 addition & 1 deletion lib/Jelix/Routing/RouterDebug.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
namespace Jelix\Routing;
use Jelix\Core\App;
use Jelix\Logger\Log:
use Jelix\Logger\Log;

/**
* the main class of the jelix core, in debug mode
Expand Down
4 changes: 2 additions & 2 deletions lib/jelix-admin-modules/jacl2db_admin/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<label lang="en_US">jAcl2.db administration</label>
<description lang="en_US">Web interface to manage rights with jAcl2 and its driver 'db'</description>
<license URL="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GPL 2.0</license>
<copyright>2008-2017 Laurent Jouanneau and other contributors</copyright>
<creator name="Laurent Jouanneau" email="laurent@jelix.org"/>
<copyright>2008-2018 Laurent Jouanneau and other contributors</copyright>
<creator name="Laurent Jouanneau" email="laurent@jelix.org" />
<homepageURL>http://jelix.org</homepageURL>
</info>
<dependencies>
Expand Down
4 changes: 2 additions & 2 deletions lib/jelix-admin-modules/jauthdb_admin/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<label lang="en_US">jauthdb_admin</label>
<description lang="en_US"/>
<license URL="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GNU Public Licence</license>
<copyright>2009-2015 Laurent Jouanneau</copyright>
<creator name="Laurent Jouanneau" email="laurent@jelix.org" active="true"/>
<copyright>2009-2018 Laurent Jouanneau</copyright>
<creator name="Laurent Jouanneau" email="laurent@jelix.org" />
<homepageURL>http://jelix.org</homepageURL>
</info>
<dependencies>
Expand Down
5 changes: 3 additions & 2 deletions lib/jelix-admin-modules/jpref_admin/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
<label lang="en_US">jPref manager</label>
<description lang="en_US" />
<license URL="http://www.gnu.org/licenses/lgpl.html">GNU Lesser General Public Licence</license>
<copyright>2011 Florian Lonqueu-Brochard</copyright>
<author name="Florian Lonqueu-Brochard" email="dev@florianlb.fr" active="true"/>
<copyright>2012 Florian Lonqueu-Brochard, 2012-2018 Laurent Jouanneau</copyright>
<creator name="Florian Lonqueu-Brochard" email="dev@florianlb.fr" />
<contributor name="Laurent Jouanneau" />
<homepageURL>http://jelix.org</homepageURL>
</info>
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ function index() {
$user = jAuth::getUserSession();
$driver = jAuth::getDriver();
if (method_exists($driver, 'checkPassword') &&
$user->login == 'admin' && $driver->checkPassword('admin', $user->password)) {
$driver->checkPassword($user->login, $user->password)
) {
jMessage::add(jLocale::get('gui.message.admin.password'), 'error');
}
$resp->body->assign('selectedMenuItem','dashboard');
Expand Down
4 changes: 2 additions & 2 deletions lib/jelix-admin-modules/master_admin/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<label lang="en_US">Main Administration Interface</label>
<description lang="en_US">Main Web interface for the administration of an application</description>
<license URL="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GPL 2.0</license>
<copyright>2008-2017 Laurent Jouanneau</copyright>
<creator name="Laurent Jouanneau" email="laurent@jelix.org"/>
<copyright>2008-2018 Laurent Jouanneau</copyright>
<creator name="Laurent Jouanneau" email="laurent@jelix.org" />
<homepageURL>http://jelix.org</homepageURL>
</info>
<dependencies>
Expand Down
17 changes: 17 additions & 0 deletions lib/jelix-legacy/auth/jAuth.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ public static function changePassword($login, $newpassword){
$dr = self::getDriver();
if($dr->changePassword($login, $newpassword)===false)
return false;
jEvent::notify ('AuthChangePassword', array('login'=>$login, 'password'=>$newpassword));
if(self::isConnected() && self::getUserSession()->login === $login){
$config = self::loadConfig();
$_SESSION[$config['session_name']] = self::getUser($login);
Expand All @@ -317,6 +318,20 @@ public static function verifyPassword($login, $password){
* @param string $password the password to test (not encrypted)
* @param boolean $persistant (optional) the session must be persistant
* @return boolean true if authentification is ok
* @jelixevent AuthBeforeLogin listeners should return processlogin=false to
* refuse authentication and to avoid a password check
* (when a user is blacklisted for exemple)
* you can also respond to this event to do record
* in a log file or else.
* parameters: login
* @jelixevent AuthCanLogin sent when password is ok.
* parameters: login, user=user object
* listeners can respond with canlogin=false to refuse the authentication.
* @jelixevent AuthLogin sent when the login process is finished and the user
* is authenticated. listeners receive the login
* and a boolean indicating the persistence
* @jelixevent AuthErrorLogin sent when the password is bad. Listeners receive
* the login.
*/
public static function login($login, $password, $persistant=false){

Expand Down Expand Up @@ -368,6 +383,8 @@ public static function isPersistant(){

/**
* logout a user and delete the user in the php session
*
* @jelixevent AuthLogout listeners received the login
*/
public static function logout(){

Expand Down
Loading

0 comments on commit 359a3a4

Please sign in to comment.