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

Revision 143, 3.9 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 function projects_init() {
4     global $CFG, $PAGE;
5     global $function;
6     $function['projects:userprojects'][] = dirname(__FILE__) . '/lib/function_userprojects.php';
7     $function['projects:browse'][] = dirname(__FILE__) . '/lib/function_browse.php';
8     $function['projects:graveyard'][] = dirname(__FILE__) . '/lib/function_graveyard.php';
9     $function['projects:pending'][] = dirname(__FILE__) . '/lib/function_pending.php';
10
11 //    $PAGE->search_menu[] = array( 'name' => __gettext("Projects"), 'user_type' => 'projects');
12
13     $CFG->templates->variables_substitute['project'][] = (string) 'projects_inline';
14
15     $CFG->widgets->list[] = array(
16         'name' => __gettext("Project list"),
17         'description' => __gettext("List of projects user is involved in."),
18         'type' => "projects::list"
19     );
20
21     //Add our search to the list of search functions
22     $function['search:all:tagtypes'][] = dirname(__FILE__) . "/lib/function_search_all_tagtypes.php";
23
24     //add project search to the search array (there is also an rss version we should add later)
25     $function['search:display_results'][] = dirname(__FILE__) . "/lib/function_search.php";
26
27
28 }
29
30 function projects_pagesetup() {
31     global $CFG; // You may want this to access global configuration values
32     global $PAGE; // You may want this to modify the current page
33     global $profile_id;
34
35     // don't clobber $page_owner, use a
36     // local $pgowner instead for clarity
37     $pgowner = $profile_id;
38     if (isloggedin()) {
39                 if (defined("context") && context == "projects" && $pgowner == $_SESSION['userid']) {
40                         $PAGE->menu[] = array (
41                                 'name' => 'projects',
42                                 'html' => '<li><a href="' . $CFG->wwwroot . $_SESSION['username'] . '/projects/" class="selected">' . __gettext("Projects") . '</a></li>');
43                 } else {
44                         $PAGE->menu[] = array (
45                                 'name' => 'projects',
46                                 'html' => '<li><a href="' . $CFG->wwwroot . $_SESSION['username'] . '/projects/">' . __gettext("Projects") . '</a></li>');
47                 }
48     }
49
50     if (defined("context") && context == "projects"){
51
52         $PAGE->menu_sub[] = array (
53             'name' => 'projects:myprojects',
54             'html' => '<a href="' . $CFG->wwwroot . $_SESSION['username'] . '/projects/">' . __gettext("My Projects") . '</a>');
55
56         $PAGE->menu_sub[] = array (
57             'name' => 'projects:browseprojects',
58             'html' => '<a href="' . $CFG->wwwroot . $_SESSION['username'] . '/projects/browse/">' . __gettext("Browse Projects") . '</a>');
59
60         $PAGE->menu_sub[] = array (
61             'name' => 'projects:projectgraveyard',
62             'html' => '<a href="' . $CFG->wwwroot . $_SESSION['username'] . '/projects/graveyard/">' . __gettext("Project Graveyard") . '</a>');
63         if(isloggedin() && user_flag_get("admin", $_SESSION['userid'])){
64             $PAGE->menu_sub[] = array (
65                 'name' => 'projects:pendingprojects',
66                 'html' => '<a href="' . $CFG->wwwroot . $_SESSION['username'] . '/projects/pending/">' . __gettext("Pending Project Requests") . '</a>');
67         }//end admin if
68     }//end context if
69
70
71
72 }
73
74
75 function projects_inline($vars) {
76     if (isset($vars[1])){
77         return (string) '<a href="' . $CFG->wwwroot . '/projects/$vars[1]/\">$vars[1]</a>';
78     }
79 }
80
81
82
83 //widget stuff
84
85 function projects_widget_display($widget) {
86     global $CFG, $page_owner;
87
88     $username = trim(optional_param('profile_name',''));
89     $user_id = user_info_username("ident", $username);
90     if (!$user_id) {
91         $user_id = $page_owner;
92     } else {
93         $page_owner = $user_id;
94         $profile_id = $user_id;
95     }
96
97     $title = "Projects";
98     $body = run("projects:userprojects", $username);
99
100
101     return array('title'=>$title,'content'=>$body);
102
103
104 }
105
106 function projects_widget_edit($widget) {
107
108
109 }
110
111
112 ?>
113
Note: See TracBrowser for help on using the browser.