fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [11817] bkbooking: stavanger upgrade portico framewor


From: Kjell Arne Espedal
Subject: [Fmsystem-commits] [11817] bkbooking: stavanger upgrade portico framework from trunk
Date: Fri, 14 Mar 2014 08:10:39 +0000

Revision: 11817
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11817
Author:   kjell
Date:     2014-03-14 08:10:39 +0000 (Fri, 14 Mar 2014)
Log Message:
-----------
bkbooking: stavanger upgrade portico framework from trunk

Modified Paths:
--------------
    branches/stavangerkommune/activitycalendarfrontend/inc/class.menu.inc.php
    
branches/stavangerkommune/activitycalendarfrontend/inc/class.uiactivity.inc.php
    branches/stavangerkommune/activitycalendarfrontend/index.php
    
branches/stavangerkommune/activitycalendarfrontend/setup/default_records.inc.php
    branches/stavangerkommune/activitycalendarfrontend/setup/phpgw_no.lang
    branches/stavangerkommune/activitycalendarfrontend/setup/setup.inc.php
    
branches/stavangerkommune/activitycalendarfrontend/setup/tables_current.inc.php
    
branches/stavangerkommune/activitycalendarfrontend/templates/base/activity.php
    
branches/stavangerkommune/activitycalendarfrontend/templates/base/activity_edit.php
    
branches/stavangerkommune/activitycalendarfrontend/templates/base/activity_edit_step_1.php
    
branches/stavangerkommune/activitycalendarfrontend/templates/base/activity_new.php
    
branches/stavangerkommune/activitycalendarfrontend/templates/base/activity_new_org.php
    
branches/stavangerkommune/activitycalendarfrontend/templates/base/activity_new_step_1.php
    
branches/stavangerkommune/activitycalendarfrontend/templates/base/organization_edit.php
    
branches/stavangerkommune/activitycalendarfrontend/templates/base/organization_reciept.php
    branches/stavangerkommune/calendar/inc/class.bocalendar.inc.php
    branches/stavangerkommune/header.inc.php.template

Modified: 
branches/stavangerkommune/activitycalendarfrontend/inc/class.menu.inc.php
===================================================================
--- branches/stavangerkommune/activitycalendarfrontend/inc/class.menu.inc.php   
2014-03-14 08:08:53 UTC (rev 11816)
+++ branches/stavangerkommune/activitycalendarfrontend/inc/class.menu.inc.php   
2014-03-14 08:10:39 UTC (rev 11817)
@@ -1,27 +1,27 @@
 <?php
-       class activitycalendarfrontend_menu
-       {
-               function get_menu()
-               {
-                       $incoming_app = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
-                       $GLOBALS['phpgw_info']['flags']['currentapp'] = 
'activitycalendarfrontend';
 
-                       $menus = array();
+class activitycalendarfrontend_menu {
 
-                       if ( $GLOBALS['phpgw']->acl->check('run', 
phpgwapi_acl::READ, 'admin')
-                       || $GLOBALS['phpgw']->acl->check('admin', 
phpgwapi_acl::ADD, 'activitycalendarfrontend'))
-                       {
-                               $menus['admin'] = array
+       function get_menu() {
+               $incoming_app = $GLOBALS['phpgw_info']['flags']['currentapp'];
+               $GLOBALS['phpgw_info']['flags']['currentapp'] = 
'activitycalendarfrontend';
+
+               $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
+                               'index' => array
                                        (
-                                               'text'  => 
lang('Configuration'),
-                                               'url'   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'admin.uiconfig.index', 'appname' => 'activitycalendarfrontend') )
-                                       ),
-                               );
-                       }
+                                       '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;
        }
+
+}

Modified: 
branches/stavangerkommune/activitycalendarfrontend/inc/class.uiactivity.inc.php
===================================================================
--- 
branches/stavangerkommune/activitycalendarfrontend/inc/class.uiactivity.inc.php 
    2014-03-14 08:08:53 UTC (rev 11816)
+++ 
branches/stavangerkommune/activitycalendarfrontend/inc/class.uiactivity.inc.php 
    2014-03-14 08:10:39 UTC (rev 11817)
@@ -1,335 +1,569 @@
 <?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');
-       
-       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
-       {
-               private $so_organization;
-               
-               public $public_functions = array
-               (
-                       'add'                   =>      true,
-                       'edit'                  =>      true,
-                       'view'                  =>      true,
-                       'index'                 =>      true,
-                       'get_organization_groups'       =>      true,
-                       'get_address_search'    => true,
+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/');
+
+class activitycalendarfrontend_uiactivity extends 
activitycalendar_uiactivities {
+
+       private $so_organization;
+       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
-               );
-               
-               public function __construct()
-               {
-                       parent::__construct();
-                       $this->so_organization = 
activitycalendar_soorganization::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;
-                       
-                       $ajaxUrl = $c->config_data['AJAXURL'];
+       );
 
-                       $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');
-                       
-                       if(isset($_POST['step_1'])) //activity shall be 
registred on a new organization
-                       {
-                               if($o_id_new == "new_org")
-                               {
-                                       //add new organization to internal 
activitycalendar organization register
-                               $org_info['name'] = phpgw::get_var('orgname');
-                               $org_info['orgnr'] = phpgw::get_var('orgno');
-                               $org_info['homepage'] = 
phpgw::get_var('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)
-                               {
-                                       //var_dump($p);
-                                       $persons[] = $p;
-                               }
-                               
-                               $message = lang('organization_saved_form');
-                               
-                               $this->render('activity_new.php', array
-                                       (
-                                               'activity'      => $activity,
-                                               'new_organization' => true,
-                                               'organization' => $organization,
-                                               'contact1' => $persons[0],
-                                               'arenas' => $arenas,
-                                               'buildings' => $buildings,
-                                               'categories' => $categories,
-                                               'targets' => $targets,
-                                               'districts' => $districts,
-                                               'offices' => $offices,
-                                               'editable' => true,
-                                               'message' => isset($message) ? 
$message : phpgw::get_var('message'),
-                                               'error' => isset($error) ? 
$error : phpgw::get_var('error'),
-                                               'ajaxURL' => $ajaxUrl
-                                       )
-                               );
+       public function __construct() {
+               parent::__construct();
+               $this->so_organization = 
activitycalendar_soorganization::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;
+
+               $ajaxUrl = $c->config_data['AJAXURL'];
+
+               $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');
+
+               if (isset($_POST['step_1'])) { //activity shall be registred on 
a new organization
+                       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 = "";
                                }
-                               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)
-                                       {
-                                               //var_dump($p);
-                                               $persons[] = $p;
-                                       }
-                                       
-                                       
-                                       $activity->set_organization_id($o_id);
-                                       
$activity->set_description($organization->get_description());
-                                       $activity->set_contact_persons($pers);
-                                       
-                                       $this->render('activity_new.php', array
+                               $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) {
+                                       //var_dump($p);
+                                       $persons[] = $p;
+                               }
+
+                               $message = lang('organization_saved_form');
+
+                               $this->render('activity_new.php', array
+                                       (
+                                               'activity' => $activity,
+                                               'new_organization' => true,
+                                               'organization' => $organization,
+                                               'contact1' => $persons[0],
+                                               'arenas' => $arenas,
+                                               'buildings' => $buildings,
+                                               'categories' => $categories,
+                                               'targets' => $targets,
+                                               'districts' => $districts,
+                                               'offices' => $offices,
+                                               'editable' => true,
+                                               'message' => isset($message) ? 
$message : phpgw::get_var('message'),
+                                               'error' => isset($error) ? 
$error : phpgw::get_var('error'),
+                                               'ajaxURL' => $ajaxUrl
+                                       )
+                               );
+                       } 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) {
+                                       //var_dump($p);
+                                       $persons[] = $p;
+                               }
+
+
+                               $activity->set_organization_id($o_id);
+                               
$activity->set_description($organization->get_description());
+                               $activity->set_contact_persons($pers);
+
+                               $this->render('activity_new.php', array
                                                (
-                                                       'activity'      => 
$activity,
-                                                       'new_organization' => 
false,
-                                                       'organization' => 
$organization,
-                                                       'contact1' => 
$persons[0],
-                                                       'arenas' => $arenas,
-                                                       'buildings' => 
$buildings,
-                                                       'categories' => 
$categories,
-                                                       'targets' => $targets,
-                                                       'districts' => 
$districts,
-                                                       'offices' => $offices,
-                                                       'editable' => true,
-                                                       'message' => 
isset($message) ? $message : phpgw::get_var('message'),
-                                                       'error' => 
isset($error) ? $error : phpgw::get_var('error'),
-                                                       'ajaxURL' => $ajaxUrl
-                                               )
-                                       );
+                                               'activity' => $activity,
+                                               'new_organization' => false,
+                                               'organization' => $organization,
+                                               'contact1' => $persons[0],
+                                               'arenas' => $arenas,
+                                               'buildings' => $buildings,
+                                               'categories' => $categories,
+                                               'targets' => $targets,
+                                               'districts' => $districts,
+                                               'offices' => $offices,
+                                               'editable' => true,
+                                               'message' => isset($message) ? 
$message : phpgw::get_var('message'),
+                                               'error' => isset($error) ? 
$error : phpgw::get_var('error'),
+                                               '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);
+
+                               //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;
                                }
-                   }
-                       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;
+                               $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);
+
+                               //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;
                                }
-                               
-                               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);
-                                       
-                                       $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);
+                               $organization = 
$this->so_organization->get_single($o_id);
+                               $new_group = true;
+                       }
+
+                       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->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);
                                }
-                               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);
-                                       
-                                       $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;
+                       } 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]);
                                }
-                               
-                               if(strlen($desc) > 254)
-                               {
-                                       $desc = substr($desc,0,254);
+                       }
+
+                       //... 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 ($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');
                                }
-                               
-                               $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);
-                       
-                                       // All is good, store arena
-                                       if ($this->so_arena->store($arena)) {
-                                               $arena_id = $arena->get_id();
-                                               $activity->set_arena($arena_id);
-                                       }
+                               //$org_info_edit_url = self::link('/index.php' 
,array('menuaction' => 
'activitycalendarfrontend.uiactivity.edit_organization_values'));
+
+                               $GLOBALS['phpgw_info']['flags']['noframework'] 
= true;
+
+                               $this->render('activity.php', array
+                                               (
+                                               'activity' => $activity,
+                                               'organization' => $organization,
+                                               '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');
                                }
-                               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]);
-                                   }
+                               if (!$district_ok) {
+                                       $error .= "<br/>" . 
lang('district_not_selected');
                                }
