/** * \brief Generate the text for this plugin. */ function Output() { global $PG_CONN; global $SysConf; if ($this->State != PLUGIN_STATE_READY) { return; } $user_pk = $SysConf['auth']['UserId']; /* Get array of groups that this user is an admin of */ $GroupArray = GetGroupArray($user_pk); $V = ""; /* If this is a POST, then process the request. */ $Group = GetParm('grouppk', PARM_TEXT); if (!empty($Group)) { $rc = DeleteGroup($Group); if (empty($rc)) { /* Need to refresh the screen */ $text = _("Group"); $text1 = _("Deleted"); $V .= displayMessage("{$text} {$GroupArray[$Group]} {$text1}."); } else { $V .= displayMessage($rc); } } /* Build HTML form */ $text = _("Delete a Group"); $V .= "<h4>{$text}</h4>\n"; $V .= "<form name='formy' method='POST' action=" . Traceback_uri() . "?mod=group_delete>\n"; /* Get array of users */ $UserArray = Table2Array('user_pk', 'user_name', 'users'); /* Remove from $GroupArray any active users. A user must always have a group by the same name */ foreach ($GroupArray as $group_fk => $group_name) { if (array_search($group_name, $UserArray)) { unset($GroupArray[$group_fk]); } } if (empty($GroupArray)) { $text = _("You have no groups you can delete."); echo "<p>{$text}<p>"; return; } reset($GroupArray); if (empty($group_pk)) { $group_pk = key($GroupArray); } $text = _("Select the group to delete: \n"); $V .= "{$text}"; /*** Display group select list, on change request new page with group= in url ***/ $V .= Array2SingleSelect($GroupArray, "grouppk", $group_pk, false, false); $text = _("Delete"); $V .= "<input type='submit' value='{$text}'>\n"; $V .= "</form>\n"; if (!$this->OutputToStdout) { return $V; } print "{$V}"; return; }
/** * @param Request $request * @return Response */ protected function handle(Request $request) { /* Get array of groups that this user is an admin of */ $groupsWhereUserIsAdmin = GetGroupArray(Auth::getUserId()); if (empty($groupsWhereUserIsAdmin)) { $text = _("You have no permission to manage any group."); return $this->render('include/base.html.twig', $this->mergeWithDefault(array('content' => $text))); } $folder_pk = intval($request->get('folder')); $upload_pk = intval($request->get('upload')); $perm_upload_pk = intval($request->get('permupk')); $perm = intval($request->get('perm')); $newgroup = intval($request->get('newgroup')); $newperm = intval($request->get('newperm')); $public_perm = $request->get('public', -1); /* @var $folderDao FolderDao */ $folderDao = $this->getObject('dao.folder'); $root_folder_pk = $folderDao->getRootFolder(Auth::getUserId())->getId(); if (empty($folder_pk)) { $folder_pk = $root_folder_pk; } $UploadList = FolderListUploads_perm($folder_pk, Auth::PERM_WRITE); if (empty($upload_pk) && !empty($UploadList)) { $upload_pk = $UploadList[0]['upload_pk']; } if (!empty($perm_upload_pk)) { $this->uploadPermDao->updatePermissionId($perm_upload_pk, $perm); } else { if (!empty($newgroup) && !empty($newperm)) { $this->insertPermission($newgroup, $upload_pk, $newperm, $UploadList); $newperm = $newgroup = 0; } else { if ($public_perm >= 0) { $this->uploadPermDao->setPublicPermission($upload_pk, $public_perm); } } } $vars = array('folderStructure' => $folderDao->getFolderStructure($root_folder_pk), 'groupArray' => $groupsWhereUserIsAdmin, 'uploadId' => $upload_pk, 'folderId' => $folder_pk, 'baseUri' => Traceback_uri() . '?mod=upload_permissions', 'newPerm' => $newperm, 'newGroup' => $newgroup, 'uploadList' => $UploadList, 'permNames' => $GLOBALS['PERM_NAMES']); if (!empty($UploadList)) { $vars['publicPerm'] = $this->uploadPermDao->getPublicPermission($upload_pk); $permGroups = $this->uploadPermDao->getPermissionGroups($upload_pk); $vars['permGroups'] = $permGroups; $additableGroups = array(0 => '-- select group --'); foreach ($groupsWhereUserIsAdmin as $gId => $gName) { if (!array_key_exists($gId, $permGroups)) { $additableGroups[$gId] = $gName; } } $vars['additableGroups'] = $additableGroups; } $vars['gumJson'] = json_encode($this->getGroupMembers($groupsWhereUserIsAdmin)); if (!empty($upload_pk)) { $vars['permNamesWithReuse'] = $this->getPermNamesWithReuse($upload_pk); } return $this->render('upload_permissions.html.twig', $this->mergeWithDefault($vars)); }
function DisplayGroupMembership() { global $SysConf; global $PG_CONN; global $PERM_NAMES; $group_pk = GetParm('group_pk', PARM_INTEGER); $user_pk = $SysConf['auth']['UserId']; $V = ""; $text = _("To edit group memberships "); $text2 = _("click here"); $V .= "<p>{$text}" . "<a href='" . Traceback_uri() . "?mod=group_manage_users'>" . $text2 . "</a>"; $text = _("Look up who is a member of group "); /* Get array of groups that this user is an admin of */ $GroupArray = GetGroupArray($user_pk); if (empty($GroupArray)) { $text = _("You have no permission to manage any group."); echo "<p>{$text}<p>"; return; } reset($GroupArray); if (empty($group_pk)) { $group_pk = key($GroupArray); } $text = _("To list the users in a group, select the group: \n"); $V .= "<p>{$text}"; /*** Display group select list, on change request new page with group= in url ***/ $url = preg_replace('/&group_pk=[0-9]*/', "", Traceback()) . "&group_pk="; $onchange = "onchange=\"js_url(this.value, '{$url}')\""; $V .= Array2SingleSelect($GroupArray, "groupuserselect", $group_pk, false, false, $onchange); /* Select all the user members of this group */ $sql = "select group_user_member_pk, user_fk, group_perm, user_name from group_user_member, users\n where group_fk='{$group_pk}' and user_fk=user_pk"; $result = pg_query($PG_CONN, $sql); DBCheckResult($result, $sql, __FILE__, __LINE__); $GroupMembersArray = pg_fetch_all($result); pg_free_result($result); /* Permissions Table */ $V .= "<p><table border=1>"; $UserText = _("User"); $V .= "<tr><th>{$UserText}</th></tr>"; foreach ($GroupMembersArray as $GroupMember) { $V .= "<tr>"; $V .= "<td>"; // user $V .= $GroupMember['user_name']; $V .= "</td>"; $V .= "</tr>"; } $V .= "</table>"; return $V; }
function Output() { global $PG_CONN; global $PERM_NAMES; global $SysConf; $user_pk = $SysConf['auth']['UserId']; /* GET parameters */ $group_pk = GetParm('group', PARM_INTEGER); /* group_pk to manage */ $gum_pk = GetParm('gum_pk', PARM_INTEGER); /* group_user_member_pk */ $perm = GetParm('perm', PARM_INTEGER); /* Updated permission for gum_pk */ $newuser = GetParm('newuser', PARM_INTEGER); /* New group */ $newperm = GetParm('newperm', PARM_INTEGER); /* New permission */ if (empty($newperm)) { $newperm = 0; } /* If gum_pk is passed in, update either the group_perm or user_pk */ $sql = ""; if (!empty($gum_pk)) { /* Verify user has access */ if (empty($group_pk)) { $gum_rec = GetSingleRec("group_user_member", "where group_user_member_pk='{$gum_pk}'"); $group_pk = $gum_rec['group_fk']; } $this->VerifyAccess($user_pk, $group_pk); if ($perm === 0 or $perm === 1) { $sql = "update group_user_member set group_perm='{$perm}' where group_user_member_pk='{$gum_pk}'"; $result = pg_query($PG_CONN, $sql); DBCheckResult($result, $sql, __FILE__, __LINE__); pg_free_result($result); } else { if ($perm === -1) { $sql = "delete from group_user_member where group_user_member_pk='{$gum_pk}'"; $result = pg_query($PG_CONN, $sql); DBCheckResult($result, $sql, __FILE__, __LINE__); pg_free_result($result); } } } else { if (!empty($newuser) && !empty($group_pk)) { // before inserting this new record, delete any record for the same upload and group since // that would be a duplicate $sql = "delete from group_user_member where group_fk='{$group_pk}' and user_fk='{$newuser}'"; $result = pg_query($PG_CONN, $sql); DBCheckResult($result, $sql, __FILE__, __LINE__); pg_free_result($result); if ($newperm >= 0) { $sql = "insert into group_user_member (group_fk, user_fk, group_perm) values ({$group_pk}, {$newuser}, {$newperm})"; $result = pg_query($PG_CONN, $sql); DBCheckResult($result, $sql, __FILE__, __LINE__); pg_free_result($result); } $newperm = $newuser = 0; } } // start building the output buffer $V = ""; /* define js_url */ $V .= js_url(); /* Get array of groups that this user is an admin of */ $GroupArray = GetGroupArray($user_pk); if (empty($GroupArray)) { $text = _("You have no permission to manage any group."); echo "<p>{$text}<p>"; return; } reset($GroupArray); if (empty($group_pk)) { $group_pk = key($GroupArray); } $text = _("Select the group to manage: \n"); $V .= "{$text}"; /*** Display group select list, on change request new page with group= in url ***/ $url = Traceback_uri() . "?mod=group_manage_users&group="; $onchange = "onchange=\"js_url(this.value, '{$url}')\""; $V .= Array2SingleSelect($GroupArray, "groupselect", $group_pk, false, false, $onchange); /* Create array of group_user_member group_perm possible values for use in a select list */ $group_permArray = array(-1 => "None", 0 => "User", 1 => "Admin"); /* Select all the user members of this group */ $sql = "select group_user_member_pk, user_fk, group_perm, user_name from group_user_member, users\n where group_fk='{$group_pk}' and user_fk=user_pk order by user_name"; $result = pg_query($PG_CONN, $sql); DBCheckResult($result, $sql, __FILE__, __LINE__); $GroupMembersArray = pg_fetch_all($result); pg_free_result($result); /* Permissions Table */ $V .= "<p><table border=1>"; $UserText = _("User"); $PermText = _("Permission"); $V .= "<tr><th>{$UserText}</th><th>{$PermText}</th></tr>"; if (!empty($GroupMembersArray)) { // does this group have childen ? foreach ($GroupMembersArray as $GroupMember) { $V .= "<tr>"; $V .= "<td>"; // user $V .= $GroupMember['user_name']; $V .= "</td>"; $V .= "<td>"; // permission $url = Traceback_uri() . "?mod=group_manage_users&gum_pk={$GroupMember['group_user_member_pk']}&perm="; $onchange = "onchange=\"js_url(this.value, '{$url}')\""; $V .= Array2SingleSelect($group_permArray, "permselect", $GroupMember['group_perm'], false, false, $onchange); $V .= "</td>"; $V .= "</tr>"; } } /* Print one extra row for adding perms */ $V .= "<tr>"; $V .= "<td>"; // user $url = Traceback_uri() . "?mod=group_manage_users&newperm={$newperm}&group={$group_pk}&newuser="******"onchange=\"js_url(this.value, '{$url}')\""; $Selected = empty($newuser) ? "" : $newuser; $UserArray = Table2Array("user_pk", "user_name", "users", " ", "order by user_name"); $V .= Array2SingleSelect($UserArray, "userselectnew", $Selected, true, false, $onchange); $V .= "</td>"; $V .= "<td>"; // permission $url = Traceback_uri() . "?mod=group_manage_users&newuser={$newuser}&group={$group_pk}&newperm="; $onchange = "onchange=\"js_url(this.value, '{$url}')\""; $Selected = $newperm; $V .= Array2SingleSelect($group_permArray, "permselectnew", $Selected, false, false, $onchange); $V .= "</td>"; $V .= "</tr>"; $V .= "</table>"; $text = _("All user permissions take place immediately when a value is changed. There is no submit button."); $V .= "<p>" . $text; $text = _("Add new users on the last line."); $V .= "<br>" . $text; if (!$this->OutputToStdout) { return $V; } print "{$V}"; return; }
extract($aGroupData); $nameX = 20; $birthdayX = 70; $parentsX = 95; $phoneX = 170; $yTitle = 20; $yTeachers = 26; $yOffsetStartStudents = 6; $yIncrement = 4; $pdf->SetFont("Times", 'B', 16); $pdf->WriteAt($nameX, $yTitle, $grp_Name . " - " . $grp_Description); $FYString = MakeFYString($iFYID); $pdf->WriteAt($phoneX, $yTitle, $FYString); $pdf->SetLineWidth(0.5); $pdf->Line($nameX, $yTeachers - 0.75, 195, $yTeachers - 0.75); $ga = GetGroupArray($iGroupID); $numMembers = count($ga); $teacherString1 = ""; $teacherString2 = ""; $teacherCount = 0; $teachersThatFit = 4; $bFirstTeacher1 = true; $bFirstTeacher2 = true; for ($row = 0; $row < $numMembers; $row++) { extract($ga[$row]); if ($lst_OptionName == gettext("Teacher")) { $phone = $pdf->StripPhone($fam_HomePhone); if ($teacherCount >= $teachersThatFit) { if (!$bFirstTeacher2) { $teacherString2 .= ", "; }