Example #1
0
 /**
  * custom log in functionality, from custom log in page
  */
 static function login()
 {
     if (!isset($_POST[Kanban_Utils::get_nonce()]) || !wp_verify_nonce($_POST[Kanban_Utils::get_nonce()], 'login')) {
         return;
     }
     if (is_email($_POST['email'])) {
         $user = get_user_by('email', $_POST['email']);
         if (empty($user)) {
             Kanban::get_instance()->flash->add('danger', __('Whoops! We can\'t find an account for that email address.', Kanban::get_text_domain()));
             wp_redirect($_POST['_wp_http_referer']);
             exit;
         }
     } else {
         $user = get_user_by('login', $_POST['email']);
         if (empty($user)) {
             Kanban::get_instance()->flash->add('danger', __('Whoops! We can\'t find an account for that username.', Kanban::get_text_domain()));
             wp_redirect($_POST['_wp_http_referer']);
             exit;
         }
     }
     $creds = array();
     $creds['user_login'] = $user->user_login;
     $creds['user_password'] = $_POST['password'];
     $creds['remember'] = true;
     $user = wp_signon($creds, false);
     if (is_wp_error($user)) {
         Kanban::get_instance()->flash->add('danger', __('Whoops! That password is incorrect for this email address.', Kanban::get_text_domain()));
         wp_redirect($_POST['_wp_http_referer']);
         exit;
     }
     wp_set_current_user($user->ID);
     wp_set_auth_cookie($user->ID);
     wp_redirect(sprintf('%s/%s/board', site_url(), Kanban::$slug));
     exit;
 }
Example #2
0
    /**
     * load data needed for board's javascript
     * @param  string $template the passed in template path
     * @return string           the same template path
     */
    static function send_page_data_to_template($template)
    {
        // make sure we're looking at the board
        if (!isset(Kanban_Template::get_instance()->slug) || Kanban_Template::get_instance()->slug != self::$slug) {
            return $template;
        }
        // make sure they don't need to upgrade
        if (Kanban::get_instance()->settings->records_to_move > 0) {
            ?>
			<p>
			<?php 
            echo sprintf(__('We\'ve found %s kanban records that need to be migrated for the latest version of Kanban for WordPress!', Kanban::get_text_domain()), Kanban::get_instance()->settings->records_to_move);
            ?>
			</p>
			<p>
			<?php 
            echo sprintf(__('Please visit the <a href="%s">Kanban welcome page</a> to migrate your data.', Kanban::get_text_domain()), add_query_arg('page', 'kanban_welcome', admin_url('admin.php')));
            ?>
			<?php 
            exit;
        }
        // get the template data
        global $wp_query;
        // attach our object to the template data
        $wp_query->query_vars['kanban'] = (object) array();
        $wp_query->query_vars['kanban']->board = (object) array();
        // get all data for the javascript
        $wp_query->query_vars['kanban']->board->settings = Kanban_Option::get_all();
        $wp_query->query_vars['kanban']->board->allowed_users = Kanban_User::get_allowed_users();
        $wp_query->query_vars['kanban']->board->estimates = Kanban_Estimate::get_all();
        $wp_query->query_vars['kanban']->board->statuses = Kanban_Status::get_all();
        $wp_query->query_vars['kanban']->board->projects = Kanban_Project::get_all();
        $wp_query->query_vars['kanban']->board->tasks = Kanban_Task::get_all();
        // get the current user from the allowed users
        $current_user_id = get_current_user_id();
        $wp_query->query_vars['kanban']->board->current_user = $wp_query->query_vars['kanban']->board->allowed_users[$current_user_id];
        // figure out percentages here (easier, quicker than in js)
        $wp_query->query_vars['kanban']->board->col_percent_w = count($wp_query->query_vars['kanban']->board->statuses) > 0 ? 100 / count($wp_query->query_vars['kanban']->board->statuses) : 100;
        $wp_query->query_vars['kanban']->board->sidebar_w = count($wp_query->query_vars['kanban']->board->statuses) > 0 ? 100 / (count($wp_query->query_vars['kanban']->board->statuses) - 2) : 0;
        return $template;
    }