+                               return $this->render('activity_new.php', array
+                                                                               
(
+                                                                               
'activity' => $activity,
+                                                                               
'organizations' => $organizations,
+                                                                               
'organization' => $organization,
+                                                                               
'contact1' => $persons[0],
+                                                                               
'contact2' => $persons[1],
+                                                                               
'org_name' => $org_name,
+                                                                               
'new_org' => $new_org,
+                                                                               
'groups' => $groups,
+                                                                               
'arenas' => $arenas,
+                                                                               
'buildings' => $buildings,
+                                                                               
'categories' => $categories,
+                                                                               
'targets' => $targets,
+                                                                               
'districts' => $districts,
+                                                                               
'offices' => $offices,
+                                                                               
'editable' => true,
+                                                                               
'cancel_link' => $cancel_link,
+                                                                               
'message' => isset($message) ? $message : phpgw::get_var('message'),
+                                                                               
'error' => isset($error) ? $error : phpgw::get_var('error'),
+                                                                               
'ajaxURL' => $ajaxUrl
+                                                                               
                )
+                               );
+                       }
+               } else {
+                       return $this->render('activity_new_step_1.php', array
+                                                                       (
+                                                                       
'organizations' => $organizations,
+                                                                       
'ajaxURL' => $ajaxUrl
+                                                                               
        )
+                       );
+               }
+       }
 
-                               //... 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($activity->get_target() && 
$activity->get_target() != '')
-                               {
-                                       $target_ok = true;
+       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.');
+               }
+
+               $data = array
+                               (
+                               'activity' => $activity,
+                               'errorMsgs' => $errorMsgs,
+                               'infoMsgs' => $infoMsgs
+               );
+
+               $GLOBALS['phpgw_info']['flags']['noframework'] = true;
+               $this->render('activity.php', $data);
+               //self::render_template('activity_tmp', array('activity' => 
$activity, 'frontend'=>'true'));
+       }
+
+       function edit() {
+               $GLOBALS['phpgw']->js->validate_file('json', 'json', 
'phpgwapi');
+
+               $c = createobject('phpgwapi.config', 
'activitycalendarfrontend');
+               $c->read();
+               $config = $c->config_data;
+
+               $ajaxUrl = $c->config_data['AJAXURL'];
+
+               $id = intval(phpgw::get_var('id', 'GET'));
+
+               $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());
+
+
+                       //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 $this->render('activity_edit_step_1.php', 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'));
+                               return 
$this->render('activity_edit_step_1.php', array
+                                                                               
(
+                                                                               
'activities' => $activities,
+                                                                               
'organizations' => $organizations,
+                                                                               
'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));
+                               return 
$this->render('activity_edit_step_1.php', array
+                                                                               
(
+                                                                               
'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));
+                                       return 
$this->render('activity_edit_step_1.php', array
+                                                                               
        (
+                                                                               
        'activities' => $activities,
+                                                                               
        'ajaxURL' => $ajaxUrl
+                                                                               
                        )
+                                       );
                                }
-                               if($activity->get_district() && 
$activity->get_district() != '')
-                               {
-                                       $district_ok = true;
+
+                               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));
+                                       return 
$this->render('activity_edit_step_1.php', array
+                                                                               
        (
+                                                                               
        'activities' => $activities,
+                                                                               
        'ajaxURL' => $ajaxUrl
+                                                                               
                        )
+                                       );
                                }
-                               
-                               if($target_ok && $district_ok)
-                               {
-                                       
if($this->so_activity->store($activity)) // ... and then try to store the object
-                                       {
-                                               $message = 
lang('messages_saved_form'); 
+
+                               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;
                                        }
-                                       else
-                                       {
-                                               $error = 
lang('messages_form_error');
+                                       $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;
                                        }
-                                       //$org_info_edit_url = 
self::link('/index.php' ,array('menuaction' => 
'activitycalendarfrontend.uiactivity.edit_organization_values'));
+                                       $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);
+                               }
+                               $organization = 
$this->so_organization->get_single($activity->get_organization_id());
 
-                                       
$GLOBALS['phpgw_info']['flags']['noframework'] = true;
+                               $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);
 
-                                       $this->render('activity.php', array
-                                                               (
-                                                                       
'activity'      => $activity,
+                                               $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();
+
+
+                                               $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;
+                                               }
+
+                                               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');
+                                                       }
+
+                                                       
$GLOBALS['phpgw_info']['flags']['noframework'] = true;
+
+                                                       
$this->render('activity.php', array
+                                                                       (
+                                                                       
'activity' => $activity,
                                                                        
'organization' => $organization,
                                                                        'group' 
=> $group,
-                                                                       
'contact1' => $persons[0],
+                                                                       
'contact1' => $persons_array_tmp[0],
                                                                        
'arenas' => $arenas,
                                                                        
'buildings' => $buildings,
                                                                        
'categories' => $categories,
@@ -339,29 +573,46 @@
                                                                        
'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');
+                                                                               
        )
+                                                       );
+                                               } else {
+                                                       if (!$target_ok) {
+                                                               $error .= 
"<br/>" . lang('target_not_selected');
+                                                       }
+                                                       if (!$district_ok) {
+                                                               $error .= 
"<br/>" . lang('district_not_selected');
+                                                       }
+                                                       return 
$this->render('activity_edit.php', array
+                                                                               
                        (
+                                                                               
                        'activity' => $activity,
+                                                                               
                        'organization' => $organization,
+                                                                               
                        'contact1' => $persons_array[0],
+                                                                               
                        'org_name' => $org_name,
+                                                                               
                        'group' => $group,
+                                                                               
                        'arenas' => $arenas,
+                                                                               
                        'buildings' => $buildings,
+                                                                               
                        'categories' => $categories,
+                                                                               
                        'targets' => $targets,
+                                                                               
                        'districts' => $districts,
+                                                                               
                        'offices' => $offices,
+                                                                               
                        'editable' => true,
+                                                                               
                        'cancel_link' => $cancel_link,
+                                                                               
                        'message' => isset($message) ? $message : 
phpgw::get_var('message'),
+                                                                               
                        'error' => isset($error) ? $error : 
phpgw::get_var('error'),
+                                                                               
                        'ajaxURL' => $ajaxUrl
+                                                                               
                                        )
+                                                       );
+                                               }
                                        }
-                                       if(!$district_ok)
-                                       {
-                                               $error .= "<br/>" . 
lang('district_not_selected');
-                                       }
-                                       return 
$this->render('activity_new.php', array
-                                               (
-                                                       'activity'      => 
$activity,
-                                                       'organizations' => 
$organizations,
+                               } else if (isset($_POST['change_request'])) {
+                                       
$GLOBALS['phpgw_info']['flags']['noframework'] = true;
+
+                                       $this->render('activity_edit.php', array
+                                                       (
+                                                       'activity' => $activity,
                                                        'organization' => 
$organization,
-                                                       'contact1' => 
$persons[0],
-                                                       'contact2' => 
$persons[1],
-                                                       'org_name' => $org_name,
-                                                       'new_org' => $new_org,
-                                                       'groups' => $groups,
+                                                       'group' => $group,
+                                                       'contact1' => 
$persons_array[0],
                                                        'arenas' => $arenas,
                                                        'buildings' => 
$buildings,
                                                        'categories' => 
$categories,
@@ -369,590 +620,256 @@
                                                        'districts' => 
$districts,
                                                        'offices' => $offices,
                                                        'editable' => true,
-                                                       'cancel_link' => 
$cancel_link,
                                                        'message' => 
isset($message) ? $message : phpgw::get_var('message'),
                                                        'error' => 
isset($error) ? $error : phpgw::get_var('error'),
                                                        'ajaxURL' => $ajaxUrl
-                                               )       
+                                                                       )
                                        );
-                               }
-                       }
-                       else
-                       {
-                               return $this->render('activity_new_step_1.php', 
array
-                                               (
-                                                       'organizations' => 
$organizations,
+                               } 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;
+
+                                               $this->render('activity.php', 
array
+                                                               (
+                                                               'activity' => 
$activity,
+                                                               'organization' 
=> $organization,
+                                                               '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'),
+                                                               'ajaxURL' => 
$ajaxUrl
+                                                                               
)
+                                               );
+                                       }
+                               } else {
+                                       
$GLOBALS['phpgw_info']['flags']['noframework'] = true;
+
+                                       $this->render('activity.php', array
+                                                       (
+                                                       'activity' => $activity,
+                                                       'organization' => 
$organization,
+                                                       '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'),
                                                        'ajaxURL' => $ajaxUrl
-                                               )       
+                                                                       )
                                        );
+                               }
                        }
                }
-               
-               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.');
-                       }
-       
-                       $data = array
-                       (
-                               'activity' => $activity,
-                               'errorMsgs' => $errorMsgs,
-                               'infoMsgs' => $infoMsgs
-                       );
-                       
-                       $GLOBALS['phpgw_info']['flags']['noframework'] = true;
-                       $this->render('activity.php', $data);
-                       //self::render_template('activity_tmp', 
array('activity' => $activity, 'frontend'=>'true'));
-               }
+       }
 
-               function edit()
-               {
-                       $GLOBALS['phpgw']->js->validate_file( 'json', 'json', 
'phpgwapi' );
+       function index() {
+               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'activitycalendarfrontend.uiactivity.add'));
+       }
 
-                       $c = 
createobject('phpgwapi.config','activitycalendarfrontend');
-                       $c->read();
-                       $config = $c->config_data;
-                       
-                       $ajaxUrl = $c->config_data['AJAXURL'];
-                       
-                       $id = intval(phpgw::get_var('id', 'GET'));
+       function get_organization_groups() {
+               $GLOBALS['phpgw_info']['flags']['noheader'] = true;
+               $GLOBALS['phpgw_info']['flags']['nofooter'] = true;
+               $GLOBALS['phpgw_info']['flags']['xslt_app'] = false;
 
-                       $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());
-                               
-                               
-                               //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 
$this->render('activity_edit_step_1.php', 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'));
-                                       return 
$this->render('activity_edit_step_1.php', array
-                                               (
-                                                       'activities' => 
$activities,
-                                                       'organizations' => 
$organizations,
-                                                       '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));
-                                       return 
$this->render('activity_edit_step_1.php', array
-                                               (
-                                                       '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));
-                                               return 
$this->render('activity_edit_step_1.php', array
-                                                       (
-                                                               'activities' => 
$activities,
-                                                               'ajaxURL' => 
$ajaxUrl
-                                                       )       
-                                               );
-                                       }
-                                       
-                                       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));
-                                               return 
$this->render('activity_edit_step_1.php', 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;
+               $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";
                                                }
-                                               $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);
-                                       }
-                                       $organization = 
$this->so_organization->get_single($activity->get_organization_id());
-                                       
-                                        $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);
+                                       $group_html[] = "<option value='" . 
$group->get_id() . "'" . $selected_group . ">" . $group->get_name() . 
"</option>";
+                               }
+                       }
+                       $html = implode(' ', $group_html);
+                       $returnHTML = $returnHTML . ' ' . $html;
+               }
 
-                                                    $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();
 
+               return $returnHTML;
+               //return "<option>Ingen gruppe valgt</option>";
+       }
 
