Commit 4f12862f authored by Fjen Undso's avatar Fjen Undso
Browse files

use own configfile and fix compability to oc 8.2

parent 71c30a10
......@@ -3,20 +3,15 @@ user_wcf
Owncloud user backend for the Woltlab Community Framework (WCF) used by Woltlab Burning Board (WBB3)
To use this backend you need to enable the app in OwnCloud and then add the user backend to your configuration file:
To use this backend you need to enable the app in OwnCloud, edit config/config.php and then add the user backend to your configuration file:
```php
$CONFIG = array (
// [...]
'user_backends' => array (
array (
'class' => 'OCA\\User_WCF\\User_WCF',
'arguments' => array (
// Change to your WCF path containing the DB settings (config.inc.php)
'/var/www/forum/wcf',
// Change this to the WCF groups that should be allowed to use OC.
array ('Admins', 'Privilged Users', 'Some other Privileged Group'),
),
'class' => 'OCA\\user_wcf\\User_WCF',
'arguments' => array (),
),
),
);
......
<?php
//OC::$CLASSPATH['User_WCF']='user_wcf/user_wcf.php';
$userBackend = new OCA\user_wcf\User_WCF();
\OC_User::useBackend($userBackend);
/media/owncloud/apps/user_wcf/appinfo
0.1
\ No newline at end of file
0.2
<?php
$wcfPath = '/var/www/finf/forum/wcf';
$authorizedGroups = array (
0 => 'Fachrat Informatik',
1 => 'Administratoren',
2 => 'Zugang zum internen Forum',
3 => 'Owncloud-User',
);
......@@ -85,7 +85,7 @@ class Group_WCF extends \OC_Group_Backend {
*
* Returns a list with all groups
*/
public function getGroups($search = '', $limit = -1, $offset = 0) {
public function getGroups($search = '', $limit=null, $offset=null) {
$groups = array();
$params = array();
$where = NULL;
......@@ -96,21 +96,27 @@ class Group_WCF extends \OC_Group_Backend {
$where = 'groupName LIKE ?';
$params[] = '%'.$search.'%';
}
if ($limit !== -1) {
$append .= ' LIMIT '.intval($limit);
if (!($limit === -1 or is_null($limit))) {
$append .= ' LIMIT '.intval($liumit);
}
if ($offset !== 0) {
if (!($offset === 0 or is_null($offset))) {
$append .= ' OFFSET '.intval($offset);
}
$result = $this->db->prepare('groupName', $where, $append);
if ($result !== FALSE and $result->execute($params)) {
if ($result->rowCount() <= 0) {
User_WCF::warn('No groups returned from database.');
}
foreach ($result as $row) {
$groups[] = $row['groupName'];
}
$result->closeCursor();
}
else {
User_WCF::warn('Error executing statement to get group list.');
}
return $groups;
}
......
......@@ -21,14 +21,14 @@ class User_WCF extends \OC_User_Backend {
protected $db = NULL;
protected $dbUser, $dbHost, $dbPassword, $dbName;
public function __construct($wcfPath, $authorizedGroups, $useGroupBackend=TRUE) {
public function __construct() {
require(\OC_App::getAppPath('user_wcf').'/config/config.php');
if (!file_exists($wcfPath) || !is_dir($wcfPath)) throw new \Exception('Not a valid WCF path: "'.$wcfPath.'"');
$this->db = lib\WCF_DB::getInstance($wcfPath);
$this->db->setAuthorizedGroups($authorizedGroups);
if ($useGroupBackend) {
$groupBackend = new Group_WCF($wcfPath, $authorizedGroups);
\OC_Group::useBackend($groupBackend);
}
$groupBackend = new Group_WCF($wcfPath, $authorizedGroups);
\OC_Group::useBackend($groupBackend);
}
public function getSupportedActions() {
......@@ -57,11 +57,11 @@ class User_WCF extends \OC_User_Backend {
if ($doubleSalted === $row['password']) {
$authenticatedAs = $row['username'];
$this->info('User "'.$authenticatedAs.
$this->debug('User "'.$authenticatedAs.
'" logged in successfully.');
}
else {
$this->info('Invalid password for user '.$uid);
$this->info('Invalid password for user '.$uid.'.');
}
}
else {
......@@ -70,7 +70,7 @@ class User_WCF extends \OC_User_Backend {
$result->closeCursor();
}
else {
$this->info('Error while checking password for user '.$uid);
$this->warn('Error while checking password for user '.$uid);
}
return $authenticatedAs;
......@@ -106,12 +106,17 @@ class User_WCF extends \OC_User_Backend {
$result = $this->db->prepare('username', $where, $append);
if ($result !== FALSE and $result->execute($params)) {
$i = 0;
if ($result->rowCount() <= 0) {
$this->warn('No users returned from database.');
}
foreach ($result as $row) {
$users[] = $row['username'];
}
$result->closeCursor();
}
else {
$this->warn('Error executing statement to get user list.');
}
return $users;
}
......@@ -127,4 +132,21 @@ class User_WCF extends \OC_User_Backend {
public static function debug($text) {
\OCP\Util::writeLog('user_wcf', $text, \OCP\Util::DEBUG);
}
/**
* Backend name to be shown in user management
* @return string the name of the backend to be shown
*/
public function getBackendName(){
return 'WCF';
}
/**
* Check if a user list is available or not
* @return boolean if users can be listed or not
*/
public function hasUserListings() {
return true;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment