aboutsummaryrefslogtreecommitdiff
path: root/Application/Models
diff options
context:
space:
mode:
authorYuchen Pei <hi@ypei.me>2021-10-14 15:16:42 +1100
committerYuchen Pei <hi@ypei.me>2021-10-14 15:16:42 +1100
commit07f5140771388c9e0c8a99b0dd2e5d950bdb173b (patch)
tree323c00faef1edc7dea2e88ff581cc2258b2b6432 /Application/Models
parente119be145500700f3c465e12664403a07530a421 (diff)
moving h-source subdir out.
Diffstat (limited to 'Application/Models')
-rw-r--r--Application/Models/AcquisitioncardsModel.php68
-rw-r--r--Application/Models/BaseModel.php43
-rw-r--r--Application/Models/BluetoothModel.php68
-rw-r--r--Application/Models/BoxesModel.php42
-rw-r--r--Application/Models/DeletionModel.php53
-rw-r--r--Application/Models/DistrosModel.php34
-rw-r--r--Application/Models/EthernetcardsModel.php68
-rw-r--r--Application/Models/FingerprintreadersModel.php68
-rw-r--r--Application/Models/GenericModel.php103
-rw-r--r--Application/Models/HardwareModel.php348
-rw-r--r--Application/Models/HistoryModel.php56
-rw-r--r--Application/Models/HostcontrollersModel.php69
-rw-r--r--Application/Models/IssuesModel.php116
-rw-r--r--Application/Models/MessagesModel.php73
-rw-r--r--Application/Models/ModemsModel.php68
-rw-r--r--Application/Models/NewsModel.php44
-rw-r--r--Application/Models/NotebooksModel.php94
-rw-r--r--Application/Models/ParamsModel.php43
-rw-r--r--Application/Models/PrintersModel.php70
-rw-r--r--Application/Models/ProfileModel.php78
-rw-r--r--Application/Models/RaidadaptersModel.php68
-rw-r--r--Application/Models/RevisionsModel.php50
-rw-r--r--Application/Models/ScannersModel.php68
-rw-r--r--Application/Models/SdcardreadersModel.php68
-rw-r--r--Application/Models/SoundcardsModel.php68
-rw-r--r--Application/Models/TalkModel.php116
-rw-r--r--Application/Models/ThreegcardsModel.php68
-rwxr-xr-xApplication/Models/UsersModel.php295
-rw-r--r--Application/Models/VendorsModel.php82
-rw-r--r--Application/Models/VideocardsModel.php68
-rw-r--r--Application/Models/WebcamsModel.php72
-rw-r--r--Application/Models/WifiModel.php68
-rw-r--r--Application/Models/WikiModel.php319
-rw-r--r--Application/Models/WikirevisionsModel.php45
-rw-r--r--Application/Models/WikitalkModel.php112
35 files changed, 3173 insertions, 0 deletions
diff --git a/Application/Models/AcquisitioncardsModel.php b/Application/Models/AcquisitioncardsModel.php
new file mode 100644
index 0000000..147aa94
--- /dev/null
+++ b/Application/Models/AcquisitioncardsModel.php
@@ -0,0 +1,68 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class AcquisitioncardsModel extends GenericModel
+{
+
+ public $type = 'acquisition-card'; //device type
+
+ public function __construct()
+ {
+
+ $this->_popupItemNames = array(
+ 'vendor' => 'vendor',
+ 'comm_year' => 'comm_year',
+ 'compatibility' => 'compatibility',
+ 'interface' => 'interface',
+ );
+
+ $this->_popupLabels = array(
+ 'vendor' => gtext("vendor"),
+ 'comm_year' => gtext("year"),
+ 'compatibility' => gtext("does it work?"),
+ 'interface' => gtext("interface"),
+ );
+
+ $this->setPopupFunctions();
+
+ $this->createPopupWhere('vendor,compatibility,comm_year,interface');
+
+ $this->diffFields = array(
+ 'vendor' => gtext("vendor"),
+ 'model' => gtext('model name'),
+ 'other_names' => gtext('possible other names of the device'),
+ 'pci_id' => gtext("VendorID:ProductID code of the device"),
+ 'comm_year' => gtext('year of commercialization'),
+ 'interface' => gtext("interface"),
+ 'distribution' => gtext('GNU/Linux distribution used for the test'),
+ 'kernel' => gtext('tested with the following kernel libre'),
+ 'compatibility' => gtext("does it work with free software?"),
+ 'driver' => gtext("free driver used"),
+ 'description' => gtext('Description'),
+ );
+
+ $this->fieldsWithBreaks = array(gtext('Description'),gtext('possible other names of the device'));
+
+ parent::__construct();
+ }
+
+} \ No newline at end of file
diff --git a/Application/Models/BaseModel.php b/Application/Models/BaseModel.php
new file mode 100644
index 0000000..2f3a142
--- /dev/null
+++ b/Application/Models/BaseModel.php
@@ -0,0 +1,43 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class BaseModel extends Model_Tree
+{
+
+ public function updateHistory($type)
+ {
+ $clean['created_by'] = (int)$this->values['created_by'];
+ $clean['last_id'] = (int)$this->lastId();
+
+ $history = new HistoryModel();
+ $history->values = array(
+ 'created_by' => $clean['created_by'],
+ 'type' => sanitizeAll($type),
+ 'action' => "insert",
+ 'id' => $clean['last_id'],
+ 'message' => '',
+ 'gr' => 'registered',
+ );
+ $history->insert();
+ }
+
+} \ No newline at end of file
diff --git a/Application/Models/BluetoothModel.php b/Application/Models/BluetoothModel.php
new file mode 100644
index 0000000..022c889
--- /dev/null
+++ b/Application/Models/BluetoothModel.php
@@ -0,0 +1,68 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class BluetoothModel extends GenericModel
+{
+
+ public $type = 'bluetooth'; //device type
+
+ public function __construct()
+ {
+
+ $this->_popupItemNames = array(
+ 'vendor' => 'vendor',
+ 'comm_year' => 'comm_year',
+ 'bluetooth_works' => 'bluetooth_works',
+ 'interface' => 'interface',
+ );
+
+ $this->_popupLabels = array(
+ 'vendor' => gtext("vendor"),
+ 'comm_year' => gtext("year"),
+ 'bluetooth_works' => gtext("does it work?"),
+ 'interface' => gtext("interface"),
+ );
+
+ $this->createPopupWhere('vendor,bluetooth_works,comm_year,interface');
+
+ $this->setPopupFunctions();
+
+ $this->diffFields = array(
+ 'vendor' => gtext("vendor"),
+ 'model' => gtext('model name'),
+ 'other_names' => gtext('possible other names of the device'),
+ 'pci_id' => gtext("VendorID:ProductID code of the device"),
+ 'comm_year' => gtext('year of commercialization'),
+ 'interface' => gtext("interface"),
+ 'distribution' => gtext('GNU/Linux distribution used for the test'),
+ 'kernel' => gtext('tested with the following kernel libre'),
+ 'bluetooth_works' => gtext("does it work with free software?"),
+ 'driver' => gtext("free driver used"),
+ 'description' => gtext('Description'),
+ );
+
+ $this->fieldsWithBreaks = array(gtext('Description'),gtext('possible other names of the device'));
+
+ parent::__construct();
+ }
+
+} \ No newline at end of file
diff --git a/Application/Models/BoxesModel.php b/Application/Models/BoxesModel.php
new file mode 100644
index 0000000..a6035cb
--- /dev/null
+++ b/Application/Models/BoxesModel.php
@@ -0,0 +1,42 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class BoxesModel extends Model_Tree {
+
+ public function __construct() {
+ $this->_tables = 'boxes';
+ $this->_idFields = 'id_box';
+
+ parent::__construct();
+ }
+
+ public $formStruct = array(
+ 'entries' => array(
+ 'title' => array(),
+ 'message' => array('type'=>'Textarea'),
+ 'id_box' => array(
+ 'type' => 'Hidden'
+ )
+ ),
+ );
+
+} \ No newline at end of file
diff --git a/Application/Models/DeletionModel.php b/Application/Models/DeletionModel.php
new file mode 100644
index 0000000..9b5dc1a
--- /dev/null
+++ b/Application/Models/DeletionModel.php
@@ -0,0 +1,53 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class DeletionModel extends Model_Tree
+{
+
+ public function __construct()
+ {
+ $this->_tables = 'deletion';
+ $this->_idFields = 'id_del';
+
+// $this->_where=array(
+// 'id_hard' => 'talk'
+// );
+//
+ $this->_popupItemNames = array(
+ 'object' => 'object',
+ );
+
+ $this->_popupLabels = array(
+ 'object' => 'OBJECT',
+ );
+//
+ $this->orderBy = 'deletion.id_del desc';
+
+ $this->strongConditions['insert'] = array(
+ "checkIsStrings|duplication,other" => 'object',
+ "+checkLength|500" => 'message'
+ );
+
+ parent::__construct();
+ }
+
+} \ No newline at end of file
diff --git a/Application/Models/DistrosModel.php b/Application/Models/DistrosModel.php
new file mode 100644
index 0000000..58cd435
--- /dev/null
+++ b/Application/Models/DistrosModel.php
@@ -0,0 +1,34 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class DistrosModel extends Model_Tree {
+
+ public function __construct() {
+ $this->_tables = 'distros';
+ $this->_idFields = 'id_distro';
+
+ $this->_idOrder = 'id_order';
+
+ parent::__construct();
+ }
+
+} \ No newline at end of file
diff --git a/Application/Models/EthernetcardsModel.php b/Application/Models/EthernetcardsModel.php
new file mode 100644
index 0000000..08dc997
--- /dev/null
+++ b/Application/Models/EthernetcardsModel.php
@@ -0,0 +1,68 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class EthernetcardsModel extends GenericModel
+{
+
+ public $type = 'ethernet-card'; //device type
+
+ public function __construct()
+ {
+
+ $this->_popupItemNames = array(
+ 'vendor' => 'vendor',
+ 'comm_year' => 'comm_year',
+ 'ethernet_card_works' => 'ethernet_card_works',
+ 'interface' => 'interface',
+ );
+
+ $this->_popupLabels = array(
+ 'vendor' => gtext("vendor"),
+ 'comm_year' => gtext("year"),
+ 'ethernet_card_works' => gtext("does it work?"),
+ 'interface' => gtext("interface"),
+ );
+
+ $this->setPopupFunctions();
+
+ $this->createPopupWhere('vendor,ethernet_card_works,comm_year,interface');
+
+ $this->diffFields = array(
+ 'vendor' => gtext("vendor"),
+ 'model' => gtext('model name'),
+ 'other_names' => gtext('possible other names of the device'),
+ 'pci_id' => gtext("VendorID:ProductID code of the device"),
+ 'comm_year' => gtext('year of commercialization'),
+ 'interface' => gtext("interface"),
+ 'distribution' => gtext('GNU/Linux distribution used for the test'),
+ 'kernel' => gtext('tested with the following kernel libre'),
+ 'ethernet_card_works' => gtext("does it work with free software?"),
+ 'driver' => gtext("free driver used"),
+ 'description' => gtext('Description'),
+ );
+
+ $this->fieldsWithBreaks = array(gtext('Description'),gtext('possible other names of the device'));
+
+ parent::__construct();
+ }
+
+} \ No newline at end of file
diff --git a/Application/Models/FingerprintreadersModel.php b/Application/Models/FingerprintreadersModel.php
new file mode 100644
index 0000000..7a2f3e8
--- /dev/null
+++ b/Application/Models/FingerprintreadersModel.php
@@ -0,0 +1,68 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class FingerprintreadersModel extends GenericModel
+{
+
+ public $type = 'fingerprint-reader'; //device type
+
+ public function __construct()
+ {
+
+ $this->_popupItemNames = array(
+ 'vendor' => 'vendor',
+ 'comm_year' => 'comm_year',
+ 'fingerprint_works' => 'fingerprint_works',
+ 'interface' => 'interface',
+ );
+
+ $this->_popupLabels = array(
+ 'vendor' => gtext("vendor"),
+ 'comm_year' => gtext("year"),
+ 'fingerprint_works' => gtext("does it work?"),
+ 'interface' => gtext("interface"),
+ );
+
+ $this->setPopupFunctions();
+
+ $this->createPopupWhere('vendor,fingerprint_works,comm_year,interface');
+
+ $this->diffFields = array(
+ 'vendor' => gtext("vendor"),
+ 'model' => gtext('model name'),
+ 'other_names' => gtext('possible other names of the device'),
+ 'pci_id' => gtext("VendorID:ProductID code of the device"),
+ 'comm_year' => gtext('year of commercialization'),
+ 'interface' => gtext("interface"),
+ 'distribution' => gtext('GNU/Linux distribution used for the test'),
+ 'kernel' => gtext('tested with the following kernel libre'),
+ 'fingerprint_works' => gtext("does it work with free software?"),
+ 'driver' => gtext("free driver used"),
+ 'description' => gtext('Description'),
+ );
+
+ $this->fieldsWithBreaks = array(gtext('Description'),gtext('possible other names of the device'));
+
+ parent::__construct();
+ }
+
+} \ No newline at end of file
diff --git a/Application/Models/GenericModel.php b/Application/Models/GenericModel.php
new file mode 100644
index 0000000..3a0f8fa
--- /dev/null
+++ b/Application/Models/GenericModel.php
@@ -0,0 +1,103 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class GenericModel extends Model_Tree {
+
+ public $type = ''; //device type
+ public $diffFields = array();
+ public $fieldsWithBreaks = array();
+
+ public function __construct() {
+ $this->_tables = 'hardware';
+ $this->_idFields = 'id_hard';
+
+ $this->_where=array(
+ 'type' => 'hardware',
+ 'vendor' => 'hardware',
+ 'compatibility' => 'hardware',
+ 'comm_year' => 'hardware',
+ );
+
+ $this->orderBy = 'hardware.id_hard desc';
+ parent::__construct();
+ }
+
+ public function checkType($id_hard = 0)
+ {
+ $clean['id_hard'] = (int)$id_hard;
+ $res = $this->db->select('hardware','type','id_hard='.$clean['id_hard']);
+ if (count($res) > 0)
+ {
+ return (strcmp($this->type,$res[0]['hardware']['type']) === 0 ) ? true : false;
+ }
+ return false;
+ }
+
+ public function getDiffArray($oldArray, $newArray)
+ {
+ return getDiffArray($this->diffFields, $oldArray, $newArray);
+ }
+
+ //create the $_popupWhere property
+ public function createPopupWhere($list)
+ {
+ $listArray = explode(',',$list);
+ foreach ($listArray as $field)
+ {
+ $this->_popupWhere[$field] = 'type="'.$this->type.'" and deleted="no" and cleared="no"';
+ }
+ }
+
+ //set the fuction to be applied upon each popup name
+ public function setPopupFunctions()
+ {
+ foreach ($this->_popupItemNames as $name => $field)
+ {
+ $this->_popupFunctions[$name] = getTranslationFunction($name);
+ }
+ }
+
+ //get the HTML of the popup labels
+ public function getPopupLabel($viewArgs)
+ {
+ $html = null;
+ $listArray = array('page','history_page','search_string');
+
+ $count = 0;
+
+ foreach ($viewArgs as $field => $value)
+ {
+ if ($count < 5)
+ {
+ if (!in_array($field,$listArray))
+ {
+ $value = call_user_func(getTranslationFunction($field),$value);
+ $html .= "<div class='viewall_popup_menu_status_item'>".$value."</div>\n";
+
+ $count++;
+ }
+ }
+ }
+ return $html;
+ }
+
+} \ No newline at end of file
diff --git a/Application/Models/HardwareModel.php b/Application/Models/HardwareModel.php
new file mode 100644
index 0000000..9c8a5db
--- /dev/null
+++ b/Application/Models/HardwareModel.php
@@ -0,0 +1,348 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class HardwareModel extends Model_Map {
+
+ public $id_user = 0;
+ public $type = ''; //device type
+ public $lastId = 0; //the id of the last record inserted
+
+ public $formStruct = array(
+ 'entries' => array(
+ 'deleted'=> array('type'=>'Select','options'=>'no,yes'),
+ 'id_hard' => array(
+ 'type' => 'Hidden'
+ )
+ ),
+ );
+
+ public function __construct() {
+ $this->_tables='hardware,regusers,hardware_users';
+ $this->_idFields='id_hard,id_user';
+ $this->_where=array(
+ 'type' => 'hardware',
+ 'username' => 'regusers',
+ 'id_user' => 'regusers',
+ 'has_confirmed' => 'regusers',
+ 'deleted' => 'regusers',
+ '-deleted' => 'hardware'
+ );
+ $this->orderBy = 'hardware.id_hard desc';
+ $this->printAssError = "no";
+
+ $this->_popupItemNames = array(
+ 'type'=>'type',
+ 'ask_for_del'=>'ask_for_del',
+ '-deleted'=>'deleted',
+ );
+
+ $this->_popupLabels = array(
+ 'type'=>'TYPE',
+ 'ask_for_del'=>'ASK FOR DEL?',
+ '-deleted'=>'DELETED?',
+ );
+
+// $this->databaseConditions['insert'] = array(
+// 'checkUnique' => 'model',
+// );
+//
+// $this->databaseConditions['update'] = array(
+// 'checkUniqueCompl' => 'model',
+// );
+
+ parent::__construct();
+ }
+
+ //set the soft and strong conditions
+ public function setConditions($worksOptions,$worksField,$interfaceOptions)
+ {
+ $this->strongConditions['update'] = array(
+ "checkNotEmpty" => "model|you have to fill the <i>model name</i> entry",
+ "checkMatch|".Hardware::$regExpressions['model'] => "model|characters not allowed in the <i>model name</i> entry",
+ "+checkMatch|".Hardware::$regExpressions['vendorid_productid'] => "pci_id|<i>VendorID:ProductID</i> has to have the following format: [a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}",
+ "checkLength|190" => "model",
+ "+checkLength|299" => "distribution",
+ "++checkIsStrings|".Hardware::getCommYears() => "comm_year",
+ "+++checkIsStrings|".$worksOptions => $worksField,
+ "++++checkIsStrings|".$interfaceOptions => "interface",
+ );
+
+ $this->strongConditions['insert'] = $this->strongConditions['update'];
+
+ $this->softConditions['update'] = array(
+ "checkMatch|".Hardware::$regExpressions['kernel'] => "kernel|characters not allowed in the <i>kernel</i> entry",
+ "checkLength|40000" => "description",
+ "+checkLength|99" => "kernel",
+ "++checkLength|49" => "driver",
+ "++checkMatch|".Hardware::$regExpressions['driver'] => "driver|only the following characters are allowed for the <i>driver</i> entry: a-z A-Z 0-9 - _ . + s / , : ; ( ) [ ]",
+ "+++checkLength|1000" => "other_names|the <i>other names</i> entry exceeds the value of 1000 characters",
+ );
+
+ $this->softConditions['insert'] = $this->softConditions['update'];
+ }
+
+ public function permanentlyDelete($id)
+ {
+ $clean['id'] = (int)$id;
+
+ $record = $this->selectId($clean['id']);
+
+ $this->values['deleted'] = 'no';
+ $this->values['approved'] = 'yes';
+ $this->values['pci_id'] = '';
+ $this->values['model'] = '[permanently deleted] '.$record['model'];
+
+ return parent::update($clean['id']);
+ }
+
+ public function pUpdate($id)
+ {
+ if (isset($this->values['approved']))
+ {
+ if (strcmp($this->values['approved'],'yes') === 0)
+ {
+ $this->values['deleted'] = 'no';
+ }
+ }
+ else if (isset($this->values['deleted']))
+ {
+ if (strcmp($this->values['deleted'],'no') === 0)
+ {
+ $this->values['approved'] = 'yes';
+ }
+ }
+ return parent::update($id);
+ }
+
+ public function insert()
+ {
+ $this->values['created_by'] = (int)$this->id_user;
+ $this->values['updated_by'] = (int)$this->id_user;
+ $this->values['update_date'] = date('Y-m-d H:i:s');
+
+ if ($this->values['created_by'] === 0)
+ {
+ $this->values['deleted'] = 'yes';
+ $this->values['approved'] = 'no';
+ }
+
+ //random ID
+ $randomId = md5(uniqid(mt_rand(),true));
+ $this->values["type"] = $randomId;
+
+ parent::insert();
+// echo $this->getQuery();
+ //associate the user to the record
+ if ($this->queryResult)
+ {
+ $resId = $this->db->select("hardware","id_hard","type='$randomId'");
+ $clean['id'] = $resId[0]['hardware']['id_hard'];
+ $this->lastId = $clean['id'];
+ $this->db->update('hardware','type',array($this->type),'id_hard='.$clean['id']);
+
+ //update the history table
+ $this->updateHistory('insert');
+
+ if ($this->values['created_by'] !== 0)
+ {
+ $this->associate($clean['id']);
+ }
+ }
+
+ }
+
+ public function update($id = null, $where = null)
+ {
+ $clean['id'] = (int)$id;
+
+ $this->values['updated_by'] = (int)$this->id_user;
+ $this->values['update_date'] = date('Y-m-d H:i:s');
+
+ //save the old fields in the revisions table
+ $this->setWhereQueryClause(array('id_hard' => $clean['id']));
+ $oldStruct = $this->getFields($this->fields.',vendor,created_by,updated_by,update_date,type,id_hard');
+
+ if (count($oldStruct > 0))
+ {
+ if (strcmp($oldStruct[0]['hardware']['type'],$this->type) === 0)
+ {
+ $oldValues = $oldStruct[0]['hardware'];
+
+ $revisions = new RevisionsModel();
+ $revisions->values = $oldValues;
+ $revisions->sanitize();
+
+ if ($revisions->insert())
+ {
+ parent::update($clean['id']);
+ if ($this->queryResult)
+ {
+ $this->lastId = $clean['id'];
+
+ //update the history table
+ $this->updateHistory('update');
+
+ if (!$this->checkAssociation($clean['id'],(int)$this->id_user))
+ {
+ $this->associate($clean['id']);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public function makeCurrent($id_rev)
+ {
+ $clean['id_rev'] = (int)$id_rev;
+
+ $revisions = new RevisionsModel();
+
+ $clean['id_hard'] = (int)$revisions->getIdHard($clean['id_rev']);
+
+ //save the old fields in the revisions table
+ $this->setWhereQueryClause(array('id_hard'=>$clean['id_hard']));
+ $oldStruct = $this->getFields($this->fields.',vendor,created_by,updated_by,update_date,type,id_hard');
+
+ if (count($oldStruct > 0))
+ {
+ if (strcmp($oldStruct[0]['hardware']['type'],$this->type) === 0)
+ {
+ //get the values of the revision
+ $revisions->setWhereQueryClause(array('id_rev'=>$clean['id_rev']));
+ $newStruct = $revisions->getFields($this->fields.',vendor,created_by,updated_by,update_date,type');
+
+ if (count($newStruct > 0))
+ {
+ $revisions->values = $oldStruct[0]['hardware'];
+ $revisions->sanitize();
+
+ $this->values = $newStruct[0]['revisions'];
+ $this->values['updated_by'] = (int)$this->id_user;
+ $this->values['update_date'] = date('Y-m-d H:i:s');
+
+ $this->sanitize();
+
+ if ($revisions->insert())
+ {
+ if (parent::update($clean['id_hard']))
+ {
+ $this->lastId = $clean['id_hard'];
+
+ //update the history table
+ $this->updateHistory('update');
+
+ if (!$this->checkAssociation($clean['id_hard'],(int)$this->id_user))
+ {
+ $this->associate($clean['id_hard']);
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ $this->notice = "<div class='alert'>Wrong type..</div>\n";
+ }
+ }
+
+ }
+
+ public function associate($id_record = null, $idGroup = null)
+ {
+ return parent::associate((int)$id_record,(int)$this->id_user);
+ }
+
+ //get the model name
+ public function getTheModelName($id)
+ {
+ $clean['id'] = (int)$id;
+ $this->setWhereQueryClause(array('id_hard' => $clean['id']));
+ $res = $this->getFields('model');
+ $name = count($res) > 0 ? $res[0]['hardware']['model'] : '';
+ return $name;
+ }
+
+ //get the model info by the vendorid:productid code
+ public function getModelByCode($code)
+ {
+ $res = $this->clear()->where(array('pci_id'=>sanitizePciid($code)))->send();
+
+ if (count($res) > 0)
+ {
+ return $res[0]['hardware'];
+ }
+ return false;
+ }
+
+ //save in the history all the action carried out by users
+ protected function updateHistory($action)
+ {
+ $translations = array(
+ 'insert' => 'inserted',
+ 'update' => 'updated',
+ );
+
+ $allowedActions = array('insert','update');
+
+ if (in_array($action,$allowedActions))
+ {
+ $users = new UsersModel();
+
+ $clean['user'] = sanitizeAll($users->getUser($this->id_user));
+
+ $history = new HistoryModel();
+ $history->values = array(
+ 'created_by' => $this->id_user,
+ 'type' => 'hardware',
+ 'action' => $action,
+ 'id' => $this->lastId,
+ 'message' => 'The device having id='.$this->lastId.' has been '.$translations[$action].' by the user ' . $clean['user'] . ' (id_user='.$this->id_user.') ',
+ 'gr' => 'registered',
+ );
+ $history->insert();
+ }
+ }
+
+ public function isDeleted($id)
+ {
+ $clean['id'] = (int)$id;
+ $res = $this->select('hardware.deleted')->where(array('id_hard'=>$clean['id']))->send();
+ if ( count($res) > 0 )
+ {
+ return strcmp($res[0]['hardware']['deleted'],'no') === 0 ? false : true;
+ }
+ return false;
+ }
+
+ public function isCleared($id)
+ {
+ $clean['id'] = (int)$id;
+ $res = $this->select('hardware.cleared')->where(array('id_hard'=>$clean['id']))->send();
+ if ( count($res) > 0 )
+ {
+ return strcmp($res[0]['hardware']['cleared'],'no') === 0 ? false : true;
+ }
+ return false;
+ }
+
+} \ No newline at end of file
diff --git a/Application/Models/HistoryModel.php b/Application/Models/HistoryModel.php
new file mode 100644
index 0000000..d94f745
--- /dev/null
+++ b/Application/Models/HistoryModel.php
@@ -0,0 +1,56 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class HistoryModel extends Model_Tree {
+
+ public function __construct() {
+ $this->_tables = 'history';
+ $this->_idFields = 'id_history';
+
+ $this->_where=array(
+ 'approved' => 'hardware',
+ 'deleted' => 'hardware',
+ 'cleared' => 'hardware',
+ 'username' => 'regusers',
+ );
+ $this->orderBy = 'history.id_history';
+
+ $this->_popupFunctions = array(
+ 'created_by'=> 'getUserName',
+ );
+
+ $this->_popupItemNames = array(
+ 'type' => 'type',
+ 'action' => 'action',
+ 'created_by'=> 'created_by',
+ );
+
+ $this->_popupLabels = array(
+ 'type' => 'TYPE',
+ 'action' => 'ACTION',
+ 'created_by'=> 'MODERATOR',
+ );
+
+ parent::__construct();
+ }
+
+} \ No newline at end of file
diff --git a/Application/Models/HostcontrollersModel.php b/Application/Models/HostcontrollersModel.php
new file mode 100644
index 0000000..8908052
--- /dev/null
+++ b/Application/Models/HostcontrollersModel.php
@@ -0,0 +1,69 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class HostcontrollersModel extends GenericModel
+{
+
+ public $type = 'host-controller'; //device type
+
+ public function __construct()
+ {
+
+ $this->_popupItemNames = array(
+ 'vendor' => 'vendor',
+ 'comm_year' => 'comm_year',
+ 'compatibility' => 'compatibility',
+ 'subtype' => 'subtype',
+ );
+
+ $this->_popupLabels = array(
+ 'vendor' => gtext("vendor"),
+ 'comm_year' => gtext("year"),
+ 'compatibility' => gtext("does it work?"),
+ 'subtype' => gtext("subtype"),
+ );
+
+ $this->setPopupFunctions();
+
+ $this->createPopupWhere('vendor,compatibility,comm_year,subtype');
+
+ $this->diffFields = array(
+ 'vendor' => gtext("vendor"),
+ 'model' => gtext('model name'),
+ 'other_names' => gtext('possible other names of the device'),
+ 'subtype' => gtext('subtype')." (laser, inkjet, ..)",
+ 'pci_id' => gtext("VendorID:ProductID code of the device"),
+ 'comm_year' => gtext('year of commercialization'),
+ 'interface' => gtext("interface"),
+ 'distribution' => gtext('GNU/Linux distribution used for the test'),
+ 'kernel' => gtext('tested with the following kernel libre'),
+ 'compatibility' => gtext("does it work with free software?"),
+ 'driver' => gtext("free driver used"),
+ 'description' => gtext('Description'),
+ );
+
+ $this->fieldsWithBreaks = array(gtext('Description'),gtext('possible other names of the device'));
+
+ parent::__construct();
+ }
+
+} \ No newline at end of file
diff --git a/Application/Models/IssuesModel.php b/Application/Models/IssuesModel.php
new file mode 100644
index 0000000..9d6a4ef
--- /dev/null
+++ b/Application/Models/IssuesModel.php
@@ -0,0 +1,116 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class IssuesModel extends BaseModel {
+
+ public function __construct() {
+ $this->_tables = 'issues';
+ $this->_idFields = 'id_issue';
+
+ $this->_onDelete = 'nocheck';
+
+ $this->_where = array(
+ 'priority' => 'issues',
+ 'status' => 'issues',
+ 'topic' => 'issues',
+ );
+
+ $this->_popupItemNames = array(
+ 'priority' => 'priority',
+ 'status' => 'status',
+ 'topic' => 'topic',
+ 'deleted' => 'deleted',
+ );
+
+ $this->_popupLabels = array(
+ 'priority' => 'PRIORITY',
+ 'status' => 'STATUS',
+ 'topic' => 'TOPIC',
+ 'deleted' => 'DELETED?',
+ );
+
+ $this->orderBy = 'issues.id_issue desc';
+
+ $this->strongConditions['insert'] = array(
+ "checkLength|99" => 'title',
+ "+checkLength|34" => 'topic',
+ "++checkLength|15" => 'priority',
+ "+++checkLength|5000" => 'message',
+ "checkisStrings|low,medium,high" => 'priority',
+ "+checkisStrings|maybe-a-bug,new-categories-of-hardware,add-a-vendor-name,other" => 'topic',
+ );
+
+ $this->formStruct = array(
+ 'entries' => array(
+ 'title' => array('labelString' => gtext("TITLE").':'),
+ 'topic' => array(
+ 'type'=>'Select',
+ 'options'=>array(
+ 'Add a vendor name' => 'add-a-vendor-name',
+ 'Maybe a bug' => 'maybe-a-bug',
+ 'Add new categories of hardware' => 'new-categories-of-hardware',
+ 'Other' => 'other'
+ ),
+ 'labelString' => gtext("TOPIC").':',
+ ),
+ 'deleted'=> array(
+ 'type' => 'Select',
+ 'options' => 'no,yes',
+ ),
+ 'priority' => array(
+ 'type'=>'Select',
+ 'options'=>'low,medium,high',
+ 'labelString' => gtext("PRIORITY").':',
+ ),
+ 'message' => array('type'=>'Textarea','idName'=>'bb_code','labelString' => gtext("MESSAGE").':',),
+ 'status' => array(
+ 'type' => 'Select',
+ 'options' => 'opened,closed'
+ ),
+ 'notice' => array(
+ 'type' => 'Textarea',
+ 'idName' => 'bb_code_notice',
+ ),
+ 'id_issue' => array(
+ 'type' => 'Hidden'
+ )
+ ),
+ );
+
+ parent::__construct();
+ }
+
+ public function pUpdate($id)
+ {
+ return parent::update($id);
+ }
+
+ public function insert()
+ {
+ if (parent::insert())
+ {
+ //update the history
+ $this->updateHistory('issue_ins');
+ }
+ }
+
+} \ No newline at end of file
diff --git a/Application/Models/MessagesModel.php b/Application/Models/MessagesModel.php
new file mode 100644
index 0000000..b36e76e
--- /dev/null
+++ b/Application/Models/MessagesModel.php
@@ -0,0 +1,73 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class MessagesModel extends BaseModel {
+
+ public function __construct() {
+ $this->_tables = 'messages';
+ $this->_idFields = 'id_mes';
+
+ $this->orderBy = 'messages.id_mes';
+
+ $this->_popupItemNames = array(
+ 'deleted' => 'deleted',
+ 'has_read' => 'has_read',
+ );
+
+ $this->_popupLabels = array(
+ 'deleted' => 'DELETED?',
+ 'has_read' => 'ALREADY READ?',
+ );
+
+ $this->strongConditions['insert'] = array(
+ "checkLength|5000" => 'message',
+ );
+
+ parent::__construct();
+ }
+
+ public function pUpdate($id)
+ {
+ return parent::update($id);
+ }
+
+ public function insert()
+ {
+ if (parent::insert())
+ {
+ //update the history
+ $this->updateHistory('message_ins');
+ }
+ }
+
+ public $formStruct = array(
+ 'entries' => array(
+ 'deleted' => array('type'=>'Select','options'=>'no,yes'),
+ 'has_read' => array('type'=>'Select','options'=>'no,yes'),
+ 'message' => array('type'=>'Textarea','idName'=>'bb_code'),
+ 'id_mes' => array(
+ 'type' => 'Hidden'
+ )
+ ),
+ );
+
+} \ No newline at end of file
diff --git a/Application/Models/ModemsModel.php b/Application/Models/ModemsModel.php
new file mode 100644
index 0000000..92571d2
--- /dev/null
+++ b/Application/Models/ModemsModel.php
@@ -0,0 +1,68 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class ModemsModel extends GenericModel
+{
+
+ public $type = 'modem'; //device type
+
+ public function __construct()
+ {
+
+ $this->_popupItemNames = array(
+ 'vendor' => 'vendor',
+ 'comm_year' => 'comm_year',
+ 'compatibility' => 'compatibility',
+ 'interface' => 'interface',
+ );
+
+ $this->_popupLabels = array(
+ 'vendor' => gtext("vendor"),
+ 'comm_year' => gtext("year"),
+ 'compatibility' => gtext("does it work?"),
+ 'interface' => gtext("interface"),
+ );
+
+ $this->setPopupFunctions();
+
+ $this->createPopupWhere('vendor,compatibility,comm_year,interface');
+
+ $this->diffFields = array(
+ 'vendor' => gtext("vendor"),
+ 'model' => gtext('model name'),
+ 'other_names' => gtext('possible other names of the device'),
+ 'pci_id' => gtext("VendorID:ProductID code of the device"),
+ 'comm_year' => gtext('year of commercialization'),
+ 'interface' => gtext("interface"),
+ 'distribution' => gtext('GNU/Linux distribution used for the test'),
+ 'kernel' => gtext('tested with the following kernel libre'),
+ 'compatibility' => gtext("does it work with free software?"),
+ 'driver' => gtext("free driver used"),
+ 'description' => gtext('Description'),
+ );
+
+ $this->fieldsWithBreaks = array(gtext('Description'),gtext('possible other names of the device'));
+
+ parent::__construct();
+ }
+
+} \ No newline at end of file
diff --git a/Application/Models/NewsModel.php b/Application/Models/NewsModel.php
new file mode 100644
index 0000000..cab1641
--- /dev/null
+++ b/Application/Models/NewsModel.php
@@ -0,0 +1,44 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class NewsModel extends Model_Tree {
+
+ public function __construct() {
+ $this->_tables = 'news';
+ $this->_idFields = 'id_news';
+
+ $this->orderBy = 'news.id_news desc';
+
+ parent::__construct();
+ }
+
+ public $formStruct = array(
+ 'entries' => array(
+ 'title' => array(),
+ 'message' => array('type'=>'Textarea','idName'=>'bb_code'),
+ 'id_news' => array(
+ 'type' => 'Hidden'
+ )
+ ),
+ );
+
+} \ No newline at end of file
diff --git a/Application/Models/NotebooksModel.php b/Application/Models/NotebooksModel.php
new file mode 100644
index 0000000..d9b9008
--- /dev/null
+++ b/Application/Models/NotebooksModel.php
@@ -0,0 +1,94 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class NotebooksModel extends GenericModel {
+
+ public $type = 'notebook'; //device type
+
+ public function __construct()
+ {
+
+ $this->_popupItemNames = array(
+ 'vendor' => 'vendor',
+ 'compatibility' => 'compatibility',
+ 'comm_year' => 'comm_year',
+ 'subtype' => 'subtype',
+ );
+
+ $this->_popupLabels = array(
+ 'vendor' => gtext("vendor"),
+ 'compatibility' => gtext("compatibility"),
+ 'comm_year' => gtext("year"),
+ 'subtype' => gtext("subtype"),
+ );
+
+ $this->setPopupFunctions();
+
+ $this->createPopupWhere('vendor,compatibility,comm_year,subtype');
+
+ $this->diffFields = array(
+ 'vendor' => gtext("vendor"),
+ 'model' => gtext('model name'),
+ 'subtype' => gtext('subtype (notebook or netbook)'),
+ 'architecture' => gtext('architecture'),
+ 'bios' => gtext('does it have a free bios?'),
+ 'can_free_systems_be_installed' => gtext('can free operating systems be installed?'),
+ 'prevent_wifi' => gtext('does the device prevent the installation of wifi cards not-approved by the vendor?'),
+ 'comm_year' => gtext('year of commercialization'),
+ 'distribution' => gtext('GNU/Linux distribution used for the test'),
+ 'compatibility' => gtext('compatibility with free software'),
+ 'kernel' => gtext('tested with the following kernel libre'),
+ 'video_card_type' => gtext('video card model'),
+ 'video_card_works' => gtext('does the video card work?'),
+ 'wifi_type' => gtext('wifi model'),
+ 'wifi_works' => gtext('does the wifi card work?'),
+ 'webcam_type' => gtext('webcam model'),
+ 'webcam_works' => gtext('does the webcam work?'),
+ 'description' => gtext('Description'),
+ );
+
+ $this->fieldsWithBreaks = array(gtext('Description'));
+
+ parent::__construct();
+ }
+
+ public function morePopups()
+ {
+ $this->_popupItemNames = array(
+ 'bios' => 'bios',
+ 'architecture' => 'architecture',
+ );
+
+ $this->_popupLabels = array(
+ 'bios' => gtext("free boot firmware?"),
+ 'architecture' => gtext("architecture"),
+ );
+
+ $this->_popupFunctions = array(
+ 'architecture' => 'translate_and_gtext',
+ 'bios' => 'translate_and_gtext',
+ );
+
+ $this->createPopupWhere('bios,architecture');
+ }
+
+} \ No newline at end of file
diff --git a/Application/Models/ParamsModel.php b/Application/Models/ParamsModel.php
new file mode 100644
index 0000000..cea99a1
--- /dev/null
+++ b/Application/Models/ParamsModel.php
@@ -0,0 +1,43 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class ParamsModel extends Model_Tree {
+
+ public function __construct() {
+ $this->_tables = 'params';
+ $this->_idFields = 'id_par';
+
+ parent::__construct();
+ }
+
+ public $formStruct = array(
+ 'entries' => array(
+ 'updating' => array(
+ 'type'=>'Select',
+ 'options'=>'no,yes',
+ ),
+ 'id_par' => array(
+ 'type' => 'Hidden'
+ )
+ ),
+ );
+} \ No newline at end of file
diff --git a/Application/Models/PrintersModel.php b/Application/Models/PrintersModel.php
new file mode 100644
index 0000000..355bb67
--- /dev/null
+++ b/Application/Models/PrintersModel.php
@@ -0,0 +1,70 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class PrintersModel extends GenericModel
+{
+
+ public $type = 'printer'; //device type
+
+ public function __construct()
+ {
+
+ $this->_popupItemNames = array(
+ 'vendor' => 'vendor',
+ 'compatibility' => 'compatibility',
+ 'comm_year' => 'comm_year',
+ 'interface' => 'interface',
+ );
+
+ $this->_popupLabels = array(
+ 'vendor' => gtext("vendor"),
+ 'compatibility' => gtext("compatibility"),
+ 'comm_year' => gtext("year"),
+ 'interface' => gtext("interface"),
+ );
+
+ $this->setPopupFunctions();
+
+ $this->createPopupWhere('vendor,compatibility,comm_year,interface');
+
+ $this->diffFields = array(
+ 'vendor' => gtext("vendor"),
+ 'model' => gtext('model name'),
+ 'other_names' => gtext('possible other names of the device'),
+ 'subtype' => gtext('subtype')." (laser, inkjet, ..)",
+ 'pci_id' => gtext("VendorID:ProductID code of the device"),
+ 'comm_year' => gtext('year of commercialization'),
+ 'interface' => gtext("interface"),
+ 'distribution' => gtext('GNU/Linux distribution used for the test'),
+ 'compatibility' => gtext('compatibility with free software'),
+ 'it_tracks_users' => gtext('does it adopt any techniques to track users?'),
+ 'kernel' => gtext('tested with the following kernel libre'),
+ 'driver' => gtext("free driver used"),
+ 'description' => gtext('Description'),
+ );
+
+ $this->fieldsWithBreaks = array(gtext('Description'),gtext('possible other names of the device'));
+
+ parent::__construct();
+ }
+
+} \ No newline at end of file
diff --git a/Application/Models/ProfileModel.php b/Application/Models/ProfileModel.php
new file mode 100644
index 0000000..c8818b4
--- /dev/null
+++ b/Application/Models/ProfileModel.php
@@ -0,0 +1,78 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class ProfileModel extends Model_Tree {
+
+ public function __construct() {
+ $this->_tables = 'profile';
+ $this->_idFields = 'id_prof';
+
+ $this->_where=array(
+ 'username' => 'regusers',
+ 'has_confirmed' => 'regusers',
+ 'deleted' => 'regusers'
+ );
+
+ $this->softConditions['update'] = array(
+ "checkLength|90" => "real_name,where_you_are,fav_distro,birth_date,website|the fields 'real name', 'where_you_are', 'favorite distro', 'website' and 'birthdate' don't have to have more than 90 characters",
+ "checkLength|1000" => "projects,description|the fields 'projects' and 'description' don't have to have more than 1000 characters",
+ "checkIsStrings|no,yes" => "publish_mail",
+ "+checkIsStrings|no,yes" => "send_notification"
+ );
+
+ parent::__construct();
+ }
+
+ public $formStruct = array(
+
+ 'entries' => array(
+ 'real_name' => array('labelString'=>'Your real name'),
+ 'website' => array('labelString'=>'Your website address (add http://)'),
+ 'where_you_are' => array('labelString'=>'I\'m from...'),
+ 'birth_date' => array('labelString'=>'My birthdate'),
+ 'fav_distro' => array('labelString'=>'My favourite distribution'),
+ 'projects' => array(
+ 'type' => 'Textarea',
+ 'labelString'=>'Free software projects I\'m working on'
+ ),
+ 'publish_mail' => array(
+ 'type' => 'Select',
+ 'options' => 'no,yes',
+ 'labelString'=> 'Would you like to publish your e-mail address?'
+ ),
+ 'send_notification' => array(
+ 'type' => 'Select',
+ 'options' => 'yes,no',
+ 'labelString'=> 'Would you like to receive mail notifications?'
+ ),
+ 'description' => array(
+ 'type' => 'Textarea',
+ 'labelString'=> 'Your description'
+ ),
+ 'id_prof' => array(
+ 'type' => 'Hidden'
+ )
+ ),
+
+ );
+
+} \ No newline at end of file
diff --git a/Application/Models/RaidadaptersModel.php b/Application/Models/RaidadaptersModel.php
new file mode 100644
index 0000000..2e140e8
--- /dev/null
+++ b/Application/Models/RaidadaptersModel.php
@@ -0,0 +1,68 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class RaidadaptersModel extends GenericModel
+{
+
+ public $type = 'RAID-adapter'; //device type
+
+ public function __construct()
+ {
+
+ $this->_popupItemNames = array(
+ 'vendor' => 'vendor',
+ 'comm_year' => 'comm_year',
+ 'compatibility' => 'compatibility',
+ 'interface' => 'interface',
+ );
+
+ $this->_popupLabels = array(
+ 'vendor' => gtext("vendor"),
+ 'comm_year' => gtext("year"),
+ 'compatibility' => gtext("does it work?"),
+ 'interface' => gtext("interface"),
+ );
+
+ $this->setPopupFunctions();
+
+ $this->createPopupWhere('vendor,compatibility,comm_year,interface');
+
+ $this->diffFields = array(
+ 'vendor' => gtext("vendor"),
+ 'model' => gtext('model name'),
+ 'other_names' => gtext('possible other names of the device'),
+ 'pci_id' => gtext("VendorID:ProductID code of the device"),
+ 'comm_year' => gtext('year of commercialization'),
+ 'interface' => gtext("interface"),
+ 'distribution' => gtext('GNU/Linux distribution used for the test'),
+ 'kernel' => gtext('tested with the following kernel libre'),
+ 'compatibility' => gtext("does it work with free software?"),
+ 'driver' => gtext("free driver used"),
+ 'description' => gtext('Description'),
+ );
+
+ $this->fieldsWithBreaks = array(gtext('Description'),gtext('possible other names of the device'));
+
+ parent::__construct();
+ }
+
+} \ No newline at end of file
diff --git a/Application/Models/RevisionsModel.php b/Application/Models/RevisionsModel.php
new file mode 100644
index 0000000..fd56db7
--- /dev/null
+++ b/Application/Models/RevisionsModel.php
@@ -0,0 +1,50 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class RevisionsModel extends Model_Tree {
+
+ public $id_user = 0;
+ public $type = ''; //device type
+
+ public function __construct() {
+ $this->_tables='revisions';
+ $this->_idFields='id_rev';
+
+ $this->_where=array(
+ 'id_hard'=>'revisions'
+ );
+
+ $this->orderBy = 'id_rev desc';
+
+ parent::__construct();
+ }
+
+ public function getIdHard($id_rev = 0)
+ {
+ $clean['id_rev'] = (int)$id_rev;
+
+ $res = $this->db->select('revisions','id_hard','id_rev='.$clean['id_rev']);
+
+ return (count($res) > 0) ? $res[0]['revisions']['id_hard'] : 0;
+ }
+
+} \ No newline at end of file
diff --git a/Application/Models/ScannersModel.php b/Application/Models/ScannersModel.php
new file mode 100644
index 0000000..4710503
--- /dev/null
+++ b/Application/Models/ScannersModel.php
@@ -0,0 +1,68 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class ScannersModel extends GenericModel
+{
+
+ public $type = 'scanner'; //device type
+
+ public function __construct()
+ {
+
+ $this->_popupItemNames = array(
+ 'vendor' => 'vendor',
+ 'compatibility' => 'compatibility',
+ 'comm_year' => 'comm_year',
+ 'interface' => 'interface',
+ );
+
+ $this->_popupLabels = array(
+ 'vendor' => gtext("vendor"),
+ 'compatibility' => gtext("compatibility"),
+ 'comm_year' => gtext("year"),
+ 'interface' => gtext("interface"),
+ );
+
+ $this->createPopupWhere('vendor,compatibility,comm_year,interface');
+
+ $this->setPopupFunctions();
+
+ $this->diffFields = array(
+ 'vendor' => gtext("vendor"),
+ 'model' => gtext('model name'),
+ 'other_names' => gtext('possible other names of the device'),
+ 'pci_id' => gtext("VendorID:ProductID code of the device"),
+ 'comm_year' => gtext('year of commercialization'),
+ 'interface' => gtext("interface"),
+ 'distribution' => gtext('GNU/Linux distribution used for the test'),
+ 'compatibility' => gtext('compatibility with free software'),
+ 'kernel' => gtext('tested with the following kernel libre'),
+ 'driver' => gtext("free driver used"),
+ 'description' => gtext('Description'),
+ );
+
+ $this->fieldsWithBreaks = array(gtext('Description'),gtext('possible other names of the device'));
+
+ parent::__construct();
+ }
+
+} \ No newline at end of file
diff --git a/Application/Models/SdcardreadersModel.php b/Application/Models/SdcardreadersModel.php
new file mode 100644
index 0000000..85950a5
--- /dev/null
+++ b/Application/Models/SdcardreadersModel.php
@@ -0,0 +1,68 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class SdcardreadersModel extends GenericModel
+{
+
+ public $type = 'sd-card-reader'; //device type
+
+ public function __construct()
+ {
+
+ $this->_popupItemNames = array(
+ 'vendor' => 'vendor',
+ 'comm_year' => 'comm_year',
+ 'sd_card_works' => 'sd_card_works',
+ 'interface' => 'interface',
+ );
+
+ $this->_popupLabels = array(
+ 'vendor' => gtext("vendor"),
+ 'comm_year' => gtext("year"),
+ 'sd_card_works' => gtext("does it work?"),
+ 'interface' => gtext("interface"),
+ );
+
+ $this->setPopupFunctions();
+
+ $this->createPopupWhere('vendor,sd_card_works,comm_year,interface');
+
+ $this->diffFields = array(
+ 'vendor' => gtext("vendor"),
+ 'model' => gtext('model name'),
+ 'other_names' => gtext('possible other names of the device'),
+ 'pci_id' => gtext("VendorID:ProductID code of the device"),
+ 'comm_year' => gtext('year of commercialization'),
+ 'interface' => gtext("interface"),
+ 'distribution' => gtext('GNU/Linux distribution used for the test'),
+ 'kernel' => gtext('tested with the following kernel libre'),
+ 'sd_card_works' => gtext("does it work with free software?"),
+ 'driver' => gtext("free driver used"),
+ 'description' => gtext('Description'),
+ );
+
+ $this->fieldsWithBreaks = array(gtext('Description'),gtext('possible other names of the device'));
+
+ parent::__construct();
+ }
+
+} \ No newline at end of file
diff --git a/Application/Models/SoundcardsModel.php b/Application/Models/SoundcardsModel.php
new file mode 100644
index 0000000..7137d79
--- /dev/null
+++ b/Application/Models/SoundcardsModel.php
@@ -0,0 +1,68 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class SoundcardsModel extends GenericModel
+{
+
+ public $type = 'soundcard'; //device type
+
+ public function __construct()
+ {
+
+ $this->_popupItemNames = array(
+ 'vendor' => 'vendor',
+ 'comm_year' => 'comm_year',
+ 'sound_card_works' => 'sound_card_works',
+ 'interface' => 'interface',
+ );
+
+ $this->_popupLabels = array(
+ 'vendor' => gtext("vendor"),
+ 'comm_year' => gtext("year"),
+ 'sound_card_works' => gtext("does it work?"),
+ 'interface' => gtext("interface"),
+ );
+
+ $this->setPopupFunctions();
+
+ $this->createPopupWhere('vendor,sound_card_works,comm_year,interface');
+
+ $this->diffFields = array(
+ 'vendor' => gtext("vendor"),
+ 'model' => gtext('model name'),
+ 'other_names' => gtext('possible other names of the device'),
+ 'pci_id' => gtext("VendorID:ProductID code of the device"),
+ 'comm_year' => gtext('year of commercialization'),
+ 'interface' => gtext("interface"),
+ 'distribution' => gtext('GNU/Linux distribution used for the test'),
+ 'kernel' => gtext('tested with the following kernel libre'),
+ 'sound_card_works' => gtext("does it work with free software?"),
+ 'driver' => gtext("free driver used"),
+ 'description' => gtext('Description'),
+ );
+
+ $this->fieldsWithBreaks = array(gtext('Description'),gtext('possible other names of the device'));
+
+ parent::__construct();
+ }
+
+} \ No newline at end of file
diff --git a/Application/Models/TalkModel.php b/Application/Models/TalkModel.php
new file mode 100644
index 0000000..1d15ab7
--- /dev/null
+++ b/Application/Models/TalkModel.php
@@ -0,0 +1,116 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class TalkModel extends BaseModel {
+
+ public function __construct() {
+ $this->_tables = 'talk';
+ $this->_idFields = 'id_talk';
+
+ $this->_where=array(
+ 'id_hard' => 'talk',
+ 'has_confirmed' => 'regusers',
+ '-deleted' => 'regusers',
+ );
+
+ $this->orderBy = 'talk.id_talk desc';
+
+ $this->strongConditions['insert'] = array(
+ "checkLength|99" => 'title',
+ "+checkNotEmpty" => 'message',
+ "++checkLength|5000" => 'message',
+ );
+
+ parent::__construct();
+ }
+
+ public function pUpdate($id)
+ {
+ return parent::update($id);
+ }
+
+ public function insert()
+ {
+ if (parent::insert())
+ {
+ //update the history
+ $this->updateHistory('talk_ins');
+
+ if (strcmp($this->values['id_hard'],0) !== 0)
+ {
+ $clean['id_hard'] = (int)$this->values['id_hard'];
+ $clean['created_by'] = (int)$this->values['created_by'];
+
+ $hard = new HardwareModel();
+ $users = $hard->select('username,e_mail')
+ ->where(array('id_hard'=>$clean['id_hard'],'has_confirmed'=>0,'deleted'=>'no'))
+ ->toList('regusers.username','regusers.e_mail')
+ ->send('Boxes');
+
+ $talkUsers = $this->select('username,e_mail')
+ ->from('talk inner join regusers')
+ ->on('talk.created_by = regusers.id_user')
+ ->where(array('id_hard'=>$clean['id_hard'],'has_confirmed'=>0,'-deleted'=>'no'))
+ ->toList('regusers.username','regusers.e_mail')
+ ->send();
+
+ $allUsers = array_merge($users,$talkUsers);
+
+ $userObj = new UsersModel();
+ $myName = $userObj->getUser($clean['created_by']);
+
+ $arrayE = new ArrayExt();
+ $fusers = $arrayE->subsetComplementary($allUsers,$myName);
+
+ //remove users that do not want the email notification
+ $inString = "'".implode("','",array_keys($fusers))."'";
+ $profile = new ProfileModel();
+ $ffusers = $profile->select('username,e_mail')
+ ->from('regusers inner join profile')
+ ->on('regusers.id_user = profile.created_by')
+ ->where(array('send_notification'=>'yes','username'=>"in($inString)"))
+ ->toList('regusers.username','regusers.e_mail')
+ ->send();
+
+ $ffusers = array_flip($ffusers);
+
+ //send the notice
+ Account::sendTalkNotice($myName,$ffusers,$clean['id_hard']);
+
+ $domainName = rtrim(Url::getRoot(),"/");
+ header('Refresh: 0;url='.$domainName.$_SERVER['REQUEST_URI']);
+ exit;
+ }
+ }
+ }
+
+ public $formStruct = array(
+ 'entries' => array(
+ 'title' => array(),
+ 'message' => array('type'=>'Textarea'),
+ 'id_talk' => array(
+ 'type' => 'Hidden'
+ )
+ ),
+ );
+
+} \ No newline at end of file
diff --git a/Application/Models/ThreegcardsModel.php b/Application/Models/ThreegcardsModel.php
new file mode 100644
index 0000000..88ae580
--- /dev/null
+++ b/Application/Models/ThreegcardsModel.php
@@ -0,0 +1,68 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class ThreegcardsModel extends GenericModel
+{
+
+ public $type = '3G-card'; //device type
+
+ public function __construct()
+ {
+
+ $this->_popupItemNames = array(
+ 'vendor' => 'vendor',
+ 'comm_year' => 'comm_year',
+ 'wifi_works' => 'wifi_works',
+ 'interface' => 'interface',
+ );
+
+ $this->_popupLabels = array(
+ 'vendor' => gtext("vendor"),
+ 'comm_year' => gtext("year"),
+ 'wifi_works' => gtext("does it work?"),
+ 'interface' => gtext("interface"),
+ );
+
+ $this->setPopupFunctions();
+
+ $this->createPopupWhere('vendor,wifi_works,comm_year,interface');
+
+ $this->diffFields = array(
+ 'vendor' => gtext("vendor"),
+ 'model' => gtext('model name'),
+ 'other_names' => gtext('possible other names of the device'),
+ 'pci_id' => gtext("VendorID:ProductID code of the device"),
+ 'comm_year' => gtext('year of commercialization'),
+ 'interface' => gtext("interface"),
+ 'distribution' => gtext('GNU/Linux distribution used for the test'),
+ 'kernel' => gtext('tested with the following kernel libre'),
+ 'wifi_works' => gtext("does it work with free software?"),
+ 'driver' => gtext("free driver used"),
+ 'description' => gtext('Description'),
+ );
+
+ $this->fieldsWithBreaks = array(gtext('Description'),gtext('possible other names of the device'));
+
+ parent::__construct();
+ }
+
+} \ No newline at end of file
diff --git a/Application/Models/UsersModel.php b/Application/Models/UsersModel.php
new file mode 100755
index 0000000..e666e36
--- /dev/null
+++ b/Application/Models/UsersModel.php
@@ -0,0 +1,295 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class UsersModel extends Model_Map
+{
+
+ public static $usersList = array();
+
+ public function __construct()
+ {
+ $this->_tables='regusers,reggroups,regusers_groups';
+ $this->_idFields='id_user,id_group';
+
+ $this->_where=array(
+ 'id_group' => 'reggroups',
+ 'id_user' => 'regusers',
+ 'name' => 'reggroups',
+ 'confirmation_token'=> 'regusers',
+ 'has_confirmed' => 'regusers',
+ 'deleted' => 'regusers',
+ 'forgot_token' => 'regusers'
+ );
+
+ $this->_popupItemNames = array(
+ 'has_confirmed'=>'has_confirmed',
+ 'deleted'=>'deleted',
+ 'id_group'=>'name',
+ );
+
+ $this->_popupLabels = array(
+ 'has_confirmed'=>'HAS CONFIRMED?',
+ 'deleted'=>'DELETED?',
+ 'id_group'=>'GROUP'
+ );
+
+ $this->orderBy = 'regusers.id_user desc';
+
+ parent::__construct();
+
+ $this->deleteNotRegistered();
+ }
+
+ public function pUpdate($id)
+ {
+ return parent::update($id);
+ }
+
+ public function deleteNotRegistered()
+ {
+ $limit = time() - Account::$confirmTime;
+ $this->db->del('regusers','has_confirmed = 1 and deleted = "no" and creation_time < '.$limit);
+ }
+
+ public function getUser($id_user = 0)
+ {
+ $clean['id_user'] = (int)$id_user;
+ if (array_key_exists($clean['id_user'],self::$usersList))
+ {
+ return self::$usersList[$clean['id_user']];
+ }
+ else
+ {
+ $user = $this->db->select('regusers','username,has_confirmed','id_user='.$clean['id_user']);
+ if (count($user) > 0)
+ {
+ $fuser = (strcmp($user[0]['regusers']['has_confirmed'],0) === 0) ? $user[0]['regusers']['username'] : "__".$user[0]['regusers']['username'];
+ self::$usersList[$clean['id_user']] = $fuser;
+ return $fuser;
+ }
+ else
+ {
+ return "<i>__anonymous__</i>";
+ }
+ }
+ }
+
+ public function getLinkToUser($user)
+ {
+ if (strstr($user,'__'))
+ {
+ return $user;
+// return str_replace('__',null,$user);
+ }
+ else
+ {
+ return "<a href='".Url::getRoot()."meet/user/".Lang::$current."/$user'>$user</a>";
+ }
+ }
+
+ public function getLinkToUserFromId($id_user = 0)
+ {
+ $clean['id_user'] = (int)$id_user;
+ return $this->getLinkToUser($this->getUser($clean['id_user']));
+ }
+
+ //check if the user exists
+ public function userExists($user)
+ {
+ $clean['user'] = ctype_alnum($user) ? sanitizeAll($user) : '';
+
+ if (strcmp($clean['user'],'') !== 0)
+ {
+ $res = $this->where(array("username"=>$clean['user'],"has_confirmed"=>"0","deleted"=>"no"))->send();
+// $res = $this->db->select('regusers','has_confirmed','username="'.$clean['user'].'" and has_confirmed=0 and deleted="no"');
+
+ if (count($res) > 0)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ //get the user id from the username
+ public function getUserId($username = '')
+ {
+ $clean['username'] = ctype_alnum($username) ? sanitizeAll($username) : '';
+
+ $users = $this->select('id_user')->where(array('username'=>$clean['username'],'has_confirmed'=>0,'deleted'=>'no'))->send();
+ if (count($users) > 0)
+ {
+ return $users[0]['regusers']['id_user'];
+ }
+ else
+ {
+ return 0;
+ }
+ }
+
+ public function isBlocked($idUser)
+ {
+ $clean['id_user'] = (int)$idUser;
+
+ $res = $this->select('blocked')->where(array('id_user'=>$clean['id_user'],'has_confirmed'=>0,'deleted'=>'no'))->toList('blocked')->send();
+
+ if (count($res) > 0)
+ {
+ return strcmp($res[0],'yes') === 0 ? true : false;
+ }
+
+ return true;
+ }
+
+ public function insert()
+ {
+ //create the token
+ $confirmation_token = md5(randString(20));
+ $this->values['confirmation_token'] = $confirmation_token;
+ //has_confirmed flag
+ $this->values['has_confirmed'] = 1;
+ $this->values['creation_time'] = time();
+
+ //random ID
+ $randomId = md5(randString(5).uniqid(mt_rand(),true));
+ $this->values["temp_field"] = $randomId;
+
+ if (isset($_POST['captcha']))
+ {
+ if ( strcmp($_SESSION['captchaString'],$_POST['captcha']) === 0 )
+ {
+
+ parent::insert();
+
+ if ($this->queryResult)
+ {
+ $resId = $this->db->select("regusers","id_user","temp_field='$randomId'");
+ $clean['id_user'] = $resId[0]['regusers']['id_user'];
+ $this->db->update("regusers",'temp_field',array(''),'id_user='.$clean['id_user']);
+
+ $result = Account::confirm($this->values['username'],$this->values['e_mail'],$clean['id_user'],$confirmation_token);
+
+ if ($result)
+ {
+ $_SESSION['status'] = 'sent';
+ }
+ else
+ {
+ $_SESSION['status'] = 'regerror';
+ }
+
+ $hed = new HeaderObj(DOMAIN_NAME);
+ $hed->redirect('users/notice/'.Lang::$current);
+ }
+
+ }
+ else
+ {
+ $this->result = false;
+ $this->queryResult = false;
+ $this->notice = "<div class='alert'>Wrong captcha code...</div>\n";
+ }
+ }
+ }
+
+ public function close($id_user)
+ {
+ $clean['id_user'] = (int)$id_user;
+
+ $this->values = array(
+ 'has_confirmed' => 1,
+ 'deleted' => 'yes',
+ 'e_mail' => ''
+ );
+
+ if ($this->update($clean['id_user']))
+ {
+ $_SESSION['status'] = 'deleted';
+
+ $profile = new ProfileModel();
+ $res = $profile->db->select('profile','id_prof','created_by='.$clean['id_user']);
+
+ if (count($res) > 0)
+ {
+ $clean['id_prof'] = (int)$res[0]['profile']['id_prof'];
+ $profile->values = array(
+ 'real_name' => '',
+ 'where_you_are' => '',
+ 'birth_date' => '',
+ 'fav_distro' => '',
+ 'projects' => '',
+ 'description' => ''
+ );
+ $profile->update($clean['id_prof']);
+ }
+ }
+
+ }
+
+ public function forgot($username)
+ {
+ $clean['username'] = ctype_alnum($username) ? sanitizeAll($username) : '';
+
+ if (isset($_POST['captcha']))
+ {
+ if ( strcmp($_SESSION['captchaString'],$_POST['captcha']) === 0 )
+ {
+ $res = $this->db->select('regusers','e_mail,id_user','username="'.$clean['username'].'" and has_confirmed = 0 and deleted = "no"');
+ if (count($res) > 0)
+ {
+ $e_mail = $res[0]['regusers']['e_mail'];
+ $id_user = (int)$res[0]['regusers']['id_user'];
+ $forgot_token = md5(randString(20));
+ $forgot_time = time();
+ $updateArray = array($forgot_token, $forgot_time);
+ $this->db->update('regusers','forgot_token,forgot_time',$updateArray,'username="'.$clean['username'].'"');
+
+ $result = Account::sendnew($clean['username'],$e_mail,$id_user,$forgot_token);
+
+ if ($result)
+ {
+ $_SESSION['status'] = 'sent_new';
+ }
+ else
+ {
+ $_SESSION['status'] = 'sent_new_error';
+ }
+
+ $hed = new HeaderObj(DOMAIN_NAME);
+ $hed->redirect('users/notice/'.Lang::$current,1);
+
+ }
+ else
+ {
+ $this->notice = "<div class='alert'>the user does not exist</div>\n";
+ }
+ }
+ else
+ {
+ $this->result = false;
+ $this->queryResult = false;
+ $this->notice = "<div class='alert'>Wrong captcha code...</div>\n";
+ }
+ }
+ }
+
+} \ No newline at end of file
diff --git a/Application/Models/VendorsModel.php b/Application/Models/VendorsModel.php
new file mode 100644
index 0000000..0b06d52
--- /dev/null
+++ b/Application/Models/VendorsModel.php
@@ -0,0 +1,82 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class VendorsModel extends Model_Tree {
+
+ public function __construct() {
+ $this->_tables = 'vendors';
+ $this->_idFields = 'id_vendor';
+
+ parent::__construct();
+ }
+
+ public function check($id,$interface = 'USB')
+ {
+ if (preg_match('/^[a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}$/',$id))
+ {
+ $clean['bus'] = strcmp($interface,'USB') === 0 ? "USB" : "PCI";
+
+ $temp = explode(':',$id);
+ $clean['vendorId'] = sanitizeAlphanum($temp[0]);
+
+ $number = $this->clear()->where(array("vendorid" => $clean['vendorId'], "bus" => $clean['bus']))->rowNumber();
+
+ if ($number > 0)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public function getName($id,$interface)
+ {
+ if ($this->check($id,$interface))
+ {
+ $clean['bus'] = strcmp($interface,'USB') === 0 ? "USB" : "PCI";
+
+ $temp = explode(':',$id);
+ $clean['vendorId'] = sanitizeAlphanum($temp[0]);
+
+ $res = $this->clear()->where(array("vendorid" => $clean['vendorId'], "bus" => $clean['bus']))->send();
+
+ if (count($res) > 0)
+ {
+ return $res[0]['vendors']['clean_name'];
+ }
+ }
+ return 'not-known';
+ }
+
+ public function getFullName($name)
+ {
+ $clean['name'] = sanitizeAll($name);
+
+ $res = $this->clear()->where(array("clean_name" => $clean['name']))->send();
+
+ if (count($res) > 0)
+ {
+ return $res[0]['vendors']['full_name'];
+ }
+ return $clean['name'];
+ }
+} \ No newline at end of file
diff --git a/Application/Models/VideocardsModel.php b/Application/Models/VideocardsModel.php
new file mode 100644
index 0000000..961340e
--- /dev/null
+++ b/Application/Models/VideocardsModel.php
@@ -0,0 +1,68 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class VideocardsModel extends GenericModel
+{
+
+ public $type = 'videocard'; //device type
+
+ public function __construct()
+ {
+
+ $this->_popupItemNames = array(
+ 'vendor' => 'vendor',
+ 'comm_year' => 'comm_year',
+ 'video_card_works' => 'video_card_works',
+ 'interface' => 'interface',
+ );
+
+ $this->_popupLabels = array(
+ 'vendor' => gtext("vendor"),
+ 'comm_year' => gtext("year"),
+ 'video_card_works' => gtext("does it work?"),
+ 'interface' => gtext("interface"),
+ );
+
+ $this->createPopupWhere('vendor,video_card_works,comm_year,interface');
+
+ $this->setPopupFunctions();
+
+ $this->diffFields = array(
+ 'vendor' => gtext("vendor"),
+ 'model' => gtext('model name'),
+ 'other_names' => gtext('possible other names of the device'),
+ 'pci_id' => gtext("VendorID:ProductID code of the device"),
+ 'comm_year' => gtext('year of commercialization'),
+ 'interface' => gtext("interface"),
+ 'distribution' => gtext('GNU/Linux distribution used for the test'),
+ 'kernel' => gtext('tested with the following kernel libre'),
+ 'video_card_works' => gtext("how does it work with free software?"),
+ 'driver' => gtext("free driver used"),
+ 'description' => gtext('Description'),
+ );
+
+ $this->fieldsWithBreaks = array(gtext('Description'),gtext('possible other names of the device'));
+
+ parent::__construct();
+ }
+
+} \ No newline at end of file
diff --git a/Application/Models/WebcamsModel.php b/Application/Models/WebcamsModel.php
new file mode 100644
index 0000000..0942bcb
--- /dev/null
+++ b/Application/Models/WebcamsModel.php
@@ -0,0 +1,72 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class WebcamsModel extends GenericModel
+{
+
+ public $type = 'webcam'; //device type
+
+ public function __construct()
+ {
+
+ $this->_popupItemNames = array(
+ 'vendor' => 'vendor',
+ 'comm_year' => 'comm_year',
+ 'webcam_works' => 'webcam_works',
+ 'interface' => 'interface',
+ );
+
+ $this->_popupLabels = array(
+ 'vendor' => gtext("vendor"),
+ 'comm_year' => gtext("year"),
+ 'webcam_works' => gtext("does it work?"),
+ 'interface' => gtext("interface"),
+ );
+
+ $this->_popupFunctions = array(
+ 'vendor' => 'betterVendor',
+ );
+
+ $this->createPopupWhere('vendor,webcam_works,comm_year,interface');
+
+ $this->setPopupFunctions();
+
+ $this->diffFields = array(
+ 'vendor' => gtext("vendor"),
+ 'model' => gtext('model name'),
+ 'other_names' => gtext('possible other names of the device'),
+ 'pci_id' => gtext("VendorID:ProductID code of the device"),
+ 'comm_year' => gtext('year of commercialization'),
+ 'interface' => gtext("interface"),
+ 'distribution' => gtext('GNU/Linux distribution used for the test'),
+ 'kernel' => gtext('tested with the following kernel libre'),
+ 'webcam_works' => gtext("does it work with free software?"),
+ 'driver' => gtext("free driver used"),
+ 'description' => gtext('Description'),
+ );
+
+ $this->fieldsWithBreaks = array(gtext('Description'),gtext('possible other names of the device'));
+
+ parent::__construct();
+ }
+
+} \ No newline at end of file
diff --git a/Application/Models/WifiModel.php b/Application/Models/WifiModel.php
new file mode 100644
index 0000000..0b6d6c2
--- /dev/null
+++ b/Application/Models/WifiModel.php
@@ -0,0 +1,68 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class WifiModel extends GenericModel
+{
+
+ public $type = 'wifi'; //device type
+
+ public function __construct()
+ {
+
+ $this->_popupItemNames = array(
+ 'vendor' => 'vendor',
+ 'comm_year' => 'comm_year',
+ 'wifi_works' => 'wifi_works',
+ 'interface' => 'interface',
+ );
+
+ $this->_popupLabels = array(
+ 'vendor' => gtext("vendor"),
+ 'comm_year' => gtext("year"),
+ 'wifi_works' => gtext("does it work?"),
+ 'interface' => gtext("interface"),
+ );
+
+ $this->setPopupFunctions();
+
+ $this->createPopupWhere('vendor,wifi_works,comm_year,interface');
+
+ $this->diffFields = array(
+ 'vendor' => gtext("vendor"),
+ 'model' => gtext('model name'),
+ 'other_names' => gtext('possible other names of the device'),
+ 'pci_id' => gtext("VendorID:ProductID code of the device"),
+ 'comm_year' => gtext('year of commercialization'),
+ 'interface' => gtext("interface"),
+ 'distribution' => gtext('GNU/Linux distribution used for the test'),
+ 'kernel' => gtext('tested with the following kernel libre'),
+ 'wifi_works' => gtext("does it work with free software?"),
+ 'driver' => gtext("free driver used"),
+ 'description' => gtext('Description'),
+ );
+
+ $this->fieldsWithBreaks = array(gtext('Description'),gtext('possible other names of the device'));
+
+ parent::__construct();
+ }
+
+} \ No newline at end of file
diff --git a/Application/Models/WikiModel.php b/Application/Models/WikiModel.php
new file mode 100644
index 0000000..bb60b66
--- /dev/null
+++ b/Application/Models/WikiModel.php
@@ -0,0 +1,319 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class WikiModel extends Model_Map {
+
+ public $id_user = 0;
+ public $lastId = 0; //the id of the last record inserted
+ public $lastTitle = null; //the title of the last page inserted
+ public $lastTitleClean = null; //the cleaned title of the last page inserted
+
+ public $diffFields = array();
+ public $fieldsWithBreaks = array();
+
+ public function __construct() {
+ $this->_tables='wiki,regusers,wiki_users';
+ $this->_idFields='id_wiki,id_user';
+ $this->_where=array(
+ 'username' => 'regusers',
+ 'id_user' => 'regusers',
+ 'has_confirmed' => 'regusers',
+ 'deleted' => 'regusers',
+ '-deleted' => 'wiki',
+ '-blocked' => 'wiki',
+ );
+
+ $this->printAssError = "no";
+
+ $this->diffFields = array(
+ 'title' => gtext("the title"),
+ 'page' => gtext('the text of the wiki page'),
+ );
+
+ $this->fieldsWithBreaks = array(gtext('the text of the wiki page'));
+
+ $this->strongConditions['insert'] = array(
+ "checkNotEmpty" => 'title',
+ "checkLength|99" => 'title|'.gtext('title is too long'),
+ "+checkNotEmpty" => 'page',
+ "+checkLength|49900" => 'page|'.gtext('the page text is too long'),
+ );
+
+ $this->strongConditions['update'] = array(
+ "checkNotEmpty" => 'title',
+ "checkLength|99" => 'title|'.gtext('title is too long'),
+ "+checkNotEmpty" => 'page',
+ "+checkLength|49900" => 'page|'.gtext('the page text is too long'),
+ );
+
+ $this->databaseConditions['insert'] = array(
+ "checkUnique" => 'title|'.gtext('a page with the same title already exists'),
+ );
+
+ $this->databaseConditions['update'] = array(
+ "checkUniqueCompl" => 'title|'.gtext('a page with the same title already exists'),
+ );
+
+ parent::__construct();
+ }
+
+ public function pUpdate($id)
+ {
+ return parent::update($id);
+ }
+
+ public function insert()
+ {
+ $this->values['created_by'] = (int)$this->id_user;
+ $this->values['update_date'] = date('Y-m-d H:i:s');
+
+ //random ID
+ $randomId = md5(uniqid(mt_rand(),true));
+ $this->values["title_clean"] = $randomId;
+
+ parent::insert();
+
+ //associate the user to the record
+ if ($this->queryResult)
+ {
+ $resId = $this->select()->where(array('title_clean'=>$randomId))->send();
+ $clean['id'] = $resId[0]['wiki']['id_wiki'];
+ $this->lastId = $clean['id'];
+ $this->lastTitle = $resId[0]['wiki']['title'];
+ $this->lastTitleClean = titleForRedirect($resId[0]['wiki']['title']);
+ $this->db->update('wiki','title_clean',array(encodeUrl(sanitizeDb($resId[0]['wiki']['title']))),'id_wiki='.$clean['id']);
+
+ //update the history table
+ $this->updateHistory('insert');
+
+ $this->associate($clean['id']);
+ }
+
+ }
+
+ public function update($id = null, $where = null)
+ {
+ $clean['id'] = (int)$id;
+
+ $this->values['created_by'] = (int)$this->id_user;
+ $this->values['update_date'] = date('Y-m-d H:i:s');
+ $this->values['title_clean'] = encodeUrl($this->values['title']);
+
+ //save the old fields in the revisions table
+ $this->setWhereQueryClause(array('id_wiki' => $clean['id']));
+ $oldStruct = $this->getFields($this->fields.',title_clean,created_by,update_date,id_wiki');
+
+ if (count($oldStruct > 0))
+ {
+ $oldValues = $oldStruct[0]['wiki'];
+
+ $revisions = new WikirevisionsModel();
+ $revisions->values = $oldValues;
+
+ $revisions->sanitize();
+
+ if ($revisions->insert())
+ {
+
+ if ($this->isMain($clean['id']))
+ {
+ $this->values['title'] = 'Main Page';
+ $this->values['title_clean'] = 'Main-Page';
+ }
+
+ parent::update($clean['id']);
+ if ($this->queryResult)
+ {
+ $this->lastId = $clean['id'];
+ $this->lastTitle = $this->values['title'];
+ $this->lastTitleClean = html_entity_decode($this->values['title_clean'],ENT_QUOTES,DEFAULT_CHARSET);
+
+ //update the history table
+ $this->updateHistory('update');
+
+ if (!$this->checkAssociation($clean['id'],(int)$this->id_user))
+ {
+ $this->associate($clean['id']);
+ }
+ }
+ }
+ }
+ }
+
+ public function makeCurrent($id_rev)
+ {
+
+ $clean['id_rev'] = (int)$id_rev;
+
+ $revisions = new WikirevisionsModel();
+
+ $clean['id_wiki'] = (int)$revisions->getIdPage($clean['id_rev']);
+
+ //save the old fields in the revisions table
+ $this->where(array('id_wiki'=>$clean['id_wiki']));
+ $oldStruct = $this->getFields($this->fields.',title_clean,created_by,update_date,id_wiki');
+
+ if (count($oldStruct > 0))
+ {
+ //get the values of the revision
+ $revisions->where(array('id_rev'=>$clean['id_rev']));
+ $newStruct = $revisions->getFields($this->fields.',title_clean,created_by,update_date');
+
+ if (count($newStruct > 0))
+ {
+ $revisions->values = $oldStruct[0]['wiki'];
+ $revisions->sanitize();
+
+ $this->values = $newStruct[0]['wiki_revisions'];
+ $this->values['created_by'] = (int)$this->id_user;
+ $this->values['update_date'] = date('Y-m-d H:i:s');
+
+ $this->sanitize();
+
+ if ($this->isMain($clean['id_wiki']))
+ {
+ $this->values['title'] = 'Main Page';
+ $this->values['title_clean'] = 'Main-Page';
+ }
+
+ if ($revisions->insert())
+ {
+ if (parent::update($clean['id_wiki']))
+ {
+ $this->lastId = $clean['id_wiki'];
+ $this->lastTitle = $this->values['title'];
+ $this->lastTitleClean = html_entity_decode($this->values['title_clean'],ENT_QUOTES,DEFAULT_CHARSET);
+
+ //update the history table
+ $this->updateHistory('update');
+
+ if (!$this->checkAssociation($clean['id_wiki'],(int)$this->id_user))
+ {
+ $this->associate($clean['id_wiki']);
+ }
+ }
+ }
+ }
+ }
+
+ }
+
+ public function associate($id_record = null, $idGroup = null)
+ {
+ return parent::associate((int)$id_record,(int)$this->id_user);
+ }
+
+ //get the model name
+ public function getTheModelName($id, $cleaned = false)
+ {
+ $clean['id'] = (int)$id;
+ $this->setWhereQueryClause(array('id_wiki' => $clean['id']));
+ $res = $this->getFields('title,title_clean');
+ $name = '';
+ if (count($res) > 0)
+ {
+ if ($cleaned)
+ {
+ $name = $res[0]['wiki']['title_clean'];
+ }
+ else
+ {
+ $name = $res[0]['wiki']['title'];
+ }
+ }
+ return $name;
+ }
+
+ //save in the history all the action carried out by users
+ protected function updateHistory($action)
+ {
+ $translations = array(
+ 'insert' => 'inserted',
+ 'update' => 'updated',
+ );
+
+ $allowedActions = array('insert','update');
+
+ if (in_array($action,$allowedActions))
+ {
+ $users = new UsersModel();
+
+ $clean['user'] = sanitizeAll($users->getUser($this->id_user));
+
+ $history = new HistoryModel();
+ $history->values = array(
+ 'created_by' => $this->id_user,
+ 'type' => 'wiki',
+ 'action' => $action,
+ 'id' => $this->lastId,
+ 'message' => 'The wiki page having id='.$this->lastId.' has been '.$translations[$action].' by the user ' . $clean['user'] . ' (id_user='.$this->id_user.') ',
+ 'gr' => 'registered',
+ );
+ $history->insert();
+ }
+ }
+
+ public function isMain($id)
+ {
+ $clean['id'] = (int)$id;
+ $res = $this->select('is_main')->where(array('id_wiki'=>$clean['id']))->send();
+ if ( count($res) > 0 )
+ {
+ return strcmp($res[0]['wiki']['is_main'],'no') === 0 ? false : true;
+ }
+ return false;
+ }
+
+ public function isDeleted($id)
+ {
+ $clean['id'] = (int)$id;
+ $res = $this->select('wiki.deleted')->where(array('id_wiki'=>$clean['id']))->send();
+ if ( count($res) > 0 )
+ {
+ return strcmp($res[0]['wiki']['deleted'],'no') === 0 ? false : true;
+ }
+ return false;
+ }
+
+ public function isBlocked($id)
+ {
+ $clean['id'] = (int)$id;
+ $res = $this->select('blocked')->where(array('id_wiki'=>$clean['id']))->send();
+ if ( count($res) > 0 )
+ {
+ return strcmp($res[0]['wiki']['blocked'],'no') === 0 ? false : true;
+ }
+ return false;
+ }
+
+ public function toWikiPage($id)
+ {
+ $clean['id'] = (int)$id;
+ $title = $this->getTheModelName($clean['id'], true);
+ return Url::getRoot()."wiki/page/".Lang::$current."/".$title;
+ }
+
+ public function getDiffArray($oldArray, $newArray)
+ {
+ return getDiffArray($this->diffFields, $oldArray, $newArray);
+ }
+} \ No newline at end of file
diff --git a/Application/Models/WikirevisionsModel.php b/Application/Models/WikirevisionsModel.php
new file mode 100644
index 0000000..fdf5558
--- /dev/null
+++ b/Application/Models/WikirevisionsModel.php
@@ -0,0 +1,45 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class WikirevisionsModel extends Model_Tree {
+
+ public $id_user = 0;
+
+ public function __construct() {
+ $this->_tables='wiki_revisions';
+ $this->_idFields='id_rev';
+
+ $this->orderBy = 'id_rev desc';
+
+ parent::__construct();
+ }
+
+ public function getIdPage($id_rev = 0)
+ {
+ $clean['id_rev'] = (int)$id_rev;
+
+ $res = $this->db->select('wiki_revisions','id_wiki','id_rev='.$clean['id_rev']);
+
+ return (count($res) > 0) ? $res[0]['wiki_revisions']['id_wiki'] : 0;
+ }
+
+} \ No newline at end of file
diff --git a/Application/Models/WikitalkModel.php b/Application/Models/WikitalkModel.php
new file mode 100644
index 0000000..7dee896
--- /dev/null
+++ b/Application/Models/WikitalkModel.php
@@ -0,0 +1,112 @@
+<?php
+
+// h-source, a web software to build a community of people that want to share their hardware information.
+// Copyright (C) 2010 Antonio Gallo (h-source-copyright.txt)
+//
+// This file is part of h-source
+//
+// h-source is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// h-source is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with h-source. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+class WikitalkModel extends BaseModel
+{
+
+ public function __construct() {
+ $this->_tables = 'wiki_talk';
+ $this->_idFields = 'id_talk';
+
+ $this->_where=array(
+ 'id_wiki' => 'wiki_talk',
+ 'has_confirmed' => 'regusers',
+ '-deleted' => 'regusers',
+ );
+
+ $this->orderBy = 'wiki_talk.id_talk';
+
+ $this->strongConditions['insert'] = array(
+ "checkLength|99" => 'title',
+ "+checkLength|5000" => 'message',
+ );
+
+ parent::__construct();
+ }
+
+ public function pUpdate($id)
+ {
+ return parent::update($id);
+ }
+
+ public function insert()
+ {
+ if (parent::insert())
+ {
+ //update the history
+ $this->updateHistory('wiki_talk_ins');
+
+ $clean['id_wiki'] = (int)$this->values['id_wiki'];
+ $clean['created_by'] = (int)$this->values['created_by'];
+
+ $hard = new WikiModel();
+ $users = $hard->select('username,e_mail')
+ ->where(array('id_wiki'=>$clean['id_wiki'],'has_confirmed'=>0,'deleted'=>'no'))
+ ->toList('regusers.username','regusers.e_mail')
+ ->send('Boxes');
+
+ $talkUsers = $this->select('username,e_mail')
+ ->inner('regusers')
+ ->on('wiki_talk.created_by = regusers.id_user')
+ ->where(array('id_wiki'=>$clean['id_wiki'],'has_confirmed'=>0,'-deleted'=>'no'))
+ ->toList('regusers.username','regusers.e_mail')
+ ->send();
+
+ $allUsers = array_merge($users,$talkUsers);
+
+ $userObj = new UsersModel();
+ $myName = $userObj->getUser($clean['created_by']);
+
+ $arrayE = new ArrayExt();
+ $fusers = $arrayE->subsetComplementary($allUsers,$myName);
+
+ //remove users that do not want the email notification
+ $inString = "'".implode("','",array_keys($fusers))."'";
+ $profile = new ProfileModel();
+ $ffusers = $profile->select('username,e_mail')
+ ->from('regusers inner join profile')
+ ->on('regusers.id_user = profile.created_by')
+ ->where(array('send_notification'=>'yes','username'=>"in($inString)"))
+ ->toList('regusers.username','regusers.e_mail')
+ ->send();
+
+ $ffusers = array_flip($ffusers);
+
+ //send the notice
+ Account::sendWikiTalkNotice($myName,$ffusers,$clean['id_wiki']);
+
+ header('Refresh: 0;url='.Url::getRoot()."wiki/talk/".Lang::$current."/".$clean['id_wiki']);
+ exit;
+ }
+ }
+
+ public $formStruct = array(
+ 'entries' => array(
+ 'title' => array(),
+ 'message' => array('type'=>'Textarea'),
+ 'id_talk' => array(
+ 'type' => 'Hidden'
+ )
+ ),
+ );
+
+} \ No newline at end of file