-                                                    $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;
-                                                    }
+       /**
+        * 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);
+       }
 
-                                                    if($target_ok && 
$district_ok)
-                                                    {
+       function edit_organization_values() {
+               $org_id = phpgw::get_var('organization_id');
+               if (isset($org_id)) {
+                       if (isset($_POST['save_org'])) { //save updated 
organization info
+                               $organization = 
$this->so_organization->get_single($org_id);
 
-                                                            
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');
-                                                            }
+                               $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);
 
-                                                            
$GLOBALS['phpgw_info']['flags']['noframework'] = true;
+                               //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);
 
-                                                            
$this->render('activity.php', array
-                                                                               
     (
-                                                                               
             'activity'         => $activity,
-                                                                               
             'organization' => $organization,
-                                                                               
             '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'),
-                                                                               
             'ajaxURL' => $ajaxUrl
-                                                                               
     )
-                                                            );
-                                                    }
-                                                    else
-                                                    {
-                                                            if(!$target_ok)
-                                                            {
-                                                                    $error .= 
"<br/>" . lang('target_not_selected');
-                                                            }
-                                                            if(!$district_ok)
-                                                            {
-                                                                    $error .= 
"<br/>" . lang('district_not_selected');
-                                                            }
-                                                            return 
$this->render('activity_edit.php', array
-                                                                    (
-                                                                            
'activity'         => $activity,
-                                                                            
'organization' => $organization,
-                                                                        
'contact1' => $persons_array[0],
-                                                                            
'org_name' => $org_name,
-                                                                            
'group' => $group,
-                                                                            
'arenas' => $arenas,
-                                                                            
'buildings' => $buildings,
-                                                                            
'categories' => $categories,
-                                                                            
'targets' => $targets,
-                                                                            
'districts' => $districts,
-                                                                            
'offices' => $offices,
-                                                                            
'editable' => true,
-                                                                            
'cancel_link' => $cancel_link,
-                                                                            
'message' => isset($message) ? $message : phpgw::get_var('message'),
-                                                                            
'error' => isset($error) ? $error : phpgw::get_var('error'),
-                                                                            
'ajaxURL' => $ajaxUrl
-                                                                    )  
-                                                            );
-                                                    }
-                                            }
-                                    }
-                                    else if(isset($_POST['change_request']))
-                                    {
-                                        
$GLOBALS['phpgw_info']['flags']['noframework'] = true;
+                               $message = lang('change_request_ok', 
$org_info['name']);
 
-                                        $this->render('activity_edit.php', 
array
-                                                                (
-                                                                        
'activity'     => $activity,
-                                                                        
'organization' => $organization,
-                                                                        
'group' => $group,
-                                                                        
'contact1' => $persons_array[0],
-                                                                        
'arenas' => $arenas,
-                                                                        
'buildings' => $buildings,
-                                                                        
'categories' => $categories,
-                                                                        
'targets' => $targets,
-                                                                        
'districts' => $districts,
-                                                                        
'offices' => $offices,
-                                                                        
'editable' => true,
-                                                                        
'message' => isset($message) ? $message : phpgw::get_var('message'),
-                                                                        
'error' => isset($error) ? $error : phpgw::get_var('error'),
-                                                                        
'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);
+                               $this->render('organization_reciept.php', array
+                                               (
+                                               'message' => isset($message) ? 
$message : phpgw::get_var('message'),
+                                               'error' => isset($error) ? 
$error : phpgw::get_var('error')
+                                                               )
+                               );
+                       } else {
+                               $c = createobject('phpgwapi.config', 
'activitycalendarfrontend');
+                               $c->read();
+                               $config = $c->config_data;
 
-                                            
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;
-                       
-                                            $this->render('activity.php', array
-                                                                        (
-                                                                            
'activity'         => $activity,
-                                                                            
'organization' => $organization,
-                                                                            
'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'),
-                                                                            
'ajaxURL' => $ajaxUrl
-                                                                        )
-                                            );
-                                        }
-                                    }
-                                    else
-                                    {
-                                        
$GLOBALS['phpgw_info']['flags']['noframework'] = true;
-
-                                        $this->render('activity.php', array
-                                                                (
-                                                                        
'activity'     => $activity,
-                                                                        
'organization' => $organization,
-                                                                        
'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'),
-                                                                        
'ajaxURL' => $ajaxUrl
-                                                                )
-                                        );
-                                    }
+                               $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;
                                }
-                       }
-               }
-               
-               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;
-                       
-                       $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>";
-                                       }
-                               }
-                           $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);
-               }
-               
-               function edit_organization_values()
-               {
-                       $org_id = phpgw::get_var('organization_id');
-                       if(isset($org_id))
-                       {
-                               if(isset($_POST['save_org'])) //save updated 
organization info
-                               {
-                                       $organization = 
$this->so_organization->get_single($org_id);
-                                       
-                                       $org_info['name'] = 
phpgw::get_var('orgname');
-                                       $org_info['orgnr'] = 
phpgw::get_var('orgno');
-                                       $org_info['homepage'] = 
phpgw::get_var('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'] = "change";
-                                       $org_info['original_org_id'] = $org_id;
-                                       $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);
-                                       
-                                       $message = lang('change_request_ok', 
$org_info['name']);
-                                       
-                                       
$this->render('organization_reciept.php', array
+
+                               $this->render('organization_edit.php', array
                                                (
-                                                       'message' => 
isset($message) ? $message : phpgw::get_var('message'),
-                                                       'error' => 
isset($error) ? $error : phpgw::get_var('error')
-                                               )
-                                       );
-                                        
-                               }
-                               else
-                               {
-                                       $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;
-                                       }
-                                       
-                                       $this->render('organization_edit.php', 
array
-                                               (
-                                                       'organization' => 
$organization,
-                                                       'contact1' => 
$persons[0],
-                                                       'editable' => true,
-                                                       'message' => 
isset($message) ? $message : phpgw::get_var('message'),
-                                                       'error' => 
isset($error) ? $error : phpgw::get_var('error')
-                                               )
-                                       );
-                               }
+                                               'organization' => $organization,
+                                               'contact1' => $persons[0],
+                                               'editable' => true,
+                                               'message' => isset($message) ? 
$message : phpgw::get_var('message'),
+                                               'error' => isset($error) ? 
$error : phpgw::get_var('error'),
+                                               '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);
-                                       
-                                       $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);
-                                       
-                                       $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']);
-                                       
-                                       $this->render('group_reciept.php', array
+       }
+
+       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);
+
+                               //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);
+
+                               $message = lang('change_request_ok', 
$group_info['name']);
+
+                               $this->render('group_reciept.php', array
                                                (
-                                                       'message' => 
isset($message) ? $message : phpgw::get_var('message'),
-                                                       'error' => 
isset($error) ? $error : phpgw::get_var('error')
-                                               )
-                                       );
-                                        
+                                               '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;
                                }
-                               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;
-                       
-                       $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>";
-                                       }
+       }
+
+       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>";
                                }
-                           $html = implode(' ' , $activity_html);
-                           $returnHTML = $returnHTML . ' ' . $html;
                        }
-                       
-                       
-                       return $returnHTML;
+                       $html = implode(' ', $activity_html);
+                       $returnHTML = $returnHTML . ' ' . $html;
                }
+
+
+               return $returnHTML;
        }
+
+}

Modified: branches/stavangerkommune/activitycalendarfrontend/index.php
===================================================================
--- branches/stavangerkommune/activitycalendarfrontend/index.php        
2014-03-14 08:08:53 UTC (rev 11816)
+++ branches/stavangerkommune/activitycalendarfrontend/index.php        
2014-03-14 08:10:39 UTC (rev 11817)
@@ -1,242 +1,171 @@
 <?php
-    $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');
 
-       // Make sure we're always logged in
-       if (!phpgw::get_var(session_name()) || 
!$GLOBALS['phpgw']->session->verify())
-       {
-               
-               $c = createobject('phpgwapi.config','activitycalendarfrontend');
-               $c->read();
-               $config = $c->config_data;
+$GLOBALS['phpgw_info']['flags'] = array(
+    'noheader' => true,
+    'nonavbar' => true,
+    'currentapp' => 'login'
+);
 
-               $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
+$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()) {
+
+  $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 = "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
+//  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();
-               }
-       }
-       
-       //$GLOBALS['phpgw_info']['flags']['noframework'] = true;
-       
-/*
-       
-       if (isset($_GET['menuaction']))
-       {
-               //list($app,$class,$method) = explode('.',$_GET['menuaction']);
-               $GLOBALS['phpgw']->redirect_link('/index.php',$_GET);
-       }
-       else
-       {
-               
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction' => 
'activitycalendarfrontend.uiactivity.index'));
-               //$app = 'activitycalendarfrontend';
-               //$class = 'uiactivity';
-               //$method = 'index';
-       }*/
-       /*
-               $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();
-               }
-       }*/
-    
-
-//    include_once('../header.inc.php');
-
-       
+$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/stavangerkommune/activitycalendarfrontend/setup/default_records.inc.php
===================================================================
--- 
branches/stavangerkommune/activitycalendarfrontend/setup/default_records.inc.php
    2014-03-14 08:08:53 UTC (rev 11816)
+++ 
branches/stavangerkommune/activitycalendarfrontend/setup/default_records.inc.php
    2014-03-14 08:10:39 UTC (rev 11817)
@@ -1,32 +1,13 @@
 <?php
 
 // Default user
-$GLOBALS['phpgw']->accounts    = createObject('phpgwapi.accounts');
-$GLOBALS['phpgw']->acl         = CreateObject('phpgwapi.acl');
+$GLOBALS['phpgw']->accounts = createObject('phpgwapi.accounts');
+$GLOBALS['phpgw']->acl = CreateObject('phpgwapi.acl');
 
 $modules = array
