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

Revision 88, 3.5 kB (checked in by bettse, 1 year ago)

New projects module. This will add a few new things including a new main menu bar item 'Projects' that will contain submenus
for 'My Projects', 'Browse Projects', and 'Project Graveyard'; it will add a 'Project list' widget for projects to list that
users projects in his/her profile. It adds a keyword for making project shortnames into links. Lastly, changes to toolbar/lib.php and some of the
functions in projects/lib now allow projects to be searched by the global search box.

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