creategroup.php 695 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. // Init owncloud
  3. require_once('../../lib/base.php');
  4. // Check if we are a user
  5. if( !OC_User::isLoggedIn() || !OC_Group::inGroup( OC_User::getUser(), 'admin' )){
  6. OC_JSON::error(array("data" => array( "message" => "Authentication error" )));
  7. exit();
  8. }
  9. $groupname = $_POST["groupname"];
  10. // Does the group exist?
  11. if( in_array( $groupname, OC_Group::getGroups())){
  12. OC_JSON::error(array("data" => array( "message" => "Group already exists" )));
  13. exit();
  14. }
  15. // Return Success story
  16. if( OC_Group::createGroup( $groupname )){
  17. OC_JSON::success(array("data" => array( "groupname" => $groupname )));
  18. }
  19. else{
  20. OC_JSON::error(array("data" => array( "message" => "Unable to add group" )));
  21. }
  22. ?>