fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [14555] activitycalendarfrontend: formatting code


From: Sigurd Nes
Subject: [Fmsystem-commits] [14555] activitycalendarfrontend: formatting code
Date: Thu, 10 Dec 2015 10:15:04 +0000

Revision: 14555
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=14555
Author:   sigurdne
Date:     2015-12-10 10:15:04 +0000 (Thu, 10 Dec 2015)
Log Message:
-----------
activitycalendarfrontend: formatting code

Modified Paths:
--------------
    branches/dev-syncromind/activitycalendarfrontend/inc/class.menu.inc.php
    
branches/dev-syncromind/activitycalendarfrontend/inc/class.uiactivity.inc.php
    branches/dev-syncromind/activitycalendarfrontend/index.php
    
branches/dev-syncromind/activitycalendarfrontend/js/activitycalendarfrontend/activity_edit.js
    
branches/dev-syncromind/activitycalendarfrontend/js/activitycalendarfrontend/activity_edit_step_1.js
    
branches/dev-syncromind/activitycalendarfrontend/js/activitycalendarfrontend/activity_new.js
    
branches/dev-syncromind/activitycalendarfrontend/js/activitycalendarfrontend/activity_new_org.js
    
branches/dev-syncromind/activitycalendarfrontend/js/activitycalendarfrontend/activity_new_step_1.js
    
branches/dev-syncromind/activitycalendarfrontend/js/activitycalendarfrontend/organization_edit.js
    
branches/dev-syncromind/activitycalendarfrontend/js/activitycalendarfrontend/organization_reciept.js
    branches/dev-syncromind/activitycalendarfrontend/templates/base/activity.xsl
    
branches/dev-syncromind/activitycalendarfrontend/templates/base/activity_edit.xsl
    
branches/dev-syncromind/activitycalendarfrontend/templates/base/activity_edit_step_1.xsl
    
branches/dev-syncromind/activitycalendarfrontend/templates/base/activity_new.xsl
    
branches/dev-syncromind/activitycalendarfrontend/templates/base/activity_new_org.xsl
    
branches/dev-syncromind/activitycalendarfrontend/templates/base/activity_new_step_1.xsl
    
branches/dev-syncromind/activitycalendarfrontend/templates/base/activity_tmp.xml
    branches/dev-syncromind/activitycalendarfrontend/templates/base/config.tpl
    
branches/dev-syncromind/activitycalendarfrontend/templates/base/organization_edit.xsl
    
branches/dev-syncromind/activitycalendarfrontend/templates/base/organization_reciept.xsl

Modified: 
branches/dev-syncromind/activitycalendarfrontend/inc/class.menu.inc.php
===================================================================
--- branches/dev-syncromind/activitycalendarfrontend/inc/class.menu.inc.php     
2015-12-10 09:58:21 UTC (rev 14554)
+++ branches/dev-syncromind/activitycalendarfrontend/inc/class.menu.inc.php     
2015-12-10 10:15:04 UTC (rev 14555)
@@ -1,27 +1,29 @@
 <?php
 
-class activitycalendarfrontend_menu {
+       class activitycalendarfrontend_menu
+       {
 
-       function get_menu() {
-               $incoming_app = $GLOBALS['phpgw_info']['flags']['currentapp'];
-               $GLOBALS['phpgw_info']['flags']['currentapp'] = 
'activitycalendarfrontend';
+               function get_menu()
+               {
+                       $incoming_app                                           
                         = $GLOBALS['phpgw_info']['flags']['currentapp'];
+                       $GLOBALS['phpgw_info']['flags']['currentapp']    = 
'activitycalendarfrontend';
 
-               $menus = array();
+                       $menus = array();
 
-               if ($GLOBALS['phpgw']->acl->check('run', phpgwapi_acl::READ, 
'admin')
-                               || $GLOBALS['phpgw']->acl->check('admin', 
phpgwapi_acl::ADD, 'activitycalendarfrontend')) {
-                       $menus['admin'] = array
-                               (
-                               'index' => array
+                       if($GLOBALS['phpgw']->acl->check('run', 
phpgwapi_acl::READ, 'admin') || $GLOBALS['phpgw']->acl->check('admin', 
phpgwapi_acl::ADD, 'activitycalendarfrontend'))
+                       {
+                               $menus['admin'] = array
                                        (
-                                       'text' => lang('Configuration'),
-                                       'url' => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'admin.uiconfig.index', 'appname' => 'activitycalendarfrontend'))
-                               ),
-                       );
+                                       'index' => array
+                                               (
+                                               'text'   => 
lang('Configuration'),
+                                               'url'    => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'admin.uiconfig.index',
+                                                       'appname' => 
'activitycalendarfrontend'))
+                                       ),
+                               );
+                       }
+
+                       $GLOBALS['phpgw_info']['flags']['currentapp'] = 
$incoming_app;
+                       return $menus;
                }
-
-               $GLOBALS['phpgw_info']['flags']['currentapp'] = $incoming_app;
-               return $menus;
-       }
-
-}
+       }
\ No newline at end of file

Modified: 
branches/dev-syncromind/activitycalendarfrontend/inc/class.uiactivity.inc.php
===================================================================
--- 
branches/dev-syncromind/activitycalendarfrontend/inc/class.uiactivity.inc.php   
    2015-12-10 09:58:21 UTC (rev 14554)
+++ 
branches/dev-syncromind/activitycalendarfrontend/inc/class.uiactivity.inc.php   
    2015-12-10 10:15:04 UTC (rev 14555)
@@ -1,1251 +1,1401 @@
 <?php
+       phpgw::import_class('activitycalendar.uiactivities');
+       phpgw::import_class('activitycalendar.soactivity');
+       phpgw::import_class('activitycalendar.sogroup');
+       phpgw::import_class('activitycalendar.soarena');
+       phpgw::import_class('activitycalendar.soorganization');
+       phpgw::import_class('activitycalendar.socontactperson');
 
-phpgw::import_class('activitycalendar.uiactivities');
-phpgw::import_class('activitycalendar.soactivity');
-phpgw::import_class('activitycalendar.sogroup');
-phpgw::import_class('activitycalendar.soarena');
-phpgw::import_class('activitycalendar.soorganization');
-phpgw::import_class('activitycalendar.socontactperson');
+       include_class('activitycalendar', 'activity', 'inc/model/');
+       include_class('activitycalendar', 'group', 'inc/model/');
+       include_class('activitycalendar', 'organization', 'inc/model/');
+       include_class('activitycalendar', 'arena', 'inc/model/');
 
