Skip to content
This repository has been archived by the owner on Jul 7, 2022. It is now read-only.

Commit

Permalink
Merge CodeIgniter RestFul
Browse files Browse the repository at this point in the history
Merge CodeIgniter RestFul
  • Loading branch information
ebencarljo committed Jun 30, 2016
1 parent 3b2f818 commit fcca64b
Show file tree
Hide file tree
Showing 10 changed files with 175 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ application/modules/*
!application/modules/blog/
!application/modules/pingback_trackback/
!application/modules/theme_mod/
!application/modules/codeigniter_restful/

application/controllers/*
!application/controllers/Page_404.php
Expand Down
74 changes: 74 additions & 0 deletions application/modules/codeigniter_restful/CodeIgniter_restful.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php
class Nexo_Restful extends CI_Model
{
public function __construct()
{
parent::__construct();
$this->events->add_action('tendoo_settings_tables', array( $this, 'sql' ));
$this->events->add_action('do_enable_module', array( $this, 'enable' ));
$this->events->add_action('do_remove_module', array( $this, 'remove' ));
}

/**
* Enable
**/

public function enable($module)
{
global $Options;
if ($module == 'codeigniter_restful' && @$Options[ 'codeigniter_restful_installed' ] == null) {
$this->sql();
$this->options->set('codeigniter_restful_installed', true, true);
}
}

public function remove($module)
{
if ($module == 'codeigniter_restful') {
$this->db->query('DROP TABLE IF EXISTS `'.$this->db->dbprefix.'restapi_keys`;');
$this->options->delete('codeigniter_restful_installed');
}
}

/**
* Keys table
**/

