private function process()
 {
     $this->commonProcess();
     $config = services::getService('config');
     $lang = services::getService('lang');
     $params = services::getService('pageParams');
     // the table with users pools is generated
     // fetch "Pool"
     $pools_pool = new pools();
     $pools_pool->id = 1;
     $pools_pool->find(true);
     if ($pools_pool->isAdmin($this->user->id)) {
         $this->mypoolstable_thirdcol = true;
         $this->mypoolstable[] = array("id" => $pools_pool->id, "name" => $pools_pool->name, "area" => $pools_pool->area, "links" => '<a href="./index.php?page=pooldata&pool_id=' . $pools->id . '">' . $lang->getMsg('mysite_poolsadmintable_changedatalink') . '</a> | <a href="./index.php?page=pooladmin&pool_id=' . $pools->id . '">' . $lang->getMsg('mysite_poolsadmintable_adminlink') . '</a>');
     } else {
         $this->mypoolstable[] = array("id" => $pools_pool->id, "name" => $pools_pool->name, "area" => $pools_pool->area);
     }
     // fetch all other pools
     $pools = new poolsFetcher();
     $pools->_user = $this->user->id;
     $pools->_order = "name";
     $pools->search();
     while ($pools->fetch()) {
         if ($pools->id != 1) {
             if ($pools->isAdmin($this->user->id)) {
                 $this->mypoolstable_thirdcol = true;
                 $this->mypoolstable[] = array("id" => $pools->id, "name" => $pools->name, "area" => $pools->area, "links" => '<a href="./index.php?page=pooldata&pool_id=' . $pools->id . '">' . $lang->getMsg('mysite_poolsadmintable_changedatalink') . '</a> | <a href="./index.php?page=pooladmin&pool_id=' . $pools->id . '">' . $lang->getMsg('mysite_poolsadmintable_adminlink') . '</a>');
             } else {
                 $this->mypoolstable[] = array("id" => $pools->id, "name" => $pools->name, "area" => $pools->area);
             }
         }
     }
 }
 public function commonProcess()
 {
     $lang = services::getService('lang');
     $session = services::getService('pageParams');
     if (!isset($this->user) && $session->getParam('page') != 'register' && $session->getParam('page') != 'static') {
         $session->addParam('msg', 'msg_login_first', 'page');
         $this->switchPage('home');
     }
     // headerlinks
     if ($this->user->login) {
         $this->addHeaderLink('logout', $lang->getMsg('link_logout'), 'right');
         $this->addHeaderLink('mysite', $lang->getMsg('link_mysite'), 'left');
     }
     // build subcategories for "myresources"
     if (isset($this->user)) {
         // borrowed res are shown
         $this->borrowed_res = $this->user->getBorrowedRes();
         // waiting res are shown
         $this->res_offers = $this->user->getWaitingRes();
         $this->toDoList();
         // fetch users pools
         $my_pools_ids = $this->user->getPoolIDs();
         foreach ($my_pools_ids as $pool_id) {
             $userpool = new pools();
             $userpool->id = $pool_id;
             $userpool->find(true);
             $this->pools_get .= $pool_id . 'a';
             $this->pools[] = array($pool_id, $userpool->name);
         }
         // Instantiate the HTML_QuickForm object
         $this->searchform = new formSearch('SearchForm', $this->pools_get);
         // Try to validate a form
         if ($this->searchform->validate() && $session->getParam('searchsubmit') == 'submitted') {
             $search_res = new resFetcher();
             $search_res->_cat = $this->searchform->exportValue('cat');
             $search_res->_search_string = $this->searchform->exportValue('searchstring');
             $search_res->_pools = $this->searchform->exportValue('searchwhere');
             $pool_ids = array();
             $pools_get = $this->searchform->exportValue('searchwhere');
             if ($search_res->count() < 1) {
                 $this->addMsg('msg_no_results');
             } else {
                 $this->switchPage('resbrowser&cat=' . $this->searchform->exportValue('cat') . '&searchwhere=' . $pools_get . '&searchstring=' . $this->searchform->exportValue('searchstring'));
             }
         }
     }
 }
 private function process()
 {
     $this->commonProcess();
     $config = services::getService('config');
     $lang = services::getService('lang');
     $params = services::getService('pageParams');
     $categories = services::getService('cats');
     // Instantiate the HTML_QuickForm object
     $this->form = new formSearch('SearchForm');
     // fetch users pools
     $my_pools_ids = $this->user->getPoolIDs();
     foreach ($my_pools_ids as $pool_id) {
         $userpool = new pools();
         $userpool->id = $pool_id;
         $userpool->find(true);
         $this->pools_get .= $pool_id . 'a';
         $this->pools[] = array($pool_id, $userpool->name);
     }
     $this->form->setPools($this->pools, $this->pools_get);
     // Try to validate a form
     if ($this->form->validate()) {
         $search_res = new resFetcher();
         $search_res->_cat = $this->form->exportValue('cat');
         $search_res->_search_string = $this->form->exportValue('searchstring');
         $search_res->_pools = $this->form->exportValue('searchwhere');
         $pool_ids = array();
         $pools_get = $this->form->exportValue('searchwhere');
         /*$something_found = true;
                 if($params->getParam('cat')) {
                   $cat = $params->getParam('cat');
                 
                   $attributes = new attributes;
                   $attributes->category_id = $cat;
         
                   if($attributes->find()) {
                   
                     while($attributes->fetch()) {
                   
                       if($attributes->type == "string") {
                         $attr_string = new attributesString;
                                   
                         $attr_string->attribute_id = $attributes->id;
                         
                         // insert
                         $attr_string->query("SELECT DISTINCT pools_attributes_string WHERE value LIKE '%".$this->form->exportValue('search_'.$attributes->name)."%');
                         $value = $this->form->exportValue('search_'.$attributes->name);
                         if($value != "") {
                           $attr_string->value = $value;
                           if(!$attr_string->find())
                             $something_found = false;(".$this->__table.".".name." LIKE '%".$search."%')
                         }
                       }
                       if($attributes->type == "select") {
                         $values = $this->form->getElementValue('resdata_'.$attributes->name);
                         if(!is_array($values))
                         $values = array($values);
         
                         foreach($values as $value) if($value[0] != 0){
                           $attr_string = new attributesSelect;
                                   
                           $attr_string->res_id = $newres->id;
                           $attr_string->attribute_id = $attributes->id;
                         
                           // insert
                           $attr_string->value = $value[0];
                           $attr_string->insert();
                         }
                       }
                     }
                   }
                 }*/
         if ($search_res->count() < 1) {
             $this->addMsg('msg_no_results');
         } else {
             $this->switchPage('resbrowser&cat=' . $this->form->exportValue('cat') . '&searchwhere=' . $pools_get . '&searchstring=' . $this->form->exportValue('searchstring'));
         }
     }
 }
 private function process()
 {
     $this->commonProcess();
     $config = services::getService('config');
     $lang = services::getService('lang');
     $params = services::getService('pageParams');
     // function is set
     if ($params->getParam('function')) {
         $this->function = $params->getParam('function');
     } else {
         $this->function = 'public';
     }
     $table = new tablePools();
     if ($this->function == 'public') {
         // fetch "Pool"
         $pools_pool = new pools();
         $pools_pool->id = 1;
         $pools_pool->find(true);
         $main_res = new resFetcher();
         $main_res->_pools = array(1);
         $table->addRow(array('<a href="./index.php?page=showpool&pool_id=' . $pools_pool->id . '&cat=0&type=0">' . $pools_pool->name . '</a>', $pools_pool->area, " ", $main_res->count()), array("class" => "pools3"));
     }
     // other pools
     $pools = new poolsFetcher();
     if ($this->function == 'public') {
         $pools->_is_public = 1;
     } else {
         $pools->_is_public = 0;
     }
     $order = "country,plz";
     $pools->_order = $order;
     $pools->search();
     $act_country = 'none';
     while ($pools->fetch()) {
         if (!($pools->id == 1)) {
             // country headlines
             if ($pools->country != $act_country) {
                 if ($pools->country == '0') {
                     $table->addRow(array('&nbsp;'), array("color" => "white"));
                     $table->addRow(array('<b>' . $lang->getMsg('showpool_nocountry_header') . '</b>'), array("class" => "poolsblank"));
                 } else {
                     $table->addRow(array('&nbsp;'), array("color" => "white"));
                     $table->addRow(array('<b>' . $lang->getMsg('country_' . $pools->country) . '</b>'), array("class" => "poolsblank"));
                 }
                 $lastplz = true;
                 $act_country = $pools->country;
             }
             if ($pools->plz && !$lastplz) {
                 $table->addRow(array('&nbsp;'), array("color" => "white"));
             }
             if ($pools->plz) {
                 $plz = $pools->plz;
             } else {
                 $plz = false;
             }
             $rescount = new resFetcher();
             $rescount->_pools = array($pools->id);
             $table->addRow(array('<a href="./index.php?page=showpool&pool_id=' . $pools->id . '">' . $pools->name . '</a>', $pools->area, $plz . ' ' . $pools->city, $rescount->count()), array("class" => "pools3"));
             $lastplz = $pools->plz;
         }
     }
     $this->table = $table;
     $this->header = $lang->getMsg('poolbrowser_all_header');
 }
 private function process()
 {
     $this->commonProcess();
     $config = services::getService('config');
     $lang = services::getService('lang');
     $params = services::getService('pageParams');
     $categories = services::getService('cats');
     // process form
     $this->processForm();
     // if a pool is chosen, it is intanciated
     $is_one_pool = false;
     if (!(count(explode("a", $params->getParam('searchwhere'))) > 1)) {
         $pool = new pools();
         $pool->id = $params->getParam('searchwhere');
         $pool->find(true);
         $is_one_pool = true;
     }
     if (!$params->getParam('show_page')) {
         $params->addParam('show_page', 1, 'now');
     }
     // get Attributes
     $attr = new attributes();
     $attr->category_id = $params->getParam('cat');
     if ($attr->find()) {
         while ($attr->fetch()) {
             $this->attributes[] = clone $attr;
         }
     }
     // tabledata is fetched and ordered
     $tabledata = array();
     $res_fetcher = new resFetcher();
     $res_fetcher->_cat = $params->getParam('cat');
     $res_fetcher->_search_string = $params->getParam('searchstring');
     $get_add .= "&searchstring=" . $params->getParam('searchstring');
     $get_add .= "&searchwhere=" . $params->getParam('searchwhere');
     if ($is_one_pool) {
         $res_fetcher->_pools = array($pool->id);
     } else {
         $res_fetcher->_pools = explode("a", $params->getParam('searchwhere'));
     }
     // fetch users pools
     $my_pools_ids = $this->user->getPoolIDs();
     foreach ($my_pools_ids as $pool_id) {
         $userpool = new pools();
         $userpool->id = $pool_id;
         $userpool->find(true);
         $this->pools_get .= $pool_id . 'a';
         $this->pools[] = array($pool_id, $userpool->name);
     }
     if ($params->getParam('order')) {
         $res_fetcher->_order = $params->getParam('order');
     } else {
         $res_fetcher->_order = 'name';
     }
     $res_fetcher->search();
     $showres = $res_fetcher->getAsArray();
     // presets for attributes
     foreach ($this->attributes as $attr_obj) {
         if ($params->getParam('attribute' . $attr_obj->id)) {
             $this->attribute_presets[$attr_obj->id] = $params->getParam('attribute' . $attr_obj->id);
             $get_add .= "&attribute" . $attr_obj->id . "=" . $params->getParam('attribute' . $attr_obj->id);
         }
     }
     // contact and action-colums are build
     $count = 1;
     $page = $params->getParam('show_page');
     foreach ($showres as $show_res) {
         $fitsattr = true;
         foreach ($this->attributes as $attr_obj) {
             // string-type
             if ($params->getParam('attribute' . $attr_obj->id)) {
                 if ($attr_obj->type == "string") {
                     $resattr = new attributesString();
                     $resattr->attribute_id = $attr_obj->id;
                     $resattr->res_id = $show_res->id;
                     if (!$resattr->isLike($params->getParam('attribute' . $attr_obj->id))) {
                         $fitsattr = false;
                     }
                 }
                 if ($attr_obj->type == "select") {
                     $resattr = new attributesSelect();
                     $resattr->attribute_id = $attr_obj->id;
                     $resattr->res_id = $show_res->id;
                     if ($resattr->find()) {
                         $fitsattr = false;
                         while ($resattr->fetch()) {
                             $select_keys = new attributesSelectKeys();
                             $select_keys->key = $resattr->value;
                             $select_keys->find(true);
                             if (stripos($lang->getMsg('resdata_form_select_' . $select_keys->value), $params->getParam('attribute' . $attr_obj->id)) !== false) {
                                 $fitsattr = true;
                             }
                         }
                     } else {
                         $fitsattr = false;
                     }
                 }
             }
         }
         if ($fitsattr) {
             if ($count >= $page * 20 - 19 && $count <= $page * 20) {
                 $contact = "";
                 $action = "";
                 $show_res->fetchUser();
                 // if the pool is browsed or a search is shown, the *_public-variables are proofed, if another pool
                 // is browsed, all userdata ist shown. If only my pools are looked up by a search, all userdata is shown too.
                 // data in the conta	ct-column
                 // userdata is only shown, if he's in at least one of the pools
                 // the logged-in user is a member of
                 // show detalis if ressource id passed
                 $detail = $show_res->id == $params->getParam('res_id');
                 $email = $show_res->user->email;
                 $street = $show_res->user->street;
                 $house = $show_res->user->house;
                 $country = $show_res->user->country;
                 $plz = $show_res->user->plz;
                 $city = $show_res->user->city;
                 $phone = $show_res->user->phone;
                 $user_desc = $show_res->user->description;
                 // show detail: resource
                 if ($detail) {
                     // attributes for detail-article are fetched
                     $attributes = new attributes();
                     $attributes->category_id = $show_res->cat;
                     $attributes->find();
                     $res_attr_array = array();
                     while ($attributes->fetch()) {
                         // string-attributes
                         if ($attributes->type == "string") {
                             $res_attr = new attributesString();
                             $res_attr->res_id = $show_res->id;
                             $res_attr->attribute_id = $attributes->id;
                             if ($res_attr->find(true)) {
                                 $res_attr_array[] = array("value" => $res_attr->value, "name" => 'resdata_form_' . $attributes->name);
                             }
                         }
                         // select-attributes
                         if ($attributes->type == "select") {
                             $res_attr = new attributesSelect();
                             $res_attr->res_id = $show_res->id;
                             $res_attr->attribute_id = $attributes->id;
                             if ($res_attr->find()) {
                                 $value = "";
                                 while ($res_attr->fetch()) {
                                     $keys = new attributesSelectKeys();
                                     $keys->key = $res_attr->value;
                                     $keys->attribute_id = $res_attr->attribute_id;
                                     $keys->find(true);
                                     $value = $value . $lang->getMsg('resdata_form_select_' . $keys->value) . '&nbsp;';
                                 }
                                 $res_attr_array[] = array("value" => $value, "name" => 'resdata_form_' . $attributes->name);
                             }
                         }
                     }
                     if ($this->user->inMine($show_res->user->id)) {
                         if ($show_res->user->id == $this->user->id) {
                             $prove_public = 2;
                         } else {
                             $prove_public = false;
                         }
                     } else {
                         $prove_public = true;
                     }
                 } else {
                     $prove_public = false;
                 }
                 $is_waiting = new resWait();
                 $is_waiting->user_id = $this->user->id;
                 $is_waiting->res_id = $show_res->id;
                 if (strlen($show_res->name) > 60) {
                     $show_res->name = substr($show_res->name, 0, 60) . '...';
                 }
                 $act_row = array('res_id' => $show_res->id, 'name' => $show_res->name, 'description' => $show_res->description, 'type' => $show_res->type, 'resolvetype' => $this->resolveType($show_res->type), 'user_id' => $show_res->user->id, 'user_name' => $show_res->user->name, 'own_ressource' => $show_res->user->id == $this->user->id, 'available' => $show_res->isAvailable(), 'is_waiting' => $is_waiting->find(), 'prove_public' => $prove_public, 'detail' => $detail, 'user_email' => $email, 'user_street' => $street, 'user_house' => $house, 'user_country' => $country, 'user_plz' => $plz, 'user_city' => $city, 'user_phone' => $phone, 'user_user_desc' => $user_desc, 'user_email_public' => $show_res->user->email_public, 'user_phone_public' => $show_res->user->phone_public, 'user_plz_city_public' => $show_res->user->plz_city_public);
                 if ($detail) {
                     $act_row = array_merge($act_row, array('attributes' => $res_attr_array));
                     $this->resdata = $act_row;
                 }
                 $tabledata[] = $act_row;
             }
             ++$count;
         }
     }
     --$count;
     $count2 = 1;
     while ($count2 < $count / 20) {
         $this->res_count[] = $count2;
         ++$count2;
     }
     $this->res_count[] = $count2;
     $this->get_add_cat = $get_add;
     $get_add .= "&cat=" . $params->getParam('cat');
     // categories to refine search
     $showcats = $categories->getChildren($params->getParam('cat'));
     if (is_array($showcats)) {
         foreach ($showcats as $cat_id => $cat_name) {
             $show_res = new resFetcher();
             $show_res->_cat = $cat_id;
             $show_res->_search_string = $params->getParam('searchstring');
             if (!$is_one_pool) {
                 $show_res->_pools = explode("a", $params->getParam('searchwhere'));
             } else {
                 $show_res->_pools = array($pool->id);
             }
             $rescounter = $show_res->count();
             if ($rescounter > 0) {
                 $this->cats[] = array("id" => $cat_id, "name" => $cat_name, "count" => $rescounter);
             }
         }
         // order categories after rescount
         $c = 0;
         foreach ($this->cats as $cat) {
             if ($c == 0) {
                 $ocats = array($cat);
             } else {
                 $c2 = 0;
                 while ($c2 <= $c) {
                     if ($cat["count"] <= $ocats[$c2]["count"]) {
                         $before = array_slice($ocats, 0, $c2);
                         $after = array_slice($ocats, $c2);
                         if (is_array($before[0])) {
                             $ocats = array_merge($before, array($cat));
                             if (is_array($after[0])) {
                                 $ocats = array_merge($ocats, $after);
                             }
                         } else {
                             $ocats = array_merge(array($cat), $after);
                         }
                         $c2 = $c + 1;
                     } else {
                         if ($cat["count"] > $ocats[$c2]["count"] && ($cat["count"] <= $ocats[$c2 + 1]["count"] || !$ocats[$c2 + 1]["count"])) {
                             $before = array_slice($ocats, 0, $c2 + 1);
                             $after = array_slice($ocats, $c2 + 1);
                             if (is_array($after[0])) {
                                 $ocats = array_merge(array($cat), $after);
                                 if (is_array($before[0])) {
                                     $ocats = array_merge($before, $ocats);
                                 }
                             } else {
                                 $ocats = array_merge($before, array($cat));
                             }
                             $c2 = $c + 1;
                         }
                     }
                     ++$c2;
                 }
             }
             ++$c;
         }
         if (is_array($ocats)) {
             $this->cats = array_reverse($ocats);
         }
         // add subcategories to the most counting category
         $lowercats = $categories->getChildren($this->cats[0]["id"]);
         if (is_array($lowercats)) {
             foreach ($lowercats as $cat_id => $cat_name) {
                 $show_res = new resFetcher();
                 $show_res->_cat = $cat_id;
                 $show_res->_search_string = $params->getParam('searchstring');
                 if (!$is_one_pool) {
                     $show_res->_pools = explode("a", $params->getParam('searchwhere'));
                 } else {
                     $show_res->_pools = array($pool->id);
                 }
                 $rescounter = $show_res->count();
                 if ($rescounter > 0) {
                     $this->lowercats[] = array("id" => $cat_id, "name" => $cat_name, "count" => $rescounter);
                 }
             }
         }
     }
     $this->get_add = $get_add;
     // table itself
     $table = new tableResBrowser($tabledata, $get_add);
     // page-header
     $this->header = $lang->getMsg('resbrowser_header_search');
     // hierarchie-links
     $parent = $categories->getParent($params->getParam('cat'));
     if ($parent) {
         $hierarchie = array();
         $hierarchie[] = array('id' => $parent, 'name' => $categories->getName($parent));
         $parent = $categories->getParent($parent);
         if ($parent) {
             $hierarchie[] = array('id' => $parent, 'name' => $categories->getName($parent));
         }
         $this->hierarchie = array_reverse($hierarchie);
     } else {
         if ($params->getParam('cat') != 0) {
             $this->hierarchie = array(array('id' => 0, 'name' => $lang->getMsg('cat_all')));
         }
     }
     if ($this->resdata) {
         $this->hierarchie[] = array('id' => $params->getParam('cat'), 'name' => $categories->getName($params->getParam('cat')));
     }
     $this->table = $table;
     $this->pool = $pool;
 }
         echo '<p class="headline2" id="anzeigen">NutziGems l&ouml;schen</p>';
         echo '<p class="standard">';
         while ($pools->fetch()) {
             if ($pools->name != "Pool") {
                 echo '<a href="./admin.php?action=delete_pool&pool_id=' . $pools->id . '&server_password='******'">' . $pools->name . '</a> ';
             }
         }
         echo '</p>';
     }
     echo '<p class="headline2" id="anzeigen">Admins kicken</p>';
     // Admins to kick
     // all pools are shown
     // Instanciate pools-class
     $pools = new pools();
     $pools->wait = 0;
     if ($pools->find()) {
         echo '<p class="standard">';
         while ($pools->fetch()) {
             $admins = array();
             $admins = $pools->getAdmins();
             echo '<b>' . $pools->name . '</b>: ';
             foreach ($admins as $admin) {
                 echo '<a href="./admin.php?action=kick_admin&pool_id=' . $pools->id . '&user_id=' . $admin->id . '&server_password='******'">' . $admin->name . '</a> ';
             }
             echo '<br>';
         }
         echo '</p>';
     }
     echo '<p class="standard"><a href="./index.php">Ausloggen und zurück zur Homepage</a></p>';
 } else {
     // redirect
 private function process()
 {
     $this->commonProcess();
     $config = services::getService('config');
     $lang = services::getService('lang');
     $params = services::getService('pageParams');
     // for redirection
     if ($params->getParam('refer') == 'mysite') {
         $this->refer = 'mysite';
     } else {
         $this->refer = 'showpool';
     }
     // res_free_page
     $userres = new resFetcher();
     $userres->_order = "name";
     $userres->_user = $this->user->id;
     $userres->search();
     $this->userres = $userres->getAsArray();
     $user_new_pool = new pools();
     $user_new_pool->id = $params->getParam('pool_id');
     if ($user_new_pool->find(true)) {
         $this->user_new_pool = $user_new_pool;
         $user_new_pools = new poolsUser();
         $user_new_pools->pool_id = $user_new_pool->id;
         $user_new_pools->user_id = $this->user->id;
         $user_new_pools->find(true);
         if ($user_new_pools->res_to_free == 1) {
             $this->new_pool = true;
         }
         if ($params->getParam('no_free_submit')) {
             $user_new_pools->res_to_free = 0;
             $user_new_pools->update();
             // delete res
             foreach ($this->userres as $res) {
                 $del_res = new poolsResources();
                 $del_res->pool_id = $params->getParam('pool_id');
                 $del_res->res_id = $res->id;
                 $del_res->find();
                 $del_res->delete();
                 $freed = true;
             }
             $this->switchPage($this->refer . '&pool_id=' . $user_new_pools->pool_id . '&msg=msg_freeres_alldeleted');
         } else {
             if ($params->getParam('res_free_submit')) {
                 // delete res
                 foreach ($this->userres as $res) {
                     $del_res = new poolsResources();
                     $del_res->pool_id = $params->getParam('pool_id');
                     $del_res->res_id = $res->id;
                     $del_res->find();
                     $del_res->delete();
                     $freed = true;
                 }
                 foreach ($_POST as $res_id => $doesnmatter) {
                     $free_res = new poolsResources();
                     $free_res->res_id = $res_id;
                     $free_res->pool_id = $params->getParam('pool_id');
                     // insert res
                     if ($doesnmatter == "check") {
                         if (!$free_res->find()) {
                             $free_res->insert();
                             $freed = true;
                         }
                     }
                 }
                 // set $msg
                 if ($freed) {
                     $this->switchPage($this->refer . '&pool_id=' . $user_new_pools->pool_id . '&msg=msg_free_res_success');
                 }
                 $user_new_pools->res_to_free = 0;
                 $user_new_pools->update();
             } else {
                 if (is_array($this->userres)) {
                     $this->free_res = true;
                 } else {
                     $user_new_pools->res_to_free = 0;
                     $user_new_pools->update();
                     // switch page with msg
                     $this->switchPage('showpool&pool_id=' . $user_new_pools->pool_id . '&msg=msg_freeres_nores');
                 }
             }
         }
     }
 }
 private function process()
 {
     $this->commonProcess();
     $config = services::getService('config');
     $lang = services::getService('lang');
     $params = services::getService('pageParams');
     // release resources
     if ($this->user->hasResources()) {
         // release no resources-function
         if ($params->getParam('function') == "freenone") {
             $relnone = new poolsUser();
             $relnone->pool_id = $params->getParam('freenone_pool_id');
             $relnone->user_id = $this->user->id;
             $relnone->find(true);
             $relnone->res_to_free = 0;
             $relnone->update();
         }
         $newpools = new poolsUser();
         $newpools->res_to_free = 1;
         $newpools->user_id = $this->user->id;
         if ($params->getParam('new_pool')) {
             $newpool = new pools();
             $newpool->id = $params->getParam('new_pool');
             $newpool->find(true);
             $this->new_pool = clone $newpool;
         } else {
             if ($newpools->find(true)) {
                 $newpools->fetchPool();
                 $this->new_pool = clone $newpools->pool;
             }
         }
     }
     $this->user->fetchPreferences();
     // registered msg
     if ($params->getParam('function') == "noregistered") {
         $this->user->preferences->delete();
         $this->user->preferences->registered_message = "2";
         $this->user->preferences->insert();
     }
     if ($this->user->preferences->registered_message === "1") {
         $this->registered_msg = true;
     }
     // welcome msg
     if ($params->getParam('function') == "nowelcome") {
         $this->user->preferences->delete();
         $this->user->preferences->welcome_message = "2";
         $this->user->preferences->insert();
     }
     if ($this->user->preferences->welcome_message === "2") {
         $this->welcome_msg = false;
     }
     // the table with users pools is generated
     // fetch "Pool"
     $pools_pool = new pools();
     $pools_pool->id = 1;
     $pools_pool->find(true);
     if ($pools_pool->isAdmin($this->user->id)) {
         $this->mypoolstable_thirdcol = true;
         $this->mypoolstable[] = array("id" => $pools_pool->id, "name" => $pools_pool->name, "area" => $pools_pool->area, "links" => '<a href="./index.php?page=pooldata&pool_id=' . $pools->id . '">' . $lang->getMsg('mysite_poolsadmintable_changedatalink') . '</a> | <a href="./index.php?page=pooladmin&pool_id=' . $pools->id . '">' . $lang->getMsg('mysite_poolsadmintable_adminlink') . '</a>');
     } else {
         $this->mypoolstable[] = array("id" => $pools_pool->id, "name" => $pools_pool->name, "area" => $pools_pool->area);
     }
     // fetch all other pools
     $pools = new poolsFetcher();
     $pools->_user = $this->user->id;
     $pools->_order = "name";
     $pools->search();
     while ($pools->fetch()) {
         if ($pools->id != 1) {
             if ($pools->isAdmin($this->user->id)) {
                 $this->mypoolstable_thirdcol = true;
                 $this->mypoolstable[] = array("id" => $pools->id, "name" => $pools->name, "area" => $pools->area, "links" => '<a href="./index.php?page=pooldata&pool_id=' . $pools->id . '">' . $lang->getMsg('mysite_poolsadmintable_changedatalink') . '</a> | <a href="./index.php?page=pooladmin&pool_id=' . $pools->id . '">' . $lang->getMsg('mysite_poolsadmintable_adminlink') . '</a>');
             } else {
                 $this->mypoolstable[] = array("id" => $pools->id, "name" => $pools->name, "area" => $pools->area);
             }
         }
     }
     // fetch all borrowed resources
     $borrowed = new resBorrowed();
     $borrowed->user_id = $this->user->id;
     if ($borrowed->find()) {
         $this->borrowed = array();
         while ($borrowed->fetch()) {
             $borrowed->fetchRes();
             $borrowed->res->fetchUser();
             $this->borrowed[] = clone $borrowed->res;
         }
     }
 }
 private function process()
 {
     $config = services::getService('config');
     $lang = services::getService('lang');
     $params = services::getService('pageParams');
     $mail = services::getService('mail');
     // lost password
     if ($params->getParam('lostpassword') == 'true') {
         $this->lostpassword = true;
         $this->pwform = new formLostPassword('LostPassword');
         if ($this->pwform->validate()) {
             // write email
             $user = new user();
             $user->email = $this->pwform->exportValue('email');
             if ($user->find(true)) {
                 $mail->send('lostpassword', $user, $user->password);
                 $user->password = crypt($user->password, 'dl');
                 $user->update();
                 $this->switchPage('home&msg=msg_pw_sent');
             } else {
                 $this->switchPage('home&lostpassword=true&msg=msg_no_email');
             }
         }
     } else {
         // newsscript: write news
         if ($params->getParam('news') == 'writenews') {
             $newsform = new formNewsData("newsdata");
             if ($newsform->validate()) {
                 $new_news = new news();
                 $new_news->name = convertNewsSubmits($newsform->exportValue('newsname'));
                 $new_news->abstract = convertNewsSubmits($newsform->exportValue('newsabstract'));
                 $new_news->text = convertNewsSubmits($newsform->exportValue('newstext'));
                 $new_news->date = time();
                 $new_news->lang = $newsform->exportValue('newslang');
                 $new_news->insert();
                 $newsform->freezeForm();
                 $this->addMsg('msg_news_submitted');
             }
             $this->newsform = $newsform;
         }
     }
     // newsscript: show news headlines
     $shownews = new news();
     $shownews->lang = $lang->getLang();
     $shownews->orderBy('date DESC');
     $shownews->find();
     while ($shownews->fetch()) {
         $this->shownews[] = array('name' => $shownews->name, 'abstract' => $shownews->abstract, 'text' => $shownews->text, 'date' => date('d. m. Y', $shownews->date), 'id' => $shownews->id);
     }
     // Instantiate the HTML_QuickForm object
     $this->login_form = new formLogin('LoginForm');
     // count resources and pools
     $pool_count = new pools();
     $res_count = new resources();
     $pool_count->wait = 0;
     $pool_count->find();
     $res_count->find();
     $this->pool_count = 0;
     while ($pool_count->fetch()) {
         ++$this->pool_count;
     }
     $this->res_count = 0;
     while ($res_count->fetch()) {
         ++$this->res_count;
     }
     // Try to validate a form
     if ($this->login_form->validate()) {
         if (loginCorrect($this->login_form->exportValue('login'), $this->login_form->exportValue('loginpassword'))) {
             $session = services::getService('pageParams');
             if ($this->login_form->exportValue('remember')) {
                 setcookie('login', $this->login_form->exportValue('login'), time() + 60 * 60 * 24 * 365);
                 setcookie('password', $this->login_form->exportValue('loginpassword'), time() + 60 * 60 * 24 * 365);
             } else {
                 $session->addParam('login', $this->login_form->exportValue('login'), 'session');
                 $session->addParam('password', $this->login_form->exportValue('loginpassword'), 'session');
             }
             $session->addParam('msg', 'msg_login_correct', 'page');
             $this->switchPage('mysite');
         } else {
             $this->addMsg('msg_login_wrong');
         }
     } else {
         if (isset($this->user)) {
             $this->switchPage('mysite');
         }
     }
 }