Skip to content

Commit

Permalink
rename all class to be OK for version 19.0
Browse files Browse the repository at this point in the history
  • Loading branch information
FHenry committed Apr 9, 2024
1 parent 88fe5c9 commit 102194a
Show file tree
Hide file tree
Showing 41 changed files with 448 additions and 467 deletions.
100 changes: 50 additions & 50 deletions class/gmaps_activity.class.php → class/gmapsactivity.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
*/

/**
* \file class/gmaps_activity.class.php
* \file class/gmapsactivity.class.php
* \ingroup gmaps
* \brief This file is a CRUD class file for Gmaps_activity (Create/Read/Update/Delete)
* \brief This file is a CRUD class file for GmapsActivity (Create/Read/Update/Delete)
*/

// Put here all includes required by your class file
Expand All @@ -28,9 +28,9 @@
//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';

/**
* Class for Gmaps_activity
* Class for GmapsActivity
*/
class Gmaps_activity extends CommonObject
class GmapsActivity extends CommonObject
{
/**
* @var string ID of module.
Expand All @@ -40,12 +40,12 @@ class Gmaps_activity extends CommonObject
/**
* @var string ID to identify managed object.
*/
public $element = 'gmaps_activity';
public $element = 'gmapsActivity';

/**
* @var string Name of table without prefix where object is stored. This is also the key used for extrafields management.
*/
public $table_element = 'gmaps_gmaps_activity';
public $table_element = 'gmaps_gmapsactivity';

/**
* @var int Does this object support multicompany module ?
Expand All @@ -59,7 +59,7 @@ class Gmaps_activity extends CommonObject
public $isextrafieldmanaged = 1;

/**
* @var string String with name of icon for gmaps_activity. Must be the part after the 'object_' into object_gmaps_activity.png
* @var string String with name of icon for gmapsActivity. Must be the part after the 'object_' into object_gmapsActivity.png
*/
public $picto = 'gmaps_activity@gmaps';

Expand Down Expand Up @@ -102,8 +102,8 @@ class Gmaps_activity extends CommonObject
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of object"),
'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'help'=>"Help text", 'showoncombobox'=>'1',),
'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:((status:=:1) AND (entity:IN:__SHARED_ENTITIES__))', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"LinkToThirparty",),
'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>'1', 'position'=>52, 'notnull'=>-1, 'visible'=>-1, 'index'=>1,),
'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:((status:=:1) AND (entity:IN:__SHARED_ENTITIES__))', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"LinkToThirparty", 'enabled'=>'isModEnabled("societe")'),
'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>'1', 'position'=>52, 'notnull'=>-1, 'visible'=>-1, 'index'=>1, 'enabled'=>'isModEnabled("project")'),
'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>3,),
'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,),
'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,),
Expand Down Expand Up @@ -150,17 +150,17 @@ class Gmaps_activity extends CommonObject
/**
* @var int Name of subtable line
*/
//public $table_element_line = 'gmaps_gmaps_activityline';
//public $table_element_line = 'gmaps_gmapsActivityline';

/**
* @var int Field with ID of parent key if this object has a parent
*/
//public $fk_element = 'fk_gmaps_activity';
//public $fk_element = 'fk_gmapsactivity';

/**
* @var int Name of subtable class that manage subtable lines
*/
//public $class_element_line = 'Gmaps_activityline';
//public $class_element_line = 'GmapsActivityline';

/**
* @var array List of child tables. To test if we can delete object.
Expand All @@ -172,15 +172,15 @@ class Gmaps_activity extends CommonObject
* If name matches '@ClassNAme:FilePathClass:ParentFkFieldName' it will
* call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object
*/
protected $childtablesoncascade = array('@Gmaps_place:/gmaps/class/gmaps_place.class.php:fk_gmaps_activity');
protected $childtablesoncascade = array('@GmapsPlace:/gmaps/class/gmapsplace.class.php:fk_gmapsActivity');

/**
* @var Gmaps_activityLine[] Array of subtable lines
* @var GmapsActivityLine[] Array of subtable lines
*/
//public $lines = array();

/**
* @var Gmaps_activityPlaces[] Array of places linked
* @var GmapsActivityPlaces[] Array of places linked
*/
public $places = array();

Expand All @@ -201,7 +201,7 @@ public function __construct(DoliDB $db)
if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0;