Example #3
0
?>
][title]" data-name="estimates[new][count][title]" value="<?php 
echo isset($title) ? $title : '';
?>
">
	</label>
	<label class="estimate-hours">
		<?php 
echo __('Hours', Kanban::get_text_domain());
?>
: 
		<input name="estimates[saved][<?php 
echo isset($id) ? $id : '';
?>
][hours]" data-name="estimates[new][count][hours]" value="<?php 
echo isset($hours) ? strtolower($hours) : '1';
?>
">
	</label>
	<input type="hidden" name="estimates[saved][<?php 
echo isset($id) ? $id : '';
?>
][position]" data-name="estimates[new][count][position]" value="<?php 
echo isset($position) ? sprintf('%03d', $position) : '';
?>
" class="position">
	<button type="button" class="delete"><?php 
echo __('Delete', Kanban::get_text_domain());
?>
</button>
</li>
Example #4
0
<div class="project">
	<input type="text" class="editable-input project_title" data-toggle="dropdown" data-id="{{=ID}}" value="{{=post_title}}" placeholder="<?php 
_e('Task project', Kanban::get_text_domain());
?>
" readonly>
	<ul class="list-group" style="display: none;">
		<li class="list-group-edit">
			<a href="#" class="btn btn-xs" data-toggle="modal" data-target="#modal-projects">
				<?php 
_e('Edit', Kanban::get_text_domain());
?>
			</a>
		</li>
	</ul>
</div>

Example #5
0
{{current_user_can_write}}
			<ul class="list-group" style="display: none;">
				<li class="list-group-edit">
					<a href="#" class="btn btn-xs btn-edit-projects" data-toggle="modal" data-target="#modal-projects">
						<?php 
_e('Edit', Kanban::get_text_domain());
?>
					</a>
				</li>
			</ul>
{{/current_user_can_write}}
		</div>

		<h3 class="h4 wrapper-task-title">
			<textarea class="editable-input task_title resize" rows="1" placeholder="<?php 
_e('Task name', Kanban::get_text_domain());
?>
" readonly>{{=task.title}}</textarea>
		</h3>

		<div class="row row-worked">
			<div class="col col-xs-4 col-task-hours">
				<div class="btn btn-default btn-task-hours">
				</div><!-- btn -->
{{current_user_can_write}}
				<div class="btn-group task-hours-operators">
					<button type="button" class="btn btn-default btn-sm" value="+{{=settings.hour_interval}}">
						<span class="glyphicon glyphicon-plus"></span>
					</button>
					<button type="button" class="btn btn-default btn-sm" value="-{{=settings.hour_interval}}">
						<span class="glyphicon glyphicon-minus"></span>
