You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2012-10-30 13:25:55

morpheuz
Member
Registered: 2012-10-30
Posts: 8

ICAL export (custom)

it is possible to customize the variables that exports the ICAL? if yes how to do? needed to have something like:

Title: data: description, summary



--------
il est possible de personnaliser les variables qui exporte l'ENTS? si oui, comment faire? besoin d'avoir quelque chose comme:

Titre: données: description, résumé

Offline

#2 2012-10-31 09:56:39

tomolimo
Member
From: Grenoble, France
Registered: 2009-05-12
Posts: 515

Re: ICAL export (custom)

I did that yesterday, you have to modify the file "planning.class.php" in the "inc" folder.
the function to be modified is:

static function generateIcal($who,$who_group)

You have to comment the line:

// TOM     $v->setConfig( 'filename', "glpi.ics" );

and you can add some HTML text like following:

            if (isset($val["content"])) {
               $vevent->setProperty( "description", html_clean($val["content"]) );
// TOM added following line
               $vevent->setProperty( "X-ALT-DESC;FMTTYPE=text/html","<HTML><BODY><a href=\"".$CFG_GLPI["url_base"]."/index.php?redirect=tracking_".
                                       $val["tickets_id"]."\">Ticket #".$val["tickets_id"]."</a><P>".$val["content"]."</P></BODY></HTML>");
            } else if (isset($val["name"])) {
               $vevent->setProperty( "description", $val["name"] );
            }

Like this you can add whatever you want to your ical...
regards,
Tomolimo


GLPI 9.2.4 - PHP 7.2.13 x64 / ProcessMaker 3.3.0-community-RE-1.7 - PHP 7.1.24 x64 / Windows 2012 x64 / IIS 8.5 / MySQL 5.7.17 x64
Worldwide: >12316 PC, >9400 users (16 languages, >11 timezones), >360k tickets, >3600 entities, >4200 groups
Raynet is ARaymond (http://www.araymond.com) IT service management

Offline

#3 2012-11-01 00:00:39

halext
Member
Registered: 2012-01-29
Posts: 59

Re: ICAL export (custom)

I,

I have tryed to implement that but my function doesn’t have anything that you speak

  static function generateIcal($who,$who_group) {
      global $CFG_GLPI, $LANG;

      if ($who==0 && $who_group==0) {
         return false;
      }

      include_once (GLPI_ROOT . "/lib/icalcreator/iCalcreator.class.php");
      $v = new vcalendar();

      if (!empty( $CFG_GLPI["version"])) {
         $v->setConfig( 'unique_id', "GLPI-Planning-".trim($CFG_GLPI["version"]) );
      } else {
         $v->setConfig( 'unique_id', "GLPI-Planning-UnknownVersion" );
      }

      $v->setProperty( "method", "PUBLISH" );
      $v->setProperty( "version", "2.0" );
      $v->setProperty( "x-wr-calname", "GLPI-".$who."-".$who_group );
      $v->setProperty( "calscale", "GREGORIAN" );
      $interv = array();

      $begin = time()-MONTH_TIMESTAMP*12;
      $end   = time()+MONTH_TIMESTAMP*12;
      $begin = date("Y-m-d H:i:s", $begin);
      $end   = date("Y-m-d H:i:s", $end);

      // ---------------Tracking
      $interv = TicketTask::populatePlanning(array('who'       => $who,
                                                   'who_group' => $who_group,
                                                   'begin'     => $begin,
                                                   'end'       => $end));

      // ---------------Problem
      $interv2 = ProblemTask::populatePlanning(array('who'       => $who,
                                                     'who_group' => $who_group,
                                                     'begin'     => $begin,
                                                     'end'       => $end));

      // ---------------Reminder
      $data = Reminder::populatePlanning(array('who'       => $who,
                                               'who_group' => $who_group,
                                               'begin'     => $begin,
                                               'end'       => $end));

      $interv = array_merge($interv, $interv2, $data);

      // ---------------Plugin
      $data = Plugin::doHookFunction("planning_populate", array("begin"     => $begin,
                                                                "end"       => $end,
                                                                "who"       => $who,
                                                                "who_group" => $who_group));

      if (isset($data["items"]) && count($data["items"])) {
         $interv = array_merge($data["items"], $interv);
      }
     
      if (count($interv)>0) {
         foreach ($interv as $key => $val) {
            $vevent = new vevent(); //initiate EVENT
            if (isset($val["tickettasks_id"])) {
               $vevent->setProperty("uid", "Job#".$val["tickettasks_id"]);
            } else if (isset($val["reminders_id"])) {
               $vevent->setProperty("uid", "Event#".$val["reminders_id"]);
            } else if (isset($val['planningID'])) { // Specify the ID (for plugins)
               $vevent->setProperty("uid", "Plugin#".$val['planningID']);
            } else {
               $vevent->setProperty("uid", "Plugin#".$key);
            }
            $vevent->setProperty( "dstamp", $val["begin"] );
            $vevent->setProperty( "dtstart", $val["begin"] );
            $vevent->setProperty( "dtend", $val["end"] );

            if (isset($val["tickets_id"])) {
               $vevent->setProperty("summary",
                                    $LANG['planning'][8]." #".$val["tickets_id"]." ".
                                    $val["name"]);
            } else if (isset($val["name"])) {
               $vevent->setProperty( "summary", $val["name"] );
            }

            if (isset($val["content"])) {
               $vevent->setProperty( "description", Html::clean($val["content"]) );
            } else if (isset($val["name"])) {
               $vevent->setProperty( "description", $val["name"] );
            }

            if (isset($val["tickets_id"])) {
               $vevent->setProperty("url",
                                    $CFG_GLPI["url_base"]."/index.php?redirect=tracking_".
                                       $val["tickets_id"]);
            }

            $v->setComponent( $vevent );
         }
      }
      $v->sort();
//       $v->parse();
      return $v->returnCalendar();
   }

}

