Copyright in modulebuilder
This commit is contained in:
parent
7e6e0ee3a4
commit
22fabe5a3a
@ -51,6 +51,7 @@ $dirins = $tmp[0];
|
|||||||
|
|
||||||
$FILEFLAG='modulebuilder.txt';
|
$FILEFLAG='modulebuilder.txt';
|
||||||
|
|
||||||
|
$now=dol_now();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
@ -106,7 +107,7 @@ if ($dirins && $action == 'initmodule' && $modulename)
|
|||||||
// Edit PHP files
|
// Edit PHP files
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
$listofphpfilestoedit = dol_dir_list($destdir, 'files', 1, '\.(php|MD|js)$', '', 'fullname', SORT_ASC, 0, 1);
|
$listofphpfilestoedit = dol_dir_list($destdir, 'files', 1, '\.(php|MD|js|sql|txt|xml|lang)$', '', 'fullname', SORT_ASC, 0, 1);
|
||||||
foreach($listofphpfilestoedit as $phpfileval)
|
foreach($listofphpfilestoedit as $phpfileval)
|
||||||
{
|
{
|
||||||
//var_dump($phpfileval['fullname']);
|
//var_dump($phpfileval['fullname']);
|
||||||
@ -116,7 +117,8 @@ if ($dirins && $action == 'initmodule' && $modulename)
|
|||||||
'MYMODULE'=>strtoupper($modulename),
|
'MYMODULE'=>strtoupper($modulename),
|
||||||
'My module'=>$modulename,
|
'My module'=>$modulename,
|
||||||
'htdocs/modulebuilder/template/'=>'',
|
'htdocs/modulebuilder/template/'=>'',
|
||||||
);
|
'---Put here your own copyright and developer email---'=>dol_print_date($now,'%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'')
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
$result=dolReplaceInFile($phpfileval['fullname'], $arrayreplacement);
|
$result=dolReplaceInFile($phpfileval['fullname'], $arrayreplacement);
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/* <one line to give the program's name and a brief idea of what it does.>
|
/* Copyright (C) ---Put here your own copyright and developer email---
|
||||||
* Copyright (C) <year> <name of author>
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/* <one line to give the program's name and a brief idea of what it does.>
|
/* Copyright (C) ---Put here your own copyright and developer email---
|
||||||
* Copyright (C) <year> <name of author>
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/* <one line to give the program's name and a brief idea of what it does.>
|
/* Copyright (C) ---Put here your own copyright and developer email---
|
||||||
* Copyright (C) <year> <name of author>
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
/* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||||
|
* Copyright (C) ---Put here your own copyright and developer email---
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -22,18 +23,18 @@ use Luracast\Restler\RestException;
|
|||||||
* \ingroup mymodule
|
* \ingroup mymodule
|
||||||
* \brief File for API management of myobject.
|
* \brief File for API management of myobject.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API class for mymodule myobject
|
* API class for mymodule myobject
|
||||||
*
|
*
|
||||||
* @smart-auto-routing false
|
* @smart-auto-routing false
|
||||||
* @access protected
|
* @access protected
|
||||||
* @class DolibarrApiAccess {@requires user,external}
|
* @class DolibarrApiAccess {@requires user,external}
|
||||||
*/
|
*/
|
||||||
class MyObjectApi extends DolibarrApi
|
class MyObjectApi extends DolibarrApi
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var array $FIELDS Mandatory fields, checked when create and update object
|
* @var array $FIELDS Mandatory fields, checked when create and update object
|
||||||
*/
|
*/
|
||||||
static $FIELDS = array(
|
static $FIELDS = array(
|
||||||
'name'
|
'name'
|
||||||
@ -48,7 +49,7 @@ class MyObjectApi extends DolibarrApi
|
|||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @url GET myobject/
|
* @url GET myobject/
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function __construct()
|
function __construct()
|
||||||
{
|
{
|
||||||
@ -64,21 +65,21 @@ class MyObjectApi extends DolibarrApi
|
|||||||
*
|
*
|
||||||
* @param int $id ID of myobject
|
* @param int $id ID of myobject
|
||||||
* @return array|mixed data without useless information
|
* @return array|mixed data without useless information
|
||||||
*
|
*
|
||||||
* @url GET myobject/{id}
|
* @url GET myobject/{id}
|
||||||
* @throws RestException
|
* @throws RestException
|
||||||
*/
|
*/
|
||||||
function get($id)
|
function get($id)
|
||||||
{
|
{
|
||||||
if(! DolibarrApiAccess::$user->rights->myobject->read) {
|
if(! DolibarrApiAccess::$user->rights->myobject->read) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->myobject->fetch($id);
|
$result = $this->myobject->fetch($id);
|
||||||
if( ! $result ) {
|
if( ! $result ) {
|
||||||
throw new RestException(404, 'MyObject not found');
|
throw new RestException(404, 'MyObject not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! DolibarrApi::_checkAccessToResource('myobject',$this->myobject->id)) {
|
if( ! DolibarrApi::_checkAccessToResource('myobject',$this->myobject->id)) {
|
||||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
}
|
}
|
||||||
@ -88,9 +89,9 @@ class MyObjectApi extends DolibarrApi
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* List myobjects
|
* List myobjects
|
||||||
*
|
*
|
||||||
* Get a list of myobjects
|
* Get a list of myobjects
|
||||||
*
|
*
|
||||||
* @param int $mode Use this param to filter list
|
* @param int $mode Use this param to filter list
|
||||||
* @param string $sortfield Sort field
|
* @param string $sortfield Sort field
|
||||||
* @param string $sortorder Sort order
|
* @param string $sortorder Sort order
|
||||||
@ -103,22 +104,22 @@ class MyObjectApi extends DolibarrApi
|
|||||||
*/
|
*/
|
||||||
function index($mode, $sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $sqlfilters = '') {
|
function index($mode, $sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $sqlfilters = '') {
|
||||||
global $db, $conf;
|
global $db, $conf;
|
||||||
|
|
||||||
$obj_ret = array();
|
$obj_ret = array();
|
||||||
|
|
||||||
$socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : '';
|
$socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : '';
|
||||||
|
|
||||||
// If the internal user must only see his customers, force searching by him
|
// If the internal user must only see his customers, force searching by him
|
||||||
if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id;
|
if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id;
|
||||||
|
|
||||||
$sql = "SELECT s.rowid";
|
$sql = "SELECT s.rowid";
|
||||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
|
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."myobject as s";
|
$sql.= " FROM ".MAIN_DB_PREFIX."myobject as s";
|
||||||
|
|
||||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
|
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st";
|
$sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st";
|
||||||
$sql.= " WHERE s.fk_stcomm = st.id";
|
$sql.= " WHERE s.fk_stcomm = st.id";
|
||||||
|
|
||||||
// Example of use $mode
|
// Example of use $mode
|
||||||
//if ($mode == 1) $sql.= " AND s.client IN (1, 3)";
|
//if ($mode == 1) $sql.= " AND s.client IN (1, 3)";
|
||||||
//if ($mode == 2) $sql.= " AND s.client IN (2, 3)";
|
//if ($mode == 2) $sql.= " AND s.client IN (2, 3)";
|
||||||
@ -175,13 +176,13 @@ class MyObjectApi extends DolibarrApi
|
|||||||
}
|
}
|
||||||
return $obj_ret;
|
return $obj_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create myobject object
|
* Create myobject object
|
||||||
*
|
*
|
||||||
* @param array $request_data Request datas
|
* @param array $request_data Request datas
|
||||||
* @return int ID of myobject
|
* @return int ID of myobject
|
||||||
*
|
*
|
||||||
* @url POST myobject/
|
* @url POST myobject/
|
||||||
*/
|
*/
|
||||||
function post($request_data = NULL)
|
function post($request_data = NULL)
|
||||||
@ -191,7 +192,7 @@ class MyObjectApi extends DolibarrApi
|
|||||||
}
|
}
|
||||||
// Check mandatory fields
|
// Check mandatory fields
|
||||||
$result = $this->_validate($request_data);
|
$result = $this->_validate($request_data);
|
||||||
|
|
||||||
foreach($request_data as $field => $value) {
|
foreach($request_data as $field => $value) {
|
||||||
$this->myobject->$field = $value;
|
$this->myobject->$field = $value;
|
||||||
}
|
}
|
||||||
@ -205,9 +206,9 @@ class MyObjectApi extends DolibarrApi
|
|||||||
* Update myobject
|
* Update myobject
|
||||||
*
|
*
|
||||||
* @param int $id Id of myobject to update
|
* @param int $id Id of myobject to update
|
||||||
* @param array $request_data Datas
|
* @param array $request_data Datas
|
||||||
* @return int
|
* @return int
|
||||||
*
|
*
|
||||||
* @url PUT myobject/{id}
|
* @url PUT myobject/{id}
|
||||||
*/
|
*/
|
||||||
function put($id, $request_data = NULL)
|
function put($id, $request_data = NULL)
|
||||||
@ -215,12 +216,12 @@ class MyObjectApi extends DolibarrApi
|
|||||||
if(! DolibarrApiAccess::$user->rights->myobject->create) {
|
if(! DolibarrApiAccess::$user->rights->myobject->create) {
|
||||||
throw new RestException(401);
|
throw new RestException(401);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->myobject->fetch($id);
|
$result = $this->myobject->fetch($id);
|
||||||
if( ! $result ) {
|
if( ! $result ) {
|
||||||
throw new RestException(404, 'MyObject not found');
|
throw new RestException(404, 'MyObject not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! DolibarrApi::_checkAccessToResource('myobject',$this->myobject->id)) {
|
if( ! DolibarrApi::_checkAccessToResource('myobject',$this->myobject->id)) {
|
||||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
}
|
}
|
||||||
@ -228,19 +229,19 @@ class MyObjectApi extends DolibarrApi
|
|||||||
foreach($request_data as $field => $value) {
|
foreach($request_data as $field => $value) {
|
||||||
$this->myobject->$field = $value;
|
$this->myobject->$field = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->myobject->update($id, DolibarrApiAccess::$user))
|
if($this->myobject->update($id, DolibarrApiAccess::$user))
|
||||||
return $this->get ($id);
|
return $this->get ($id);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete myobject
|
* Delete myobject
|
||||||
*
|
*
|
||||||
* @param int $id MyObject ID
|
* @param int $id MyObject ID
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
* @url DELETE myobject/{id}
|
* @url DELETE myobject/{id}
|
||||||
*/
|
*/
|
||||||
function delete($id)
|
function delete($id)
|
||||||
@ -252,31 +253,31 @@ class MyObjectApi extends DolibarrApi
|
|||||||
if( ! $result ) {
|
if( ! $result ) {
|
||||||
throw new RestException(404, 'MyObject not found');
|
throw new RestException(404, 'MyObject not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! DolibarrApi::_checkAccessToResource('myobject',$this->myobject->id)) {
|
if( ! DolibarrApi::_checkAccessToResource('myobject',$this->myobject->id)) {
|
||||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !$this->myobject->delete($id))
|
if( !$this->myobject->delete($id))
|
||||||
{
|
{
|
||||||
throw new RestException(500);
|
throw new RestException(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'success' => array(
|
'success' => array(
|
||||||
'code' => 200,
|
'code' => 200,
|
||||||
'message' => 'MyObject deleted'
|
'message' => 'MyObject deleted'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate fields before create or update object
|
* Validate fields before create or update object
|
||||||
*
|
*
|
||||||
* @param array $data Data to validate
|
* @param array $data Data to validate
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
* @throws RestException
|
* @throws RestException
|
||||||
*/
|
*/
|
||||||
function _validate($data)
|
function _validate($data)
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/* <one line to give the program's name and a brief idea of what it does.>
|
/* Copyright (C) ---Put here your own copyright and developer email---
|
||||||
* Copyright (C) <year> <name of author>
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) ---Put here your own copyright and developer email---
|
||||||
* Copyright (C) 2005-2016 Regis Houssin <regis.houssin@capnetworks.com>
|
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/* <one line to give the program's name and a brief idea of what it does.>
|
/* Copyright (C) ---Put here your own copyright and developer email---
|
||||||
* Copyright (C) <year> <name of author>
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/* <one line to give the program's name and a brief idea of what it does.>
|
/* Copyright (C) ---Put here your own copyright and developer email---
|
||||||
* Copyright (C) <year> <name of author>
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
# <one line to give the program's name and a brief idea of what it does.>
|
# Copyright (C) ---Put here your own copyright and developer email---
|
||||||
# Copyright (C) <year> <name of author>
|
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
# <one line to give the program's name and a brief idea of what it does.>
|
# Copyright (C) ---Put here your own copyright and developer email---
|
||||||
# Copyright (C) <year> <name of author>
|
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/* <one line to give the program's name and a brief idea of what it does.>
|
/* Copyright (C) ---Put here your own copyright and developer email---
|
||||||
* Copyright (C) <year> <name of author>
|
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
-- <one line to give the program's name and a brief idea of what it does.>
|
-- Copyright (C) ---Put here your own copyright and developer email---
|
||||||
-- Copyright (C) <year> <name of author>
|
|
||||||
--
|
--
|
||||||
-- This program is free software: you can redistribute it and/or modify
|
-- This program is free software: you can redistribute it and/or modify
|
||||||
-- it under the terms of the GNU General Public License as published by
|
-- it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
-- <one line to give the program's name and a brief idea of what it does.>
|
-- Copyright (C) ---Put here your own copyright and developer email---
|
||||||
-- Copyright (C) <year> <name of author>
|
|
||||||
--
|
--
|
||||||
-- This program is free software: you can redistribute it and/or modify
|
-- This program is free software: you can redistribute it and/or modify
|
||||||
-- it under the terms of the GNU General Public License as published by
|
-- it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
-- <one line to give the program's name and a brief idea of what it does.>
|
-- Copyright (C) ---Put here your own copyright and developer email---
|
||||||
-- Copyright (C) <year> <name of author>
|
|
||||||
--
|
--
|
||||||
-- This program is free software: you can redistribute it and/or modify
|
-- This program is free software: you can redistribute it and/or modify
|
||||||
-- it under the terms of the GNU General Public License as published by
|
-- it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user