-include_class('activitycalendar', 'activity', 'inc/model/');
-include_class('activitycalendar', 'group', 'inc/model/');
-include_class('activitycalendar', 'organization', 'inc/model/');
-include_class('activitycalendar', 'arena', 'inc/model/');
+       class activitycalendarfrontend_uiactivity extends 
activitycalendar_uiactivities
+       {
 
-class activitycalendarfrontend_uiactivity extends 
activitycalendar_uiactivities {
-
-       private $so_organization;
+               private $so_organization;
 //    private $so_activity;
-       public $public_functions = array
+               public $public_functions = array
                        (
-                       'add' => true,
-                       'edit' => true,
-                       'view' => true,
-                       'index' => true,
-                       'get_organization_groups' => true,
-                       'get_address_search' => true,
-                       'edit_organization_values' => true,
-                       'get_organization_activities' => true
-       );
+                       'add'                                                   
 => true,
+                       'edit'                                                  
 => true,
+                       'view'                                                  
 => true,
+                       'index'                                                 
 => true,
+                       'get_organization_groups'                => true,
+                       'get_address_search'                     => true,
+                       'edit_organization_values'               => true,
+                       'get_organization_activities'    => true
+               );
 
-       public function __construct() {
-               parent::__construct();
-               $this->so_organization = 
activitycalendar_soorganization::get_instance();
+               public function __construct()
+               {
+                       parent::__construct();
+                       $this->so_organization = 
activitycalendar_soorganization::get_instance();
 //        $this->so_activity = activitycalendar_soactivity::get_instance();
-       }
+               }
 
-       /**
-        * Public method. Add new activity.
-        */
-       public function add() {
-               
//$GLOBALS['phpgw']->redirect_link('/activitycalendarfrontend/index.php', 
array('menuaction' => 'activitycalendarfrontend.uiactivity.edit', 'action' => 
'new_activity'));
-               $GLOBALS['phpgw']->js->validate_file('json', 'json', 
'phpgwapi');
-               $c = createobject('phpgwapi.config', 
'activitycalendarfrontend');
-               $c->read();
-               $config = $c->config_data;
+               /**
+                * Public method. Add new activity.
+                */
+               public function add()
+               {
+                       
//$GLOBALS['phpgw']->redirect_link('/activitycalendarfrontend/index.php', 
array('menuaction' => 'activitycalendarfrontend.uiactivity.edit', 'action' => 
'new_activity'));
+                       $GLOBALS['phpgw']->js->validate_file('json', 'json', 
'phpgwapi');
+                       $c               = createobject('phpgwapi.config', 
'activitycalendarfrontend');
+                       $c->read();
+                       $config  = $c->config_data;
 
-               $ajaxUrl = $c->config_data['AJAXURL'];
-        $helpImg = 
$GLOBALS['phpgw']->common->image('activitycalendarfrontend', 'hjelp.gif');
+                       $ajaxUrl = $c->config_data['AJAXURL'];
+                       $helpImg = 
$GLOBALS['phpgw']->common->image('activitycalendarfrontend', 'hjelp.gif');
 
-               $categories = $this->so_activity->get_categories();
-               $targets = $this->so_activity->get_targets();
-               $offices = $this->so_activity->select_district_list();
-               $districts = $this->so_activity->get_districts();
-               $buildings = $this->so_arena->get_buildings();
-               $arenas = $this->so_arena->get(null, null, 'arena.arena_name', 
true, null, null, null);
-               $organizations = $this->so_organization->get(null, null, 
'org.name', true, null, null, null);
-        
-        $activity = new activitycalendar_activity();
-        
-        $o_id = phpgw::get_var('organization_id');
-               $o_id_new = phpgw::get_var('organization_id_hidden');
+                       $categories              = 
$this->so_activity->get_categories();
+                       $targets                 = 
$this->so_activity->get_targets();
+                       $offices                 = 
$this->so_activity->select_district_list();
+                       $districts               = 
$this->so_activity->get_districts();
+                       $buildings               = 
$this->so_arena->get_buildings();
+                       $arenas                  = $this->so_arena->get(null, 
null, 'arena.arena_name', true, null, null, null);
+                       $organizations   = $this->so_organization->get(null, 
null, 'org.name', true, null, null, null);
 
-        $organization_options = Array();
-        foreach ($organizations as $o) {
-            $organization_options[] = array(
-                'id' => $o->get_id(),
-                'name' => $o->get_name()
-            );
-        }
+                       $activity = new activitycalendar_activity();
 
-        $category_options = Array();
-        foreach ($categories as $c) {
-            $category_options['list'][] = array(
-                'id' => $c->get_id(),
-                'name' => $c->get_name()
-            );
-        }
+                       $o_id            = phpgw::get_var('organization_id');
+                       $o_id_new        = 
phpgw::get_var('organization_id_hidden');
 
-        $arena_options = Array();
-        foreach ($arenas as $a) {
-            $arena_options[] = array(
-                'id' => $a->get_id(),
-                'name' => $a->get_arena_name()
-            );
-        }
+                       $organization_options = Array();
+                       foreach($organizations as $o)
+                       {
+                               $organization_options[] = array(
+                                       'id'     => $o->get_id(),
+                                       'name'   => $o->get_name()
+                               );
+                       }
 
-        $building_options = Array();
-        foreach ($buildings as $building_id => $building_name) {
-            $building_options[] = array(
-                'id' => $building_id,
-                'name' => $building_name
-            );
-        }
+                       $category_options = Array();
+                       foreach($categories as $c)
+                       {
+                               $category_options['list'][] = array(
+                                       'id'     => $c->get_id(),
+                                       'name'   => $c->get_name()
+                               );
+                       }
 
-        $office_options = Array();
-        foreach ($offices as $o) {
-            $office_options['list'][] = array(
-                'id' => $o['id'],
-                'name' => $o['name']
-            );
-        }
-        
-        phpgwapi_jquery::formvalidator_generate(array('location', 'date', 
'security', 'file'));
+                       $arena_options = Array();
+                       foreach($arenas as $a)
+                       {
+                               $arena_options[] = array(
+                                       'id'     => $a->get_id(),
+                                       'name'   => $a->get_arena_name()
+                               );
+                       }
 
-               if (isset($_POST['step_1']))
-        { //activity shall be registred on a new organization
-            
-            self::add_javascript('activitycalendarfrontend', 
'activitycalendarfrontend', 'activity_new.js');
-            
-                       if ($o_id_new == "new_org") {
-                               //add new organization to internal 
activitycalendar organization register
-                               $org_homepage = phpgw::get_var('homepage');
-                               if ($org_homepage == 'http://') {
-                                       $org_homepage = "";
-                               }
-                               $org_info['name'] = phpgw::get_var('orgname');
-                               $org_info['orgnr'] = phpgw::get_var('orgno');
-                               $org_info['homepage'] = $org_homepage;
-                               $org_info['street'] = phpgw::get_var('address');
-                               $org_info['streetnumber'] = 
phpgw::get_var('number');
-                               $org_info['zip'] = phpgw::get_var('postzip');
-                               $org_info['postaddress'] = 
phpgw::get_var('postaddress');
-                               $org_info['status'] = "new";
-                               $o_id = 
$this->so_activity->add_organization_local($org_info);
+                       $building_options = Array();
+                       foreach($buildings as $building_id => $building_name)
+                       {
+                               $building_options[] = array(
+                                       'id'     => $building_id,
+                                       'name'   => $building_name
+                               );
+                       }
 
-                               //add contact persons
-                               $contact1 = array();
-                               $contact1['name'] = 
phpgw::get_var('org_contact1_name');
-                               $contact1['phone'] = 
phpgw::get_var('org_contact1_phone');
-                               $contact1['mail'] = 
phpgw::get_var('org_contact1_mail');
-                               $contact1['org_id'] = $o_id;
-                               $contact1['group_id'] = 0;
-                               
$this->so_activity->add_contact_person_local($contact1);
+                       $office_options = Array();
+                       foreach($offices as $o)
+                       {
+                               $office_options['list'][] = array(
+                                       'id'     => $o['id'],
+                                       'name'   => $o['name']
+                               );
+                       }
 
-                               $person_arr = 
$this->so_contact->get_local_contact_persons($o_id);
-                               foreach ($person_arr as $p) {
-                                       $persons[] = $p;
-                               }
+                       
phpgwapi_jquery::formvalidator_generate(array('location', 'date', 'security',
+                               'file'));
 
-                               $person_ids = 
$this->so_organization->get_contacts_local($o_id);
-                               $desc = phpgw::get_var('org_description');
-                               $organization = 
$this->so_organization->get_organization_local($o_id);
-                               $new_org = true;
+                       if(isset($_POST['step_1']))
+                       { //activity shall be registred on a new organization
+                               
self::add_javascript('activitycalendarfrontend', 'activitycalendarfrontend', 
'activity_new.js');
 
-                               $organization = 
$this->so_organization->get_organization_local($o_id);
-                               $person_arr = 
$this->so_organization->get_contacts_local_as_objects($o_id);
-                               foreach ($person_arr as $p) {
-                                       $persons[] = $p;
+                               if($o_id_new == "new_org")
+                               {
+                                       //add new organization to internal 
activitycalendar organization register
+                                       $org_homepage = 
phpgw::get_var('homepage');
+                                       if($org_homepage == 'http://')
+                                       {
+                                               $org_homepage = "";
+                                       }
+                                       $org_info['name']                       
 = phpgw::get_var('orgname');
+                                       $org_info['orgnr']                      
 = phpgw::get_var('orgno');
+                                       $org_info['homepage']            = 
$org_homepage;
+                                       $org_info['street']                     
 = phpgw::get_var('address');
+                                       $org_info['streetnumber']        = 
phpgw::get_var('number');
+                                       $org_info['zip']                        
 = phpgw::get_var('postzip');
+                                       $org_info['postaddress']         = 
phpgw::get_var('postaddress');
+                                       $org_info['status']                     
 = "new";
+                                       $o_id                                   
         = $this->so_activity->add_organization_local($org_info);
+
+                                       //add contact persons
+                                       $contact1                               
 = array();
+                                       $contact1['name']                = 
phpgw::get_var('org_contact1_name');
+                                       $contact1['phone']               = 
phpgw::get_var('org_contact1_phone');
+                                       $contact1['mail']                = 
phpgw::get_var('org_contact1_mail');
+                                       $contact1['org_id']              = 
$o_id;
+                                       $contact1['group_id']    = 0;
+                                       
$this->so_activity->add_contact_person_local($contact1);
+
+                                       $person_arr = 
$this->so_contact->get_local_contact_persons($o_id);
+                                       foreach($person_arr as $p)
+                                       {
+                                               $persons[] = $p;
+                                       }
+
+                                       $person_ids              = 
$this->so_organization->get_contacts_local($o_id);
+                                       $desc                    = 
phpgw::get_var('org_description');
+                                       $organization    = 
$this->so_organization->get_organization_local($o_id);
+                                       $new_org                 = true;
+
+                                       $organization    = 
$this->so_organization->get_organization_local($o_id);
+                                       $person_arr              = 
$this->so_organization->get_contacts_local_as_objects($o_id);
+                                       foreach($person_arr as $p)
+                                       {
+                                               $persons[] = $p;
+                                       }
+
+                                       $message = 
lang('organization_saved_form');
                                }
+                               else
+                               {
+                                       $new_org                 = false;
+                                       $organization    = 
$this->so_organization->get_single($o_id);
+                                       $person_arr              = 
$this->so_contact->get(null, null, null, null, null, null, array(
+                                               'organization_id' => $o_id));
+                                       foreach($person_arr as $p)
+                                       {
+                                               $persons[] = $p;
+                                       }
 
-                               $message = lang('organization_saved_form');
-                       } else {
-                               $new_org = false;
-                               $organization = 
$this->so_organization->get_single($o_id);
-                               $person_arr = $this->so_contact->get(null, 
null, null, null, null, null, array('organization_id' => $o_id));
-                               foreach ($person_arr as $p) {
-                                       $persons[] = $p;
+                                       $activity->set_organization_id($o_id);
+                                       
$activity->set_description($organization->get_description());
+                                       $activity->set_contact_persons($pers);
                                }
 
-                               $activity->set_organization_id($o_id);
-                               
$activity->set_description($organization->get_description());
-                               $activity->set_contact_persons($pers);          
      
-                       }
+                               $activity_options                               
                 = Array();
+                               $activity_options['id']                         
         = ($activity->get_id()) ? $activity->get_id() : 0;
+                               $activity_options['time']                       
         = $activity->get_time();
+                               $activity_options['title']                      
         = $activity->get_title();
+                               $category_options['current_category_id'] = 
($activity->get_category()) ? $activity->get_category() : "";
+                               $office_options['selected_office']              
 = ($activity->get_office()) ? $activity->get_office() : "";
 
-            $activity_options = Array();
-            $activity_options['id'] = ($activity->get_id()) ? 
$activity->get_id() : 0;
-            $activity_options['time'] = $activity->get_time();
-            $activity_options['title'] = $activity->get_title();
-            $category_options['current_category_id'] = 
($activity->get_category()) ? $activity->get_category() : "";
-            $office_options['selected_office'] = ($activity->get_office()) ? 
$activity->get_office() : "";
-            
-            $organization_id = $organization->get_id();
-            
-            $current_target_ids = $activity->get_target();
-            $current_target_id_array = explode(",", $current_target_ids);
-            $target_options = Array();
-            foreach ($targets as $t) {
-                $checked = (in_array($t->get_id(), $current_target_id_array)) 
? "checked" : "";
-                $target_options[] = array(
-                    'id' => $t->get_id(),
-                    'name' => $t->get_name(),
-                    'checked' => $checked
-                );
-            }
-            
-            return self::render_template_xsl('activity_new', array
-                (
-                    'activity' => $activity_options,
-                    'new_organization' => $new_org,
-                    'organization_id' => $organization_id,
-                    'contact1' => $persons[0],
-                    'arenas' => $arena_options,
-                    'buildings' => $building_options,
-                    'categories' => $category_options,
-                    'targets' => $target_options,
-                    'districts' => $districts,
-                    'offices' => $office_options,
-                    'editable' => true,
-                    'message' => isset($message) ? $message : 
phpgw::get_var('message'),
-                    'error' => isset($error) ? $error : 
phpgw::get_var('error'),
-                    'helpImg' => $helpImg,
-                    'ajaxURL' => $ajaxUrl
-                )
-            );
-               } else if (isset($_POST['save_activity'])) {
-                       $get_org_from_local = false;
-                       $new_org_group = false;
-                       $new_org = phpgw::get_var('new_organization');
-                       if ($new_org != null && $new_org == 'yes') {
-                               $get_org_from_local = true;
+                               $organization_id = $organization->get_id();
+
+                               $current_target_ids              = 
$activity->get_target();
+                               $current_target_id_array = explode(",", 
$current_target_ids);
+                               $target_options                  = Array();
+                               foreach($targets as $t)
+                               {
+                                       $checked                         = 
(in_array($t->get_id(), $current_target_id_array)) ? "checked" : "";
+                                       $target_options[]        = array(
+                                               'id'             => 
$t->get_id(),
+                                               'name'           => 
$t->get_name(),
+                                               'checked'        => $checked
+                                       );
+                               }
+
+                               return 
self::render_template_xsl('activity_new', array
+                                       (
+                                       'activity'                       => 
$activity_options,
+                                       'new_organization'       => $new_org,
+                                       'organization_id'        => 
$organization_id,
+                                       'contact1'                       => 
$persons[0],
+                                       'arenas'                         => 
$arena_options,
+                                       'buildings'                      => 
$building_options,
+                                       'categories'             => 
$category_options,
+                                       'targets'                        => 
$target_options,
+                                       'districts'                      => 
$districts,
+                                       'offices'                        => 
$office_options,
+                                       'editable'                       => 
true,
+                                       'message'                        => 
isset($message) ? $message : phpgw::get_var('message'),
+                                       'error'                          => 
isset($error) ? $error : phpgw::get_var('error'),
+                                       'helpImg'                        => 
$helpImg,
+                                       'ajaxURL'                        => 
$ajaxUrl
+                               )
+                               );
                        }
+                       else if(isset($_POST['save_activity']))
+                       {
+                               $get_org_from_local      = false;
+                               $new_org_group           = false;
+                               $new_org                         = 
phpgw::get_var('new_organization');
+                               if($new_org != null && $new_org == 'yes')
+                               {
+                                       $get_org_from_local = true;
+                               }
 
-                       if ($get_org_from_local) {
-                               $activity->set_new_org(true);
-                               //$person_arr = 
$this->so_contact->get_local_contact_persons($o_id);
-                               //foreach($person_arr as $p)
-                               //{
-                               //$persons[] = $p;
-                               //}
-                               //$person_ids = 
$this->so_organization->get_contacts_local($o_id);
-                               //$desc = 
$this->so_organization->get_description_local($o_id);
-                               $organization = 
$this->so_organization->get_organization_local($o_id);
-                               $new_org = true;
-                               //$new_org_group = true;
-                               //Add new group for the activity
-                               $group_info['name'] = phpgw::get_var('title');
-                               $group_info['organization_id'] = $o_id;
-                               $group_info['description'] = 
phpgw::get_var('description');
-                               $group_info['status'] = "new";
-                               $g_id = 
$this->so_activity->add_group_local($group_info);
+                               if($get_org_from_local)
+                               {
+                                       $activity->set_new_org(true);
+                                       //$person_arr = 
$this->so_contact->get_local_contact_persons($o_id);
+                                       //foreach($person_arr as $p)
+                                       //{
+                                       //$persons[] = $p;
+                                       //}
+                                       //$person_ids = 
$this->so_organization->get_contacts_local($o_id);
+                                       //$desc = 
$this->so_organization->get_description_local($o_id);
+                                       $organization                           
         = $this->so_organization->get_organization_local($o_id);
+                                       $new_org                                
                 = true;
+                                       //$new_org_group = true;
+                                       //Add new group for the activity
+                                       $group_info['name']                     
         = phpgw::get_var('title');
+                                       $group_info['organization_id']   = 
$o_id;
+                                       $group_info['description']              
 = phpgw::get_var('description');
+                                       $group_info['status']                   
 = "new";
+                                       $g_id                                   
                 = $this->so_activity->add_group_local($group_info);
 
-                               //add contact persons
-                               $contact1 = array();
-                               $contact1['name'] = 
phpgw::get_var('contact_name');
-                               $contact1['phone'] = 
phpgw::get_var('contact_phone');
-                               $contact1['mail'] = 
phpgw::get_var('contact_mail');
-                               $contact1['org_id'] = $o_id;
-                               $contact1['group_id'] = $g_id;
-                               
$this->so_activity->add_contact_person_local($contact1);
+                                       //add contact persons
+                                       $contact1                               
 = array();
+                                       $contact1['name']                = 
phpgw::get_var('contact_name');
+                                       $contact1['phone']               = 
phpgw::get_var('contact_phone');
+                                       $contact1['mail']                = 
phpgw::get_var('contact_mail');
+                                       $contact1['org_id']              = 
$o_id;
+                                       $contact1['group_id']    = $g_id;
+                                       
$this->so_activity->add_contact_person_local($contact1);
 
-                               $person_arr = 
$this->so_contact->get_local_contact_persons($g_id, true);
-                               foreach ($person_arr as $p) {
-                                       $persons[] = $p;
+                                       $person_arr = 
$this->so_contact->get_local_contact_persons($g_id, true);
+                                       foreach($person_arr as $p)
+                                       {
+                                               $persons[] = $p;
+                                       }
+                                       $desc            = 
phpgw::get_var('description');
+                                       $group           = 
$this->so_group->get_group_local($g_id);
+                                       $person_ids      = 
$this->so_group->get_contacts_local($g_id);
+                                       $new_group       = true;
                                }
-                               $desc = phpgw::get_var('description');
-                               $group = 
$this->so_group->get_group_local($g_id);
-                               $person_ids = 
$this->so_group->get_contacts_local($g_id);
-                               $new_group = true;
-                       } else if (is_numeric($o_id) && $o_id > 0) {
-                               $group_info['name'] = phpgw::get_var('title');
-                               $group_info['organization_id'] = $o_id;
-                               $group_info['description'] = 
phpgw::get_var('description');
-                               $group_info['status'] = "new";
-                               $g_id = 
$this->so_activity->add_group_local($group_info);
+                               else if(is_numeric($o_id) && $o_id > 0)
+                               {
+                                       $group_info['name']                     
         = phpgw::get_var('title');
+                                       $group_info['organization_id']   = 
$o_id;
+                                       $group_info['description']              
 = phpgw::get_var('description');
+                                       $group_info['status']                   
 = "new";
+                                       $g_id                                   
                 = $this->so_activity->add_group_local($group_info);
 
-                               //add contact persons
-                               $contact1 = array();
-                               $contact1['name'] = 
phpgw::get_var('contact_name');
-                               $contact1['phone'] = 
phpgw::get_var('contact_phone');
-                               $contact1['mail'] = 
phpgw::get_var('contact_mail');
-                               $contact1['org_id'] = 0;
-                               $contact1['group_id'] = $g_id;
-                               
$this->so_activity->add_contact_person_local($contact1);
+                                       //add contact persons
+                                       $contact1                               
 = array();
+                                       $contact1['name']                = 
phpgw::get_var('contact_name');
+                                       $contact1['phone']               = 
phpgw::get_var('contact_phone');
+                                       $contact1['mail']                = 
phpgw::get_var('contact_mail');
+                                       $contact1['org_id']              = 0;
+                                       $contact1['group_id']    = $g_id;
+                                       
$this->so_activity->add_contact_person_local($contact1);
 
-                               $person_arr = 
$this->so_contact->get_local_contact_persons($g_id, true);
-                               foreach ($person_arr as $p) {
-                                       $persons[] = $p;
+                                       $person_arr = 
$this->so_contact->get_local_contact_persons($g_id, true);
+                                       foreach($person_arr as $p)
+                                       {
+                                               $persons[] = $p;
+                                       }
+                                       $desc                    = 
phpgw::get_var('description');
+                                       $group                   = 
$this->so_group->get_group_local($g_id);
+                                       $person_ids              = 
$this->so_group->get_contacts_local($g_id);
+                                       $organization    = 
$this->so_organization->get_single($o_id);
+                                       $new_group               = true;
                                }
-                               $desc = phpgw::get_var('description');
-                               $group = 
$this->so_group->get_group_local($g_id);
-                               $person_ids = 
$this->so_group->get_contacts_local($g_id);
-                               $organization = 
$this->so_organization->get_single($o_id);
-                               $new_group = true;
-                       }
 
-                       if (strlen($desc) > 254) {
-                               $desc = substr($desc, 0, 254);
-                       }
+                               if(strlen($desc) > 254)
+                               {
+                                       $desc = substr($desc, 0, 254);
+                               }
 
-                       $arena_id = phpgw::get_var('internal_arena_id');
-                       $new_arena = phpgw::get_var('new_arena_hidden');
-                       if ($new_arena != null && $new_arena == 'new_arena') {
-                               $arena = new activitycalendar_arena();
-                               $arena_name = phpgw::get_var('arena_name');
-                               $arena_address = 
phpgw::get_var('arena_address');
-                               $arena_addressnumber = 
phpgw::get_var('arena_number');
-                               $arena_zip_code = 
phpgw::get_var('arena_zip_code');
-                               $arena_city = phpgw::get_var('arena_city');
+                               $arena_id        = 
phpgw::get_var('internal_arena_id');
+                               $new_arena       = 
phpgw::get_var('new_arena_hidden');
+                               if($new_arena != null && $new_arena == 
'new_arena')
+                               {
+                                       $arena                           = new 
activitycalendar_arena();
+                                       $arena_name                      = 
phpgw::get_var('arena_name');
+                                       $arena_address           = 
phpgw::get_var('arena_address');
+                                       $arena_addressnumber = 
phpgw::get_var('arena_number');
+                                       $arena_zip_code          = 
phpgw::get_var('arena_zip_code');
+                                       $arena_city                      = 
phpgw::get_var('arena_city');
 
-                               $arena->set_arena_name($arena_name);
-                               $arena->set_address($arena_address);
-                               $arena->set_addressnumber($arena_addressnumber);
-                               $arena->set_zip_code($arena_zip_code);
-                               $arena->set_city($arena_city);
-                               $arena->set_active(true);
+                                       $arena->set_arena_name($arena_name);
+                                       $arena->set_address($arena_address);
+                                       
$arena->set_addressnumber($arena_addressnumber);
+                                       $arena->set_zip_code($arena_zip_code);
+                                       $arena->set_city($arena_city);
+                                       $arena->set_active(true);
 
-                               // All is good, store arena
-                               if ($this->so_arena->store($arena)) {
-                                       $arena_id = $arena->get_id();
-                                       $activity->set_arena($arena_id);
+                                       // All is good, store arena
+                                       if($this->so_arena->store($arena))
+                                       {
+                                               $arena_id = $arena->get_id();
+                                               $activity->set_arena($arena_id);
+                                       }
                                }
-                       } else {
-                               $arena_arr = explode("_", $arena_id);
-                               if ($arena_arr[0] == 'i') {
-                                       
$activity->set_internal_arena($arena_arr[1]);
-                               } else {
-                                       $activity->set_arena($arena_arr[1]);
+                               else
+                               {
+                                       $arena_arr = explode("_", $arena_id);
+                                       if($arena_arr[0] == 'i')
+                                       {
+                                               
$activity->set_internal_arena($arena_arr[1]);
+                                       }
+                                       else
+                                       {
+                                               
$activity->set_arena($arena_arr[1]);
+                                       }
                                }
-                       }
 
-                       //... set all parameters
-                       $activity->set_title(phpgw::get_var('title'));
-                       $activity->set_organization_id($o_id);
-                       $activity->set_group_id($g_id);
-                       $activity->set_district(phpgw::get_var('district'));
-                       $activity->set_office(phpgw::get_var('office'));
-                       $activity->set_state(1);
-                       $activity->set_category(phpgw::get_var('category'));
-                       $target_array = phpgw::get_var('target');
-                       $activity->set_target(implode(",", $target_array));
-                       $activity->set_description($desc);
-                       $activity->set_time(phpgw::get_var('time'));
-                       $activity->set_contact_persons($persons);
-                       
$activity->set_special_adaptation(phpgw::get_var('special_adaptation'));
-                       
$activity->set_contact_person_2_address(phpgw::get_var('contact2_address') . ", 
" . phpgw::get_var('contact2_number'));
-                       
$activity->set_contact_person_2_zip(phpgw::get_var('contact2_postaddress'));
-                       $activity->set_frontend(true);
-                       $activity->set_new_org($new_org);
-                       $activity->set_new_group($new_group);
-                       $target_ok = false;
-                       $district_ok = false;
+                               //... set all parameters
+                               $activity->set_title(phpgw::get_var('title'));
+                               $activity->set_organization_id($o_id);
+                               $activity->set_group_id($g_id);
+                               
$activity->set_district(phpgw::get_var('district'));
+                               $activity->set_office(phpgw::get_var('office'));
+                               $activity->set_state(1);
+                               
$activity->set_category(phpgw::get_var('category'));
+                               $target_array    = phpgw::get_var('target');
+                               $activity->set_target(implode(",", 
$target_array));
+                               $activity->set_description($desc);
+                               $activity->set_time(phpgw::get_var('time'));
+                               $activity->set_contact_persons($persons);
+                               
$activity->set_special_adaptation(phpgw::get_var('special_adaptation'));
+                               
$activity->set_contact_person_2_address(phpgw::get_var('contact2_address') . ", 
" . phpgw::get_var('contact2_number'));
+                               
$activity->set_contact_person_2_zip(phpgw::get_var('contact2_postaddress'));
+                               $activity->set_frontend(true);
+                               $activity->set_new_org($new_org);
+                               $activity->set_new_group($new_group);
+                               $target_ok               = false;
+                               $district_ok     = false;
 
-                       if ($get_org_from_local) {
-                               //update new organization with district-id from 
activity.
-                               
$this->so_organization->update_org_district_local($organization->get_id(), 
$activity->get_district());
-                       }
+                               if($get_org_from_local)
+                               {
+                                       //update new organization with 
district-id from activity.
+                                       
$this->so_organization->update_org_district_local($organization->get_id(), 
$activity->get_district());
+                               }
 
-                       if ($activity->get_target() && $activity->get_target() 
!= '') {
-                               $target_ok = true;
-                       }
-                       if ($activity->get_district() && 
$activity->get_district() != '') {
-                               $district_ok = true;
-                       }
+                               if($activity->get_target() && 
$activity->get_target() != '')
+                               {
+                                       $target_ok = true;
+                               }
+                               if($activity->get_district() && 
$activity->get_district() != '')
+                               {
+                                       $district_ok = true;
+                               }
 
-                       if ($target_ok && $district_ok) {
-                               if ($this->so_activity->store($activity)) { // 
... and then try to store the object
-                                       $message = lang('messages_saved_form');
-                               } else {
-                                       $error = lang('messages_form_error');
+                               if($target_ok && $district_ok)
+                               {
+                                       if($this->so_activity->store($activity))
+                                       { // ... and then try to store the 
object
+                                               $message = 
lang('messages_saved_form');
+                                       }
+                                       else
+                                       {
+                                               $error = 
lang('messages_form_error');
+                                       }
+                                       //$org_info_edit_url = 
self::link('/index.php' ,array('menuaction' => 
'activitycalendarfrontend.uiactivity.edit_organization_values'));
+
+                                       
$GLOBALS['phpgw_info']['flags']['noframework'] = true;
+
+                                       $activity_options                       
                         = Array();
+                                       $activity_options['id']                 
                 = ($activity->get_id()) ? $activity->get_id() : "0";
+                                       $activity_options['title']              
                 = $activity->get_title();
+                                       $activity_options['description']        
         = $activity->get_description();
+                                       $activity_options['category']           
         = ($activity->get_category()) ? 
$this->so_activity->get_category_name($activity->get_category()) : "";
+                                       $activity_options['targets']            
         = "";
+                                       $activity_options['special_adaptation'] 
 = ($activity->get_special_adaptation()) ? true : false;
+                                       $activity_options['internal_arena']     
         = ($activity->get_internal_arena()) ? true : false;
+                                       $activity_options['building_name']      
         = $this->so_arena->get_building_name($activity->get_internal_arena());
+                                       $activity_options['arena']              
                 = ($activity->get_arena()) ? true : false;
+                                       $activity_options['arena_name']         
         = $this->so_arena->get_arena_name($activity->get_arena());
+                                       $activity_options['districts']          
         = "";
+                                       $activity_options['time']               
                 = $activity->get_time();
+                                       $activity_options['contact_person_1']   
 = ($activity->get_contact_person_1()) ? true : false;
+                                       $activity_options['contact1_name']      
         = (isset($persons[0])) ? $persons[0]->get_name() : "";
+                                       $activity_options['contact1_phone']     
         = (isset($persons[0])) ? $persons[0]->get_phone() : "";
+                                       $activity_options['contact1_mail']      
         = (isset($persons[0])) ? $persons[0]->get_email() : "";
+                                       $activity_options['office']             
                 = ($activity->get_office()) ? 
$this->so_activity->get_office_name($activity->get_office()) : "";
+
+                                       if($activity->get_target())
+                                       {
+                                               $current_target_ids             
 = $activity->get_target();
+                                               $current_target_id_array = 
explode(",", $current_target_ids);
+                                               
foreach($current_target_id_array as $ct)
+                                               {
+                                                       
$activity_options['targets'] .= $this->so_activity->get_target_name($ct) . "<br 
/>";
+                                               }
+                                       }
+
+                                       if($activity->get_district())
+                                       {
+                                               $current_district_ids           
 = $activity->get_district();
+                                               $current_district_id_array      
 = explode(",", $current_district_ids);
+                                               
foreach($current_district_id_array as $cd)
+                                               {
+                                                       
$activity_options['districts'] .= $this->so_activity->get_district_name($cd) . 
"<br />";
+                                               }
+                                       }
+
+                                       $organization_options                   
         = Array();
+                                       $organization_options['id']             
         = $organization->get_id();
+                                       $organization_options['name']           
 = $organization->get_name();
+                                       $organization_options['new_org']        
 = $activity->get_new_org();
+                                       $organization_options['edit_link']      
 = self::link(array('menuaction' => 
'activitycalendarfrontend.uiactivity.edit_organization_values',
+                                               'organization_id' => 
$organization_options['id']));
+
+
+                                       return 
self::render_template_xsl('activity', array
+                                               (
+                                               'activity'               => 
$activity_options,
+                                               'organization'   => 
$organization_options,
+                                               'group'                  => 
$group,
+                                               'contact1'               => 
$persons[0],
+                                               'arenas'                 => 
$arenas,
+                                               'buildings'              => 
$buildings,
+                                               'categories'     => $categories,
+                                               'targets'                => 
$targets,
+                                               'districts'              => 
$districts,
+                                               'offices'                => 
$offices,
+                                               'message'                => 
isset($message) ? $message : phpgw::get_var('message'),
+                                               'error'                  => 
isset($error) ? $error : phpgw::get_var('error'),
+                                               'ajaxURL'                => 
$ajaxUrl
+                                       )
+                                       );
                                }
-                               //$org_info_edit_url = self::link('/index.php' 
,array('menuaction' => 
'activitycalendarfrontend.uiactivity.edit_organization_values'));
-                
-                               $GLOBALS['phpgw_info']['flags']['noframework'] 
= true;
-                
-                $activity_options = Array();
-                $activity_options['id'] = ($activity->get_id()) ? 
$activity->get_id() : "0";
-                $activity_options['title'] = $activity->get_title();
-                $activity_options['description'] = 
$activity->get_description();
-                $activity_options['category'] = ($activity->get_category()) ? 
$this->so_activity->get_category_name($activity->get_category()) : "";
-                $activity_options['targets'] = "";
-                $activity_options['special_adaptation'] = 
($activity->get_special_adaptation()) ? true : false;
-                $activity_options['internal_arena'] = 
($activity->get_internal_arena()) ? true : false;
-                $activity_options['building_name'] = 
$this->so_arena->get_building_name($activity->get_internal_arena());
-                $activity_options['arena'] = ($activity->get_arena()) ? true : 
false;
-                $activity_options['arena_name'] = 
$this->so_arena->get_arena_name($activity->get_arena());
-                $activity_options['districts'] = "";
-                $activity_options['time'] = $activity->get_time();
-                $activity_options['contact_person_1'] = 
($activity->get_contact_person_1()) ? true : false;
-                $activity_options['contact1_name'] = (isset($persons[0])) ? 
$persons[0]->get_name() : "";
-                $activity_options['contact1_phone'] = (isset($persons[0])) ? 
$persons[0]->get_phone() : "";
-                $activity_options['contact1_mail'] = (isset($persons[0])) ? 
$persons[0]->get_email() : "";
-                $activity_options['office'] = ($activity->get_office()) ? 
$this->so_activity->get_office_name($activity->get_office()) : "";
-                
-                if ($activity->get_target()) {
-                    $current_target_ids = $activity->get_target();
-                    $current_target_id_array = explode(",", 
$current_target_ids);
-                    foreach ($current_target_id_array as $ct) {
-                        $activity_options['targets'] .= 
$this->so_activity->get_target_name($ct) . "<br />";
-                    }
-                }
-                
-                if ($activity->get_district()) {
-                    $current_district_ids = $activity->get_district();
-                    $current_district_id_array = explode(",", 
$current_district_ids);
-                    foreach ($current_district_id_array as $cd) {
-                        $activity_options['districts'] .= 
$this->so_activity->get_district_name($cd) . "<br />";
-                    }
-                }
-                
-                $organization_options = Array();
-                $organization_options['id'] = $organization->get_id();
-                $organization_options['name'] = $organization->get_name();
-                $organization_options['new_org'] = $activity->get_new_org();
-                $organization_options['edit_link'] = 
self::link(array('menuaction' => 
'activitycalendarfrontend.uiactivity.edit_organization_values','organization_id'
 => $organization_options['id']));
+                               else
+                               {
+                                       if(!$target_ok)
+                                       {
+                                               $error .= "<br/>" . 
lang('target_not_selected');
+                                       }
+                                       if(!$district_ok)
+                                       {
+                                               $error .= "<br/>" . 
lang('district_not_selected');
+                                       }
 
+                                       $activity_options                       
                         = Array();
+                                       $activity_options['id']                 
                 = ($activity->get_id()) ? $activity->get_id() : 0;
+                                       $activity_options['time']               
                 = $activity->get_time();
+                                       $activity_options['title']              
                 = $activity->get_title();
+                                       
$category_options['current_category_id'] = ($activity->get_category()) ? 
$activity->get_category() : "";
+                                       $office_options['selected_office']      
         = ($activity->get_office()) ? $activity->get_office() : "";
 
-                return self::render_template_xsl('activity', array
-                    (
-                                               'activity' => $activity_options,
-                                               'organization' => 
$organization_options,
-                                               'group' => $group,
-                                               'contact1' => $persons[0],
-                                               'arenas' => $arenas,
-                                               'buildings' => $buildings,
-                                               'categories' => $categories,
-                                               'targets' => $targets,
-                                               'districts' => $districts,
-                                               'offices' => $offices,
-                                               'message' => isset($message) ? 
$message : phpgw::get_var('message'),
-                                               'error' => isset($error) ? 
$error : phpgw::get_var('error'),
-                                               'ajaxURL' => $ajaxUrl
-                    )
-                               );
-                       } else {
-                               if (!$target_ok) {
-                                       $error .= "<br/>" . 
lang('target_not_selected');
+                                       $organization_id = 
$organization->get_id();
+
+                                       $current_target_ids              = 
$activity->get_target();
+                                       $current_target_id_array = explode(",", 
$current_target_ids);
+                                       $target_options                  = 
Array();
+                                       foreach($targets as $t)
+                                       {
+                                               $checked                        
 = (in_array($t->get_id(), $current_target_id_array)) ? "checked" : "";
+                                               $target_options[]        = 
array(
+                                                       'id'             => 
$t->get_id(),
+                                                       'name'           => 
$t->get_name(),
+                                                       'checked'        => 
$checked
+                                               );
+                                       }
+
+                                       return 
self::render_template_xsl('activity_new', array(
+                                               'activity'                      
 => $activity_options,
+                                               'organization_id'        => 
$organization_id,
+                                               'contact1'                      
 => $persons[0],
+                                               'contact2'                      
 => $persons[1],
+                                               'new_org'                       
 => $new_org,
+                                               'arenas'                        
 => $arena_options,
+                                               'buildings'                     
 => $building_options,
+                                               'categories'             => 
$category_options,
+                                               'targets'                       
 => $target_options,
+                                               'districts'                     
 => $districts,
+                                               'offices'                       
 => $office_options,
+                                               'editable'                      
 => true,
+                                               'cancel_link'            => 
$cancel_link,
+                                               'message'                       
 => isset($message) ? $message : phpgw::get_var('message'),
+                                               'error'                         
 => isset($error) ? $error : phpgw::get_var('error'),
+                                               'helpImg'                       
 => $helpImg,
+                                               'ajaxURL'                       
 => $ajaxUrl
+                                       )
+                                       );
                                }
-                               if (!$district_ok) {
-                                       $error .= "<br/>" . 
lang('district_not_selected');
-                               }
+                       }
+                       else
+                       {
+                               
self::add_javascript('activitycalendarfrontend', 'activitycalendarfrontend', 
'activity_new_step_1.js');
 
-                $activity_options = Array();
-                $activity_options['id'] = ($activity->get_id()) ? 
$activity->get_id() : 0;
-                $activity_options['time'] = $activity->get_time();
-                $activity_options['title'] = $activity->get_title();
-                $category_options['current_category_id'] = 
($activity->get_category()) ? $activity->get_category() : "";
-                $office_options['selected_office'] = ($activity->get_office()) 
? $activity->get_office() : "";
-                
-                $organization_id = $organization->get_id();
-            
-                $current_target_ids = $activity->get_target();
-                $current_target_id_array = explode(",", $current_target_ids);
-                $target_options = Array();
-                foreach ($targets as $t) {
-                    $checked = (in_array($t->get_id(), 
$current_target_id_array)) ? "checked" : "";
-                    $target_options[] = array(
-                        'id' => $t->get_id(),
-                        'name' => $t->get_name(),
-                        'checked' => $checked
-                    );
-                }
-                
-                               return 
self::render_template_xsl('activity_new', array (
-                        'activity' => $activity_options,
-                        'organization_id' => $organization_id,
-                        'contact1' => $persons[0],
-                        'contact2' => $persons[1],
-                        'new_org' => $new_org,
-                        'arenas' => $arena_options,
-                        'buildings' => $building_options,
-                        'categories' => $category_options,
-                        'targets' => $target_options,
-                        'districts' => $districts,
-                        'offices' => $office_options,
-                        'editable' => true,
-                        'cancel_link' => $cancel_link,
-                        'message' => isset($message) ? $message : 
phpgw::get_var('message'),
-                        'error' => isset($error) ? $error : 
phpgw::get_var('error'),
-                        'helpImg' => $helpImg,
-                        'ajaxURL' => $ajaxUrl
-                    )
+                               self::render_template_xsl(
+                               'activity_new_step_1', array(
+                                       'ajaxURL'                => $ajaxUrl,
+                                       'helpImg'                => $helpImg,
+                                       'organizations'  => 
$organization_options
+                               )
                                );
                        }
-               } else {
-            self::add_javascript('activitycalendarfrontend', 
'activitycalendarfrontend', 'activity_new_step_1.js');
-
-            self::render_template_xsl(
-                    'activity_new_step_1',
-                    array(
-                        'ajaxURL' => $ajaxUrl,
-                        'helpImg' => $helpImg,
-                        'organizations' => $organization_options
-                    )
-            );
                }
-       }
 
-       function view() {
-               $errorMsgs = array();
-               $infoMsgs = array();
-               $activity = $this->so_activity->get_single((int) 
phpgw::get_var('id'));
-        
-               if ($activity == null) { // Not found
-                       $errorMsgs[] = lang('Could not find specified 
activity.');
-               }
+               function view()
+               {
+                       $errorMsgs       = array();
+                       $infoMsgs        = array();
+                       $activity        = 
$this->so_activity->get_single((int)phpgw::get_var('id'));
 
-        $activity_options = Array();
-        $activity_options['id'] = ($activity->get_id()) ? $activity->get_id() 
: "0";
-        $activity_options['title'] = $activity->get_title();
-        $activity_options['description'] = $activity->get_description();
-        $activity_options['category'] = ($activity->get_category()) ? 
$this->so_activity->get_category_name($activity->get_category()) : "";
-        $activity_options['targets'] = "";
-        $activity_options['special_adaptation'] = 
($activity->get_special_adaptation()) ? true : false;
-        $activity_options['internal_arena'] = 
($activity->get_internal_arena()) ? true : false;
-        $activity_options['building_name'] = 
$this->so_arena->get_building_name($activity->get_internal_arena());
-        $activity_options['arena'] = ($activity->get_arena()) ? true : false;
-        $activity_options['arena_name'] = 
$this->so_arena->get_arena_name($activity->get_arena());
-        $activity_options['districts'] = "";
-        $activity_options['time'] = $activity->get_time();
-        $activity_options['contact_person_1'] = 
($activity->get_contact_person_1()) ? true : false;
-        $activity_options['contact1_name'] = (isset($persons[0])) ? 
$persons[0]->get_name() : "";
-        $activity_options['contact1_phone'] = (isset($persons[0])) ? 
$persons[0]->get_phone() : "";
-        $activity_options['contact1_mail'] = (isset($persons[0])) ? 
$persons[0]->get_email() : "";
-        $activity_options['office'] = ($activity->get_office()) ? 
$this->so_activity->get_office_name($activity->get_office()) : "";
+                       if($activity == null)
+                       { // Not found
+                               $errorMsgs[] = lang('Could not find specified 
activity.');
+                       }
 
-        $activity_options['organization_id'] = 
$activity->get_organization_id();
+                       $activity_options                                       
         = Array();
+                       $activity_options['id']                                 
 = ($activity->get_id()) ? $activity->get_id() : "0";
+                       $activity_options['title']                              
 = $activity->get_title();
+                       $activity_options['description']                 = 
$activity->get_description();
+                       $activity_options['category']                    = 
($activity->get_category()) ? 
$this->so_activity->get_category_name($activity->get_category()) : "";
+                       $activity_options['targets']                     = "";
+                       $activity_options['special_adaptation']  = 
($activity->get_special_adaptation()) ? true : false;
+                       $activity_options['internal_arena']              = 
($activity->get_internal_arena()) ? true : false;
+                       $activity_options['building_name']               = 
$this->so_arena->get_building_name($activity->get_internal_arena());
+                       $activity_options['arena']                              
 = ($activity->get_arena()) ? true : false;
+                       $activity_options['arena_name']                  = 
$this->so_arena->get_arena_name($activity->get_arena());
+                       $activity_options['districts']                   = "";
+                       $activity_options['time']                               
 = $activity->get_time();
+                       $activity_options['contact_person_1']    = 
($activity->get_contact_person_1()) ? true : false;
+                       $activity_options['contact1_name']               = 
(isset($persons[0])) ? $persons[0]->get_name() : "";
+                       $activity_options['contact1_phone']              = 
(isset($persons[0])) ? $persons[0]->get_phone() : "";
+                       $activity_options['contact1_mail']               = 
(isset($persons[0])) ? $persons[0]->get_email() : "";
+                       $activity_options['office']                             
 = ($activity->get_office()) ? 
$this->so_activity->get_office_name($activity->get_office()) : "";
 
-        $organization = 
$this->so_organization->get_single($activity_options['organization_id']);
-        $organization_options = Array();
-        $organization_options['id'] = $organization->get_id();
-        $organization_options['name'] = $organization->get_name();
+                       $activity_options['organization_id'] = 
$activity->get_organization_id();
 
-        $activity_options['contact_person_1_id'] = 
$activity->get_contact_person_1();
-        $activity_options['group_id'] = $activity->get_group_id();
+                       $organization                                    = 
$this->so_organization->get_single($activity_options['organization_id']);
+                       $organization_options                    = Array();
+                       $organization_options['id']              = 
$organization->get_id();
+                       $organization_options['name']    = 
$organization->get_name();
 
-        $persons = 
$this->so_contact->get_local_contact_persons($activity_options['group_id'], 
true);
-        $person = $persons[0];
-        $activity_options['contact1_name'] = $person->get_name();
-        $activity_options['contact1_phone'] = $person->get_phone();
-        $activity_options['contact1_mail'] = $person->get_email();
+                       $activity_options['contact_person_1_id'] = 
$activity->get_contact_person_1();
+                       $activity_options['group_id']                    = 
$activity->get_group_id();
 
-        if ($activity->get_target()) {
-            $current_target_ids = $activity->get_target();
-            $current_target_id_array = explode(",", $current_target_ids);
-            foreach ($current_target_id_array as $ct) {
-                $activity_options['targets'] .= 
$this->so_activity->get_target_name($ct) . "<br />";
-            }
-        }
+                       $persons                                                
         = 
$this->so_contact->get_local_contact_persons($activity_options['group_id'], 
true);
+                       $person                                                 
         = $persons[0];
+                       $activity_options['contact1_name']       = 
$person->get_name();
+                       $activity_options['contact1_phone']      = 
$person->get_phone();
+                       $activity_options['contact1_mail']       = 
$person->get_email();
 
-        if ($activity->get_district()) {
-            $current_district_ids = $activity->get_district();
-            $current_district_id_array = explode(",", $current_district_ids);
-            foreach ($current_district_id_array as $cd) {
-                $activity_options['districts'] .= 
$this->so_activity->get_district_name($cd) . "<br />";
-            }
-        }
+                       if($activity->get_target())
+                       {
+                               $current_target_ids              = 
$activity->get_target();
+                               $current_target_id_array = explode(",", 
$current_target_ids);
+                               foreach($current_target_id_array as $ct)
+                               {
+                                       $activity_options['targets'] .= 
$this->so_activity->get_target_name($ct) . "<br />";
+                               }
+                       }
 
-               $data = array (
-            'activity' => $activity_options,
-            'organization' => $organization_options,
-            'errorMsgs' => $errorMsgs,
-            'infoMsgs' => $infoMsgs
-               );
+                       if($activity->get_district())
+                       {
+                               $current_district_ids            = 
$activity->get_district();
+                               $current_district_id_array       = explode(",", 
$current_district_ids);
+                               foreach($current_district_id_array as $cd)
+                               {
+                                       $activity_options['districts'] .= 
$this->so_activity->get_district_name($cd) . "<br />";
+                               }
+                       }
 
-               $GLOBALS['phpgw_info']['flags']['noframework'] = true;
+                       $data = array(
+                               'activity'               => $activity_options,
+                               'organization'   => $organization_options,
+                               'errorMsgs'              => $errorMsgs,
+                               'infoMsgs'               => $infoMsgs
+                       );
+
+                       $GLOBALS['phpgw_info']['flags']['noframework'] = true;
 //             $this->render('activity.php', $data);
-               self::render_template_xsl('activity', $data);
-               //self::render_template('activity_tmp', array('activity' => 
$activity, 'frontend'=>'true'));
-       }
+                       self::render_template_xsl('activity', $data);
+                       //self::render_template('activity_tmp', 
array('activity' => $activity, 'frontend'=>'true'));
+               }
 
-       function edit() {
-               $GLOBALS['phpgw']->js->validate_file('json', 'json', 
'phpgwapi');
+               function edit()
+               {
+                       $GLOBALS['phpgw']->js->validate_file('json', 'json', 
'phpgwapi');
 
-               $c = createobject('phpgwapi.config', 
'activitycalendarfrontend');
-               $c->read();
-               $config = $c->config_data;
+                       $c               = createobject('phpgwapi.config', 
'activitycalendarfrontend');
+                       $c->read();
+                       $config  = $c->config_data;
 
-               $ajaxUrl = $c->config_data['AJAXURL'];
-        $helpImg = 
$GLOBALS['phpgw']->common->image('activitycalendarfrontend', 'hjelp.gif');
-        
-               $id = intval(phpgw::get_var('id', 'GET'));
+                       $ajaxUrl = $c->config_data['AJAXURL'];
+                       $helpImg = 
$GLOBALS['phpgw']->common->image('activitycalendarfrontend', 'hjelp.gif');
 
-               $categories = $this->so_activity->get_categories();
-               $targets = $this->so_activity->get_targets();
-               $offices = $this->so_activity->select_district_list();
-               $districts = $this->so_activity->get_districts();
-               $buildings = $this->so_arena->get_buildings();
-               $arenas = $this->so_arena->get(null, null, 'arena.arena_name', 
true, null, null, null);
+                       $id = intval(phpgw::get_var('id', 'GET'));
 
-        $category_options = Array();
-        foreach ($categories as $c) {
-            $category_options['list'][] = array(
-                'id' => $c->get_id(),
-                'name' => $c->get_name()
-            );
-        }
-        
-        $building_options = Array();
-        foreach ($buildings as $building_id => $building_name) {
-            $building_options['list'][] = array(
-                'id' => $building_id,
-                'name' => $building_name
-            );
-        }
-        
-        $arena_options = Array();
-        foreach ($arenas as $a) {
-            $arena_options['list'][] = array(
-                'id' => $a->get_id(),
-                'name' => $a->get_arena_name()
-            );
-        }
-        
-        $district_options = Array();
-        foreach ($districts as $d) {
-            $district_options['list'][] = array(
-                'part_of_town_id' => $d['part_of_town_id'],
-                'name' => $d['name']
-            );
-        }
-        
-        $office_options = Array();
-        foreach ($offices as $o) {
-            $office_options['list'][] = array(
-                'id' => $o['id'],
-                'name' => $o['name']
-            );
-        }
-        
-        phpgwapi_jquery::formvalidator_generate(array('location', 'date', 
'security', 'file'));
+                       $categories      = $this->so_activity->get_categories();
+                       $targets         = $this->so_activity->get_targets();
+                       $offices         = 
$this->so_activity->select_district_list();
+                       $districts       = $this->so_activity->get_districts();
+                       $buildings       = $this->so_arena->get_buildings();
+                       $arenas          = $this->so_arena->get(null, null, 
'arena.arena_name', true, null, null, null);
 
-               if (isset($_POST['step_1'])) { //change_request
-                       $activity_id = phpgw::get_var('activity_id');
-                       $activity = 
$this->so_activity->get_single($activity_id);
-                       $org = 
$this->so_organization->get_single($activity->get_organization_id());
+                       $category_options = array();
+                       foreach($categories as $c)
+                       {
+                               $category_options['list'][] = array(
+                                       'id'     => $c->get_id(),
+                                       'name'   => $c->get_name()
+                               );
+                       }
 
+                       $building_options = array();
+                       foreach($buildings as $building_id => $building_name)
+                       {
+                               $building_options['list'][] = array(
+                                       'id'     => $building_id,
+                                       'name'   => $building_name
+                               );
+                       }
 
-                       //store update-request
-                       //$activity->set_state(2);
-                       //if($this->so_activity->store($activity))
-                       //{
-                       $this->send_email_to_selection(array($activity));
-                       $message = lang('update_request_sent', 
$activity->get_title(), $org->get_name());
-                       return 
self::render_template_xsl('activity_edit_step_1', array
-                (
-                    'activities' => $activities,
-                    'message' => $message,
-                    'ajaxURL' => $ajaxUrl
-                )
-                       );
-                       //}
-               } else {
-                       $secret_param = phpgw::get_var('secret', 'GET');
-                       if (!isset($id) || $id == '') {
-                               //select activity to edit
-                               $activities = $this->so_activity->get(null, 
null, 'title', true, null, null, array('activity_state' => 3));
-                               $organizations = 
$this->so_organization->get(null, null, 'org.name', true, null, null, 
array('edit_from_frontend' => 'yes'));
-                $organization_options = Array();
-                foreach ($organizations as $o) {
-                    $organization_options[] = array(
-                        'id' => $o->get_id(),
-                        'name' => $o->get_name()
-                    );
-                }
-                
-                self::add_javascript('activitycalendarfrontend', 
'activitycalendarfrontend', 'activity_edit_step_1.js');
-                
-                return self::render_template_xsl('activity_edit_step_1', array(
-                        'activities' => $activities,
-                        'organizations' => $organization_options,
-                        'ajaxURL' => $ajaxUrl
-                    )
-                );
+                       $arena_options = array();
+                       foreach($arenas as $a)
+                       {
+                               $arena_options['list'][] = array(
+                                       'id'     => $a->get_id(),
+                                       'name'   => $a->get_arena_name()
+                               );
                        }
-                       if (!isset($secret_param) || $secret_param == '') {
-                               //select activity to edit
-                               $activities = $this->so_activity->get(null, 
null, 'title', true, null, null, array('activity_state' => 3));
-                
-                self::add_javascript('activitycalendarfrontend', 
'activitycalendarfrontend', 'activity_edit_step_1.js');
-                
+
+                       $district_options = array();
+                       foreach($districts as $d)
+                       {
+                               $district_options['list'][] = array(
+                                       'part_of_town_id'        => 
$d['part_of_town_id'],
+                                       'name'                           => 
$d['name']
+                               );
+                       }
+
+                       $office_options = array();
+                       foreach($offices as $o)
+                       {
+                               $office_options['list'][] = array(
+                                       'id'     => $o['id'],
+                                       'name'   => $o['name']
+                               );
+                       }
+
+                       
phpgwapi_jquery::formvalidator_generate(array('location', 'date', 'security',
+                               'file'));
+
+                       if(isset($_POST['step_1']))
+                       { //change_request
+                               $activity_id = phpgw::get_var('activity_id');
+                               $activity        = 
$this->so_activity->get_single($activity_id);
+                               $org             = 
$this->so_organization->get_single($activity->get_organization_id());
+
+
+                               //store update-request
+                               //$activity->set_state(2);
+                               //if($this->so_activity->store($activity))
+                               //{
+                               
$this->send_email_to_selection(array($activity));
+                               $message = lang('update_request_sent', 
$activity->get_title(), $org->get_name());
                                return 
self::render_template_xsl('activity_edit_step_1', array
-                    (
-                        'activities' => $activities,
-                        'ajaxURL' => $ajaxUrl
-                    )
+                                       (
+                                       'activities' => $activities,
+                                       'message'        => $message,
+                                       'ajaxURL'        => $ajaxUrl
+                               )
                                );
-                       } else {
-                               // Retrieve the activity object or create a new 
one
-                               if (isset($id) && $id > 0) {
-                                       $activity = 
$this->so_activity->get_single($id);
-                               } else {
-                                       $activities = 
$this->so_activity->get(null, null, 'title', true, null, null, 
array('activity_state' => 3));
-                    
-                    self::add_javascript('activitycalendarfrontend', 
'activitycalendarfrontend', 'activity_edit_step_1.js');
-                    
-                                       return 
self::render_template_xsl('activity_edit_step_1', array
-                        (
-                            'activities' => $activities,
-                            'ajaxURL' => $ajaxUrl
-                        )
+                               //}
+                       }
+                       else
+                       {
+                               $secret_param = phpgw::get_var('secret', 'GET');
+                               if(!isset($id) || $id == '')
+                               {
+                                       //select activity to edit
+                                       $activities                             
 = $this->so_activity->get(null, null, 'title', true, null, null, array(
+                                               'activity_state' => 3));
+                                       $organizations                   = 
$this->so_organization->get(null, null, 'org.name', true, null, null, array(
+                                               'edit_from_frontend' => 'yes'));
+                                       $organization_options    = Array();
+                                       foreach($organizations as $o)
+                                       {
+                                               $organization_options[] = array(
+                                                       'id'     => 
$o->get_id(),
+                                                       'name'   => 
$o->get_name()
+                                               );
+                                       }
+
+                                       
self::add_javascript('activitycalendarfrontend', 'activitycalendarfrontend', 
'activity_edit_step_1.js');
+
+                                       return 
self::render_template_xsl('activity_edit_step_1', array(
+                                               'activities'     => $activities,
+                                               'organizations'  => 
$organization_options,
+                                               'ajaxURL'                => 
$ajaxUrl
+                                       )
                                        );
                                }
+                               if(!isset($secret_param) || $secret_param == '')
+                               {
+                                       //select activity to edit
+                                       $activities = 
$this->so_activity->get(null, null, 'title', true, null, null, array(
+                                               'activity_state' => 3));
 
-                               if ($activity->get_secret() != 
phpgw::get_var('secret', 'GET')) {
-                                       //select activity to edit
-                                       $activities = 
$this->so_activity->get(null, null, 'title', true, null, null, 
array('activity_state' => 3));
-                    
-                    self::add_javascript('activitycalendarfrontend', 
'activitycalendarfrontend', 'activity_edit_step_1.js');
-                    
+                                       
self::add_javascript('activitycalendarfrontend', 'activitycalendarfrontend', 
'activity_edit_step_1.js');
+
                                        return 
self::render_template_xsl('activity_edit_step_1', array
-                        (
-                            'activities' => $activities,
-                            'ajaxURL' => $ajaxUrl
-                        )
+                                               (
+                                               'activities' => $activities,
+                                               'ajaxURL'        => $ajaxUrl
+                                       )
                                        );
                                }
+                               else
+                               {
+                                       // Retrieve the activity object or 
create a new one
+                                       if(isset($id) && $id > 0)
+                                       {
+                                               $activity = 
$this->so_activity->get_single($id);
+                                       }
+                                       else
+                                       {
+                                               $activities = 
$this->so_activity->get(null, null, 'title', true, null, null, array(
+                                                       'activity_state' => 3));
 
-                               if ($activity->get_group_id()) {
-                                       $person_arr = 
$this->so_contact->get_booking_contact_persons($activity->get_group_id(), true);
-                                       foreach ($person_arr as $p) {
-                                               $persons_array[] = $p;
+                                               
self::add_javascript('activitycalendarfrontend', 'activitycalendarfrontend', 
'activity_edit_step_1.js');
+
+                                               return 
self::render_template_xsl('activity_edit_step_1', array
+                                                       (
+                                                       'activities' => 
$activities,
+                                                       'ajaxURL'        => 
$ajaxUrl
+                                               )
+                                               );
                                        }
-                                       $desc = 
$this->so_group->get_description($activity->get_group_id());
-                                       $group = 
$this->so_group->get_single($activity->get_group_id());
-                                       $person_ids = 
$this->so_group->get_contacts($activity->get_group_id());
-                               } else if ($activity->get_organization_id()) {
-                                       $person_arr = 
$this->so_contact->get_booking_contact_persons($activity->get_organization_id());
-                                       foreach ($person_arr as $p) {
-                                               $persons_array[] = $p;
-                                       }
-                                       $desc = 
$this->so_organization->get_description($activity->get_organization_id());
-                                       $person_ids = 
$this->so_organization->get_contacts($activity->get_organization_id());
-                               }
-                               if (strlen($desc) > 254) {
-                                       $desc = substr($desc, 0, 254);
-                               }
-                
-                $activity_options = Array();
-                $activity_options['id'] = ($activity->get_id()) ? 
$activity->get_id() : "0";
-                $activity_options['title'] = $activity->get_title();
-                $activity_options['description'] = 
$activity->get_description();
-                $activity_options['category'] = ($activity->get_category()) ? 
$this->so_activity->get_category_name($activity->get_category()) : "";
-                $activity_options['targets'] = "";
-                $activity_options['special_adaptation'] = 
($activity->get_special_adaptation()) ? true : false;
-                $activity_options['internal_arena'] = 
($activity->get_internal_arena()) ? true : false;
-                $activity_options['building_name'] = 
$this->so_arena->get_building_name($activity->get_internal_arena());
-                $activity_options['arena'] = ($activity->get_arena()) ? true : 
false;
-                $activity_options['arena_name'] = 
$this->so_arena->get_arena_name($activity->get_arena());
-                $activity_options['districts'] = "";
-                $activity_options['time'] = $activity->get_time();
-                $activity_options['contact_person_1'] = 
($activity->get_contact_person_1()) ? true : false;
-                $activity_options['contact1_name'] = 
(isset($persons_array[0])) ? $persons_array[0]->get_name() : "";
-                $activity_options['contact1_phone'] = 
(isset($persons_array[0])) ? $persons_array[0]->get_phone() : "";
-                $activity_options['contact1_mail'] = 
(isset($persons_array[0])) ? $persons_array[0]->get_email() : "";
-                $activity_options['office'] = ($activity->get_office()) ? 
$this->so_activity->get_office_name($activity->get_office()) : "";
-                $activity_options['group_id'] = $activity->get_group_id();
 
-                $category_options['current_category_id'] = 
($activity->get_category()) ? $activity->get_category() : "";
-                $district_options['current_district_id'] = 
($activity->get_district()) ? $activity->get_district() : "";
-                $office_options['selected_office'] = ($activity->get_office()) 
? $activity->get_office() : "";
-                $building_options['selected_internal_arena'] = 
($activity->get_internal_arena()) ? $activity->get_internal_arena() : "";
-                $arena_options['selected_arena'] = ($activity->get_arena()) ? 
$activity->get_arena() : "";
+                                       if($activity->get_secret() != 
phpgw::get_var('secret', 'GET'))
+                                       {
+                                               //select activity to edit
+                                               $activities = 
$this->so_activity->get(null, null, 'title', true, null, null, array(
+                                                       'activity_state' => 3));
 
-                $current_target_ids = $activity->get_target();
-                $current_target_id_array = explode(",", $current_target_ids);
-                $target_options = Array();
-                foreach ($targets as $t) {
-                    $checked = (in_array($t->get_id(), 
$current_target_id_array)) ? "checked" : "";
-                    $target_options[] = array(
-                        'id' => $t->get_id(),
-                        'name' => $t->get_name(),
-                        'checked' => $checked
-                    );
-                }
-                
-                if ($activity->get_target()) {
-                    $current_target_ids = $activity->get_target();
-                    $current_target_id_array = explode(",", 
$current_target_ids);
-                    foreach ($current_target_id_array as $ct) {
-                        $activity_options['targets'] .= 
$this->so_activity->get_target_name($ct) . "<br />";
-                    }
-                }
+                                               
self::add_javascript('activitycalendarfrontend', 'activitycalendarfrontend', 
'activity_edit_step_1.js');
 
-                if ($activity->get_district()) {
-                    $current_district_ids = $activity->get_district();
-                    $current_district_id_array = explode(",", 
$current_district_ids);
-                    foreach ($current_district_id_array as $cd) {
-                        $activity_options['districts'] .= 
$this->so_activity->get_district_name($cd) . "<br />";
-                    }
-                }
-                
-                               $organization = 
$this->so_organization->get_single($activity->get_organization_id());
-                $organization_options = Array();
-                $organization_options['id'] = $organization->get_id();
-                $organization_options['name'] = $organization->get_name();
-                
-                               $change_activity_request = FALSE;
-                               if (isset($_POST['save_activity'])) { // The 
user has pressed the save button
-                                       if (isset($activity)) { // If an 
activity object is created
-                                               $act_description = 
phpgw::get_var('description');
-                                               $old_state = 
$activity->get_state();
-                                               $new_state = 
phpgw::get_var('state');
-                                               // ... set all parameters
-                                               $activity->set_state(2);
-                                               
$activity->set_title(phpgw::get_var('title'));
-                                               $arena_id = 
phpgw::get_var('internal_arena_id');
-                                               $arena_arr = explode("_", 
$arena_id);
-                                               if ($arena_arr[0] == 'i') {
-                                                       
$activity->set_internal_arena($arena_arr[1]);
-                                                       $activity->set_arena(0);
-                                               } else {
-                                                       
$activity->set_internal_arena(0);
-                                                       
$activity->set_arena($arena_arr[1]);
+                                               return 
self::render_template_xsl('activity_edit_step_1', array
+                                                       (
+                                                       'activities' => 
$activities,
+                                                       'ajaxURL'        => 
$ajaxUrl
+                                               )
+                                               );
+                                       }
+
+                                       if($activity->get_group_id())
+                                       {
+                                               $person_arr = 
$this->so_contact->get_booking_contact_persons($activity->get_group_id(), true);
+                                               foreach($person_arr as $p)
+                                               {
+                                                       $persons_array[] = $p;
                                                }
-                                               //$district_array = 
phpgw::get_var('district');
-                                               
$activity->set_district(phpgw::get_var('district'));
-                                               
$activity->set_office(phpgw::get_var('office'));
-                                               $activity->set_state(2);
-                                               
$activity->set_category(phpgw::get_var('category'));
-                                               $target_array = 
phpgw::get_var('target');
-                                               
$activity->set_target(implode(",", $target_array));
-                                               
$activity->set_description($act_description);
-                                               
$activity->set_time(phpgw::get_var('time'));
-                                               
$activity->set_contact_persons($persons);
-                                               
$activity->set_special_adaptation(phpgw::get_var('special_adaptation'));
-                                               $activity->set_frontend(true);
+                                               $desc            = 
$this->so_group->get_description($activity->get_group_id());
+                                               $group           = 
$this->so_group->get_single($activity->get_group_id());
+                                               $person_ids      = 
$this->so_group->get_contacts($activity->get_group_id());
+                                       }
+                                       else 
if($activity->get_organization_id())
+                                       {
+                                               $person_arr = 
$this->so_contact->get_booking_contact_persons($activity->get_organization_id());
+                                               foreach($person_arr as $p)
+                                               {
+                                                       $persons_array[] = $p;
+                                               }
+                                               $desc            = 
$this->so_organization->get_description($activity->get_organization_id());
+                                               $person_ids      = 
$this->so_organization->get_contacts($activity->get_organization_id());
+                                       }
+                                       if(strlen($desc) > 254)
+                                       {
+                                               $desc = substr($desc, 0, 254);
+                                       }
 
-                                               $contact_person = array();
-                                               $cp_tmp = $persons_array[0];
-                                               $contact_person['original_id'] 
= $cp_tmp->get_id();
-                                               $contact_person['name'] = 
phpgw::get_var('contact_name');
-                                               $contact_person['phone'] = 
phpgw::get_var('contact_phone');
-                                               $contact_person['mail'] = 
phpgw::get_var('contact_mail');
-                                               $contact_person['group_id'] = 
$activity->get_group_id();
+                                       $activity_options                       
                         = array();
+                                       $activity_options['id']                 
                 = ($activity->get_id()) ? $activity->get_id() : "0";
+                                       $activity_options['title']              
                 = $activity->get_title();
+                                       $activity_options['description']        
         = $activity->get_description();
+                                       $activity_options['category']           
         = ($activity->get_category()) ? 
$this->so_activity->get_category_name($activity->get_category()) : "";
+                                       $activity_options['targets']            
         = "";
+                                       $activity_options['special_adaptation'] 
 = ($activity->get_special_adaptation()) ? true : false;
+                                       $activity_options['internal_arena']     
         = ($activity->get_internal_arena()) ? true : false;
+                                       $activity_options['building_name']      
         = $this->so_arena->get_building_name($activity->get_internal_arena());
+                                       $activity_options['arena']              
                 = ($activity->get_arena()) ? true : false;
+                                       $activity_options['arena_name']         
         = $this->so_arena->get_arena_name($activity->get_arena());
+                                       $activity_options['districts']          
         = "";
+                                       $activity_options['time']               
                 = $activity->get_time();
+                                       $activity_options['contact_person_1']   
 = ($activity->get_contact_person_1()) ? true : false;
+                                       $activity_options['contact1_name']      
         = (isset($persons_array[0])) ? $persons_array[0]->get_name() : "";
+                                       $activity_options['contact1_phone']     
         = (isset($persons_array[0])) ? $persons_array[0]->get_phone() : "";
+                                       $activity_options['contact1_mail']      
         = (isset($persons_array[0])) ? $persons_array[0]->get_email() : "";
+                                       $activity_options['office']             
                 = ($activity->get_office()) ? 
$this->so_activity->get_office_name($activity->get_office()) : "";
+                                       $activity_options['group_id']           
         = $activity->get_group_id();
 
+                                       
$category_options['current_category_id']         = ($activity->get_category()) 
? $activity->get_category() : "";
+                                       
$district_options['current_district_id']         = ($activity->get_district()) 
? $activity->get_district() : "";
+                                       $office_options['selected_office']      
                 = ($activity->get_office()) ? $activity->get_office() : "";
+                                       
$building_options['selected_internal_arena'] = 
($activity->get_internal_arena()) ? $activity->get_internal_arena() : "";
+                                       $arena_options['selected_arena']        
                 = ($activity->get_arena()) ? $activity->get_arena() : "";
 
-                                               $target_ok = false;
-                                               $district_ok = false;
-                                               if ($activity->get_target() && 
$activity->get_target() != '') {
-                                                       $target_ok = true;
+                                       $current_target_ids              = 
$activity->get_target();
+                                       $current_target_id_array = explode(",", 
$current_target_ids);
+                                       $target_options                  = 
array();
+                                       foreach($targets as $t)
+                                       {
+                                               $checked                        
 = (in_array($t->get_id(), $current_target_id_array)) ? "checked" : "";
+                                               $target_options[]        = 
array(
+                                                       'id'             => 
$t->get_id(),
+                                                       'name'           => 
$t->get_name(),
+                                                       'checked'        => 
$checked
+                                               );
+                                       }
+
+                                       if($activity->get_target())
+                                       {
+                                               $current_target_ids             
 = $activity->get_target();
+                                               $current_target_id_array = 
explode(",", $current_target_ids);
+                                               
foreach($current_target_id_array as $ct)
+                                               {
+                                                       
$activity_options['targets'] .= $this->so_activity->get_target_name($ct) . "<br 
/>";
                                                }
-                                               if ($activity->get_district() 
&& $activity->get_district() != '') {
-                                                       $district_ok = true;
+                                       }
+
+                                       if($activity->get_district())
+                                       {
+                                               $current_district_ids           
 = $activity->get_district();
+                                               $current_district_id_array      
 = explode(",", $current_district_ids);
+                                               
foreach($current_district_id_array as $cd)
+                                               {
+                                                       
$activity_options['districts'] .= $this->so_activity->get_district_name($cd) . 
"<br />";
                                                }
+                                       }
 
-                        $activity_options = Array();
-                        $activity_options['id'] = ($activity->get_id()) ? 
$activity->get_id() : "0";
-                        $activity_options['title'] = $activity->get_title();
-                        $activity_options['description'] = 
$activity->get_description();
-                        $activity_options['category'] = 
($activity->get_category()) ? 
$this->so_activity->get_category_name($activity->get_category()) : "";
-                        $activity_options['targets'] = "";
-                        $activity_options['special_adaptation'] = 
($activity->get_special_adaptation()) ? true : false;
-                        $activity_options['internal_arena'] = 
($activity->get_internal_arena()) ? true : false;
-                        $activity_options['building_name'] = 
$this->so_arena->get_building_name($activity->get_internal_arena());
-                        $activity_options['arena'] = ($activity->get_arena()) 
? true : false;
-                        $activity_options['arena_name'] = 
$this->so_arena->get_arena_name($activity->get_arena());
-                        $activity_options['districts'] = "";
-                        $activity_options['time'] = $activity->get_time();
-                        $activity_options['contact_person_1'] = 
($activity->get_contact_person_1()) ? true : false;
-                        $activity_options['contact1_name'] = 
(isset($persons_array[0])) ? $persons_array[0]->get_name() : "";
-                        $activity_options['contact1_phone'] = 
(isset($persons_array[0])) ? $persons_array[0]->get_phone() : "";
-                        $activity_options['contact1_mail'] = 
(isset($persons_array[0])) ? $persons_array[0]->get_email() : "";
-                        $activity_options['office'] = 
($activity->get_office()) ? 
$this->so_activity->get_office_name($activity->get_office()) : "";
-                        $activity_options['group_id'] = 
$activity->get_group_id();
+                                       $organization                           
         = $this->so_organization->get_single($activity->get_organization_id());
+                                       $organization_options                   
 = array();
+                                       $organization_options['id']             
 = $organization->get_id();
+                                       $organization_options['name']    = 
$organization->get_name();
 
-                        $category_options['current_category_id'] = 
($activity->get_category()) ? $activity->get_category() : "";
-                        $district_options['current_district_id'] = 
($activity->get_district()) ? $activity->get_district() : "";
-                        $office_options['selected_office'] = 
($activity->get_office()) ? $activity->get_office() : "";
-                        $building_options['selected_internal_arena'] = 
($activity->get_internal_arena()) ? $activity->get_internal_arena() : "";
-                        $arena_options['selected_arena'] = 
($activity->get_arena()) ? $activity->get_arena() : "";
+                                       $change_activity_request = false;
+                                       if(isset($_POST['save_activity']))
+                                       { // The user has pressed the save 
button
+                                               if(isset($activity))
+                                               { // If an activity object is 
created
+                                                       $act_description = 
phpgw::get_var('description');
+                                                       $old_state              
 = $activity->get_state();
+                                                       $new_state              
 = phpgw::get_var('state');
+                                                       // ... set all 
parameters
+                                                       $activity->set_state(2);
+                                                       
$activity->set_title(phpgw::get_var('title'));
+                                                       $arena_id               
 = phpgw::get_var('internal_arena_id');
+                                                       $arena_arr              
 = explode("_", $arena_id);
+                                                       if($arena_arr[0] == 'i')
+                                                       {
+                                                               
$activity->set_internal_arena($arena_arr[1]);
+                                                               
$activity->set_arena(0);
+                                                       }
+                                                       else
+                                                       {
+                                                               
$activity->set_internal_arena(0);
+                                                               
$activity->set_arena($arena_arr[1]);
+                                                       }
+                                                       //$district_array = 
phpgw::get_var('district');
+                                                       
$activity->set_district(phpgw::get_var('district'));
+                                                       
$activity->set_office(phpgw::get_var('office'));
+                                                       $activity->set_state(2);
+                                                       
$activity->set_category(phpgw::get_var('category'));
+                                                       $target_array = 
phpgw::get_var('target');
+                                                       
$activity->set_target(implode(",", $target_array));
+                                                       
$activity->set_description($act_description);
+                                                       
$activity->set_time(phpgw::get_var('time'));
+                                                       
$activity->set_contact_persons($persons);
+                                                       
$activity->set_special_adaptation(phpgw::get_var('special_adaptation'));
+                                                       
$activity->set_frontend(true);
 
-                        $current_target_ids = $activity->get_target();
-                        $current_target_id_array = explode(",", 
$current_target_ids);
-                        $target_options = Array();
-                        foreach ($targets as $t) {
-                            $checked = (in_array($t->get_id(), 
$current_target_id_array)) ? "checked" : "";
-                            $target_options[] = array(
-                                'id' => $t->get_id(),
-                                'name' => $t->get_name(),
-                                'checked' => $checked
-                            );
-                        }
+                                                       $contact_person         
                         = array();
+                                                       $cp_tmp                 
                                 = $persons_array[0];
+                                                       
$contact_person['original_id']   = $cp_tmp->get_id();
+                                                       $contact_person['name'] 
                 = phpgw::get_var('contact_name');
+                                                       
$contact_person['phone']                 = phpgw::get_var('contact_phone');
+                                                       $contact_person['mail'] 
                 = phpgw::get_var('contact_mail');
+                                                       
$contact_person['group_id']              = $activity->get_group_id();
 
-                        if ($activity->get_target()) {
-                            $current_target_ids = $activity->get_target();
-                            $current_target_id_array = explode(",", 
$current_target_ids);
-                            foreach ($current_target_id_array as $ct) {
-                                $activity_options['targets'] .= 
$this->so_activity->get_target_name($ct) . "<br />";
-                            }
-                        }
 
-                        if ($activity->get_district()) {
-                            $current_district_ids = $activity->get_district();
-                            $current_district_id_array = explode(",", 
$current_district_ids);
-                            foreach ($current_district_id_array as $cd) {
-                                $activity_options['districts'] .= 
$this->so_activity->get_district_name($cd) . "<br />";
-                            }
-                        }
+                                                       $target_ok       = 
false;
+                                                       $district_ok = false;
+                                                       
if($activity->get_target() && $activity->get_target() != '')
+                                                       {
+                                                               $target_ok = 
true;
+                                                       }
+                                                       
if($activity->get_district() && $activity->get_district() != '')
+                                                       {
+                                                               $district_ok = 
true;
+                                                       }
 
-                        $organization = 
$this->so_organization->get_single($activity->get_organization_id());
-                        $organization_options = Array();
-                        $organization_options['id'] = $organization->get_id();
-                        $organization_options['name'] = 
$organization->get_name();
+                                                       $activity_options       
                                         = array();
+                                                       $activity_options['id'] 
                                 = ($activity->get_id()) ? $activity->get_id() 
: "0";
+                                                       
$activity_options['title']                               = 
$activity->get_title();
+                                                       
$activity_options['description']                 = $activity->get_description();
+                                                       
$activity_options['category']                    = ($activity->get_category()) 
? $this->so_activity->get_category_name($activity->get_category()) : "";
+                                                       
$activity_options['targets']                     = "";
+                                                       
$activity_options['special_adaptation']  = 
($activity->get_special_adaptation()) ? true : false;
+                                                       
$activity_options['internal_arena']              = 
($activity->get_internal_arena()) ? true : false;
+                                                       
$activity_options['building_name']               = 
$this->so_arena->get_building_name($activity->get_internal_arena());
+                                                       
$activity_options['arena']                               = 
($activity->get_arena()) ? true : false;
+                                                       
$activity_options['arena_name']                  = 
$this->so_arena->get_arena_name($activity->get_arena());
+                                                       
$activity_options['districts']                   = "";
+                                                       
$activity_options['time']                                = 
$activity->get_time();
+                                                       
$activity_options['contact_person_1']    = ($activity->get_contact_person_1()) 
? true : false;
+                                                       
$activity_options['contact1_name']               = (isset($persons_array[0])) ? 
$persons_array[0]->get_name() : "";
+                                                       
$activity_options['contact1_phone']              = (isset($persons_array[0])) ? 
$persons_array[0]->get_phone() : "";
+                                                       
$activity_options['contact1_mail']               = (isset($persons_array[0])) ? 
$persons_array[0]->get_email() : "";
+                                                       
$activity_options['office']                              = 
($activity->get_office()) ? 
$this->so_activity->get_office_name($activity->get_office()) : "";
+                                                       
$activity_options['group_id']                    = $activity->get_group_id();
 
-                                               if ($target_ok && $district_ok) 
{
+                                                       
$category_options['current_category_id']         = ($activity->get_category()) 
? $activity->get_category() : "";
+                                                       
$district_options['current_district_id']         = ($activity->get_district()) 
? $activity->get_district() : "";
+                                                       
$office_options['selected_office']                       = 
($activity->get_office()) ? $activity->get_office() : "";
+                                                       
$building_options['selected_internal_arena'] = 
($activity->get_internal_arena()) ? $activity->get_internal_arena() : "";
+                                                       
$arena_options['selected_arena']                         = 
($activity->get_arena()) ? $activity->get_arena() : "";
 
-                                                       if 
($this->so_activity->store($activity)) { // ... and then try to store the object
-                                                               $message = 
lang('messages_saved_form');
-                                                               //update group 
description
-                                                               if 
($activity->get_group_id()) {
-                                                                       
$this->so_group->update_group_description($activity->get_group_id(), 
$act_description);
-                                                                       
$this->so_group->update_group_contact($contact_person);
+                                                       $current_target_ids     
         = $activity->get_target();
+                                                       
$current_target_id_array = explode(",", $current_target_ids);
+                                                       $target_options         
         = array();
+                                                       foreach($targets as $t)
+                                                       {
+                                                               $checked        
                 = (in_array($t->get_id(), $current_target_id_array)) ? 
"checked" : "";
+                                                               
$target_options[]        = array(
+                                                                       'id'    
         => $t->get_id(),
+                                                                       'name'  
         => $t->get_name(),
+                                                                       
'checked'        => $checked
+                                                               );
+                                                       }
 
-                                                                       
$person_arr_tmp = 
$this->so_contact->get_booking_contact_persons($activity->get_group_id(), true);
-                                                                       foreach 
($person_arr_tmp as $p_t) {
-                                                                               
$persons_array_tmp[] = $p_t;
+                                                       
if($activity->get_target())
+                                                       {
+                                                               
$current_target_ids              = $activity->get_target();
+                                                               
$current_target_id_array = explode(",", $current_target_ids);
+                                                               
foreach($current_target_id_array as $ct)
+                                                               {
+                                                                       
$activity_options['targets'] .= $this->so_activity->get_target_name($ct) . "<br 
/>";
+                                                               }
+                                                       }
+
+                                                       
if($activity->get_district())
+                                                       {
+                                                               
$current_district_ids            = $activity->get_district();
+                                                               
$current_district_id_array       = explode(",", $current_district_ids);
+                                                               
foreach($current_district_id_array as $cd)
+                                                               {
+                                                                       
$activity_options['districts'] .= $this->so_activity->get_district_name($cd) . 
"<br />";
+                                                               }
+                                                       }
+
+                                                       $organization           
                         = 
$this->so_organization->get_single($activity->get_organization_id());
+                                                       $organization_options   
                 = array();
+                                                       
$organization_options['id']              = $organization->get_id();
+                                                       
$organization_options['name']    = $organization->get_name();
+
+                                                       if($target_ok && 
$district_ok)
+                                                       {
+
+                                                               
if($this->so_activity->store($activity))
+                                                               { // ... and 
then try to store the object
+                                                                       
$message = lang('messages_saved_form');
+                                                                       
//update group description
+                                                                       
if($activity->get_group_id())
+                                                                       {
+                                                                               
$this->so_group->update_group_description($activity->get_group_id(), 
$act_description);
+                                                                               
$this->so_group->update_group_contact($contact_person);
+
+                                                                               
$person_arr_tmp = 
$this->so_contact->get_booking_contact_persons($activity->get_group_id(), true);
+                                                                               
foreach($person_arr_tmp as $p_t)
+                                                                               
{
+                                                                               
        $persons_array_tmp[] = $p_t;
+                                                                               
}
                                                                        }
                                                                }
-                                                       } else {
-                                                               $error = 
lang('messages_form_error');
+                                                               else
+                                                               {
+                                                                       $error 
= lang('messages_form_error');
+                                                               }
+
+                                                               
$GLOBALS['phpgw_info']['flags']['noframework'] = true;
+
+                                                               return 
self::render_template_xsl('activity', array
+                                                                       (
+                                                                       
'activity'               => $activity_options,
+                                                                       
'organization'   => $organization_options,
+                                                                       'group' 
                 => $group,
+                                                                       
'contact1'               => $persons_array_tmp[0],
+                                                                       
'arenas'                 => $arenas,
+                                                                       
'buildings'              => $buildings,
+                                                                       
'categories'     => $categories,
+                                                                       
'targets'                => $targets,
+                                                                       
'districts'              => $districts,
+                                                                       
'offices'                => $offices,
+                                                                       
'message'                => isset($message) ? $message : 
phpgw::get_var('message'),
+                                                                       'error' 
                 => isset($error) ? $error : phpgw::get_var('error'),
+                                                                       
'helpImg'                => $helpImg,
+                                                                       
'ajaxURL'                => $ajaxUrl
+                                                               )
+                                                               );
                                                        }
+                                                       else
+                                                       {
+                                                               if(!$target_ok)
+                                                               {
+                                                                       $error 
.= "<br/>" . lang('target_not_selected');
+                                                               }
+                                                               
if(!$district_ok)
+                                                               {
+                                                                       $error 
.= "<br/>" . lang('district_not_selected');
+                                                               }
 
-                                                       
$GLOBALS['phpgw_info']['flags']['noframework'] = true;
+                                                               
self::add_javascript('activitycalendarfrontend', 'activitycalendarfrontend', 
'activity_edit.js');
 
-                                                       return 
self::render_template_xsl('activity', array
-                                (
-                                                                       
'activity' => $activity_options,
-                                                                       
'organization' => $organization_options,
-                                                                       'group' 
=> $group,
-                                                                       
'contact1' => $persons_array_tmp[0],
-                                                                       
'arenas' => $arenas,
-                                                                       
'buildings' => $buildings,
-                                                                       
'categories' => $categories,
-                                                                       
'targets' => $targets,
-                                                                       
'districts' => $districts,
-                                                                       
'offices' => $offices,
-                                                                       
'message' => isset($message) ? $message : phpgw::get_var('message'),
-                                                                       'error' 
=> isset($error) ? $error : phpgw::get_var('error'),
-                                    'helpImg' => $helpImg,
-                                                                       
'ajaxURL' => $ajaxUrl
-                                )
-                                                       );
-                                               } else {
-                                                       if (!$target_ok) {
-                                                               $error .= 
"<br/>" . lang('target_not_selected');
+                                                               return 
self::render('activity_edit', array
+                                                                       (
+                                                                       
'activity'               => $activity_options,
+                                                                       
'organization'   => $organization_options,
+                                                                       
'contact1'               => $persons_array[0],
+                                                                       
'org_name'               => $org_name,
+                                                                       'group' 
                 => $group,
+                                                                       
'arenas'                 => $arena_options,
+                                                                       
'buildings'              => $building_options,
+                                                                       
'categories'     => $category_options,
+                                                                       
'targets'                => $target_options,
+                                                                       
'districts'              => $district_options,
+                                                                       
'offices'                => $office_options,
+                                                                       
'editable'               => true,
+                                                                       
'cancel_link'    => $cancel_link,
+                                                                       
'message'                => isset($message) ? $message : 
phpgw::get_var('message'),
+                                                                       'error' 
                 => isset($error) ? $error : phpgw::get_var('error'),
+                                                                       
'helpImg'                => $helpImg,
+                                                                       
'ajaxURL'                => $ajaxUrl
+                                                               )
+                                                               );
                                                        }
-                                                       if (!$district_ok) {
-                                                               $error .= 
"<br/>" . lang('district_not_selected');
-                                                       }
-                            
-                            self::add_javascript('activitycalendarfrontend', 
'activitycalendarfrontend', 'activity_edit.js');
-                            
-                                                       return 
self::render('activity_edit', array
-                                (
-                                    'activity' => $activity_options,
-                                    'organization' => $organization_options,
-                                    'contact1' => $persons_array[0],
-                                    'org_name' => $org_name,
-                                    'group' => $group,
-                                    'arenas' => $arena_options,
-                                    'buildings' => $building_options,
-                                    'categories' => $category_options,
-                                    'targets' => $target_options,
-                                    'districts' => $district_options,
-                                    'offices' => $office_options,
-                                    'editable' => true,
-                                    'cancel_link' => $cancel_link,
-                                    'message' => isset($message) ? $message : 
phpgw::get_var('message'),
-                                    'error' => isset($error) ? $error : 
phpgw::get_var('error'),
-                                    'helpImg' => $helpImg,
-                                    'ajaxURL' => $ajaxUrl
-                                )
-                                                       );
                                                }
                                        }
-                               } else if (isset($_POST['change_request'])) {
-                                       
$GLOBALS['phpgw_info']['flags']['noframework'] = true;
-                    
-                    self::add_javascript('activitycalendarfrontend', 
'activitycalendarfrontend', 'activity_edit.js');
+                                       else if(isset($_POST['change_request']))
+                                       {
+                                               
$GLOBALS['phpgw_info']['flags']['noframework'] = true;
 
-                                       return 
self::render_template_xsl('activity_edit', array
-                        (
-                                                       'activity' => 
$activity_options,
-                                                       'organization' => 
$organization_options,
-                                                       'group' => $group,
-                                                       'contact1' => 
$persons_array[0],
-                                                       'arenas' => 
$arena_options,
-                                                       'buildings' => 
$building_options,
-                                                       'categories' => 
$category_options,
-                                                       'targets' => 
$target_options,
-                                                       'districts' => 
$district_options,
-                                                       'offices' => 
$office_options,
-                                                       'editable' => true,
-                                                       'message' => 
isset($message) ? $message : phpgw::get_var('message'),
-                                                       'error' => 
isset($error) ? $error : phpgw::get_var('error'),
-                            'helpImg' => $helpImg,
-                                                       'ajaxURL' => $ajaxUrl
-                        )
-                                       );
-                               } else if (isset($_POST['activity_ok'])) { // 
The user has pressed the save button
-                                       if (isset($activity)) { // If an 
activity object is created
-                                               $activity->set_frontend(true);
+                                               
self::add_javascript('activitycalendarfrontend', 'activitycalendarfrontend', 
'activity_edit.js');
 
-                                               if 
($this->so_activity->save_with_no_changes($activity)) { // ... and then try to 
store the object
-                                                       $message = 
lang('activity_ok_message');
+                                               return 
self::render_template_xsl('activity_edit', array
+                                                       (
+                                                       'activity'              
 => $activity_options,
+                                                       'organization'   => 
$organization_options,
+                                                       'group'                 
 => $group,
+                                                       'contact1'              
 => $persons_array[0],
+                                                       'arenas'                
 => $arena_options,
+                                                       'buildings'             
 => $building_options,
+                                                       'categories'     => 
$category_options,
+                                                       'targets'               
 => $target_options,
+                                                       'districts'             
 => $district_options,
+                                                       'offices'               
 => $office_options,
+                                                       'editable'              
 => true,
+                                                       'message'               
 => isset($message) ? $message : phpgw::get_var('message'),
+                                                       'error'                 
 => isset($error) ? $error : phpgw::get_var('error'),
+                                                       'helpImg'               
 => $helpImg,
+                                                       'ajaxURL'               
 => $ajaxUrl
+                                               )
+                                               );
+                                       }
+                                       else if(isset($_POST['activity_ok']))
+                                       { // The user has pressed the save 
button
+                                               if(isset($activity))
+                                               { // If an activity object is 
created
+                                                       
$activity->set_frontend(true);
+
+                                                       
if($this->so_activity->save_with_no_changes($activity))
+                                                       { // ... and then try 
to store the object
+                                                               $message = 
lang('activity_ok_message');
+                                                       }
+                                                       
$GLOBALS['phpgw_info']['flags']['noframework'] = true;
+
+                                                       return 
self::render_template_xsl('activity', array
+                                                               (
+                                                               'activity'      
         => $activity_options,
+                                                               'organization'  
 => $organization_options,
+                                                               'group'         
         => $group,
+                                                               'contact1'      
         => $persons_array[0],
+                                                               'arenas'        
         => $arenas,
+                                                               'buildings'     
         => $buildings,
+                                                               'categories'    
 => $categories,
+                                                               'targets'       
         => $targets,
+                                                               'districts'     
         => $districts,
+                                                               'offices'       
         => $offices,
+                                                               'message'       
         => isset($message) ? $message : phpgw::get_var('message'),
+                                                               'error'         
         => isset($error) ? $error : phpgw::get_var('error'),
+                                                               'helpImg'       
         => $helpImg,
+                                                               'ajaxURL'       
         => $ajaxUrl
+                                                       )
+                                                       );
                                                }
+                                       }
+                                       else
+                                       {
                                                
$GLOBALS['phpgw_info']['flags']['noframework'] = true;
 
                                                return 
self::render_template_xsl('activity', array
-                            (
-                                                               'activity' => 
$activity_options,
-                                                               'organization' 
=> $organization_options,
-                                                               'group' => 
$group,
-                                                               'contact1' => 
$persons_array[0],
-                                                               'arenas' => 
$arenas,
-                                                               'buildings' => 
$buildings,
-                                                               'categories' => 
$categories,
-                                                               'targets' => 
$targets,
-                                                               'districts' => 
$districts,
-                                                               'offices' => 
$offices,
-                                                               'message' => 
isset($message) ? $message : phpgw::get_var('message'),
-                                                               'error' => 
isset($error) ? $error : phpgw::get_var('error'),
-                                'helpImg' => $helpImg,
-                                                               'ajaxURL' => 
$ajaxUrl
-                            )
+                                                       (
+                                                       'activity'              
 => $activity_options,
+                                                       'organization'   => 
$organization_options,
+                                                       'group'                 
 => $group,
+                                                       'contact1'              
 => $persons_array[0],
+                                                       'arenas'                
 => $arenas,
+                                                       'buildings'             
 => $buildings,
+                                                       'categories'     => 
$categories,
+                                                       'targets'               
 => $targets,
+                                                       'districts'             
 => $districts,
+                                                       'offices'               
 => $offices,
+                                                       'editable'              
 => false,
+                                                       'change_request' => 
true,
+                                                       'message'               
 => isset($message) ? $message : phpgw::get_var('message'),
+                                                       'error'                 
 => isset($error) ? $error : phpgw::get_var('error'),
+                                                       'helpImg'               
 => $helpImg,
+                                                       'ajaxURL'               
 => $ajaxUrl
+                                               )
                                                );
                                        }
-                               } else {
-                                       
$GLOBALS['phpgw_info']['flags']['noframework'] = true;
-
-                                       return 
self::render_template_xsl('activity', array
-                        (
-                                                       'activity' => 
$activity_options,
-                                                       'organization' => 
$organization_options,
-                                                       'group' => $group,
-                                                       'contact1' => 
$persons_array[0],
-                                                       'arenas' => $arenas,
-                                                       'buildings' => 
$buildings,
-                                                       'categories' => 
$categories,
-                                                       'targets' => $targets,
-                                                       'districts' => 
$districts,
-                                                       'offices' => $offices,
-                                                       'editable' => false,
-                                                       'change_request' => 
true,
-                                                       'message' => 
isset($message) ? $message : phpgw::get_var('message'),
-                                                       'error' => 
isset($error) ? $error : phpgw::get_var('error'),
-                            'helpImg' => $helpImg,
-                                                       'ajaxURL' => $ajaxUrl
-                        )
-                                       );
                                }
                        }
                }
-       }
 
-       function index() {
-               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'activitycalendarfrontend.uiactivity.add'));
-       }
+               function index()
+               {
+                       $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'activitycalendarfrontend.uiactivity.add'));
+               }
 
-       function get_organization_groups() {
-               $GLOBALS['phpgw_info']['flags']['noheader'] = true;
-               $GLOBALS['phpgw_info']['flags']['nofooter'] = true;
-               $GLOBALS['phpgw_info']['flags']['xslt_app'] = false;
+               function get_organization_groups()
+               {
+                       $GLOBALS['phpgw_info']['flags']['noheader']      = true;
+                       $GLOBALS['phpgw_info']['flags']['nofooter']      = true;
+                       $GLOBALS['phpgw_info']['flags']['xslt_app']      = 
false;
 
-               $org_id = phpgw::get_var('orgid');
-               $group_id = phpgw::get_var('groupid');
-               $returnHTML = "<option value='0'>Ingen gruppe valgt</option>";
-               if ($org_id) {
-                       $group_html[] = "<option value='new_group'>Ny 
gruppe</option>";
-                       $groups = 
activitycalendar_sogroup::get_instance()->get(null, null, null, null, null, 
null, array('org_id' => $org_id));
-                       foreach ($groups as $group) {
-                               if (isset($group)) {
-                                       //$res_g = $group->serialize();
-                                       $selected = "";
-                                       if ($group_id && $group_id > 0) {
-                                               $gr_id = (int) $group_id;
-                                               if ($gr_id == (int) 
$group->get_id()) {
-                                                       $selected_group = " 
selected";
+                       $org_id          = phpgw::get_var('orgid');
+                       $group_id        = phpgw::get_var('groupid');
+                       $returnHTML      = "<option value='0'>Ingen gruppe 
valgt</option>";
+                       if($org_id)
+                       {
+                               $group_html[]    = "<option 
value='new_group'>Ny gruppe</option>";
+                               $groups                  = 
activitycalendar_sogroup::get_instance()->get(null, null, null, null, null, 
null, array(
+                                       'org_id' => $org_id));
+                               foreach($groups as $group)
+                               {
+                                       if(isset($group))
+                                       {
+                                               //$res_g = $group->serialize();
+                                               $selected = "";
+                                               if($group_id && $group_id > 0)
+                                               {
+                                                       $gr_id = (int)$group_id;
+                                                       if($gr_id == 
(int)$group->get_id())
+                                                       {
+                                                               $selected_group 
= " selected";
+                                                       }
                                                }
+                                               $group_html[] = "<option 
value='" . $group->get_id() . "'" . $selected_group . ">" . $group->get_name() 
. "</option>";
                                        }
-                                       $group_html[] = "<option value='" . 
$group->get_id() . "'" . $selected_group . ">" . $group->get_name() . 
"</option>";
                                }
+                               $html            = implode(' ', $group_html);
+                               $returnHTML      = $returnHTML . ' ' . $html;
                        }
-                       $html = implode(' ', $group_html);
-                       $returnHTML = $returnHTML . ' ' . $html;
+
+
+                       return $returnHTML;
+                       //return "<option>Ingen gruppe valgt</option>";
                }
 
+               /**
+                * Public method.
+                */
+               function get_address_search()
+               {
+                       $search_string = phpgw::get_var('search');
+                       //var_dump($search_string);
+                       return 
activitycalendar_soarena::get_instance()->get_address($search_string);
+               }
 
-               return $returnHTML;
-               //return "<option>Ingen gruppe valgt</option>";
-       }
+               function edit_organization_values()
+               {
+                       $org_id = phpgw::get_var('organization_id');
+                       if(isset($org_id))
+                       {
 
-       /**
-        * Public method.
-        */
-       function get_address_search() {
-               $search_string = phpgw::get_var('search');
-               //var_dump($search_string);
-               return 
activitycalendar_soarena::get_instance()->get_address($search_string);
-       }
+                               $helpImg = 
$GLOBALS['phpgw']->common->image('activitycalendarfrontend', 'hjelp.gif');
 
-       function edit_organization_values() {
-               $org_id = phpgw::get_var('organization_id');
-               if (isset($org_id)) {
-            
-            $helpImg = 
$GLOBALS['phpgw']->common->image('activitycalendarfrontend', 'hjelp.gif');
-            
-            phpgwapi_jquery::formvalidator_generate(array('location', 'date', 
'security', 'file'));
-            
-                       if (isset($_POST['save_org'])) { //save updated 
organization info
-                               $organization = 
$this->so_organization->get_single($org_id);
+                               
phpgwapi_jquery::formvalidator_generate(array('location', 'date', 'security',
+                                       'file'));
 
-                               $org_homepage = phpgw::get_var('homepage');
-                               if ($org_homepage == 'http://') {
-                                       $org_homepage = "";
-                               }
-                               $org_info['name'] = phpgw::get_var('orgname');
-                               $org_info['orgnr'] = phpgw::get_var('orgno');
-                               $org_info['homepage'] = $org_homepage;
-                               $org_info['street'] = phpgw::get_var('address');
-                               $org_info['streetnumber'] = 
phpgw::get_var('number');
-                               $org_info['zip'] = phpgw::get_var('postzip');
-                               $org_info['postaddress'] = 
phpgw::get_var('postaddress');
-                               $org_info['district'] = 
$organization->get_district();
-                               $org_info['status'] = "change";
-                               $org_info['original_org_id'] = $org_id;
-                               $o_id = 
$this->so_activity->add_organization_local($org_info);
+                               if(isset($_POST['save_org']))
+                               { //save updated organization info
+                                       $organization = 
$this->so_organization->get_single($org_id);
 
-                               //add contact persons
-                               $contact1 = array();
-                               $contact1['name'] = 
phpgw::get_var('org_contact1_name');
-                               $contact1['phone'] = 
phpgw::get_var('org_contact1_phone');
-                               $contact1['mail'] = 
phpgw::get_var('org_contact1_mail');
-                               $contact1['org_id'] = $o_id;
-                               $contact1['group_id'] = 0;
-                               
$this->so_activity->add_contact_person_local($contact1);
+                                       $org_homepage = 
phpgw::get_var('homepage');
+                                       if($org_homepage == 'http://')
+                                       {
+                                               $org_homepage = "";
+                                       }
+                                       $org_info['name']                       
 = phpgw::get_var('orgname');
+                                       $org_info['orgnr']                      
 = phpgw::get_var('orgno');
+                                       $org_info['homepage']            = 
$org_homepage;
+                                       $org_info['street']                     
 = phpgw::get_var('address');
+                                       $org_info['streetnumber']        = 
phpgw::get_var('number');
+                                       $org_info['zip']                        
 = phpgw::get_var('postzip');
+                                       $org_info['postaddress']         = 
phpgw::get_var('postaddress');
+                                       $org_info['district']            = 
$organization->get_district();
+                                       $org_info['status']                     
 = "change";
+                                       $org_info['original_org_id'] = $org_id;
+                                       $o_id                                   
         = $this->so_activity->add_organization_local($org_info);
 
-                               $message = lang('change_request_ok', 
$org_info['name']);
+                                       //add contact persons
+                                       $contact1                               
 = array();
+                                       $contact1['name']                = 
phpgw::get_var('org_contact1_name');
+                                       $contact1['phone']               = 
phpgw::get_var('org_contact1_phone');
+                                       $contact1['mail']                = 
phpgw::get_var('org_contact1_mail');
+                                       $contact1['org_id']              = 
$o_id;
+                                       $contact1['group_id']    = 0;
+                                       
$this->so_activity->add_contact_person_local($contact1);
 
-                               return 
self::render_template_xsl('organization_reciept', array
-                    (
-                                               'message' => isset($message) ? 
$message : phpgw::get_var('message'),
-                                               'error' => isset($error) ? 
$error : phpgw::get_var('error'),
-                        'helpImg' => $helpImg
-                    )
-                               );
-                       } else {
-                               $c = createobject('phpgwapi.config', 
'activitycalendarfrontend');
-                               $c->read();
-                               $config = $c->config_data;
+                                       $message = lang('change_request_ok', 
$org_info['name']);
 
-                               $ajaxUrl = $c->config_data['AJAXURL'];
-                               $organization = 
$this->so_organization->get_single($org_id);
-                               $person_arr = $this->so_contact->get(null, 
null, null, null, null, null, array('organization_id' => $org_id));
-                               foreach ($person_arr as $p) {
-                                       $persons[] = $p;
+                                       return 
self::render_template_xsl('organization_reciept', array
+                                               (
+                                               'message'        => 
isset($message) ? $message : phpgw::get_var('message'),
+                                               'error'          => 
isset($error) ? $error : phpgw::get_var('error'),
+                                               'helpImg'        => $helpImg
+                                       )
+                                       );
                                }
-                
-                $organization_options = Array();
-                $organization_options['id'] = $organization->get_id();
-                $organization_options['name'] = $organization->get_name();
-                $organization_options['number'] = 
$organization->get_organization_number();
-                $organization_options['address'] = 
$organization->get_address();
-                $organization_options['zip_code'] = 
$organization->get_zip_code();
-                $organization_options['city'] = $organization->get_city();
-                $organization_options['homepage'] = 
$organization->get_homepage();
-                
-                $organization_options['contact1_name'] = 
$persons[0]->get_name();
-                $organization_options['contact1_phone'] = 
$persons[0]->get_phone();
-                $organization_options['contact1_mail'] = 
$persons[0]->get_email();
-                
-                self::add_javascript('activitycalendarfrontend', 
'activitycalendarfrontend', 'organization_edit.js');
+                               else
+                               {
+                                       $c               = 
createobject('phpgwapi.config', 'activitycalendarfrontend');
+                                       $c->read();
+                                       $config  = $c->config_data;
 
-                               return 
self::render_template_xsl('organization_edit', array
+                                       $ajaxUrl                 = 
$c->config_data['AJAXURL'];
+                                       $organization    = 
$this->so_organization->get_single($org_id);
+                                       $person_arr              = 
$this->so_contact->get(null, null, null, null, null, null, array(
+                                               'organization_id' => $org_id));
+                                       foreach($person_arr as $p)
+                                       {
+                                               $persons[] = $p;
+                                       }
+
+                                       $organization_options                   
         = array();
+                                       $organization_options['id']             
         = $organization->get_id();
+                                       $organization_options['name']           
 = $organization->get_name();
+                                       $organization_options['number']         
 = $organization->get_organization_number();
+                                       $organization_options['address']        
 = $organization->get_address();
+                                       $organization_options['zip_code']       
 = $organization->get_zip_code();
+                                       $organization_options['city']           
 = $organization->get_city();
+                                       $organization_options['homepage']       
 = $organization->get_homepage();
+
+                                       $organization_options['contact1_name']  
 = $persons[0]->get_name();
+                                       $organization_options['contact1_phone'] 
 = $persons[0]->get_phone();
+                                       $organization_options['contact1_mail']  
 = $persons[0]->get_email();
+
+                                       
self::add_javascript('activitycalendarfrontend', 'activitycalendarfrontend', 
'organization_edit.js');
+
+                                       return 
self::render_template_xsl('organization_edit', array
                                                (
-                                               'organization' => 
$organization_options,
-                                               'contact1' => $persons[0],
-                                               'editable' => true,
-                                               'message' => isset($message) ? 
$message : phpgw::get_var('message'),
-                                               'error' => isset($error) ? 
$error : phpgw::get_var('error'),
-                        'helpImg' => $helpImg,
-                                               'ajaxURL' => $ajaxUrl
-                                                               )
-                               );
+                                               'organization'   => 
$organization_options,
+                                               'contact1'               => 
$persons[0],
+                                               'editable'               => 
true,
+                                               'message'                => 
isset($message) ? $message : phpgw::get_var('message'),
+                                               'error'                  => 
isset($error) ? $error : phpgw::get_var('error'),
+                                               'helpImg'                => 
$helpImg,
+                                               'ajaxURL'                => 
$ajaxUrl
+                                       )
+                                       );
+                               }
                        }
                }
-       }
 
-       function edit_group_values() {
-               $group_id = phpgw::get_var('group_id');
-               if (isset($group_id)) {
-                       if (isset($_POST['save_group'])) { //save updated 
organization info
-                               $group = $this->so_group->get_single($group_id);
+               function edit_group_values()
+               {
+                       $group_id = phpgw::get_var('group_id');
+                       if(isset($group_id))
+                       {
+                               if(isset($_POST['save_group']))
+                               { //save updated organization info
+                                       $group = 
$this->so_group->get_single($group_id);
 
-                               $group_info['name'] = 
phpgw::get_var('groupname');
-                               $group_info['organization_id'] = 
phpgw::get_var('orgid');
-                               $group_info['description'] = 
phpgw::get_var('org_description');
-                               $group_info['status'] = "change";
-                               $group_info['original_group_id'] = $group_id;
-                               $g_id = 
$this->so_activity->add_group_local($group_info);
+                                       $group_info['name']                     
         = phpgw::get_var('groupname');
+                                       $group_info['organization_id']   = 
phpgw::get_var('orgid');
+                                       $group_info['description']              
 = phpgw::get_var('org_description');
+                                       $group_info['status']                   
 = "change";
+                                       $group_info['original_group_id'] = 
$group_id;
+                                       $g_id                                   
                 = $this->so_activity->add_group_local($group_info);
 
-                               //add contact persons
-                               $contact1 = array();
-                               $contact1['name'] = 
phpgw::get_var('group_contact1_name');
-                               $contact1['phone'] = 
phpgw::get_var('group_contact1_phone');
-                               $contact1['mail'] = 
phpgw::get_var('group_contact1_email');
-                               $contact1['org_id'] = 0;
-                               $contact1['group_id'] = $g_id;
-                               
$this->so_activity->add_contact_person_local($contact1);
+                                       //add contact persons
+                                       $contact1                               
 = array();
+                                       $contact1['name']                = 
phpgw::get_var('group_contact1_name');
+                                       $contact1['phone']               = 
phpgw::get_var('group_contact1_phone');
+                                       $contact1['mail']                = 
phpgw::get_var('group_contact1_email');
+                                       $contact1['org_id']              = 0;
+                                       $contact1['group_id']    = $g_id;
+                                       
$this->so_activity->add_contact_person_local($contact1);
 
-                               $contact2 = array();
-                               $contact2['name'] = 
phpgw::get_var('group_contact2_name');
-                               $contact2['phone'] = 
phpgw::get_var('group_contact2_phone');
-                               $contact2['mail'] = 
phpgw::get_var('group_contact2_email');
-                               $contact2['org_id'] = 0;
-                               $contact2['group_id'] = $g_id;
-                               
$this->so_activity->add_contact_person_local($contact2);
+                                       $contact2                               
 = array();
+                                       $contact2['name']                = 
phpgw::get_var('group_contact2_name');
+                                       $contact2['phone']               = 
phpgw::get_var('group_contact2_phone');
+                                       $contact2['mail']                = 
phpgw::get_var('group_contact2_email');
+                                       $contact2['org_id']              = 0;
+                                       $contact2['group_id']    = $g_id;
+                                       
$this->so_activity->add_contact_person_local($contact2);
 
-                               $message = lang('change_request_ok', 
$group_info['name']);
+                                       $message = lang('change_request_ok', 
$group_info['name']);
 
-                               $this->render('group_reciept.php', array
+                                       $this->render('group_reciept.php', array
                                                (
-                                               'message' => isset($message) ? 
$message : phpgw::get_var('message'),
-                                               'error' => isset($error) ? 
$error : phpgw::get_var('error')
-                                                               )
-                               );
-                       } else {
-                               $group = $this->so_group->get_single($group_id);
-                               $person_arr = $this->so_contact->get(null, 
null, null, null, null, null, array('group_id' => $group_id));
-                               foreach ($person_arr as $p) {
-                                       $persons[] = $p;
+                                               'message'        => 
isset($message) ? $message : phpgw::get_var('message'),
+                                               'error'          => 
isset($error) ? $error : phpgw::get_var('error')
+                                       )
+                                       );
                                }
+                               else
+                               {
+                                       $group           = 
$this->so_group->get_single($group_id);
+                                       $person_arr      = 
$this->so_contact->get(null, null, null, null, null, null, array(
+                                               'group_id' => $group_id));
+                                       foreach($person_arr as $p)
+                                       {
+                                               $persons[] = $p;
+                                       }
 
-                               $this->render('group_edit.php', array
+                                       $this->render('group_edit.php', array
                                                (
-                                               'group' => $group,
-                                               'contact1' => $persons[0],
-                                               'contact2' => $persons[1],
-                                               'editable' => true,
-                                               'message' => isset($message) ? 
$message : phpgw::get_var('message'),
-                                               'error' => isset($error) ? 
$error : phpgw::get_var('error')
-                                                               )
-                               );
+                                               'group'          => $group,
+                                               'contact1'       => $persons[0],
+                                               'contact2'       => $persons[1],
+                                               'editable'       => true,
+                                               'message'        => 
isset($message) ? $message : phpgw::get_var('message'),
+                                               'error'          => 
isset($error) ? $error : phpgw::get_var('error')
+                                       )
+                                       );
+                               }
                        }
                }
-       }
 
-       public function get_organization_activities() {
-               $GLOBALS['phpgw_info']['flags']['noheader'] = true;
-               $GLOBALS['phpgw_info']['flags']['nofooter'] = true;
-               $GLOBALS['phpgw_info']['flags']['xslt_app'] = false;
+               public function get_organization_activities()
+               {
+                       $GLOBALS['phpgw_info']['flags']['noheader']      = true;
+                       $GLOBALS['phpgw_info']['flags']['nofooter']      = true;
+                       $GLOBALS['phpgw_info']['flags']['xslt_app']      = 
false;
 
-               $org_id = phpgw::get_var('orgid');
-               $returnHTML = "<option value='0'>Ingen aktivitet 
valgt</option>";
-               if ($org_id) {
-                       $activities = $this->so_activity->get(null, null, 
'title', true, null, null, array('activity_state' => 3, 'activity_org' => 
$org_id));
-                       foreach ($activities as $act) {
-                               if (isset($act)) {
-                                       //$res_g = $group->serialize();
-                                       $activity_html[] = "<option value='" . 
$act->get_id() . "'>" . $act->get_title() . "</option>";
+                       $org_id          = phpgw::get_var('orgid');
+                       $returnHTML      = "<option value='0'>Ingen aktivitet 
valgt</option>";
+                       if($org_id)
+                       {
+                               $activities = $this->so_activity->get(null, 
null, 'title', true, null, null, array(
+                                       'activity_state' => 3, 'activity_org' 
=> $org_id));
+                               foreach($activities as $act)
+                               {
+                                       if(isset($act))
+                                       {
+                                               //$res_g = $group->serialize();
+                                               $activity_html[] = "<option 
value='" . $act->get_id() . "'>" . $act->get_title() . "</option>";
+                                       }
                                }
+                               $html            = implode(' ', $activity_html);
+                               $returnHTML      = $returnHTML . ' ' . $html;
                        }
-                       $html = implode(' ', $activity_html);
-                       $returnHTML = $returnHTML . ' ' . $html;
-               }
 
 
-               return $returnHTML;
-       }
-
-}
+                       return $returnHTML;
+               }
+       }
\ No newline at end of file

Modified: branches/dev-syncromind/activitycalendarfrontend/index.php
===================================================================
--- branches/dev-syncromind/activitycalendarfrontend/index.php  2015-12-10 
09:58:21 UTC (rev 14554)
+++ branches/dev-syncromind/activitycalendarfrontend/index.php  2015-12-10 
10:15:04 UTC (rev 14555)
@@ -1,171 +1,185 @@
 <?php
+       $GLOBALS['phpgw_info']['flags'] = array(
+               'noheader'       => true,
+               'nonavbar'       => true,
+               'currentapp' => 'login'
+       );
 
-$GLOBALS['phpgw_info']['flags'] = array(
-    'noheader' => true,
-    'nonavbar' => true,
-    'currentapp' => 'login'
-);
+       $GLOBALS['phpgw_info']['flags']['session_name']  = 
'activitycalendarfrontendsession';
+       $GLOBALS['phpgw_remote_user_fallback']                   = 'sql';
+       include_once '../header.inc.php';
 
-$GLOBALS['phpgw_info']['flags']['session_name'] = 
'activitycalendarfrontendsession';
-$GLOBALS['phpgw_remote_user_fallback'] = 'sql';
-include_once '../header.inc.php';
-
 // Make sure we're always logged in
-if (!phpgw::get_var(session_name()) || !$GLOBALS['phpgw']->session->verify()) {
+       if(!phpgw::get_var(session_name()) || 
!$GLOBALS['phpgw']->session->verify())
+       {
 
-  $c = createobject('phpgwapi.config', 'activitycalendarfrontend');
-  $c->read();
-  $config = $c->config_data;
+               $c               = createobject('phpgwapi.config', 
'activitycalendarfrontend');
+               $c->read();
+               $config  = $c->config_data;
 
-  $login = $c->config_data['anonymous_user'];
-  $passwd = $c->config_data['anonymous_pass'];
-  $_POST['submitit'] = "";
+               $login                           = 
$c->config_data['anonymous_user'];
+               $passwd                          = 
$c->config_data['anonymous_pass'];
+               $_POST['submitit']       = "";
 
-  /*           $login = "activitycalendar_guest";
-    $passwd = "bkactivities";
-    $_POST['submitit'] = "";
-   */
-  $GLOBALS['sessionid'] = $GLOBALS['phpgw']->session->create($login, $passwd);
-  if (!$GLOBALS['sessionid']) {
-    $lang_denied = lang('Anonymous access not correctly configured');
-    if ($GLOBALS['phpgw']->session->reason) {
-      $lang_denied = $GLOBALS['phpgw']->session->reason;
-    }
-    echo <<<HTML
+               /*              $login = "activitycalendar_guest";
+                 $passwd = "bkactivities";
+                 $_POST['submitit'] = "";
+                */
+               $GLOBALS['sessionid'] = 
$GLOBALS['phpgw']->session->create($login, $passwd);
+               if(!$GLOBALS['sessionid'])
+               {
+                       $lang_denied = lang('Anonymous access not correctly 
configured');
+                       if($GLOBALS['phpgw']->session->reason)
+                       {
+                               $lang_denied = 
$GLOBALS['phpgw']->session->reason;
+                       }
+                       echo <<<HTML
                                <div class="error">$lang_denied</div>
 HTML;
-    $GLOBALS['phpgw']->common->phpgw_exit(True);
-  }
-}
-$GLOBALS['phpgw_info']['flags']['currentapp'] = 'activitycalendarfrontend';
+                       $GLOBALS['phpgw']->common->phpgw_exit(True);
+               }
+       }
+       $GLOBALS['phpgw_info']['flags']['currentapp'] = 
'activitycalendarfrontend';
 
 /////////////////////////////////////////////////////////////////////////////
 // BEGIN Stuff copied from functions.inc.php
 /////////////////////////////////////////////////////////////////////////////
 
-if (isset($GLOBALS['phpgw_info']['user']['preferences']['common']['lang']) && 
$GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] != 'en') {
-  
$GLOBALS['phpgw']->translation->set_userlang($GLOBALS['phpgw_info']['user']['preferences']['common']['lang'],
 true);
-}
+       
if(isset($GLOBALS['phpgw_info']['user']['preferences']['common']['lang']) && 
$GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] != 'en')
+       {
+               
$GLOBALS['phpgw']->translation->set_userlang($GLOBALS['phpgw_info']['user']['preferences']['common']['lang'],
 true);
+       }
 
-/* A few hacker resistant constants that will be used throught the program */
-define('PHPGW_TEMPLATE_DIR', ExecMethod('phpgwapi.phpgw.common.get_tpl_dir', 
'phpgwapi'));
-define('PHPGW_IMAGES_DIR', ExecMethod('phpgwapi.phpgw.common.get_image_path', 
'phpgwapi'));
-define('PHPGW_IMAGES_FILEDIR', 
ExecMethod('phpgwapi.phpgw.common.get_image_dir', 'phpgwapi'));
-define('PHPGW_APP_ROOT', ExecMethod('phpgwapi.phpgw.common.get_app_dir'));
-define('PHPGW_APP_INC', ExecMethod('phpgwapi.phpgw.common.get_inc_dir'));
-define('PHPGW_APP_TPL', ExecMethod('phpgwapi.phpgw.common.get_tpl_dir'));
-define('PHPGW_IMAGES', ExecMethod('phpgwapi.phpgw.common.get_image_path'));
-define('PHPGW_APP_IMAGES_DIR', 
ExecMethod('phpgwapi.phpgw.common.get_image_dir'));
+       /* A few hacker resistant constants that will be used throught the 
program */
+       define('PHPGW_TEMPLATE_DIR', 
ExecMethod('phpgwapi.phpgw.common.get_tpl_dir', 'phpgwapi'));
+       define('PHPGW_IMAGES_DIR', 
ExecMethod('phpgwapi.phpgw.common.get_image_path', 'phpgwapi'));
+       define('PHPGW_IMAGES_FILEDIR', 
ExecMethod('phpgwapi.phpgw.common.get_image_dir', 'phpgwapi'));
+       define('PHPGW_APP_ROOT', 
ExecMethod('phpgwapi.phpgw.common.get_app_dir'));
+       define('PHPGW_APP_INC', 
ExecMethod('phpgwapi.phpgw.common.get_inc_dir'));
+       define('PHPGW_APP_TPL', 
ExecMethod('phpgwapi.phpgw.common.get_tpl_dir'));
+       define('PHPGW_IMAGES', 
ExecMethod('phpgwapi.phpgw.common.get_image_path'));
+       define('PHPGW_APP_IMAGES_DIR', 
ExecMethod('phpgwapi.phpgw.common.get_image_dir'));
 
-/* * **********************************************************************\
- * Load the menuaction                                                    *
-  \*********************************************************************** */
-$GLOBALS['phpgw_info']['menuaction'] = phpgw::get_var('menuaction');
-if (!$GLOBALS['phpgw_info']['menuaction']) {
-  unset($GLOBALS['phpgw_info']['menuaction']);
-}
+       /*       * 
**********************************************************************\
+        * Load the menuaction                                                  
  *
+         
\*********************************************************************** */
+       $GLOBALS['phpgw_info']['menuaction'] = phpgw::get_var('menuaction');
+       if(!$GLOBALS['phpgw_info']['menuaction'])
+       {
+               unset($GLOBALS['phpgw_info']['menuaction']);
+       }
 
-/* * ******* This sets the user variables ******** */
-$GLOBALS['phpgw_info']['user']['private_dir'] = 
$GLOBALS['phpgw_info']['server']['files_dir']
-        . '/users/' . $GLOBALS['phpgw_info']['user']['userid'];
+       /*       * ******* This sets the user variables ******** */
+       $GLOBALS['phpgw_info']['user']['private_dir'] = 
$GLOBALS['phpgw_info']['server']['files_dir']
+       . '/users/' . $GLOBALS['phpgw_info']['user']['userid'];
 
-/* This will make sure that a user has the basic default prefs. If not it will 
add them */
-$GLOBALS['phpgw']->preferences->verify_basic_settings();
+       /* This will make sure that a user has the basic default prefs. If not 
it will add them */
+       $GLOBALS['phpgw']->preferences->verify_basic_settings();
 
-/* * ******* Optional classes, which can be disabled for performance increases 
******** */
-while ($phpgw_class_name = each($GLOBALS['phpgw_info']['flags'])) {
-  if (ereg('enable_', $phpgw_class_name[0])) {
-    $enable_class = str_replace('enable_', '', $phpgw_class_name[0]);
-    $enable_class = str_replace('_class', '', $enable_class);
-    $GLOBALS['phpgw']->$enable_class = 
createObject("phpgwapi.{$enable_class}");
-  }
-}
-unset($enable_class);
-reset($GLOBALS['phpgw_info']['flags']);
+       /*       * ******* Optional classes, which can be disabled for 
performance increases ******** */
+       while($phpgw_class_name = each($GLOBALS['phpgw_info']['flags']))
+       {
+               if(ereg('enable_', $phpgw_class_name[0]))
+               {
+                       $enable_class                                    = 
str_replace('enable_', '', $phpgw_class_name[0]);
+                       $enable_class                                    = 
str_replace('_class', '', $enable_class);
+                       $GLOBALS['phpgw']->$enable_class = 
createObject("phpgwapi.{$enable_class}");
+               }
+       }
+       unset($enable_class);
+       reset($GLOBALS['phpgw_info']['flags']);
 
-/* * ***********************************************************************\
- * These lines load up the templates class                                 *
-  \************************************************************************ */
-if (!isset($GLOBALS['phpgw_info']['flags']['disable_Template_class'])
-        || !$GLOBALS['phpgw_info']['flags']['disable_Template_class']) {
-  $GLOBALS['phpgw']->template = createObject('phpgwapi.Template', 
PHPGW_APP_TPL);
-  $GLOBALS['phpgw']->xslttpl = createObject('phpgwapi.xslttemplates', 
PHPGW_APP_TPL);
-}
+       /*       * 
***********************************************************************\
+        * These lines load up the templates class                              
   *
+         
\************************************************************************ */
+       if(!isset($GLOBALS['phpgw_info']['flags']['disable_Template_class']) || 
!$GLOBALS['phpgw_info']['flags']['disable_Template_class'])
+       {
+               $GLOBALS['phpgw']->template      = 
createObject('phpgwapi.Template', PHPGW_APP_TPL);
+               $GLOBALS['phpgw']->xslttpl       = 
createObject('phpgwapi.xslttemplates', PHPGW_APP_TPL);
+       }
 
-/* * ***********************************************************************\
- * Verify that the users session is still active otherwise kick them out   *
-  \************************************************************************ */
-if ($GLOBALS['phpgw_info']['flags']['currentapp'] != 'home' && 
$GLOBALS['phpgw_info']['flags']['currentapp'] != 'about') {
-  if (!$GLOBALS['phpgw']->acl->check('run', PHPGW_ACL_READ, 
$GLOBALS['phpgw_info']['flags']['currentapp'])) {
-    $GLOBALS['phpgw']->common->phpgw_header(true);
-    $GLOBALS['phpgw']->log->write(array('text' => 'W-Permissions, Attempted to 
access %1', 'p1' => $GLOBALS['phpgw_info']['flags']['currentapp']));
+       /*       * 
***********************************************************************\
+        * Verify that the users session is still active otherwise kick them 
out   *
+         
\************************************************************************ */
+       if($GLOBALS['phpgw_info']['flags']['currentapp'] != 'home' && 
$GLOBALS['phpgw_info']['flags']['currentapp'] != 'about')
+       {
+               if(!$GLOBALS['phpgw']->acl->check('run', PHPGW_ACL_READ, 
$GLOBALS['phpgw_info']['flags']['currentapp']))
+               {
+                       $GLOBALS['phpgw']->common->phpgw_header(true);
+                       $GLOBALS['phpgw']->log->write(array('text' => 
'W-Permissions, Attempted to access %1',
+                               'p1' => 
$GLOBALS['phpgw_info']['flags']['currentapp']));
 
-    $lang_denied = lang('Access not permitted');
-    echo <<<HTML
+                       $lang_denied = lang('Access not permitted');
+                       echo <<<HTML
                                        <div class="error">$lang_denied</div>
 
 HTML;
-    $GLOBALS['phpgw']->common->phpgw_exit(True);
-  }
-}
+                       $GLOBALS['phpgw']->common->phpgw_exit(True);
+               }
+       }
 
 //  Already called from sessions::verify
 //     $GLOBALS['phpgw']->applications->read_installed_apps(); // to get 
translated app-titles
 
-/* * ***********************************************************************\
- * Load the header unless the developer turns it off                       *
-  \************************************************************************ */
-if (!isset($GLOBALS['phpgw_info']['flags']['noheader']) || 
!$GLOBALS['phpgw_info']['flags']['noheader']) {
-  $inc_navbar = !isset($GLOBALS['phpgw_info']['flags']['nonavbar']) || 
!$GLOBALS['phpgw_info']['flags']['nonavbar'];
-  $GLOBALS['phpgw']->common->phpgw_header($inc_navbar);
-  unset($inc_navbar);
-}
+       /*       * 
***********************************************************************\
+        * Load the header unless the developer turns it off                    
   *
+         
\************************************************************************ */
+       if(!isset($GLOBALS['phpgw_info']['flags']['noheader']) || 
!$GLOBALS['phpgw_info']['flags']['noheader'])
+       {
+               $inc_navbar = 
!isset($GLOBALS['phpgw_info']['flags']['nonavbar']) || 
!$GLOBALS['phpgw_info']['flags']['nonavbar'];
+               $GLOBALS['phpgw']->common->phpgw_header($inc_navbar);
+               unset($inc_navbar);
+       }
 
-/* * ***********************************************************************\
- * Load the app include files if the exists                                *
-  \************************************************************************ */
-/* Then the include file */
-if (!preg_match("/phpgwapi/i", PHPGW_APP_INC) && file_exists(PHPGW_APP_INC . 
'/functions.inc.php') && !isset($GLOBALS['phpgw_info']['menuaction'])) {
-  include_once PHPGW_APP_INC . '/functions.inc.php';
-}
-if (address@hidden'phpgw_info']['flags']['noheader'] &&
-        address@hidden'phpgw_info']['flags']['noappheader'] &&
-        file_exists(PHPGW_APP_INC . '/header.inc.php') && 
!isset($GLOBALS['phpgw_info']['menuaction'])) {
-  include_once PHPGW_APP_INC . '/header.inc.php';
-}
+       /*       * 
***********************************************************************\
+        * Load the app include files if the exists                             
   *
+         
\************************************************************************ */
+       /* Then the include file */
+       if(!preg_match("/phpgwapi/i", PHPGW_APP_INC) && 
file_exists(PHPGW_APP_INC . '/functions.inc.php') && 
!isset($GLOBALS['phpgw_info']['menuaction']))
+       {
+               include_once PHPGW_APP_INC . '/functions.inc.php';
+       }
+       if(address@hidden'phpgw_info']['flags']['noheader'] &&
+       address@hidden'phpgw_info']['flags']['noappheader'] &&
+       file_exists(PHPGW_APP_INC . '/header.inc.php') && 
!isset($GLOBALS['phpgw_info']['menuaction']))
+       {
+               include_once PHPGW_APP_INC . '/header.inc.php';
+       }
 
 /////////////////////////////////////////////////////////////////////////////
 // END Stuff copied from functions.inc.php
 /////////////////////////////////////////////////////////////////////////////
 
-if (isset($_GET['menuaction'])) {
-  list($app, $class, $method) = explode('.', $_GET['menuaction']);
-} else {
-  //   $GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction' => 
'activitycalendarfrontend.uiactivity.add'));
-  $app = 'activitycalendarfrontend';
-  $class = 'uiactivity';
-  $method = 'add';
-}
-$GLOBALS[$class] = CreateObject("{$app}.{$class}");
+       if(isset($_GET['menuaction']))
+       {
+               list($app, $class, $method) = explode('.', $_GET['menuaction']);
+       }
+       else
+       {
+               //      
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction' => 
'activitycalendarfrontend.uiactivity.add'));
+               $app     = 'activitycalendarfrontend';
+               $class   = 'uiactivity';
+               $method  = 'add';
+       }
+       $GLOBALS[$class] = CreateObject("{$app}.{$class}");
 
-$invalid_data = false; //FIXME consider whether this should be computed as in 
the main index.php
-if (!$invalid_data
-        && is_object($GLOBALS[$class])
-        && isset($GLOBALS[$class]->public_functions)
-        && is_array($GLOBALS[$class]->public_functions)
-        && isset($GLOBALS[$class]->public_functions[$method])
-        && $GLOBALS[$class]->public_functions[$method]) {
-  if (phpgw::get_var('X-Requested-With', 'string', 'SERVER') == 
'XMLHttpRequest'
-          // deprecated
-          || phpgw::get_var('phpgw_return_as', 'string', 'GET') == 'json') {
-    // comply with RFC 4627
-    header('Content-Type: application/json');
-    $return_data = $GLOBALS[$class]->$method();
-    echo json_encode($return_data);
-    $GLOBALS['phpgw_info']['flags']['nofooter'] = true;
-    $GLOBALS['phpgw']->common->phpgw_exit();
-  } else {
-    $GLOBALS[$class]->$method();
-    $GLOBALS['phpgw']->common->phpgw_footer();
-  }
-}
\ No newline at end of file
+       $invalid_data = false; //FIXME consider whether this should be computed 
as in the main index.php
+       if(!$invalid_data && is_object($GLOBALS[$class]) && 
isset($GLOBALS[$class]->public_functions) && 
is_array($GLOBALS[$class]->public_functions) && 
isset($GLOBALS[$class]->public_functions[$method]) && 
$GLOBALS[$class]->public_functions[$method])
+       {
+               if(phpgw::get_var('X-Requested-With', 'string', 'SERVER') == 
'XMLHttpRequest'
+               // deprecated
+               || phpgw::get_var('phpgw_return_as', 'string', 'GET') == 'json')
+               {
+                       // comply with RFC 4627
+                       header('Content-Type: application/json');
+                       $return_data                                            
                 = $GLOBALS[$class]->$method();
+                       echo json_encode($return_data);
+                       $GLOBALS['phpgw_info']['flags']['nofooter']      = true;
+                       $GLOBALS['phpgw']->common->phpgw_exit();
+               }
+               else
+               {
+                       $GLOBALS[$class]->$method();
+                       $GLOBALS['phpgw']->common->phpgw_footer();
+               }
+       }
\ No newline at end of file

Modified: 
branches/dev-syncromind/activitycalendarfrontend/js/activitycalendarfrontend/activity_edit.js
===================================================================
--- 
branches/dev-syncromind/activitycalendarfrontend/js/activitycalendarfrontend/activity_edit.js
       2015-12-10 09:58:21 UTC (rev 14554)
+++ 
branches/dev-syncromind/activitycalendarfrontend/js/activitycalendarfrontend/activity_edit.js
       2015-12-10 10:15:04 UTC (rev 14555)
@@ -1,387 +1,314 @@
 var current_org_id = "";
 function get_available_groups()
 {
-//    var org_id = document.getElementById('organization_id').value;
-//    var div_select = document.getElementById('group_select');
-    
-    var org_id = $('#organization_id').val();
-    var div_select = $('#group_select');
+       var org_id = $('#organization_id').val();
+       var div_select = $('#group_select');
 
-//<?php if ($activity->get_group_id()) { ?>
-//                     //url = 
"/aktivby/registreringsskjema/ny/index.php?menuaction=activitycalendarfrontend.uiactivity.get_organization_groups&amp;phpgw_return_as=json&amp;orgid="
 + org_id + "&amp;groupid=" + <?php echo $activity->get_group_id(); ?>;
-//                     url = "<?php echo $ajaxURL 
?>index.php?menuaction=activitycalendarfrontend.uiactivity.get_organization_groups&amp;phpgw_return_as=json&amp;orgid="
 + org_id + "&amp;groupid=" + <?php echo $activity->get_group_id(); ?>;
-//<?php } else { ?>
-//                     //url = 
"/aktivby/registreringsskjema/ny/index.php?menuaction=activitycalendarfrontend.uiactivity.get_organization_groups&amp;phpgw_return_as=json&amp;orgid="
 + org_id;
-//                     url = "<?php echo $ajaxURL 
?>index.php?menuaction=activitycalendarfrontend.uiactivity.get_organization_groups&amp;phpgw_return_as=json&amp;orgid="
 + org_id;
-//<?php } ?>
+       if (org_id != null && org_id == 'new_org')
+       {
+               //alert('new_org');
+               document.getElementById('new_org').style.display = "block";
+               document.getElementById('new_org_fields').style.display = 
"block";
+               document.getElementById('group_label').style.display = "none";
+               document.getElementById('group_select').style.display = "none";
+       }
+       else if (org_id != null && org_id == 'change_org')
+       {
+               document.getElementById('new_org').style.display = "block";
+               document.getElementById('new_org_fields').style.display = 
"none";
+               document.getElementById('change_org_fields').style.display = 
"block";
+               document.getElementById('group_label').style.display = "none";
+               document.getElementById('group_select').style.display = "none";
+       }
+       else
+       {
+               document.getElementById('new_org').style.display = "none";
+               document.getElementById('new_org_fields').style.display = 
"none";
+               document.getElementById('change_org_fields').style.display = 
"none";
 
-    if(org_id != null && org_id == 'new_org')
-    {
-        //alert('new_org');
-        document.getElementById('new_org').style.display = "block";
-        document.getElementById('new_org_fields').style.display = "block";
-        document.getElementById('group_label').style.display = "none";
-        document.getElementById('group_select').style.display = "none";
-    }
-    else if(org_id != null && org_id == 'change_org')
-    {
-        document.getElementById('new_org').style.display = "block";
-        document.getElementById('new_org_fields').style.display = "none";
-        document.getElementById('change_org_fields').style.display = "block";
-        document.getElementById('group_label').style.display = "none";
-        document.getElementById('group_select').style.display = "none";
-    }
-    else
-    {
-        document.getElementById('new_org').style.display = "none";
-        document.getElementById('new_org_fields').style.display = "none";
-        document.getElementById('change_org_fields').style.display = "none";
-//        var divcontent_start = "<select name=\"group_id\" id=\"group_id\" 
onchange=\"javascript:checkNewGroup()\">";
-//        var divcontent_end = "</select>";
+               var attr = [{name: 'name', value: 'group_id'}, {name: 'id', 
value: 'group_id'}, {name: 'onchange', value: 'javascript:checkNewGroup()'}];
 
-        var attr = [{name: 'name', value: 'group_id'},{name: 'id', value: 
'group_id'}, {name: 'onchange', value: 'javascript:checkNewGroup()'}];
-        
-        div_select.hide();
-        
-        if (org_id && org_id != current_org_id) {
-            div_select.show();
-            populateSelect_activityCalendar(availableGroupsURL, div_select, 
attr);
-            current_org_id = org_id;
-        }
+               div_select.hide();
 
-//        var callback = {
-//            success: function(response){
-//                div_select.innerHTML = divcontent_start + 
JSON.parse(response.responseText) + divcontent_end; 
-//            },
-//            failure: function(o) {
-//                alert("AJAX doesn't work"); //FAILURE
-//            }
-//        }
-//        var trans = YAHOO.util.Connect.asyncRequest('GET', url, callback, 
null);
-    }
+               if (org_id && org_id != current_org_id) {
+                       div_select.show();
+                       populateSelect_activityCalendar(availableGroupsURL, 
div_select, attr);
+                       current_org_id = org_id;
+               }
+       }
 }
 
-//YAHOO.util.Event.onDOMReady(function()
-//{
-//    get_available_groups();
-//});
-
-$(document).ready(function(){
-    if ($('#organization_id').length) {
-        get_available_groups();
-    }
+$(document).ready(function () {
+       if ($('#organization_id').length) {
+               get_available_groups();
+       }
 });
 
 function checkNewGroup()
 {
-    var group_selected = document.getElementById('group_id').value;
-    if(group_selected == 'new_group')
-    {
-        document.getElementById('new_group').style.display = "block";
-        document.getElementById('new_group_fields').style.display = "block";
-    }
-    else
-    {
-        document.getElementById('new_group').style.display = "none";
-        document.getElementById('new_group_fields').style.display = "none";
-    }
+       var group_selected = document.getElementById('group_id').value;
+       if (group_selected == 'new_group')
+       {
+               document.getElementById('new_group').style.display = "block";
+               document.getElementById('new_group_fields').style.display = 
"block";
+       }
+       else
+       {
+               document.getElementById('new_group').style.display = "none";
+               document.getElementById('new_group_fields').style.display = 
"none";
+       }
 }
 
 var current_address = "";
 function get_address_search()
 {
-    var address = document.getElementById('address').value;
-    var div_address = document.getElementById('address_container');
-//    div_address.style.display="block";
+       var address = document.getElementById('address').value;
+       var div_address = document.getElementById('address_container');
+       var url = phpGWLink('activitycalendarfrontend/', {menuaction: 
'activitycalendarfrontend.uiactivity.get_address_search', search: address}, 
true);
 
-    //url = 
"/aktivby/registreringsskjema/ny/index.php?menuaction=activitycalendarfrontend.uiactivity.get_address_search&amp;phpgw_return_as=json&amp;search="
 + address;
-//    url = "<?php echo $ajaxURL 
?>index.php?menuaction=activitycalendarfrontend.uiactivity.get_address_search&amp;phpgw_return_as=json&amp;search="
 + address;
-    var url = phpGWLink('activitycalendarfrontend/', {menuaction: 
'activitycalendarfrontend.uiactivity.get_address_search', search: address}, 
true);
+       div_address.hide();
 
-//    var divcontent_start = "<select name=\"address_select\" id=\"address\" 
size=\"5\" onChange='setAddressValue(this)'>";
-//    var divcontent_end = "</select>";
-//
-//    var callback = {
-//        success: function(response){
-//            div_address.innerHTML = divcontent_start + 
JSON.parse(response.responseText) + divcontent_end; 
-//        },
-//        failure: function(o) {
-//            alert("AJAX doesn't work"); //FAILURE
-//        }
-//    }
-//    var trans = YAHOO.util.Connect.asyncRequest('GET', url, callback, null);
-    
-    div_address.hide();
+       if (address && address != current_address) {
+               div_address.show();
+               populateSelect_activityCalendar(url, div_address, attr);
+               current_address = address;
+       }
 
-    if (address && address != current_address) {
-        div_address.show();
-        populateSelect_activityCalendar(url, div_address, attr);
-        current_address = address;
-    }
-
 }
 
 var current_address_search_cp2 = "";
 function get_address_search_cp2()
 {
-//    var address = document.getElementById('contact2_address').value;
-//    var div_address = document.getElementById('contact2_address_container');
-//    div_address.style.display="block";
-    
-    var address = $('#contact2_address');
-    var div_address = $('#contact2_address_container');
+       var address = $('#contact2_address');
+       var div_address = $('#contact2_address_container');
 
-    //url = 
"/aktivby/registreringsskjema/ny/index.php?menuaction=activitycalendarfrontend.uiactivity.get_address_search&amp;phpgw_return_as=json&amp;search="
 + address;
-//    url = "<?php echo $ajaxURL 
?>index.php?menuaction=activitycalendarfrontend.uiactivity.get_address_search&amp;phpgw_return_as=json&amp;search="
 + address;
-    
-//    var divcontent_start = "<select name=\"contact2_address_select\" 
id=\"address_cp2\" size=\"5\" onChange='setAddressValue(this)'>";
-//    var divcontent_end = "</select>";
+       var url = phpGWLink('activitycalendarfrontend/', {menuaction: 
'activitycalendarfrontend.uiactivity.get_address_search', search: address}, 
true);
+       var attr = [{name: 'name', value: 'contact2_address_select'}, {name: 
'id', value: 'address_cp2'}, {name: 'size', value: '5'}, {name: 'onChange', 
value: 'setAddressValue(this)'}];
 
-    var url = phpGWLink('activitycalendarfrontend/', {menuaction: 
'activitycalendarfrontend.uiactivity.get_address_search', search: address}, 
true);
-    var attr = [{name: 'name', value: 'contact2_address_select'}, {name: 'id', 
value: 'address_cp2'}, {name: 'size', value: '5'}, {name: 'onChange', value: 
'setAddressValue(this)'}];
+       div_address.hide();
 
-//    var callback = {
-//        success: function(response){
-//            div_address.innerHTML = divcontent_start + 
JSON.parse(response.responseText) + divcontent_end; 
-//        },
-//        failure: function(o) {
-//            alert("AJAX doesn't work"); //FAILURE
-//        }
-//    }
-//    var trans = YAHOO.util.Connect.asyncRequest('GET', url, callback, null);
-    
-    div_address.hide();
-    
-    if (address && address != current_address_search_cp2) {
-        div_address.show();
-        populateSelect_activityCalendar(url, div_address, attr);
-        current_address_search_cp2 = address;
-    }
+       if (address && address != current_address_search_cp2) {
+               div_address.show();
+               populateSelect_activityCalendar(url, div_address, attr);
+               current_address_search_cp2 = address;
+       }
 }
 
 function setAddressValue(field)
 {
-    if(field.name == 'contact2_address_select')
-    {
-        var address = document.getElementById('contact2_address');
-        var div_address = 
document.getElementById('contact2_address_container');
+       if (field.name == 'contact2_address_select')
+       {
+               var address = document.getElementById('contact2_address');
+               var div_address = 
document.getElementById('contact2_address_container');
 
-//        address.value=field.value;
-        address.value = (field.value && field.value != 0) ? field.value : "";
-        div_address.style.display="none";
-    }
-    else
-    {
-        var address = document.getElementById('address');
-        var div_address = document.getElementById('address_container');
+               address.value = (field.value && field.value != 0) ? field.value 
: "";
+               div_address.style.display = "none";
+       }
+       else
+       {
+               var address = document.getElementById('address');
+               var div_address = document.getElementById('address_container');
 
-//        address.value=field.value;
-        address.value = (field.value && field.value != 0) ? field.value : "";
-        div_address.style.display="none";
-    }
+               address.value = (field.value && field.value != 0) ? field.value 
: "";
+               div_address.style.display = "none";
+       }
 }
 
 function allOK()
 {
-    if(document.getElementById('title').value == null || 
document.getElementById('title').value == '')
-    {
-        alert("Tittel må fylles ut!");
-        return false;
-    }
-    if(document.getElementsByTagName('textarea')[0].value == null || 
document.getElementsByTagName('textarea')[0].value == '')
-    {
-        alert("Beskrivelse må fylles ut!");
-        return false;
-    }
-    if(document.getElementsByTagName('textarea')[0].value.length > 254)
-    {
-        alert("Beskrivelse kan maksimalt være 255 tegn!");
-        return false;
-    }
-    if(document.getElementById('category').value == null || 
document.getElementById('category').value == 0)
-    {
-        alert("Kategori må fylles ut!");
-        return false;
-    } 
-    if((document.getElementById('internal_arena_id').value == null || 
document.getElementById('internal_arena_id').value == 0))
-    {
-        alert("Lokale må fylles ut!");
-        return false;
-    }
-    if(document.getElementById('time').value == null || 
document.getElementById('time').value == '')
-    {
-        alert("Dag og tid må fylles ut!");
-        return false;
-    }
-    if(document.getElementById('contact_name').value == null || 
document.getElementById('contact_name').value == '')
-    {
-        alert("Navn på kontaktperson må fylles ut!");
-        return false;
-    }
-    if(document.getElementById('contact_phone').value == null || 
document.getElementById('contact_phone').value == '')
-    {
-        alert("Telefonnummer til kontaktperson må fylles ut!");
-        return false;
-    }
-    if(document.getElementById('contact_phone').value != null && 
document.getElementById('contact_phone').value.length < 8)
-    {
-        alert("Telefonnummer må inneholde minst 8 siffer!");
-        return false;
-    }
-    if(document.getElementById('contact_mail').value == null || 
document.getElementById('contact_mail').value == '')
-    {
-        alert("E-postadresse til kontaktperson må fylles ut!");
-        return false;
-    }
-    if(document.getElementById('contact_mail2').value == null || 
document.getElementById('contact_mail2').value == '')
-    {
-        alert("Begge felter for E-post må fylles ut!");
-        return false;
-    }
-    if(document.getElementById('contact_mail').value != 
document.getElementById('contact_mail2').value)
-    {
-        alert("E-post må være den samme i begge felt!");
-        return false;
-    }
-    if(document.getElementById('office').value == null || 
document.getElementById('office').value == 0)
-    {
-        alert("Hovedansvarlig kulturkontor må fylles ut!");
-        return false;
-    }
-    else
-        return true;
+       if (document.getElementById('title').value == null || 
document.getElementById('title').value == '')
+       {
+               alert("Tittel må fylles ut!");
+               return false;
+       }
+       if (document.getElementsByTagName('textarea')[0].value == null || 
document.getElementsByTagName('textarea')[0].value == '')
+       {
+               alert("Beskrivelse må fylles ut!");
+               return false;
+       }
+       if (document.getElementsByTagName('textarea')[0].value.length > 254)
+       {
+               alert("Beskrivelse kan maksimalt være 255 tegn!");
+               return false;
+       }
+       if (document.getElementById('category').value == null || 
document.getElementById('category').value == 0)
+       {
+               alert("Kategori må fylles ut!");
+               return false;
+       }
+       if ((document.getElementById('internal_arena_id').value == null || 
document.getElementById('internal_arena_id').value == 0))
+       {
+               alert("Lokale må fylles ut!");
+               return false;
+       }
+       if (document.getElementById('time').value == null || 
document.getElementById('time').value == '')
+       {
+               alert("Dag og tid må fylles ut!");
+               return false;
+       }
+       if (document.getElementById('contact_name').value == null || 
document.getElementById('contact_name').value == '')
+       {
+               alert("Navn på kontaktperson må fylles ut!");
+               return false;
+       }
+       if (document.getElementById('contact_phone').value == null || 
document.getElementById('contact_phone').value == '')
+       {
+               alert("Telefonnummer til kontaktperson må fylles ut!");
+               return false;
+       }
+       if (document.getElementById('contact_phone').value != null && 
document.getElementById('contact_phone').value.length < 8)
+       {
+               alert("Telefonnummer må inneholde minst 8 siffer!");
+               return false;
+       }
+       if (document.getElementById('contact_mail').value == null || 
document.getElementById('contact_mail').value == '')
+       {
+               alert("E-postadresse til kontaktperson må fylles ut!");
+               return false;
+       }
+       if (document.getElementById('contact_mail2').value == null || 
document.getElementById('contact_mail2').value == '')
+       {
+               alert("Begge felter for E-post må fylles ut!");
+               return false;
+       }
+       if (document.getElementById('contact_mail').value != 
document.getElementById('contact_mail2').value)
+       {
+               alert("E-post må være den samme i begge felt!");
+               return false;
+       }
+       if (document.getElementById('office').value == null || 
document.getElementById('office').value == 0)
+       {
+               alert("Hovedansvarlig kulturkontor må fylles ut!");
+               return false;
+       }
+       else
+               return true;
 }
 
 
-
-
-
-
-
-
 if ($.formUtils) {
-    $.formUtils.addValidator({
-        name: 'description',
-        validatorFunction: function(){
-            var description = $('#description').val();
-            var v = true;
-            if(description == null || description == "") {
-                v = false;
-            }
-            return v;
-        },
-        errorMessage: 'Beskrivelse må fylles ut!',
-        errorMessageKey: 'description'
-    });    
-    $.formUtils.addValidator({
-        name: 'description_length',
-        validatorFunction: function(){
-            var description = $('#description').val();
-            var v = true;
-            if(description.length > 254) {
-                v = false;
-            }
-            return v;
-        },
-        errorMessage: 'Beskrivelse kan maksimalt være 255 tegn!',
-        errorMessageKey: 'description_length'
-    });
-    $.formUtils.addValidator({
-        name: 'target',
-        validatorFunction: function() {
-            var n = 0;
-            $('input[name="target[]"]').each(function(){
-               if ($(this).is(':checked')) {
-                   n++;
-               }
-            });
-            var v = (n > 0) ? true : false;
-            return v;
-        },
-        errorMessage: 'Målgruppe må fylles ut!',
-        errorMessageKey: 'target'
-    });
-    $.formUtils.addValidator({
-        name: 'district',
-        validatorFunction: function() {
-            var n = 0;
-            $('input[name="district"]').each(function(){
-               if ($(this).is(':checked')) {
-                   n++;
-               }
-            });
-            var v = (n > 0) ? true : false;
-            return v;
-        },
-        errorMessage: 'Bydel må fylles ut!',
-        errorMessageKey: 'district'
-    });
-    $.formUtils.addValidator({
-        name: 'contact_phone',
-        validatorFunction: function(){
-            var contact_phone = $('#contact_phone').val();
-            var v = true;
-            if(contact_phone == null || contact_phone == '') {
-                v = false;
-            }
-            return v;
-        },
-        errorMessage: 'Telefonnummer til kontaktperson må fylles ut!',
-        errorMessageKey: 'contact_phone'
-    });
-    $.formUtils.addValidator({
-        name: 'contact_phone_length',
-        validatorFunction: function(){
-            var contact_phone = $('#contact_phone').val();
-            var v = true;
-            if((contact_phone != null || contact_phone != '') && 
contact_phone.length < 8) {
-                v = false;
-            }
-            return v;
-        },
-        errorMessage: 'Telefonnummer må inneholde minst 8 siffer!',
-        errorMessageKey: 'contact_phone_length'
-    });
-    $.formUtils.addValidator({
-        name: 'contact_mail',
-        validatorFunction: function(){
-            var contact_mail = $('#contact_mail').val();
-            var v = true;
-            if(contact_mail == null || contact_mail == '') {
-                v = false;
-            }
-            return v;
-        },
-        errorMessage: 'E-post for kontaktperson må fylles ut!',
-        errorMessageKey: 'contact_mail'
-    });
-    $.formUtils.addValidator({
-        name: 'contact_mail2',
-        validatorFunction: function(){
-            var contact_mail2 = $('#contact_mail2').val();
-            var v = true;
-            if(contact_mail2 == null || contact_mail2 == '') {
-                v = false;
-            }
-            return v;
-        },
-        errorMessage: 'Begge felter for E-post må fylles ut!',
-        errorMessageKey: 'contact_mail2'
-    });
-    $.formUtils.addValidator({
-        name: 'contact_mail2_confirm',
-        validatorFunction: function(){
-            var contact_mail1 = $('#contact_mail').val();
-            var contact_mail2 = $('#contact_mail2').val();
-            var v = true;
-            if(contact_mail2 != null || contact_mail2 != '') {
-                if (contact_mail1 != contact_mail2) {
-                    v = false;
-                }
-            }
-            return v;
-        },
-        errorMessage: 'E-post må være den samme i begge felt!',
-        errorMessageKey: 'contact_mail2_confirm'
-    });
+       $.formUtils.addValidator({
+               name: 'description',
+               validatorFunction: function () {
+                       var description = $('#description').val();
+                       var v = true;
+                       if (description == null || description == "") {
+                               v = false;
+                       }
+                       return v;
+               },
+               errorMessage: 'Beskrivelse må fylles ut!',
+               errorMessageKey: 'description'
+       });
+       $.formUtils.addValidator({
+               name: 'description_length',
+               validatorFunction: function () {
+                       var description = $('#description').val();
+                       var v = true;
+                       if (description.length > 254) {
+                               v = false;
+                       }
+                       return v;
+               },
+               errorMessage: 'Beskrivelse kan maksimalt være 255 tegn!',
+               errorMessageKey: 'description_length'
+       });
+       $.formUtils.addValidator({
+               name: 'target',
+               validatorFunction: function () {
+                       var n = 0;
+                       $('input[name="target[]"]').each(function () {
+                               if ($(this).is(':checked')) {
+                                       n++;
+                               }
+                       });
+                       var v = (n > 0) ? true : false;
+                       return v;
+               },
+               errorMessage: 'Målgruppe må fylles ut!',
+               errorMessageKey: 'target'
+       });
+       $.formUtils.addValidator({
+               name: 'district',
+               validatorFunction: function () {
+                       var n = 0;
+                       $('input[name="district"]').each(function () {
+                               if ($(this).is(':checked')) {
+                                       n++;
+                               }
+                       });
+                       var v = (n > 0) ? true : false;
+                       return v;
+               },
+               errorMessage: 'Bydel må fylles ut!',
+               errorMessageKey: 'district'
+       });
+       $.formUtils.addValidator({
+               name: 'contact_phone',
+               validatorFunction: function () {
+                       var contact_phone = $('#contact_phone').val();
+                       var v = true;
+                       if (contact_phone == null || contact_phone == '') {
+                               v = false;
+                       }
+                       return v;
+               },
+               errorMessage: 'Telefonnummer til kontaktperson må fylles ut!',
+               errorMessageKey: 'contact_phone'
+       });
+       $.formUtils.addValidator({
+               name: 'contact_phone_length',
+               validatorFunction: function () {
+                       var contact_phone = $('#contact_phone').val();
+                       var v = true;
+                       if ((contact_phone != null || contact_phone != '') && 
contact_phone.length < 8) {
+                               v = false;
+                       }
+                       return v;
+               },
+               errorMessage: 'Telefonnummer må inneholde minst 8 siffer!',
+               errorMessageKey: 'contact_phone_length'
+       });
+       $.formUtils.addValidator({
+               name: 'contact_mail',
+               validatorFunction: function () {
+                       var contact_mail = $('#contact_mail').val();
+                       var v = true;
+                       if (contact_mail == null || contact_mail == '') {
+                               v = false;
+                       }
+                       return v;
+               },
+               errorMessage: 'E-post for kontaktperson må fylles ut!',
+               errorMessageKey: 'contact_mail'
+       });
+       $.formUtils.addValidator({
+               name: 'contact_mail2',
+               validatorFunction: function () {
+                       var contact_mail2 = $('#contact_mail2').val();
+                       var v = true;
+                       if (contact_mail2 == null || contact_mail2 == '') {
+                               v = false;
+                       }
+                       return v;
+               },
+               errorMessage: 'Begge felter for E-post må fylles ut!',
+               errorMessageKey: 'contact_mail2'
+       });
+       $.formUtils.addValidator({
+               name: 'contact_mail2_confirm',
+               validatorFunction: function () {
+                       var contact_mail1 = $('#contact_mail').val();
+                       var contact_mail2 = $('#contact_mail2').val();
+                       var v = true;
+                       if (contact_mail2 != null || contact_mail2 != '') {
+                               if (contact_mail1 != contact_mail2) {
+                                       v = false;
+                               }
+                       }
+                       return v;
+               },
+               errorMessage: 'E-post må være den samme i begge felt!',
+               errorMessageKey: 'contact_mail2_confirm'
+       });
 }
\ No newline at end of file

Modified: 
branches/dev-syncromind/activitycalendarfrontend/js/activitycalendarfrontend/activity_edit_step_1.js
===================================================================
--- 
branches/dev-syncromind/activitycalendarfrontend/js/activitycalendarfrontend/activity_edit_step_1.js
        2015-12-10 09:58:21 UTC (rev 14554)
+++ 
branches/dev-syncromind/activitycalendarfrontend/js/activitycalendarfrontend/activity_edit_step_1.js
        2015-12-10 10:15:04 UTC (rev 14555)
@@ -1,59 +1,32 @@
 function isOK()
 {
-    if(document.getElementById('activity_id').value == null || 
document.getElementById('activity_id').value == '' || 
document.getElementById('activity_id').value == 0)
-    {
-        alert("Du må velge en aktivitet som skal endres!");
-        return false;
-    }
-    else
-    {
-        return true;
-    }
+       if (document.getElementById('activity_id').value == null || 
document.getElementById('activity_id').value == '' || 
document.getElementById('activity_id').value == 0)
+       {
+               alert("Du må velge en aktivitet som skal endres!");
+               return false;
+       }
+       else
+       {
+               return true;
+       }
 }
 
 var current_org_id_get_activities = "";
 function get_activities()
 {
-//    var org_id = document.getElementById('organization_id').value;
-//    var div_select = document.getElementById('activity_select');
-    
-    var org_id = $('#organization_id').val();
-    var div_select = $('#activity_select');
+       var org_id = $('#organization_id').val();
+       var div_select = $('#activity_select');
 
-//    url = "<?php echo $ajaxURL 
?>index.php?menuaction=activitycalendarfrontend.uiactivity.get_organization_activities&amp;phpgw_return_as=json&amp;orgid="
 + org_id;
-//
-//    var divcontent_start = "<select name=\"activity_id\" 
id=\"activity_id\">";
-//    var divcontent_end = "</select>";
-    
-    var url = phpGWLink('activitycalendarfrontend/', {menuaction: 
'activitycalendarfrontend.uiactivity.get_organization_activities', orgid: 
org_id}, true);
-    var attr = [{name: 'name', value: 'activity_id'}, {name: 'id', value: 
'activity_id'}];
-    
+       var url = phpGWLink('activitycalendarfrontend/', {menuaction: 
'activitycalendarfrontend.uiactivity.get_organization_activities', orgid: 
org_id}, true);
+       var attr = [{name: 'name', value: 'activity_id'}, {name: 'id', value: 
'activity_id'}];
 
-//    var callback = {
-//        success: function(response){
-//            div_select.innerHTML = divcontent_start + 
JSON.parse(response.responseText) + divcontent_end; 
-//        },
-//        failure: function(o) {
-//            alert("AJAX doesn't work"); //FAILURE
-//        }
-//    }
-//    var trans = YAHOO.util.Connect.asyncRequest('GET', url, callback, null);
-    
-//    div_select.hide();
+       if (org_id && org_id != current_org_id_get_activities) {
+               populateSelect_activityCalendar(url, div_select, attr);
+               current_org_id_get_activities = org_id;
+       }
 
-    if (org_id && org_id != current_org_id_get_activities) {
-//        div_select.show();
-        populateSelect_activityCalendar(url, div_select, attr);
-        current_org_id_get_activities = org_id;
-    }
-
 }
 
-//YAHOO.util.Event.onDOMReady(function()
-//{
-//    get_activities();
-//});
-
-$(document).ready(function(){
-    get_activities();
+$(document).ready(function () {
+       get_activities();
 });
\ No newline at end of file

Modified: 
branches/dev-syncromind/activitycalendarfrontend/js/activitycalendarfrontend/activity_new.js
===================================================================
--- 
branches/dev-syncromind/activitycalendarfrontend/js/activitycalendarfrontend/activity_new.js
        2015-12-10 09:58:21 UTC (rev 14554)
+++ 
branches/dev-syncromind/activitycalendarfrontend/js/activitycalendarfrontend/activity_new.js
        2015-12-10 10:15:04 UTC (rev 14555)
@@ -1,434 +1,373 @@
-$(document).ready(function(){
-    var text = document.getElementById("displayText");
-    //ele.hide();
-    $("#toggleText").hide();
-    text.innerHTML = "Ikke i listen? Registrer nytt lokale";
+$(document).ready(function () {
+       var text = document.getElementById("displayText");
+       //ele.hide();
+       $("#toggleText").hide();
+       text.innerHTML = "Ikke i listen? Registrer nytt lokale";
 });
 
 function toggle() {
-    var ele = document.getElementById("toggleText");
-    var text = document.getElementById("displayText");
-    var arenahidden = document.getElementById("new_arena_hidden");
-    if(ele.style.display == "block") {
-        ele.style.display = "none";

@@ Diff output truncated at 153600 characters. @@



reply via email to

[Prev in Thread] Current Thread [Next in Thread]