add bookmarks api and iimports, bugfixes
This commit is contained in:
59
app/plugins/bookmarks/controllers/api/bookmarks.php
Normal file
59
app/plugins/bookmarks/controllers/api/bookmarks.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* app/plugins/bookmarks/controllers/api/bookmarks.php
|
||||
*
|
||||
* This is the api bookmarks controller.
|
||||
*
|
||||
* @version 3.0
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Controllers\Api;
|
||||
|
||||
use TheTempusProject\Models\User;
|
||||
use TheTempusProject\Classes\ApiController;
|
||||
use TheTempusProject\Houdini\Classes\Views;
|
||||
use TheTempusProject\Canary\Bin\Canary as Debug;
|
||||
use TheTempusProject\Bedrock\Functions\Input;
|
||||
use TheTempusProject\Models\Bookmarks as Bookmark;
|
||||
|
||||
class Bookmarks extends ApiController {
|
||||
protected static $bookmarks;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
self::$bookmarks = new Bookmark;
|
||||
}
|
||||
|
||||
public function create() {
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
|
||||
$user = self::$authToken->createdBy;
|
||||
|
||||
$payload = @file_get_contents('php://input');
|
||||
$payload = json_decode( $payload, true );
|
||||
Debug::error($payload['name']);
|
||||
|
||||
$result = self::$bookmarks->create(
|
||||
$payload['name'],
|
||||
$payload['url'],
|
||||
0,
|
||||
$payload['notes'],
|
||||
'default',
|
||||
'private',
|
||||
'external',
|
||||
$user
|
||||
);
|
||||
|
||||
if ( ! $result ) {
|
||||
$responseType = 'error';
|
||||
$response = 'There was an error creating your bookmark.';
|
||||
} else {
|
||||
$responseType = 'success';
|
||||
$response = 'success';
|
||||
}
|
||||
Views::view( 'api.response', ['response' => json_encode( [ $responseType => $response ], true )]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user