public function toDoList()
 {
     // ToDo-list
     if (isset($this->user)) {
         $newmsgs = 0;
         $msgs = new pm();
         $msgs->recipient_id = $this->user->id;
         $msgs->recipient_delete = 0;
         $msgs->is_read = 0;
         if ($msgs->find()) {
             while ($msgs->fetch()) {
                 ++$newmsgs;
             }
         }
         $wait_res_count = 0;
         $waiting_res = $this->user->getWaitingRes();
         if (is_array($waiting_res)) {
             foreach ($waiting_res as $res) {
                 ++$wait_res_count;
             }
         }
         $waiting_user = new poolsUser();
         $wait_user_count = array();
         $waiting_user->wait = 1;
         $wait_user = false;
         if ($waiting_user->find()) {
             while ($waiting_user->fetch()) {
                 $user_admin = new poolsAdmin();
                 $user_admin->pool_id = $waiting_user->pool_id;
                 $user_admin->user_id = $this->user->id;
                 if ($user_admin->find()) {
                     $wait_user = true;
                     ++$wait_user_count["{$waiting_user->pool_id}"]["count"];
                     $wait_user_count["{$waiting_user->pool_id}"]["pool"] = new pools();
                     $wait_user_count["{$waiting_user->pool_id}"]["pool"]->get($waiting_user->pool_id);
                 }
             }
         }
         if ($wait_user || $wait_res_count > 0 || $newmsgs > 0) {
             $todo = array();
             if ($wait_res_count > 0) {
                 $todo['res'] = $wait_res_count;
             }
             if ($newmsgs > 0) {
                 $todo['msgs'] = $newmsgs;
             }
             if ($wait_user) {
                 $todo['user'] = $wait_user_count;
             }
             $this->todo = $todo;
         } else {
             $this->todo = false;
         }
     }
 }
        </form>';
}
// form processing
if (isset($submit_server_password)) {
    if ($submit_server_password == $config->getSetting('password')) {
        // kick admin-form
        if ($_GET['action'] == 'kick_admin') {
            // add admin if given
            if (isset($_POST['add_admin_submit'])) {
                $pool = new pools();
                $pool->get($_GET['pool_id']);
                $pool->addAdmin($_POST['add_admin_select']);
            }
            $pool_admin_del = new poolsAdmin();
            $pool_admin_del->pool_id = $_GET['pool_id'];
            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();
Пример #3
0
 function isAdmin($pool_id = "")
 {
     $is_admin = new poolsAdmin();
     if ($pool_id != "") {
         $is_admin->pool_id = $pool_id;
     }
     $is_admin->user_id = $this->id;
     return $is_admin->find();
 }
 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 isLastAdmin($user_id)
 {
     $check_admin = new poolsAdmin();
     $check_admin->user_id = $user_id;
     $check_admin->pool_id = $this->id;
     $isadmin = $check_admin->find();
     if ($isadmin) {
         $check_one_admin = new poolsAdmin();
         $check_one_admin->pool_id = $this->id;
         $check_one_admin->find();
         while ($check_one_admin->fetch()) {
             if ($check_one_admin->user_id != $user_id) {
                 return false;
             }
         }
         return true;
     } else {
         return false;
     }
 }