Example #6
0
 static function save_settings()
 {
     if (!isset($_POST[Kanban_Utils::get_nonce()]) || !wp_verify_nonce($_POST[Kanban_Utils::get_nonce()], sprintf('%s-%s', Kanban::get_instance()->settings->basename, Kanban_Option::table_name())) || !is_user_logged_in()) {
         return;
     }
     $statuses = Kanban_Status::get_all();
     $status_ids = array_keys($statuses);
     // any statuses to delete?
     if (isset($_POST['statuses']['saved'])) {
         $deleted_statuses = array_diff($status_ids, array_keys($_POST['statuses']['saved']));
         if (!empty($deleted_statuses)) {
             foreach ($deleted_statuses as $key => $id) {
                 Kanban_Status::delete(array('id' => $id));
             }
         }
     }
     // add new statuses first
     if (isset($_POST['statuses']['new'])) {
         foreach ($_POST['statuses']['new'] as $status) {
             // save it
             $success = Kanban_Status::replace($status);
             if ($success) {
                 $status_id = Kanban_Status::insert_id();
                 // add it to all the statuses to save
                 $_POST['statuses']['saved'][$status_id] = $status;
             }
         }
     }
     // now save all statuses with positions
     if (isset($_POST['statuses']['saved'])) {
         foreach ($_POST['statuses']['saved'] as $status_id => $status) {
             $status['id'] = $status_id;
             Kanban_Status::replace($status);
         }
     }
     $estimates = Kanban_Estimate::get_all();
     $estimate_ids = array_keys($estimates);
     // any estimates to delete?
     if (isset($_POST['estimates']['saved'])) {
         $deleted_estimates = array_diff($estimate_ids, array_keys($_POST['estimates']['saved']));
         if (!empty($deleted_estimates)) {
             foreach ($deleted_estimates as $key => $id) {
                 Kanban_Estimate::delete(array('id' => $id));
             }
         }
     }
     // add new estimates first
     if (isset($_POST['estimates']['new'])) {
         foreach ($_POST['estimates']['new'] as $estimate) {
             // save it
             $success = Kanban_Estimate::replace($estimate);
             if ($success) {
                 $estimate_id = Kanban_Estimate::insert_id();
                 // add it to all the estimates to save
                 $_POST['estimates']['saved'][$estimate_id] = $estimate;
             }
         }
     }
     // now save all estimates with positions
     if (isset($_POST['estimates']['saved'])) {
         foreach ($_POST['estimates']['saved'] as $estimate_id => $estimate) {
             $estimate['id'] = $estimate_id;
             Kanban_Estimate::replace($estimate);
         }
     }
     // get current settings
     $settings = Kanban_Option::get_all_raw();
     $settings = Kanban_Utils::build_array_with_id_keys($settings);
     // save all single settings
     foreach ($_POST['settings'] as $key => $value) {
         if (is_array($value)) {
             $value = serialize($value);
         }
         $data = array('name' => $key, 'value' => $value);
         // see if it's already set
         $id = Kanban_Utils::find_key_of_object_by_property('name', $key, $settings);
         if ($id) {
             $data['id'] = $id;
         }
         Kanban_Option::_replace($data);
     }
     $url = add_query_arg(array('message' => urlencode(__('Settings saved', Kanban::get_text_domain()))), $_POST['_wp_http_referer']);
     wp_redirect($url);
     exit;
 }