// Example to show how to set values of fields definition dynamically
/*if ($user->rights->gmaps->gmaps_activity->read) {
/*if ($user->rights->gmaps->gmapsActivity->read) {
$this->fields['myfield']['visible'] = 1;
$this->fields['myfield']['noteditable'] = 0;
}*/
Expand Down Expand Up @@ -370,10 +370,10 @@ public function fetchLines()
public function fetchPlaces()
{
$this->places = array();
dol_include_once('/gmaps/class/gmaps_place.class.php');
dol_include_once('/gmaps/class/gmapsplace.class.php');

$place = new Gmaps_place($this->db);
$result = $place->fetchAll('','', 0, 0, array('t.fk_gmaps_activity'=>$this->id));
$place = new GmapsPlace($this->db);
$result = $place->fetchAll('','', 0, 0, array('t.fk_gmapsActivity'=>$this->id));
if (is_array($result) && count($result)>0) {
$this->places=$result;
} else {
Expand All @@ -390,9 +390,9 @@ public function findThirdpartyLinked() {
foreach($this->places as $place) {
if (!key_exists($place->id,$cached_places)) {
$sql = 'SELECT fk_object FROM ' . MAIN_DB_PREFIX . 'societe_extrafields WHERE ';
$sql .= ' ( fk_gmaps_gmaps_place=\'' . $place->id . '\' OR ';
$sql .= ' fk_gmaps_gmaps_place LIKE \'' . $place->id . ',%\' OR ';
$sql .= ' fk_gmaps_gmaps_place LIKE \'%,' . $place->id . ',%\'';
$sql .= ' ( fk_gmaps_gmapsPlace=\'' . $place->id . '\' OR ';
$sql .= ' fk_gmaps_gmapsPlace LIKE \'' . $place->id . ',%\' OR ';
$sql .= ' fk_gmaps_gmapsPlace LIKE \'%,' . $place->id . ',%\'';
$sql .= ' )';
$resql = $this->db->query($sql);
if ($resql) {
Expand Down Expand Up @@ -564,8 +564,8 @@ public function validate($user, $notrigger = 0)
return 0;
}

/*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->gmaps->gmaps_activity->write))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->gmaps->gmaps_activity->gmaps_activity_advance->validate))))
/*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->gmaps->gmapsActivity->write))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->gmaps->gmapsActivity->gmapsActivity_advance->validate))))
{
$this->error='NotEnoughPermissions';
dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
Expand Down Expand Up @@ -606,7 +606,7 @@ public function validate($user, $notrigger = 0)
if (!$error && !$notrigger)
{
// Call trigger
$result = $this->call_trigger('GMAPS_ACTIVITY_VALIDATE', $user);
$result = $this->call_trigger('GMAPSACTIVITY_VALIDATE', $user);
if ($result < 0) $error++;
// End call triggers
}
Expand All @@ -620,16 +620,16 @@ public function validate($user, $notrigger = 0)
if (preg_match('/^[\(]?PROV/i', $this->ref))
{
// Now we rename also files into index
$sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'gmaps_activity/".$this->db->escape($this->newref)."'";
$sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'gmaps_activity/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
$sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'gmapsActivity/".$this->db->escape($this->newref)."'";
$sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'gmapsActivity/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->error = $this->db->lasterror(); }

// We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
$oldref = dol_sanitizeFileName($this->ref);
$newref = dol_sanitizeFileName($num);
$dirsource = $conf->gmaps->dir_output.'/gmaps_activity/'.$oldref;
$dirdest = $conf->gmaps->dir_output.'/gmaps_activity/'.$newref;
$dirsource = $conf->gmaps->dir_output.'/gmapsActivity/'.$oldref;
$dirdest = $conf->gmaps->dir_output.'/gmapsActivity/'.$newref;
if (!$error && file_exists($dirsource))
{
dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest);
Expand All @@ -638,7 +638,7 @@ public function validate($user, $notrigger = 0)
{
dol_syslog("Rename ok");
// Rename docs starting with $oldref with $newref
$listoffiles = dol_dir_list($conf->gmaps->dir_output.'/gmaps_activity/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
$listoffiles = dol_dir_list($conf->gmaps->dir_output.'/gmapsActivity/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
foreach ($listoffiles as $fileentry)
{
$dirsource = $fileentry['name'];
Expand Down Expand Up @@ -692,7 +692,7 @@ public function setDraft($user, $notrigger = 0)
return -1;
}*/

return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'GMAPS_ACTIVITY_UNVALIDATE');
return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'GMAPSACTIVITY_UNVALIDATE');
}

/**
Expand All @@ -717,7 +717,7 @@ public function cancel($user, $notrigger = 0)
return -1;
}*/

return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'GMAPS_ACTIVITY_CLOSE');
return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'GMAPSACTIVITY_CLOSE');
}

