-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 04113de
Showing
11 changed files
with
326 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
//delete only if admin login | ||
if (!isadminloggedin()){ | ||
forward('pg/collaboration/admin'); | ||
} | ||
$guids_to_delete = get_input('to_delete'); | ||
foreach($guids_to_delete as $guid) { | ||
delete_entity($guid); | ||
} | ||
forward('pg/collaboration/admin'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
//add only if admin login | ||
if (!isadminloggedin()) { | ||
forward('pg/collaboration/admin'); | ||
} | ||
$site_name = get_input('site_name'); | ||
$site_url = get_input('site_url'); | ||
$use_iframe = get_input('use_iframe'); | ||
$group_id = get_input('group_visibility'); | ||
|
||
$site = saveCollaborativeSite($site_name, $site_url, $use_iframe, $group_id); | ||
forward('pg/collaboration/admin'); | ||
|
||
/** | ||
* Function inserts the site entered by the admin into database | ||
* @params $site_name => The user friendly display name of the site | ||
* @params $site_url => The url of the collaborative site. | ||
* | ||
* All the parameters must properly validated and sanitized | ||
*/ | ||
function saveCollaborativeSite($site_name, $site_url, $in_new_window = false, $group_id) { | ||
$site = new ElggObject(); | ||
$site->subtype = "collaboration"; | ||
$site->name = $site_name; | ||
$site->url = $site_url; | ||
$site->access_id = ACCESS_PUBLIC; | ||
$site = setVisibility($site, $group_id); | ||
if ($in_new_window) { | ||
$site->use_iframe = false; | ||
} else { | ||
$site->use_iframe = true; | ||
} | ||
|
||
|
||
$site->save(); | ||
|
||
return $site; | ||
} | ||
|
||
function setVisibility(ElggObject $site, $group_id = 0) { | ||
$group = get_entity($group_id); | ||
|
||
if ($group instanceof ElggGroup) { | ||
$site->access_id = $group->group_acl; | ||
} | ||
return $site; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
$site_id = get_input('site_id'); | ||
|
||
$area1 = elgg_view_title($title); | ||
|
||
$area1 = elgg_view('collaboration/view'); | ||
|
||
$body = elgg_view_layout('one_column |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
include_once(dirname(dirname(dirname(__FILE__))) ."/engine/start.php"); | ||
|
||
gatekeeper(); | ||
|
||
$title = ""; | ||
|
||
$area1 = elgg_view_title($title); | ||
|
||
$area1 .= elgg_view('collaboration/add'); | ||
$area1 .= elgg_view('collaboration/view_all'); | ||
|
||
$body = elgg_view_layout('one_column', $area1); | ||
|
||
echo page_draw($title, $body); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<plugin_manifest> | ||
<field key="author" value="Robert George" /> | ||
<field key="version" value="1.7" /> | ||
<field key="description" value="This plugin allows linking external sites to elgg site." /> | ||
<field key="website" value="http://www.neevtech.com/" /> | ||
<field key="copyright" value="" /> | ||
<field key="license" value="GNU Public License version 2" /> | ||
<field key="elgg_version" value="2010030101" /> | ||
</plugin_manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
global $CONFIG; | ||
|
||
|
||
register_action("collaboration/insert_site", | ||
false, | ||
$CONFIG->pluginspath . "collaboration/actions/insert.php" | ||
); | ||
/* | ||
register_action("collaboration/view", | ||
false, | ||
$CONFIG->pluginspath . "collaboration/actions/view.php" | ||
);*/ | ||
|
||
function collaboration_page_handler($page) { | ||
|
||
if (isset($page[0])) { | ||
switch ($page[0]) { | ||
case 'add': | ||
include (dirname(__FILE__) ."/add.php"); | ||
break; | ||
case 'delete': | ||
include (dirname(__FILE__) ."/actions/delete.php"); | ||
break; | ||
case 'view': | ||
include (dirname(__FILE__) ."/view.php"); | ||
break; | ||
case 'admin': | ||
include (dirname(__FILE__) ."/admin.php"); | ||
break; | ||
} | ||
} else { | ||
register_error('Page not found'); | ||
forward( $CONFIG->wwwroot ); | ||
} | ||
return true; | ||
} | ||
|
||
function collaboration_init() { | ||
register_page_handler('collaboration', 'collaboration_page_handler'); | ||
elgg_extend_view('elgg_topbar/extend', 'collaboration/topbar'); | ||
} | ||
|
||
function collaboration_pagesetup() { | ||
global $CONFIG; | ||
if (get_context() == 'admin' && isadminloggedin()) { | ||
add_submenu_item('Manage external sites', $CONFIG->wwwroot . 'pg/collaboration/admin'); | ||
} | ||
} | ||
|
||
register_elgg_event_handler('init', 'system', 'collaboration_init'); | ||
register_elgg_event_handler('pagesetup', 'system', 'collaboration_pagesetup'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
include_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); | ||
|
||
gatekeeper(); | ||
|
||
$title = ""; | ||
|
||
$area1 = elgg_view_title($title); | ||
|
||
$area1 .= elgg_view('collaboration/view'); | ||
|
||
$body = elgg_view_layout('one_column', $area1); | ||
|
||
echo page_draw($title, $body); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
$groups = elgg_get_entities(array('type' => 'group', 'owner' => 0, 'full_view' => false)); | ||
$options = array(); | ||
$options_values = array(); | ||
$options[] = 'All groups'; | ||
$options_values[0] = 'All groups'; | ||
|
||
foreach( $groups as $group) { | ||
$options[] = $group->name; | ||
$options_values[$group->getGUID()] = $group->name; | ||
} | ||
?> | ||
<div class="conentWrapper"> | ||
<form action="<?php echo $vars['url']; ?>action/collaboration/insert_site" method="post"> | ||
<fieldset style="border: 1px solid gold;padding: 18px; margin: 10px;"> | ||
<legend> Add a new collaboration site. Enter the name and url of the site below. </legend> | ||
<label for="site_name">Name:</label> | ||
<?php echo elgg_view('input/text', array('internalname' => 'site_name')); ?> | ||
|
||
<label for="site_url">Url:</label> | ||
<?php echo elgg_view('input/text', array('internalname' => 'site_url')); ?> | ||
<label for="group_assigned">Visible to:</label> | ||
<?php echo elgg_view('input/pulldown', | ||
array( | ||
'internalname' => 'group_visibility', | ||
'options' => $options, | ||
'options_values' => $options_values | ||
) | ||
); | ||
?> | ||
<br> | ||
<label for="use_iframe">Open the site in new window:</label> | ||
<input type="checkbox" name="use_iframe"></input> | ||
|
||
<?php echo elgg_view('input/securitytoken'); ?> | ||
<br> | ||
<?php echo elgg_view('input/submit', array('value' => elgg_echo('Add site'))); ?> | ||
</fieldset> | ||
|
||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
if ( !function_exists('make_link')) { | ||
function make_link($href, $title, $target_blank = false) { | ||
if ($target_blank) { | ||
return '<a href="' . $href . '" target="_blank">' .$title . '</a>'; | ||
} else { | ||
return '<a href="' . $href . '" target="_self">' .$title . '</a>'; | ||
} | ||
} | ||
} | ||
if (!function_exists('get_my_links')) { | ||
function get_my_links() { | ||
$collaboration_sites = elgg_get_entities( | ||
array( | ||
'type' => 'object', | ||
'subtype' => 'collaboration', | ||
) | ||
); | ||
$submenus = array(); | ||
|
||
foreach($collaboration_sites as $site) { | ||
if ($site->name == '' || $site->url == '') { | ||
continue; | ||
} | ||
$submenu = array( | ||
'title' => $site->name, | ||
); | ||
if ($site->use_iframe) { | ||
$url = make_link( $site->url, $site->name ); | ||
} else { | ||
$url = make_link( $site->url, $site->name, true ); | ||
} | ||
$submenu['url'] = $url; | ||
$submenus[] = $submenu; | ||
} | ||
return $submenus; | ||
|
||
} | ||
} | ||
$submenus = get_my_links(); | ||
?> | ||
<ul class="topbardropdownmenu"> | ||
<li class="drop"><a href="#" class="menuitemtools">Sites</a> | ||
<ul> | ||
<?php | ||
foreach($submenus as $menu) { | ||
echo "<li>{$menu['url']}</li>"; | ||
} | ||
?> | ||
</ul> | ||
</li> | ||
</ul> | ||
<script type="text/javascript"> | ||
jQuery(function() { | ||
jQuery('ul.topbardropdownmenu').elgg_topbardropdownmenu(); | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
$site_id = get_input('id'); | ||
$entity = get_entity($site_id); | ||
|
||
$area2 = "<iframe src=\"{$entity->url}\" width=\"100%\" height=\"718px\"></iframe>"; | ||
?> | ||
<div class="conentWrapper"> | ||
<?= $area2 ?> | ||
</div> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
if (!function_exists('get_all_links')) { | ||
function get_all_links() { | ||
$links = array(); | ||
$collaboration_sites = elgg_get_entities( | ||
array( | ||
'type' => 'object', | ||
'subtype' => 'collaboration' | ||
) | ||
); | ||
|
||
foreach($collaboration_sites as $site) { | ||
if ($site->name == '' || $site->url == '') { | ||
continue; | ||
} | ||
$links[] = array( | ||
'name' => $site->name, | ||
'id' => $site->getGUID() | ||
); | ||
} | ||
return $links; | ||
} | ||
} | ||
?> | ||
|
||
<?php | ||
$delete_path = $CONFIG->wwwroot . "pg/collaboration/delete"; | ||
$links = get_all_links(); | ||
|
||
if (count($links) ) { | ||
echo '<form action="' .$delete_path .'" method="post"> | ||
<fieldset style="border: 1px solid gold; padding: 10px;margin: 10px;"> | ||
<legend>All collaboration sites</legend> | ||
<ol style="list-style-type: decimal;">'; | ||
foreach($links as $link) { | ||
echo '<li>'. $link['name'] .' | ||
<input type="checkbox" name="to_delete[]" value="'. | ||
$link['id'] ."\"></input>"; | ||
echo '</li>'; | ||
} | ||
echo '</ol>'; | ||
echo elgg_view('input/securitytoken'); | ||
echo '<br>'; | ||
echo elgg_view( | ||
'input/submit', | ||
array( | ||
'value' => elgg_echo("Remove selected sites") | ||
) | ||
); | ||
echo '</fieldset> | ||
</form>'; | ||
} else { | ||
echo 'No sites found. Please add sites using the above form.'; | ||
} | ||
?> |