Example #7
0
    /**
     * show upgrade notice with progress bar
     */
    static function render_upgrade_notice()
    {
        // make sure something needs to be upgraded
        if (Kanban::get_instance()->settings->records_to_move <= 0) {
            return;
        }
        ?>
		<div class="updated error">
			<p style="font-size: 1.236em;">
				<b><?php 
        echo __('Warning!', Kanban::get_text_domain());
        ?>
</b>
				<?php 
        echo sprintf(__('We\'ve found %s kanban records that need to be migrated for the latest version of Kanban for WordPress!', Kanban::get_text_domain()), Kanban::get_instance()->settings->records_to_move);
        ?>
			</p>
			<p>
				<?php 
        echo __('Please click "migrate" below and we\'ll move them for you.', Kanban::get_text_domain());
        ?>
			</p>
			<p>
				<button type="button" class="button-primary" id="kanban-migrate-start">
					<?php 
        echo __('Migrate', Kanban::get_text_domain());
        ?>
				</button>
			</p>

			<div id="kanban-migrate-progress">
				<?php 
        echo __('Migration Progress', Kanban::get_text_domain());
        ?>
				<?php 
        echo __('(Please do not browse away from the page until migration is complete)', Kanban::get_text_domain());
        ?>
:
				<div id="kanban-migrate-progress-outer">
					<div id="kanban-migrate-progress-inner">
						&nbsp;
					</div><!-- inner -->
				</div><!-- outer -->
				<div id="kanban-migrate-message"></div>
			</div><!-- progress -->
		</div>
		<style>
		#kanban-migrate-progress {
			display: none;
			margin-bottom: 20px;
		}
		#kanban-migrate-progress-outer {
			background: #0073aa;
			padding: 3px;
			width: 100%;

		}
		#kanban-migrate-progress-inner {
			background: #00b9eb;
			font-size: 20px;
			overflow: hidden;
			position: relative;
			width: 1%;

			-webkit-transition: width 1s ease-in-out;
			-moz-transition: width 1s ease-in-out;
			-o-transition: width 1s ease-in-out;
			transition: width 1s ease-in-out;
		}
		#kanban-migrate-progress-inner:after {
		  content: "";
		  position: absolute;
		  top: 0; left: 0; bottom: 0; right: 0;
		  background-image: linear-gradient(
		    -45deg,
		    rgba(255, 255, 255, .2) 25%,
		    transparent 25%,
		    transparent 50%,
		    rgba(255, 255, 255, .2) 50%,
		    rgba(255, 255, 255, .2) 75%,
		    transparent 75%,
		    transparent
		  );
		  z-index: 1;
		  background-size: 50px 50px;
		  animation: move 2s linear infinite;
		  border-top-right-radius: 8px;
		  border-bottom-right-radius: 8px;
		  border-top-left-radius: 20px;
		  border-bottom-left-radius: 20px;
		  overflow: hidden;
		}

		@keyframes move {
			0% {
			background-position: 0 0;
			}
			100% {
			background-position: 50px 50px;
			}
		}
		</style>
		<script>
		jQuery(function($)
		{
			// start with how many records need to be migrated
			var records_to_move = <?php 
        echo Kanban::get_instance()->settings->records_to_move;
        ?>
;

			// if migration fails, show alert
			function migration_failed ()
			{
				alert('Migration failed. Please refresh the page and try again.');
			}

			// the loop to continually do migration, and update progress bar
			function do_migrate ()
			{
				$.post(
					ajaxurl,
					{
						action: 'kanban_migrate_db'
					}
				)
				.done(function(data)
				{
					try
					{
						var percentage = 100-((100 * parseInt(data.data.posts_remaining))/records_to_move);

						if ( percentage > 100 )
						{
							percentage = 100;
						}

						if ( percentage < 1 )
						{
							percentage = 1;
						}

						$('#kanban-migrate-progress-inner').css('width', percentage + '%');
					}
					catch (err)
					{
						migration_failed();
					}

					// update the returned message
					try
					{
						$('#kanban-migrate-message').text(data.data.message);
					}
					catch (err) {}

					// wait 2 seconds and do it again
					try
					{
						if ( data.data.continue )
						{
							setTimeout(function()
							{
								do_migrate();
							}, 2000);
						}
						else
						{
							if ( data.data.done )
							{
								$('#kanban-migrate-progress').html('<b style="font-size: 1.618em;">Migration has completed! <a href="<?php 
        echo site_url();
        ?>
/kanban/board" class="button button-primary" target="_blank">Go to your board</a>.</b>');
							}
							else
							{
								migration_failed();
							}
						}
					}
					catch (err)
					{
						migration_failed();
					}
				})
				.fail(function(data)
				{
					migration_failed();
					return false;
				});
			}; // do_migrate

			$('#kanban-migrate-start').on(
				'click',
				function()
				{
					$(this).hide();
					$('#kanban-migrate-progress').show();

					do_migrate();
				}
			)
		});
		</script>
		<?php 
    }
