-
-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from alexweissman/butterflyknife
merge changes for group api
- Loading branch information
Showing
13 changed files
with
429 additions
and
395 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
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 |
---|---|---|
@@ -1,65 +1,70 @@ | ||
<?php | ||
/* | ||
UserFrosting Version: 0.1 | ||
By Alex Weissman | ||
Copyright (c) 2014 | ||
Based on the UserCake user management system, v2.0.2. | ||
Copyright (c) 2009-2012 | ||
UserFrosting, like UserCake, is 100% free and open-source. | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the 'Software'), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
*/ | ||
|
||
// Request method: GET | ||
|
||
include('../models/db-settings.php'); | ||
include('../models/config.php'); | ||
|
||
set_error_handler('logAllErrors'); | ||
|
||
// User must be logged in | ||
if (!isUserLoggedIn()){ | ||
addAlert("danger", "You must be logged in to access this resource."); | ||
echo json_encode(array("errors" => 1, "successes" => 0)); | ||
exit(); | ||
} | ||
|
||
// GET Parameters: [user_id] | ||
$validator = new Validator(); | ||
$user_id = $validator->optionalGetVar('user_id'); | ||
|
||
// If no user_id is specified, use the id of the currently logged in user. | ||
if (!$user_id){ | ||
$user_id = $loggedInUser->user_id; | ||
} | ||
|
||
// Attempt to load information for the specified user. | ||
if (!($results = loadUserGroups($user_id))){ | ||
echo json_encode(array("errors" => 1, "successes" => 0)); | ||
exit(); | ||
} | ||
|
||
restore_error_handler(); | ||
|
||
echo json_encode($results); | ||
|
||
?> | ||
<?php | ||
/* | ||
UserFrosting Version: 0.2.0 | ||
By Alex Weissman | ||
Copyright (c) 2014 | ||
Based on the UserCake user management system, v2.0.2. | ||
Copyright (c) 2009-2012 | ||
UserFrosting, like UserCake, is 100% free and open-source. | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the 'Software'), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
*/ | ||
|
||
require_once("../models/config.php"); | ||
|
||
set_error_handler('logAllErrors'); | ||
|
||
// User must be logged in | ||
if (!isUserLoggedIn()){ | ||
addAlert("danger", "You must be logged in to access this resource."); | ||
echo json_encode(array("errors" => 1, "successes" => 0)); | ||
exit(); | ||
} | ||
|
||
// TODO: accept home page ids, is_default, and can_delete | ||
|
||
$validator = new Validator(); | ||
$group_name = $validator->requiredPostVar('group_name'); | ||
|
||
//Forms posted | ||
if($group_name) { | ||
if (!createGroup($group_name)){ | ||
echo json_encode(array("errors" => 1, "successes" => 0)); | ||
exit(); | ||
} | ||
} else { | ||
addAlert("danger", lang("PERMISSION_CHAR_LIMIT", array(1, 50))); | ||
echo json_encode(array("errors" => 1, "successes" => 0)); | ||
exit(); | ||
} | ||
|
||
restore_error_handler(); | ||
|
||
if (isset($_POST['ajaxMode']) and $_POST['ajaxMode'] == "true" ){ | ||
echo json_encode(array( | ||
"errors" => 0, | ||
"successes" => 1)); | ||
} else { | ||
header('Location: ' . getReferralPage()); | ||
exit(); | ||
} | ||
?> |
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
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
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
Oops, something went wrong.