protected final function __construct() { $course_post_type = \Ekko\Core\CoursePostType::singleton()->post_type(); add_submenu_page("edit.php?post_type={$course_post_type}", __('Ekko Cloud Videos', \Ekko\TEXT_DOMAIN), __('Cloud Videos', \Ekko\TEXT_DOMAIN), 'edit_posts', 'ekko-cloud-videos', array(&$this, 'display_page')); add_action('load-ekko-course_page_ekko-cloud-videos', array(&$this, 'init_videos_list'), 0, 0); add_action('load-ekko-course_page_ekko-cloud-videos', array(&$this, 'save_changes'), 10, 0); }
function prepare_items() { $this->_column_headers = array($this->get_columns(), array(), array()); $post = get_post($_REQUEST['post']); $course = \Ekko\Core\CoursePostType::singleton()->get_course($post); $hub = \Ekko\Core\Services\Hub::singleton(); $thekey = \Ekko\Core\Services\TheKey::singleton(); $this->items = array(); $enrolled = $hub->get_enrolled($course->course_ID); $course->set_transient('enrolled_users', $enrolled, 15 * MINUTE_IN_SECONDS); foreach ($enrolled as $guid) { $user = $thekey->get_user_by_guid($guid); if ($user instanceof \WP_User) { $this->items[] = $user; } else { if ($attributes = $thekey->get_user_attributes_by_guid($guid)) { $user = $thekey->create_user($attributes->guid, array('user_login' => $attributes->email, 'user_email' => $attributes->email, 'first_name' => $attributes->firstName, 'last_name' => $attributes->lastName, 'display_name' => "{$attributes->firstName} {$attributes->lastName}", 'nickname' => '')); if ($user instanceof \WP_User) { $this->items[] = $user; } } } } $this->set_pagination_args(array('total_items' => count($this->items), 'per_page' => 10, 'total_pages' => ceil(count($this->items) / 10))); }
public final function set_banner_image() { $post_ID = intval($_POST['post_id']); if (!current_user_can('edit_post', $post_ID)) { wp_die(-1); } $banner_id = intval($_POST['banner_id']); check_ajax_referer("update-post_{$post_ID}"); if ($banner_id == '-1') { if (delete_post_thumbnail($post_ID)) { wp_send_json_success(''); } else { wp_die(0); } } $course = \Ekko\Core\CoursePostType::singleton()->get_course($post_ID); if (set_post_thumbnail($course->ID, $banner_id)) { wp_send_json_success($this->banner_thumbnail_html($course)); } wp_die(0); }
public final function display_page() { $hub = \Ekko\Core\Services\Hub::singleton(); $post = get_post($_REQUEST['post']); $course = \Ekko\Core\CoursePostType::singleton()->get_course($post); $course_id = $course->course_ID; ?> <div class="wrap"> <div id="icon-post" class="icon32"><br /></div> <h2> <?php _e('Publish Course', \Ekko\TEXT_DOMAIN); ?> <a href="edit.php?post_type=ekko-course" class="add-new-h2">Return to Courses</a> </h2> <div class="ekko-bootstrap"> <div><h1><?php _e(sprintf('Publishing Course: %1$s', $course->post_title)); ?> </h1></div> <div class="well"> <p><?php if ($course_id === false) { $course_id = $hub->create_course($course->get_manifest()); } else { $hub->update_course($course_id, $course->get_manifest()); } $course->course_ID = $course_id; esc_html_e('Updating Course Manifest.', \Ekko\TEXT_DOMAIN); ?> </p> <p><?php esc_html_e('Processing Course Media:', \Ekko\TEXT_DOMAIN); $existing_resources = $hub->get_resources($course_id); $resources = $course->resources; ?> <ul><?php foreach ($resources as $resource) { if ($resource->type == 'file') { echo sprintf('<li>%1$s</li>', basename($resource->file)); if (!in_array($resource->sha1, $existing_resources['files'])) { $hub->upload_resource($course_id, $resource->file, $resource->mimeType); } } elseif ($resource->type == 'ecv') { echo sprintf('<li>%1$s</li>', basename($resource->title)); if (!in_array($resource->ecv_id, $existing_resources['videos'])) { $hub->add_course_to_video($resource->ecv_id, $course_id); } } } ?> </ul> </p><?php $result = $hub->publish_course($course_id); ?> <p class="<?php echo $result === true ? 'text-success' : 'text-error'; ?> "><?php if ($result === true) { esc_html_e('Course successfully published!', \Ekko\TEXT_DOMAIN); } else { echo '<strong>' . esc_html__('One or more Errors occured during publish', \Ekko\TEXT_DOMAIN) . ':</strong>'; if (is_array($result)) { foreach ($result as $error) { echo '<div>' . esc_html($error) . '</div>'; } } } ?> </p> </div> </div> </div> <?php $admins = array(); foreach (get_users() as $user) { $class = class_exists('\\GlobalTechnology\\CentralAuthenticationService\\CASLogin') ? \GlobalTechnology\CentralAuthenticationService\CASLogin::singleton() : \WPGCXPlugin::singleton(); $guid = $class->get_user_guid($user); if ($user->has_cap('administrator')) { $admins[] = $guid; } } $hub->sync_admins($course_id, $admins); }
public final function display_page() { $this->enrollment_list->prepare_items(); $post = get_post($_REQUEST['post']); $course = \Ekko\Core\CoursePostType::singleton()->get_course($post); ?> <div class="wrap"> <div id="icon-users" class="icon32"><br /></div> <h2> <?php _e('Enrollment', \Ekko\TEXT_DOMAIN); ?> : <?php esc_html_e($course->post_title); ?> <a href="edit.php?post_type=ekko-course" class="add-new-h2">Return to Courses</a> </h2> <br class="clear" /> <div id="col-container"> <div id="col-right"> <div class="col-wrap"> <h3>Students</h3> <form id="posts-filter" action="" method="post"> <input type="hidden" name="page" value="<?php echo $_REQUEST['page']; ?> " /> <?php $this->enrollment_list->display(); ?> <br class="clear" /> </form> </div> </div> <div id="col-left"> <div class="col-wrap"> <div class="form-wrap"> <?php $enrollment_type = $course->enrollment_type; ?> <h3><?php _e('Enrollment Type', \Ekko\TEXT_DOMAIN); ?> </h3> <form id="enrollmenttype" method="post" action="edit.php?post_type=ekko-course&page=ekko-enrollment" class="validate"> <input type="hidden" name="action" value="enrollment-type" /> <input type="hidden" name="post" value="<?php echo $course->ID; ?> " /> <?php wp_nonce_field('enrollment-type', '_wpnonce_enrollment-type'); ?> <div class="form-field"> <label> <input type="radio" name="enrollment-type" value="<?php echo $course::ENROLLMENT_PUBLIC; ?> " disabled<?php checked($course::ENROLLMENT_PUBLIC, $enrollment_type); ?> > <strong> <?php echo esc_html_x('Public', 'enrollment type', \Ekko\TEXT_DOMAIN); ?> </strong> <p><?php esc_html_e('Anyone may take this course without enrolling.', \Ekko\TEXT_DOMAIN); ?> </p> </label> </div> <div class="form-field"> <label> <input type="radio" name="enrollment-type" value="<?php echo $course::ENROLLMENT_OPEN; ?> "<?php checked($course::ENROLLMENT_OPEN, $enrollment_type); ?> > <strong> <?php echo esc_html_x('Open Enrollment', 'enrollment type', \Ekko\TEXT_DOMAIN); ?> </strong> <p><?php esc_html_e('Students may enroll in this course.', \Ekko\TEXT_DOMAIN); ?> </p> </label> </div> <div class="form-field"> <label> <input type="radio" name="enrollment-type" value="<?php echo $course::ENROLLMENT_APPROVAL; ?> "<?php checked($course::ENROLLMENT_APPROVAL, $enrollment_type); ?> > <strong> <?php echo esc_html_x('Approval Needed', 'enrollment type', \Ekko\TEXT_DOMAIN); ?> </strong> <p><?php esc_html_e('Students must request enrollment and be approved by instructors.', \Ekko\TEXT_DOMAIN); ?> </p> </label> </div> <div class="form-field"> <label> <input type="radio" name="enrollment-type" value="<?php echo $course::ENROLLMENT_MANAGED; ?> "<?php checked($course::ENROLLMENT_MANAGED, $enrollment_type); ?> > <strong> <?php echo esc_html_x('Instructor Managed', 'enrollment type', \Ekko\TEXT_DOMAIN); ?> </strong> <p><?php esc_html_e('Instructors will manage enrollment of students.', \Ekko\TEXT_DOMAIN); ?> </p> </label> </div> <?php submit_button(__('Update Enrollment Type', \Ekko\TEXT_DOMAIN)); ?> </form> </div> </div> </div> </div> </div> <?php }