Example #8
0
 /**
  * Add a message to the queue
  * 
  * @author Mike Everhart
  * 
  * @param  string   $type        	The type of message to add
  * @param  string   $message     	The message
  * @param  string   $redirect_to 	(optional) If set, the user will be redirected to this URL
  * @return  bool 
  * 
  */
 public function add($type, $message, $redirect_to = null)
 {
     if (!isset($_SESSION['flash_messages'])) {
         return false;
     }
     if (!isset($type) || !isset($message[0])) {
         return false;
     }
     // Replace any shorthand codes with their full version
     if (strlen(trim($type)) == 1) {
         $type = str_replace(array('h', 'i', 'w', 'e', 's'), array('help', 'info', 'warning', 'error', 'success'), $type);
         // Backwards compatibility...
     } elseif ($type == 'information') {
         $type = 'info';
     }
     // Make sure it's a valid message type
     if (!in_array($type, $this->msgTypes)) {
         die(__('"' . strip_tags($type) . '" is not a valid message type!', Kanban::get_text_domain()));
     }
     // If the session array doesn't exist, create it
     if (!array_key_exists($type, $_SESSION['flash_messages'])) {
         $_SESSION['flash_messages'][$type] = array();
     }
     $_SESSION['flash_messages'][$type][] = $message;
     if (!is_null($redirect_to)) {
         header("Location: {$redirect_to}");
         exit;
     }
     return true;
 }
Example #9
0
<div class="btn btn-default btn-estimate" data-toggle="dropdown">
	<small><?php 
_e('Estimate:', Kanban::get_text_domain());
?>
</small>
	<b class="task-estimate">
		{{=kanban_task_estimate}}
	</b>
</div>
Example #10
0
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">

	<title><?php 
echo __('Kanban for WordPress', Kanban::get_text_domain());
?>
</title>

	<!--[if lt IE 9]>
		<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
		<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
	<![endif]-->

	<?php 
Kanban_Template::add_style();
?>
</head>
<body>
Example #11
0
		<div class="modal-content">
			<div class="modal-body">
				<p class="lead text-center" id="empty-archive-confirmation-label" data-label="<?php 
echo __('Delete all tasks in &quot;{0}&quot;?', Kanban::get_text_domain());
?>
">
				</p>
				<p class="text-center">
					<button type="button" class="btn btn-default" id="btn-empty-status-tasks-cancel" data-dismiss="modal">
						<?php 
echo __('Cancel', Kanban::get_text_domain());
?>
					</button>
					<button type="button" class="btn btn-primary" id="btn-empty-status-tasks" data-status-col-id="">
						<?php 
echo __('Archive', Kanban::get_text_domain());
?>
					</button>
				</p>
			</div>
		</div><!-- content -->
	</div><!-- dialog -->
</div><!-- modal -->




<div id="screen-size">
	<div class="visible-xs" data-size="xs"></div>
	<div class="visible-sm" data-size="sm"></div>
	<div class="visible-md" data-size="md"></div>
Example #12
0
 static function make_word_plural($word)
 {
     return substr($word, -1) == 's' ? __(sprintf('%ses', $word), Kanban::get_text_domain()) : __(sprintf('%ss', $word), Kanban::get_text_domain());
 }
Example #13
0
    ?>
				<?php 
    echo Kanban_Template::render_template('admin/t-estimate', (array) $estimate);
}
?>
			</ol><!-- sortable -->
			<p>
				<button type="button" class="button" id="add-estimate">
					<?php 
echo __('Add another estimate', Kanban::get_text_domain());
?>
				</button>
			</p>

			<?php 
submit_button(__('Save your Settings', Kanban::get_text_domain()), 'primary', 'submit');
?>
		</div><!-- tab-estimates -->



		<?php 
echo apply_filters(sprintf('%s_settings_tabs_content', Kanban::get_instance()->settings->basename), '');
?>



		<?php 
wp_nonce_field(sprintf('%s-%s', Kanban::$instance->settings->basename, Kanban_Option::table_name()), Kanban_Utils::get_nonce());
?>
Example #14
0
    wp_nonce_field('login', Kanban_Utils::get_nonce());
    ?>
				</div>
<?php 
} else {
    // is_user_logged_in
    ?>
				<p>
					<?php 
    echo __('Whoops, looks like you haven\'t been granted access yet. Click below to request access.', Kanban::get_text_domain());
    ?>
				</p>
				<p class="text-center">
					<button type="submit" class="btn btn-primary btn-lg">
						<?php 
    echo __('Request access', Kanban::get_text_domain());
    ?>
					</button>
					<?php 
    wp_nonce_field('request_access', Kanban_Utils::get_nonce());
    ?>
				</p>
<?php 
}
?>
			</div><!-- panel-body -->
		</div><!-- panel -->
	</form>


