public function editForm($id)
 {
     $group = Group::getGroupById($id);
     $template = new Template('admin/security/ui.groupForm.tpl');
     $template->group = $group;
     $template->action = "/groupage/update/" . $group->id;
     return $template->parse();
 }
 public function isAdmin()
 {
     if ($this->id == User::ADMIN) {
         return true;
     }
     $group = Group::getGroupById(Group::ADMINS);
     return $group->hasMember($this);
 }
 static function getMeetingById($id)
 {
     $pdo = db::getPDO();
     $st = $pdo->prepare("SELECT * FROM meetings WHERE\n            MeetingId = :meetingId");
     $st->execute(array(':meetingId' => $id));
     $result = $st->fetch();
     $group = Group::getGroupById($result['UserGroup']);
     $meeting = new Meeting($result['MeetingId'], $result['Room'], $group, $result['Day'], $result['Hour']);
     return $meeting;
 }
Example #4
0
 static function getAllMeetingsOfUser($mtrklnr)
 {
     $pdo = db::getPDO();
     $st = $pdo->prepare("SELECT m.* FROM meetings AS m\n            WHERE UserGroup in\n              (SELECT g.Id FROM user_in_group AS uig\n              LEFT JOIN groups AS g ON uig.groupId = g.Id\n              LEFT JOIN users AS u ON uig.userId = u.MtklNr\n              WHERE g.Id IN (SELECT groupId FROM user_in_group AS uig WHERE uig.userId = :mtklNr))");
     $st->execute(array(':mtklNr' => $mtrklnr));
     $result = $st->fetchAll();
     $meetings = array();
     for ($i = 0; $i < count($result); $i++) {
         $group = Group::getGroupById($result[$i]['UserGroup']);
         $meetings[] = new Meeting($result[$i]['MeetingId'], $result[$i]['Room'], $group, $result[$i]['Day'], $result[$i]['Hour']);
     }
     return $meetings;
 }
 public function checkAccess(User $user)
 {
     if ($user->isAdmin()) {
         return Acl::ADMINISTRATOR;
     }
     $perms = $this->permissions;
     if (array_key_exists($user->id, $perms['users'])) {
         return $perms['users'][$user->id];
     }
     $groups = $perms['groups'];
     $prms = array(0);
     foreach ($groups as $group => $role) {
         $oGroup = Group::getGroupById($group);
         if ($oGroup->hasMember($user)) {
             $prms[] = $role;
         }
     }
     return max($prms);
 }
<?php

include "../assets/_header_in.php";
include "../assets/_header_tasks.php";
require_once "../classes/group.php";
$id_group = htmlspecialchars($_GET["id_group"]);
$name_group = Group::getGroupById($id_group);
$name_group = $name_group['g_name'];
?>
<h2>Creating a task</h2>
        <form action="save_task.php" method="post">
        	<p>
                <label>
                	<?php 
echo "<a href='../groups/index.php?id_group=" . $id_group . "'>" . $name_group . "</a>";
?>
                	<br></label>
                <input readonly size=5 name="group" type="text" value=<?php 
echo $id_group;
?>
>
            </p>
            <p>
                <label>Name:<br></label>
                <input name="name" type="text" size="50" maxlength="50">
            </p>
            <p>
                <label>Description:<br></label>
                <textarea name="desc" maxlength="500" type="text"></textarea>
            </p>
             <p>
Example #7
0
<?php

