Newer
Older
/**
* Copyright Maarch since 2008 under licence GPLv3.
* See LICENCE.txt file at the root folder for more details.
* This file is part of Maarch software.
* @brief notes
* @author <dev@maarch.org>
* @ingroup notes
*/
require_once "core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_request.php";
require_once "apps".DIRECTORY_SEPARATOR.$_SESSION['config']['app_id'].DIRECTORY_SEPARATOR
."class".DIRECTORY_SEPARATOR."class_lists.php";
require_once "modules".DIRECTORY_SEPARATOR."notes".DIRECTORY_SEPARATOR."notes_tables.php";
require_once "modules" . DIRECTORY_SEPARATOR . "notes" . DIRECTORY_SEPARATOR
. "class" . DIRECTORY_SEPARATOR
. "class_modules_tools.php";
$core_tools = new core_tools();
$request = new request();
$identifier = '';
$origin = '';
$parameters = '';
//Collection ID
if (isset($_REQUEST['coll_id']) && !empty($_REQUEST['coll_id'])) {
$parameters = "&coll_id=".$_REQUEST['coll_id'];
}
if (isset($_REQUEST['identifier']) && !empty($_REQUEST['identifier'])) {
$identifier = $_REQUEST['identifier'];
} else {
echo '<span class="error">'._IDENTIFIER.' '._IS_EMPTY.'</span>';
exit();
}
if (isset($_REQUEST['origin']) && !empty($_REQUEST['origin'])) {
$origin = $_REQUEST['origin'];
}
$user = \User\models\UserModel::getByLogin(['login' => $_SESSION['user']['UserId'], 'select' => ['id']]);
$right = \Resource\controllers\ResController::hasRightByResId(['resId' => [$identifier], 'userId' => $user['id']]);
if (isset($_REQUEST['size']) && !empty($_REQUEST['size'])) {
$parameters .= '&size='.$_REQUEST['size'];
}
if (isset($_REQUEST['order']) && !empty($_REQUEST['order'])) {
$parameters .= '&order='.$_REQUEST['order'];
}
if (isset($_REQUEST['order_field']) && !empty($_REQUEST['order_field'])) {
$parameters .= '&order_field='.$_REQUEST['order_field'];
}
if (isset($_REQUEST['what']) && !empty($_REQUEST['what'])) {
$parameters .= '&what='.$_REQUEST['what'];
}
$core_tools->load_header('', true, false); ?>
<body><?php
$core_tools->load_js();
//Load list
if (!empty($identifier) && !empty($origin)) {
$target = $_SESSION['config']['businessappurl']
.'index.php?module=notes&page=notes&identifier='
.$identifier.'&origin='.$origin.$parameters;
$listContent = $list->loadList($target);
echo $listContent;
} else {
echo '<span class="error">'._ERROR_IN_PARAMETERS.'</span>';
} ?>
<div id="container" style="width:100%;min-height:0px;height:0px;"></div>
</body>
</html><?php
//If size is full change some parameters
if (isset($_REQUEST['size'])
&& ($_REQUEST['size'] == "full")
) {
$sizeUser = "10";
$sizeText = "40";
$css = "listing spec";
$cutString = 150;
} elseif (isset($_REQUEST['size'])
&& ($_REQUEST['size'] == "medium")
) {
$sizeUser = "15";
$sizeText = "30";
$css = "listingsmall";
$cutString = 100;
} else {
$sizeUser = "10";
$sizeText = "10";
$css = "listingsmall";
$cutString = 20;
}
$select[NOTES_TABLE] = array(); //Notes
$select[USERS_TABLE] = array(); //Users
array_push($select[NOTES_TABLE], "id", "identifier", "creation_date", "user_id", "note_text", "note_text as note_short"); //Notes
array_push($select[USERS_TABLE], "user_id", "lastname || ' ' || firstname as user", "lastname as visibleBy"); //Users

Florian Azizian
committed
$rawUserEntities = \Entity\models\EntityModel::getByLogin(['login' => $_SESSION['user']['UserId'], 'select' => ['entity_id']]);
$userEntities = array_column($rawUserEntities, 'entity_id');
$userEntities = !empty($userEntities) ? $userEntities : [''];
$db = new Database();
$stmt3 = $db->query("SELECT id FROM USERS WHERE user_id = ?", array($_SESSION['user']['UserId']));
$userInfo = $stmt3->fetchObject();
$where_tab[] = "identifier = ?";
$where_tab[] = "type = ?";
$where_tab[] = "notes.id in (select notes.id from notes left join note_entities on notes.id = note_entities.note_id where item_id IS NULL OR item_id in (?) or notes.user_id = ".$userInfo->id.")";
$arrayPDO[] = 'resource';

