123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- <?php
- global $_,$conf;
- switch($_['action']){
- /** CHAT **/
- //Récuperation d'une liste de chat
- case 'rocketchat_chat_search':
- Action::write(function(&$response){
- global $myUser,$_;
- User::check_access('rocketchat','read');
- require_once(__DIR__.SLASH.'Chat.class.php');
-
- // OPTIONS DE RECHERCHE, A ACTIVER POUR UNE RECHERCHE AVANCEE
- $query = 'SELECT * FROM '.Chat::tableName().' WHERE 1';
- $data = array();
- //Recherche simple
- if(!empty($_['filters']['keyword'])){
- $query .= ' AND label LIKE ?';
- $data[] = '%'.$_['filters']['keyword'].'%';
- }
- //Recherche avancée
- if(isset($_['filters']['advanced'])) filter_secure_query($_['filters']['advanced'],array('label'),$query,$data);
- //Tri des colonnes
- if(isset($_['sort'])) sort_secure_query($_['sort'],array('label'),$query,$data);
- //Pagination
- $response['pagination'] = Chat::paginate(20,(!empty($_['page'])?$_['page']:0),$query,$data);
- $chats = Chat::staticQuery($query,$data,true,0);
-
- foreach($chats as $chat){
- $row = $chat->toArray();
- $response['rows'][] = $row;
- }
-
- });
- break;
-
- //Ajout ou modification d'élément chat
- case 'rocketchat_chat_save':
- Action::write(function(&$response){
- global $myUser,$_;
- User::check_access('rocketchat','edit');
- require_once(__DIR__.SLASH.'Chat.class.php');
- $item = Chat::provide();
- $item->save();
- });
- break;
-
-
- //Suppression d'élement chat
- case 'rocketchat_chat_delete':
- Action::write(function(&$response){
- global $myUser,$_;
- User::check_access('rocketchat','delete');
- require_once(__DIR__.SLASH.'Chat.class.php');
- Chat::deleteById($_['id']);
-
- });
- break;
-
- //Sauvegarde des configurations de rocketchat
- case 'rocketchat_setting_save':
- Action::write(function(&$response){
- global $myUser,$_,$conf;
- User::check_access('rocketchat','configure');
- //Si input file "multiple", possibilité de normlaiser le
- //tableau $_FILES récupéré avec la fonction => normalize_php_files();
-
- foreach(Configuration::setting('rocketchat') as $key=>$value){
- if(!is_array($value)) continue;
- $allowed[] = $key;
- }
- foreach ($_['fields'] as $key => $value) {
- if(in_array($key, $allowed))
- $conf->put($key,$value);
- }
- });
- break;
-
- case 'rocketchat_widget_load':
- global $myUser;
- User::check_access('rocketchat','read');
- require_once(__DIR__.SLASH.'..'.SLASH.'dashboard'.SLASH.'DashboardWidget.class.php');
- $widget = DashboardWidget::current();
- $widget->title = 'Widget Rocketchat';
- ob_start();
- //Décommenter après avoir créé widget.php
- require_once(__DIR__.SLASH.'widget.php');
- $widget->content = ob_get_clean();
-
- echo json_encode($widget);
- break;
-
- case 'rocketchat_widget_rocketchat_configure':
- global $myUser;
- User::check_access('rocketchat','read');
- require_once(PLUGIN_PATH.'dashboard'.SLASH.'DashboardWidget.class.php');
- $widget = DashboardWidget::current();
- ob_start();
- require_once(__DIR__.SLASH.'widget.configure.php');
- $content = ob_get_clean();
- echo $content ;
- break;
- case 'rocketchat_widget_rocketchat_configure_save':
- Action::write(function(&$response){
- global $myUser,$_;
- User::check_access('rocketchat','read');
- require_once(PLUGIN_PATH.'dashboard'.SLASH.'DashboardWidget.class.php');
- $widget = DashboardWidget::getById($_['id']);
- $widget->data('chan',$_['widget-rocketchat-chan']);
- $widget->save();
- });
- break;
- }
- ?>
|