function inMine($user_id)
 {
     $in_mine = new resources();
     $in_mine->query('SELECT DISTINCT name FROM pools_resources, pools_pools_resources, pools_pools_user WHERE 
                    (pools_resources.id = ' . $this->id . ') AND 
                    (pools_pools_user.user_id = ' . $user_id . ') AND
                    (pools_pools_resources.res_id = pools_resources.id) AND 
                    (pools_pools_user.pool_id = pools_pools_resources.pool_id)');
     while ($in_mine->fetch()) {
         return true;
     }
     return false;
 }
Пример #2
0
 function getBorrowedRes()
 {
     $bow_res = new resources();
     $bow_res->user_id = $this->id;
     $res = array();
     if ($bow_res->find()) {
         while ($bow_res->fetch()) {
             $bow_res->fetchBorrower();
             if ($bow_res->borrowed) {
                 $res[] = clone $bow_res;
             }
         }
         return $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');
         }
     }
 }