diff --git a/web/inc/classes/Model.class.php b/web/inc/classes/Model.class.php index 8980de0..432f27f 100644 --- a/web/inc/classes/Model.class.php +++ b/web/inc/classes/Model.class.php @@ -69,8 +69,10 @@ class Model { { if(isset($this->data[$field])) { - if($options['type']=='array') + if($options['type']=='array' && is_array($this->data[$field])) $GLOBALS['redis']->hset($this->dbTable.':'.$this->id,$field,json_encode($this->data[$field])); + else if($options['type']=='array' && !is_array($this->data[$field])) + $GLOBALS['redis']->hset($this->dbTable.':'.$this->id,$field,json_encode([])); else { $GLOBALS['redis']->hset($this->dbTable.':'.$this->id,$field,$this->data[$field]); @@ -101,9 +103,10 @@ class Model { case 'float': $value = floatval($value);break; case 'double': $value = doubleval($value);break; case 'array': - $value = json_decode($value,true); - if($value===null) + if(!$value) $value = []; + else if(is_string($value)) + $value = json_decode($value,true); break; } $this->data[$key] = $value; diff --git a/web/inc/helpers.php b/web/inc/helpers.php index 75fb14a..b08718a 100644 --- a/web/inc/helpers.php +++ b/web/inc/helpers.php @@ -246,8 +246,11 @@ function pictshareUploadImage($path,$hash=false) function partial($name,$variables=[]) { $templatefile = ROOT.DS.'templates'.DS.'partials'.DS.$name; - - //render template by running include + return template($name,$variables); +} + +function template($templatefile,$variables=[]) +{ ob_start(); if(is_array($variables)) extract($variables); diff --git a/web/pages/register/controller.php b/web/pages/register/controller.php index f7d71a9..4ce81cb 100644 --- a/web/pages/register/controller.php +++ b/web/pages/register/controller.php @@ -47,6 +47,7 @@ class Register extends Page { try { $u->save(); + $this->redirect('/register/success'); } catch(Exception $e) { @@ -55,7 +56,7 @@ class Register extends Page { $this->set('errorMessage', $e->getMessage()); return; } - //$this->redirect('/register/success'); + return; } diff --git a/web/pages/register/register.html b/web/pages/register/register.html index 1475aaf..2b0b3a3 100644 --- a/web/pages/register/register.html +++ b/web/pages/register/register.html @@ -9,11 +9,11 @@