Offline

#4 2012-11-09 17:27:48

tomolimo
Member
From: Grenoble, France
Registered: 2009-05-12
Posts: 515

Re: ICAL export (custom)

Hello,
Sorry for being out for a while...
Search for this:

$vevent->setProperty( "description", html_clean($val["content"]) );

You have it I saw it:)!
Then add the following right after:

if( isset($val["tickets_id"])){
                       $vevent->setProperty( "X-ALT-DESC;FMTTYPE=text/html","<HTML><BODY><a href=\"".$CFG_GLPI["url_base"]."/index.php?redirect=tracking_".
                                       $val["tickets_id"]."\">Ticket #".$val["tickets_id"]."</a><P>".$val["content"]."</P></BODY></HTML>");
               }

regards,
Tomolimo


GLPI 9.2.4 - PHP 7.2.13 x64 / ProcessMaker 3.3.0-community-RE-1.7 - PHP 7.1.24 x64 / Windows 2012 x64 / IIS 8.5 / MySQL 5.7.17 x64
Worldwide: >12316 PC, >9400 users (16 languages, >11 timezones), >360k tickets, >3600 entities, >4200 groups
Raynet is ARaymond (http://www.araymond.com) IT service management

Offline

#5 2012-11-12 10:00:50

tomolimo
Member
From: Grenoble, France
Registered: 2009-05-12
Posts: 515

Re: ICAL export (custom)

Hi,
Yes, of course, you can export the calendar, but then you are not going to have sync between GLPI and your calendar client (Outlook for exemple).
In our case, the GLPI planning is updated on a regular basis in Outlook,
Regards,
Tomolimo


GLPI 9.2.4 - PHP 7.2.13 x64 / ProcessMaker 3.3.0-community-RE-1.7 - PHP 7.1.24 x64 / Windows 2012 x64 / IIS 8.5 / MySQL 5.7.17 x64
Worldwide: >12316 PC, >9400 users (16 languages, >11 timezones), >360k tickets, >3600 entities, >4200 groups
Raynet is ARaymond (http://www.araymond.com) IT service management

Offline

Board footer

Powered by FluxBB