private function process() { $this->commonProcess(); $mail = services::getService('mail'); $config = services::getService('config'); $lang = services::getService('lang'); $params = services::getService('pageParams'); $categories = services::getService('cats'); // use-res logics // accept inquiry if ($params->getParam('action') == 'wait_res_accept') { $wait_res = new resWait(); $wait_res->get($params->getParam('wait_id')); $wait_res->fetchRes(); // no item if ($wait_res->res->type == 0) { // delete all interessants $wait_res->res->deleteWaiting($wait_res->user_id); $wait_res->fetchUser(); $wait_res->res->fetchUser(); $mail->send('nogood_accepted', $wait_res->user, $wait_res->res, $wait_res->res->user); $this->switchPage('resmanager&msg=msg_request_success'); } // give if ($wait_res->res->type == 1) { // res is given to the new owner $wait_res->res->changeOwner($wait_res->user_id); $wait_res->fetchUser(); // delete pool affiliations $wait_res->res->deletePools(); // delete all interessants $wait_res->res->deleteWaiting(); $wait_res->res->fetchUser(); $mail->send('give_accepted', $wait_res->user, $wait_res->res, $wait_res->res->user); $this->switchPage('resmanager&msg=msg_give_success'); } // borrow if ($wait_res->res->type == 2) { // res is borrowed $wait_res->res->isBorrowed($wait_res->user_id); $wait_res->fetchUser(); // delete all interessants $wait_res->res->deleteWaiting(); $wait_res->res->fetchUser(); $mail->send('borrow_accepted', $wait_res->user, $wait_res->res, $wait_res->res->user); $this->switchPage('resmanager&msg=msg_borrow_success'); } $this->toDoList(); } // refuse inquiry if ($params->getParam('action') == 'wait_res_refuse') { $wait_res = new resWait(); $wait_res->id = $params->getParam('wait_id'); $wait_res->find(true); $waiter = new user(); $waiter->get($wait_res->user_id); $wait_res->fetchRes(); $wait_res->res->fetchUser(); $mail->send('refused', $waiter, $wait_res->res, $wait_res->res->user); $wait_res->delete(); $this->toDoList(); $this->switchPage('resmanager&'); } // res is given back if ($params->getParam('action') == 'res_back') { $bow_res = new resBorrowed(); $bow_res->res_id = $params->getParam('res_id'); if ($bow_res->delete()) { $this->switchPage('resmanager&msg=msg_res_back'); } } // delete resources if ($params->getParam('resdata_del_submit')) { foreach ($_POST as $res_id => $doesnmatter) { $del_res = new resources(); // delete res $del_res->id = $res_id; if ($del_res->deleteAll()) { $deleted = true; } } // set $msg if ($deleted) { $this->switchPage('resmanager&msg=msg_delres_success'); } } $userres = new resFetcher(); $userres->_order = "name"; $userres->_user = $this->user->id; $userres->search(); $this->userres = $userres->getAsArray(); // function is set if ($this->res_offers) { $this->function = 'offers'; } else { if ($this->borrowed_res) { $this->function = 'borrowed'; } else { $this->function = 'all'; } } if ($params->getParam('function')) { $this->function = $params->getParam('function'); } if (!$this->res_offers && $this->function == 'offers') { $this->function = 'borrowed'; } if (!$this->borrowed_res && $this->function == 'borrowed') { $this->function = 'all'; } }
function deleteAll() { $aff1 = new resWait(); $aff2 = new resBorrowed(); $aff3 = new poolsResources(); $aff4 = new attributesString(); $aff5 = new attributesSelect(); $aff1->res_id = $this->id; $aff1->delete(); $aff2->res_id = $this->id; $aff2->delete(); $aff3->res_id = $this->id; $aff3->delete(); $aff4->res_id = $this->id; $aff4->delete(); $aff5->res_id = $this->id; $aff5->delete(); $this->deletePools(); return $this->delete(); }