'.$string.'>');
$this->filesystem->appendToFile($this->rootlog.'cron.log', $string."\n");
diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/CalendarController.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/CalendarController.php
index eec48530..9d36fac5 100644
--- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/CalendarController.php
+++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Controller/CalendarController.php
@@ -188,7 +188,8 @@ class CalendarController extends Controller
$em->getRepository($this->labelentity)->getPermission($this->getUser(),$entity,$cansee,$canupdate);
if(!$canupdate) throw $this->createNotFoundException('Permission denied');
}
-
+ $oldpassword=$entity->getPasswordDecrypt();
+
// Création du formulaire
$form = $this->entityForm($entity,$access);
$form->handleRequest($request);
@@ -198,6 +199,17 @@ class CalendarController extends Controller
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
+ $entity = $form->getData();
+
+ // Si pas de changement de password on replace l'ancien
+ if($entity->getPasswordDecrypt()=="") {
+ $entity->setPassword($oldpassword);
+ }
+ // Sinon on encode le nouveau
+ else {
+ $entity->setPasswordDirect($entity->getPassword());
+ }
+
$em->persist($entity);
$em->flush();
diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Entity/Calendar.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Entity/Calendar.php
index a00a8e45..a3f9b296 100644
--- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Entity/Calendar.php
+++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Entity/Calendar.php
@@ -60,6 +60,29 @@ class Calendar
*/
private $url;
+ /**
+ * @var string
+ *
+ * @ORM\Column(name="login", type="string", nullable=true)
+ */
+ private $login;
+
+
+ /**
+ * @var string
+ *
+ * @ORM\Column(name="password", type="string", nullable=true)
+ */
+ private $password;
+
+
+ /**
+ * @var string
+ *
+ * @ORM\Column(name="salt", type="string", nullable=true)
+ */
+ private $salt;
+
/**
* @var string
*
@@ -103,6 +126,57 @@ class Calendar
return $this;
}
+ /* Password User */
+ public function setPassword($password)
+ {
+ $length = 8;
+ $cstrong = true;
+ $cipher = 'aes-128-cbc';
+
+ if (in_array($cipher, openssl_get_cipher_methods()))
+ {
+ $ivlen = openssl_cipher_iv_length($cipher);
+ $iv = openssl_random_pseudo_bytes($ivlen);
+ $this->salt = uniqid(mt_rand(), true);
+
+ $ciphertext_raw = openssl_encrypt($password, $cipher, $this->salt, $options=OPENSSL_RAW_DATA, $iv);
+ $hmac = hash_hmac('sha256', $ciphertext_raw, $this->salt, $as_binary=true);
+
+ $this->password = base64_encode( $iv.$hmac.$ciphertext_raw );
+ }
+
+ return $this;
+ }
+
+ public function setPasswordDirect($password)
+ {
+ $this->password = $password;
+ return $this;
+ }
+
+ public function getPassword()
+ {
+ return $this->password;
+ }
+
+ public function getPasswordDecrypt()
+ {
+ $c = base64_decode($this->password);
+ $cipher = 'aes-128-cbc';
+
+ if (in_array($cipher, openssl_get_cipher_methods()))
+ {
+ $ivlen = openssl_cipher_iv_length($cipher);
+ $iv = substr($c, 0, $ivlen);
+ $hmac = substr($c, $ivlen, $sha2len=32);
+ $ivlenSha2len = $ivlen+$sha2len;
+ $ciphertext_raw = substr($c, $ivlen+$sha2len);
+ $plainText = openssl_decrypt($ciphertext_raw, $cipher, $this->salt, $options=OPENSSL_RAW_DATA, $iv);
+ }
+
+ return $plainText;
+ }
+
/**
* Constructor
*/
@@ -242,6 +316,56 @@ class Calendar
return $this->url;
}
+ /**
+ * Set login
+ *
+ * @param string $login
+ *
+ * @return Calendar
+ */
+ public function setLogin($login)
+ {
+ $this->login = $login;
+
+ return $this;
+ }
+
+ /**
+ * Get login
+ *
+ * @return string
+ */
+ public function getLogin()
+ {
+ return $this->login;
+ }
+
+
+
+ /**
+ * Set salt
+ *
+ * @param string $salt
+ *
+ * @return Calendar
+ */
+ public function setSalt($salt)
+ {
+ $this->salt = $salt;
+
+ return $this;
+ }
+
+ /**
+ * Get salt
+ *
+ * @return string
+ */
+ public function getSalt()
+ {
+ return $this->salt;
+ }
+
/**
* Set roles
*
diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Form/CalendarType.php b/src/ninegate-1.0/src/Cadoles/PortalBundle/Form/CalendarType.php
index 85f29c7e..10a1ab2c 100644
--- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Form/CalendarType.php
+++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Form/CalendarType.php
@@ -9,6 +9,7 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
+use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -38,6 +39,7 @@ class CalendarType extends AbstractType
"choices" => [
"Interne" => '0',
"iCalendar (ICS)" => '1',
+ "CalDAV" => '2',
],
"disabled" => ($options["mode"]=="delete"?true:false),
])
@@ -45,6 +47,16 @@ class CalendarType extends AbstractType
->add('url', TextType::class, [
'label' => "URL",
'required' => false,
+ ])
+
+ ->add('login', TextType::class, [
+ 'label' => "Login",
+ 'required' => false,
+ ])
+
+ ->add('password', PasswordType::class, [
+ 'label' => "Password",
+ 'required' => false,
]);
if($options["access"]=="config") {
diff --git a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Calendar/edit.html.twig b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Calendar/edit.html.twig
index d6799a1f..49410141 100644
--- a/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Calendar/edit.html.twig
+++ b/src/ninegate-1.0/src/Cadoles/PortalBundle/Resources/views/Calendar/edit.html.twig
@@ -57,6 +57,11 @@
{{ form_row(form.url) }}
+
+ {{ form_row(form.login) }}
+ {{ form_row(form.password) }}
+
+
{% if form.roles is defined %}
@@ -84,9 +89,17 @@
function showhide() {
console.log($("#calendar_type").val());
- if($("#calendar_type").val()==1)
+ if($("#calendar_type").val()==1) {
$("#url").show();
- else
+ $("#login").hide();
+ }
+ else if($("#calendar_type").val()==2) {
+ $("#url").show();
+ $("#login").show();
+ }
+ else {
$("#url").hide();
+ $("#login").hide();
+ }
}
{% endblock %}