Florian Azizian
committed
$arrayPDO[] = $userEntities;

Florian Azizian
committed
//Build where
$where = implode(' and ', $where_tab);
//Order
$order = $order_field = '';
$order = $list->getOrder();
$order_field = $list->getOrderField();
if (!empty($order_field) && !empty($order)) {
$orderstr = "order by ".$order_field." ".$order;
} else {
$list->setOrder();
$list->setOrderField('creation_date');
$orderstr = "order by creation_date desc";
}
if (isset($_REQUEST['start']) && !empty($_REQUEST['start'])) {
$parameters .= '&start='.$_REQUEST['start'];
$start = $_REQUEST['start'];
} else {
$start = $list->getStart();
$parameters .= '&start='.$start;
}
// $tabNotes=$request->PDOselect(
// $select,
// $where,
// $arrayPDO,
// $orderstr,
// $_SESSION['config']['databasetype'],
// "default",
// true,
// NOTES_TABLE,
// USERS_TABLE,
// "user_id",
// true,
// false,
// false,
// $start
// );
// $request->show_array($tabNotes);
for ($indNotes1 = 0; $indNotes1 < count($tabNotes); $indNotes1 ++) {
for ($indNotes2 = 0; $indNotes2 < count($tabNotes[$indNotes1]); $indNotes2 ++) {
foreach (array_keys($tabNotes[$indNotes1][$indNotes2]) as $value) {
if ($tabNotes[$indNotes1][$indNotes2][$value] == "id") {
$tabNotes[$indNotes1][$indNotes2]["id"] = $tabNotes[$indNotes1][$indNotes2]['value'];
$tabNotes[$indNotes1][$indNotes2]["label"] = 'ID';
$tabNotes[$indNotes1][$indNotes2]["size"] = 1;
$tabNotes[$indNotes1][$indNotes2]["label_align"] = "left";
$tabNotes[$indNotes1][$indNotes2]["align"] = "left";
$tabNotes[$indNotes1][$indNotes2]["valign"] = "bottom";
$tabNotes[$indNotes1][$indNotes2]["show"] = false;
$tabNotes[$indNotes1][$indNotes2]["order"] = "id";
$indNotes1d = $tabNotes[$indNotes1][$indNotes2]['value'];
}
if ($tabNotes[$indNotes1][$indNotes2][$value] == "user_id") {
$tabNotes[$indNotes1][$indNotes2]["user_id"] = $tabNotes[$indNotes1][$indNotes2]['value'];
$tabNotes[$indNotes1][$indNotes2]["label"] = _ID;
$tabNotes[$indNotes1][$indNotes2]["size"] = 5;
$tabNotes[$indNotes1][$indNotes2]["label_align"] = "left";
$tabNotes[$indNotes1][$indNotes2]["align"] = "left";
$tabNotes[$indNotes1][$indNotes2]["valign"] = "bottom";
$tabNotes[$indNotes1][$indNotes2]["show"] = false;
$tabNotes[$indNotes1][$indNotes2]["order"] = "user_id";
}
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
if ($tabNotes[$indNotes1][$indNotes2][$value] == "creation_date") {
$tabNotes[$indNotes1][$indNotes2]["creation_date"] = $tabNotes[$indNotes1][$indNotes2]['value'];
$tabNotes[$indNotes1][$indNotes2]["value"] = $core_tools->format_date_db($tabNotes[$indNotes1][$indNotes2]['value'], false, '', true);
$tabNotes[$indNotes1][$indNotes2]["label"] = _DATE;
$tabNotes[$indNotes1][$indNotes2]["size"] = 10;
$tabNotes[$indNotes1][$indNotes2]["label_align"] = "left";
$tabNotes[$indNotes1][$indNotes2]["align"] = "left";
$tabNotes[$indNotes1][$indNotes2]["valign"] = "bottom";
$tabNotes[$indNotes1][$indNotes2]["show"] = true;
$tabNotes[$indNotes1][$indNotes2]["order"] = "creation_date";
}
if ($tabNotes[$indNotes1][$indNotes2][$value] == "user") {
$tabNotes[$indNotes1][$indNotes2]["user"] = $tabNotes[$indNotes1][$indNotes2]['value'];
$tabNotes[$indNotes1][$indNotes2]["label"] = _USER;
$tabNotes[$indNotes1][$indNotes2]["size"] = 10;
$tabNotes[$indNotes1][$indNotes2]["label_align"] = "left";
$tabNotes[$indNotes1][$indNotes2]["align"] = "left";
$tabNotes[$indNotes1][$indNotes2]["valign"] = "bottom";
$tabNotes[$indNotes1][$indNotes2]["show"] = true;
$tabNotes[$indNotes1][$indNotes2]["order"] = "lastname";
}
if ($tabNotes[$indNotes1][$indNotes2][$value] == "note_text") {
//$tabNotes[$indNotes1][$indNotes2]["note_text"] = $tabNotes[$indNotes1][$indNotes2]['value'];
$tabNotes[$indNotes1][$indNotes2]["note_text"] = $request->cut_string($request->show_string($tabNotes[$indNotes1][$indNotes2]['value']), $cutString);
$tabNotes[$indNotes1][$indNotes2]["label"] = _NOTES;
$tabNotes[$indNotes1][$indNotes2]["size"] = 60;
$tabNotes[$indNotes1][$indNotes2]["label_align"] = "left";
$tabNotes[$indNotes1][$indNotes2]["align"] = "left";
$tabNotes[$indNotes1][$indNotes2]["valign"] = "bottom";
$tabNotes[$indNotes1][$indNotes2]["show"] = true;
$tabNotes[$indNotes1][$indNotes2]["order"] = "note_text";
}
if ($tabNotes[$indNotes1][$indNotes2][$value] == "visibleby") {
$noteEntities = $notes_tools->getNotesEntities($indNotes1d);
$tabEntityLabel = [];
$tabEntityId = [];
$allEntities = '';
$allEntitiesId = '';
foreach ($noteEntities as $value) {
$tabEntityLabel[] = $value->short_label;
$tabEntityId[] = $value->entity_id;
}
if (!empty($tabEntityLabel)) {
$allEntities = implode(' - ', $tabEntityLabel);
if (count($tabEntityId) > 3) {
$allEntitiesId = $tabEntityId[0] .'<br/>'.$tabEntityId[1].'<br/>'.$tabEntityId[2].'<br/>...';
} else {
$allEntitiesId = implode('<br/>', $tabEntityId);
}

Henri Queneau
committed
}
$tabNotes[$indNotes1][$indNotes2]['value'] = '<div style="cursor:pointer;text-overflow: ellipsis;clear:both;white-space: nowrap;overflow: hidden;"><i title="'.$allEntities.'" >'.$allEntitiesId.'</i></div>';
$tabNotes[$indNotes1][$indNotes2]["label"] = _VISIBLEBY;
$tabNotes[$indNotes1][$indNotes2]["size"] = 10;
$tabNotes[$indNotes1][$indNotes2]["label_align"] = "left";
$tabNotes[$indNotes1][$indNotes2]["align"] = "left";
$tabNotes[$indNotes1][$indNotes2]["valign"] = "bottom";
$tabNotes[$indNotes1][$indNotes2]["show"] = true;
}
//List
$listKey = 'id'; //Clé de la liste
$paramsTab = array(); //Initialiser le tableau de paramètres
$paramsTab['bool_sortColumn'] = true; //Affichage Tri
$paramsTab['pageTitle'] =''; //Titre de la page
$paramsTab['bool_bigPageTitle'] = false; //Affichage du titre en grand
$paramsTab['urlParameters'] = 'identifier='.$identifier
."&origin=".$origin.'&display=true'.$parameters; //Parametres d'url supplementaires
$paramsTab['filters'] = array(); //Filtres
$paramsTab['listHeight'] = '100%'; //Hauteur de la liste
$paramsTab['tools'] = array(); //Icones dans la barre d'outils
"script" => "showNotesForm('".$_SESSION['config']['businessappurl']
. "index.php?display=true&module=notes&page=notes_ajax_content"
. "&mode=add&identifier=".$identifier."&origin=".$origin
. $parameters."')",
array_push($paramsTab['tools'], $add);
//Action icons array
$paramsTab['actionIcons'] = array();
"script" => "showNotesForm('".$_SESSION['config']['businessappurl']
."index.php?display=true&module=notes&page=notes_ajax_content"
."&mode=up&id=@@id@@&identifier=".$identifier."&origin=".$origin
. $parameters."');",
"class" => "read",
// "label" => _UPDATE.'/'._DELETE,
"tooltip" => _UPDATE.'/'._DELETION,
"disabledRules" => "@@user_id@@ != '".$_SESSION['user']['UserId']."'"
);
array_push($paramsTab['actionIcons'], $read);
//Output
$status = 0;
$content = $list->showList($tabNotes, $paramsTab, $listKey);
echo "{status : " . $status . ", content : '" . addslashes($debug.$content) . "', error : '" . addslashes($error) . "'}";
}