-(
-       'activitycalendarfrontend',
+    (
+    'activitycalendarfrontend',
 //     'preferences'
 );
 
-$aclobj =& $GLOBALS['phpgw']->acl;
-/*
-if (!$GLOBALS['phpgw']->accounts->exists('bookingguest') ) // no guest account 
already exists
-{
-       $GLOBALS['phpgw_info']['server']['password_level'] = '8CHAR';
-       $account                        = new phpgwapi_user();
-       $account->lid           = 'bookingguest';
-       $account->firstname     = 'booking';
-       $account->lastname      = 'Guest';
-       $account->passwd        = 'bkbooking';
-       $account->enabled       = true;
-       $account->expires       = -1;
-       $bookingguest           = $GLOBALS['phpgw']->accounts->create($account, 
array(), array(), $modules);
-
-       $preferences    = createObject('phpgwapi.preferences');
-       $preferences->set_account_id($bookingguest);
-       $preferences->add('bookingfrontend','template_set','bkbooking');
-       $preferences->save_repository(true,$GLOBALS['type']);
-}
-*/
\ No newline at end of file
+$aclobj = & $GLOBALS['phpgw']->acl;
\ No newline at end of file

Modified: branches/stavangerkommune/activitycalendarfrontend/setup/phpgw_no.lang
===================================================================
--- branches/stavangerkommune/activitycalendarfrontend/setup/phpgw_no.lang      
2014-03-14 08:08:53 UTC (rev 11816)
+++ branches/stavangerkommune/activitycalendarfrontend/setup/phpgw_no.lang      
2014-03-14 08:10:39 UTC (rev 11817)
@@ -2,7 +2,7 @@
 Activitycalendarfrontend       common  no      Aktivitetsoversikt Frontend
 office activitycalendarfrontend        no      Hovedansvarlig kulturkontor
 arena  activitycalendarfrontend        no      Lokale
-description    activitycalendarfrontend        no      Beskrivelse
+description    activitycalendarfrontend        no      Beskrivelse (max 255 
tegn)
 date_start     activitycalendarfrontend        no      Startdato
 date_end       activitycalendarfrontend        no      Sluttdato
 special_adaptation     activitycalendarfrontend        no      Ja, aktiviteten 
er spesielt tilpasset for utviklingshemmede
@@ -95,8 +95,8 @@
 edit_organization      activitycalendarfrontend        no      Rediger 
organisasjonsinformasjon
 address        activitycalendarfrontend        no      Adresse
 activity_edit_helptext_step1   activitycalendarfrontend        no      Skal du 
endre opplysninger knyttet til en aktivitet må du være registrert som 
kontaktperson for aktiviteten.<br/>Du velger først organisasjon og deretter 
aktivitet i bildet under, og får en e-post i retur med en lenke til 
endringsskjema.
-mail_body_update_frontend      activitycalendarfrontend        no      Dette 
er en melding fra Bergen kommune/AktivBy.<br/><br/>I aktivitetsoversikten som 
ligger i kommuneportalen på internett, står du registrert som kontaktperson for 
%1.<br/>Det har kommet inn et endringsønske på denne aktiviteten. Bruk lenken 
under for å endre opplysningene om aktiviteten.<br/>%2<br/><br/><br/> Mvh %3 
kulturkontor
-mail_body_update       activitycalendarfrontend        no      Dette er en 
melding fra Bergen kommune/AktivBy.<br/><br/>I aktivitetsoversikten som ligger 
i kommuneportalen på internett, står du registrert som kontaktperson for 
%1.<br/>Det har kommet inn et endringsønske på denne aktiviteten. Bruk lenken 
under for å endre opplysningene om aktiviteten.<br/>%2<br/><br/><br/> Mvh %3 
kulturkontor
+mail_body_update_frontend      activitycalendarfrontend        no      Dette 
er en melding fra Bergen kommune/AktivBy.<br/><br/>I aktivitetsoversikten som 
ligger i kommuneportalen på internett, står du registrert som kontaktperson for 
%1.<br/>Det har kommet inn et endringsønske på denne aktiviteten. Bruk lenken 
under for å endre opplysningene om aktiviteten.<br/>%2<br/><br/>%3<br><br/> Mvh 
%4 kulturkontor
+mail_body_update       activitycalendarfrontend        no      Dette er en 
melding fra Bergen kommune/AktivBy.<br/><br/>I aktivitetsoversikten som ligger 
i kommuneportalen på internett, står du registrert som kontaktperson for 
%1.<br/>Det har kommet inn et endringsønske på denne aktiviteten. Bruk lenken 
under for å endre opplysningene om aktiviteten.<br/>%2<br/><br/>%3<br/><br/> 
Mvh %4 kulturkontor
 mail_subject_update    activitycalendarfrontend        no      Melding fra 
AktivBy - Aktivitetsoversikt
 save_organization_next activitycalendarfrontend        no      Lagre 
organisasjon og gå videre til Ny aktivitet
 new_organization       activitycalendarfrontend        no      Ny organisasjon
@@ -109,9 +109,30 @@
 new_activity_helptext  activitycalendarfrontend        no      Hvem arrangerer 
aktiviteten?
 responsible    activitycalendarfrontend        no      Arrangør
 choose_org     activitycalendarfrontend        no      Velg organisasjon
-activity_title activitycalendarfrontend        no      Navn på aktiviteten
+activity_title activitycalendarfrontend        no      Navn på aktiviteten 
(max 255 tegn)
 location       activitycalendarfrontend        no      Lokale
 contact_person activitycalendarfrontend        no      Kontaktperson for 
aktiviteten
 activity_ok_message    activitycalendarfrontend        no      Aktiviteten er 
lagret uten endringer
 activity_ok    activitycalendarfrontend        no      Opplysningene er 
korrekte
-change_activity        activitycalendarfrontend        no      Endre 
opplysningene
\ No newline at end of file
+change_activity        activitycalendarfrontend        no      Endre 
opplysningene
+help_choose_activity_org       activitycalendarfrontend        no      I 
aktivitetsoversikten må en aktivitet alltid tilhøre en organisasjon.\\n\\n 
Dersom en organisasjonen er oppført med andre aktiviteter fra før, skal du 
velge denne i stedet for å registrere ny. Du kan søke deg frem til din 
organisasjon ved å skrive i feltet.\\n\\nDersom organisasjon ikke er registrert 
tidligere velger du «Registrer ny organisasjon».\\n\\nDersom det ikke er et 
skarpt skille mellom organisasjon og aktivitet, skal du likevel velge 
organisasjon/registrere ny organisasjon. Det gjør ingen ting om enkelte 
opplysninger, som f.eks. kontaktinformasjon, skrives inn to ganger.
+help_organization_name activitycalendarfrontend        no      I 
aktivitetsoversikten må en aktivitet alltid tilhøre en organisasjon. 
\\n\\nDersom det ikke er et skarpt skille mellom organisasjon og aktivitet, 
skal du likevel skrive inn navn i feltet for organisasjonsnavn. Det gjør ingen 
ting om navnet på organisasjonen er det samme som navnet på aktiviteten.
+help_new_activity_org  activitycalendarfrontend        no      I 
aktivitetsoversikten må en aktivitet alltid tilhøre en organisasjon. 
\\n\\nDersom det ikke er et skarpt skille mellom organisasjon og aktivitet, 
skal du likevel skrive inn navn i feltet for organisasjonsnavn. Det gjør ingen 
ting om navnet på organisasjonen er det samme som navnet på aktiviteten.
+help_streetaddress     activitycalendarfrontend        no      For å unngå 
feil innskriving av gateadresse, er feltet for «Gateadresse» koplet mot 
kommunens gateregister med oversikt over alle gatenavn i Bergen. Begynn å fylle 
ut feltet og velg rett gatenavn som løsningen foreslår.
+help_homepage  activitycalendarfrontend        no      Dersom 
organisasjonen/aktiviteten har egen internettside, så kan du skrive den inn her.
+help_contact_person    activitycalendarfrontend        no      Skriv inn navn, 
telefonnummer og e-postadresse til kontaktperson for 
organisasjonen.\\n\\nDersom organisasjon og aktivitet har samme kontaktperson, 
skal du likevel skrive inn kontaktopplysninger. Det gjør ingen ting om disse 
opplysningene senere også skrives inn på aktiviteten.\\n\\nI 
aktivitetsoversikten på kommunens internettsider, er det opplysningene skrevet 
inn på kontaktperson for aktiviteten som vil vises, ikke kontaktperson for 
organisasjonen.
+help_new_activity_title        activitycalendarfrontend        no      Skriv 
inn navnet på aktiviteten. (max 255 tegn)
+help_new_activity_description  activitycalendarfrontend        no      Gi en 
KORT beskrivelse av hva aktiviteten går ut på. Skriv helst kun én setning, 
maksimalt to. (max 255 tegn)
+help_new_activity_category     activitycalendarfrontend        no      Velg 
den kategorien som passer best for din aktivitet.
+help_new_activity_target       activitycalendarfrontend        no      Velg en 
eller flere målgrupper.
+help_new_activity_spec_adapt   activitycalendarfrontend        no      Hak av 
dersom aktiviteten passer for utviklingshemmede.
+help_new_activity_location     activitycalendarfrontend        no      Du må 
spesifisere hvor aktiviteten foregår.\\n\\nListen er sortert i «Kommunale bygg» 
og «Eksterne bygg», dvs. bygg som brukere av løsningen har registrert 
tidligere. \\n\\nVelg «Registrer nytt lokale» dersom du ikke finner det i 
listen.
+help_new_arena activitycalendarfrontend        no      Her skriver du inn 
lokalets navn, gateadresse, husnummer, postnummer og poststed.
+help_new_arena_name    activitycalendarfrontend        no      Skriv inn 
lokalets navn.\\n\\nLokalets navn vil vises i aktivitetsoversikten på kommunens 
nettsider. Det er derfor viktig at du velger et navn som gir mening for 
publikum, f.eks. «Grendahuset på Nymark». 
+help_new_arena_address activitycalendarfrontend        no      For å unngå 
feil innskriving av gateadresse, er feltet for «Gateadresse» koplet mot 
kommunens gateregister med oversikt over alle gatenavn i Bergen. Begynn å fylle 
ut feltet og velg rett gatenavn som løsningen foreslår.
+help_new_activity_district     activitycalendarfrontend        no      Velg 
bydelen hvor aktiviteten foregår.
+help_new_activity_time activitycalendarfrontend        no      Skriv inn dag 
og klokkeslett når aktiviteten foregår, f.eks. slik «Mandag kl. 20 – 21» eller 
slik «Hver andre tirsdag kl. 19 – 21».
+help_new_activity_contact_person       activitycalendarfrontend        no      
Skriv inn navn, telefonnummer og e-postadresse til kontaktperson for 
aktiviteten.
+help_new_activity_office       activitycalendarfrontend        no      Det 
kommunale kulturkontoret mottar registreringen. Velg kulturkontoret i den 
bydelen hvor aktiviteten foregår.
+help_edit_activity_location    activitycalendarfrontend        no      Du må 
spesifisere hvor aktiviteten foregår.\\n\\nListen er sortert i «Kommunale bygg» 
og «Eksterne bygg», dvs. bygg som brukere av løsningen har registrert tidligere.
+help_edit_activity_org activitycalendarfrontend        no      Her kan du 
endre opplysninger som tidligere er registrert for din organisasjon.
\ No newline at end of file

Modified: branches/stavangerkommune/activitycalendarfrontend/setup/setup.inc.php
===================================================================
--- branches/stavangerkommune/activitycalendarfrontend/setup/setup.inc.php      
2014-03-14 08:08:53 UTC (rev 11816)
+++ branches/stavangerkommune/activitycalendarfrontend/setup/setup.inc.php      
2014-03-14 08:10:39 UTC (rev 11817)
@@ -1,43 +1,43 @@
 <?php
-       $setup_info['activitycalendarfrontend']['name'] = 
'activitycalendarfrontend';
-       $setup_info['activitycalendarfrontend']['version'] = '0.1';
-       $setup_info['activitycalendarfrontend']['app_order'] = 61;
-       $setup_info['activitycalendarfrontend']['enable'] = 1;
-       $setup_info['activitycalendarfrontend']['app_group']    = 'office';
 
-       $setup_info['activitycalendarfrontend']['description'] = 'Bergen 
kommune activitycalendarfrontend';
+$setup_info['activitycalendarfrontend']['name'] = 'activitycalendarfrontend';
+$setup_info['activitycalendarfrontend']['version'] = '0.1';
+$setup_info['activitycalendarfrontend']['app_order'] = 61;
+$setup_info['activitycalendarfrontend']['enable'] = 1;
+$setup_info['activitycalendarfrontend']['app_group'] = 'office';
 
-       $setup_info['activitycalendarfrontend']['author'][] = array
-       (
-               'name'  => 'Bouvet ASA',
-               'email' => 'address@hidden'
-       );
+$setup_info['activitycalendarfrontend']['description'] = 'Bergen kommune 
activitycalendarfrontend';
 
-       /* Dependencies for this app to work */
-       $setup_info['activitycalendarfrontend']['depends'][] = array(
-               'appname' => 'phpgwapi',
-               'versions' => Array('0.9.17', '0.9.18')
-       );
+$setup_info['activitycalendarfrontend']['author'][] = array
+    (
+    'name' => 'Bouvet ASA',
+    'email' => 'address@hidden'
+);
 
-       $setup_info['activitycalendarfrontend']['depends'][] = array(
-               'appname' => 'booking',
-               'versions' => Array('0.2.00', 
'0.2.01','0.2.02','0.2.03','0.2.04','0.2.05','0.2.06','0.2.07','0.2.08','0.2.09')
-       );
+/* Dependencies for this app to work */
+$setup_info['activitycalendarfrontend']['depends'][] = array(
+    'appname' => 'phpgwapi',
+    'versions' => Array('0.9.17', '0.9.18')
+);
 
-       $setup_info['activitycalendarfrontend']['depends'][] = array(
-               'appname' => 'property',
-               'versions' => Array('0.9.17')
-       );
-       
-       $setup_info['activitycalendarfrontend']['depends'][] = array(
-               'appname' => 'activitycalendar',
-               'versions' => 
Array('0.1.3','0.1.4','0.1.5','0.1.6','0.1.7','0.1.8','0.1.9','0.1.10','0.1.11')
-       );
+$setup_info['activitycalendarfrontend']['depends'][] = array(
+    'appname' => 'booking',
+    'versions' => Array('0.2.00', '0.2.01', '0.2.02', '0.2.03', '0.2.04', 
'0.2.05', '0.2.06', '0.2.07', '0.2.08', '0.2.09', '0.2.10', '0.2.11','0.2.12')
+);
 
-       /* The hooks this app includes, needed for hooks registration */
-       $setup_info['activitycalendarfrontend']['hooks'] = array
-       (
-               'menu'  => 'activitycalendarfrontend.menu.get_menu',
-               'config'
-       );
-?>
+$setup_info['activitycalendarfrontend']['depends'][] = array(
+    'appname' => 'property',
+    'versions' => Array('0.9.17')
+);
+
+$setup_info['activitycalendarfrontend']['depends'][] = array(
+    'appname' => 'activitycalendar',
+    'versions' => Array('0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.1.7', '0.1.8', 
'0.1.9', '0.1.10', '0.1.11')
+);
+
+/* The hooks this app includes, needed for hooks registration */
+$setup_info['activitycalendarfrontend']['hooks'] = array
+    (
+    'menu' => 'activitycalendarfrontend.menu.get_menu',
+    'config'
+);

Modified: 
branches/stavangerkommune/activitycalendarfrontend/setup/tables_current.inc.php
===================================================================
--- 
branches/stavangerkommune/activitycalendarfrontend/setup/tables_current.inc.php 
    2014-03-14 08:08:53 UTC (rev 11816)
+++ 
branches/stavangerkommune/activitycalendarfrontend/setup/tables_current.inc.php 
    2014-03-14 08:10:39 UTC (rev 11817)
@@ -1,3 +1,4 @@
 <?php
-       $phpgw_baseline = array();
+
+$phpgw_baseline = array();
 ?>
\ No newline at end of file

Modified: 
branches/stavangerkommune/activitycalendarfrontend/templates/base/activity.php
===================================================================
--- 
branches/stavangerkommune/activitycalendarfrontend/templates/base/activity.php  
    2014-03-14 08:08:53 UTC (rev 11816)
+++ 
branches/stavangerkommune/activitycalendarfrontend/templates/base/activity.php  
    2014-03-14 08:10:39 UTC (rev 11817)
@@ -1,42 +1,47 @@
 <?php
-       //include common logic for all templates
+//include common logic for all templates
 //     include("common.php");
        $act_so = activitycalendar_soactivity::get_instance();
        $contpers_so = activitycalendar_socontactperson::get_instance();
 ?>
 <div class="yui-content">
        <div id="details">
-       <?php if($message){?>
-       <div class="success">
-               <?php echo $message;?>
-       </div>
-       <?php }else if($error){?>
-       <div class="error">
-               <?php echo $error;?>
-       </div>
-       <?php }?>
+               <?php if ($message) { ?>
+                       <div class="success">
+                               <?php echo $message; ?>
+                       </div>
+               <?php } else if ($error) { ?>
+                       <div class="error">
+                               <?php echo $error; ?>
+                       </div>
+               <?php } ?>
        </div>
        <DIV class="pageTop">
                <h1><?php echo lang('activity') ?></h1>
        </DIV>
        <form action="#" method="post">
-               <input type="hidden" name="id" value="<?php 
if($activity->get_id()){ echo $activity->get_id(); } else { echo '0'; }  ?>"/>
+               <input type="hidden" name="id" value="<?php
+               if ($activity->get_id()) {
+                       echo $activity->get_id();
+               } else {
+                       echo '0';
+               }
+               ?>"/>
                <dl class="proplist-col">
-                    <div class="form-buttons">
-                        <?php
-                            if ($change_request) {?>
-                                <input type="submit" name="activity_ok" 
value="<?php echo lang('activity_ok')?>" />
-                                <input type="submit" name="change_request" 
value="<?php echo lang('change_activity')?>" />
-                        <?php }
-                        ?>
-                    </div>
+                       <div class="form-buttons">
+                               <?php if ($change_request) { ?>
+                                       <input type="submit" name="activity_ok" 
value="<?php echo lang('activity_ok') ?>" />
+                                       <input type="submit" 
name="change_request" value="<?php echo lang('change_activity') ?>" />
+<?php }
+?>
+                       </div>
                        <FIELDSET title="Hva">
                                <LEGEND>Hva</LEGEND>
                                <dt>
                                        <label for="title"><?php echo 
lang('activity_title') ?></label>
                                </dt>
                                <dd>
-                                       <?php echo $activity->get_title();?>
+                                       <?php echo $activity->get_title(); ?>
                                </dd>
                                <dt>
                                        <label for="description"><?php echo 
lang('description') ?></label>
@@ -44,15 +49,15 @@
                                <dd>
                                        <?php echo 
$activity->get_description(); ?>
                                </dd>
-                               
+
                                <dt>
                                        <label for="category"><?php echo 
lang('category') ?></label>
                                </dt>
                                <dd>
                                        <?php
-                                               if($activity->get_category()){
-                                                       echo 
$act_so->get_category_name($activity->get_category());
-                                               }
+                                       if ($activity->get_category()) {
+                                               echo 
$act_so->get_category_name($activity->get_category());
+                                       }
                                        ?>
                                </dd>
                        </FIELDSET>
@@ -62,49 +67,47 @@
                                </dt>
                                <dd>
                                        <?php
-                                               if($activity->get_target()){
-                                                       $current_target_ids = 
$activity->get_target();
-                                                       
$current_target_id_array=explode(",", $current_target_ids);
-                                                       
foreach($current_target_id_array as $curr_target)
-                                                       {
-                                                               echo 
$act_so->get_target_name($curr_target).'<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 $curr_target) {
+                                                       echo 
$act_so->get_target_name($curr_target) . '<br/>';
                                                }
+                                       }
                                        ?>
                                </dd>
                                <dt>
-                                       <input type="checkbox" 
name="special_adaptation" id="special_adaptation"<?php echo 
$activity->get_special_adaptation() ? ' checked="checked"' : '' ?> 
disabled="disabled" /><label for="special_adaptation"><?php echo 
lang('special_adaptation') ?></label>
+                               <input type="checkbox" 
name="special_adaptation" id="special_adaptation"<?php echo 
$activity->get_special_adaptation() ? ' checked="checked"' : '' ?> 
disabled="disabled" /><label for="special_adaptation"><?php echo 
lang('special_adaptation') ?></label>
                                </dt>
                        </FIELDSET>
                        <FIELDSET title="hvor">
                                <LEGEND>Hvor og når</LEGEND>
-                               <?php if($activity->get_internal_arena()) { ?>
+<?php if ($activity->get_internal_arena()) { ?>
+                                       <dt>
+                                               <label for="arena"><?php echo 
lang('building') ?></label>
+                                       </dt>
+                                       <dd>
+                                               <?php echo 
activitycalendar_soarena::get_instance()->get_building_name($activity->get_internal_arena());
 ?>
+                                       </dd>
+<?php } ?>
+<?php if ($activity->get_arena()) { ?>
+                                       <dt>
+                                               <label for="arena"><?php echo 
lang('arena') ?></label>
+                                       </dt>
+                                       <dd>
+                                               <?php echo 
activitycalendar_soarena::get_instance()->get_arena_name($activity->get_arena());
 ?>
+                                       </dd>
+<?php } ?>
                                <dt>
-                                       <label for="arena"><?php echo 
lang('building') ?></label>
-                               </dt>
-                               <dd>
-                                       <?php echo 
activitycalendar_soarena::get_instance()->get_building_name($activity->get_internal_arena());
 ?>
-                               </dd>
-                               <?php }?>
-                               <?php if($activity->get_arena()) { ?>
-                               <dt>
-                                       <label for="arena"><?php echo 
lang('arena') ?></label>
-                               </dt>
-                               <dd>
-                                       <?php echo 
activitycalendar_soarena::get_instance()->get_arena_name($activity->get_arena());
 ?>
-                               </dd>
-                               <?php  } ?>
-                               <dt>
                                        <label for="district"><?php echo 
lang('district') ?></label>
                                </dt>
                                <dd>
                                        <?php
-                                       if($activity->get_district()){
+                                       if ($activity->get_district()) {
                                                $current_district_ids = 
$activity->get_district();
-                                               
$current_district_id_array=explode(",", $current_district_ids);
-                                               
foreach($current_district_id_array as $curr_district)
-                                               {
-                                                       echo 
$act_so->get_district_name($curr_district).'<br/>';
+                                               $current_district_id_array = 
explode(",", $current_district_ids);
+                                               foreach 
($current_district_id_array as $curr_district) {
+                                                       echo 
$act_so->get_district_name($curr_district) . '<br/>';
                                                }
                                        }
                                        ?>
@@ -113,58 +116,60 @@
                                        <label for="time"><?php echo 
lang('time') ?></label>
                                </dt>
                                <dd>
-                                       <?php echo $activity->get_time();?>
+<?php echo $activity->get_time(); ?>
                                </dd>
                        </FIELDSET>
                        <FIELDSET id="arr">
                                <legend>Arrangør</legend>
                                <dd>
-                                       <?php echo $organization->get_name();?>
-                                    <?php if(!$change_request)
-                                    {
-                                        if(!$activity->get_new_org()){?>
-                                               <a 
href="index.php?menuaction=activitycalendarfrontend.uiactivity.edit_organization_values&amp;organization_id=<?php
 echo $organization->get_id();?>" target="_blank"><?php echo 
lang('edit_organization');?></a>
-                                       <?php }
-                                    }?>
+                                       <?php echo $organization->get_name(); ?>
+                                       <?php
+                                       if (!$change_request) {
+                                               if (!$activity->get_new_org()) {
+                                                       ?>
+                                                       <a 
href="index.php?menuaction=activitycalendarfrontend.uiactivity.edit_organization_values&amp;organization_id=<?php
 echo $organization->get_id(); ?>" target="_blank"><?php echo 
lang('edit_organization'); ?></a>
+                                               <?php
+                                               }
+                                       }
+                                       ?>
                                </dd>
                                <br/>
                                <LEGEND>Kontaktperson</LEGEND>
                                <dt>
-                                       <?php 
if($activity->get_contact_person_1()) { ?>
+<?php if ($activity->get_contact_person_1()) { ?>
                                        <label for="contact_person_1"><?php 
echo lang('contact_person') ?></label>
-                                       <?php  } ?>
+                                       <?php } ?>
                                </dt>
                                <dd>
                                        <label for="contact1_name">Navn</label>
-                                       <?php echo 
isset($contact1)?$contact1->get_name():''?><br/>
+                                       <?php echo isset($contact1) ? 
$contact1->get_name() : '' ?><br/>
                                        <label 
for="contact1_phone">Telefon</label>
-                                       <?php echo 
isset($contact1)?$contact1->get_phone():''?><br/>
+<?php echo isset($contact1) ? $contact1->get_phone() : '' ?><br/>
                                        <label 
for="contact1_mail">E-post</label>
-                                       <?php echo 
isset($contact1)?$contact1->get_email():''?>
+<?php echo isset($contact1) ? $contact1->get_email() : '' ?>
                                </dd>
                        </FIELDSET>
                        <FIELDSET>
                                <BR>
-                <dt>
-                       <LABEL for="office">Kulturkontor</label>
+                               <dt>
+                                       <LABEL for="office">Kulturkontor</LABEL>
                                </dt>
                                <dd>
                                        <?php
-                                               if($activity->get_office()){
-                                                       echo 
$act_so->get_office_name($activity->get_office());
-                                               }
+                                       if ($activity->get_office()) {
+                                               echo 
$act_so->get_office_name($activity->get_office());
+                                       }
                                        ?>
                                </dd>
-                   </FIELDSET>
-                    <br/><br/>
-                    <div class="form-buttons">
-                        <?php
-                            if ($change_request) {?>
-                                <input type="submit" name="activity_ok" 
value="<?php echo lang('activity_ok')?>" />
-                                <input type="submit" name="change_request" 
value="<?php echo lang('change_activity')?>" />
-                        <?php }
-                        ?>
-                    </div>
-                </dl>
+                       </FIELDSET>
+                       <br/><br/>
+                       <div class="form-buttons">
+                               <?php if ($change_request) { ?>
+                                       <input type="submit" name="activity_ok" 
value="<?php echo lang('activity_ok') ?>" />
+                                       <input type="submit" 
name="change_request" value="<?php echo lang('change_activity') ?>" />
+<?php }
+?>
+                       </div>
+               </dl>
        </form>
 </div>
\ No newline at end of file

Modified: 
branches/stavangerkommune/activitycalendarfrontend/templates/base/activity_edit.php
===================================================================
--- 
branches/stavangerkommune/activitycalendarfrontend/templates/base/activity_edit.php
 2014-03-14 08:08:53 UTC (rev 11816)
+++ 
branches/stavangerkommune/activitycalendarfrontend/templates/base/activity_edit.php
 2014-03-14 08:10:39 UTC (rev 11817)
@@ -1,5 +1,5 @@
 <?php
-       //include common logic for all templates
+//include common logic for all templates
 //     include("common.php");
        $act_so = activitycalendar_soactivity::get_instance();
        $contpers_so = activitycalendar_socontactperson::get_instance();
@@ -7,414 +7,393 @@
 
 <script type="text/javascript">
 
-function get_available_groups()
-{
-       var org_id = document.getElementById('organization_id').value;
-       var div_select = document.getElementById('group_select');
+       function get_available_groups()
+       {
+               var org_id = document.getElementById('organization_id').value;
+               var div_select = document.getElementById('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 }?>
+<?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";
+               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 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);
+               }
        }
-       else if(org_id != null && org_id == 'change_org')
+
+       YAHOO.util.Event.onDOMReady(function()
        {
-               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";
+               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";
+               }
        }
-       else
+
+       function get_address_search()
        {
-               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 address = document.getElementById('address').value;
+               var div_address = document.getElementById('address_container');
+               div_address.style.display="block";
+
+               //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=\"address_select\" 
id=\"address\" size=\"5\" onChange='setAddressValue(this)'>";
                var divcontent_end = "</select>";
-               
+       
                var callback = {
                        success: function(response){
-                                               div_select.innerHTML = 
divcontent_start + JSON.parse(response.responseText) + divcontent_end; 
-                                       },
+                               div_address.innerHTML = divcontent_start + 
JSON.parse(response.responseText) + divcontent_end; 
+                       },
                        failure: function(o) {
-                                                alert("AJAX doesn't work"); 
//FAILURE
-                                        }
+                               alert("AJAX doesn't work"); //FAILURE
+                       }
                }
                var trans = YAHOO.util.Connect.asyncRequest('GET', url, 
callback, null);
+       
        }
-}
 
