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')); } } } }
function removeMember($user_id) { $member_to_remove = new poolsUser(); $admin_to_remove = new poolsAdmin(); $member_to_remove->pool_id = $this->id; $admin_to_remove->pool_id = $this->id; $member_to_remove->user_id = $user_id; $admin_to_remove->user_id = $user_id; $member_to_remove->delete(); $admin_to_remove->delete(); $userres = new resFetcher(); $userres->_pools = array($this->id => $this->id); $userres->_user = $user_id; $userres->search(); while ($userres->res->fetch()) { $res_pool = new poolsResources(); $res_pool->pool_id = $this->id; $res_pool->res_id = $userres->res->id; $res_pool->delete(); } }
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(' '), array("color" => "white")); $table->addRow(array('<b>' . $lang->getMsg('showpool_nocountry_header') . '</b>'), array("class" => "poolsblank")); } else { $table->addRow(array(' '), 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(' '), 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) . ' '; } $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; }
private function process() { $this->commonProcess(); $config = services::getService('config'); $lang = services::getService('lang'); $params = services::getService('pageParams'); $mail = services::getService('mail'); $categories = services::getService('cats'); $pool = new pools(); if ($pool->get($params->getParam('pool_id'))) { // become member if ($params->getParam('action') == 'become_member') { if ($params->getParam('become_member_submit') || $pool->is_public) { $new_membership = new poolsUser(); $new_membership->user_id = $this->user->id; $new_membership->pool_id = $pool->id; if (!$pool->is_public) { $new_membership->wait = 1; } else { $new_membership->res_to_free = 1; $new_membership->wait = 0; } if ($params->getParam('become_member_comments')) { $new_membership->comments = $params->getParam('become_member_comments'); } $new_membership->insert(); // compose E-Mails if (!$pool->is_public) { $tos = $pool->getAdmins(); foreach ($tos as $to) { $mail->send('new_member', $to, $pool, $this->user, $new_membership->comments); } } else { $this->switchPage('mysite&new_pool=' . $pool->id); } } else { $this->become_member_form = true; } } // are you waiting? if ($pool->isWaiting($this->user->id)) { $this->user_is_waiting = true; } // loose membership if ($params->getParam('action') == 'no_member') { // the last admin can't leave the pool if (!$pool->isLastAdmin($this->user->id)) { $pool->removeMember($this->user->id); $this->addMsg('msg_leave_pool'); } else { $this->addMsg('msg_leave_pool_last_admin'); } } // build tabledata if ($pool->isMember($this->user->id)) { $showcats = $categories->getChildren(0); foreach ($showcats as $cat_id => $cat_name) { $show_res = new resFetcher(); $show_res->_cat = $cat_id; $show_res->_pools = array($pool->id); $rescounter = $show_res->count(); if ($rescounter > 0) { $this->cats[$cat_id] = array("name" => $cat_name, "count" => $rescounter); } } $allcount = 0; foreach ($this->cats as $cat) { $allcount += $cat['count']; } $this->cats[0] = array("name" => $lang->getMsg('cat_all'), "count" => $allcount); } else { if (!$pool->isMember($this->user->id, true)) { $this->not_member = true; } $res_counter = new poolsResources(); $res_counter->pool_id = $pool->id; $this->res_counter = 0; $res_counter->find(); while ($res_counter->fetch()) { ++$this->res_counter; } } // build forum-tabledata if ($pool->isMember($this->user->id)) { // new/change entry if ($params->getParam('action') == 'new_entry') { // formular $form = new form('forum_entry'); $form->addElement('text', 'entryheader', $lang->getMsg('showpool_forum_headline'), array('size' => 30, 'maxlength' => 100)); $form->addElement('textarea', 'entrytext', $lang->getMsg('home_news_text'), array('rows' => 15, 'cols' => 70)); $form->addElement('hidden', 'action', 'new_entry'); $form->addElement('hidden', 'pool_id', $pool->id); $form->addElement('hidden', 'thread', $thread->id); $form->addElement('submit', 'entrysubmit', $lang->getMsg('home_news_submit')); $form->addRule('entryheader', $lang->getMsg('showpool_forum_headline_required'), 'required'); $form->addRule('entrytext', $lang->getMsg('showpool_forum_text_required'), 'required'); // write entry if ($form->validate()) { $new_thread = new forumThreads(); $new_thread->pool_id = $pool->id; $new_thread->title = $form->exportValue('entryheader'); $new_thread->act_date = time(); $new_thread->insert(); $new_thread->find(true); $new_entry = new forumEntries(); $new_entry->thread_id = $new_thread->id; $new_entry->text = $form->exportValue('entrytext'); $new_entry->user_id = $this->user->id; $new_entry->date = $new_thread->act_date; $new_entry->insert(); $this->switchPage('showpool&pool_id=' . $pool->id . '&msg=msg_forum_entry_made'); } $this->form = $form; } $showthreads = new forumThreads(); $showthreads->pool_id = $pool->id; $showthreads->find(); while ($showthreads->fetch()) { $showthreads->fetchLastEntry(); $showthreads->last_entry->fetchUser(); $this->threads[] = array("id" => $showthreads->id, "title" => $showthreads->title, "act_date" => date('j. n. y, H:i', $showthreads->last_entry->date) . ' ' . $lang->getMsg('showpool_forum_lastentry_by') . ' ' . '<a href="./index.php?page=showmember&pool_id=' . $pool->id . '&showmember=' . $showthreads->last_entry->user->id . '">' . $showthreads->last_entry->user->name . '</a>'); } } // build userlist if ($pool->id != 1) { // assotiativ array with object and detail-flag if ($pool->isMember($this->user->id)) { $members = array(); $pool_users = new poolsUser(); $pool_users->pool_id = $pool->id; $pool_users->wait = 0; if ($pool_users->find()) { $detail_id = $params->getParam('showmember'); $count = 1; while ($pool_users->fetch()) { if ($pool_users->user_id != $this->user->id) { $pool_users->fetchUser(); $member = array("obj" => $pool_users->user, "detail" => $pool_users->user->id == $detail_id, "count" => $count, "admin" => $pool->isAdmin($pool_users->user->id)); if ($pool_users->user->name != "") { $members[] = $member; } ++$count; } } $this->members = $members; } } } $this->pool = $pool; } else { $this->switchPage('mysite'); } }
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'; } }
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'); } } } } }