Example #1
0
 public function do_update()
 {
     //$this->set_back_url("javascript:history.back()");
     $error_data = NULL;
     $this->div_container->set_attrib("class", "k1lib-crudlexs-update");
     $this->post_incoming_array = \k1lib\forms\check_all_incomming_vars($this->post_incoming_array);
     $update_result = $this->db_table->update_data($this->post_incoming_array, $this->db_table_data_keys[1], $error_data);
     if ($update_result !== FALSE) {
         $this->update_perfomed = TRUE;
         $this->updated = TRUE;
         DOM_notification::queue_mesasage(updating_strings::$data_updated, "success", $this->notifications_div_id);
         return TRUE;
     } else {
         $this->update_perfomed = FALSE;
         if (is_array($error_data) && !empty($error_data)) {
             $this->post_validation_errors = array_merge($this->post_validation_errors, $error_data);
         } elseif (is_string($error_data)) {
             DOM_notification::queue_mesasage($error_data, "alert", $this->notifications_div_id);
         }
         $this->updated = FALSE;
         DOM_notification::queue_mesasage(updating_strings::$data_not_updated, "warning", $this->notifications_div_id);
         return FALSE;
     }
 }
Example #2
0
 /**
  * @return \k1lib\html\div|boolean
  */
 public function start_board()
 {
     if (!parent::start_board()) {
         return FALSE;
     }
     if ($this->list_object->get_state()) {
         /**
          * BACK
          */
         if ($this->back_enable && isset($_GET['back-url'])) {
             $back_url = \k1lib\urlrewrite\get_back_url();
             $back_link = \k1lib\html\get_link_button($back_url, board_read_strings::$button_back);
             $back_link->append_to($this->button_div_tag);
         }
         /**
          * NEW BUTTON
          */
         $related_url_keys_text = url::get_url_level_value_by_name("related_url_keys_text");
         if (empty($related_url_keys_text)) {
             $related_url_keys_text = "";
             $new_link = \k1lib\html\get_link_button(url::do_url("../{$this->controller_object->get_board_create_url_name()}/" . $related_url_keys_text), board_list_strings::$button_new);
         } else {
             $related_url_keys_text .= "/";
             $new_link = \k1lib\html\get_link_button(url::do_url("../../{$this->controller_object->get_board_create_url_name()}/" . $related_url_keys_text), board_list_strings::$button_new);
         }
         if ($this->create_enable) {
             //                $new_link = \k1lib\html\get_link_button(url::do_url("../{$this->controller_object->get_board_create_url_name()}/" . $related_url_keys_text), board_list_strings::$button_new);
             //                $new_link = \k1lib\html\get_link_button("../{$this->controller_object->get_board_create_url_name()}/?back-url={$this_url}", board_list_strings::$button_new);
             $new_link->append_to($this->button_div_tag);
         }
         /**
          * Search
          */
         if ($this->search_enable) {
             $search_iframe = new \k1lib\html\iframe(url::do_url($this->controller_object->get_controller_root_dir() . "search/?just-controller=1&caller-url=" . urlencode($_SERVER['REQUEST_URI'])), 'utility-iframe', "search-iframe");
             //                $this->board_content_div->append_child_tail($search_iframe);
             DOM::html()->body()->append_child_tail($search_iframe);
             //                $search_iframe->append_to($this->board_content_div);
             $search_buttom = new \k1lib\html\a(NULL, " " . board_list_strings::$button_search, "_self");
             $search_buttom->set_id("search-button");
             $search_buttom->set_attrib("class", "button fi-page-search");
             $search_buttom->append_to($this->button_div_tag);
             if (isset($_POST) && isset($_POST['from-search']) && urldecode($_POST['from-search']) == $_SERVER['REQUEST_URI']) {
                 //                    if ($this->)
                 /**
                  * decrypt post field names
                  */
                 $incomming_search_data = \k1lib\forms\check_all_incomming_vars($_POST);
                 if ($this->list_object->get_do_table_field_name_encrypt()) {
                     $search_data = $this->list_object->decrypt_field_names($incomming_search_data);
                 } else {
                     $search_data = $incomming_search_data;
                 }
                 $this->controller_object->db_table->set_query_filter($search_data);
                 $search_post = \k1lib\common\serialize_var($_POST, urlencode($_SERVER['REQUEST_URI']));
                 /**
                  * Clear search
                  */
                 $clear_search_buttom = new \k1lib\html\a(url::do_url($_SERVER['REQUEST_URI']), board_list_strings::$button_search_cancel, "_self");
                 $search_buttom->set_value(" " . board_list_strings::$button_search_modify);
                 $clear_search_buttom->set_attrib("class", "button warning");
                 $clear_search_buttom->append_to($this->button_div_tag);
             } else {
                 $search_post = \k1lib\common\unset_serialize_var(urlencode($_SERVER['REQUEST_URI']));
             }
         }
         $this->data_loaded = $this->list_object->load_db_table_data($this->show_rule_to_apply);
         return $this->board_content_div;
     } else {
         DOM_notification::queue_mesasage(board_base_strings::$error_mysql_table_not_opened, "alert", $this->notifications_div_id);
         DOM_notification::queue_title(board_base_strings::$error_mysql);
         $this->list_object->make_invalid();
         $this->is_enabled = FALSE;
         return FALSE;
     }
 }
