function hasResources()
 {
     $resources = new resources();
     $resources->user_id = $this->id;
     if ($resources->find()) {
         return true;
     } else {
         return false;
     }
 }
 private function process()
 {
     $this->commonProcess();
     $config = services::getService('config');
     $lang = services::getService('lang');
     $params = services::getService('pageParams');
     $categories = services::getService('cats');
     if ($params->getParam('res_id')) {
         $this->header = $lang->getMsg('resdata_header_change');
         $this->is_change = true;
     } else {
         $this->header = $lang->getMsg('resdata_header_new');
         $this->is_change = false;
     }
     $aItems = $categories->getThisAndBelow(1);
     $sJavaScriptArray = sprintf('new Array(%s)', implode(',', array_keys($aItems)));
     $this->sJavaScriptArray = $sJavaScriptArray;
     if ($_POST['resdata_isbn_submit'] && is_isbn($_POST['resdata_isbn'])) {
         foreach ($_POST as $key => $value) {
             if ($key != 'page' && $key != 'name' && $key != 'description' && $key != 'resdata_authors') {
                 $get .= $key . '=' . $value . '&';
             }
         }
         $this->switchPage('resdata&' . $get);
     }
     // Instantiate the HTML_QuickForm object
     $this->form = new formResData('ResDataForm', $params->getParam($res_id), $this->user);
     $this->new_res_link = false;
     // Try to validate a form
     if ($this->form->validate() && $this->form->exportValue('submit')) {
         $newres = new resources();
         if ($params->getParam('res_id')) {
             $newres->get($params->getParam('res_id'));
         }
         $newres->name = $this->form->exportValue('name');
         $newres->description = $this->form->exportValue('description');
         $newres->cat = $this->form->exportValue('resdata_cat');
         $newres->type = in_array($newres->cat, array_keys($aItems)) ? $this->form->exportValue('type') : 0;
         // insert/update in res-maintable
         if ($params->getParam('res_id')) {
             $newres->update();
         } else {
             $newres->since = time();
             $newres->user_id = $this->user->id;
             $newres->insert();
         }
         $newres->find(true);
         // insert/update in attributes-tables
         $attr_string = new attributesString();
         $attr_string->res_id = $newres->id;
         $attr_string->delete();
         $attr_select = new attributesSelect();
         $attr_select->res_id = $newres->id;
         $attr_select->delete();
         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->res_id = $newres->id;
                         $attr_string->attribute_id = $attributes->id;
                         // insert
                         $value = $this->form->exportValue('resdata_' . $attributes->name);
                         if ($value != "") {
                             $attr_string->value = $value;
                             $attr_string->insert();
                         }
                     }
                     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();
                             }
                         }
                     }
                 }
             }
         }
         // add res to pools if given
         $respools = new poolsResources();
         $respools->res_id = $newres->id;
         $respools->delete();
         $res_pools = $this->form->exportValue('free_pools');
         if (is_array($res_pools)) {
             foreach ($res_pools as $pool_id => $bool) {
                 if ($bool) {
                     $newres->addPool($pool_id);
                 }
             }
         }
         if ($params->getParam('res_id')) {
             $params->addParam('msg', 'msg_data_change_success', 'page');
             $this->switchPage('resmanager&function=all');
         } else {
             $this->form->removeElement('resdata_isbn_submit');
             $this->form->freezeForm();
             $this->addMsg('msg_res_insert_success');
             $this->new_res_link = true;
         }
     }
     if ($_POST['resdata_isbn_submit']) {
         $this->form->addRule('name', $lang->getMsg('resdata_form_namenecessary'), 'required');
         $this->form->addRule('resdata_cat', $lang->getMsg('resdata_form_catnecessary'), 'required');
     }
 }
 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');
         }
     }
 }