-YAHOO.util.Event.onDOMReady(function()
-{
-       get_available_groups();
-});
-
-function checkNewGroup()
-{
-       var group_selected = document.getElementById('group_id').value;
-       if(group_selected == 'new_group')
+       function get_address_search_cp2()
        {
-               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 address = document.getElementById('contact2_address').value;
+               var div_address = 
document.getElementById('contact2_address_container');
+               div_address.style.display="block";
 
-function get_address_search()
-{
-       var address = document.getElementById('address').value;
-       var div_address = document.getElementById('address_container');
-       div_address.style.display="block";
+               //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;
 
-       //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=\"address_select\" id=\"address\" 
size=\"5\" onChange='setAddressValue(this)'>";
-       var divcontent_end = "</select>";
+               var divcontent_start = "<select 
name=\"contact2_address_select\" id=\"address_cp2\" 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);
+               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);
        
-}
-
-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";
-
-       //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 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);
-       
-}
 
-function setAddressValue(field)
-{
-       if(field.name == 'contact2_address_select')
+       function setAddressValue(field)
        {
-       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;
-               div_address.style.display="none";
-       }
-       else
-       {
-       var address = document.getElementById('address');
-       var div_address = document.getElementById('address_container');
+                       address.value=field.value;
+                       div_address.style.display="none";
+               }
+               else
+               {
+                       var address = document.getElementById('address');
+                       var div_address = 
document.getElementById('address_container');
     
-       address.value=field.value;
-               div_address.style.display="none";
+                       address.value=field.value;
+                       div_address.style.display="none";
+               }
        }