/**
Expand All @@ -742,7 +742,7 @@ public function reopen($user, $notrigger = 0)
return -1;
}*/

return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'GMAPS_ACTIVITY_REOPEN');
return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'GMAPSACTIVITY_REOPEN');
}

/**
Expand All @@ -763,7 +763,7 @@ public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss

$result = '';

$label = img_picto('', $this->picto).' <u>'.$langs->trans("Gmaps_activity").'</u>';
$label = img_picto('', $this->picto).' <u>'.$langs->trans("GmapsActivity").'</u>';
$label .= '<br>';
$label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
if (isset($this->status)) {
Expand All @@ -785,7 +785,7 @@ public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss
{
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$label = $langs->trans("ShowGmaps_activity");
$label = $langs->trans("ShowGmapsActivity");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
Expand Down Expand Up @@ -831,7 +831,7 @@ public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss
//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');

global $action, $hookmanager;
$hookmanager->initHooks(array('gmaps_activitydao'));
$hookmanager->initHooks(array('gmapsActivitydao'));
$parameters = array('id'=>$this->id, 'getnomurl'=>$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) $result = $hookmanager->resPrint;
Expand Down Expand Up @@ -952,8 +952,8 @@ public function getLinesArray()
{
$this->lines = array();

$objectline = new Gmaps_activityLine($this->db);
$result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_gmaps_activity = '.$this->id));
$objectline = new GmapsActivityLine($this->db);
$result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_gmapsActivity = '.$this->id));

if (is_numeric($result))
{
Expand All @@ -976,16 +976,16 @@ public function getNextNumRef()
global $langs, $conf;
$langs->load("gmaps@gmaps");

if (empty($conf->global->GMAPS_GMAPS_ACTIVITY_ADDON)) {
$conf->global->GMAPS_GMAPS_ACTIVITY_ADDON = 'mod_gmaps_activity_standard';
if (empty($conf->global->GMAPS_GMAPSACTIVITY_ADDON)) {
$conf->global->GMAPS_GMAPSACTIVITY_ADDON = 'mod_gmapsActivity_standard';
}

if (!empty($conf->global->GMAPS_GMAPS_ACTIVITY_ADDON))
if (!empty($conf->global->GMAPS_GMAPSACTIVITY_ADDON))
{
$mybool = false;

$file = $conf->global->GMAPS_GMAPS_ACTIVITY_ADDON.".php";
$classname = $conf->global->GMAPS_GMAPS_ACTIVITY_ADDON;
$file = $conf->global->GMAPS_GMAPSACTIVITY_ADDON.".php";
$classname = $conf->global->GMAPS_GMAPSACTIVITY_ADDON;

// Include file with class
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
Expand Down Expand Up @@ -1046,12 +1046,12 @@ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hided
$langs->load("gmaps@gmaps");

if (!dol_strlen($modele)) {
$modele = 'standard_gmaps_activity';
$modele = 'standard_gmapsActivity';

if ($this->model_pdf) {
$modele = $this->model_pdf;
} elseif (!empty($conf->global->GMAPS_ACTIVITY_ADDON_PDF)) {
$modele = $conf->global->GMAPS_ACTIVITY_ADDON_PDF;
} elseif (!empty($conf->global->GMAPSACTIVITY_ADDON_PDF)) {
$modele = $conf->global->GMAPSACTIVITY_ADDON_PDF;
}
}

Expand Down Expand Up @@ -1099,12 +1099,12 @@ public function doScheduledJob()
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';

/**
* Class Gmaps_activityLine. You can also remove this and generate a CRUD class for lines objects.
* Class GmapsActivityLine. You can also remove this and generate a CRUD class for lines objects.
*/
class Gmaps_activityLine extends CommonObjectLine
class GmapsActivityLine extends CommonObjectLine
{
// To complete with content of an object Gmaps_activityLine
// We should have a field rowid, fk_gmaps_activity and position
// To complete with content of an object GmapsActivityLine
// We should have a field rowid, fk_gmapsActivity and position

/**
* @var int Does object support extrafields ? 0=No, 1=Yes
Expand Down
24 changes: 12 additions & 12 deletions class/gmaps_import.class.php → class/gmapsimport.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@
*/

/**
* \file class/gmaps_import.class.php
* \file class/gmapsimport.class.php
* \ingroup gmaps
* \brief This file is a CRUD class file for Gmaps_import (Create/Read/Update/Delete)
*/

// Put here all includes required by your class file
require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php';
dol_include_once('/gmaps/class/gmaps_activity.class.php');
dol_include_once('/gmaps/class/gmaps_place.class.php');
dol_include_once('/gmaps/class/gmapsactivity.class.php');
dol_include_once('/gmaps/class/gmapsplace.class.php');

/**
* Class for Gmaps_import
*/
class Gmaps_import extends CommonObject
class GmapsImport extends CommonObject
{
/**
* @var string ID of module.
Expand All @@ -40,12 +40,12 @@ class Gmaps_import extends CommonObject
/**
* @var string ID to identify managed object.
*/
public $element = 'gmaps_import';
public $element = 'gmapsImport';

/**
* @var string Name of table without prefix where object is stored. This is also the key used for extrafields management.
*/
public $table_element = 'gmaps_gmaps_import';
public $table_element = 'gmaps_gmapsimport';

/**
* @var int Does this object support multicompany module ?
Expand Down Expand Up @@ -836,7 +836,7 @@ public function getLinesArray()
{
$this->lines = array();

$objectline = new Gmaps_importLine($this->db);
$objectline = new gmapsImportLine($this->db);
$result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql' => 'fk_gmaps_import = ' . $this->id));

if (is_numeric($result)) {
Expand Down Expand Up @@ -1005,7 +1005,7 @@ public function importFile($file, $user)
&& property_exists($activitySegment, 'endLocation')
&& property_exists($activitySegment, 'duration')
&& property_exists($activitySegment, 'distance')) {
$gmapsActivity = new Gmaps_activity($this->db);
$gmapsActivity = new GmapsActivity($this->db);
$gmapsActivity->ref = $key;
$gmapsActivity->location_start_long = $activitySegment->startLocation->longitudeE7;
$gmapsActivity->location_start_lat = $activitySegment->startLocation->latitudeE7;
Expand All @@ -1018,7 +1018,7 @@ public function importFile($file, $user)
//$gmapsActivity->duration_end = round(((int) $activitySegment->duration->endTimestamp)*0.001);
$gmapsActivity->duration_end = dol_stringtotime($activitySegment->duration->endTimestamp);
$gmapsActivity->distance = $activitySegment->distance;
$gmapsActivity->status = Gmaps_activity::STATUS_VALIDATED;
$gmapsActivity->status = GmapsActivity::STATUS_VALIDATED;

$result = $gmapsActivity->create($user);
if ($result < 0) {
Expand All @@ -1039,17 +1039,17 @@ public function importFile($file, $user)
&& property_exists($placeVisit->location, 'placeId')
&& property_exists($placeVisit->location, 'address')
&& property_exists($placeVisit, 'duration')) {
$gmapsPlaceVisit = new Gmaps_place($this->db);
$gmapsPlaceVisit = new GmapsPlace($this->db);
$gmapsPlaceVisit->ref = $key;
$gmapsPlaceVisit->fk_gmaps_activity = $gmapsActivity->id;
$gmapsPlaceVisit->fk_gmapsactivity = $gmapsActivity->id;
$gmapsPlaceVisit->location_placeid = $placeVisit->location->placeId;
$gmapsPlaceVisit->location_address_raw = $placeVisit->location->address;
$gmapsPlaceVisit->location_name = (property_exists($placeVisit->location, 'name')?$placeVisit->location->name:$placeVisit->location->address);
//$gmapsPlaceVisit->duration_start = round((int) $placeVisit->duration->startTimestampMs)*0.001;
$gmapsPlaceVisit->duration_start = dol_stringtotime($placeVisit->duration->startTimestamp);
//$gmapsPlaceVisit->duration_end = round ((int) $placeVisit->duration->endTimestampMs)*0.001;
$gmapsPlaceVisit->duration_end = dol_stringtotime($placeVisit->duration->startTimestamp);
$gmapsPlaceVisit->status = Gmaps_place::STATUS_VALIDATED;
$gmapsPlaceVisit->status = GmapsPlace::STATUS_VALIDATED;

$result = $gmapsPlaceVisit->create($user);
if ($result < 0) {
Expand Down
Loading

0 comments on commit 102194a

Please sign in to comment.