Example #3
0
 public function catch_post()
 {
     if (isset($_POST['magic_value'])) {
         $magic_test = \k1lib\common\check_magic_value("login_form", $_POST['magic_value']);
         if ($magic_test == TRUE) {
             unset($_POST['magic_value']);
             // the form was correct, so lets try to login
             /**
              * Check the _GET incomming vars
              */
             $form_values = \k1lib\forms\check_all_incomming_vars($_POST, "k1lib_login");
             /**
              * Login fields
              */
             if (isset($form_values[$this->user_login_input_name]) && isset($form_values[$this->user_password_input_name])) {
                 $this->user_login_input_value = $form_values[$this->user_login_input_name];
                 $this->user_password_input_value = self::$user_password_use_md5 ? md5($form_values[$this->user_password_input_name]) : $form_values[$this->user_password_input_name];
                 if (isset($form_values[$this->user_remember_me_input])) {
                     $this->user_remember_me_value = $form_values[$this->user_remember_me_input];
                 }
             } else {
                 return NULL;
             }
             //                $filter_array = [
             //                    $this->user_login_input_name => $this->user_login_input_value,
             //                    $this->user_password_input_name => $this->user_password_input_value,
             //                ];
             //                $this->db_table->set_query_filter($filter_array, TRUE);
             return $form_values;
         } else {
             return FALSE;
         }
     } else {
         DOM_notifications::queue_mesasage("There is not magic present here!", "alert");
         return NULL;
     }
 }
Example #4
0
 /**
  * This uses the post_incoming_array (Please verify it first) to make the insert.
  * NOTE: If the table has multiple KEYS the auto_number HAS to be on the first position, if not, the redirection won't works.
  * @param type $url_to_go
  * @return boolean TRUE on sucess or FALSE on error.
  */
 public function do_insert()
 {
     $error_data = NULL;
     $this->post_incoming_array = \k1lib\forms\check_all_incomming_vars($this->post_incoming_array);
     $this->inserted_result = $this->db_table->insert_data($this->post_incoming_array, $error_data);
     if ($this->inserted_result !== FALSE) {
         DOM_notification::queue_mesasage(creating_strings::$data_inserted, "success", $this->notifications_div_id);
         $this->inserted = TRUE;
         return TRUE;
     } else {
         if (is_array($error_data) && !empty($error_data)) {
             $this->post_validation_errors = array_merge($this->post_validation_errors, $error_data);
         }
         DOM_notification::queue_mesasage(creating_strings::$data_not_inserted, "warning", $this->notifications_div_id);
         $this->inserted = FALSE;
         return FALSE;
     }
 }
Example #5
0
 /**
  * Return an URL with NEW and EXISTENT GET values with no efford
  * @param type $url
  * @param array $new_get_vars
  * @param type $keep_actual_get_vars
  * @param array $wich_get_vars
  * @param type $keep_including
  * @return string
  */
 public static function do_url($url, array $new_get_vars = [], $keep_actual_get_vars = TRUE, array $wich_get_vars = [], $keep_including = TRUE)
 {
     if (!is_string($url)) {
         trigger_error("The value to make the link have to be a string", E_USER_ERROR);
     }
     /**
      * Separate URL, GET VARS and HASH
      */
     //Get the HASH part
     $hash = strstr($url, "#");
     // Clean the hash part from URL
     $url = str_replace($hash, "", $url);
     //Get the GET vars part
     $url_vars = strstr($url, "?", FALSE);
     // Clean the GET vars from URL
     $url = str_replace($url_vars, "", $url);
     // Now remove the ? from GET vars part
     //        $url_vars = str_replace("?", "", $url_vars);
     $url_var_array = \k1lib\common\explode_with_2_delimiters("&", "=", $url_vars, 1);
     /**
      * Catch all _GET vars
      */
     foreach ($_GET as $key => $value) {
         $_GET[$key] = urldecode($value);
     }
     $actual_get_vars = \k1lib\forms\check_all_incomming_vars($_GET);
     unset($actual_get_vars[\k1lib\URL_REWRITE_VAR_NAME]);
     /**
      * Join actual GET vars with the URL GET vars
      */
     $actual_get_vars = array_merge($actual_get_vars, $url_var_array);
     /**
      * We have to uset() the new vars from the ACTUAL _GET to avoid problems
      */
     foreach ($actual_get_vars as $var_name => $value) {
         if (key_exists($var_name, $new_get_vars)) {
             unset($actual_get_vars[$var_name]);
         }
     }
     $get_vars_to_add = [];
     if (!empty($new_get_vars)) {
         foreach ($new_get_vars as $var_name => $value) {
             $get_vars_to_add[] = "{$var_name}=" . urlencode($value);
         }
     }
     $get_var_to_keep = [];
     if ($keep_actual_get_vars) {
         if (!empty($wich_get_vars)) {
             foreach ($actual_get_vars as $var_name => $value) {
                 if (key_exists($var_name, array_flip($wich_get_vars))) {
                     if ($keep_including) {
                         $get_var_to_keep[] = "{$var_name}=" . urlencode($value);
                     } else {
                         unset($actual_get_vars[$var_name]);
                     }
                 }
             }
             if (!$keep_including) {
                 foreach ($actual_get_vars as $var_name => $value) {
                     $get_var_to_keep[] = "{$var_name}=" . urlencode($value);
                 }
             }
         } else {
             foreach ($actual_get_vars as $var_name => $value) {
                 $get_var_to_keep[] = "{$var_name}=" . urlencode($value);
             }
         }
     }
     $get_vars = array_merge($get_var_to_keep, $get_vars_to_add);
     /**
      * join the new get vars
      */
     if (!empty($new_get_vars) || !empty($get_vars)) {
         $get_vars_on_text = "?" . implode("&", $get_vars);
     } else {
         $get_vars_on_text = "";
     }
     $url_to_return = $url . $get_vars_on_text . $hash;
     return $url_to_return;
 }