include "../assets/_header_in.php";
include "../assets/_header_groups.php";
$id_group = htmlspecialchars($_GET["id_group"]);
require_once "../classes/group.php";
$mygroup = Group::getGroupById($id_group);
$users_of_group = Group::getUsersByIdGroup($id_group);
echo "Name: " . $mygroup["g_name"];
echo "<br>";
echo "Creator: " . $mygroup["u_name"];
echo "<br>";
echo "Count of users: " . count($users_of_group);
echo "<br>";
echo "<table>";
for ($i = 0; $i < count($users_of_group); $i++) {
    echo "<tr><td>" . $i . "</td><td>" . $users_of_group[$i]["name"] . "</td></tr>";
}
echo "</table>";
echo "Count of all tasks: " . Group::getCountTaskByIdGroup($id_group);
echo "<br>";
echo "<a href='end_task.php?id_group=" . $id_group . "'>Finished tasks: </a>" . Group::getCountEndTaskByIdGroup($id_group);
echo "<br>";
echo "<a href='start_task.php?id_group=" . $id_group . "'>Started tasks: </a>" . Group::getCountStartTaskByIdGroup($id_group);
if (Group::checkCreator($id_group, $_SESSION['login_user'])) {
    echo "<br>";
    echo "<a href='../tasks/create_task_for_group.php?id_group=" . $id_group . "'>Create a task</a>";
} else {
    if (!Group::checkGroupForUser($id_group, $_SESSION['login_user'])) {
        echo "<br>";
        echo "<a href='add_user_to_group.php?id_group=" . $id_group . "'>Sign up in this group</a>";
 private function getTemplate(Module $module)
 {
     $template = new Template('admin/security/ui.moduleForm.tpl');
     $permsTpl = new Template('admin/security/ui.permissions.tpl');
     $perms = $module->permissions;
     $users = '';
     $groups = '';
     foreach ($perms['users'] as $userID => $role) {
         $user = User::getUserById($userID);
         $permsTpl->id = $user->id;
         $permsTpl->type = 'users';
         $permsTpl->name = sprintf("%s %s", $user->name, $user->surname);
         $permsTpl->options = $this->getOptions($role);
         $users .= $permsTpl->parse();
     }
     foreach ($perms['groups'] as $groupID => $role) {
         $group = Group::getGroupById($groupID);
         $permsTpl->type = 'groups';
         $permsTpl->id = $group->id;
         $permsTpl->name = $group->name;
         $permsTpl->options = $this->getOptions($role);
         $groups .= $permsTpl->parse();
     }
     $template->users = $users;
     $template->groups = $groups;
     $template->module = $module;
     return $template;
 }
        $groupOwner = $group->owner;
        if ($group->owner == $user) {
            $groupOwner = $postArray['owner'];
            $tmpMembers = $postArray['users'];
            foreach ($tmpMembers as $tmpmember) {
                $member = get_object_vars($tmpmember);
                $members[] = new User($member['mtklNr'], '', '', '');
            }
            $groupUsers = $members;
        }
        $group = new Group($args['id'], $postArray['name'], $groupOwner, $groupUsers, $postArray['groupImage']);
        $group->update();
        echo json_encode($group);
    } else {
        echo json_encode(false);
    }
});
$app->delete('/groups/{id}', function ($request, $response, $args) {
    $group = Group::getGroupById($args['id']);
    $server_params = $request->getServerParams();
    if (preg_match("/Basic\\s+(.*)\$/i", $server_params["REDIRECT_HTTP_AUTHORIZATION"], $matches)) {
        list($user, $password) = explode(":", base64_decode($matches[1]));
    }
    if ($group->owner == $user) {
        $deleted = Group::deleteGroupById($args['id']);
        echo json_encode($deleted);
    } else {
        echo json_encode(false);
    }
});
$app->run();
    public function stored(Request $request)
    {
        session_start();
        $html = "";
        $vecesenelgrupo = 0;
        $creadormiembro = 0;
        if ($request->ajax()) {
            $group = Group::getGroupById($_SESSION['group']);
            $user = User::getUserById($request->usuario);
            $vecesenelgrupo = $group->users()->where('owner', 0)->where('user_id', $user->id)->where('group_id', $group->id)->count();
            $creadormiembro = $group->users()->where('owner', 1)->where('user_id', $user->id)->where('group_id', $group->id)->count();
            if ($vecesenelgrupo < 1 && $creadormiembro < 1) {
                $group->users()->save($user, ['owner' => 0]);
                $html .= '<div class="col-sm-6 col-md-4">
                      <div class="thumbnail">
                          <button style="margin-left: 88%" type="button" class="btn btn-link delMem" data-botonLeaveMember="{{$members->id}}" ><i class="fa fa-remove"></i></button>
                          <img src="' . asset("img/user.png") . '" class="img-circle img-responsive" alt="owner" width="140" height="140">
                          <div class="caption">
                              <h3 style="text-align: center;">Member</h3>
                              <h4 style="text-align: center;">' . $user->full_name . '</h4>

                          </div>
                      </div>
                  </div>';
            } else {
                if ($creadormiembro >= 1) {
                    echo "<script type='text/javascript'>alert('You can not add yourself, you are the owner.');</script>";
                } else {
                    echo "<script type='text/javascript'>alert('The user is already a member of the group..');</script>";
                }
            }
        }
        return $html;
    }