Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 4.0_templates
  • 4.1_templates-symlink
  • develop
  • git-fixes
  • master
5 results

Target

Select target project
  • tneumann9/PlanetRed
  • JSTUREK8/PlanetRed
  • smccoy12/PlanetRed
  • dkuzelka2/PlanetRed
  • s-cwiedel5/PlanetRed
  • dxg/PlanetRed
6 results
Select Git revision
  • 4.0_templates
  • 4.1_templates-symlink
  • develop
  • git-fixes
  • master
5 results
Show changes
Commits on Source (106)
Showing
with 835 additions and 0 deletions
vagrant/dev/.vagrant
data
tmp
[submodule "elgg"]
path = elgg
url = https://github.com/Elgg/Elgg.git
# Contributing
This project follows the normal github workflow.
## Working on a feature or issue
* Please make a fork of the repository if you do not already have one.
* Create a branch for the feature/issue with a name like `feature-x` or `issue-#`.
* Commit your changes to that branch.
* Create a pull request with your changes.
# Planet Red
Planet Red is UNL's implementation of elgg
## Directory Structure
* elgg - the elgg directory. Currently a submodule, checked out at 1.8.19
* vagrant - various vagrant boxes for development/testing. Use vagrant/dev/ for development
* plugins - Our custom plugins such as auth and themes that need to be symlinked. Keeping the plugins out of the elgg directory makes for easy upgrades.
## Setup
1. Initialize submodules by running `git submodule init` and then `gitsubmodule update`
## Using Vagrant
For now, use the dev vagrant box at vagrant/dev/
1. `cd vagrant/dev/`
2. `vagrant up`
3. go to http://localhost:8005 to view the project
## Using Elgg Clean theme
1. `vagrant ssh`
2. `ln -s /var/www/html/plugins/unl_theme /var/www/html/elgg/mod`
3. `ln -s /var/www/html/plugins/cas_auth_unl /var/www/html/elgg/mod`
## TODO
* implement the UNLedu Framework 4.0 theme at plugins/unl_theme
* implement UNL auth at plugins/cas_auth_unl
* make sure profile image routes still work
\ No newline at end of file
Subproject commit 83a56e7201288ccbfb036d8251df992f8446da3e
{
"folders":
[
{
"path": "."
}
]
}
This diff is collapsed.
vendor
migration.lock
\ No newline at end of file
<?php
cas_auth_unl_logout_page_handler();
\ No newline at end of file
{
"require": {
"jasig/phpcas": "~1.3",
"tedivm/stash": "~0.13"
}
}
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "b4245ecc009711f2dc14b812d7df3801",
"content-hash": "6100f9d8f438ea02c6cc1e2fdb4f9075",
"packages": [
{
"name": "jasig/phpcas",
"version": "1.3.4",
"source": {
"type": "git",
"url": "https://github.com/Jasig/phpCAS.git",
"reference": "8c74d21630f74278270830fdbdb0c1317bce3f0a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Jasig/phpCAS/zipball/8c74d21630f74278270830fdbdb0c1317bce3f0a",
"reference": "8c74d21630f74278270830fdbdb0c1317bce3f0a",
"shasum": ""
},
"require": {
"ext-curl": "*",
"php": ">=5.0.0"
},
"require-dev": {
"phpunit/phpunit": "~3.7.10"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.3.x-dev"
}
},
"autoload": {
"classmap": [
"source/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "Joachim Fritschi",
"homepage": "https://wiki.jasig.org/display/~fritschi"
},
{
"name": "Adam Franco",
"homepage": "https://wiki.jasig.org/display/~adamfranco"
}
],
"description": "Provides a simple API for authenticating users against a CAS server",
"homepage": "https://wiki.jasig.org/display/CASC/phpCAS",
"keywords": [
"cas",
"jasig"
],
"time": "2015-11-16 20:44:36"
},
{
"name": "tedivm/stash",
"version": "v0.13.2",
"source": {
"type": "git",
"url": "https://github.com/tedious/Stash.git",
"reference": "3489b13bad93c81a898fcb1054ae954575e1a7b6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tedious/Stash/zipball/3489b13bad93c81a898fcb1054ae954575e1a7b6",
"reference": "3489b13bad93c81a898fcb1054ae954575e1a7b6",
"shasum": ""
},
"require": {
"php": "^5.4|^7.0"
},
"require-dev": {
"fabpot/php-cs-fixer": "^1.9",
"phpunit/phpunit": "4.7.*",
"satooshi/php-coveralls": "1.0.*"
},
"type": "library",
"autoload": {
"psr-4": {
"Stash\\": "src/Stash/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Robert Hafner",
"email": "tedivm@tedivm.com"
},
{
"name": "Josh Hall-Bachner",
"email": "charlequin@gmail.com"
}
],
"description": "The place to keep your cache.",
"homepage": "http://github.com/tedious/Stash",
"keywords": [
"apc",
"cache",
"caching",
"memcached",
"redis",
"sessions"
],
"time": "2015-12-29 00:07:05"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": []
}
<?xml version="1.0" encoding="UTF-8" ?>
<plugin_manifest xmlns="http://www.elgg.org/plugin_manifest/1.8">
<name>CAS Auth UNL</name>
<author>UNL</author>
<version>1.0</version>
<description>CAS Authetication. Modified from the original LDAP plugin for use at UNL.</description>
<requires>
<type>elgg_release</type>
<version>1.9</version>
</requires>
</plugin_manifest>
<?php
require_once __DIR__ . '/../../elgg/vendor/autoload.php';
\Elgg\Application::start();
$lock_file = __DIR__ . '/migration.lock';
$lock = @file_get_contents($lock_file);
$lock_data = json_decode($lock, true);
if (!$lock) {
$lock_data = array(
'last_guid' => 0,
'icontime' => 0
);
}
if (!$users = @file_get_contents('https://planetred.unl.edu/sync.php?start='.$lock_data['last_guid'] . '&icontime='.$lock_data['icontime'])) {
echo 'FAILED TO CONNECT' . PHP_EOL;
exit();
}
$users = json_decode($users, true);
if (!$users) {
echo 'FAILED TO DECODE' . PHP_EOL;
exit();
}
//Copy over avatar stuffs
$context = stream_context_create(
array(
'http' => array(
'follow_location' => false
)
)
);
$icon_sizes = array('master', 'large', 'medium', 'small', 'tiny', 'topbar');
foreach ($users as $source_user) {
if (0 !== stripos($source_user['username'], 'unl_')) {
//Not a UNL authenticated user
continue;
}
$target_user = get_user_by_username($source_user['username']);
if (!$target_user) {
//create user
echo 'creating user: ' . $source_user['username'] . PHP_EOL;
$password = generate_random_cleartext_password();
try {
$target_guid = register_user($source_user['username'], $password, $source_user['name'], $source_user['email'], false);
} catch (RegistrationException $e) {
echo "\t Unable to create user: " . $e->getMessage() . PHP_EOL;
continue;
}
if (!$target_guid) {
continue;
}
$target_user = get_user($target_guid);
}
foreach ($icon_sizes as $size) {
if (!$icon = @file_get_contents('http://planetred.unl.edu/pg/icon/'.$source_user['username'].'/'.$size, false, $context)) {
//No icon was found, skip.
echo 'SKIP' . PHP_EOL;
continue;
}
echo 'Creating ' . $size . ' icon for ' . $source_user['username'] . PHP_EOL;
$file = new ElggFile();
$file->owner_guid = $target_user->guid;
$file->setFilename("profile/{$target_user->guid}{$size}.jpg");
$file->open('write');
$file->write($icon);
$file->close();
//Don't overload the server
usleep(500000);
}
// reset crop coordinates
$target_user->x1 = 0;
$target_user->x2 = 0;
$target_user->y1 = 0;
$target_user->y2 = 0;
$target_user->icontime = time();
//Update the lock file
$lock_data = array(
'last_guid' => $source_user['guid'],
'icontime' => time()
);
file_put_contents($lock_file, json_encode($lock_data));
}
# CAS AUTH UNL
This plugin implements SSO (single sign on) via CAS for UNL. It overrides the default login and logout actions, as well as implements auto-login via the presen of the UNL sso cookie.
Users who do not have an email address that is publicly available will be asked to provide one upon first login.
## Install
1. symlink to the elgg/mod directory
2. run composer install
3. Activate in the elgg admin interface
<?php
/**
* Elgg UNL CAS authentication
*
* @package cas_auth_unl
* @license BSD http://www1.unl.edu/wdn/wiki/Software_License
* @author University of Nebraska-Lincoln
* @copyright 2010 Regents of the University of Nebraska
* @link http://www.unl.edu/
*/
global $CONFIG;
require_once __DIR__ . '/vendor/autoload.php';
function cas_auth_unl_init() {
global $CONFIG;
$auth = new UnlCAS();
$auth->autoLogin();
$auth->singleLogOut();
// Set up login page, this creates the url /login to be used as our login page
elgg_register_page_handler('login', 'cas_auth_unl_login_page_handler');
elgg_register_page_handler('logout', 'cas_auth_unl_logout_page_handler');
elgg_register_page_handler('register', 'cas_auth_unl_registration_page_handler');
/* set up getemail page */
elgg_register_page_handler('getemail', 'cas_auth_unl_getemail_page_handler');
elgg_register_action('getemail', $CONFIG->pluginspath . 'cas_auth_unl/actions/getemail.php', 'public');
elgg_register_action('logout', $CONFIG->pluginspath . 'cas_auth_unl/actions/logout.php', 'public');
}
// Fire up the plugin initialization using the elgg handler
elgg_register_event_handler('init','system','cas_auth_unl_init');
function cas_auth_unl_login_page_handler($page) {
// If we're not logged in, display the login page
if (!elgg_is_logged_in()) {
$auth = new UnlCAS();
$auth->forceLogin();
}
// Otherwise, forward to the index page
forward();
}
function cas_auth_unl_logout_page_handler($page) {
if (elgg_is_logged_in()) {
// If we're not logged in, display the login page
$auth = new UnlCAS();
$auth->forceLogout();
}
// Otherwise, forward to the index page
forward();
}
function cas_auth_unl_registration_page_handler($page) {
if (elgg_is_logged_in()) {
// Otherwise, forward to the index page
forward();
}
if (!isset($_SESSION['cas_auth_unl']['register']['uid'])) {
//They are not already in the registration process
forward();
}
if (!isset($_POST['email'])) {
forward();
}
// If we're not logged in, display the login page
$auth = new UnlCAS();
$unl_uid = $_SESSION['cas_auth_unl']['register']['uid'];
$auth->register($unl_uid, $_POST['email']);
$auth->login($unl_uid);
forward();
}
function cas_auth_unl_getemail_page_handler($page) {
if (!elgg_get_logged_in_user_entity()) {
echo elgg_view_page(elgg_echo('Your Email'), elgg_view("account/forms/getemail"));
} else {
forward();
}
}
class UnlCAS {
var $client;
var $casInitialized = false;
const DIRECTORY_URL = 'http://directory.unl.edu/';
public static $cert_path = '/etc/pki/tls/cert.pem';
function __construct() {
if (!\phpCAS::isInitialized()) {
\phpCAS::client(CAS_VERSION_2_0, 'login.unl.edu', 443, 'cas');
\phpCAS::setCasServerCACert(self::$cert_path);
\phpCAS::setPostAuthenticateCallback(function($logoutTicket) {
$auth = new UnlCAS();
$auth->loginOrRegister(\phpCAS::getUser());
$session = elgg_get_session();
$pool = $auth->getSessionMapPool();
$item = $pool->getItem($logoutTicket);
$item->set(array(
'session_id' => $session->getId(),
'date_created' => time()
));
});
\phpCAS::setSingleSignoutCallback(function ($logoutTicket) {
$auth = new UnlCAS();
$pool = $auth->getSessionMapPool();
$item = $pool->getItem($logoutTicket);
if ($item->isMiss()) {
return null;
}
$data = $item->get();
$handler = new Elgg\Http\DatabaseSessionHandler(_elgg_services()->db);
if (!$handler->destroy($data['session_id'])) {
throw new \Exception('unable to destroy session on single sign out');
}
//Remove the cached item
$item->clear();
});
}
}
public function getSessionMapPool()
{
$driver = new Stash\Driver\FileSystem();
// Setting a custom path is done by passing an options array to the constructor.
$options = array('path' => __DIR__ .'/../../tmp/elgg_session_map');
$driver->setOptions($options);
$pool = new Stash\Pool($driver);
return $pool;
}
public function singleLogOut()
{
\phpCAS::handleLogoutRequests(false);
}
public function autoLogin()
{
if (!array_key_exists('unl_sso', $_COOKIE)) {
//No unl_sso cookie was found, no need to auto-login.
return;
}
if (elgg_get_logged_in_user_entity()) {
//We are already logged in, no need to auto-login
return;
}
//Everything looks good. Log in!
$result = \phpCAS::checkAuthentication();
if ($result) {
//Make sure we are still authenticated with CAS
//setPostAuthenticateCallback() will actually do the work
\phpCAS::renewAuthentication();
}
}
protected function loginOrRegister($unl_uid)
{
$elgg_uid = $this->toElggUID($unl_uid);
$user = get_user_by_username($elgg_uid);
if (!$user) {
$this->register($unl_uid);
$this->login($unl_uid);
} else {
$this->login($unl_uid);
}
}
public function login($unl_uid)
{
$user = get_user_by_username($this->toElggUID($unl_uid));
//Log the user into elgg
login($user);
}
public function register($unl_uid, $student_email = false)
{
$elgg_uid = $this->toElggUID($unl_uid);
$directory_info = $this->getDirectoryInfo($unl_uid);
$name = 'unknown';
$email = false;
if ($student_email) {
$email = $student_email;
}
if (isset($directory_info['name'])) {
$name = $directory_info['name'];
}
if (isset($directory_info['email'])) {
//Override the student email with the one from the directory
$email = $directory_info['email'];
}
if (false === $email) {
$_SESSION['cas_auth_unl']['register']['uid'] = $unl_uid;
forward('getemail');
}
$password = generate_random_cleartext_password();
try {
$user_guid = register_user($elgg_uid, $password, $name, $email, false);
} catch (RegistrationException $e) {
//Looks like we had an invalid email address... ask for it again.
register_error(elgg_echo($e->getMessage()));
forward('getemail');
}
if (!$user_guid) {
register_error(elgg_echo("registerbad"));
}
//Make sure that this gets unset
unset($_SESSION['cas_auth_unl']);
return true;
}
protected function getDirectoryInfo($uid)
{
$info = array();
if (!$json = @file_get_contents(self::DIRECTORY_URL . '?uid=' . $uid . '&format=json')) {
return $info;
}
if (!$json = json_decode($json, true)) {
return $info;
}
$map = array(
'givenName' => 'first_name',
'sn' => 'last_name',
'mail' => 'email'
);
foreach ($map as $from => $to) {
if (isset($json[$from][0])) {
$info[$to] = $json[$from][0];
}
}
$info['name'] = $info['first_name'] . ' ' . $info['last_name'];
return $info;
}
protected function toElggUID($unl_uid)
{
$unl_uid = str_replace('-','_',$unl_uid);
return 'unl_' . $unl_uid;
}
public function forceLogin() {
//Due to the weirdness of phpCAS, it might think we are still logged in (when we are not)
$_SESSION['phpCAS'] = array();
\phpCAS::forceAuthentication();
}
public function forceLogout()
{
//log out of elgg
logout();
//log out of CAS
\phpCAS::logout();
}
}
<?php
/**
* Elgg Get Email Only SSO register form
*
* @package Elgg
* @subpackage Core
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
* @author Curverider Ltd
* @copyright Curverider Ltd 2008-2009
* @link http://elgg.org/
*/
// if we're returning from a failed email validation, we'll put the failed email in the email form field
$theiremail = get_input('e');
?>
<h2 class="sec_header">Email Verification</h2>
<div class="three_col left">
<p>We just want to make sure we have your correct e-mail and then we'll log you in.</p>
<?php
$form_body = "<p><label>" . elgg_echo('email') . "<br />" . elgg_view('input/text' , array('name' => 'email', 'class' => "general-textarea", 'value' => $theiremail)) . "</label><br />";
$form_body .= elgg_view('input/submit', array('value' => elgg_echo('Complete Registration and Login!'))) ."</p>";
$ts = time();
$token = generate_action_token($ts);
echo elgg_view('input/form', array('body' => $form_body, 'action' => $vars['url']."register?__elgg_ts=$ts&__elgg_token=$token"));
?>
</div>
<div class="col right">
<div class="zenbox cool">
<h3>Email Address Usage</h3>
<p>Your email address is only used to send notifications from Planet Red.</p>
</div>
</div>
Version History
===============
4.1 (2015-12-17):
- added: admin option to disable river item creation (fixes #5)
- added: composer support
- chore: refactoring for performance and coding style
4.0 (2014-11-10):
- changes for Elgg 1.9
3.3.1 (2014-11-10):
- changed: restored the default events, couldn't find the reason for the removal (fixes #4)
- applied Elgg coding standards
3.3 (2013-04-05):
- added: Spanish translation (thanks to Iknaxio Marx http://community.elgg.org/profile/iknaxio)
- added: notification on friend accept
- added: French translation (thanks to https://github.com/GeekShadow PR #3)
- changed: layout and code cleanup
- changed: styling of topbar icon (inspired by https://github.com/minhtinh2604 PR #1)
- removed: CSS because it's no longer needed
3.2 (2012-06-11):
- added: direct link to add/remove friend in member listing
- added: Dutch translation
- added: river view now works both ways
- added: river cleanup
- fixed: small error in Englisch language file (thanks to Matt Beckett http://community.elgg.org/pg/profile/Beck24)
- fixed: old link in notification
- changed: small code optimalizations
3.1 (2012-03-02):
- added: german translation (thanks to Opteron http://community.elgg.org/pg/profile/Opteron)
- fixed: wrong link in new request notify (thanks to Lee http://community.elgg.org/pg/profile/8toenails)
3.0.2 (2011-12-23):
- fixed: river events in Elgg 1.8.1+
- changed: required Elgg version to 1.8.1
3.0.1 (2011-11-28):
- fixed: page_handler issue with Elgg 1.8.1
- changed: moved version history from README.txt to CHANGES.txt
3.0 (2011-11-08):
- changed: Elgg 1.8 compatibility
2.3 (2011-09-23):
- added: dutch translation
- fixed: link on profile actions when pending friend request
2.2.4 (2011-09-19):
- fixed: elgg depricated functions
- changed: used more elgg functions
- changed: user profile menu now shows pending request
2.2.3 (2011-08-10):
- fixed: conflict with invitefriends (thanks to AV-2 http://community.elgg.org/pg/profile/vectorraster)
2.2.2 (2011-06-21):
- fixed: depricated notice in start.php
2.2.1 (2011-06-15):
- changed: layout of listings
- fixed: depricated notice in topbar
2.2:
- changed: removed action_gatekeepers from actions
2.1:
- added: CSS fix to hide friendsof on profile and user pulldown menu
- added: friends menu no longer showing friendsof
- fixed: collections links now showing
- changed: menu title language handling
- changed: CSS for topbar
2.0:
- added: menu options in friends and messages
- added: option to revoke a request
- added: listing of sent requests
- changed: listing of received friend requests
- changed: Elgg topbar icon
1.5:
- latest release by Bosssumon and Zac Hopkinson
\ No newline at end of file
Friend request
==============
[![Build Status](https://scrutinizer-ci.com/g/ColdTrick/friend_request/badges/build.png?b=master)](https://scrutinizer-ci.com/g/ColdTrick/friend_request/build-status/master)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/ColdTrick/friend_request/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/ColdTrick/friend_request/?branch=master)
[![Latest Stable Version](https://poser.pugx.org/coldtrick/friend_request/v/stable.svg)](https://packagist.org/packages/coldtrick/friend_request)
[![License](https://poser.pugx.org/coldtrick/friend_request/license.svg)](https://packagist.org/packages/coldtrick/friend_request)
Let users confirm friend requests. Make all friend requests reciprocal.
Features
-----------
- Add friends like on Facebook / LinkedIn, so you have to approve a request
Credits
----------
The original idea for this plugin was made by Bosssumon and Zac Hopkinson
<?php
$friend_guid = (int) get_input('guid');
$friend = get_user($friend_guid);
if (empty($friend)) {
register_error(elgg_echo('error:missing_data'));
forward(REFERER);
}
$user = elgg_get_logged_in_user_entity();
if (!remove_entity_relationship($friend->getGUID(), 'friendrequest', $user->getGUID())) {
register_error(elgg_echo('friend_request:approve:fail', [$friend->name]));
forward(REFERER);
}
$user->addFriend($friend->getGUID());
$friend->addFriend($user->getGUID()); //Friends mean reciprical...
// notify the user about the acceptance
$subject = elgg_echo('friend_request:approve:subject', [$user->name]);
$message = elgg_echo('friend_request:approve:message', [$friend->name, $user->name]);
$params = [
'action' => 'add_friend',
'object' => $user,
];
notify_user($friend->getGUID(), $user->getGUID(), $subject, $message, $params);
// add to river
friend_request_create_river_events($user->getGUID(), $friend->getGUID());
system_message(elgg_echo('friend_request:approve:successful', [$friend->name]));
forward(REFERER);
<?php
$friend_guid = (int) get_input('guid');
$friend = get_user($friend_guid);
if (empty($friend)) {
register_error(elgg_echo('error:missing_data'));
forward(REFERER);
}
$user = elgg_get_logged_in_user_entity();
if (!remove_entity_relationship($friend->getGUID(), 'friendrequest', $user->getGUID())) {
register_error(elgg_echo('friend_request:decline:fail'));
forward(REFERER);
}
$subject = elgg_echo('friend_request:decline:subject', [$user->name]);
$message = elgg_echo('friend_request:decline:message', [$friend->name, $user->name]);
$params = [
'action' => 'friend_request_decline',
'object' => $user,
];
notify_user($friend->getGUID(), $user->getGUID(), $subject, $message, $params);
system_message(elgg_echo('friend_request:decline:success'));
forward(REFERER);