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); } } } }
private function process() { $this->commonProcess(); $config = services::getService('config'); $lang = services::getService('lang'); $params = services::getService('pageParams'); $pool = new pools(); $pool->get($params->getParam('pool_id')); $this->pool = $pool; if ($pool->isMember($this->user->id)) { $thread = new forumThreads(); $thread->id = $params->getParam('thread'); $thread->find(); $thread->fetch(); // new/change entry if ($params->getParam('action') == 'new_entry') { // formular $form = new form('forum_entry'); $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('entrytext', $lang->getMsg('showpool_forum_text_required'), 'required'); // write entry if ($form->validate()) { $new_entry = new forumEntries(); $new_entry->thread_id = $thread->id; $new_entry->text = $form->exportValue('entrytext'); $new_entry->user_id = $this->user->id; $new_entry->date = time(); $threads = clone $thread; $threads->act_date = $new_entry->date; $thread->delete(); $threads->insert(); $new_entry->insert(); $this->switchPage('threadbrowser&pool_id=' . $pool->id . '&thread=' . $threads->id . '&msg=msg_forum_entry_made'); } $this->form = $form; } // build forum-tabledata $this->thread = $thread; // fetch entries $entries = new forumEntries(); $entries->thread_id = $thread->id; $entries->find(); while ($entries->fetch()) { $entries->fetchUser(); $this->entries[$entries->id] = clone $entries; } } else { $this->switchPage('showpool&pool_id=' . $pool->id . '&msg=msg_nice_try'); } }
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(' '), 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(); $config = services::getService('config'); $lang = services::getService('lang'); $params = services::getService('pageParams'); $categories = services::getService('cats'); $mail = services::getService('mail'); $form = new formPoolData('FoundForm'); if ($params->getParam('pool_id')) { $pool = new pools(); $pool->get($params->getParam('pool_id')); if (!$pool->isAdmin($this->user->id)) { $this->switchPage('mysite'); } // defaults $form->setDefaults(array('poolname' => $pool->name, 'pooldesc' => $pool->description, 'poolarea' => $pool->area, 'poolcountry' => $pool->country, 'pooladress' => array('plz1' => substr($pool->plz, 0, 2), 'plz2' => substr($pool->plz, 2, 3), 'city' => $pool->city), 'is_public' => $pool->is_public)); $this->pool = $pool; $this->header = $pool->name . $lang->getMsg('pooldata_header_change'); } else { $this->header = $pool->name . $lang->getMsg('pooldata_header_found'); } // Try to validate a form if ($form->validate()) { if (!isset($pool)) { $pool = new pools(); } $pool->name = $form->exportValue('poolname'); $pool->description = $form->exportValue('pooldesc'); $pool->area = $form->exportValue('poolarea'); $pool->country = $form->exportValue('poolcountry'); $adress2 = $form->getElementValue('pooladress'); $pool->plz = $adress2['plz1'] . $adress2['plz2']; $pool->city = $adress2['city']; $pool->is_public = $form->exportValue('is_public'); //$pool->is_located = $form->exportValue('is_located'); if (isset($pool->id)) { $pool->update(); $this->addMsg('msg_data_change_success'); $form->freezeForm(); $this->change_success_link = true; } else { $pool->wait = 1; $pool->insert(); $new_user = new poolsUser(); $new_user->user_id = $this->user->id; $new_user->pool_id = $pool->id; $new_user->wait = 0; $new_user->insert(); $new_admin = new poolsAdmin(); $new_admin->user_id = $this->user->id; $new_admin->pool_id = $pool->id; $new_admin->insert(); $params->addParam('msg', 'msg_found_success', 'page'); $mail->send('found_pool_admin', $config->getSetting('email'), $pool); $mail->send('found_pool_founder', $this->user, $pool); $this->switchPage('mysite'); } } $this->form = $form; }
$pools->wait = 0; if ($pools->find()) { echo '<p class="headline2" id="anzeigen">NutziGems lö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>';
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'); $pool = new pools(); $pool->get($params->getParam("pool_id")); if ($pool->isAdmin($this->user->id)) { $this->header = $pool->name . $lang->getMsg('pooladmin_header'); // build userlist // 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); $members[] = $member; ++$count; } } $this->members = $members; } } // build adminlist // assotiativ array with object and detail-flag if ($pool->isAdmin($this->user->id)) { $admins = array(); $pool_admins = new poolsAdmin(); $pool_admins->pool_id = $pool->id; $pool_admins->wait = 0; if ($pool_admins->find()) { $detail_id = $params->getParam('showadmin'); $count1 = 1; while ($pool_admins->fetch()) { if ($pool_admins->user_id != $this->user->id) { $pool_admins->fetchUser(); $admin = array("obj" => $pool_admins->user, "detail" => $pool_admins->user->id == $detail_id, "count" => $count1); $admins[] = $admin; ++$count1; } } $this->admins = $admins; } } // form processing // Waiting User $wait_users = new poolsUser(); $wait_users->pool_id = $pool->id; $wait_users->wait = "1"; if ($wait_users->find()) { $waiting_user = array(); while ($wait_users->fetch()) { $waiting_user[] = $wait_users->user_id; } } // refuse_user-form if ($params->getParam('user_refuse_submit') != false) { foreach ($waiting_user as $user_id) { if ($params->getParam($user_id) == 1) { $refuse_user = new poolsUser(); // user is refused $refuse_user->user_id = $user_id; $refuse_user->pool_id = $pool->id; $refuse_user->find(); $refuse_user->delete(); $refused = TRUE; $refused_mail = new user(); $refused_mail->get($refuse_user->user_id); $mail->send("user_refused", $refused_mail, $pool); } } // set $msg if ($refused) { $this->addMsg('msg_refuse_user_success'); } } // accept_user-form if ($params->getParam('user_accept_submit') != false) { foreach ($waiting_user as $user_id) { if ($params->getParam($user_id) == 1) { $accept_user = new poolsUser(); // user is accepted $accept_user->user_id = $user_id; $accept_user->pool_id = $pool->id; $accept_user->find(true); $accept_user->wait = 0; $accept_user->res_to_free = 1; $accept_user->update(); $accepted = TRUE; $accepted_mail = new user(); $accepted_mail->get($user_id); $mail->send("user_accepted", $accepted_mail, $pool); } } // set $msg if ($accepted) { $this->addMsg('msg_accept_user_success'); } } // add Admin if ($params->getParam('action') == 'new_admin') { if ($params->getParam('really') == 'yes') { $pool->addAdmin($params->getParam('user')); $this->addMsg('msg_add_admin'); $new_admin = new user(); $new_admin->get($params->getParam('user')); $mail->send('new_admin', $new_admin, $pool); } else { $add_admin = new user(); $add_admin->get($params->getParam('user')); $this->really_add_admin = $add_admin; } } // kick_member if ($params->getParam('action') == 'kick_user') { if ($params->getParam('really') == 'yes') { $pool->removeMember($params->getParam('user')); $this->addMsg('msg_kick_member'); $kicker = new user(); $kicker->get($params->getParam('user')); $mail->send('kick_member', $kicker, $pool); } else { $kick_member = new user(); $kick_member->get($params->getParam('user')); $this->really_kick_member = $kick_member; } } $pool_new_admins = new poolsUser(); $pool_new_admins->pool_id = $pool->id; $pool_new_admins->wait = 0; $pool_new_admins->find(); $new_admins = array(); while ($pool_new_admins->fetch()) { if (!$pool->isAdmin($pool_new_admins->user_id)) { $pool_new_admin = new user(); $pool_new_admin->get($pool_new_admins->user_id); $new_admins[] = clone $pool_new_admin; } } $this->new_admins = $new_admins; $pool_kick_nutzis = new poolsUser(); $pool_kick_nutzis->pool_id = $pool->id; $pool_kick_nutzis->wait = 0; $pool_kick_nutzis->find(); $kick_user = array(); while ($pool_kick_nutzis->fetch()) { if (!$pool->isAdmin($pool_kick_nutzis->user_id)) { $pool_kick_nutzi = new user(); $pool_kick_nutzi->get($pool_kick_nutzis->user_id); $kick_user[] = clone $pool_kick_nutzi; } } $this->kick_user = $kick_user; // Waiting User $wait_users = new poolsUser(); $wait_users->pool_id = $pool->id; $wait_users->wait = "1"; if ($wait_users->find()) { $waiting_user = array(); while ($wait_users->fetch()) { $wait_user = new user(); $wait_user->get($wait_users->user_id); $waiting_user[] = array("obj" => clone $wait_user, "comments" => $wait_users->comments); } $this->waiting_user = $waiting_user; } // delete pool if ($pool->isLastAdmin($this->user->id)) { $this->lastadmin = true; } if ($params->getParam('action') == 'delpool') { $this->reallydelpool = true; if ($params->getParam('really') == 'yes') { $pool->deleteAll(); $this->switchPage('mysite&msg=msg_delpool_success'); } } $this->pool = $pool; } }
function addMembership($pool_id) { $mail = services::getService('mail'); // add to relations-table $new_membership = new poolsUser(); $new_membership->user_id = $this->id; $new_membership->pool_id = $pool_id; if ($pool_id != 1) { $new_membership->wait = 1; } else { $new_membership->wait = 0; } $new_membership->insert(); // compose E-Mails, if it wasn't the pool to be added $new_apply_pool = new pools(); $new_apply_pool->get($pool_id); $tos = $new_apply_pool->getAdmins(); foreach ($tos as $to) { $mail->send('new_member', $to, $new_apply_pool); } }
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'); } } }