root/elgg/trunk/mod/projects/lib/function_pending.php

Revision 143, 1.3 kB (checked in by bettse, 1 year ago)

fixes ##2756
This is the code I wrote, adds a pending projects area to the projects module with links for approval.

  • Property svn:executable set to *
Line 
1 <?php
2
3 /////THIS IS NOT THE WAY IT SHOULD BE DONE.  THIS IS JUST A DEMONSTRATION
4
5 // Connecting, selecting database
6 $dbconn = pg_connect($CFG->mp_connectionstring)
7     or die('Could not connect: ' . pg_last_error());
8
9 // Performing SQL query
10 $owner_query = "SELECT P.id, P.name, P.description, U.username FROM project_request_project P, auth_user AS U WHERE status='R' AND U.id=P.owner_id";
11 $result = pg_query($owner_query) or die('Query failed: ' . pg_last_error());
12
13 $run_result .= '<div class=\"project_list\"><h2>Pending Project Requests</h2></div>';
14
15 if(pg_num_rows($result) < 1){
16     $run_result .= "No pending projects.";
17
18 }else{
19     // Printing results in HTML
20     $run_result .= "<ul>\n";
21     while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) {
22         $projectname = $line['name'];
23         $pid = $line['id'];
24         $description = $line['description'];
25         $owner = $line['username'];
26         $ownerlink = "$CFG->wwwroot/$owner/";
27         $approvallink = "$CFG->wwwroot../request/$pid/approve/";
28         $run_result .= "<li>$projectname:</li><br/>$description<br/>Owner: <a href=\"$ownerlink\">$owner</a> <br/><a href=\"$approvallink\">Approve</a>\n";
29     }
30     $run_result .= "</ul>\n";
31 }
32
33 // Free resultset
34 pg_free_result($result);
35
36 // Closing connection
37 pg_close($dbconn);
38
39
40
41
42 ?>
43
Note: See TracBrowser for help on using the browser.