Example #15
0
			<span class="glyphicon glyphicon-th-large"></span>
		</button>
		<button type="button" class="btn btn-default">
			<input type="radio" name="view-compact" value="1" autocomplete="off">
			<span class="glyphicon glyphicon-align-justify"></span>
		</button>
	</div>



	<a href="<?php 
echo admin_url('admin.php?page=' . Kanban::$instance->settings->basename);
?>
" class="btn btn-default" target="_blank">
		<?php 
echo __('Admin', Kanban::get_text_domain());
?>
	</a>
</div>




<div class="modal fade" id="modal-projects" data-keyboard="false">
	<div class="modal-dialog modal-lg" role="document">
		<div class="modal-content">
			<div class="modal-body">
				<button type="button" class=" btn btn-default btn-close" data-dismiss="modal">
					Close
				</button>
Example #16
0
    static function welcome_page()
    {
        ?>
		<div class="wrap">
			<h1>
				<?php 
        echo __('About', Kanban::get_text_domain());
        ?>
 <?php 
        echo Kanban::get_instance()->settings->pretty_name;
        ?>
			</h1>

			<?php 
        if (isset($_GET['activation'])) {
            ?>
				<div class="updated notice is-dismissible below-h2">
					<p><?php 
            echo __('Thanks for using Kanban for WordPress!', Kanban::get_text_domain());
            ?>
</p>
					<button type="button" class="notice-dismiss">
						<span class="screen-reader-text"><?php 
            echo __('Dismiss this notice.', Kanban::get_text_domain());
            ?>
</span>
					</button>
				</div>
			<?php 
        }
        ?>

			<p>
				<a href="<?php 
        echo sprintf('%s/%s/board', home_url(), Kanban::$slug);
        ?>
" class="button" target="_blank">
					<?php 
        echo __('Go to your board', Kanban::get_text_domain());
        ?>
				</a>
			</p>

			<p>
				<a href="http://kanbanwp.com/documentation" target="_blank">
					<?php 
        echo __('Documentation', Kanban::get_text_domain());
        ?>
				</a>
			</p>
		</div>
		<?php 
    }
<div class="btn btn-default btn-work-hours" data-toggle="dropdown">
	<small><?php 
_e('Worked:', Kanban::get_text_domain());
?>
</small>
	<b class="task-work-hours">
		{{=kanban_task_work_hour_count}}
	</b>
</div><!-- btn -->
Example #18
0
	<p>
		<a href="<?php 
echo sprintf('%s/%s/board', home_url(), Kanban::$slug);
?>
" class="button-primary" target="_blank">
			<?php 
echo __('Go to your board', Kanban::get_text_domain());
?>
		</a>
		<a href="http://kanbanwp.com/documentation" class="button" target="_blank">
			<?php 
echo __('Documentation', Kanban::get_text_domain());
?>
			<?php 
echo __('(On kanbanwp.com)', Kanban::get_text_domain());
?>
		</a>
	</p>
	<h3>Intro to Kanban for WordPress</h3>
	<p>Get started with the plugin in 60 seconds.</p>
	<div class="video-wrapper" style="max-width: 1000px;">
		<iframe src="https://player.vimeo.com/video/145274368" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
	</div><!-- video-wrapper -->
<?php 
/*
	<h3>Intro to Kanban</h3>
	<p>New to kanban? Here's one of our favorite intrudctory videos.</p>
	<div class="video-wrapper">
		<iframe width="640" height="360" src="https://www.youtube-nocookie.com/embed/ueVXZUaWhYw?rel=0&amp;showinfo=0" frameborder="0" allowfullscreen></iframe>
	</div><!-- video-wrapper -->