public static function action($plugin_id, $object_name)
 {
     $object = new $object_name($plugin_id);
     $object->load_values_from_array($_POST['propertie'], 'php2db');
     $insert_id = $object->save();
     if ($insert_id) {
         q2w3_table_func::change_referer(q2w3_table::NEW_MARKER, $insert_id);
     }
 }
 public static function change_ref_after_del($id_col_name, $id)
 {
     q2w3_table_func::change_referer('&' . $id_col_name . '=' . $id, '');
     // remove deleted id from query string
     if (!(isset($_GET['last_record']) || isset($_POST['last_record']))) {
         return;
     }
     // continue if deleted record is last
     $page = strstr($_SERVER['HTTP_REFERER'], q2w3_table_page_filter::VAR_NAME);
     if ($page) {
         // if page var is set
         $next_var = strpos($page, '&');
         if ($next_var) {
             $page = substr($page, 0, $next_var);
         }
         // remove other vars from string
         $page_num = explode('=', $page);
         $page_num = intval($page_num[1]);
         // page number
     } else {
         // there is only one page
         $page_num = 1;
     }
     if ($page_num > 1) {
         // if this is not first page reset page number to 1
         q2w3_table_func::change_referer('&' . $page, '');
     } else {
         // if this is first page reset location filter var
         $location = strstr($_SERVER['HTTP_REFERER'], q2w3_table_location_filter::VAR_NAME);
         $next_var = strpos($location, '&');
         if ($next_var) {
             $location = substr($location, 0, $next_var);
         }
         if ($location) {
             q2w3_table_func::change_referer('&' . $location, '');
         }
     }
 }
Beispiel #3
0
 /**
  * Prepares user setting input befor save
  * 
  * Bind this function to WP 'set-screen-option' hook
  * 
  * @param array $new_settings
  * @return string Serialized array
  */
 public function user_settings_save($new_settings)
 {
     if (!is_array($new_settings)) {
         return $new_settings;
     }
     $old_settings = unserialize(get_user_option($this->user_options_var));
     if ($_GET[q2w3_table_page_filter::VAR_NAME] && $new_settings['settings']['rows_per_page'] != $old_settings['settings']['rows_per_page']) {
         q2w3_table_func::change_referer(q2w3_table_page_filter::VAR_NAME);
     }
     // if number of rows per page changed switch to first page
     $new_settings['settings']['rows_per_page'] = intval($new_settings['settings']['rows_per_page']);
     if ($new_settings['settings']['rows_per_page'] < 1 || $new_settings['settings']['rows_per_page'] > 999) {
         $new_settings['settings']['rows_per_page'] = $this->rows_per_page;
     }
     return serialize($new_settings);
 }