diff --git a/uc-people-widget.php b/uc-people-widget.php
index 2efc742..3748fbd 100644
--- a/uc-people-widget.php
+++ b/uc-people-widget.php
@@ -28,7 +28,7 @@ Class UC_People_Widget extends WP_Widget {
$r = strnatcasecmp( $orderGroupA, $orderGroupB );
if( $r === 0 ){
- $r = strnatcasecmp( $a, $b ); // If groups have the same order, group them by name alphabetically
+ $r = strnatcasecmp( $a, $b );
}
return $r;
}
@@ -81,7 +81,12 @@ Class UC_People_Widget extends WP_Widget {
} elseif( $f == 'email' && in_array( 'email', $information_to_display ) ){
$out .= '
'.get_field('email', $id ).''.'
';
} else if( $f == 'title' && in_array( 'title', $information_to_display ) ){
- $out .= ''.get_field('title', $id ).'
';
+ $out .= '';
+ $titlePieces = explode(";", get_field('title', $id ));
+ foreach( $titlePieces as $t ){
+ $out .= ( !empty($t) ? "{$t}
": "" );
+ }
+ $out .= '
';
} else {
if ( in_array($f, $information_to_display) ) {
$out .= ''.get_field($f, $id ).'
';
@@ -162,9 +167,16 @@ Class UC_People_Widget extends WP_Widget {
foreach( $this->fields as $f ){
if( $f == 'file' && in_array('file', $information_to_display) ){
$file = get_field('file', $id );
- $out .= ''.$file[title].'';
+ $out .= ' | '.$file[title].' | ';
} else if( $f == 'email' && in_array('email', $information_to_display) ){
$out .= ''.get_field('email', $id ).' | ';
+ } else if( $f == 'title' && in_array('title', $information_to_display) ){
+ $out .= '';
+ $titlePieces = explode(";", get_field('title', $id ));
+ foreach( $titlePieces as $t ){
+ $out .= ( !empty($t) ? "{$t} ": "" );
+ }
+ $out .= ' | ';
} else {
$out .= $this->createTextCell($f, $information_to_display, $id );
}
diff --git a/uc-people.php b/uc-people.php
index 427ce24..c36ca08 100644
--- a/uc-people.php
+++ b/uc-people.php
@@ -2,7 +2,7 @@
/**
* Plugin Name: UC People
* Description: Displays information about people, a replacement for UUP.
- * Version: 1.0
+ * Version: 1.1
* Author: Andrew Bacon and Salman Kaleem of UITS Web Dev
*/
@@ -11,7 +11,7 @@ if ( ! defined( 'WPINC' ) ) {
die;
}
require 'acf-export.php';
-require_once(WP_CONTENT_DIR . '/ldap.php');
+//require_once(WP_CONTENT_DIR . '/ldap.php');
include 'uc-people-widget.php';
function create_custom_custom_post_type(){
@@ -32,7 +32,7 @@ function create_custom_custom_post_type(){
'public' => true,
'menu_position' => 35,
'menu_icon' => 'dashicons-groups',
- 'supports' => array( 'tags', 'thumbnail', 'revisions', 'page-attributes', 'author' ),
+ 'supports' => array( 'title', 'tags', 'thumbnail', 'revisions', 'page-attributes', 'author' ),
'has_archive' => true,
'rewrite' => array(
'slug' => '/person'
@@ -181,6 +181,8 @@ function importFile( $filename ){
$data = processCSV( $uploadedFile['file'] );
$fields = array(
+ 'netid' => 'NetID',
+ 'role' => 'Role',
'first_name' => 'First Name',
'last_name' => 'Last Name',
'title' => 'Title',
@@ -197,6 +199,17 @@ function importFile( $filename ){
);
foreach( $data as $k => $v ){
+ $user = username_exists( $v['NetID'] );
+ $postAuthorFlag = false;
+ if( $user != false && is_user_member_of_blog($user, get_current_blog_id() ) ){
+ $postAuthorFlag = true;
+ $role = $v['Role'];
+ if( $role == 'profile_user' ){
+ $userObject = new WP_User( $user );
+ $userObject->remove_role('profile_user');
+ $userObject->add_role('contributor');
+ }
+ }
$title = $v['First Name'].' '.$v['Last Name'];
$args = array(
'post_title' => $title,
@@ -204,11 +217,15 @@ function importFile( $filename ){
'post_status' => 'publish',
'post_type' => 'person',
'menu_order' => ( !empty($v['Order']) ? $v['Order'] : 0 ),
+ 'post_author' => ( $postAuthorFlag == true ? $user: get_current_user_id() ),
);
$id = wp_insert_post( $args, true );
wp_set_object_terms( $id, explode(' ', $v['Tags']), 'tag' );
set_post_thumbnail( $id, intval($v['Profile Image']) );
foreach ($fields as $l => $w) {
+ if( $l == 'netid' || $l == 'role' ){
+ continue;
+ }
update_field($l, $v[$w], $id);
}
}
@@ -219,6 +236,8 @@ function importFile( $filename ){
}
}
+
+
function uc_people_settings_page_menu(){
add_submenu_page('tools.php', 'Import People', 'Import People', 'manage_options', 'uc-import-people', 'uc_people_settings_page' );
}