public function sql()
{
global $CurrentScreen;
if ($CurrentScreen != 'dashboard') {
// Enable Me
Modules::enable('codeigniter_restful');
}
$this->db->query('
CREATE TABLE IF NOT EXISTS `' . $this->db->dbprefix . 'restapi_keys` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`key` VARCHAR(40) NOT NULL,
`scopes` text,
`app_name` VARCHAR(40) NOT NULL,
`level` INT(2) NOT NULL,
`ignore_limits` TINYINT(1) NOT NULL DEFAULT "0",
`user` INT(11) NOT NULL,
`date_created` DATETIME NOT NULL,
`expire` INT(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;');

$randomString = $this->oauthlibrary->generateKey();

$this->db->insert('restapi_keys', array(
'key' => $randomString,
'scopes' => 'core',
'app_name' => __('Tendoo CMS'),
'user' => 0,
'date_created' => date_now(),
'expire' => 0
));

// Save Core Key
$this->options->set('rest_key', $randomString, true);
}
}

new Nexo_Restful;
3 changes: 3 additions & 0 deletions application/modules/codeigniter_restful/changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
v1.5
====
- Enable module while installing Tendoo CMS.
11 changes: 11 additions & 0 deletions application/modules/codeigniter_restful/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<application>
<details>
<name>CodeIgniter Restful</name>
<namespace>codeigniter_restful</namespace>
<version>1.5</version>
<author>Blair Jersyer</author>
<main>CodeIgniter_restful.php</main>
<description>A fully RESTful server implementation for CodeIgniter using one library, one config file and one controller.</description>
</details>
</application>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

/*
* Bulgarian language
*/

$lang['text_rest_invalid_api_key'] = 'Невалиден API ключ %s';
$lang['text_rest_invalid_credentials'] = 'Невалидни данни за достъп';
$lang['text_rest_ip_denied'] = 'Отказан IP адрес';
$lang['text_rest_ip_unauthorized'] = 'Неоторизиран IP адрес';
$lang['text_rest_unauthorized'] = 'Неоторизиран достъп';
$lang['text_rest_ajax_only'] = 'Само AJAX заявки са разрешени';
$lang['text_rest_api_key_unauthorized'] = 'API ключът не е оторизиран зо достъп до заявения контролер';
$lang['text_rest_api_key_permissions'] = 'API ключът няма достатъчно права';
$lang['text_rest_api_key_time_limit'] = 'API ключът е изполван с превишаване на времевия лимит за този метод';
$lang['text_rest_unknown_method'] = 'Неизвестен метод';
$lang['text_rest_unsupported'] = 'Неподдържан протокол';
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

/*
* English language
*/

$lang['text_rest_invalid_api_key'] = 'Invalid API key %s'; // %s is the REST API key
$lang['text_rest_invalid_credentials'] = 'Invalid credentials';
$lang['text_rest_ip_denied'] = 'IP denied';
$lang['text_rest_ip_unauthorized'] = 'IP unauthorized';
$lang['text_rest_unauthorized'] = 'Unauthorized';
$lang['text_rest_ajax_only'] = 'Only AJAX requests are allowed';
$lang['text_rest_api_key_unauthorized'] = 'This API key does not have access to the requested controller';
$lang['text_rest_api_key_permissions'] = 'This API key does not have enough permissions';
$lang['text_rest_api_key_time_limit'] = 'This API key has reached the time limit for this method';
$lang['text_rest_unknown_method'] = 'Unknown method';
$lang['text_rest_unsupported'] = 'Unsupported protocol';
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

/*
* French language
*/

$lang['text_rest_invalid_api_key'] = 'La clef d\'API %s est invalide'; // %s is the REST API key
$lang['text_rest_invalid_credentials'] = 'Authentification invalide';
$lang['text_rest_ip_denied'] = 'IP refusée';
$lang['text_rest_ip_unauthorized'] = 'IP non-autorisée';
$lang['text_rest_unauthorized'] = 'Non autorisé';
$lang['text_rest_ajax_only'] = 'Seul les requêtes AJAX sont autorisées';
$lang['text_rest_api_key_unauthorized'] = 'Cette clef d\'API n\'a pas accès au contrôleur demandé';
$lang['text_rest_api_key_permissions'] = 'Cette clef d\'API n\'a pas les permissions requises';
$lang['text_rest_api_key_time_limit'] = 'Cette clef d\'API a atteint sa limite de temps pour cette méthode';
$lang['text_rest_unknown_method'] = 'Méthode inconnue';
$lang['text_rest_unsupported'] = 'Protocole non-supporté';
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

/*
* Brazilian portuguese language
*/

$lang['text_rest_invalid_api_key'] = 'Chave da API %s inválida'; // %s is the REST API key
$lang['text_rest_invalid_credentials'] = 'Credenciais inválidas';
$lang['text_rest_ip_denied'] = 'IP proibido';
$lang['text_rest_ip_unauthorized'] = 'IP não autorizado';
$lang['text_rest_unauthorized'] = 'Não autorizado';
$lang['text_rest_ajax_only'] = 'Apenas chamadas AJAX são permitidas';
$lang['text_rest_api_key_unauthorized'] = 'Esta chave da API não tem acesso ao controller solicitado';
$lang['text_rest_api_key_permissions'] = 'Esta chave da API não tem permissões suficientes';
$lang['text_rest_api_key_time_limit'] = 'Esta chave da API já atingiu o tempo limite para este método';
$lang['text_rest_unknown_method'] = 'Método desconhecido';
$lang['text_rest_unsupported'] = 'Sem suporte para este protocolo';
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

/*
* Spanish language
*/

$lang['text_rest_invalid_api_key'] = 'API key %s No valida'; // %s is the REST API key
$lang['text_rest_invalid_credentials'] = 'Credenciales Invalidas';
$lang['text_rest_ip_denied'] = 'IP denegada';
$lang['text_rest_ip_unauthorized'] = 'IP no autorizada';
$lang['text_rest_unauthorized'] = 'Acceso no autorizado';
$lang['text_rest_ajax_only'] = 'Solo peticiones ajax permitidas';
$lang['text_rest_api_key_unauthorized'] = 'This API key does not have access to the requested controller';
$lang['text_rest_api_key_permissions'] = 'This API key does not have enough permissions';
$lang['text_rest_api_key_time_limit'] = 'This API key has reached the time limit for this method';
$lang['text_rest_unknown_method'] = 'metodo desconocido';
$lang['text_rest_unsupported'] = 'Protocolo no soportado';
1 change: 1 addition & 0 deletions application/modules/codeigniter_restful/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["D:\/xampp\/htdocs\/nexopos\/application\/config\/rest.php","D:\/xampp\/htdocs\/nexopos\/application\/controllers\/api\/Example.php","D:\/xampp\/htdocs\/nexopos\/application\/controllers\/api\/index.html","D:\/xampp\/htdocs\/nexopos\/application\/controllers\/api\/Key.php","D:\/xampp\/htdocs\/nexopos\/application\/controllers\/Rest.php","D:\/xampp\/htdocs\/nexopos\/application\/libraries\/Format.php","D:\/xampp\/htdocs\/nexopos\/application\/libraries\/REST_Controller.php"]

0 comments on commit fcca64b

Please sign in to comment.