if ($pool_admin_del->find() > 1) { $pool_admin_del->user_id = $_GET['user_id']; $pool_admin_del->delete(); $deleted = true; } else { $pool_user_new = new poolsUser(); $pool_user_new->pool_id = $_GET['pool_id']; if ($pool_user_new->find() > 1) { include './inc/adminHeader.php'; echo '<p class="headline">Neuen Admin ernennen</p>'; echo '<p class="standard">Die NutziGem deren Admin gelöscht werden soll, hat nur einen, Du musst einen neuen ernennen.</p>'; echo '<p class="standard"> <form action="./admin.php?action=kick_admin&pool_id=' . $_GET['pool_id'] . '&user_id=' . $_GET['user_id'] . '&server_password='******'" method="POST"> <select name="add_admin_select">'; while ($pool_user_new->fetch()) { $pool_user_new->fetchUser(); if (!$pool_user_new->user->isAdmin($pool_user_new->pool_id)) { echo '<option value="' . $pool_user_new->user->id . '">' . $pool_user_new->user->name . '</option>'; } } echo ' </select> <input type="submit" name="add_admin_submit" value="ernennen"> </form> </p>'; exit; } else { $msg = 'kickadmin_notenourghusers'; } } // set $msg if ($deleted) {
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'); $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; } }