KTUserAssistancePlugin.php 4.95 KB
<?php

/**
 * $Id$
 *
 * Copyright (c) 2006 Jam Warehouse http://www.jamwarehouse.com
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; using version 2 of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * -------------------------------------------------------------------------
 *
 * You can contact the copyright owner regarding licensing via the contact
 * details that can be found on the KnowledgeTree web site:
 *
 *         http://www.ktdms.com/
 */

require_once(KT_LIB_DIR . '/dispatcher.inc.php');
require_once(KT_LIB_DIR . '/plugins/pluginregistry.inc.php');
require_once(KT_LIB_DIR . '/plugins/plugin.inc.php');
require_once(KT_LIB_DIR . '/dashboard/dashlet.inc.php');
require_once(KT_LIB_DIR . '/dashboard/DashletDisables.inc.php');
require_once(KT_LIB_DIR . "/templating/templating.inc.php");
require_once(KT_LIB_DIR . "/dashboard/Notification.inc.php");
require_once(KT_LIB_DIR . "/security/Permission.inc");

class KTUserAssistance extends KTPlugin {
    var $sNamespace = 'ktcore.userassistance';

    function setup() {
        //$this->registerDashlet('KTUserTutorialDashlet', 'ktcore.dashlet.usertutorial', __FILE__);
        //$this->registerDashlet('KTAdminTutorialDashlet', 'ktcore.dashlet.admintutorial', __FILE__);
        $this->registerPage('kt3b1-what-is-a-beta', 'KTUserAssistB1WhatIs', __FILE__);
        $this->registerPage('kt-bug-reporting-guide', 'KTUserAssistBugReportingGUide', __FILE__);
        $this->registerPage('admin-quickguide', 'KTUserAssistAdminQuickguide', __FILE__);
        $this->registerPage('admin-guide-whats-new-in-kt3', 'KTUserAssistAdminGuideWhatsNew', __FILE__);
    }
}

$oRegistry =& KTPluginRegistry::getSingleton();
$oRegistry->registerPlugin('KTUserAssistance', 'ktcore.userassistance', __FILE__);

// ultra simple skeleton for the user tutorial
// FIXME do we want to store the namespace inside the dashlet?
class KTUserTutorialDashlet extends KTBaseDashlet {
	function is_active($oUser) {
	    $namespace = 'ktcore.dashlet.usertutorial';
		$disables = KTDashletDisable::getForUserAndDashlet($oUser->getId(), $namespace);
		
		if (!empty($disables)) { 
		    return false;
		} else {
		    return true;
		}
	}
	
    function render() {
		$oTemplating =& KTTemplating::getSingleton();
		$oTemplate = $oTemplating->loadTemplate("ktcore/dashlets/usertutorial");
		$aTemplateData = array(
		);
		return $oTemplate->render($aTemplateData);
    }
}


// ultra simple skeleton for the admin tutorial
class KTAdminTutorialDashlet extends KTBaseDashlet {
	function is_active($oUser) {
	 
	    $namespace = 'ktcore.dashlet.admintutorial';

		if (!Permission::userIsSystemAdministrator($oUser->getId())) {
		    return false; // quickest disable.
		}
		
		$disables = KTDashletDisable::getForUserAndDashlet($oUser->getId(), $namespace);		
		if (!empty($disables)) { 
		    return false;
		} else {
		    return true;
		}
	}
	
    function render() {
		$oTemplating =& KTTemplating::getSingleton();
		$oTemplate = $oTemplating->loadTemplate("ktcore/dashlets/admintutorial");
		$aTemplateData = array(
		);
		return $oTemplate->render($aTemplateData);
    }
}

class KTUserAssistBasePage extends KTStandardDispatcher {
    var $sSection = 'help';
    var $aBreadcrumbs = array(
	    array('action' => 'dashboard', 'name' => 'Dashboard'),
		array('name' => 'User Assistance')
	);
    var $pagefile = 'base';
	var $title = 'User Assistance';
	function do_main() {
	    $this->oPage->setBreadcrumbDetails($this->title);
	    $contents = @file_get_contents(dirname(__FILE__) . '/docs/' . $this->pagefile);
		if ($contents === false) { 
		    $contents = '<div class="ktError"><p>Unable to find requested documentation.</p></div>';
		}
		$this->oPage->setTitle($this->title);
		$this->oPage->setShowPortlets(false);
		return $contents;
	}
	
	// hide the dashlet from the user (e.g. don't show it again) and redirect back to the dashboard.
}

class KTUserAssistB1WhatIs extends KTUserAssistBasePage { var $pagefile = 'kt3b1-what-is-a-beta'; var $title = 'What is a Beta?'; }

class KTUserAssistBugReportingGUide extends KTUserAssistBasePage { var $pagefile = 'kt-bug-reporting-guide'; var $title = 'Help! Something went wrong'; }

class KTUserAssistAdminQuickguide extends KTUserAssistBasePage { var $pagefile = 'admin-quickguide'; var $title = 'Quickstart Guide for Administrators'; }

class KTUserAssistAdminGuideWhatsNew extends KTUserAssistBasePage { var $pagefile = 'admin-guide-whats-new-in-kt3'; var $title = 'What\'s new in KT3 for Administrators'; }

?>