Exemple #1
0
 function testSingleBackend()
 {
     OC_Group::useBackend(new OCA\user_ldap\GROUP_LDAP());
     $group_ldap = new OCA\user_ldap\GROUP_LDAP();
     $this->assertIsA(OC_Group::getGroups(), gettype(array()));
     $this->assertIsA($group_ldap->getGroups(), gettype(array()));
     $this->assertFalse(OC_Group::inGroup('john', 'dosers'), gettype(false));
     $this->assertFalse($group_ldap->inGroup('john', 'dosers'), gettype(false));
     //TODO: check also for expected true result. This backend won't be able to do any modifications, maybe use a dummy for this.
     $this->assertIsA(OC_Group::getUserGroups('john doe'), gettype(array()));
     $this->assertIsA($group_ldap->getUserGroups('john doe'), gettype(array()));
     $this->assertIsA(OC_Group::usersInGroup('campers'), gettype(array()));
     $this->assertIsA($group_ldap->usersInGroup('campers'), gettype(array()));
 }
                 if (!is_array($emails)) {
                     $emails = array($emails);
                 }
                 foreach ($emails as $email) {
                     $result[] = array('id' => $contact['id'], 'email' => $email, 'displayname' => $contact['FN']);
                 }
             }
         }
     }
     OC_JSON::success(array('data' => $result));
     break;
 case 'getShareWith':
     if (isset($_GET['search'])) {
         $shareWithinGroupOnly = OC\Share\Share::shareWithGroupMembersOnly();
         $shareWith = array();
         $groups = OC_Group::getGroups((string) $_GET['search']);
         if ($shareWithinGroupOnly) {
             $usergroups = OC_Group::getUserGroups(OC_User::getUser());
             $groups = array_intersect($groups, $usergroups);
         }
         $count = 0;
         $users = array();
         $limit = 0;
         $offset = 0;
         while ($count < 15 && count($users) == $limit) {
             $limit = 15 - $count;
             if ($shareWithinGroupOnly) {
                 $users = OC_Group::DisplayNamesInGroups($usergroups, (string) $_GET['search'], $limit, $offset);
             } else {
                 $users = OC_User::getDisplayNames((string) $_GET['search'], $limit, $offset);
             }
Exemple #3
0
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
*/
OC_Util::checkAdminUser();
OCP\Util::addScript('files_external', 'settings');
OCP\Util::addscript('3rdparty', 'chosen/chosen.jquery.min');
OCP\Util::addStyle('files_external', 'settings');
OCP\Util::addStyle('3rdparty', 'chosen/chosen');
$backends = OC_Mount_Config::getBackends();
$personal_backends = array();
$enabled_backends = explode(',', OCP\Config::getAppValue('files_external', 'user_mounting_backends', ''));
foreach ($backends as $class => $backend) {
    if ($class != '\\OC\\Files\\Storage\\Local') {
        $personal_backends[$class] = array('backend' => $backend['backend'], 'enabled' => in_array($class, $enabled_backends));
    }
}
$tmpl = new OCP\Template('files_external', 'settings');
$tmpl->assign('isAdminPage', true);
$tmpl->assign('mounts', OC_Mount_Config::getSystemMountPoints());
$tmpl->assign('backends', $backends);
$tmpl->assign('personal_backends', $personal_backends);
$tmpl->assign('groups', OC_Group::getGroups());
$tmpl->assign('users', OCP\User::getUsers());
$tmpl->assign('userDisplayNames', OC_User::getDisplayNames());
$tmpl->assign('dependencies', OC_Mount_Config::checkDependencies());
$tmpl->assign('allowUserMounting', OCP\Config::getAppValue('files_external', 'allow_user_mounting', 'yes'));
return $tmpl->fetchPage();
Exemple #4
0
 /**
  * returns a list of groups
  */
 public static function getGroups($parameters)
 {
     return array('groups' => OC_Group::getGroups());
 }
Exemple #5
0
<?php

OCP\JSON::checkAppEnabled('files_external');
OCP\JSON::callCheck();
OCP\JSON::checkAdminUser();
$pattern = '';
$limit = null;
$offset = null;
if (isset($_GET['pattern'])) {
    $pattern = $_GET['pattern'];
}
if (isset($_GET['limit'])) {
    $limit = $_GET['limit'];
}
if (isset($_GET['offset'])) {
    $offset = $_GET['offset'];
}
$groups = \OC_Group::getGroups($pattern, $limit, $offset);
$users = \OCP\User::getDisplayNames($pattern, $limit, $offset);
$results = array('groups' => $groups, 'users' => $users);
\OCP\JSON::success($results);
Exemple #6
0
 // 						foreach ($vcards as $vcard) {
 // 							$contact = $vcard['fullname'];
 // 							if (stripos($contact, $_GET['search']) !== false
 // 								&& (!isset($_GET['itemShares'])
 // 								|| !isset($_GET['itemShares'][OCP\Share::SHARE_TYPE_CONTACT])
 // 								|| !is_array($_GET['itemShares'][OCP\Share::SHARE_TYPE_CONTACT])
 // 								|| !in_array($contact, $_GET['itemShares'][OCP\Share::SHARE_TYPE_CONTACT]))) {
 // 								$shareWith[] = array('label' => $contact, 'value' => array('shareType' => 5, 'shareWith' => $vcard['id']));
 // 							}
 // 						}
 // 					}
 // 				}
 if ($sharePolicy == 'groups_only') {
     $groups = OC_Group::getUserGroups(OC_User::getUser());
 } else {
     $groups = OC_Group::getGroups();
 }
 $count = 0;
 $users = array();
 $limit = 0;
 $offset = 0;
 while ($count < 4 && count($users) == $limit) {
     $limit = 4 - $count;
     if ($sharePolicy == 'groups_only') {
         $users = OC_Group::usersInGroups($groups, $_GET['search'], $limit, $offset);
     } else {
         $users = OC_User::getUsers($_GET['search'], $limit, $offset);
     }
     $offset += $limit;
     foreach ($users as $user) {
         if ((!isset($_GET['itemShares']) || !is_array($_GET['itemShares'][OCP\Share::SHARE_TYPE_USER]) || !in_array($user, $_GET['itemShares'][OCP\Share::SHARE_TYPE_USER])) && $user != OC_User::getUser()) {
Exemple #7
0
 public function testMultiBackend()
 {
     $userBackend = new \Test\Util\User\Dummy();
     \OC_User::getManager()->registerBackend($userBackend);
     $backend1 = new OC_Group_Dummy();
     $backend2 = new OC_Group_Dummy();
     OC_Group::useBackend($backend1);
     OC_Group::useBackend($backend2);
     $group1 = $this->getUniqueID();
     $group2 = $this->getUniqueID();
     OC_Group::createGroup($group1);
     //groups should be added to the first registered backend
     $this->assertEquals(array($group1), $backend1->getGroups());
     $this->assertEquals(array(), $backend2->getGroups());
     $this->assertEquals(array($group1), OC_Group::getGroups());
     $this->assertTrue(OC_Group::groupExists($group1));
     $this->assertFalse(OC_Group::groupExists($group2));
     $backend1->createGroup($group2);
     $this->assertEquals(array($group1, $group2), OC_Group::getGroups());
     $this->assertTrue(OC_Group::groupExists($group1));
     $this->assertTrue(OC_Group::groupExists($group2));
     $user1 = $this->getUniqueID();
     $user2 = $this->getUniqueID();
     $userBackend->createUser($user1, '');
     $userBackend->createUser($user2, '');
     $this->assertFalse(OC_Group::inGroup($user1, $group1));
     $this->assertFalse(OC_Group::inGroup($user2, $group1));
     $this->assertTrue(OC_Group::addToGroup($user1, $group1));
     $this->assertTrue(OC_Group::inGroup($user1, $group1));
     $this->assertFalse(OC_Group::inGroup($user2, $group1));
     $this->assertFalse($backend2->inGroup($user1, $group1));
     OC_Group::addToGroup($user1, $group1);
     $this->assertEquals(array($user1), OC_Group::usersInGroup($group1));
     $this->assertEquals(array($group1), OC_Group::getUserGroups($user1));
     $this->assertEquals(array(), OC_Group::getUserGroups($user2));
     OC_Group::deleteGroup($group1);
     $this->assertEquals(array(), OC_Group::getUserGroups($user1));
     $this->assertEquals(array(), OC_Group::usersInGroup($group1));
     $this->assertFalse(OC_Group::inGroup($user1, $group1));
 }
Exemple #8
0
 * This file is licensed under the Affero General Public License version 3 or later.
 * See the COPYING-README file.
 */
OC_Util::checkSubAdminUser();
OC_App::loadApps();
// We have some javascript foo!
OC_Util::addScript('settings', 'users');
OC_Util::addScript('core', 'multiselect');
OC_Util::addScript('core', 'jquery.inview');
OC_Util::addStyle('settings', 'settings');
OC_App::setActiveNavigationEntry('core_users');
$users = array();
$groups = array();
$isadmin = OC_Group::inGroup(OC_User::getUser(), 'admin') ? true : false;
if ($isadmin) {
    $accessiblegroups = OC_Group::getGroups();
    $accessibleusers = OC_User::getUsers('', 30);
    $subadmins = OC_SubAdmin::getAllSubAdmins();
} else {
    $accessiblegroups = OC_SubAdmin::getSubAdminsGroups(OC_User::getUser());
    $accessibleusers = OC_Group::usersInGroups($accessiblegroups, '', 30);
    $subadmins = false;
}
foreach ($accessibleusers as $i) {
    $users[] = array("name" => $i, "groups" => join(", ", OC_Group::getUserGroups($i)), 'quota' => OC_Preferences::getValue($i, 'files', 'quota', 'default'), 'subadmin' => implode(', ', OC_SubAdmin::getSubAdminsGroups($i)));
}
foreach ($accessiblegroups as $i) {
    // Do some more work here soon
    $groups[] = array("name" => $i);
}
$quotaPreset = OC_Appconfig::getValue('files', 'quota_preset', 'default,none,1 GB, 5 GB, 10 GB');
<?php

// Init owncloud
require_once '../../lib/base.php';
// Check if we are a user
if (!OC_User::isLoggedIn() || !OC_Group::inGroup(OC_User::getUser(), 'admin')) {
    OC_JSON::error(array("data" => array("message" => "Authentication error")));
    exit;
}
$groupname = $_POST["groupname"];
// Does the group exist?
if (in_array($groupname, OC_Group::getGroups())) {
    OC_JSON::error(array("data" => array("message" => "Group already exists")));
    exit;
}
// Return Success story
if (OC_Group::createGroup($groupname)) {
    OC_JSON::success(array("data" => array("groupname" => $groupname)));
} else {
    OC_JSON::error(array("data" => array("message" => "Unable to add group")));
}
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
*
*/
$RUNTIME_NOAPPS = TRUE;
//no apps, yet
require_once '../../lib/base.php';
if (!OC_User::isLoggedIn()) {
    if (!isset($_SERVER['PHP_AUTH_USER'])) {
        header('WWW-Authenticate: Basic realm="ownCloud Server"');
        header('HTTP/1.0 401 Unauthorized');
        echo 'Valid credentials must be supplied';
        exit;
    } else {
        if (!OC_User::checkPassword($_SERVER["PHP_AUTH_USER"], $_SERVER["PHP_AUTH_PW"])) {
            exit;
        }
    }
}
$groups = array();
foreach (OC_Group::getGroups() as $i) {
    // Do some more work here soon
    $groups[] = array("groupname" => $i);
}
OC_JSON::encodedPrint($groups);
Exemple #11
0
 // 					$ids = OC_Contacts_Addressbook::activeIds();
 // 					foreach ($ids as $id) {
 // 						$vcards = OC_Contacts_VCard::all($id);
 // 						foreach ($vcards as $vcard) {
 // 							$contact = $vcard['fullname'];
 // 							if (stripos($contact, $_GET['search']) !== false
 // 								&& (!isset($_GET['itemShares'])
 // 								|| !isset($_GET['itemShares'][OCP\Share::SHARE_TYPE_CONTACT])
 // 								|| !is_array($_GET['itemShares'][OCP\Share::SHARE_TYPE_CONTACT])
 // 								|| !in_array($contact, $_GET['itemShares'][OCP\Share::SHARE_TYPE_CONTACT]))) {
 // 								$shareWith[] = array('label' => $contact, 'value' => array('shareType' => 5, 'shareWith' => $vcard['id']));
 // 							}
 // 						}
 // 					}
 // 				}
 $groups = OC_Group::getGroups($_GET['search']);
 if ($sharePolicy == 'groups_only') {
     $usergroups = OC_Group::getUserGroups(OC_User::getUser());
     $groups = array_intersect($groups, $usergroups);
 }
 $count = 0;
 $users = array();
 $limit = 0;
 $offset = 0;
 while ($count < 15 && count($users) == $limit) {
     $limit = 15 - $count;
     if ($sharePolicy == 'groups_only') {
         $users = OC_Group::DisplayNamesInGroups($usergroups, $_GET['search'], $limit, $offset);
     } else {
         $users = OC_User::getDisplayNames($_GET['search'], $limit, $offset);
     }
Exemple #12
0
$tmpl->assign('internetconnectionworking', OC_Util::isInternetConnectionEnabled() ? OC_Util::isInternetConnectionWorking() : false);
$tmpl->assign('isLocaleWorking', OC_Util::isSetLocaleWorking());
$tmpl->assign('isAnnotationsWorking', OC_Util::isAnnotationsWorking());
$tmpl->assign('isWebDavWorking', OC_Util::isWebDAVWorking());
$tmpl->assign('has_fileinfo', OC_Util::fileInfoLoaded());
$tmpl->assign('old_php', OC_Util::isPHPoutdated());
$tmpl->assign('backgroundjobs_mode', OC_Appconfig::getValue('core', 'backgroundjobs_mode', 'ajax'));
$tmpl->assign('cron_log', OC_Config::getValue('cron_log', true));
$tmpl->assign('lastcron', OC_Appconfig::getValue('core', 'lastcron', false));
$tmpl->assign('shareAPIEnabled', OC_Appconfig::getValue('core', 'shareapi_enabled', 'yes'));
$tmpl->assign('shareDefaultExpireDateSet', OC_Appconfig::getValue('core', 'shareapi_default_expire_date', 'no'));
$tmpl->assign('shareExpireAfterNDays', OC_Appconfig::getValue('core', 'shareapi_expire_after_n_days', '7'));
$tmpl->assign('shareEnforceExpireDate', OC_Appconfig::getValue('core', 'shareapi_enforce_expire_date', 'no'));
$excludeGroups = OC_Appconfig::getValue('core', 'shareapi_exclude_groups', 'no') === 'yes' ? true : false;
$tmpl->assign('shareExcludeGroups', $excludeGroups);
$allGroups =  OC_Group::getGroups();
$excludedGroupsList = OC_Appconfig::getValue('core', 'shareapi_exclude_groups_list', '');
$excludedGroups = $excludedGroupsList !== '' ? explode(',', $excludedGroupsList) : array();
$groups = array();
foreach ($allGroups as $group) {
	if (in_array($group, $excludedGroups)) {
		$groups[$group] = array('gid' => $group,
			'excluded' => true);
	} else {
		$groups[$group] = array('gid' => $group,
			'excluded' => false);
	}
}
ksort($groups);
$tmpl->assign('groups', $groups);
Exemple #13
0
 function testMultiBackend()
 {
     $backend1 = new OC_Group_Dummy();
     $backend2 = new OC_Group_Dummy();
     OC_Group::useBackend($backend1);
     OC_Group::useBackend($backend2);
     $group1 = uniqid();
     $group2 = uniqid();
     OC_Group::createGroup($group1);
     //groups should be added to the first registered backend
     $this->assertEqual(array($group1), $backend1->getGroups());
     $this->assertEqual(array(), $backend2->getGroups());
     $this->assertEqual(array($group1), OC_Group::getGroups());
     $this->assertTrue(OC_Group::groupExists($group1));
     $this->assertFalse(OC_Group::groupExists($group2));
     $backend1->createGroup($group2);
     $this->assertEqual(array($group1, $group2), OC_Group::getGroups());
     $this->assertTrue(OC_Group::groupExists($group1));
     $this->assertTrue(OC_Group::groupExists($group2));
     $user1 = uniqid();
     $user2 = uniqid();
     $this->assertFalse(OC_Group::inGroup($user1, $group1));
     $this->assertFalse(OC_Group::inGroup($user2, $group1));
     $this->assertTrue(OC_Group::addToGroup($user1, $group1));
     $this->assertTrue(OC_Group::inGroup($user1, $group1));
     $this->assertFalse(OC_Group::inGroup($user2, $group1));
     $this->assertFalse($backend2->inGroup($user1, $group1));
     $this->assertFalse(OC_Group::addToGroup($user1, $group1));
     $this->assertEqual(array($user1), OC_Group::usersInGroup($group1));
     $this->assertEqual(array($group1), OC_Group::getUserGroups($user1));
     $this->assertEqual(array(), OC_Group::getUserGroups($user2));
     OC_Group::deleteGroup($group1);
     $this->assertEqual(array(), OC_Group::getUserGroups($user1));
     $this->assertEqual(array(), OC_Group::usersInGroup($group1));
     $this->assertFalse(OC_Group::inGroup($user1, $group1));
 }