Page 1 of 1

Ticket system for cms made simple

Posted: Tue Jul 04, 2006 11:01 pm
by Lahuindai
Hello all,

I'm developing a ticket/servicedesk system for a company in cmsms, no question that there are many out there but none will do so here it is. I'm working on the install method currently of the module and have the following questions.

The module so far depends on CMSMailer and FrontEndUsers.

Firstly the Creation Process or method.install.php:
- I have created all the preferences for the system. There are sections in these and i would like to display them in tabs in the admin section. However these preferences will change in the future and for clients depending on requirements. How can i automagically create the tabs when it loads up in admin | is there an easy way or am i doing a smarty study ;) ?
- Do i create the default templates in the templates directory and load them into the database on the creation ? what are the pros and cons ?

Thanks everybody for the reply's and help and my apology if this is covered somehwere else (did a quick search but could not find anything)

Yes i'll release this once i have a working system if anybody is interested.

Regards
Gary

Re: Ticket system for cms made simple

Posted: Tue Jul 04, 2006 11:45 pm
by Elijah Lofgren
Lahuindai wrote: Firstly the Creation Process or method.install.php:
- I have created all the preferences for the system. There are sections in these and i would like to display them in tabs in the admin section. However these preferences will change in the future and for clients depending on requirements. How can i automagically create the tabs when it loads up in admin | is there an easy way or am i doing a smarty study ;) ?
Maybe something like this in action.defaultadmin.php:

Code: Select all


// The tabs
echo $this->StartTabHeaders();
$active_tab = isset($params['active_tab']) ? $params['active_tab'] : FALSE;
// Only show thecategories tab if the 'showcategoriestab' pref is set to 1
if ($this->GetPreference('showcategoriestab', 1))
{
    echo $this->SetTabHeader('categories', $this->Lang('categories'), ('categories' == $active_tab));
}
// Only show the template tab if the 'showtemplatetab' pref is set to 1
if ($this->GetPreference('showtemplatetab', 1))
{
    echo $this->SetTabHeader('templates',$this->Lang('Templates'), ('templates' == $active_tab));
}
if($this->CheckPermission('Modify Site Preferences'))
{
	echo $this->SetTabHeader('options', $this->Lang('options'), ('options' == $active_tab));
}
echo $this->EndTabHeaders();

echo $this->StartTabContent();

// Only show thecategories tab if the 'showcategoriestab' pref is set to 1
if ($this->GetPreference('showcategoriestab', 1))
{
    echo $this->StartTab('categories', $params);

    // Category tab code here

    echo $this->EndTab();
}

// Only show the template tab if the 'showtemplatetab' pref is set to 1
if ($this->GetPreference('showtemplatetab', 1))
{
    echo $this->StartTab('templates', $params);
    // Template tab code here
    echo $this->EndTab();
}

echo $this->EndTabContent();
Lahuindai wrote: - Do i create the default templates in the templates directory and load them into the database on the creation ? what are the pros and cons ?
If template wil need to be edited, then I would load them into the database. You can see an example of multiple templates being loaded into the database in the Album module. However, sometime I plan to make Album only load the default template template into the database and allow the other extra templates to be installed into the database from files. You can see the MenuManager module for an example of this.

If the templates will not need to be edited, then I would just process them from a file with something like:

Code: Select all

echo $this->ProcessTemplate('sometemplate.tpl');
That code assumes the 'sometemplate.tpl' file is in the templates directory.

If you have any more questions, check out the #cms channel on irc.freenode.net or just post back here.

Hope this helps,

Elijah

Re: Ticket system for cms made simple

Posted: Tue Jul 04, 2006 11:49 pm
by Lahuindai
Thank you Elijah, this is very helpfull indeed. Will come back with some more questions possibly as i'm creating user fields and groups from within the install method (FrontEndUser), so far so good though.

Re: Ticket system for cms made simple

Posted: Wed Jul 05, 2006 12:26 am
by calguy1000
Look at the FrontendUsers module for examples of the installation process, Creating Preferences, etc. and also for examples of using tabs.  The FrontendUsers module displays different tabs in the admin section based on a users permissions, etc.

Re: Ticket system for cms made simple

Posted: Wed Jul 05, 2006 2:53 am
by Lahuindai
How would one get a complete list of all the Preferences that you set during install and later in the modules life ?

For example inside a Module:

  $this->SetPreference($property['name'], $property['default']);

In the default admin section

  $preference_list = $this-> ???

I should clarify:
  The reaosn for this is that i want to create a smarty template that will loop through this list and create all the property/values in a tab ... :) thanks

Regards
Gary

Re: Ticket system for cms made simple

Posted: Wed Jul 05, 2006 3:10 am
by calguy1000
do an SQL query on the cms_db_prefix()."siteprefs" table.

i.e:

Code: Select all

SELECT * FROM cms_siteprefs WHERE sitepref_name REGEXP "Uploads_mapi_pref.*";

Re: Ticket system for cms made simple

Posted: Thu Jul 06, 2006 12:52 am
by Lahuindai
Ok next thing:

I have created a templates/default directory to house the default templates (cause i don't want them in the php). These will get loaded into the database when the module gets installed. The question is how do i get the templates directory, is there a function in the Module class that i have missed ?

Re: Ticket system for cms made simple

Posted: Thu Jul 06, 2006 3:02 am
by calguy1000
try:

Code: Select all

$path = $this->GetModulePath().DIRECTORY_SEPARATOR.'templates';

Re: Ticket system for cms made simple

Posted: Thu Jul 06, 2006 10:28 pm
by Lahuindai
Weird it returns the path as

/var/www/lib/modules/Servicedesk

instead of

/var/www/modules/Servicedesk

Looking at the base class the code would indicate that it should return
        if (is_subclass_of($this, 'CMSModule'))
        {
            return dirname(dirname(__FILE__)) . '/modules/' . $this->GetName();
        }

however it seems to be failing the is_subclass_of test. Any idea why this would be happening ?

Silly me, it was not failing and my hangover is not helping my debug skills

G

Re: Ticket system for cms made simple

Posted: Thu Jul 06, 2006 10:36 pm
by Lahuindai
I fixed this by changing the overiding the GetModulePath funtion in my class and changing it to

    /**
    * Returns the full path of the module directory.
    */
    function GetModulePath()
    {
        if (is_subclass_of($this, 'CMSModule'))
        {
            return dirname(dirname(dirname(__FILE__))) . '/modules/' . $this->GetName();
        }
        else
        {
            return dirname(__FILE__);
        }
    }

Is this a possible bug in CMSMS ?