diff options
Diffstat (limited to 'public/app/controllers')
| -rw-r--r-- | public/app/controllers/Auth.php | 82 | ||||
| -rw-r--r-- | public/app/controllers/Office.php | 20 |
2 files changed, 97 insertions, 5 deletions
diff --git a/public/app/controllers/Auth.php b/public/app/controllers/Auth.php index 9f440ed..cbf4d19 100644 --- a/public/app/controllers/Auth.php +++ b/public/app/controllers/Auth.php @@ -20,7 +20,7 @@ use app\extends\SendMail_service; */ class Auth { - /** login + /** AJAX POST: login * * checks visitor's credentials; * if valid, authenticates user @@ -98,7 +98,7 @@ class Auth { } - /** activate + /** AJAX POST: activate * resolves call POST:/account/activate * * @param void : all parametres passed via request->POST @@ -118,20 +118,50 @@ class Auth { if ($check != 0) { Render::json([ 'title' => ACCOUNT_ACTIVATED_TITLE, - 'message' => ACCOUNT_ACTIVATED_MESSAGE . '<br>(msg code: '. $check .')' + 'message' => ACCOUNT_ACTIVATED_MESSAGE . '<br>(msg code: '. $check .')' ]); } else { Render::json([ 'title' => NOT_VALID_ACTIVATION_TITLE, - 'message' => NOT_VALID_ACTIVATION_MESSAGE + 'message' => NOT_VALID_ACTIVATION_MESSAGE ]); } } - /** invitation + + /** AJAX POST: update_user + * + * resolves call POST:/user/update_properties; + * updates user's proiperties with POSTed data + * + * @param void : all parametres passed via request->POST + */ + public static function update_user() + { + $req = Registry::get('REQUEST'); + $manager = new App_manager(); + ; + // print_r($req->POST); die(); + + // ask model to update user; get user-id from user-manager + $check = Access_model::update_user( + $req->POST, + $manager->getUserToken()->getUser()->getID() + ); + + // TODO: message for user updating properties + Render::json([ + 'title' => ACCOUNT_ACTIVATED_TITLE, + 'message' => ACCOUNT_ACTIVATED_MESSAGE . '<br>(msg code: '. $check .')' + ]); + + } + + + /** SERVE FORM: invitation * * setups and renders the form for a certain invitation * @@ -188,6 +218,48 @@ class Auth { } + /** SERVE FORM: update_form + * + * renders a form with all user's properties + * + * NOTE: + * after form is submited, client shall call Auth::update_user() + * + */ + public static function update_form() + { + $user = json_decode(json_encode(self::user_data(), JSON_UNESCAPED_UNICODE)); + + // format form_setup to a json array + $form_setup = json_decode(json_encode(USER_PROPERTIES_FORM, JSON_UNESCAPED_UNICODE)); + + // get $key of position item inside the form_setup->form array + for( $i=0; $i < sizeof($form_setup->form) ; $i++ ) { + if ($form_setup->form[$i]->name == 'position') { $key = $i; } + } + + // prepare gendered options to position field + $positions = ($user->prefix != 'η') + ? GENDERED_POSITIONS['he'] + : GENDERED_POSITIONS['she']; + $gendered_position = json_decode( json_encode( $positions, JSON_UNESCAPED_UNICODE )); + $form_setup->form[$key]->options = $gendered_position; + + // attach default values + $form_setup->defaults = $user; + + // get Form's HTML and Jsvascript + $form = JsonToForm::json_form($form_setup, [ + // pass invitation identity for security + ['name' => 'id', 'value' => $user->id] + ]); // print_r($form_setup); die(); + + Render::view('user/update_properties', [ + 'form' => $form + ]); + } + + /** is_connected * checks if the user is connected * diff --git a/public/app/controllers/Office.php b/public/app/controllers/Office.php index 83135de..f57cf08 100644 --- a/public/app/controllers/Office.php +++ b/public/app/controllers/Office.php @@ -327,6 +327,26 @@ class Office { + public static function petition_copy($sign) + { + if (false) { //(Auth::in_admin_group()) { + $petition = Content_model::get_petition(['signature' => $sign]); + + } else { + $manager = new App_manager(); + $petition = Content_model::get_petition([ + 'signature' => $sign, + 'user_id' => $manager->getUserToken()->getUser()->getID() + ]); + } + if ($petition === false) Render::view('error/404'); + else { + Render::view( 'templates/create_pdf',['petition' => $petition]); + } + } + + + ## TICKET METHODS (create, remove) ## tickets eliminate CSRF attacks ## ------------------------------------------------------------------------- |
