Browse Source

Bumped version to 0.0.46

Jannick Knudsen 4 năm trước cách đây
mục cha
commit
e1b1ffe632
7 tập tin đã thay đổi với 290 bổ sung18 xóa
  1. 1 1
      VERSION
  2. 1 0
      VERSIONLOG
  3. 1 1
      package.json
  4. 190 0
      plug_adminusers.php
  5. 87 9
      plug_login.php
  6. 8 5
      plug_mail.php
  7. 2 2
      plugin.php

+ 1 - 1
VERSION

@@ -1 +1 @@
-v0.0.45
+v0.0.46

+ 1 - 0
VERSIONLOG

@@ -44,3 +44,4 @@ v0.0.42
 v0.0.43
 v0.0.43
 v0.0.44
 v0.0.44
 v0.0.45
 v0.0.45
+v0.0.46

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "dagsplug",
   "name": "dagsplug",
-  "version": "0.0.45",
+  "version": "0.0.46",
   "description": "",
   "description": "",
   "main": "script_backend.js",
   "main": "script_backend.js",
   "scripts": {
   "scripts": {

+ 190 - 0
plug_adminusers.php

@@ -0,0 +1,190 @@
+<?php
+
+if (!class_exists("plug_adminusers")) {
+	class plug_adminusers {
+		function __construct($ns) {
+			$this->title = __("adminusers", "dagsopt");
+			$this->pluginname = $ns->pluginname;
+			$this->file = $ns->file;
+			$this->ns = $ns;
+		}
+		function start() {
+			add_action('manage_users_custom_column', array(&$this, 'imel_custom_column_userfield'), 15, 3);
+			add_filter('manage_users_columns', array(&$this, 'imel_column_userfield'), 15, 1);
+			add_filter('manage_users_sortable_columns', array(&$this, 'user_sortable_columns'), 15, 1);
+
+			if (is_admin()) {
+//prolly not necessary, but I do want to be sure this only runs within the admin
+				add_action('pre_user_query', array(&$this, 'my_user_query'));
+			}
+
+		}
+
+		function help() {
+			?>
+				<?php echo (__("Adds adminusers functions", "dagsopt")) ?>
+ 			<?php
+}
+
+		function Option($pre) {
+			//	update_option($pre . '_support_splash', $_POST[$pre . '_support_splash']);
+
+		}
+
+		function admin_line($pre) {
+			?>
+
+		 <hr>
+
+
+
+
+		  <?php
+}
+
+		function imel_column_userfield($defaults) {
+
+			$defaults['lastlogin'] = __('Seneste Login', 'lastlogin-column');
+			$defaults['lastview'] = __('Seneste Side', 'lastlogin-column');
+			$defaults['imel-login-userfield'] = __('Ældste Session', 'login-column');
+			$defaults['imel-login2-userfield'] = __('Nyeste Session', 'login2-column');
+			$defaults['imel-usercolumn-userfield'] = __('Pro/Select', 'user-column');
+			$defaults['imel-navn-userfield'] = __('Navn', 'navn-column');
+			$defaults['session'] = __('sessions', 'session-column');
+			$defaults['id'] = __('id', 'id-column');
+
+			return $defaults;
+
+		}
+
+		function user_sortable_columns($columns) {
+			$columns['session'] = 'session';
+			$columns['id'] = 'id';
+			$columns['lastlogin'] = 'lastlogin';
+			$columns['lastview'] = 'lastview';
+			return $columns;
+		}
+
+		function my_user_query($userquery) {
+			if ('session' == $userquery->query_vars['orderby']) {
+				global $wpdb;
+				$userquery->query_from .= " LEFT OUTER JOIN $wpdb->usermeta AS alias ON ($wpdb->users.ID = alias.user_id) "; //note use of alias
+				$userquery->query_where .= " AND alias.meta_key = 'session_tokens' "; //which meta are we sorting with?
+				$userquery->query_orderby = " ORDER BY length(alias.meta_value) " . ($userquery->query_vars["order"] == "ASC" ? "asc " : "desc "); //set sort order
+			}
+
+			if ('lastlogin' == $userquery->query_vars['orderby']) {
+				global $wpdb;
+				$userquery->query_from .= " LEFT OUTER JOIN $wpdb->usermeta AS alias ON ($wpdb->users.ID = alias.user_id) "; //note use of alias
+				$userquery->query_where .= " AND alias.meta_key = 'last_login' "; //which meta are we sorting with?
+				$userquery->query_orderby = " ORDER BY alias.meta_value " . ($userquery->query_vars["order"] == "ASC" ? "asc " : "desc "); //set sort order
+			}
+			if ('lastview' == $userquery->query_vars['orderby']) {
+				global $wpdb;
+				$userquery->query_from .= " LEFT OUTER JOIN $wpdb->usermeta AS alias ON ($wpdb->users.ID = alias.user_id) "; //note use of alias
+				$userquery->query_where .= " AND alias.meta_key = 'last_view' "; //which meta are we sorting with?
+				$userquery->query_orderby = " ORDER BY alias.meta_value " . ($userquery->query_vars["order"] == "ASC" ? "asc " : "desc "); //set sort order
+			}
+
+			if ('id' == $userquery->query_vars['orderby']) {
+				global $wpdb;
+				//$userquery->query_from .= " LEFT OUTER JOIN $wpdb->usermeta AS alias ON ($wpdb->users.ID = alias.user_id) "; //note use of alias
+				//$userquery->query_where .= " AND alias.meta_key = 'session_tokens' "; //which meta are we sorting with?
+				$userquery->query_orderby = " ORDER BY ID " . ($userquery->query_vars["order"] == "ASC" ? "asc " : "desc "); //set sort order
+			}
+		}
+
+		function imel_custom_column_userfield($value, $column_name, $id) {
+
+			if ($column_name == 'lastlogin') {
+
+				$ss = get_user_meta($id, 'last_login', true);
+				if ($ss) {
+					$the_login_date = human_time_diff($ss);
+					return $the_login_date;
+
+				} else {
+					return " ";
+				}
+			}
+
+			if ($column_name == 'lastview') {
+
+				$ss = get_user_meta($id, 'last_view', true);
+				if ($ss) {
+					$the_login_date = human_time_diff($ss);
+					return $the_login_date;
+
+				} else {
+					return " ";
+				}
+			}
+
+			if ($column_name == 'imel-usercolumn-userfield') {
+
+				return get_user_meta($id, 'Proselect', true);
+
+			}
+			if ($column_name == 'id') {
+
+				return $id;
+
+			}
+			if ($column_name == 'imel-navn-userfield') {
+
+				return get_user_meta($id, 'Navn', true);
+
+			}
+
+			if ($column_name == 'session2') {
+
+				$ss = get_user_meta($id, 'session_tokens', true);
+				if ($ss) {
+					$s = "";
+					foreach ($ss as $name => $obj) {
+						//	$s .= human_time_diff($obj['login']) . " " . $obj['ua'] . "\n";
+						$s .= human_time_diff($obj['login']) . " <br> ";
+					}
+					return $s;
+				} else {
+					return "N";
+				}
+			}
+			if ($column_name == 'session') {
+
+				$ss = get_user_meta($id, 'session_tokens', true);
+				if ($ss) {
+					$s = "";
+					$i = 0;
+					foreach ($ss as $name => $obj) {
+						if ($i < 2) {
+							$s .= human_time_diff($obj['login']) . "   ";
+						}
+						$i++;
+					}
+
+					return count($ss) . ' | ' . $s . '';
+				} else {
+					return "N";
+				}
+			}
+			if ($column_name == 'imel-login2-userfield') {
+
+				$ss = get_user_meta($id, 'session_tokens', true);
+				if ($ss) {
+					//$f = array_pop(array_keys($ss));
+					//return human_time_diff($ss[$f]['login']);
+					return "L";
+				} else {
+					return "N";
+				}
+			}
+		}
+
+	}
+
+	global $plug_adminusers;
+	$plug_adminusers = new plug_adminusers($this);
+	$this->dagsopt['plug_adminusers'] = $plug_adminusers;
+
+}

+ 87 - 9
plug_login.php

@@ -26,6 +26,9 @@ if (!class_exists("plug_login")) {
 			}
 			}
 			add_action('login_head', array(&$this, 'login_head'));
 			add_action('login_head', array(&$this, 'login_head'));
 
 
+			add_action('user_register', array(&$this, 'plugin_user_register'), 10, 3);
+			add_action('personal_options_update', array(&$this, 'plugin_user_register'), 10, 3);
+
 			add_action('admin_enqueue_scripts', function () {
 			add_action('admin_enqueue_scripts', function () {
 				/*
 				/*
 					    if possible try not to queue this all over the admin by adding your settings GET page val into next
 					    if possible try not to queue this all over the admin by adding your settings GET page val into next
@@ -49,14 +52,22 @@ if (!class_exists("plug_login")) {
 				return $mime_types;
 				return $mime_types;
 			}, 1, 1);
 			}, 1, 1);
 
 
-			add_action('admin_footer', function () {
+			add_action('register_post', array(&$this, 'register_post'), 10, 3);
+			add_action('edit_user_profile', array(&$this, 'plugin_show_user_profile'), 10, 3);
+			add_action('admin_footer', array(&$this, 'admin_footer'), 10, 3);
 
 
-				/*
+		}
+
+//add_action('show_user_profile', 'plugin_show_user_profile');
+
+		function admin_footer() {
+
+			/*
 					    if possible try not to queue this all over the admin by adding your settings GET page val into next
 					    if possible try not to queue this all over the admin by adding your settings GET page val into next
 					    if( empty( $_GET['page'] ) || "my-settings-page" !== $_GET['page'] ) { return; }
 					    if( empty( $_GET['page'] ) || "my-settings-page" !== $_GET['page'] ) { return; }
 				*/
 				*/
 
 
-				?>
+			?>
 
 
     <script>
     <script>
         jQuery(document).ready(function($){
         jQuery(document).ready(function($){
@@ -131,9 +142,32 @@ if (!class_exists("plug_login")) {
     </script>
     </script>
 
 
     <?php
     <?php
-});
+}
+
+		function plugin_show_user_profile($user) {
+
+			?>
+    <h3><?php _e('Pro/Select information')?></h3>
+    <table class="form-table">
+    <tr>
+
+        <td><input type="hidden" name="r_proselect" id="r_proselect" value="<?php echo $user->Proselect; ?>" /><?php echo $user->Proselect; ?></td>
+   </tr>
+    <tr>
+        <th><label for="Navn"><?php _e('Navn');?></label></th>
+        <td><input type="text" name="r_navn" id="r_navn" value="<?php echo $user->Navn; ?>" /></td>
+   </tr>
+    <tr>
+        <th><label for="Medlem af"><?php _e('Medlem af');?></label></th>
+        <td><input type="text" name="r_membership" id="r_membership" value="<?php echo $user->Gruppe; ?>" /></td>
+   </tr>
+
+
+    </table>
+    <?php
 
 
 		}
 		}
+
 		function replace_howdy($wp_admin_bar) {
 		function replace_howdy($wp_admin_bar) {
 			$my_account = $wp_admin_bar->get_node('my-account');
 			$my_account = $wp_admin_bar->get_node('my-account');
 			$newtitle = str_replace('Hejsa,', 'Velkommen,', $my_account->title);
 			$newtitle = str_replace('Hejsa,', 'Velkommen,', $my_account->title);
@@ -259,22 +293,67 @@ body {
 						$str .= apply_filters('the_content', $page->post_content);
 						$str .= apply_filters('the_content', $page->post_content);
 
 
 					} else {
 					} else {
-						$str .= get_option($this->pluginname . "_login_support_splash_" . $_GET['action'], false);
+						$str .= stripslashes(get_option($this->pluginname . "_login_support_splash_" . $_GET['action'], false));
 
 
 					}
 					}
 
 
 				} else {
 				} else {
-					$str .= get_option($this->pluginname . "_login_support_splash_" . $_GET['action'], false);
+					$str .= stripslashes(get_option($this->pluginname . "_login_support_splash_" . $_GET['action'], false));
 
 
 				}
 				}
 			} else {
 			} else {
-				$str .= get_option($this->pluginname . "_login_support_splash", false);
+				$str .= stripslashes(get_option($this->pluginname . "_login_support_splash", false));
 			}
 			}
 			$str .= '</p></div>';
 			$str .= '</p></div>';
 
 
 			return $str;
 			return $str;
 		}
 		}
 
 
+		function plugin_user_register($id) {
+			$user_info = get_userdata($id);
+
+			update_user_meta($id, 'Proselect', $_POST['r_proselect']);
+
+			update_user_meta($id, 'Navn', $_POST['r_navn']);
+
+			update_user_meta($id, 'Gruppe', $_POST['r_membership']);
+
+			//   update_usermeta($id, 'Institution'	, $_POST['r_institution'] );
+			//   update_usermeta($id, 'Fag'			, $_POST['r_fag'] );
+			//   update_usermeta($id, 'Fødselsår'		, $_POST['r_alder'] );
+
+		}
+
+		function register_post($login, $email, $errors) {
+
+			if (empty($_POST['r_proselect'])) {
+				$_POST['r_proselect'] = "Perspektiv";
+
+			}
+
+			if (empty($_POST['r_navn'])) {
+				$errors->add('demo_error', __('Du skal udfylde Navn'));
+			}
+			;
+			if (empty($_POST['r_membership']) || $_POST['r_membership'] === "Vælg gruppe") {
+				$errors->add('demo_error', __('Du skal udfylde Gruppe'));
+			}
+			;
+/*  	if(empty($_POST['r_fag'])){
+$errors->add('demo_error',__('Du skal udfylde Fag'));
+};
+if(empty($_POST['r_alder'])){
+$errors->add('demo_error',__('Du skal udfylde Alder'));
+}else{
+$alder = intval($_POST['r_alder']);
+if($alder < 1900 || $alder > 2005){
+$errors->add('demo_error',__('hmmm.. din alder virker mystisk'));
+};
+};
+ */
+
+		}
+
 		function help() {
 		function help() {
 			?>
 			?>
 				<?php echo (__("Adds logo to login page", "dagsopt")) ?>
 				<?php echo (__("Adds logo to login page", "dagsopt")) ?>
@@ -284,7 +363,7 @@ body {
 
 
 		function login_head() {
 		function login_head() {
 			$type = isset($_GET['type']) ? $_GET['type'] : 'default';
 			$type = isset($_GET['type']) ? $_GET['type'] : 'default';
-			if ($type !== "default") {
+			if ($type !== "!!default") {
 				?>
 				?>
 		<script type='text/javascript' src='/wp-includes/js/jquery/jquery.js?ver=1.4.2'></script>
 		<script type='text/javascript' src='/wp-includes/js/jquery/jquery.js?ver=1.4.2'></script>
 		<script type="text/javascript">
 		<script type="text/javascript">
@@ -331,7 +410,6 @@ body {
 }
 }
 			?>
 			?>
 
 
-		<link rel="stylesheet" href="<?php bloginfo('stylesheet_directory');?>/style2.css">
 
 
 
 
 <?php
 <?php

+ 8 - 5
plug_mail.php

@@ -29,12 +29,12 @@ if (!class_exists("plug_mail")) {
 
 
 		function help() {
 		function help() {
 			?>
 			?>
-				<?php echo (__("Adds mail functions", "dagsopt")) ?>
+				<?php echo (__("Adds mail log functions", "dagsopt")) ?>
  			<?php
  			<?php
 }
 }
 
 
 		function Option($pre) {
 		function Option($pre) {
-			update_option($pre . '_support_splash', $_POST[$pre . '_support_splash']);
+			//	update_option($pre . '_support_splash', $_POST[$pre . '_support_splash']);
 
 
 		}
 		}
 
 
@@ -43,13 +43,16 @@ if (!class_exists("plug_mail")) {
 
 
 		 <hr>
 		 <hr>
 
 
+		 	<?php
+$data = file_get_contents(ABSPATH . "/wp-content/uploads/maillog.log");
 
 
+			?>
+<textarea class="" rows="8" style="width: 100%; font-size: 11px;">
+<?php echo ($data) ?>
+</textarea>
 
 
 
 
 
 
-		  <?php echo (__("mail splash html register:", "dagsopt")) ?><br><textarea style="width: 100%; height: 150px;" name="<?php echo ($pre . '_support_splash'); ?>"><?php echo (stripslashes(get_option($pre . "_support_splash"))); ?></textarea>
-
-
 
 
 
 
 
 

+ 2 - 2
plugin.php

@@ -4,7 +4,7 @@ Plugin Name: dagsopt
 Plugin URI: https://git.tum.dk/tum.dk/dagsplug/
 Plugin URI: https://git.tum.dk/tum.dk/dagsplug/
 Description: Tools
 Description: Tools
 Author: iskedk
 Author: iskedk
-Version: 0.0.45
+Version: 0.0.46
 Date: 2021-01-14
 Date: 2021-01-14
 Author URI: https://iske.dk/
 Author URI: https://iske.dk/
 Text Domain: dagsopt
 Text Domain: dagsopt
@@ -17,7 +17,7 @@ function wppluginspage() {
 $wp_dagsopt = new dagsopt();
 $wp_dagsopt = new dagsopt();
 
 
 class dagsopt {
 class dagsopt {
-	var $version = "0.0.45";
+	var $version = "0.0.46";
 	var $publish_date = "2021-01-14";
 	var $publish_date = "2021-01-14";
 	var $pluginname;
 	var $pluginname;
 	var $plugintitle;
 	var $plugintitle;