public function doAction() { try { $out = ''; $cName = $this->doorGets->controllerNameNow(); // Init langue $lgActuel = $this->doorGets->getLangueTradution(); $moduleInfos = $this->doorGets->moduleInfos($this->doorGets->Uri, $lgActuel); $User = $this->doorGets->user; // Init url redirection $redirectUrl = './?controller=module' . $moduleInfos['type'] . '&uri=' . $this->doorGets->Uri . '&lg=' . $lgActuel; // Check if is content modo $is_modo = in_array($moduleInfos['id'], $User['liste_module_modo']) ? true : false; // Check if is module modo in_array('module', $User['liste_module_interne']) && in_array('module_' . $moduleInfos['type'], $User['liste_module_interne']) ? $is_modules_modo = true : ($is_modules_modo = false); // check if user can edit content $user_can_edit = in_array($moduleInfos['id'], $User['liste_module_edit']) ? true : false; // check if user can delete content $user_can_delete = in_array($moduleInfos['id'], $User['liste_module_delete']) ? true : false; // Init count total contents $countContents = 0; $arrForCountSearchQuery[] = array('key' => "id_user", 'type' => '=', 'value' => $User['id']); $countContents = $this->doorGets->getCountTable($this->doorGets->Table, $arrForCountSearchQuery); // Check limit to add content $isLimited = 0; if (array_key_exists($moduleInfos['id'], $User['liste_module_limit']) && $User['liste_module_limit'] !== '0') { $isLimited = (int) $User['liste_module_limit'][$moduleInfos['id']]; } // get Content for edit / delete $params = $this->doorGets->Params(); if (array_key_exists('id', $params['GET'])) { $id = $params['GET']['id']; $isContent = $this->doorGets->dbQS($id, $this->doorGets->Table); if (!empty($isContent)) { if ($lgGroupe = @unserialize($isContent['groupe_traduction'])) { $idLgGroupe = $lgGroupe[$lgActuel]; $isContentTraduction = $this->doorGets->dbQS($idLgGroupe, $this->doorGets->Table . '_traduction'); if (!empty($isContentTraduction)) { $isContent = array_merge($isContent, $isContentTraduction); } // test if user can edit content if ($isContent['id_user'] !== $this->doorGets->user['id'] && !in_array($isContent['id_groupe'], $this->doorGets->user['liste_enfant_modo'])) { FlashInfo::set($this->doorGets->__("Vous n'avez pas les droits pour afficher ce contenu"), "error"); $this->doorGets->_redirect($redirectUrl); } } } } $champsNonObligatoire = array('article_tinymce', 'meta_titre', 'meta_description', 'meta_keys', 'sendto', 'id_disqus', 'image_gallery', 'meta_facebook_titre', 'meta_facebook_description', 'meta_facebook_image', 'meta_twitter_titre', 'meta_twitter_description', 'meta_twitter_image', 'meta_twitter_player', 'tags'); $messageSuccess = $this->doorGets->__("Vos informations ont bien été mises à jour"); switch ($this->Action) { case 'add': if (!empty($this->doorGets->Form->i)) { $this->doorGets->checkMode(); $cResultsInt = $this->doorGets->getCountTable($this->doorGets->Table); $listToCategories = ''; // gestion des champs vide foreach ($this->doorGets->Form->i as $k => $v) { if (!in_array($k, $champsNonObligatoire) && empty($v)) { $this->doorGets->Form->e[$cName . '_add_' . $k] = 'ok'; } $iCat = explode('_', $k); if (!empty($iCat) && $iCat[0] === 'categories' && is_numeric($iCat[1])) { $listToCategories .= '#' . $iCat[1] . ','; unset($this->doorGets->Form->i[$k]); } } if (empty($this->doorGets->Form->e)) { $image_gallery = $this->doorGets->Form->i['image_gallery']; // Copy images gallery to real path $this->doorGets->copyFileToRealPath($this->doorGets->Uri, $image_gallery); } // validation si aucune erreur if (empty($this->doorGets->Form->e)) { if (!array_key_exists('active', $this->doorGets->Form->i)) { $this->doorGets->Form->i['active'] = 3; } if (!array_key_exists('author_badge', $this->doorGets->Form->i)) { $this->doorGets->Form->i['author_badge'] = $is_modo ? 0 : $moduleInfos['author_badge']; } if (!array_key_exists('comments', $this->doorGets->Form->i)) { $this->doorGets->Form->i['comments'] = 0; } if (!array_key_exists('partage', $this->doorGets->Form->i)) { $this->doorGets->Form->i['partage'] = 0; } if (!array_key_exists('facebook', $this->doorGets->Form->i)) { $this->doorGets->Form->i['facebook'] = 0; } if (!array_key_exists('disqus', $this->doorGets->Form->i)) { $this->doorGets->Form->i['disqus'] = 0; } if (!array_key_exists('in_rss', $this->doorGets->Form->i)) { $this->doorGets->Form->i['in_rss'] = 0; } // $data['pseudo'] = $User['pseudo']; $data['author_badge'] = $this->doorGets->Form->i['author_badge']; $data['id_user'] = $this->doorGets->user['id']; $data['id_groupe'] = $this->doorGets->user['groupe']; $data['categorie'] = $listToCategories; $data['ordre'] = $cResultsInt + 1; $data['active'] = $this->doorGets->Form->i['active']; if (!$is_modo) { $data['active'] = 3; } $data['comments'] = $this->doorGets->Form->i['comments']; $data['partage'] = $this->doorGets->Form->i['partage']; $data['facebook'] = $this->doorGets->Form->i['facebook']; $data['disqus'] = $this->doorGets->Form->i['disqus']; $data['in_rss'] = $this->doorGets->Form->i['in_rss']; $data['date_creation'] = time(); $idContent = $this->doorGets->dbQI($data, $this->doorGets->Table); $titre = $this->doorGets->Form->i['titre']; foreach ($this->doorGets->getAllLanguages() as $k => $v) { $dataNext = array('titre' => $titre, 'uri' => $this->doorGets->Form->i['uri'], 'article_tinymce' => $this->doorGets->Form->i['article_tinymce'], 'meta_titre' => $this->doorGets->Form->i['meta_titre'], 'meta_description' => $this->doorGets->Form->i['meta_description'], 'meta_keys' => $this->doorGets->Form->i['meta_keys'], 'image' => $this->doorGets->Form->i['image'], 'image_gallery' => $image_gallery, 'tags' => $this->doorGets->Form->i['tags'], 'meta_facebook_type' => $this->doorGets->Form->i['meta_facebook_type'], 'meta_facebook_titre' => $this->doorGets->Form->i['meta_facebook_titre'], 'meta_facebook_description' => $this->doorGets->Form->i['meta_facebook_description'], 'meta_facebook_image' => $this->doorGets->Form->i['meta_facebook_image'], 'meta_twitter_type' => $this->doorGets->Form->i['meta_twitter_type'], 'meta_twitter_titre' => $this->doorGets->Form->i['meta_twitter_titre'], 'meta_twitter_description' => $this->doorGets->Form->i['meta_twitter_description'], 'meta_twitter_image' => $this->doorGets->Form->i['meta_twitter_image'], 'meta_twitter_player' => $this->doorGets->Form->i['meta_twitter_player']); $dataNext['categorie'] = $listToCategories; $dataNext['date_modification'] = $data['date_creation']; $dataNext['id_content'] = $idContent; $dataNext['langue'] = $k; $dataNext['uri'] = $this->doorGets->Form->i['uri'] . '-' . $idContent . '-' . $k; $idTraduction[$k] = $this->doorGets->dbQI($dataNext, $this->doorGets->Table . '_traduction'); } $dataModification['groupe_traduction'] = serialize($idTraduction); $this->doorGets->dbQU($idContent, $dataModification, $this->doorGets->Table); // Tracker $usersTracking = new UsersTrackEntity(null, $this->doorGets); $usersTracking->setIdSession(session_id())->setIpUser($_SERVER['REMOTE_ADDR'])->setUrlPage($_SERVER['REQUEST_URI'])->setUrlReferer($_SERVER['HTTP_REFERER'])->setIdUser($User['id'])->setTitle($dataNext['titre'])->setIdGroupe($User['groupe'])->setLangue($lgActuel)->setUriModule($this->doorGets->Uri)->setIdContent($idContent)->setAction($this->Action)->setDate(time())->save(); if (!$is_modo) { $moderation = new ModerationEntity(null, $this->doorGets); $moderation->setIdContent($idContent)->setIdUser($User['id'])->setPseudo($User['pseudo'])->setIdGroupe($User['groupe'])->setUriModule($this->doorGets->Uri)->setTypeModule('image')->setAction($this->Action)->setLangue($lgActuel)->setDateCreation(time())->save(); $this->doorGets->sendEmailNotificationToGroupe($moduleInfos['uri_notification_moderator'], $moduleInfos['id']); $messageSuccess = $this->doorGets->__("Votre contenu est en cours de modération"); } $dataModification['groupe_traduction'] = serialize($idTraduction); $this->doorGets->dbQU($idContent, $dataModification, $this->doorGets->Table); // Copy image to real path $this->doorGets->copyFileToRealPath($this->doorGets->Uri, $this->doorGets->Form->i['image']); // Copy image to real path $this->doorGets->copyFileToRealPath($this->doorGets->Uri, $this->doorGets->Form->i['meta_facebook_image']); $this->doorGets->copyFileToRealPath($this->doorGets->Uri, $this->doorGets->Form->i['meta_twitter_image']); $this->doorGets->successHeaderResponse($messageSuccess, $redirectUrl . '&action=edit&id=' . $idContent); } $this->doorGets->errorHeaderResponse($this->doorGets->__("Veuillez remplir correctement le formulaire"), $this->doorGets->Form->e); } break; case 'edit': if (!empty($this->doorGets->Form->i) && $user_can_edit) { $this->doorGets->checkMode(); $listToCategories = ''; // gestion des champs vide foreach ($this->doorGets->Form->i as $k => $v) { if (!in_array($k, $champsNonObligatoire) && empty($v)) { $this->doorGets->Form->e[$cName . '_edit_' . $k] = 'ok'; } $iCat = explode('_', $k); if (!empty($iCat) && $iCat[0] === 'categories' && is_numeric($iCat[1])) { $listToCategories .= '#' . $iCat[1] . ','; unset($this->doorGets->Form->i[$k]); } } if (empty($this->doorGets->Form->e)) { $image_gallery = $this->doorGets->Form->i['image_gallery']; // Copy images gallery to real path $this->doorGets->copyFileToRealPath($this->doorGets->Uri, $image_gallery); } if (empty($this->doorGets->Form->e)) { if (!array_key_exists('active', $this->doorGets->Form->i)) { $this->doorGets->Form->i['active'] = $isContent['active']; } if (!array_key_exists('author_badge', $this->doorGets->Form->i)) { $this->doorGets->Form->i['author_badge'] = $is_modo ? 0 : $isContent['author_badge']; } if (!array_key_exists('comments', $this->doorGets->Form->i)) { $this->doorGets->Form->i['comments'] = $is_modo ? 0 : $isContent['comments']; } if (!array_key_exists('partage', $this->doorGets->Form->i)) { $this->doorGets->Form->i['partage'] = $is_modo ? 0 : $isContent['partage']; } if (!array_key_exists('facebook', $this->doorGets->Form->i)) { $this->doorGets->Form->i['facebook'] = $is_modo ? 0 : $isContent['facebook']; } if (!array_key_exists('disqus', $this->doorGets->Form->i)) { $this->doorGets->Form->i['disqus'] = $is_modo ? 0 : $isContent['disqus']; } if (!array_key_exists('in_rss', $this->doorGets->Form->i)) { $this->doorGets->Form->i['in_rss'] = $is_modo ? 0 : $isContent['in_rss']; } $image = $isContent['image']; if (!empty($this->doorGets->Form->i['image'])) { $image = $this->doorGets->Form->i['image']; // Copy image to real path $this->doorGets->copyFileToRealPath($this->doorGets->Uri, $this->doorGets->Form->i['image']); } $imageFacebook = $isContent['meta_facebook_image']; if (!empty($this->doorGets->Form->i['meta_facebook_image'])) { $imageFacebook = $this->doorGets->Form->i['meta_facebook_image']; // Copy image to real path $this->doorGets->copyFileToRealPath($this->doorGets->Uri, $this->doorGets->Form->i['meta_facebook_image']); } $imageTwitter = $isContent['meta_twitter_image']; if (!empty($this->doorGets->Form->i['meta_twitter_image'])) { $imageTwitter = $this->doorGets->Form->i['meta_twitter_image']; // Copy image to real path $this->doorGets->copyFileToRealPath($this->doorGets->Uri, $this->doorGets->Form->i['meta_twitter_image']); } $dataContenu['categorie'] = $listToCategories; $dataContenu['author_badge'] = $this->doorGets->Form->i['author_badge']; $dataContenu['active'] = $this->doorGets->Form->i['active']; if (!$is_modo) { $dataContenu['active'] = 3; } $dataContenu['comments'] = $this->doorGets->Form->i['comments']; $dataContenu['partage'] = $this->doorGets->Form->i['partage']; $dataContenu['facebook'] = $this->doorGets->Form->i['facebook']; $dataContenu['disqus'] = $this->doorGets->Form->i['disqus']; $dataContenu['in_rss'] = $this->doorGets->Form->i['in_rss']; $dataTraduction = array('titre' => $this->doorGets->Form->i['titre'], 'uri' => $this->doorGets->Form->i['uri'], 'article_tinymce' => $this->doorGets->Form->i['article_tinymce'], 'meta_titre' => $this->doorGets->Form->i['meta_titre'], 'meta_description' => $this->doorGets->Form->i['meta_description'], 'meta_keys' => $this->doorGets->Form->i['meta_keys'], 'categorie' => $listToCategories, 'image' => $image, 'image_gallery' => $image_gallery, 'tags' => $this->doorGets->Form->i['tags'], 'meta_facebook_type' => $this->doorGets->Form->i['meta_facebook_type'], 'meta_facebook_titre' => $this->doorGets->Form->i['meta_facebook_titre'], 'meta_facebook_description' => $this->doorGets->Form->i['meta_facebook_description'], 'meta_facebook_image' => $imageFacebook, 'meta_twitter_type' => $this->doorGets->Form->i['meta_twitter_type'], 'meta_twitter_titre' => $this->doorGets->Form->i['meta_twitter_titre'], 'meta_twitter_description' => $this->doorGets->Form->i['meta_twitter_description'], 'meta_twitter_image' => $imageTwitter, 'meta_twitter_player' => $this->doorGets->Form->i['meta_twitter_player'], 'date_modification' => time()); $dataVersion = $dataTraduction; $this->saveLastContentVersion($isContent['id_content'], $dataVersion); // Tracker $usersTracking = new UsersTrackEntity(null, $this->doorGets); $usersTracking->setIdSession(session_id())->setIpUser($_SERVER['REMOTE_ADDR'])->setUrlPage($_SERVER['REQUEST_URI'])->setUrlReferer($_SERVER['HTTP_REFERER'])->setIdUser($User['id'])->setTitle($dataTraduction['titre'])->setIdGroupe($User['groupe'])->setLangue($lgActuel)->setUriModule($this->doorGets->Uri)->setIdContent($isContent['id_content'])->setAction($this->Action)->setDate(time())->save(); if (!$is_modo) { $moderation = new ModerationEntity(null, $this->doorGets); $moderation->setIdContent($isContent['id_content'])->setIdUser($User['id'])->setPseudo($User['pseudo'])->setIdGroupe($User['groupe'])->setUriModule($this->doorGets->Uri)->setTypeModule('image')->setAction($this->Action)->setLangue($lgActuel)->setDateCreation(time())->save(); $this->doorGets->sendEmailNotificationToGroupe($moduleInfos['uri_notification_moderator'], $moduleInfos['id']); $messageSuccess = $this->doorGets->__("Votre contenu est en cours de modération"); } else { $uri_module = $this->doorGets->Uri; $id_content = $isContent['id_content']; $this->doorGets->dbQL("\n DELETE FROM _moderation \n WHERE id_content = '{$id_content}' \n AND uri_module = '{$uri_module}'\n LIMIT 1000\n "); $uriNotification = $dataContenu['active'] === '2' ? $moduleInfos['uri_notification_user_success'] : $moduleInfos['uri_notification_user_error']; $this->doorGets->sendEmailNotificationToUser($uriNotification, $isContent['id_user']); } // Update Data $this->doorGets->dbQU($isContent['id_content'], $dataContenu, $this->doorGets->Table); $this->doorGets->dbQU($isContent['id'], $dataTraduction, $this->doorGets->Table . '_traduction'); $this->doorGets->successHeaderResponse($messageSuccess); } $this->doorGets->errorHeaderResponse($this->doorGets->__("Veuillez remplir correctement le formulaire"), $this->doorGets->Form->e); } break; case 'delete': if (!empty($this->doorGets->Form->i) && $user_can_delete) { $this->doorGets->checkMode(); if (empty($this->doorGets->Form->e)) { $lgGroupe = unserialize($isContent['groupe_traduction']); foreach ($lgGroupe as $v) { @$this->doorGets->dbQD($v, $this->doorGets->Table . '_traduction'); } @unlink(BASE . 'data/' . $this->doorGets->getRealUri($this->doorGets->Uri) . '/' . $isContent['image']); $this->doorGets->dbQD($isContent['id_content'], $this->doorGets->Table); $this->doorGets->dbQL("DELETE FROM _dg_comments WHERE uri_module = '" . $this->doorGets->Uri . "' AND uri_content = '" . $isContent['id_content'] . "' "); $this->doorGets->dbQL("UPDATE " . $this->doorGets->Table . " SET ordre = ordre - 1 WHERE ordre > " . $isContent['ordre'] . " "); //$this->doorGets->clearDBCache(); // Tracker $usersTracking = new UsersTrackEntity(null, $this->doorGets); $usersTracking->setIdSession(session_id())->setIpUser($_SERVER['REMOTE_ADDR'])->setUrlPage($_SERVER['REQUEST_URI'])->setUrlReferer($_SERVER['HTTP_REFERER'])->setIdUser($User['id'])->setTitle($isContent['titre'])->setIdGroupe($User['groupe'])->setLangue($lgActuel)->setUriModule($this->doorGets->Uri)->setIdContent($isContent['id_content'])->setAction($this->Action)->setDate(time())->save(); $this->doorGets->successHeaderResponse($this->doorGets->__("Les données sont supprimées"), $redirectUrl); } } break; } } catch (Exception $e) { // echo $e->getMessage(); // exit(); } }
public function doAction() { try { $out = ''; $cName = $this->doorGets->controllerNameNow(); // Init langue $lgActuel = $this->doorGets->getLangueTradution(); $moduleInfos = $this->doorGets->moduleInfos($this->doorGets->Uri, $lgActuel); $User = $this->doorGets->user; // Check if is content modo $is_modo = in_array($moduleInfos['id'], $User['liste_module_modo']) ? true : false; // Check if is module modo in_array('module', $User['liste_module_interne']) && in_array('module_' . $moduleInfos['type'], $User['liste_module_interne']) ? $is_modules_modo = true : ($is_modules_modo = false); // check if user can edit content $user_can_edit = in_array($moduleInfos['id'], $User['liste_module_edit']) ? true : false; // check if user can delete content $user_can_delete = in_array($moduleInfos['id'], $User['liste_module_delete']) ? true : false; // Init url redirection $redirectUrl = './?controller=module' . $moduleInfos['type'] . '&uri=' . $this->doorGets->Uri . '&lg=' . $lgActuel; // get Content for edit / delete $params = $this->doorGets->Params(); if (array_key_exists('id', $params['GET'])) { $id = $params['GET']['id']; $isContent = $this->doorGets->dbQS($id, $this->doorGets->Table); if (!empty($isContent)) { if ($lgGroupe = @unserialize($isContent['groupe_traduction'])) { $idLgGroupe = $lgGroupe[$lgActuel]; $isContentTraduction = $this->doorGets->dbQS($idLgGroupe, $this->doorGets->Table . '_traduction'); if (!empty($isContentTraduction)) { $isContent = array_merge($isContent, $isContentTraduction); } // test if user can edit content if ($isContent['id_user'] !== $this->doorGets->user['id'] && !in_array($isContent['id_groupe'], $this->doorGets->user['liste_enfant_modo'])) { FlashInfo::set($this->doorGets->__("Vous n'avez pas les droits pour afficher ce contenu"), "error"); $this->doorGets->_redirect($redirectUrl); } } } } $champsNonObligatoire = array(''); $messageSuccess = $this->doorGets->__("Vos informations ont bien été mises à jour"); switch ($this->Action) { case 'add': $this->doorGets->checkMode(); if (!empty($this->doorGets->Form->i)) { $cResultsInt = $this->doorGets->getCountTable($this->doorGets->Table); // gestion des champs vide foreach ($this->doorGets->Form->i as $k => $v) { if (!in_array($k, $champsNonObligatoire) && empty($v)) { $this->doorGets->Form->e[$cName . '_add_' . $k] = 'ok'; } } $var = $this->doorGets->Form->i['url']; $varUrl = filter_var($var, FILTER_VALIDATE_URL); if (empty($varUrl)) { $this->doorGets->Form->e[$cName . '_add_url'] = 'ok'; } // validation si aucune erreur if (empty($this->doorGets->Form->e)) { if (!array_key_exists('active', $this->doorGets->Form->i)) { $this->doorGets->Form->i['active'] = 0; } // $data['pseudo'] = $User['pseudo']; $data['id_user'] = $this->doorGets->user['id']; $data['id_groupe'] = $this->doorGets->user['groupe']; $data['ordre'] = $cResultsInt + 1; $data['active'] = !$is_modo ? 3 : $this->doorGets->Form->i['active']; $data['date_creation'] = time(); $idContent = $this->doorGets->dbQI($data, $this->doorGets->Table); // foreach ($this->doorGets->getAllLanguages() as $k => $v) { $dataNext = array('image' => $this->doorGets->Form->i['image'], 'titre' => $this->doorGets->Form->i['titre'], 'description' => $this->doorGets->Form->i['description'], 'url' => $this->doorGets->Form->i['url']); $dataNext['date_modification'] = $data['date_creation']; $dataNext['id_content'] = $idContent; $dataNext['langue'] = $k; $idTraduction[$k] = $this->doorGets->dbQI($dataNext, $this->doorGets->Table . '_traduction'); } // Copy image to real path $this->doorGets->copyFileToRealPath($this->doorGets->Uri, $this->doorGets->Form->i['image']); $dataModification['groupe_traduction'] = serialize($idTraduction); $this->doorGets->dbQU($idContent, $dataModification, $this->doorGets->Table); // Tracker $usersTracking = new UsersTrackEntity(null, $this->doorGets); $usersTracking->setIdSession(session_id())->setIpUser($_SERVER['REMOTE_ADDR'])->setUrlPage($_SERVER['REQUEST_URI'])->setUrlReferer($_SERVER['HTTP_REFERER'])->setIdUser($User['id'])->setTitle($dataNext['titre'])->setIdGroupe($User['groupe'])->setLangue($lgActuel)->setUriModule($this->doorGets->Uri)->setIdContent($idContent)->setAction($this->Action)->setDate(time())->save(); if (!$is_modo) { $moderation = new ModerationEntity(null, $this->doorGets); $moderation->setIdContent($idContent)->setIdUser($User['id'])->setPseudo($User['pseudo'])->setIdGroupe($User['groupe'])->setUriModule($this->doorGets->Uri)->setTypeModule('partner')->setAction($this->Action)->setLangue($lgActuel)->setDateCreation(time())->save(); $this->doorGets->sendEmailNotificationToGroupe($moduleInfos['uri_notification_moderator'], $moduleInfos['id']); $messageSuccess = $this->doorGets->__("Votre contenu est en cours de modération"); } $this->doorGets->successHeaderResponse($messageSuccess, $redirectUrl); } $this->doorGets->errorHeaderResponse($this->doorGets->__("Veuillez remplir correctement le formulaire"), $this->doorGets->Form->e); } break; case 'edit': if (!empty($this->doorGets->Form->i)) { $this->doorGets->checkMode(); $listToCategories = ''; // gestion des champs vide foreach ($this->doorGets->Form->i as $k => $v) { if (!in_array($k, $champsNonObligatoire) && $k !== 'image' && empty($v)) { $this->doorGets->Form->e[$cName . '_edit_' . $k] = 'ok'; } } if (empty($this->doorGets->Form->i['image'])) { $this->doorGets->Form->i['image'] = $isContent['image']; } if (empty($this->doorGets->Form->e)) { // Copy image to real path $this->doorGets->copyFileToRealPath($this->doorGets->Uri, $this->doorGets->Form->i['image']); $dataContenu['active'] = !$is_modo ? 3 : $this->doorGets->Form->i['active']; $dataTraduction = array('image' => $this->doorGets->Form->i['image'], 'titre' => $this->doorGets->Form->i['titre'], 'description' => $this->doorGets->Form->i['description'], 'url' => $this->doorGets->Form->i['url']); $dataVersion = $dataTraduction; $dataVersion['active'] = $this->doorGets->Form->i['active']; $this->saveLastContentVersion($isContent['id_content'], $dataVersion); // Tracker $usersTracking = new UsersTrackEntity(null, $this->doorGets); $usersTracking->setIdSession(session_id())->setIpUser($_SERVER['REMOTE_ADDR'])->setUrlPage($_SERVER['REQUEST_URI'])->setUrlReferer($_SERVER['HTTP_REFERER'])->setIdUser($User['id'])->setTitle($dataTraduction['titre'])->setIdGroupe($User['groupe'])->setLangue($lgActuel)->setUriModule($this->doorGets->Uri)->setIdContent($isContent['id_content'])->setAction($this->Action)->setDate(time())->save(); if (!$is_modo) { $moderation = new ModerationEntity(null, $this->doorGets); $moderation->setIdContent($isContent['id_content'])->setIdUser($User['id'])->setPseudo($User['pseudo'])->setIdGroupe($User['groupe'])->setUriModule($this->doorGets->Uri)->setTypeModule('blog')->setAction($this->Action)->setLangue($lgActuel)->setDateCreation(time())->save(); $this->doorGets->sendEmailNotificationToGroupe($moduleInfos['uri_notification_moderator'], $moduleInfos['id']); $messageSuccess = $this->doorGets->__("Votre contenu est en cours de modération"); } else { $uri_module = $this->doorGets->Uri; $id_content = $isContent['id_content']; $this->doorGets->dbQL("\n DELETE FROM _moderation \n WHERE id_content = '{$id_content}' \n AND uri_module = '{$uri_module}'\n LIMIT 1000\n "); $uriNotification = $dataContenu['active'] === '2' ? $moduleInfos['uri_notification_user_success'] : $moduleInfos['uri_notification_user_error']; $this->doorGets->sendEmailNotificationToUser($uriNotification, $isContent['id_user']); } // Update Data $this->doorGets->dbQU($isContent['id_content'], $dataContenu, $this->doorGets->Table); $this->doorGets->dbQU($isContent['id'], $dataTraduction, $this->doorGets->Table . '_traduction'); $this->doorGets->successHeaderResponse($messageSuccess); } $this->doorGets->errorHeaderResponse($this->doorGets->__("Veuillez remplir correctement le formulaire"), $this->doorGets->Form->e); } break; case 'delete': if (!empty($this->doorGets->Form->i)) { $this->doorGets->checkMode(); if (empty($this->doorGets->Form->e)) { $lgGroupe = unserialize($isContent['groupe_traduction']); foreach ($lgGroupe as $v) { @$this->doorGets->dbQD($v, $this->doorGets->Table . '_traduction'); } @unlink(BASE . 'data/' . $this->doorGets->getRealUri($this->doorGets->Uri) . '/' . $isContent['image']); $this->doorGets->dbQD($isContent['id_content'], $this->doorGets->Table); $this->doorGets->dbQL("DELETE FROM _dg_comments WHERE uri_module = '" . $this->doorGets->Uri . "' AND uri_content = '" . $isContent['id_content'] . "' "); $this->doorGets->dbQL("UPDATE " . $this->doorGets->Table . " SET ordre = ordre - 1 WHERE ordre > " . $isContent['ordre'] . " "); // Tracker $usersTracking = new UsersTrackEntity(null, $this->doorGets); $usersTracking->setIdSession(session_id())->setIpUser($_SERVER['REMOTE_ADDR'])->setUrlPage($_SERVER['REQUEST_URI'])->setUrlReferer($_SERVER['HTTP_REFERER'])->setIdUser($User['id'])->setTitle($isContent['titre'])->setIdGroupe($User['groupe'])->setLangue($lgActuel)->setUriModule($this->doorGets->Uri)->setIdContent($isContent['id_content'])->setAction($this->Action)->setDate(time())->save(); FlashInfo::set($this->doorGets->__("Les données sont supprimées")); $this->doorGets->_redirect($redirectUrl); } } break; } } catch (Exception $e) { } }
public function doAction() { $out = ''; $User = $this->doorGets->user; $lgActuel = $this->doorGets->getLangueTradution(); $allLanguages = $this->doorGets->getAllLanguages(); $isVersionActive = false; $version_id = 0; $isContent = array(); // Check if is content modo in_array('traduction', $User['liste_module_interne']) ? $is_modo = true : ($is_modo = false); // Check if is module modo in_array('traduction', $User['liste_module_interne']) && in_array('traduction_modo', $User['liste_module_interne']) ? $is_modules_modo = true : ($is_modules_modo = false); // get Content for edit / delete $params = $this->doorGets->Params(); if (array_key_exists('id', $params['GET'])) { $id = $params['GET']['id']; $isContent = $this->doorGets->dbQS($id, $this->doorGets->Table); if (!empty($isContent)) { if ($lgGroupe = @unserialize($isContent['groupe_traduction'])) { $idLgGroupe = $lgGroupe[$lgActuel]; $isContentTraduction = $this->doorGets->dbQS($idLgGroupe, $this->doorGets->Table . '_traduction'); if (!empty($isContentTraduction)) { $isContent = array_merge($isContent, $isContentTraduction); $this->isContent = $isContent; } } } } switch ($this->Action) { case 'index': break; case 'tofile': if (!empty($this->doorGets->Form['_saveToFile']->i) && $is_modules_modo) { $this->doorGets->checkMode(); $temp = array(); $dirTraduction = LANGUE; // Création des variables pour chaque langue foreach ($allLanguages as $langue => $label) { ${$langue} = array(); } $allTraductions = $this->doorGets->dbQA('_dg_translator', 'LIMIT 5000'); foreach ($allTraductions as $traduction) { $temp[] = $traduction['sentence']; if ($groupeTraduction = @unserialize($traduction['groupe_traduction'])) { foreach ($groupeTraduction as $langue => $idTraduction) { $traductionTraduction = $this->doorGets->dbQS($idTraduction, '_dg_translator_traduction'); if (!empty($traductionTraduction)) { array_push(${$langue}, $traductionTraduction['translated_sentence']); } } } } foreach ($allLanguages as $_toLanguage => $value) { $iAdd = 0; $fileTraduction = $dirTraduction . $_toLanguage . '.lg.php'; $outTempTranslate = '<?php ' . PHP_EOL; foreach (${$_toLanguage} as $k => $w) { $w = trim($w); $outTempTranslate .= "\t" . '$_w[] = "' . $w . '"; ' . PHP_EOL; $iAdd++; } if (empty($iAdd)) { $outTempTranslate .= "\t" . '$_w = array(); '; } file_put_contents($fileTraduction, $outTempTranslate); } $iAdd = 0; $fileTempTraduction = $dirTraduction . 'temp.lg.php'; $outTempTranslate = '<?php //je suis la' . PHP_EOL; foreach ($temp as $k => $w) { $w = str_replace(''', "'", trim($w)); $outTempTranslate .= "\t" . '$wTranslate[] = "' . $w . '"; ' . PHP_EOL; $iAdd++; } if (empty($iAdd)) { $outTempTranslate .= "\t" . '$wTraslate = array(); '; } file_put_contents($fileTempTraduction, $outTempTranslate); FlashInfo::set($this->doorGets->__("Les traductions sont maintenant en ligne")); } break; case 'tobase': if (!empty($this->doorGets->Form['_saveToBase']->i) && $is_modules_modo) { $this->doorGets->checkMode(); $isOkForTranfert = true; $filesTraduction = array(); $_fileTempTraduction = LANGUE . 'temp.lg.php'; if (is_file($_fileTempTraduction)) { include $_fileTempTraduction; $countSentences = count($wTranslate); //echo $countSentences; $filesTraduction['temp']['file'] = $_fileTempTraduction; $filesTraduction['temp']['sentences'] = $wTranslate; // loading foreach ($allLanguages as $langue => $label) { $_fileName = LANGUE . $langue . '.lg.php'; if (is_file($_fileName)) { if (isset($_w)) { unset($_w); } include $_fileName; $filesTraduction[$langue]['file'] = $_fileName; $filesTraduction[$langue]['sentences'] = $_w; } } } foreach ($filesTraduction['temp']['sentences'] as $position => $sentence) { $idsTraduction = array(); $sentence = trim(filter_var($sentence, FILTER_SANITIZE_STRING)); $isSentence = $this->doorGets->dbQS($sentence, '_dg_translator', 'sentence'); if (empty($isSentence)) { $dataSentence = array('sentence' => $sentence, 'id_user' => $User['id'], 'id_groupe' => $User['groupe'], 'date_creation' => time()); $idContent = $this->doorGets->dbQI($dataSentence, '_dg_translator'); foreach ($allLanguages as $langue => $label) { $traduction = ''; if (array_key_exists($position, $filesTraduction[$langue]['sentences'])) { $traduction = $filesTraduction[$langue]['sentences'][$position]; } $dataTraduction['translated_sentence'] = $traduction; $dataTraduction['langue'] = $langue; $dataTraduction['id_translator'] = $idContent; $dataTraduction['is_translated'] = 1; $dataTraduction['date_modification'] = time(); $idsTraduction[$langue] = $this->doorGets->dbQI($dataTraduction, '_dg_translator_traduction'); } //file_put_contents($filesTraduction,); $idsTraduction = serialize($idsTraduction); $this->doorGets->dbQU($idContent, array('groupe_traduction' => $idsTraduction), '_dg_translator'); } } FlashInfo::set($this->doorGets->__("Les traductions sont sauvegardées")); } break; case 'add': if (!empty($this->doorGets->Form->i) && empty($this->doorGets->Form->e) && $is_modules_modo) { $this->doorGets->checkMode(); if (empty($this->doorGets->Form->i['sentence'])) { FlashInfo::set($this->doorGets->__("Veuillez saisir une phrase"), "error"); $this->doorGets->Form->e['translator_add_sentence'] = 'ok'; } if (empty($this->doorGets->Form->e)) { $data['sentence'] = $this->doorGets->Form->i['sentence']; $data['id_user'] = $this->doorGets->user['id']; $data['id_groupe'] = $this->doorGets->user['groupe']; $data['date_creation'] = time(); $idContent = $this->doorGets->dbQI($data, $this->doorGets->Table); foreach ($this->doorGets->getAllLanguages() as $k => $v) { $dataTraduction['translated_sentence'] = $this->doorGets->Form->i['sentence']; $dataTraduction['langue'] = $k; $dataTraduction['id_translator'] = $idContent; $dataTraduction['date_modification'] = time(); $idsTraduction[$k] = $this->doorGets->dbQI($dataTraduction, $this->doorGets->Table . '_traduction'); } $dataModification['groupe_traduction'] = serialize($idsTraduction); $this->doorGets->dbQU($idContent, $dataModification, $this->doorGets->Table); // Tracker $usersTracking = new UsersTrackEntity(null, $this->doorGets); $usersTracking->setIdSession(session_id())->setIpUser($_SERVER['REMOTE_ADDR'])->setUrlPage($_SERVER['REQUEST_URI'])->setUrlReferer($_SERVER['HTTP_REFERER'])->setIdUser($User['id'])->setTitle($data['sentence'])->setIdGroupe($User['groupe'])->setLangue($lgActuel)->setUriModule('translator')->setIdContent($idContent)->setAction($this->Action)->setDate(time())->save(); FlashInfo::set($this->doorGets->__("Vos informations ont bien été mises à jour")); header('Location:./?controller=translator&action=edit&id=' . $idContent . '&lg=' . $lgActuel); exit; } } break; case 'edit': $error = false; if (!empty($this->doorGets->Form->i)) { $this->doorGets->checkMode(); if (empty($this->doorGets->Form->e)) { $dataTraduction['translated_sentence'] = $this->doorGets->Form->i['translated_sentence']; $dataTraduction['is_translated'] = $this->doorGets->Form->i['is_translated']; $dataTraduction['date_modification'] = time(); $dataVersion = $dataTraduction; $this->saveLastContentVersion($isContent['id_translator'], $dataVersion); $this->doorGets->dbQU($isContent['id'], $dataTraduction, $this->doorGets->Table . '_traduction'); // Tracker $usersTracking = new UsersTrackEntity(null, $this->doorGets); $usersTracking->setIdSession(session_id())->setIpUser($_SERVER['REMOTE_ADDR'])->setUrlPage($_SERVER['REQUEST_URI'])->setUrlReferer($_SERVER['HTTP_REFERER'])->setIdUser($User['id'])->setTitle($isContent['sentence'] . ' -> ' . $lgActuel . ' -> ' . $dataTraduction['translated_sentence'])->setIdGroupe($User['groupe'])->setLangue($lgActuel)->setUriModule('translator')->setIdContent($isContent['id_translator'])->setAction($this->Action)->setDate(time())->save(); FlashInfo::set($this->doorGets->__("Vos informations ont bien été mises à jour")); if (array_key_exists('go_to_next', $this->doorGets->Form->i)) { $idNextContent = $this->doorGets->getContentPaginatePosition('sentence', $isContent['sentence']); header('Location:./?controller=translator&action=edit&id=' . $idNextContent . '&lg=' . $lgActuel); exit; } header('Location:./?controller=translator&action=edit&id=' . $isContent['id_translator'] . '&lg=' . $lgActuel); exit; } FlashInfo::set($this->doorGets->__("Veuillez remplir correctement le formulaire"), "error"); } break; case 'delete': if (!empty($this->doorGets->Form->i) && $is_modules_modo) { $this->doorGets->checkMode(); if (empty($this->doorGets->Form->e)) { $this->doorGets->dbQD($isContent['id_translator'], $this->doorGets->Table); $this->doorGets->dbQD($isContent['id_translator'], $this->doorGets->Table . '_traduction', 'id_translator', '=', ''); $this->doorGets->dbQD($isContent['id_translator'], $this->doorGets->Table . '_version', 'id_content', '=', ''); // Tracker $usersTracking = new UsersTrackEntity(null, $this->doorGets); $usersTracking->setIdSession(session_id())->setIpUser($_SERVER['REMOTE_ADDR'])->setUrlPage($_SERVER['REQUEST_URI'])->setUrlReferer($_SERVER['HTTP_REFERER'])->setIdUser($User['id'])->setTitle($isContent['sentence'])->setIdGroupe($User['groupe'])->setLangue($lgActuel)->setUriModule('translator')->setIdContent($isContent['id_translator'])->setAction($this->Action)->setDate(time())->save(); FlashInfo::set($this->doorGets->__("La phrase a été corréctement supprimer")); header('Location:./?controller=translator'); exit; } } break; } }
public function doAction() { $out = ''; $id = 0; // if (!$this->doorGets->getIsUserLogged()) { // $this->doorGets->_errorJson("Access Token required"); // } $cName = $this->doorGets->controllerNameNow(); $User = $this->doorGets->user; $uri = $this->doorGets->Uri; // Init langue $lgActuel = $this->doorGets->getLangueTradution(); $moduleInfos = $this->doorGets->moduleInfos($this->doorGets->Uri, $lgActuel); if (!empty($User)) { // Init url redirection $redirectUrl = './?controller=module' . $moduleInfos['type'] . '&uri=' . $this->doorGets->Uri . '&lg=' . $lgActuel; // Check if is content modo $is_modo = in_array($moduleInfos['id'], $User['liste_module_modo']) ? true : false; // Check if is module modo in_array('module', $User['liste_module_interne']) && in_array('module_' . $moduleInfos['type'], $User['liste_module_interne']) ? $is_modules_modo = true : ($is_modules_modo = false); // check if user can edit content $user_can_edit = in_array($moduleInfos['id'], $User['liste_module_edit']) ? true : false; // check if user can delete content $user_can_delete = in_array($moduleInfos['id'], $User['liste_module_delete']) ? true : false; // Init count total contents $countContents = 0; $arrForCountSearchQuery[] = array('key' => "id_user", 'type' => '=', 'value' => $User['id']); $countContents = $this->doorGets->getCountTable($this->doorGets->Table, $arrForCountSearchQuery); // Check limit to add content $isLimited = 0; if (array_key_exists($moduleInfos['id'], $User['liste_module_limit']) && $User['liste_module_limit'] !== '0') { $isLimited = (int) $User['liste_module_limit'][$moduleInfos['id']]; } // get Content for edit / delete $params = $this->doorGets->Params(); if (array_key_exists('id', $params['GET'])) { $id = $params['GET']['id']; $isContent = $this->doorGets->dbQS($id, $this->doorGets->Table); if (!empty($isContent)) { if ($lgGroupe = @unserialize($isContent['groupe_traduction'])) { $idLgGroupe = $lgGroupe[$lgActuel]; $isContentTraduction = $this->doorGets->dbQS($idLgGroupe, $this->doorGets->Table . '_traduction'); if (!empty($isContentTraduction)) { $this->isContent = $isContent = array_merge($isContent, $isContentTraduction); } } // test if user can edit content if ($isContent['id_user'] !== $User['id'] && !in_array($isContent['id_groupe'], $User['liste_enfant_modo'])) { $this->doorGets->_errorJson($this->doorGets->__("Vous n'avez pas les droits pour afficher ce contenu")); } } } } $messageSuccess = $this->doorGets->__("Vos informations ont bien été mises à jour"); $messageError = $this->doorGets->__("Veuillez remplir correctement le formulaire"); switch ($this->doorGets->requestMethod) { case 'POST': if (empty($this->isContent)) { // to do $formData = $this->getFormDataFromParams(); $listToCategories = ''; if (empty($formData['error'])) { $formData['success']['active'] = 2; $keyToCheck = array('meta_titre', 'meta_description', 'meta_keys', 'meta_facebook_type', 'meta_facebook_titre', 'meta_facebook_description', 'meta_facebook_image', 'meta_twitter_type', 'meta_twitter_titre', 'meta_twitter_description', 'meta_twitter_image', 'meta_twitter_player'); foreach ($keyToCheck as $key) { $formData['success'][$key] = array_key_exists($key, $formData['success']) ? $formData['success'][$key] : ''; } $cResultsInt = $this->doorGets->getCountTable($this->doorGets->Table); $data['pseudo'] = $User['pseudo']; $data['id_user'] = $User['id']; $data['id_groupe'] = $User['groupe']; $data['ordre'] = $cResultsInt + 1; $data['active'] = $is_modo ? $formData['success']['active'] : 3; $data['categorie'] = $listToCategories; $data['date_creation'] = time(); $idContent = $this->doorGets->dbQI($data, $this->doorGets->Table); //var_dump($formData); $formData['success']['image'] = $this->doorGets->_moveUploadImage($_FILES, 'image', $uri); if ($formData['success']['image'] === false) { $this->doorGets->_errorJson($messageError); } $isExistUri = $this->doorGets->checkIfUriExist($formData['success']['uri'], '_m_' . $uri . '_traduction', $lgActuel); if ($isExistUri) { $this->doorGets->_errorJson("Uri field is not valid"); } foreach ($this->doorGets->getAllLanguages() as $k => $v) { $dataTraduction = array('titre' => $formData['success']['title'], 'uri' => $formData['success']['uri'], 'article_tinymce' => $formData['success']['article_tinymce'], 'meta_titre' => $formData['success']['meta_titre'], 'meta_description' => $formData['success']['meta_description'], 'meta_keys' => $formData['success']['meta_keys'], 'image' => $formData['success']['image']); foreach ($keyToCheck as $key) { $dataTraduction[$key] = $formData['success'][$key]; } $dataTraduction['categorie'] = $listToCategories; $dataTraduction['date_modification'] = $data['date_creation']; $dataTraduction['id_content'] = $idContent; $dataTraduction['langue'] = $k; $dataTraduction['uri'] = $formData['success']['uri'] . '-' . $k; $idTraduction[$k] = $this->doorGets->dbQI($dataTraduction, $this->doorGets->Table . '_traduction'); } $dataModification['groupe_traduction'] = serialize($idTraduction); $this->doorGets->dbQU($idContent, $dataModification, $this->doorGets->Table); // Tracker $usersTracking = new UsersTrackEntity(null, $this->doorGets); $usersTracking->setIdSession(session_id())->setIpUser($_SERVER['REMOTE_ADDR'])->setUrlPage($_SERVER['REQUEST_URI'])->setUrlReferer('API')->setIdUser($User['id'])->setTitle($dataTraduction['titre'])->setIdGroupe($User['groupe'])->setLangue($lgActuel)->setUriModule($this->doorGets->Uri)->setIdContent($idContent)->setAction('add')->setDate(time())->save(); if (!$is_modo) { $moderation = new ModerationEntity(null, $this->doorGets); $moderation->setIdContent($idContent)->setIdUser($User['id'])->setPseudo($User['pseudo'])->setIdGroupe($User['groupe'])->setUriModule($this->doorGets->Uri)->setTypeModule('blog')->setAction('add')->setLangue($lgActuel)->setDateCreation(time())->save(); $this->doorGets->sendEmailNotificationToGroupe($moduleInfos['uri_notification_moderator'], $moduleInfos['id']); $messageSuccess = $this->doorGets->__("Votre contenu est en cours de modération"); } $this->doorGets->_successJson($messageSuccess); } else { $this->doorGets->_errorJson($messageError, $formData['error']); } } break; case 'PUT': case 'PATCH': if (!empty($this->isContent)) { // to do $formData = $this->getFormDataFromParams('PUT'); $listToCategories = ''; if (empty($formData['error'])) { $formData['success']['active'] = array_key_exists('active', $formData['success']) ? $formData['success']['active'] : 2; $keyToCheck = array('title', 'article_tinymce', 'categorie', 'uri', 'image', 'meta_titre', 'meta_description', 'meta_keys', 'meta_facebook_type', 'meta_facebook_titre', 'meta_facebook_description', 'meta_facebook_image', 'meta_twitter_type', 'meta_twitter_titre', 'meta_twitter_description', 'meta_twitter_image', 'meta_twitter_player'); foreach ($keyToCheck as $key) { if ($key === 'title') { $formData['success']['titre'] = array_key_exists($key, $formData['success']) ? $formData['success'][$key] : $isContent['titre']; unset($formData['success'][$key]); } else { $formData['success'][$key] = array_key_exists($key, $formData['success']) ? $formData['success'][$key] : $isContent[$key]; } } $cResultsInt = $this->doorGets->getCountTable($this->doorGets->Table); $dataContenu['active'] = $is_modo ? $formData['success']['active'] : 3; //var_dump($formData); //$formData['success']['image'] = $this->doorGets->_moveUploadImage($_FILES,'image',$uri); if ($formData['success']['image'] === false) { $this->doorGets->_errorJson("File error: image"); } $dataContenu['active'] = $formData['success']['active']; if (!$is_modo) { $dataContenu['active'] = 3; } $image = $isContent['image']; if (!empty($formData['success']['image'])) { $image = $formData['success']['image']; } $dataTraduction = array('image' => $image, 'categorie' => $listToCategories, 'date_modification' => time()); foreach ($keyToCheck as $key) { $key = $key === 'title' ? 'titre' : $key; $dataTraduction[$key] = $formData['success'][$key]; } $dataVersion = $dataTraduction; unset($dataTraduction['active']); $this->saveLastContentVersion($isContent['id_content'], $dataVersion); // Tracker $usersTracking = new UsersTrackEntity(null, $this->doorGets); $usersTracking->setIdSession(session_id())->setIpUser($_SERVER['REMOTE_ADDR'])->setUrlPage($_SERVER['REQUEST_URI'])->setUrlReferer('API')->setIdUser($User['id'])->setTitle($dataTraduction['titre'])->setIdGroupe($User['groupe'])->setLangue($lgActuel)->setUriModule($this->doorGets->Uri)->setIdContent($isContent['id_content'])->setAction('edit')->setDate(time())->save(); if (!$is_modo) { $moderation = new ModerationEntity(null, $this->doorGets); $moderation->setIdContent($isContent['id_content'])->setIdUser($User['id'])->setPseudo($User['pseudo'])->setIdGroupe($User['groupe'])->setUriModule($this->doorGets->Uri)->setTypeModule('blog')->setAction('edit')->setLangue($lgActuel)->setDateCreation(time())->save(); $this->doorGets->sendEmailNotificationToGroupe($moduleInfos['uri_notification_moderator'], $moduleInfos['id']); $messageSuccess = $this->doorGets->__("Votre contenu est en cours de modération"); } else { $uri_module = $this->doorGets->Uri; $id_content = $isContent['id_content']; $this->doorGets->dbQL("\n DELETE FROM _moderation \n WHERE id_content = '{$id_content}' \n AND uri_module = '{$uri_module}'\n LIMIT 1000\n "); $uriNotification = $dataContenu['active'] === '2' ? $moduleInfos['uri_notification_user_success'] : $moduleInfos['uri_notification_user_error']; $this->doorGets->sendEmailNotificationToUser($uriNotification, $isContent['id_user']); } // Update Data $this->doorGets->dbQU($isContent['id_content'], $dataContenu, $this->doorGets->Table); $this->doorGets->dbQU($isContent['id'], $dataTraduction, $this->doorGets->Table . '_traduction'); //var_dump($dataTraduction); $this->doorGets->_successJson($formData['success']); } else { $this->doorGets->_errorJson("Fields errors", $formData['error']); } } break; case 'DELETE': if (!$is_modules_modo) { $this->doorGets->_errorJson("Not authorized to delete"); } if (!empty($this->isContent)) { $this->doorGets->dbQD($isContent['id'], $this->doorGets->Table); $this->doorGets->dbQD($isContent['id_content'], $this->doorGets->Table . '_traduction', 'id_content', '=', ''); $this->doorGets->dbQD($isContent['id_content'], $this->doorGets->Table . '_version', 'id_content', '=', ''); $this->doorGets->_successJson("{$id} deleted"); } break; } return $out; }
public function doAction() { $out = ''; $this->doorGets->Table = '_dg_onepage'; $User = $this->doorGets->user; // Init langue $lgActuel = $this->doorGets->getLangueTradution(); $moduleInfos = $this->doorGets->moduleInfos($this->doorGets->Uri, $lgActuel); // Check if is content modo $is_modo = in_array($moduleInfos['id'], $User['liste_module_modo']) ? true : false; // Check if is module modo in_array('module', $User['liste_module_interne']) && in_array('module_' . $moduleInfos['type'], $User['liste_module_interne']) ? $is_modules_modo = true : ($is_modules_modo = false); // check if user can edit content $user_can_edit = in_array($moduleInfos['id'], $User['liste_module_edit']) ? true : false; // check if user can delete content $user_can_delete = in_array($moduleInfos['id'], $User['liste_module_delete']) ? true : false; // Init url redirection $redirectUrl = './?controller=module' . $moduleInfos['type'] . '&uri=' . $this->doorGets->Uri . '&lg=' . $lgActuel; // get Content for edit / delete $params = $this->doorGets->Params(); if (array_key_exists('uri', $params['GET'])) { $uri = $params['GET']['uri']; $isContent = $this->doorGets->dbQS($uri, $this->doorGets->Table, 'uri'); if (!empty($isContent)) { if ($lgGroupe = @unserialize($isContent['groupe_traduction'])) { $idLgGroupe = $lgGroupe[$lgActuel]; $isContentTraduction = $this->doorGets->dbQS($idLgGroupe, $this->doorGets->Table . '_traduction'); if (!empty($isContentTraduction)) { $isContent = array_merge($isContent, $isContentTraduction); } } } } $messageSuccess = $this->doorGets->__("Vos informations ont bien été mises à jour"); $champsNonObligatoire = array('description', 'backimage_', 'backcolor_', 'height_'); $removeInt = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '_tinymce'); if (!empty($this->doorGets->Form->i)) { $this->doorGets->checkMode(); $countPages = 0; // gestion des champs vide foreach ($this->doorGets->Form->i as $k => $v) { $rKey = str_replace($removeInt, '', $k); if (!in_array($rKey, $champsNonObligatoire) && empty($v)) { $this->doorGets->Form->e[$this->doorGets->controllerNameNow() . '_edit_' . $k] = 'ok'; } $valTitle = substr($k, 0, 5); if ($valTitle === 'title') { $countPages++; } } $article = array(); for ($i = 0; $i < $countPages + 1; $i++) { $z = $i + 1; if (array_key_exists('title_' . $z, $this->doorGets->Form->i)) { $pos = $this->doorGets->Form->i['position_' . $z]; $article[$pos]['position'] = $this->doorGets->Form->i['position_' . $z]; $article[$pos]['title'] = $this->doorGets->Form->i['title_' . $z]; $article[$pos]['page'] = $this->doorGets->Form->i['page_' . $z . '_tinymce']; $article[$pos]['marqueur'] = $this->doorGets->Form->i['marqueur_' . $z]; $article[$pos]['backcolor'] = $this->doorGets->Form->i['backcolor_' . $z]; $article[$pos]['backimage'] = $this->doorGets->Form->i['backimage_' . $z]; $article[$pos]['opacity'] = $this->doorGets->Form->i['opacity_' . $z]; $article[$pos]['height'] = $this->doorGets->Form->i['height_' . $z]; $article[$pos]['showinmenu'] = $this->doorGets->Form->i['showinmenu_' . $z]; } } ksort($article); if (empty($this->doorGets->Form->e)) { $dataTraduction = array('menu_position' => 'top', 'backimage_fixe' => $this->doorGets->Form->i['backimage_fixe'], 'article_tinymce' => base64_encode(serialize($article)), 'date_modification' => time()); $dataVersion = $dataTraduction; $this->saveLastContentVersion($isContent['id_content'], $dataVersion); $this->doorGets->dbQU($isContent['id'], $dataTraduction, $this->doorGets->Table . '_traduction'); $usersTracking = new UsersTrackEntity(null, $this->doorGets); $usersTracking->setIdSession(session_id())->setIpUser($_SERVER['REMOTE_ADDR'])->setUrlPage($_SERVER['REQUEST_URI'])->setUrlReferer($_SERVER['HTTP_REFERER'])->setIdUser($User['id'])->setTitle($this->doorGets->Uri)->setIdGroupe($User['groupe'])->setLangue($lgActuel)->setUriModule($this->doorGets->Uri)->setIdContent($isContent['id_content'])->setAction('edit')->setDate(time())->save(); if (!$is_modo) { $moderation = new ModerationEntity(null, $this->doorGets); $moderation->setIdContent($isContent['id_content'])->setIdUser($User['id'])->setPseudo($User['pseudo'])->setIdGroupe($User['groupe'])->setUriModule($this->doorGets->Uri)->setTypeModule('page')->setAction('edit')->setLangue($lgActuel)->setDateCreation(time())->save(); $this->doorGets->sendEmailNotificationToGroupe($moduleInfos['uri_notification_moderator'], $moduleInfos['id']); $messageSuccess = $this->doorGets->__("Votre contenu est en cours de modération"); } $this->doorGets->successHeaderResponse($messageSuccess, $redirectUrl); } $this->doorGets->errorHeaderResponse($this->doorGets->__("Veuillez remplir correctement le formulaire"), $this->doorGets->Form->e); } }
public function doAction() { $out = ''; $this->doorGets->Table = '_dg_page'; $User = $this->doorGets->user; // Init langue $lgActuel = $this->doorGets->getLangueTradution(); $moduleInfos = $this->doorGets->moduleInfos($this->doorGets->Uri, $lgActuel); // Check if is content modo in_array($moduleInfos['id'], $User['liste_module_modo']) ? $is_modo = true : ($is_modo = false); // Check if is module modo in_array('module', $User['liste_module_interne']) && in_array('module_' . $moduleInfos['type'], $User['liste_module_interne']) ? $is_modules_modo = true : ($is_modules_modo = false); // check if user can edit content in_array($moduleInfos['id'], $User['liste_module_edit']) ? $user_can_edit = true : ($user_can_edit = false); // check if user can delete content in_array($moduleInfos['id'], $User['liste_module_delete']) ? $user_can_delete = true : ($user_can_delete = false); // Init url redirection $redirectUrl = './?controller=module' . $moduleInfos['type'] . '&uri=' . $this->doorGets->Uri . '&lg=' . $lgActuel; // get Content for edit / delete $params = $this->doorGets->Params(); if (array_key_exists('uri', $params['GET'])) { $uri = $params['GET']['uri']; $isContent = $this->doorGets->dbQS($uri, $this->doorGets->Table, 'uri'); if (!empty($isContent)) { if ($lgGroupe = @unserialize($isContent['groupe_traduction'])) { $idLgGroupe = $lgGroupe[$lgActuel]; $isContentTraduction = $this->doorGets->dbQS($idLgGroupe, $this->doorGets->Table . '_traduction'); if (!empty($isContentTraduction)) { $isContent = array_merge($isContent, $isContentTraduction); } } } } $messageSuccess = $this->doorGets->__("Vos informations ont bien été mises à jour"); $champsNonObligatoire = array('description', 'image', 'meta_titre', 'meta_description', 'meta_keys', 'sendto', 'id_disqus', 'meta_facebook_titre', 'meta_facebook_description', 'meta_facebook_image', 'meta_twitter_titre', 'meta_twitter_description', 'meta_twitter_image', 'meta_twitter_player'); if (!empty($this->doorGets->Form->i)) { $this->doorGets->checkMode(); // gestion des champs vide foreach ($this->doorGets->Form->i as $k => $v) { if (!in_array($k, $champsNonObligatoire) && empty($v)) { $this->doorGets->Form->e[$this->doorGets->controllerNameNow() . '_edit_' . $k] = 'ok'; } } if (empty($this->doorGets->Form->e)) { if (!array_key_exists('comments', $this->doorGets->Form->i)) { $this->doorGets->Form->i['comments'] = $is_modo ? 0 : $isContent['comments']; } if (!array_key_exists('partage', $this->doorGets->Form->i)) { $this->doorGets->Form->i['partage'] = $is_modo ? 0 : $isContent['partage']; } if (!array_key_exists('mailsender', $this->doorGets->Form->i)) { $this->doorGets->Form->i['mailsender'] = $is_modo ? 0 : $isContent['mailsender']; } if (!array_key_exists('facebook', $this->doorGets->Form->i)) { $this->doorGets->Form->i['facebook'] = $is_modo ? 0 : $isContent['facebook']; } if (!array_key_exists('disqus', $this->doorGets->Form->i)) { $this->doorGets->Form->i['disqus'] = $is_modo ? 0 : $isContent['disqus']; } if (!array_key_exists('in_rss', $this->doorGets->Form->i)) { $this->doorGets->Form->i['in_rss'] = $is_modo ? 0 : $isContent['in_rss']; } if (!array_key_exists('active', $this->doorGets->Form->i)) { $this->doorGets->Form->i['active'] = $isContent['active']; } $dataContenu['active'] = !$is_modo ? 3 : $this->doorGets->Form->i['active']; $dataContenu['comments'] = $this->doorGets->Form->i['comments']; $dataContenu['partage'] = $this->doorGets->Form->i['partage']; $dataContenu['mailsender'] = $this->doorGets->Form->i['mailsender']; $dataContenu['facebook'] = $this->doorGets->Form->i['facebook']; $dataContenu['disqus'] = $this->doorGets->Form->i['disqus']; $dataContenu['in_rss'] = $this->doorGets->Form->i['in_rss']; $dataTraduction = array('titre' => $this->doorGets->Form->i['titre'], 'article_tinymce' => $this->doorGets->Form->i['article_tinymce'], 'meta_titre' => $this->doorGets->Form->i['meta_titre'], 'meta_description' => $this->doorGets->Form->i['meta_description'], 'meta_keys' => $this->doorGets->Form->i['meta_keys'], 'meta_facebook_type' => $this->doorGets->Form->i['meta_facebook_type'], 'meta_facebook_titre' => $this->doorGets->Form->i['meta_facebook_titre'], 'meta_facebook_description' => $this->doorGets->Form->i['meta_facebook_description'], 'meta_facebook_image' => $this->doorGets->Form->i['meta_facebook_image'], 'meta_twitter_type' => $this->doorGets->Form->i['meta_twitter_type'], 'meta_twitter_titre' => $this->doorGets->Form->i['meta_twitter_titre'], 'meta_twitter_description' => $this->doorGets->Form->i['meta_twitter_description'], 'meta_twitter_image' => $this->doorGets->Form->i['meta_twitter_image'], 'meta_twitter_player' => $this->doorGets->Form->i['meta_twitter_player'], 'date_modification' => time()); $dataVersion = $dataTraduction; $dataVersion['active'] = $dataContenu['active']; $this->saveLastContentVersion($isContent['id_content'], $dataVersion); // Update Data $this->doorGets->dbQU($isContent['id_content'], $dataContenu, $this->doorGets->Table); $this->doorGets->dbQU($isContent['id'], $dataTraduction, $this->doorGets->Table . '_traduction'); $usersTracking = new UsersTrackEntity(null, $this->doorGets); $usersTracking->setIdSession(session_id())->setIpUser($_SERVER['REMOTE_ADDR'])->setUrlPage($_SERVER['REQUEST_URI'])->setUrlReferer($_SERVER['HTTP_REFERER'])->setIdUser($User['id'])->setTitle($dataTraduction['titre'])->setIdGroupe($User['groupe'])->setLangue($lgActuel)->setUriModule($this->doorGets->Uri)->setIdContent($isContent['id_content'])->setAction('edit')->setDate(time())->save(); if (!$is_modo) { $moderation = new ModerationEntity(null, $this->doorGets); $moderation->setIdContent($isContent['id_content'])->setIdUser($User['id'])->setPseudo($User['pseudo'])->setIdGroupe($User['groupe'])->setUriModule($this->doorGets->Uri)->setTypeModule('page')->setAction('edit')->setLangue($lgActuel)->setDateCreation(time())->save(); $this->doorGets->sendEmailNotificationToGroupe($moduleInfos['uri_notification_moderator'], $moduleInfos['id']); $messageSuccess = $this->doorGets->__("Votre contenu est en cours de modération"); } $this->doorGets->successHeaderResponse($messageSuccess, $redirectUrl); } $this->doorGets->errorHeaderResponse($this->doorGets->__("Veuillez remplir correctement le formulaire"), $this->doorGets->Form->e); } }
public function doAction() { $out = ''; $this->doorGets->Table = '_dg_carousel'; $User = $this->doorGets->user; // Init langue $lgActuel = $this->doorGets->getLangueTradution(); $moduleInfos = $this->doorGets->moduleInfos($this->doorGets->Uri, $lgActuel); // Init url redirection $redirectUrl = './?controller=module' . $moduleInfos['type'] . '&uri=' . $this->doorGets->Uri . '&lg=' . $lgActuel; // get Content for edit / delete $params = $this->doorGets->Params(); if (array_key_exists('uri', $params['GET'])) { $uri = $params['GET']['uri']; $isContent = $this->doorGets->dbQS($uri, $this->doorGets->Table, 'uri'); if (!empty($isContent)) { if ($lgGroupe = @unserialize($isContent['groupe_traduction'])) { $idLgGroupe = $lgGroupe[$lgActuel]; $isContentTraduction = $this->doorGets->dbQS($idLgGroupe, $this->doorGets->Table . '_traduction'); if (!empty($isContentTraduction)) { $isContent = array_merge($isContent, $isContentTraduction); } } } } $messageSuccess = $this->doorGets->__("Vos informations ont bien été mises à jour"); $champsNonObligatoire = array('description', 'items_count', 'auto_play', 'stop_on_hover', 'navigation', 'image_', 'url_', 'page_', 'title_'); $removeInt = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '_tinymce'); if (!empty($this->doorGets->Form->i)) { $this->doorGets->checkMode(); $countPages = 0; // gestion des champs vide foreach ($this->doorGets->Form->i as $k => $v) { $rKey = str_replace($removeInt, '', $k); if (!in_array($rKey, $champsNonObligatoire) && empty($v)) { $this->doorGets->Form->e[$this->doorGets->controllerNameNow() . '_edit_' . $k] = 'ok'; } $valTitle = substr($k, 0, 5); if ($valTitle === 'image') { $countPages++; } } $article = array(); $imagesToSave = ''; for ($i = 0; $i < $countPages + 1; $i++) { $z = $i + 1; if (array_key_exists('image_' . $z, $this->doorGets->Form->i)) { $imagesToSave .= $this->doorGets->Form->i['image_' . $z] . ';'; $pos = $this->doorGets->Form->i['position_' . $z]; $article[$pos]['position'] = $this->doorGets->Form->i['position_' . $z]; $article[$pos]['page'] = $this->doorGets->Form->i['page_' . $z . '_tinymce']; $article[$pos]['image'] = $this->doorGets->Form->i['image_' . $z]; $article[$pos]['url'] = $this->doorGets->Form->i['url_' . $z]; $article[$pos]['type'] = $this->doorGets->Form->i['type_' . $z]; $article[$pos]['title'] = $this->doorGets->Form->i['title_' . $z]; $article[$pos]['module'] = $this->doorGets->Uri; } } ksort($article); if (empty($this->doorGets->Form->e)) { $data['items_count'] = $this->doorGets->Form->i['items_count']; $data['auto_play'] = $this->doorGets->Form->i['auto_play']; $data['stop_on_hover'] = $this->doorGets->Form->i['items_count']; $data['navigation'] = $this->doorGets->Form->i['navigation']; $this->doorGets->dbQU($isContent['id_carousel'], $data, $this->doorGets->Table); $dataTraduction = array('article_tinymce' => base64_encode(serialize($article)), 'date_modification' => time()); $this->doorGets->dbQU($isContent['id'], $dataTraduction, $this->doorGets->Table . '_traduction'); $usersTracking = new UsersTrackEntity(null, $this->doorGets); $usersTracking->setIdSession(session_id())->setIpUser($_SERVER['REMOTE_ADDR'])->setUrlPage($_SERVER['REQUEST_URI'])->setUrlReferer($_SERVER['HTTP_REFERER'])->setIdUser($User['id'])->setTitle($this->doorGets->Uri)->setIdGroupe($User['groupe'])->setLangue($lgActuel)->setUriModule($this->doorGets->Uri)->setIdContent($isContent['id_carousel'])->setAction('edit')->setDate(time())->save(); $this->doorGets->copyFileToRealPath($this->doorGets->Uri, $imagesToSave); $this->doorGets->successHeaderResponse($messageSuccess, $redirectUrl); } $this->doorGets->errorHeaderResponse($this->doorGets->__("Veuillez remplir correctement le formulaire"), $this->doorGets->Form->e); } }