Ticket system for cms made simple

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
User avatar
Lahuindai
Forum Members
Forum Members
Posts: 66
Joined: Mon Aug 01, 2005 11:00 am

Ticket system for cms made simple

Post 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
User avatar
Elijah Lofgren
Power Poster
Power Poster
Posts: 811
Joined: Mon Apr 24, 2006 1:01 am
Location: Deatsville, AL

Re: Ticket system for cms made simple

Post 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
Note: I don't have time to take on any more projects. I'm quite busy. I may be too busy to reply to emails or messages. Thanks for your understanding. :)
User avatar
Lahuindai
Forum Members
Forum Members
Posts: 66
Joined: Mon Aug 01, 2005 11:00 am

Re: Ticket system for cms made simple

Post 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.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Ticket system for cms made simple

Post 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.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
User avatar
Lahuindai
Forum Members
Forum Members
Posts: 66
Joined: Mon Aug 01, 2005 11:00 am

Re: Ticket system for cms made simple

Post 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
Last edited by Lahuindai on Wed Jul 05, 2006 2:58 am, edited 1 time in total.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Ticket system for cms made simple

Post 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.*";
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
User avatar
Lahuindai
Forum Members
Forum Members
Posts: 66
Joined: Mon Aug 01, 2005 11:00 am

Re: Ticket system for cms made simple

Post 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 ?
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Ticket system for cms made simple

Post by calguy1000 »

try:

Code: Select all

$path = $this->GetModulePath().DIRECTORY_SEPARATOR.'templates';
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
User avatar
Lahuindai
Forum Members
Forum Members
Posts: 66
Joined: Mon Aug 01, 2005 11:00 am

Re: Ticket system for cms made simple

Post 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
Last edited by Lahuindai on Thu Jul 06, 2006 11:01 pm, edited 1 time in total.
User avatar
Lahuindai
Forum Members
Forum Members
Posts: 66
Joined: Mon Aug 01, 2005 11:00 am

Re: Ticket system for cms made simple

Post 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 ?
Post Reply

Return to “Developers Discussion”