-}
 
-function allOK()
-{
-       if(document.getElementById('title').value == null || 
document.getElementById('title').value == '')
+       function allOK()
        {
-               alert("Tittel må fylles ut!");
-               return false;
+               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('description').value == null || 
document.getElementById('description').value == '')
-       {
-               alert("Beskrivelse må fylles ut!");
-               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_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;
-}
 
 </script>
 
 <div class="yui-content">
        <div id="details">
-       
-       <?php if($message){?>
-       <div class="success">
-               <?php echo $message;?>
-       </div>
-       <?php }else if($error){?>
-       <div class="error">
-               <?php echo $error;?>
-       </div>
-       <?php }?>
-       </div>
-       <div class="pageTop">
-               <h1><?php echo lang('activity') ?></h1>
-                       <div>
-                           <?php echo lang('required_fields')?>
+
+               <?php if ($message) { ?>
+                       <div class="success">
+                               <?php echo $message; ?>
                        </div>
-       </div>
-               <form action="#" method="post">
-                       <input type="hidden" name="id" value="<?php 
if($activity->get_id()){ echo $activity->get_id(); } else { echo '0'; }  ?>"/>
-                       <dl class="proplist-col">
-                               <fieldset title="<?php echo lang('what')?>">
-                                       <legend>Hva</legend>
-                               <dt>
-                                       <label for="title"><?php echo 
lang('activity_title') ?> (*) <A 
onclick="window.open('hjelp.html','name','height=255, 
width=350,toolbar=no,directories=no,status=no, 
menubar=no,scrollbars=no,resizable=no'); return false;" 
-                          
href="http://dl-web.dropbox.com/u/44022695/Aktivitetsoversikt/hjelp.html"; 
-                          target="name"><IMG alt="Hjelp" 
-                          
src="/aktivitetsoversikt/images/hjelp.gif"></A></label>
-                               </dt>
-                               <dd>
-                                       <input type="text" name="title" 
id="title" value="<?php echo $activity->get_title() ?>" size="83"/>
-                               </dd>
-                               <DT>
-                                       <LABEL for="org_description"><?php echo 
lang('description')?> (*) <A 
onclick="window.open('hjelp.html','name','height=255, 
width=350,toolbar=no,directories=no,status=no, 
menubar=no,scrollbars=no,resizable=no'); return false;" 
-                       
href="http://dl-web.dropbox.com/u/44022695/Aktivitetsoversikt/hjelp.html"; 
-                       target="name"><IMG alt="Hjelp" 
-                       
src="/aktivitetsoversikt/images/hjelp.gif"></A></LABEL></DT>
-                    <DD><TEXTAREA cols="80" rows="4" name="description" 
id="description"><?php echo $activity->get_description() ?></TEXTAREA></DD>
-                               <dt>
-                                       <label for="category"><?php echo 
lang('category') ?> (*) <A 
onclick="window.open('hjelp.html','name','height=255, 
width=350,toolbar=no,directories=no,status=no, 
menubar=no,scrollbars=no,resizable=no'); return false;" 
-                              
href="http://dl-web.dropbox.com/u/44022695/Aktivitetsoversikt/hjelp.html"; 
-                              target="name"><IMG alt="Hjelp" 
-                              
src="/aktivitetsoversikt/images/hjelp.gif"></A></label>
-                               </dt>
-                               <dd>
-                                       <?php
-                                       $current_category_id = 
$activity->get_category();
-                                       ?>
-                                       <select name="category" id="category">
-                                               <option value="0">Ingen 
kategori valgt</option>
-                                               <?php
-                                               foreach($categories as 
$category)
-                                               {
-                                                       echo "<option 
".($current_category_id == $category->get_id() ? 'selected="selected"' : "")." 
value=\"{$category->get_id()}\">".$category->get_name()."</option>";
-                                               }
-                                               ?>
-                                       </select>
-                               </dd>
-                               </fieldset>
-                               <fieldset id="hvem"><legend>For hvem</legend>
-                               <dt>
-                                       <label for="target"><?php echo 
lang('target') ?> (*) <A onclick="window.open('hjelp.html','name','height=255, 
width=350,toolbar=no,directories=no,status=no, 
menubar=no,scrollbars=no,resizable=no'); return false;" 
-                              
href="http://dl-web.dropbox.com/u/44022695/Aktivitetsoversikt/hjelp.html"; 
-                              target="name"><IMG alt="Hjelp" 
-                              src="/aktivitetsoversikt/images/hjelp.gif"></A>
-                        </label>
-                               </dt>
-                               <dd>
-                                       <?php
-                                       $current_target_ids = 
$activity->get_target();
-                                       $current_target_id_array=explode(",", 
$current_target_ids);
-                                       foreach($targets as $t)
-                                       {
-                                       ?>
-                                               <input name="target[]" 
type="checkbox" value="<?php echo $t->get_id()?>" <?php echo 
(in_array($t->get_id(), $current_target_id_array) ? 'checked' : "")?>/><?php 
echo $t->get_name()?><br/>
-                                       <?php
-                                       }
-                                       ?>
-                               </dd>
-                               <dt>
-                                       <input type="checkbox" 
name="special_adaptation" id="special_adaptation" <?php echo 
$activity->get_special_adaptation() ? ' checked="checked"' : '' ?>/>
-                                       <label for="special_adaptation"><?php 
echo lang('special_adaptation') ?></label>
-                                       <A 
onclick="window.open('hjelp.html','name','height=255, 
width=350,toolbar=no,directories=no,status=no, 
menubar=no,scrollbars=no,resizable=no'); return false;" 
-                             
href="http://dl-web.dropbox.com/u/44022695/Aktivitetsoversikt/hjelp.html"; 
-                             target="name"><IMG alt="Hjelp" 
-                             src="/aktivitetsoversikt/images/hjelp.gif"></A>
-                               </dt>
-                       </fieldset>
-                               <fieldset title="hvor">
-                                       <LEGEND>Hvor og når</LEGEND>
-                               <dt>
-                                       <br/>
-                                       <label for="arena"><?php echo 
lang('arena') ?> (*) <A onclick="window.open('hjelp.html','name','height=255, 
width=350,toolbar=no,directories=no,status=no, 
menubar=no,scrollbars=no,resizable=no'); return false;" 
-                          
href="http://dl-web.dropbox.com/u/44022695/Aktivitetsoversikt/hjelp.html"; 
-                          target="name"><IMG alt="Hjelp" 
-                          src="/aktivitetsoversikt/images/hjelp.gif"></A>
-                        </label>
-                                       <br/>
-                               </dt>
-                               <dd>
-                               <?php 
-                                   $internal_arena_id = 
$activity->get_internal_arena();
-                                   $arena_id = $activity->get_arena();
-                               ?>
-                                       <select name="internal_arena_id" 
id="internal_arena_id" style="width: 200px;">
-                                                       <option 
value="0">Lokale ikke valgt</option>
-                                                       <optgroup label="<?php 
echo lang('building') ?>">
-                                                       <?php
-                                                       foreach($buildings as 
$building_id => $building_name)
-                                                       {
-                                                           
if($internal_arena_id && $internal_arena_id == $building_id)
-                                                               $selected = 
"selected";
-                                                           else
-                                                               $selected = "";
-                                                               echo "<option 
value=\"i_{$building_id}\" {$selected}>".$building_name."</option>";
-                                                       }
-                                                       ?>
-                                                       </optgroup>
-                                                       <optgroup label="<?php 
echo lang('external_arena') ?>">
-                                                       <?php 
-                                                       foreach($arenas as 
$arena)
-                                                       {
-                                                           if($arena_id && 
$arena_id == $arena->get_id())
-                                                               $selected = 
"selected";
-                                                           else
-                                                               $selected = "";
-                                                               echo "<option 
value=\"e_{$arena->get_id()}\" title=\"{$arena->get_arena_name()}\" 
{$selected}>".$arena->get_arena_name()."</option>";
-                                                       }
-                                                       ?>
-                                                       </optgroup>
-                                       </select>
-                                       <BR>
-                               </dd>
-                               <dt>
-                                       <label for="district"><?php echo 
lang('district') ?> (*) <A 
onclick="window.open('hjelp.html','name','height=255, 
width=350,toolbar=no,directories=no,status=no, 
menubar=no,scrollbars=no,resizable=no'); return false;" 
-                              
href="http://dl-web.dropbox.com/u/44022695/Aktivitetsoversikt/hjelp.html"; 
-                              target="name"><IMG alt="Hjelp" 
-                              src="/aktivitetsoversikt/images/hjelp.gif"></A>
-                        </label>
-                               </dt>
-                               <dd>
-                                       <?php
-                                       $current_district_id = 
$activity->get_district();
-                                       
//$current_district_id_array=explode(",", $current_district_ids);
-                                       foreach($districts as $d)
-                                       {
-                                       ?>
-                                               <input name="district" 
type="radio" value="<?php echo $d['part_of_town_id']?>" <?php echo 
($d['part_of_town_id'] == $current_district_id) ? 'checked' : "" ?>/><?php echo 
$d['name']?><br/>
-                                       <?php
-                                       }
-                                       ?>
-                               </dd>
-                               <dt>
-                                       <label for="time"><?php echo 
lang('time') ?> (*) <A onclick="window.open('hjelp.html','name','height=255, 
width=350,toolbar=no,directories=no,status=no, 
menubar=no,scrollbars=no,resizable=no'); return false;" 
-                                               
href="http://dl-web.dropbox.com/u/44022695/Aktivitetsoversikt/hjelp.html"; 
-                                               target="name"><IMG alt="Hjelp" 
-                                       
src="/aktivitetsoversikt/images/hjelp.gif"></A>
-                               </label>
-                               </dt>
-                               <dd>
-                                       <input type="text" name="time" 
id="time" value="<?php echo $activity->get_time() ?>" size="80" />
-                               </dd>
-                               </fieldset>
-                               <FIELDSET id="arr">
-                                       <LEGEND>Kontaktperson</LEGEND><BR>
-                                       Kontaktperson for aktiviteten <A 
onclick="window.open('hjelp.html','name','height=255, 
width=350,toolbar=no,directories=no,status=no, 
menubar=no,scrollbars=no,resizable=no'); return false;" 
-                       
href="http://dl-web.dropbox.com/u/44022695/Aktivitetsoversikt/hjelp.html"; 
-                       target="name"><IMG alt="Hjelp" 
src="/aktivitetsoversikt/images/hjelp.gif"></A><BR>
-                                       <DT><LABEL for="contact_name">Navn 
(*)</LABEL></DT>
-                       <DD><INPUT name="contact_name" id="contact_name" 
size="80" type="text" value="<?php echo $contact1->get_name()?>"></DD>
-                       <DT><LABEL for="contact_phone">Telefon (*)</LABEL></DT>
-                       <DD><INPUT name="contact_phone" id="contact_phone" 
type="text" value="<?php echo $contact1->get_phone()?>"></DD>
-                       <DT><LABEL for="contact_mail">E-post (*)</LABEL></DT>
-                       <DD><INPUT name="contact_mail" id="contact_mail" 
size="50" type="text" value="<?php echo $contact1->get_email()?>"></DD>
-                       <DT><LABEL for="contact2_mail2">Gjenta e-post 
(*)</LABEL></DT>
-                       <DD><INPUT name="contact_mail2" id="contact_mail2" 
size="50" type="text" value="<?php echo $contact1->get_email()?>"></DD>
-                               </FIELDSET>
-                               <FIELDSET>
-                               <BR>
-                    <DT><LABEL for="office">Hvilket kulturkontor skal motta 
registreringen (*) <A 
-                      onclick="window.open('hjelp.html','name','height=255, 
width=350,toolbar=no,directories=no,status=no, 
menubar=no,scrollbars=no,resizable=no'); return false;" 
-                      
href="http://dl-web.dropbox.com/u/44022695/Aktivitetsoversikt/hjelp.html"; 
-                      target="name"><IMG alt="Hjelp" 
-                      
src="/aktivitetsoversikt/images/hjelp.gif"></A></LABEL></DT>
-                               <dd>
-                                       <?php
-                                       $selected_office = 
$activity->get_office();
-                                       ?>
-                                       <select name="office" id="office">
-                                               <option value="0">Ingen kontor 
valgt</option>
-                                               <?php
-                                               foreach($offices as $office)
-                                               {
-                                                       echo "<option 
".($selected_office == $office['id'] ? 'selected="selected"' : "")." 
value=\"{$office['id']}\">".$office['name']."</option>";
-                                               }
-                                               ?>
-                                       </select>
-                               </dd>
-                               </FIELDSET>
-                               <div class="form-buttons">
-                               <?php
-                                       if ($editable) {?>
-                                            <input type="submit" 
name="save_activity" value="<?php echo lang('save')?>" onclick="return 
allOK();"/>
-                               <?php   }
-                               ?>
-                               </div>
-                       </dl>
-               </form>
+               <?php } else if ($error) { ?>
+                       <div class="error">
+                               <?php echo $error; ?>
+                       </div>
+               <?php } ?>
        </div>
+       <div class="pageTop">
+               <h1><?php echo lang('activity') ?></h1>
+               <div>
+                       <?php echo lang('required_fields') ?>
+               </div>
+       </div>
+       <form action="#" method="post">
+               <input type="hidden" name="id" value="<?php
+                       if ($activity->get_id()) {
+                               echo $activity->get_id();
+                       } else {
+                               echo '0';
+                       }
+                       ?>"/>
+               <dl class="proplist-col">
+                       <fieldset title="<?php echo lang('what') ?>">
+                               <legend>Hva</legend>
+                               <dt>
+                                       <label for="title"><?php echo 
lang('activity_title') ?> (*) <a onclick="alert('<?php echo 
lang('help_new_activity_title') ?>'); return false;" href="#"><img alt="Hjelp" 
src="/aktivitetsoversikt/images/hjelp.gif"></a></label>
+                               </dt>
+                               <dd>
+                                       <input type="text" name="title" 
id="title" value="<?php echo $activity->get_title() ?>" size="83" 
maxlength="254"/>
+                               </dd>
+                               <DT>
+                                       <LABEL for="org_description"><?php echo 
lang('description') ?> (*) <a onclick="alert('<?php echo 
lang('help_new_activity_description') ?>'); return false;" href="#"><img 
alt="Hjelp" src="/aktivitetsoversikt/images/hjelp.gif"></a></LABEL></DT>
+                               <DD><TEXTAREA cols="80" rows="4" 
name="description" id="description"><?php echo $activity->get_description() 
?></TEXTAREA></DD>
+                               <dt>
+                                       <label for="category"><?php echo 
lang('category') ?> (*) <a onclick="alert('<?php echo 
lang('help_new_activity_category') ?>'); return false;" href="#"><img 
alt="Hjelp" src="/aktivitetsoversikt/images/hjelp.gif"></a></label>
+                               </dt>
+                               <dd>
+                                       <?php
+                                       $current_category_id = 
$activity->get_category();
+                                       ?>
+                                       <select name="category" id="category">
+                                               <option value="0">Ingen 
kategori valgt</option>
+                                               <?php
+                                               foreach ($categories as 
$category) {
+                                                       echo "<option " . 
($current_category_id == $category->get_id() ? 'selected="selected"' : "") . " 
value=\"{$category->get_id()}\">" . $category->get_name() . "</option>";
+                                               }
+                                               ?>
+                                       </select>
+                               </dd>
+                       </fieldset>
+                       <fieldset id="hvem"><legend>For hvem</legend>
+                               <dt>
+                                       <label for="target"><?php echo 
lang('target') ?> (*) <a onclick="alert('<?php echo 
lang('help_new_activity_target') ?>'); return false;" href="#"><img alt="Hjelp" 
src="/aktivitetsoversikt/images/hjelp.gif"></a>
+                                       </label>
+                               </dt>
+                               <dd>
+                                       <?php
+                                       $current_target_ids = 
$activity->get_target();
+                                       $current_target_id_array = explode(",", 
$current_target_ids);
+                                       foreach ($targets as $t) {
+                                               ?>
+                                               <input name="target[]" 
type="checkbox" value="<?php echo $t->get_id() ?>" <?php echo 
(in_array($t->get_id(), $current_target_id_array) ? 'checked' : "") ?>/><?php 
echo $t->get_name() ?><br/>
+                                               <?php
+                                       }
+                                       ?>
+                               </dd>
+                               <dt>
+                                       <input type="checkbox" 
name="special_adaptation" id="special_adaptation" <?php echo 
$activity->get_special_adaptation() ? ' checked="checked"' : '' ?>/>
+                                       <label for="special_adaptation"><?php 
echo lang('special_adaptation') ?></label>
+                                       <a onclick="alert('<?php echo 
lang('help_new_activity_spec_adapt') ?>'); return false;" href="#"><img 
alt="Hjelp" src="/aktivitetsoversikt/images/hjelp.gif"></a>
+                               </dt>
+                       </fieldset>
+                       <fieldset title="hvor">
+                               <LEGEND>Hvor og når</LEGEND>
+                               <dt>
+                                       <br/>
+                                       <label for="arena"><?php echo 
lang('location') ?> (*) <a onclick="alert('<?php echo 
lang('help_edit_activity_location') ?>'); return false;" href="#"><img 
alt="Hjelp" src="/aktivitetsoversikt/images/hjelp.gif"></a>
+                                       </label>
+                                       <br/>
+                               </dt>
+                               <dd>
+                                       <?php
+                                       $internal_arena_id = 
$activity->get_internal_arena();
+                                       $arena_id = $activity->get_arena();
+                                       ?>
+                                       <select name="internal_arena_id" 
id="internal_arena_id" style="width: 200px;">
+                                               <option value="0">Lokale ikke 
valgt</option>
+                                               <optgroup label="<?php echo 
lang('building') ?>">
+                                                       <?php
+                                                       foreach ($buildings as 
$building_id => $building_name) {
+                                                               if 
($internal_arena_id && $internal_arena_id == $building_id)
+                                                                       
$selected = "selected";
+                                                               else
+                                                                       
$selected = "";
+                                                               echo "<option 
value=\"i_{$building_id}\" {$selected}>" . $building_name . "</option>";
+                                                       }
+                                                       ?>
+                                               </optgroup>
+                                               <optgroup label="<?php echo 
lang('external_arena') ?>">
+                                                       <?php
+                                                       foreach ($arenas as 
$arena) {
+                                                               if ($arena_id 
&& $arena_id == $arena->get_id())
+                                                                       
$selected = "selected";
+                                                               else
+                                                                       
$selected = "";
+                                                               echo "<option 
value=\"e_{$arena->get_id()}\" title=\"{$arena->get_arena_name()}\" 
{$selected}>" . $arena->get_arena_name() . "</option>";
+                                                       }
+                                                       ?>
+                                               </optgroup>
+                                       </select>
+                                       <BR>
+                               </dd>
+                               <dt>
+                                       <label for="district"><?php echo 
lang('district') ?> (*) <a onclick="alert('<?php echo 
lang('help_new_activity_district') ?>'); return false;" href="#"><img 
alt="Hjelp" src="/aktivitetsoversikt/images/hjelp.gif"></a>
+                                       </label>
+                               </dt>
+                               <dd>
+                                       <?php
+                                       $current_district_id = 
$activity->get_district();
+                                       
//$current_district_id_array=explode(",", $current_district_ids);
+                                       foreach ($districts as $d) {
+                                               ?>
+                                               <input name="district" 
type="radio" value="<?php echo $d['part_of_town_id'] ?>" <?php echo 
($d['part_of_town_id'] == $current_district_id) ? 'checked' : "" ?>/><?php echo 
$d['name'] ?><br/>
+                                               <?php
+                                       }
+                                       ?>
+                               </dd>
+                               <dt>
+                                       <label for="time"><?php echo 
lang('time') ?> (*) <a onclick="alert('<?php echo 
lang('help_new_activity_time') ?>'); return false;" href="#"><img alt="Hjelp" 
src="/aktivitetsoversikt/images/hjelp.gif"></a>
+                                       </label>
+                               </dt>
+                               <dd>
+                                       <input type="text" name="time" 
id="time" value="<?php echo $activity->get_time() ?>" size="80" maxlength="254" 
/>
+                               </dd>
+                       </fieldset>
+                       <FIELDSET id="arr">
+                               <LEGEND>Kontaktperson</LEGEND><BR>
+                               Kontaktperson for aktiviteten <a 
onclick="alert('<?php echo lang('help_new_activity_contact_person') ?>'); 
return false;" href="#"><img alt="Hjelp" 
src="/aktivitetsoversikt/images/hjelp.gif"></a><BR>
+                               <DT><LABEL for="contact_name">Navn 
(*)</LABEL></DT>
+                               <DD><INPUT name="contact_name" 
id="contact_name" size="80" type="text" value="<?php echo $contact1->get_name() 
?>"></DD>
+                               <DT><LABEL for="contact_phone">Telefon 
(*)</LABEL></DT>
+                               <DD><INPUT name="contact_phone" 
id="contact_phone" type="text" value="<?php echo $contact1->get_phone() 
?>"></DD>
+                               <DT><LABEL for="contact_mail">E-post 
(*)</LABEL></DT>
+                               <DD><INPUT name="contact_mail" 
id="contact_mail" size="50" type="text" value="<?php echo 
$contact1->get_email() ?>"></DD>
+                               <DT><LABEL for="contact2_mail2">Gjenta e-post 
(*)</LABEL></DT>
+                               <DD><INPUT name="contact_mail2" 
id="contact_mail2" size="50" type="text" value="<?php echo 
$contact1->get_email() ?>"></DD>
+                       </FIELDSET>
+                       <FIELDSET>
+                               <BR>
+                               <DT><LABEL for="office">Hvilket kulturkontor 
skal motta registreringen (*) <a onclick="alert('<?php echo 
lang('help_new_activity_office') ?>'); return false;" href="#"><img alt="Hjelp" 
src="/aktivitetsoversikt/images/hjelp.gif"></a></LABEL></DT>
+                               <dd>
+                                       <?php
+                                       $selected_office = 
$activity->get_office();
+                                       ?>
+                                       <select name="office" id="office">
+                                               <option value="0">Ingen kontor 
valgt</option>
+                                               <?php
+                                               foreach ($offices as $office) {
+                                                       echo "<option " . 
($selected_office == $office['id'] ? 'selected="selected"' : "") . " 
value=\"{$office['id']}\">" . $office['name'] . "</option>";
+                                               }
+                                               ?>
+                                       </select>
+                               </dd>
+                       </FIELDSET>
+                       <div class="form-buttons">
+                               <?php if ($editable) { ?>
+                                       <input type="submit" 
name="save_activity" value="<?php echo lang('save') ?>" onclick="return 
allOK();"/>
+<?php }
+?>
+                       </div>
+               </dl>
+       </form>
+</div>
 </div>
\ No newline at end of file

Modified: 
branches/stavangerkommune/activitycalendarfrontend/templates/base/activity_edit_step_1.php
===================================================================
--- 
branches/stavangerkommune/activitycalendarfrontend/templates/base/activity_edit_step_1.php
  2014-03-14 08:08:53 UTC (rev 11816)
+++ 
branches/stavangerkommune/activitycalendarfrontend/templates/base/activity_edit_step_1.php
  2014-03-14 08:10:39 UTC (rev 11817)
@@ -1,86 +1,85 @@
 <?php ?>
 <script type="text/javascript">
-function isOK()
-{
-       if(document.getElementById('activity_id').value == null || 
document.getElementById('activity_id').value == '' || 
document.getElementById('activity_id').value == 0)
+       function isOK()
        {
-               alert("Du må velge en aktivitet som skal endres!");
-               return false;
+               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;
+               }
        }
-       else
+       function get_activities()
        {
-               return true;
-       }
-}
-function get_activities()
-{
-       var org_id = document.getElementById('organization_id').value;
-       var div_select = document.getElementById('activity_select');
+               var org_id = document.getElementById('organization_id').value;
+               var div_select = document.getElementById('activity_select');
 
-       url = "<?php echo 
$ajaxURL?>index.php?menuaction=activitycalendarfrontend.uiactivity.get_organization_activities&amp;phpgw_return_as=json&amp;orgid="
 + org_id;
+               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 divcontent_start = "<select name=\"activity_id\" 
id=\"activity_id\">";
+               var divcontent_end = "</select>";
        
-       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);
+               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);
        
-}
+       }
 
-YAHOO.util.Event.onDOMReady(function()
-{
-       get_activities();
-});
+       YAHOO.util.Event.onDOMReady(function()
+       {
+               get_activities();
+       });
 </script>
 
 <div class="yui-content" style="width: 100%;">
-    <div class="pageTop">
-       <h1><?php echo lang('edit_activity');?></h1>
-       <form action="#" method="post">
-               <dl class="proplist-col" style="width: 200%">
-                       <dt>
-                            <?php if($message){?>

@@ Diff output truncated at 153600 characters. @@



reply via email to

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