diff --git a/apps/maarch_entreprise/actions/index_mlb.php b/apps/maarch_entreprise/actions/index_mlb.php index 9db0ea1c29cc211fa8ced465eb494b7ae217459d..ffe060861503488e6f5fd8889f5399528329d671 100644 --- a/apps/maarch_entreprise/actions/index_mlb.php +++ b/apps/maarch_entreprise/actions/index_mlb.php @@ -371,7 +371,7 @@ function get_form_txt($values, $pathManageAction, $actionId, $table, $module, $ $frmStr .= '<td><span class="red_asterisk" id="category_id_mandatory" ' . 'style="display:inline;vertical-align:text-top"><i class="fa fa-star"></i></span></td>'; $frmStr .= '</tr>'; - + $frmStr .= '<script>new Chosen($(\'category_id\'),{width: "226px", disable_search_threshold: 10, search_contains: true});</script>'; /*** Doctype ***/ $frmStr .= '<tr id="type_id_tr" style="display:' . $displayValue . ';">'; $frmStr .= '<td><span class="form_title" ' @@ -427,6 +427,7 @@ function get_form_txt($values, $pathManageAction, $actionId, $table, $module, $ $frmStr .= '<td><span class="red_asterisk" id="type_id_mandatory" ' . 'style="display:inline;vertical-align:text-top"><i class="fa fa-star"></i></span></td>'; $frmStr .= '</tr>'; + $frmStr .= '<script>new Chosen($(\'type_id\'),{width: "226px", disable_search_threshold: 10, search_contains: true});</script>'; /*** Priority ***/ $frmStr .= '<tr id="priority_tr" style="display:' . $displayValue . ';">'; @@ -452,7 +453,8 @@ function get_form_txt($values, $pathManageAction, $actionId, $table, $module, $ $frmStr .= '<td><span class="red_asterisk" id="priority_mandatory" ' . 'style="display:inline;vertical-align:text-top"><i class="fa fa-star"></i></span></td>'; $frmStr .= '</tr>'; - + $frmStr .= '<script>new Chosen($(\'priority\'),{width: "226px", disable_search_threshold: 10, search_contains: true});</script>'; + /*** Confidentiality ***/ $frmStr .= '<tr id="confidentiality_tr" style="display:' . $displayValue . ';">'; @@ -673,6 +675,7 @@ function get_form_txt($values, $pathManageAction, $actionId, $table, $module, $ $frmStr .= '<td><span class="red_asterisk" id="nature_id_mandatory" ' . 'style="display:inline;"><i class="fa fa-star"></i></span> </td>'; $frmStr .= '</tr>'; + $frmStr .= '<script>new Chosen($(\'nature_id\'),{width: "226px", disable_search_threshold: 10, search_contains: true});</script>'; /****** RECOMMANDE ******/ $frmStr .= '<tr id="reference_number_tr" style="display:none;">'; @@ -738,6 +741,7 @@ function get_form_txt($values, $pathManageAction, $actionId, $table, $module, $ . 'style="width:420px; max-width: 420px;"></div>'; $frmStr .= '</td>'; $frmStr .= '</tr>'; + $frmStr .= '<script>new Chosen($(\'destination\'),{width: "226px", disable_search_threshold: 10, search_contains: true});</script>'; } /*** Process limit date ***/ @@ -793,6 +797,7 @@ function get_form_txt($values, $pathManageAction, $actionId, $table, $module, $ $frmStr .= '</select></td><td><span class="red_asterisk" id="market_mandatory" ' . 'style="display:inline;"><i class="fa fa-star"></i></span> </td>'; $frmStr .= '</tr>'; + $frmStr .= '<script>new Chosen($(\'status\'),{width: "226px", disable_search_threshold: 10, search_contains: true});</script>'; } $frmStr .= '</table>'; @@ -860,6 +865,7 @@ function get_form_txt($values, $pathManageAction, $actionId, $table, $module, $ $frmStr .= '<td><span class="red_asterisk" id="folder_mandatory" style="display:inline;"><i class="fa fa-star"></i></span> </td>'; $frmStr .= '</tr>'; $frmStr .= '<tr id="parentFolderTr" style="display: none;text-align:center;"><td> </td><td colspan="2"><span id="parentFolderSpan" style="font-style: italic;font-size: 10px"></span></td></tr>'; + $frmStr .= '<script>new Chosen($(\'folder\'),{width: "226px", disable_search_threshold: 10, search_contains: true});</script>'; } /*** Thesaurus ***/ @@ -884,6 +890,7 @@ function get_form_txt($values, $pathManageAction, $actionId, $table, $module, $ $frmStr .= '</select>'; $frmStr .= '<td style="width:5%;"> <i onclick="lauch_thesaurus_list(this);" class="fa fa-search" title="parcourir le thésaurus" aria-hidden="true" style="cursor:pointer;"></i></td>'; $frmStr .= '</tr>'; + $frmStr .= '<script>new Chosen($(\'thesaurus\'),{width: "226px", disable_search_threshold: 10, search_contains: true});</script>'; $frmStr .= '<style>#thesaurus_chosen{width:100% !important;}#thesaurus_chosen .chosen-drop{display:none;}</style>'; /*****************/ @@ -950,7 +957,6 @@ function get_form_txt($values, $pathManageAction, $actionId, $table, $module, $ . $_SESSION['config']['businessappurl'] . 'index.php?display=true' . '&dir=indexing_searching&page=autocomplete_contacts\', \'contact\', \'show_contacts\', \'\', \'contactid\', \'addressid\');'; - $frmStr .= '$$(\'select\').each(function(element) { new Chosen(element,{width: "226px", disable_search_threshold: 10,search_contains: true}); });'; $frmStr .= '$(\'baskets\').style.visibility=\'hidden\';' . 'var item = $(\'index_div\'); if(item)' . '{item.style.display=\'block\';}</script>'; diff --git a/apps/maarch_entreprise/actions/process.php b/apps/maarch_entreprise/actions/process.php index 113887d90e3839f31b1626c7b7abef515923033a..d8ccd9cfdac06da6a12db7a3c399edd51ac068f3 100644 --- a/apps/maarch_entreprise/actions/process.php +++ b/apps/maarch_entreprise/actions/process.php @@ -422,10 +422,6 @@ function get_form_txt($values, $path_manage_action, $id_action, $table, $module include_once("modules" . DIRECTORY_SEPARATOR . "tags" . DIRECTORY_SEPARATOR . "templates" . DIRECTORY_SEPARATOR . "process" . DIRECTORY_SEPARATOR . "index.php"); - //script - $frm_str .= '<script>'; - $frm_str .= 'new Chosen($(\'tag_userform\'),{width: "95%", disable_search_threshold: 10, search_contains: true});'; - $frm_str .= '</script>'; } //FOLDERS diff --git a/apps/maarch_entreprise/actions/validate_mail.php b/apps/maarch_entreprise/actions/validate_mail.php index f1f6ab4d78b59af3a76e86030787c901e7e1349a..e8f625b5f29e7feef5b1f11b09a0936cd711154c 100644 --- a/apps/maarch_entreprise/actions/validate_mail.php +++ b/apps/maarch_entreprise/actions/validate_mail.php @@ -371,6 +371,7 @@ function get_form_txt($values, $path_manage_action, $id_action, $table, $module $frm_str.='</select></td>'; $frm_str .= '<td><span class="red_asterisk" id="category_id_mandatory" style="display:inline;vertical-align:text-top"><i class="fa fa-star"></i></span></td>'; $frm_str .= '</tr>'; + $frm_str .= '<script>new Chosen($(\'category_id\'),{width: "226px", disable_search_threshold: 10, search_contains: true});</script>'; /*** Doctype ***/ $frm_str .= '<tr id="type_id_tr" style="display:'.$display_value.';">'; @@ -422,6 +423,7 @@ function get_form_txt($values, $path_manage_action, $id_action, $table, $module $frm_str .='</select>'; $frm_str .= '<td><span class="red_asterisk" id="type_id_mandatory" style="display:inline;vertical-align:text-top"><i class="fa fa-star"></i></span></td>'; $frm_str .= '</tr>'; + $frm_str .= '<script>new Chosen($(\'type_id\'),{width: "226px", disable_search_threshold: 10, search_contains: true});</script>'; /*** Priority ***/ $frm_str .= '<tr id="priority_tr" style="display:'.$display_value.';">'; @@ -448,6 +450,7 @@ function get_form_txt($values, $path_manage_action, $id_action, $table, $module $frm_str .='</select></td>'; $frm_str .= '<td><span class="red_asterisk" id="priority_mandatory" style="display:inline;"><i class="fa fa-star"></i></span> </td>'; $frm_str .= '</tr>'; + $frm_str .= '<script>new Chosen($(\'priority\'),{width: "226px", disable_search_threshold: 10, search_contains: true});</script>'; /*** Confidentiality ***/ $frm_str .= '<tr id="confidentiality_tr" style="display:' . $display_value @@ -717,6 +720,7 @@ function get_form_txt($values, $path_manage_action, $id_action, $table, $module $frm_str .= '</select></td>'; $frm_str .= '<td><span class="red_asterisk" id="nature_mandatory" style="display:inline;vertical-align:text-top"><i class="fa fa-star"></i></span></td>'; $frm_str .= '</tr>'; + $frm_str .= '<script>new Chosen($(\'nature_id\'),{width: "226px", disable_search_threshold: 10, search_contains: true});</script>'; /*** Recommande ***/ $frm_str .= '<tr id="reference_number_tr" style="display:none;">'; @@ -777,6 +781,7 @@ function get_form_txt($values, $path_manage_action, $id_action, $table, $module $frm_str .= '<div id="diff_list_div" class="scroll_div" style="width:420px; max-width: 420px;"></div>'; $frm_str .= '</td>'; $frm_str .= '</tr>'; + $frm_str .= '<script>new Chosen($(\'destination\'),{width: "226px", disable_search_threshold: 10, search_contains: true});</script>'; } /*** Process limit date ***/ @@ -874,6 +879,7 @@ function get_form_txt($values, $path_manage_action, $id_action, $table, $module $frm_str .= '</select></td><td><span class="red_asterisk" id="market_mandatory" ' . 'style="display:inline;"><i class="fa fa-star"></i></span> </td>'; $frm_str .= '</tr>'; + $frm_str .= '<script>new Chosen($(\'status\'),{width: "226px", disable_search_threshold: 10, search_contains: true});</script>'; } $frm_str .= '</table>'; @@ -958,6 +964,7 @@ function get_form_txt($values, $path_manage_action, $id_action, $table, $module } $frm_str .= '</tr>'; $frm_str .= '<tr id="parentFolderTr" style="display: none"><td> </td><td colspan="2"><span id="parentFolderSpan" style="font-style: italic;font-size: 10px"></span></td></tr>'; + $frm_str .= '<script>new Chosen($(\'folder\'),{width: "226px", disable_search_threshold: 10, search_contains: true});</script>'; } /*** Thesaurus ***/ @@ -998,6 +1005,7 @@ function get_form_txt($values, $path_manage_action, $id_action, $table, $module $frm_str .= '</optgroup>'; $frm_str .= '</select></td><td style="width:5%;"><i onclick="lauch_thesaurus_list(this);" class="fa fa-search" title="parcourir le thésaurus" aria-hidden="true" style="cursor:pointer;"></i></td>'; $frm_str .= '</tr>'; + $frm_str .= '<script>new Chosen($(\'thesaurus\'),{width: "226px", disable_search_threshold: 10, search_contains: true});</script>'; $frm_str .= '<style>#thesaurus_chosen{width:100% !important;}#thesaurus_chosen .chosen-drop{display:none;}</style>'; /*****************/ @@ -1216,7 +1224,6 @@ function get_form_txt($values, $path_manage_action, $id_action, $table, $module .'index.php?display=true&dir=indexing_searching&page=autocomplete_contacts_prepare_multi\');'; $frm_str .= 'affiche_reference();'; - $frm_str .= '$$(\'select\').each(function(element) { new Chosen(element,{width: "226px", disable_search_threshold: 10,search_contains: true}); });'; $frm_str .='</script>'; $frm_str .= '<style>#destination_chosen .chosen-drop{width:400px;}#folder_chosen .chosen-drop{width:400px;}</style>'; $frm_str .= '</div>'; diff --git a/apps/maarch_entreprise/indexing_searching/details.php b/apps/maarch_entreprise/indexing_searching/details.php index 4b95491a8f67ddd097e6d6fd20e7c75f021af0fd..070abc09fa9a4e6e599a5cffc6ac2c54350d8a93 100644 --- a/apps/maarch_entreprise/indexing_searching/details.php +++ b/apps/maarch_entreprise/indexing_searching/details.php @@ -1008,7 +1008,6 @@ if ((!empty($_SESSION['error']) && ! ($_SESSION['indexation'] )) ) <?php if ($core->is_module_loaded('tags') && ($core->test_service('tag_view', 'tags', false) == 1)) { include_once('modules/tags/templates/details/index.php'); - echo '<script>new Chosen($(\'tag_userform\'),{width: "95%", disable_search_threshold: 10, search_contains: true});</script>'; } if ($core->is_module_loaded('thesaurus') && ($core->test_service('thesaurus_view', 'thesaurus', false) == 1)) diff --git a/apps/maarch_entreprise/lang/en.php b/apps/maarch_entreprise/lang/en.php index 672314b7146bb3c769005d9ec39218d73f0d55eb..ff8596e57cc9a5aa8d103d7ea690c80ca85fcca8 100644 --- a/apps/maarch_entreprise/lang/en.php +++ b/apps/maarch_entreprise/lang/en.php @@ -1802,3 +1802,5 @@ if (!defined("_MARK_AS_READ")) define("_MARK_AS_READ", "Marked as read"); if (!defined("_USE_PREVIOUS_ADDRESS")) define("_USE_PREVIOUS_ADDRESS", "Re use an address"); if (!defined("_SEARCH_INDICATION")) define("_SEARCH_INDICATION", " indicate that the search is done on mails and attachments."); + +if (!defined("_VISIBLE_BY")) define("_VISIBLE_BY", "Is visible by"); \ No newline at end of file diff --git a/apps/maarch_entreprise/lang/fr.php b/apps/maarch_entreprise/lang/fr.php index 4fa39f703f5f749b76b8e654644895f7075a4638..26bfb0d877da7963316e7523912a43a7e7bf1cc8 100755 --- a/apps/maarch_entreprise/lang/fr.php +++ b/apps/maarch_entreprise/lang/fr.php @@ -1807,3 +1807,4 @@ if (!defined("_CONNECTION_CAS_OK")) define("_CONNECTION_CAS_OK", "Authentific if (!defined("_CAS_SAML_NOT_SUPPORTED")) define("_CAS_SAML_NOT_SUPPORTED", "Le protocal SAML 1.1 n est pas encore géré."); if (!defined("_PROTOCOL_NOT_SUPPORTED")) define("_PROTOCOL_NOT_SUPPORTED", "Ce protocol du CAS n est pas prise en compte."); if (!defined("_USER_NOT_EXIST")) define("_USER_NOT_EXIST", "Cet utilisateur n existe pas dans l application."); +if (!defined("_VISIBLE_BY")) define("_VISIBLE_BY", "Visible par"); diff --git a/core/class/users_controler.php b/core/class/users_controler.php index fdcfc20b61f853970b930b0ce0c4446376830114..376b0385e649f3879a7b1d8ff4108f8bb4fae29c 100644 --- a/core/class/users_controler.php +++ b/core/class/users_controler.php @@ -954,4 +954,41 @@ class users_controler extends ObjectControler implements ObjectControlerIF return $entities; } + + /** + * Returns in an array all the parent entities associated with a specific entitiy type + * + * @param $userId string $entityType string + * @return Array or null + */ + public function getParentEntitiesWithType($userId, $entityType) { + $userEntities = self::getEntities($userId); + $parentEntitiesWithType = array(); + + foreach ($userEntities as $entity) { + $entity = $entity['ENTITY_ID']; + $isRightEntityType = false; + while (!$isRightEntityType) { + $query = "SELECT parent_entity_id, entity_type" + . " FROM entities" + . " WHERE entity_id = ?"; + $stmt = self::$db->query($query, array($entity)); + + $res = $stmt->fetchObject(); + if (!$res) { + $isRightEntityType = true; + } else if ($res->entity_type == $entityType) { + if (!in_array($entity, $parentEntitiesWithType)) { + $parentEntitiesWithType[] = $entity; + } + $isRightEntityType = true; + } else { + $entity = $res->parent_entity_id; + } + } + } + + return $parentEntitiesWithType; + } + } diff --git a/modules/entities/class/class_users_entities_Abstract.php b/modules/entities/class/class_users_entities_Abstract.php index b54fd79865a70e563715a49e11144490140ad71b..845c3f27352bb81c9741419255f53fbce926c82a 100755 --- a/modules/entities/class/class_users_entities_Abstract.php +++ b/modules/entities/class/class_users_entities_Abstract.php @@ -154,27 +154,22 @@ abstract class users_entities_Abstract extends functions * @param string $entity_id entity identifier * @param array $tmparray the array who receive the children */ - public function getEntityChildren($entity_id) + public function getEntityChildren($parent_id) { + $entities = array(); $db = new Database(); - static $tmparray = array(); - - $stmt = $db->query('select entity_id from '.ENT_ENTITIES." where parent_entity_id = ?",array(trim($entity_id))); - if($stmt->rowCount() > 0) - { - while($line = $stmt->fetchObject()) - { - array_push($tmparray, $line->entity_id); - $userEnt = new users_entities(); - $db = new Database(); - $stmt2 = $db->query('select entity_id from '.ENT_ENTITIES." where parent_entity_id = ?",array(trim($line->entity_id))); - if($stmt2->rowCount > 0) - { - $stmt2->getEntityChildren($line->entity_id, $tmparray); - } - } + $stmt = $db->query('SELECT entity_id, parent_entity_id FROM entities WHERE parent_entity_id = \''.$parent_id.'\' order by entity_id asc', array()); + while($row=$stmt->fetch(PDO::FETCH_ASSOC)){ + $stmt3 = $db->query( + "SELECT count(entity_id) as total FROM entities WHERE parent_entity_id IN ('".$row['entity_id']."')" + ); + $row3 = $stmt3->fetch(PDO::FETCH_ASSOC); + + $entities[] = $row['entity_id']; + + $entities = array_merge($entities,self::getEntityChildren($row['entity_id'])); } - return $tmparray; + return $entities ; } diff --git a/modules/tags/aj_add_this_tags.php b/modules/tags/aj_add_this_tags.php index da7577dddbadc42ce15bedd6532e0764677855ce..514441f74447c9b4965b82fdf287a01e5b65392c 100644 --- a/modules/tags/aj_add_this_tags.php +++ b/modules/tags/aj_add_this_tags.php @@ -48,41 +48,17 @@ try{ $core = new core_tools(); $core->load_lang(); $tag = new tag_controler; - +$coll_id = 'letterbox_coll'; $p_input_value = $_REQUEST['p_input_value']; -$p_input_value = str_replace('\r', '', $p_input_value); -$p_input_value = str_replace('\n', '', $p_input_value); -// $p_input_value = str_replace('\'', ' ', $p_input_value); -$p_input_value = str_replace('"', ' ', $p_input_value); -$p_input_value = str_replace('\\', ' ', $p_input_value); - - -//On découpe la chaine composée de virgules -$tabrr = array( CHR(13) => ",", CHR(10) => "," ); -$p_input_value = strtr($p_input_value,$tabrr); - -$new_tags = explode(',',$p_input_value); - - - - - -foreach($new_tags as $new_tag){ - - if (trim($new_tag) <> '') - { - $result = $tag->add_this_tags_in_session($new_tag); - //$result = $tag->add_this_tags($p_res_id, $p_coll_id, $new_tag); - //if (!$result){ - // echo "{status : 1, error_txt : '".addslashes(UNABLETOADDTAGS)."'}"; - // exit(); - //} - } - +if (trim($p_input_value) <> '') +{ + $result = $tag->add_this_tags_in_session($p_input_value, $coll_id); + $tagInfo = $tag->get_by_label($p_input_value); } -echo "{status : 0, value : 'ok'}"; + +echo "{status : 0, value : '".$tagInfo->tag_id."'}"; exit(); ?> diff --git a/modules/tags/aj_tag_fusion_tags.php b/modules/tags/aj_tag_fusion_tags.php index 1a76934ea3a5a562bd207f3c69da2e8bec75533f..586a163a769d9aadb760a4add2fc2c701e1b23d7 100644 --- a/modules/tags/aj_tag_fusion_tags.php +++ b/modules/tags/aj_tag_fusion_tags.php @@ -1,6 +1,6 @@ <?php /* -* Copyright 2008,2009 Maarch +* Copyright 2008,2017 Maarch * * This file is part of Maarch Framework. * @@ -16,15 +16,15 @@ * * You should have received a copy of the GNU General Public License * along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -* File : aj_add_this_tag.php +* File : aj_tag_fusion_tags.php * -* Script called by an ajax object to delete jonction on a ressource and a tag +* Script called by an ajax object to replace a tag with an other * * @package maarch * @version 1 -* @since 10/2005 +* @since 10/2016 * @license GPL v3 -* @author Loic Vinet <dev@maarch.org> +* @author Alex ORLUC <dev@maarch.org> */ try{ @@ -32,8 +32,8 @@ try{ require_once 'core/class/ObjectControlerAbstract.php'; require_once 'core/class/ObjectControlerIF.php'; require_once 'core/class/class_request.php' ; - require_once 'modules/tags/class/TagControler.php' ; - require_once 'modules/tags/tags_tables_definition.php'; + require_once 'modules/tags/class/TagControler.php' ; + require_once 'modules/tags/tags_tables_definition.php'; } catch (Exception $e) { functions::xecho($e->getMessage()); } @@ -45,56 +45,40 @@ $core = new core_tools(); $core->load_lang(); $tag = new tag_controler; +if(empty($_REQUEST['newTagId'])){ + echo "{status : 1, value : 'NO TAG'}"; + exit(); +} +$tagIdBeforeFusion = $_REQUEST['tagIdBeforeFusion']; +$newTagId = $_REQUEST['newTagId']; -$a_search_tag = $_REQUEST['a_search_tag']; -$a_search_tag = str_replace('\r', '', $a_search_tag); -$a_search_tag = str_replace('\n', '', $a_search_tag); -// $a_search_tag = str_replace('\'', ' ', $a_search_tag); -$a_search_tag = str_replace('"', ' ', $a_search_tag); -$a_search_tag = str_replace('\\', ' ', $a_search_tag); - - -//On découpe la chaine composée de virgules -$tabrr = array( CHR(13) => ",", CHR(10) => "," ); -$a_search_tag = strtr($a_search_tag,$tabrr); - -$a_search_tag_arr = explode(',',$a_search_tag); - -$a_search_tag_label = $a_search_tag_arr[0]; -$a_search_tag_coll = $a_search_tag_arr[1]; - -//---------------------------------- - -$a_new_tag = $_REQUEST['a_new_tag']; -$a_new_tag = str_replace('\r', '', $a_new_tag ); -$a_new_tag = str_replace('\n', '', $a_new_tag ); -// $a_new_tag = str_replace('\'', ' ', $a_new_tag ); -$a_new_tag = str_replace('"', ' ', $a_new_tag ); -$a_new_tag = str_replace('\\', ' ', $a_new_tag ); -//On découpe la chaine composée de virgules -$tabrr = array( CHR(13) => ",", CHR(10) => "," ); -$a_new_tag = strtr($a_new_tag,$tabrr); - -$a_new_tag_arr = explode(',',$a_new_tag); - -$a_new_tag_label = $a_new_tag_arr[0]; -$a_new_tag_coll = trim($a_new_tag_arr[1]); - - +//check all res_id associate with newTagId $stmt = $db->query( - "SELECT DISTINCT res_id from "._TAG_TABLE_NAME - . " WHERE tag_label = ? and coll_id = ? " - ,array($a_search_tag_label,$a_search_tag_coll)); - -while ($result = $stmt->fetchObject()) { - $tag -> delete_this_tag($result->res_id,$a_search_tag_coll,functions::protect_string_db($a_search_tag_label)); - $tag -> add_this_tag($result->res_id,$a_new_tag_coll,$a_new_tag_label); + "SELECT res_id FROM tag_res" + . " WHERE tag_id = ?" + ,array($newTagId)); + +while($tagRes = $stmt->fetchObject()){ + $stmt = $db->query( + "DELETE FROM tag_res" + . " WHERE res_id = ? and tag_id = ?" + ,array($tagRes->res_id,$tagIdBeforeFusion)); } -//$query_verify = "select count()"; -//$queryupdate = "update "._TAG_TABLE_NAME." set tag_label = '".$a_new_tag_label."', coll_id = '".$a_new_tag_coll."' where tag_label = '".$a_search_tag_label."' and coll_id = '".$a_search_tag_coll."' "; +//Clean restrictions +$stmt = $db->query( + "DELETE FROM tags_entities" + . " WHERE tag_id = ?" +,array($tagIdBeforeFusion)); + +//replace all res associate with tagIdBeforeFusion +$stmt = $db->query( + "UPDATE tag_res SET tag_id = ?" + . " WHERE tag_id = ?" + ,array($newTagId,$tagIdBeforeFusion)); -//$db->query($query); +//delete old tag +$tag->delete($tagIdBeforeFusion); echo "{status : 0, value : 'ok'}"; exit(); diff --git a/modules/tags/class/TagControler_Abstract.php b/modules/tags/class/TagControler_Abstract.php index f6694580b6025ba3b4a00e927d3777e04b89ca09..a62389831ff3f4a11eb1d2a4634b5e67807b51d9 100755 --- a/modules/tags/class/TagControler_Abstract.php +++ b/modules/tags/class/TagControler_Abstract.php @@ -44,6 +44,8 @@ try { require_once("core/class/class_history.php"); require_once("modules/tags/class/Tag.php"); require_once("modules/tags/tags_tables_definition.php"); + require_once("core/class/users_controler.php"); + require_once("modules/entities/class/class_users_entities_Abstract.php"); } catch (Exception $e){ functions::xecho($e->getMessage()).' // '; @@ -65,30 +67,83 @@ abstract class tag_controler_Abstract extends ObjectControler public function get_all_tags($coll_id = '') { + $core = new core_tools(); + /* * Return a complete list of tags in Maarch */ $return = array(); $where_what = array(); - - if ($coll_id <> '') { - $whereClause = " where coll_id = ? "; - $where_what[] = $coll_id; - } - + $db = new Database(); - $stmt = $db->query( - 'SELECT DISTINCT tag_label, coll_id FROM ' + + if($core->test_service('private_tag', 'tags',false) == 1){ + $entitiesRestriction = array(); + $entitiesDirection = users_controler::getParentEntitiesWithType($_SESSION['user']['UserId'],'Direction'); + //var_dump($entitiesDirection); + foreach ($entitiesDirection as $entity_id) { + $entitiesRestriction[] = $entity_id; + $tmp_arr = users_entities_Abstract::getEntityChildren($entity_id); + $entitiesRestriction = array_merge($entitiesRestriction,$tmp_arr); + } + //var_dump($entitiesRestriction); + //CHECK TAG IS ALLOW FOR THESE ENTITIES + if(!empty($entitiesRestriction)){ + $entitiesRestriction = "'".implode("','", $entitiesRestriction)."'"; + $where = ' WHERE entity_id IN ('.$entitiesRestriction.')'; + }else{ + $where = ''; + } + $stmt = $db->query( + 'SELECT distinct(tag_id)' + . ' FROM tags_entities' + . $where + ,array()); + + $restrictedTagIdList = $stmt->fetchAll(PDO::FETCH_COLUMN, 0); + + //var_dump($restrictedTagIdList); + //CHECK TAG WHO IS NOT RESTRICTED + $stmt = $db->query( + 'SELECT tag_id' + . ' FROM tags' + . ' WHERE tag_id NOT IN (select distinct(tag_id) from tags_entities)' + ,array()); + $freeTagIdList = $stmt->fetchAll(PDO::FETCH_COLUMN, 0); + + //var_dump($freeTagIdList); + //MERGE ALLOWED TAGS AND FREE TAGS + $tagIdList = array_merge($restrictedTagIdList,$freeTagIdList); + + if(!empty($tagIdList)){ + $tagIdList = "'".implode("','", $tagIdList)."'"; + $where = ' WHERE tag_id IN ('.$tagIdList.')'; + }else{ + $where = ''; + } + + + $stmt = $db->query( + 'SELECT tag_id, tag_label FROM ' + . _TAG_TABLE_NAME + . $where + . ' ORDER BY tag_label ASC ' + ,$where_what); + }else{ + $stmt = $db->query( + 'SELECT tag_id, tag_label FROM ' . _TAG_TABLE_NAME . $whereClause . ' ORDER BY tag_label ASC ' ,$where_what); + } - self::set_specific_id('tag_label'); + self::set_specific_id('tag_id'); if($stmt->rowCount() > 0){ while($tag=$stmt->fetchObject()){ + $tougue['tag_id'] = $tag->tag_id; $tougue['tag_label'] = $tag->tag_label; $tougue['coll_id'] = $tag->coll_id; array_push($return, $tougue); @@ -98,7 +153,45 @@ abstract class tag_controler_Abstract extends ObjectControler return false; } - + public function get_by_id($tag_id, $coll_id = 'letterbox_coll') { + /* + * Searching a tag by label + * @If tag exists, return this value, else, return false + */ + if (empty($tag_id) || empty($coll_id)) { + + return null; + } + + $db = new Database(); + $entities = array(); + + $stmt = $db->query( + 'SELECT tag_id, tag_label, coll_id FROM ' . _TAG_TABLE_NAME + . ' WHERE tag_id = ? AND' + . ' coll_id = ?' + , array($tag_id, $coll_id)); + + self::set_specific_id('tag_id'); + + $tag = $stmt->fetchObject(); + + //Retrieve entities restriction + $stmt = $db->query( + 'SELECT entity_id FROM tags_entities' + . ' WHERE tag_id = ?' + , array($tag_id)); + $entities = $stmt->fetchAll(PDO::FETCH_COLUMN, 0); + + $tag->entities = $entities; + + if (isset($tag)) { + return $tag; + } else { + return null; + } + } + public function get_by_label($tag_label, $coll_id = 'letterbox_coll') { /* @@ -113,13 +206,11 @@ abstract class tag_controler_Abstract extends ObjectControler $db = new Database(); $stmt = $db->query( - 'SELECT tag_label, coll_id FROM '._TAG_TABLE_NAME + 'SELECT tag_id, tag_label FROM '._TAG_TABLE_NAME . ' WHERE tag_label = ? AND' . ' coll_id = ?' ,array($tag_label,$coll_id)); - - self::set_specific_id('tag_label'); - + $tag=$stmt->fetchObject(); if (isset($tag)) { @@ -156,16 +247,18 @@ abstract class tag_controler_Abstract extends ObjectControler * @Return : list of tags for one ressource */ $db = new Database(); + $stmt = $db->query( - "SELECT tag_label FROM " ._TAG_TABLE_NAME - . " WHERE res_id = ? AND coll_id = ?" + "SELECT tag_res.tag_id FROM tag_res" + . " INNER JOIN tags ON tag_res.tag_id = tags.tag_id" + . " WHERE tag_res.res_id = ? AND tags.coll_id = ?" ,array($res_id,$coll_id)); //$db->show(); $return = array(); while ($res = $stmt->fetchObject()){ - array_push($return, $res->tag_label); + array_push($return, $res->tag_id); } if ($return) return $return; else return false; @@ -202,17 +295,17 @@ abstract class tag_controler_Abstract extends ObjectControler //$db->show(); } - public function countdocs($tag_label, $coll_id){ + public function countdocs($tag_id){ /* * Count ressources for one tag : used by tags administration */ $db = new Database(); $stmt = $db->query( - "SELECT count(res_id) AS bump FROM " ._TAG_TABLE_NAME - . " WHERE tag_label = ? AND coll_id = ?" + "SELECT count(res_id) AS bump FROM tag_res" + . " WHERE tag_id = ?" . " AND res_id <> 0" - ,array($tag_label,$coll_id)); + ,array($tag_id)); $result = $stmt->fetchObject(); $return = 0; @@ -254,7 +347,7 @@ abstract class tag_controler_Abstract extends ObjectControler } - public function delete_tags($res_id,$coll_id) + public function deleteTagsRes($res_id) { /* * Searching a tag by label @@ -262,9 +355,9 @@ abstract class tag_controler_Abstract extends ObjectControler */ $db = new Database(); $stmt = $db->query( - "DELETE FROM " ._TAG_TABLE_NAME - . " WHERE res_id = ? and coll_id = ? " - ,array($res_id,$coll_id)); + "DELETE FROM tag_res" + . " WHERE res_id = ?" + ,array($res_id)); /*$hist = new history(); $hist->add( 'res_view_letterbox', $res_id, "DEL", 'tagdel', _ALL_TAG_DELETED_FOR_RES_ID.' : "'. @@ -275,7 +368,7 @@ abstract class tag_controler_Abstract extends ObjectControler } - public function delete($tag_label,$coll_id) + public function delete($tag_id,$coll_id='letterbox_coll') { /* * Deleting [REALLY] a tag for a ressource @@ -283,8 +376,17 @@ abstract class tag_controler_Abstract extends ObjectControler $db = new Database(); $stmt = $db->query( "DELETE FROM " ._TAG_TABLE_NAME - . " WHERE tag_label = ? AND coll_id = ?" - ,array($tag_label,$coll_id)); + . " WHERE tag_id = ?" + ,array($tag_id)); + $stmt = $db->query( + "DELETE FROM tag_res" + . " WHERE tag_id = ?" + ,array($tag_id)); + $stmt = $db->query( + "DELETE FROM tags_entities" + . " WHERE tag_id = ?" + ,array($tag_id)); + if ($stmt){ $hist = new history(); $hist->add( @@ -299,7 +401,7 @@ abstract class tag_controler_Abstract extends ObjectControler } - public function store($tag_label, $mode='up', $params){ + public function store($tag_id, $mode='up', $params){ /* * Store into the database a tag for a ressource */ @@ -321,7 +423,7 @@ abstract class tag_controler_Abstract extends ObjectControler $new_tag_label = $params[0]; $coll_id = $params[1]; - $this->update_tag_label($new_tag_label, functions::protect_string_db($tag_label), $coll_id); + $this->update_tag($tag_id, $coll_id); /*$hist = new history(); $hist->add( _TAG_TABLE_NAME, $new_tag_label, "ADD", 'tagup', _TAG_ADDED.' : "'. @@ -371,6 +473,42 @@ abstract class tag_controler_Abstract extends ObjectControler } } + public function update_tag($tag_id, $coll_id) + { + /* + * Add in the memory [Session] the tag value for one ressource + */ + + $new_tag_label = str_replace("''", "'", $_SESSION['m_admin']['tag']['tag_label']); + $new_tag_label = $this->control_label($_SESSION['m_admin']['tag']['tag_label']); + + $db = new Database(); + + //Primo, test de l'existance du mot clé en base. + $stmt = $db->query( + "UPDATE " ._TAG_TABLE_NAME + . " SET tag_label = ?" + . " WHERE tag_id = ?" + ,array($new_tag_label,$tag_id)); + + //reset entities restrictions + $stmt = $db->query( + "DELETE FROM tags_entities" + . " WHERE tag_id = ?" + ,array($tag_id)); + + if(!empty($_SESSION['m_admin']['tag']['entities'])){ + foreach ($_SESSION['m_admin']['tag']['entities'] as $entity_id) { + $stmt = $db->query( + "INSERT INTO tags_entities" + . "(tag_id, entity_id) VALUES (?, ?)" + ,array($tag_id,$entity_id)); + } + } + + + } + public function insert_tag_label($new_tag_label, $coll_id) { /* @@ -385,99 +523,91 @@ abstract class tag_controler_Abstract extends ObjectControler //Primo, test de l'existance du mot clé en base. $stmt = $db->query( "SELECT tag_label FROM " ._TAG_TABLE_NAME - . " WHERE coll_id = ? AND tag_label = ?" + . " WHERE coll_id = ? AND tag_label ILIKE ?" ,array($coll_id,$new_tag_label)); //$db->show();exit(); if ($stmt->rowCount() == 0) { $stmt = $db->query( "INSERT INTO " ._TAG_TABLE_NAME - . " VALUES (?, ?, 0)" + . "(tag_label, coll_id) VALUES (?, ?)" ,array($new_tag_label,$coll_id)); - /*$hist = new history(); - $hist->add( - _TAG_TABLE_NAME, $new_tag_label, "ADD", 'tagadd', _TAG_ADDED.' : "'. - substr(functions::protect_string_db($new_tag_label), 0, 254) .'"', - $_SESSION['config']['databasetype'], 'tags' - );*/ + + $tag_id = $db->lastInsertId('tag_id_seq'); + + if(!empty($_SESSION['m_admin']['tag']['entities'])){ + foreach ($_SESSION['m_admin']['tag']['entities'] as $entity_id) { + $stmt = $db->query( + "INSERT INTO tags_entities" + . "(tag_id, entity_id) VALUES (?, ?)" + ,array($tag_id,$entity_id)); + } + } + + }else{ + $_SESSION['error'] = _TAG_DEFAULT.' '.': '.$new_tag_label.' '._ALREADY_EXISTS; + return false; } } - public function add_this_tag($res_id,$coll_id,$tag_label) - { + public function add_this_tag($res_id, $tag_id) { /* * Adding [REALLY] a tag for a ressource */ - $db = new Database(); - $tag_label = $this->control_label($tag_label); - + $db = new Database(); + $stmt = $db->query( - "SELECT tag_label FROM " ._TAG_TABLE_NAME - . " WHERE res_id = ? AND coll_id = ? AND tag_label = ?" - ,array($res_id,$coll_id,$tag_label)); - if ($stmt->rowCount()==0){ - //Lancement de la suppression de l'occurence - $stmt = $db->query( - "INSERT INTO " ._TAG_TABLE_NAME - . " (tag_label, res_id, coll_id)" - . " VALUES (?,?,?) " - ,array($tag_label,$res_id,$coll_id)); - if ($stmt){ - - /*$hist = new history(); - $hist->add( - 'res_view_letterbox', $res_id, "ADD", 'tagadd', _TAG_ADDED.' : "'. - substr(functions::protect_string_db($tag_label), 0, 254) .'"', - $_SESSION['config']['databasetype'], 'tags' - );*/ - return true; } + "INSERT INTO tag_res" + . " (tag_id, res_id)" + . " VALUES (?,?) " + , array($tag_id, $res_id)); + if ($stmt) { + + /* $hist = new history(); + $hist->add( + 'res_view_letterbox', $res_id, "ADD", 'tagadd', _TAG_ADDED.' : "'. + substr(functions::protect_string_db($tag_label), 0, 254) .'"', + $_SESSION['config']['databasetype'], 'tags' + ); */ + return true; } + return false; - + //$db->show(); - } - + public function load_sessiontag($res_id,$coll_id) { $_SESSION['tagsuser'] = array(); - $_SESSION['tagsuser'] = $this->get_by_res($res_id, $coll_id); + $_SESSION['tagsuser'] = $this->get_by_res($res_id, $coll_id); } - public function add_this_tags_in_session($tag_label) - { - - $ready = true; - if ($_SESSION['tagsuser']) - { - //$_SESSION['taguser'] = array(); - - foreach($_SESSION['tagsuser'] as $this_tag){ - if (strtolower($this_tag) == strtolower($tag_label)){ - $ready = false; - } - } - - } + public function add_this_tags_in_session($tag_label, $coll_id) { + $_SESSION['m_admin']['tag'] = array(); + $_SESSION['m_admin']['tag']['tag_label'] = $tag_label; + $_SESSION['m_admin']['tag']['entities'] = array(); + $core = new core_tools(); - if ($ready == true){ - - - if (!$_SESSION['tagsuser']) - { - $_SESSION['tagsuser'] = array(); + if ($core->test_service('private_tag', 'tags', false) == 1) { + $entitiesRestriction = array(); + $entitiesDirection = users_controler::getParentEntitiesWithType($_SESSION['user']['UserId'], 'Direction'); + //var_dump($entitiesDirection); + foreach ($entitiesDirection as $entity_id) { + $entitiesRestriction[] = $entity_id; + $tmp_arr = users_entities_Abstract::getEntityChildren($entity_id); + $entitiesRestriction = array_merge($entitiesRestriction, $tmp_arr); } - - array_push($_SESSION['tagsuser'], $tag_label); - return true; + $_SESSION['m_admin']['tag']['entities'] = $entitiesRestriction; } - return false; - + + $this->insert_tag_label($tag_label, $coll_id); + return true; } - + public function remove_this_tags_in_session($tag_label) { //remplir le formulaire de session @@ -503,17 +633,17 @@ abstract class tag_controler_Abstract extends ObjectControler } } - public function update_restag($res_id,$coll_id,$tag_array) + public function associateTagToRes($res_id,$coll_id,$tag_array) { $core_tools = new core_tools(); if ($core_tools->test_service('add_tag_to_res', 'tags',false) == 1) { - $this->delete_tags($res_id, $coll_id); + $this->deleteTagsRes($res_id); if ($tag_array) { - foreach($tag_array as $this_taglabel) + foreach($tag_array as $this_tagId) { - $this->add_this_tag($res_id,$coll_id,$this_taglabel); + $this->add_this_tag($res_id,$this_tagId); } } } diff --git a/modules/tags/js/functions.js b/modules/tags/js/functions.js index 76e1d83f1efdcb2f2a80eed04b3aabd478e89357..ea7256083f7dd4f2cf86acd33c077296584088ea 100644 --- a/modules/tags/js/functions.js +++ b/modules/tags/js/functions.js @@ -1,67 +1,53 @@ function add_this_tags(action_script, ui_script) { - //if(res_id == '' || coll_id == '') - //{ - // if(console) - // { - // console.log('Error add_this_tag :: coll_id or res_id is empty'); - // } - //} - //Allons chercher l'info du formulaire en l etat... - var content = $('tag_userform').value; - - if(content.length < 50) { - if(action_script) - { + var content = $j("#new_tag_label").val(); - new Ajax.Request(action_script, - { - method:'post', - parameters: - { - p_input_value : content - //p_res_id : res_id, - //p_coll_id : coll_id - - }, - onSuccess: function(answer){ - eval("response = "+answer.responseText); - //alert(answer.responseText); - if(response.status == 0 ) - { - //load_tags(ui_script,res_id,coll_id) - load_tags(ui_script) - } else if (response.status == 1 ){ - //var span = document.getElementById('show_tags'); - //span.innerHTML ="<font color=\"red\">vous n avez pas les droits pour ajouter ce mot clé !</font>"; - //alert("<?php echo _ADD_TAG; ?>"); - if(response.value == 'fr'){ - alert("Vous devez utiliser les mots clés existants!"); - }else if(response.value == 'en'){ - alert("You must use the tags exists !"); - } - } else - { - if(console) - { - console.log('Erreur Ajax'); - } - } - }, - onFailure: function(){ alert('Something went wrong...'); } - }); - - } - else - { - if(console) - { - console.log('Error delete_this_tag::no script defined'); - } - } - } else { - alert("Le mot-clé doit être inférieur à 50 caractères"); - } + if (content.length < 50) { + if (action_script) + { + + new Ajax.Request(action_script, + { + method: 'post', + parameters: + { + p_input_value: content + + }, + onSuccess: function (answer) { + eval("response = " + answer.responseText); + + //alert(answer.responseText); + if (response.status == 0) + { + $j('#tag_userform').append($j('<option>', { value : response.value, selected : true }).text(content)); + //alert('mot clé ajouté'); + console.log($j('#tag_userform option')); + Event.fire($("tag_userform"), "chosen:updated"); + } else + { + if (console) + { + console.log('Erreur Ajax'); + } + } + }, + onFailure: function () { + alert('Something went wrong...'); + } + }); + + } + else + { + if (console) + { + console.log('Error delete_this_tag::no script defined'); + } + } + } else { + alert("Le mot-clé doit être inférieur à 50 caractères"); + } } @@ -191,45 +177,40 @@ function launch_autocompleter_tags(path_script) } } -function tag_fusion(search_tag, new_tag, path_script, result_text, header_location) +function tag_fusion(tagIdBeforeFusion, newTagId, path_script, result_text, header_location) { - if(search_tag == '' || new_tag == '' || path_script == '') - { - if(console) - { - console.log('fields empty :: tag_fusion'); - } - } - if(path_script) - { - new Ajax.Request(path_script, - { - method:'post', - parameters: - { - a_search_tag : search_tag, - a_new_tag : new_tag - }, - onSuccess: function(answer){ - eval("response = "+answer.responseText); - //alert(answer.responseText); - if(response.status == 0 ) - { - alert(result_text); - header(header_location); - } - else - { - if(console) - { - console.log('Erreur Ajax'); - } - } - }, - onFailure: function(){ alert('Something went wrong...'); } - }); - - } + if (path_script) + { + new Ajax.Request(path_script, + { + method: 'post', + parameters: + { + tagIdBeforeFusion: tagIdBeforeFusion, + newTagId: newTagId + }, + onSuccess: function (answer) { + eval("response = " + answer.responseText); + //alert(answer.responseText); + if (response.status == 0) + { + alert(result_text); + window.location.href=header_location; + } + else + { + if (console) + { + console.log('Erreur Ajax'); + } + } + }, + onFailure: function () { + alert('Something went wrong...'); + } + }); + + } } diff --git a/modules/tags/lang/en.php b/modules/tags/lang/en.php index c57dc33c3ccc0bd88c6dcdfac1f7939656d1f9f4..9fe043d361268602fbba60d894ee700fc649de5f 100755 --- a/modules/tags/lang/en.php +++ b/modules/tags/lang/en.php @@ -86,7 +86,7 @@ if (!defined("_TAGS")) if (!defined("_TAG_SEPARATOR_HELP")) define("_TAG_SEPARATOR_HELP", "Separate tags by pressing on Enter or with commas"); if (!defined("_NB_DOCS_FOR_THIS_TAG")) - define("_NB_DOCS_FOR_THIS_TAG", "Number of tagged documents"); + define("_NB_DOCS_FOR_THIS_TAG", "tagged documents"); if (!defined("_TAGOTHER_OPTIONS")) define("_TAGOTHER_OPTIONS", "Other options"); if (!defined("_TAG_FUSION_ACTIONLABEL")) diff --git a/modules/tags/lang/fr.php b/modules/tags/lang/fr.php index 8e4880fd77976cc9f027ad4e7da4291b603c12ff..0d5f114c40c776148a387934cbd161b206c559aa 100755 --- a/modules/tags/lang/fr.php +++ b/modules/tags/lang/fr.php @@ -68,7 +68,9 @@ if (!defined("_ADD_TAG")) if (!defined("_ADD_TAG_TO_RES")) define("_ADD_TAG_TO_RES", "Associer les "._TAGS_DEFAULT." disponible à un document"); if (!defined("_CREATE_TAG")) - define("_CREATE_TAG", "Créer des "._TAGS_DEFAULT); + define("_CREATE_TAG", "Créer des "._TAGS_DEFAULT." depuis les page d'actions"); +if (!defined("_CREATE_TAG_DESC")) + define("_CREATE_TAG_DESC", "Permet d'enregistrer à la volée des mots clés inexistants dans la base de données"); if (!defined("_ADD_TAG_TO_RES_DESC")) define("_ADD_TAG_TO_RES_DESC", "Permet d'ajouter des "._TAGS_DEFAULT." à une ressource"); if (!defined("_DELETE_TAG_TO_RES")) @@ -86,7 +88,7 @@ if (!defined("_TAGS")) if (!defined("_TAG_SEPARATOR_HELP")) define("_TAG_SEPARATOR_HELP", "Séparez les mots-clés en appuyant sur Entrée ou avec des virgules"); if (!defined("_NB_DOCS_FOR_THIS_TAG")) - define("_NB_DOCS_FOR_THIS_TAG", "Nbre de documents taggués"); + define("_NB_DOCS_FOR_THIS_TAG", "document(s) taggué(s)"); if (!defined("_TAGOTHER_OPTIONS")) define("_TAGOTHER_OPTIONS", "Autres options"); if (!defined("_TAG_FUSION_ACTIONLABEL")) @@ -109,4 +111,8 @@ if (!defined("_TAGCLICKTODEL")) define("_TAGCLICKTODEL", "supprimer"); if (!defined("_NAME_TAGS")) define("_NAME_TAGS", "Nom du mot-clé"); +if (!defined("_PRIVATE_TAGS")) + define("_PRIVATE_TAGS", "Restreindre les mots-clés à l'entité de l'utilisateur (Niveau direction)"); +if (!defined("_PRIVATE_TAGS_DESC")) + define("_PRIVATE_TAGS_DESC", "L'utilisateur ne verra que les mots clées qui ont été restreint à sa direction (l'ajout / modification associera le mot clé automatiquement à sa direction)."); diff --git a/modules/tags/manage_tag_list.php b/modules/tags/manage_tag_list.php index 7cd2b008bfd3b8e1c2bb28ee75324472f79c35ce..388f5873694471e7024d4eafcbef6da978f95d6d 100755 --- a/modules/tags/manage_tag_list.php +++ b/modules/tags/manage_tag_list.php @@ -39,7 +39,7 @@ if ($mode == 'list') { $tagslist['title'], 'tag_label', 'manage_tag_list_controller&mode=list', - 'tags','tag_label', + 'tags','tag_id', true, $tagslist['page_name_up'], $tagslist['page_name_val'], @@ -86,7 +86,7 @@ if ($mode == 'list') { <input type="hidden" name="page" value="manage_tag_list_controler" /> <input type="hidden" name="mode" value="<?php functions::xecho($mode);?>" /> - <input type="hidden" name="tag_label" id="tag_label" value="<?php functions::xecho($_SESSION['m_admin']['tag']['tag_label']);?>" /> + <input type="hidden" name="tag_id" id="tag_label" value="<?php functions::xecho($_SESSION['m_admin']['tag']['tag_id']);?>" /> <input type="hidden" name="order" id="order" value="<?php functions::xecho($_REQUEST['order']);?>" /> @@ -96,7 +96,12 @@ if ($mode == 'list') { functions::xecho($_REQUEST['what']);?>" /> <input type="hidden" name="start" id="start" value="<?php functions::xecho($_REQUEST['start']);?>" /> - + + <p> + <label for="label"><?php echo _ID;?> : </label> + <input name="tag_label" type="text" id="tag_label_id" class="readonly" readonly="readonly" value="<?php + echo $_SESSION['m_admin']['tag']['tag_id'];?>"/> + </p> <p> <label for="label"><?php echo _NAME_TAGS;?> : </label> <input name="tag_label" type="text" id="tag_label_id" value="<?php @@ -104,17 +109,65 @@ if ($mode == 'list') { $_SESSION['m_admin']['tag']['tag_label'] );?>"/> </p> + <?php + if($core->test_service('private_tag', 'tags',false) == 1){ + ?> + <p> + <label for="label"><?php echo _VISIBLE_BY;?> : </label> + <?php + require_once "modules".DIRECTORY_SEPARATOR."entities".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."EntityControler.php"; + + $content .= '<select data-placeholder=" " name="entitieslist[]" id="entitieslist" size="7" style="width: 206px" '; + $content .= 'ondblclick=\'moveclick($(entitieslist), $(entities_chosen));\' multiple="multiple">'; + + //entitiesRestriction + $entitiesRestriction = array(); + $entitiesDirection = users_controler::getParentEntitiesWithType($_SESSION['user']['UserId'],'Direction'); + //var_dump($entitiesDirection); + foreach ($entitiesDirection as $entity_id) { + $entitiesRestriction[] = $entity_id; + $tmp_arr = users_entities_Abstract::getEntityChildren($entity_id); + $entitiesRestriction = array_merge($entitiesRestriction,$tmp_arr); + } + //entitiesList + $entitiesList = array(); + $entitiesList = EntityControler::getAllEntities(); + for ($i=0;$i<count($entitiesList);$i++) { + + $content .= '<option value="' + .$entitiesList[$i]->entity_id.'" alt="' + .$entitiesList[$i]->short_label.'" title="' + .$entitiesList[$i]->short_label.'"'; + if ($mode == 'add') { + if(in_array($entitiesList[$i]->entity_id, $entitiesRestriction)){ + $content .= 'selected="selected"'; + } + }else{ + if(in_array($entitiesList[$i]->entity_id, $_SESSION['m_admin']['tag']['entities'])){ + $content .= 'selected="selected"'; + } + } + $content .= '>'; + $content .= $entitiesList[$i]->short_label.'</option>'; + + } + $content .= '</select>'; + $content .= '<script>new Chosen($(\'entitieslist\'),{width: "95%", disable_search_threshold: 10});</script>'; + echo $content; + ?> + </p> + <?php } ?> <?php if ($mode == 'up') { ?> - <p> + <!--<p> <label for="label"><?php echo _COLL_ID;?> : </label> <span><?php echo functions::show_str( $_SESSION['m_admin']['tag']['tag_coll'] );?> </span> - </p> + </p>--> <?php } else { $arrayColl = $_SESSION['m_admin']['tags']['coll_id']; @@ -145,12 +198,9 @@ if ($mode == 'list') { } if ($mode == 'up') { ?> - <p> - <label for="label"><?php echo _NB_DOCS_FOR_THIS_TAG;?> : </label> + <p style="font-style: italic;color:#009DC5;"> <span><?php - echo functions::show_str( - $_SESSION['m_admin']['tag']['tag_count'] - );?> + echo $_SESSION['m_admin']['tag']['tag_count'].' '._NB_DOCS_FOR_THIS_TAG;?> </span> </p> <?php @@ -161,7 +211,7 @@ if ($mode == 'list') { <?php if ($mode == 'up') { ?> <input class="button" type="submit" name="tag_submit" value= - "<?php echo _MODIFY_TAG;?>" /> + "<?php echo _MODIFY;?>" /> <?php } elseif ($mode == 'add') { ?> <input type="submit" class="button" name="tag_submit" value= @@ -178,28 +228,28 @@ if ($mode == 'list') { if ($mode == 'up') { ?> <hr/> - <h3><?php echo _TAGOTHER_OPTIONS;?></h3> <p> <label for="label"><?php echo _TAG_FUSION_ACTIONLABEL;?> : </label> <select name="tagfusion" id="tagfusion"> <?php foreach ($_SESSION['tmp_all_tags'] as $tmp_selectvalue_tag) { + if($tmp_selectvalue_tag['tag_id'] <> $_SESSION['m_admin']['tag']['tag_id']){ ?> - <option value="<?php functions::xecho($tmp_selectvalue_tag['tag_label'].",".$tmp_selectvalue_tag['coll_id']);?>"> - <?php functions::xecho($tmp_selectvalue_tag['tag_label']." ::".$tmp_selectvalue_tag['coll_id']);?> + <option value="<?php functions::xecho($tmp_selectvalue_tag['tag_id']);?>"> + <?php //functions::xecho($tmp_selectvalue_tag['tag_label']." ::".$tmp_selectvalue_tag['coll_id']);?> + <?php functions::xecho($tmp_selectvalue_tag['tag_label']);?> </option> <?php + } } ?> </select> <input type="button" class="button" name="cancel" style="border-radius:8px;font-size:8px;" - onclick = "tag_fusion('<?php echo addslashes($_SESSION['m_admin']['tag']['tag_label']).',' - .$_SESSION['m_admin']['tag']['tag_coll'];?>', + onclick = "tag_fusion('<?php echo $_SESSION['m_admin']['tag']['tag_id'];?>', $('tagfusion').value, <?php functions::xecho($route_tag_fusion_tags);?>,'<?php echo _TAGFUSION_GOODRESULT;?>' , '<?php - echo $_SESSION['config']['businessappurl'] . 'index.php?display=true' - . '&module=tags&page=manage_tag_list_controller&mode=list' + echo $_SESSION['config']['businessappurl'] . 'index.php?page=manage_tag_list_controller&module=tags' ?>');" value="<?php echo _TAGFUSION;?> "> </p> diff --git a/modules/tags/manage_tag_list_controller.php b/modules/tags/manage_tag_list_controller.php index 9b710cf6a71c1e364859cf49396f27e1abd96471..2df76f8324de77dd5afd34be15cf459e5485de60 100755 --- a/modules/tags/manage_tag_list_controller.php +++ b/modules/tags/manage_tag_list_controller.php @@ -71,7 +71,7 @@ $func = new functions(); //Get list of all templates if (isset($_REQUEST['id']) && !empty($_REQUEST['id'])) { $_REQUEST['id'] = htmlspecialchars_decode($_REQUEST['id']); - $tag_label = $func->protect_string_db($_REQUEST['id']); + $tag_id = $func->protect_string_db($_REQUEST['id']); } @@ -86,7 +86,7 @@ if (isset($_REQUEST['tag_submit'])) { switch ($mode) { case 'up' : - display_up($tag_label); + display_up($tag_id); $_SESSION['service_tag'] = 'tag_init'; core_tools::execute_modules_services( @@ -103,7 +103,7 @@ if (isset($_REQUEST['tag_submit'])) { location_bar_management($mode); break; case 'del' : - display_del($tag_label); + display_del($tag_id); break; case 'list' : $tagslist = display_list(); @@ -152,26 +152,24 @@ function location_bar_management($mode) * Initialize session parameters for update display * @param String $statusId */ -function display_up($tag_label) +function display_up($tag_id) { - - $func = new functions(); + $func = new functions(); $tagCtrl = new tag_controler; $state = true; - $tag = $tagCtrl->get_by_label($tag_label); + $tag = $tagCtrl->get_by_id($tag_id); if (empty($tag)) { $state = false; } else { //put_in_session('tag', $tag->getArray()); + $_SESSION['m_admin']['tag']['tag_id'] = $tag->tag_id; $_SESSION['m_admin']['tag']['tag_label'] = $tag->tag_label; - $_SESSION['m_admin']['tag']['tag_coll'] = $tag->coll_id; - $_SESSION['m_admin']['tag']['tag_count'] = (string) $tagCtrl->countdocs( - $func->protect_string_db($tag->tag_label), - $tag->coll_id - ); - + $_SESSION['m_admin']['tag']['tag_coll'] = $tag->coll_id; + $_SESSION['m_admin']['tag']['entities'] = $tag->entities; + $_SESSION['m_admin']['tag']['tag_count'] = (string) $tagCtrl->countdocs( + $tag->tag_id + ); } - //récupération de l'ensemble des tags dans un tableau $all_tags = array(); $all_tags = $tagCtrl->get_all_tags(); @@ -211,7 +209,7 @@ function display_list() { $select[TAGS] = array(); array_push( - $select[TAGS], 'tag_label', 'coll_id' + $select[TAGS], 'tag_id', 'tag_label' ); $where = ''; $where_what = array(); @@ -222,23 +220,18 @@ function display_list() { } if ($_SESSION['config']['databasetype'] == 'POSTGRESQL') { - $where .= " (tag_label ilike ? or tag_label ilike ? ) "; - $where_what[] = $what.'%'; - $where_what[] = $what.'%'; - + $where .= ""; } else { - $where .= " (tag_label like ? or tag_label like ? ) "; - $where_what[] = $what.'%'; - $where_what[] = $what.'%'; + $where .= ""; } // Checking order and order_field values - $order = 'asc'; + $order = 'desc'; if (isset($_REQUEST['order']) && !empty($_REQUEST['order'])) { $order = trim($_REQUEST['order']); } - $field = 'tag_label'; + $field = 'tag_id'; if (isset($_REQUEST['order_field']) && !empty($_REQUEST['order_field'])) { $field = trim($_REQUEST['order_field']); } @@ -247,23 +240,23 @@ function display_list() { $request = new request(); $tab = $request->PDOselect( $select, $where, $where_what, $orderstr, $_SESSION['config']['databasetype'], - "default", false, "", "", "", true, false, true + "default", false, "", "", "", true, false, false ); //$request->show(); for ($i=0;$i<count($tab);$i++) { foreach ($tab[$i] as &$item) { switch ($item['column']) { - case 'tag_label': + case 'tag_id': format_item( - $item, _NAME_TAGS, '18', 'left', 'left', 'bottom', true + $item, _ID, '10', 'left', 'left', 'bottom', true ); break; - case 'coll_id': + + case 'tag_label': format_item( - $item, _DESC, '55', 'left', 'left', 'bottom', true + $item, _NAME_TAGS, '70', 'left', 'left', 'bottom', true ); - break; } } @@ -296,7 +289,7 @@ function display_list() { * Delete given tag if exists and initialize session parameters * @param string $statusId */ -function display_del($tag_label) { +function display_del($tag_id) { if (!$_SESSION['m_admin']['tags']['coll_id']){ $_SESSION['m_admin']['tags']['coll_id'] = 'letterbox_coll'; @@ -305,14 +298,13 @@ function display_del($tag_label) { $coll_id = $_SESSION['m_admin']['tags']['coll_id']; $tagCtrl = new tag_controler(); - $tag = $tagCtrl->get_by_label($tag_label, $coll_id); - if (isset($tag)) { + if (isset($tag_id)) { // Deletion - $control = $tagCtrl->delete($tag_label, $coll_id); + $control = $tagCtrl->delete($tag_id, $coll_id); if (!$control) { $_SESSION['error'] = str_replace("#", "<br />", $control['error']); } else { - $_SESSION['info'] = _TAG_DELETED.' : '. str_replace("''", "'", $tag_label); + $_SESSION['info'] = _TAG_DELETED.' : '. str_replace("''", "'", $_SESSION['m_admin']['tags']['tag_label']).' (ID : '.$tag_id.')'; } ?><script type="text/javascript">window.top.location='<?php echo $_SESSION['config']['businessappurl'] @@ -370,8 +362,8 @@ function validate_tag_submit() { $pageName = 'manage_tag_list_controller'; $func = new functions(); $mode = 'up'; - $mode = $_REQUEST['mode']; - $tagObj = new tag_controler(); + $mode = $_REQUEST['mode']; + $tagObj = new tag_controler(); if ($_REQUEST['collection']) { @@ -390,14 +382,14 @@ function validate_tag_submit() { array_push($params, $new_tag_label); array_push($params, $coll_id); - // var_dump($new_tag_label); + var_dump($new_tag_label); if ($new_tag_label == '' || !$new_tag_label || empty($new_tag_label)) { $_SESSION['error'] = _TAG_LABEL_IS_EMPTY; header( 'location: ' . $_SESSION['config']['businessappurl'] . 'index.php?page=' . $pageName . '&mode='.$mode.'&id=' - . $tag->tag_label . '&module=tags' + . $tag->tag_idl . '&module=tags' ); exit(); } @@ -410,66 +402,60 @@ function validate_tag_submit() { header( 'location: ' . $_SESSION['config']['businessappurl'] . 'index.php?page=' . $pageName . '&mode='.$mode.'&id=' - . $tag->tag_label . '&module=tags' + . $tag->tag_id . '&module=tags' ); exit(); } - - $tag = $tagObj->store($_SESSION['m_admin']['tag']['tag_label'], $mode, $params); - - - $_SESSION['m_admin']['tag']['tag_label'] = $new_tag_label; - $_SESSION['m_admin']['tag']['coll_id'] = $coll_id; - - - + $_SESSION['m_admin']['tag']['tag_label'] = $new_tag_label; + $_SESSION['m_admin']['tag']['coll_id'] = $coll_id; + $_SESSION['m_admin']['tag']['entities'] = $_REQUEST['entitieslist']; + + $tag = $tagObj->store($_SESSION['m_admin']['tag']['tag_id'], $mode, $params); + switch ($mode) { case 'up': - if ($_SESSION['error'] == "") - $_SESSION['info'] = _TAG_UPDATED.' : '.str_replace("''", "'", $new_tag_label); - + if ($_SESSION['error'] == "") + $_SESSION['info'] = _TAG_UPDATED . ' : ' . str_replace("''", "'", $new_tag_label) . ' (ID : ' . $_SESSION['m_admin']['tag']['tag_id'] . ')'; + if (!empty($_SESSION['m_admin']['tag']['dddtag_label'])) { header( - 'location: ' . $_SESSION['config']['businessappurl'] - . 'index.php?page=' . $pageName . '&mode=up&id=' - . $tag->tag_label . '&module=tags' + 'location: ' . $_SESSION['config']['businessappurl'] + . 'index.php?page=' . $pageName . '&mode=up&id=' + . $tag->tag_id . '&module=tags' ); } else { header( - 'location: ' . $_SESSION['config']['businessappurl'] - . 'index.php?page=' . $pageName . '&mode=list&module=' - .'tags&order=' . $status['order'] . '&order_field=' - . $status['order_field'] . '&start=' . $status['start'] - . '&what=' . $status['what'] + 'location: ' . $_SESSION['config']['businessappurl'] + . 'index.php?page=' . $pageName . '&mode=list&module=' + . 'tags&order=' . $status['order'] . '&order_field=' + . $status['order_field'] . '&start=' . $status['start'] + . '&what=' . $status['what'] ); } exit(); case 'add': - //header( - // 'location: ' . $_SESSION['config']['businessappurl'] - // . 'index.php?page=' . $pageName . '&mode=add&module=tags' - //); - $_SESSION['info'] = _TAG_ADDED.' : '. str_replace("''", "'", $new_tag_label); + if (empty($_SESSION['error'])) { + $_SESSION['info'] = _TAG_ADDED . ' : ' . str_replace("''", "'", $new_tag_label); + } header( 'location: ' . $_SESSION['config']['businessappurl'] . 'index.php?page=' . $pageName . '&mode=list&module=' - .'tags&order=' . $status['order'] . '&order_field=' + . 'tags&order=' . $status['order'] . '&order_field=' . $status['order_field'] . '&start=' . $status['start'] . '&what=' . $status['what'] - ); + ); exit(); - - } + } } function init_session() { $_SESSION['m_admin']['tag'] = array( - 'tag_label' => '', - 'coll_id' => '', - 'res_id' => '', - + 'tag_id' => '', + 'tag_label' => '', + 'coll_id' => '', + 'entities' => array() ); } diff --git a/modules/tags/tags_update.php b/modules/tags/tags_update.php index f04e2660ac79edca162d5786c0ef381854c23802..398582769ae7a4ec88432d0666517ec55199e0ec 100644 --- a/modules/tags/tags_update.php +++ b/modules/tags/tags_update.php @@ -65,7 +65,7 @@ include_once 'modules/tags/route.php'; //if (!empty($tags)) //{ $tags = new tag_controler(); - $tagmodule_result = $tags->update_restag($ressource_tagmodule,$collection_tagmodule, $tags_list); + $tagmodule_result = $tags->associateTagToRes($ressource_tagmodule,$collection_tagmodule, $tags_list); unset($_SESSION['tagsuser']); //} diff --git a/modules/tags/templates/addtag_userform.php b/modules/tags/templates/addtag_userform.php index 7bd50b463f69ef0729ed29296f3f3807f5bfbaf9..5c0ac5c70138fe07eb6ff5421af5b00233fcd555 100644 --- a/modules/tags/templates/addtag_userform.php +++ b/modules/tags/templates/addtag_userform.php @@ -56,10 +56,10 @@ if (!is_array($_SESSION['tagsuser'])) { if (!empty($tags_list)) { foreach ($tags_list as $key => $value) { - if (in_array($value['tag_label'], $_SESSION['tagsuser'])) { - $frm_str .= '<option selected="selected" value="'.$value['tag_label'].'">'.$value['tag_label'].'</option>'; + if (in_array($value['tag_id'], $_SESSION['tagsuser'])) { + $frm_str .= '<option selected="selected" value="'.$value['tag_id'].'">'.$value['tag_label'].'</option>'; }else{ - $frm_str .= '<option value="'.$value['tag_label'].'">'.$value['tag_label'].'</option>'; + $frm_str .= '<option value="'.$value['tag_id'].'">'.$value['tag_label'].'</option>'; } } } diff --git a/modules/tags/templates/details/index.php b/modules/tags/templates/details/index.php index 2a31fd9c7a291fa07b64137637a84202291ef5df..5d1e0051baa96f83ca34b8e06132f211b9046bcd 100644 --- a/modules/tags/templates/details/index.php +++ b/modules/tags/templates/details/index.php @@ -70,8 +70,12 @@ if (!$modify_doc){ else{ $rttagfinaldetail = $route_tag_ui_script; } - +$frm_str .= '<input type="hidden" id="new_tag_label" name="new_tag_label"/>'; $frm_str .= '<script type="text/javascript">load_tags('.$rttagfinaldetail.', \''.$s_id.'\', \''.$coll_id.'\');'; +$frm_str .= 'new Chosen($(\'tag_userform\'),{width: "95%", disable_search_threshold: 10, search_contains: true});'; +if ($core_tools->test_service('create_tag', 'tags', false) == 1) { + $frm_str .= '$j( "#tag_userform_chosen input" ).focusout(function() {$j("#new_tag_label").val($j("#tag_userform_chosen input").val());if($j( "#tag_userform_chosen .no-results" ).length){if(confirm("ce mot sera ajouté en tant que mot clé")){add_this_tags('.$route_tag_add_tags_from_res.', '.$route_tag_ui_script.');}}});'; +} $frm_str .= '</script>'; echo $frm_str; diff --git a/modules/tags/templates/index_mlb/index.php b/modules/tags/templates/index_mlb/index.php index 467d924c1d30a037e00baee03f323826d9801625..39941ca770050a9d9f0485c2f2915356397ba633 100644 --- a/modules/tags/templates/index_mlb/index.php +++ b/modules/tags/templates/index_mlb/index.php @@ -62,7 +62,11 @@ $frmStr .='</td></tr><style>#tag_userform_chosen{width:100% !important;}</style> //$frmStr .= '<td><label for="tag" class="tag_title" ></label></td>'; $frmStr .= '<input type="hidden" name="res_id" id="res_id" value="'.$res_id.'" />'; - +$frmStr .= '<input type="hidden" id="new_tag_label" name="new_tag_label"/>'; $frmStr .= '<script type="text/javascript">load_tags('.$route_tag_ui_script.', \''.$res_id.'\', \''.$coll_id.'\');'; +$frmStr .= 'new Chosen($(\'tag_userform\'),{width: "226px", disable_search_threshold: 10,search_contains: true});'; +if ($core_tools->test_service('create_tag', 'tags', false) == 1) { + $frmStr .= '$j( "#tag_userform_chosen input" ).focusout(function() {$j("#new_tag_label").val($j("#tag_userform_chosen input").val());if($j( "#tag_userform_chosen .no-results" ).length){if(confirm("ce mot sera ajouté en tant que mot clé")){add_this_tags('.$route_tag_add_tags_from_res.', '.$route_tag_ui_script.');}}});'; +} $frmStr .= '</script>'; ?> \ No newline at end of file diff --git a/modules/tags/templates/process/index.php b/modules/tags/templates/process/index.php index 4d0472219c114ebc3977c20fcc91b3525ac20e8a..a756aa8852d29b5205fef8f6aa3afd7c4b7232fb 100644 --- a/modules/tags/templates/process/index.php +++ b/modules/tags/templates/process/index.php @@ -56,8 +56,12 @@ include_once 'modules/tags/templates/addtag_userform.php'; //CHARGEMENT DU FORMU $frm_str .='</td></tr><style>#tag_userform_chosen{width:95% !important;}</style>'; $frm_str .= '<input type="hidden" name="res_id" id="res_id" value="'.$res_id.'" />'; - +$frm_str .= '<input type="hidden" id="new_tag_label" name="new_tag_label"/>'; $frm_str .= '<script type="text/javascript">load_tags('.$route_tag_ui_script.', \''.$res_id.'\', \''.$coll_id.'\');'; +$frm_str .= 'new Chosen($(\'tag_userform\'),{width: "95%", disable_search_threshold: 10, search_contains: true});'; +if ($core_tools->test_service('create_tag', 'tags', false) == 1) { + $frm_str .= '$j( "#tag_userform_chosen input" ).focusout(function() {$j("#new_tag_label").val($j("#tag_userform_chosen input").val());if($j( "#tag_userform_chosen .no-results" ).length){if(confirm("ce mot sera ajouté en tant que mot clé")){add_this_tags('.$route_tag_add_tags_from_res.', '.$route_tag_ui_script.');}}});'; +} $frm_str .= '</script>'; ?> diff --git a/modules/tags/templates/validate_mail/index.php b/modules/tags/templates/validate_mail/index.php index 2e8460e63c4fadd692ece9023faf1868c532250d..f88a1221193840aef87b5b807925a19b00db7511 100644 --- a/modules/tags/templates/validate_mail/index.php +++ b/modules/tags/templates/validate_mail/index.php @@ -61,7 +61,12 @@ $frm_str .='<style>#tag_userform_chosen{width:100% !important;}</style>'; //$frm_str .= '<td><label for="tag" class="tag_title" ></label></td>'; +$frm_str .= '<input type="hidden" id="new_tag_label" name="new_tag_label"/>'; $frm_str .= '<script type="text/javascript">load_tags('.$route_tag_ui_script.', \''.$res_id.'\', \''.$coll_id.'\');'; +$frm_str .= 'new Chosen($(\'tag_userform\'),{width: "226px", disable_search_threshold: 10,search_contains: true});'; +if ($core_tools->test_service('create_tag', 'tags', false) == 1) { + $frm_str .= '$j( "#tag_userform_chosen input" ).focusout(function() {$j("#new_tag_label").val($j("#tag_userform_chosen input").val());if($j( "#tag_userform_chosen .no-results" ).length){if(confirm("ce mot sera ajouté en tant que mot clé")){add_this_tags('.$route_tag_add_tags_from_res.', '.$route_tag_ui_script.');}}});'; +} $frm_str .= '</script>'; ?> \ No newline at end of file diff --git a/modules/tags/xml/IVS/validation_rules.xml b/modules/tags/xml/IVS/validation_rules.xml index 0ac416422827cda33f6b78d5149ce4ea963d8c6d..d7e34de5319e0212f6588af1105e097447c89db2 100755 --- a/modules/tags/xml/IVS/validation_rules.xml +++ b/modules/tags/xml/IVS/validation_rules.xml @@ -1,15 +1,17 @@ <validationRules> <validationRule name="tag_manage_add" extends="standardForm" mode="error"> <parameter name="id" type="string" /> + <parameter name="tag_id" type="integer" /> <parameter name="tag_label" type="string" /> <parameter name="tag_submit" type="string" /> <parameter name="tagfusion" type="string" /> <parameter name="collection" type="collection_list" /> + <parameter name="entitieslist" type="string" /> </validationRule> <validationRule name="tag_fusion_tag" extends="standardForm" mode="error"> - <parameter name="a_search_tag" type="string" /> - <parameter name="a_new_tag" type="string" /> + <parameter name="tagIdBeforeFusion" type="integer" /> + <parameter name="newTagId" type="integer" /> </validationRule> <validationRule name="aj_add_this_tags" extends="standardForm" mode="error"> diff --git a/modules/tags/xml/services.xml b/modules/tags/xml/services.xml index 8cf632df98f7eb564dc639b38daede023b78e24e..87d6d9980982857e745187a22547ecb247e22661 100755 --- a/modules/tags/xml/services.xml +++ b/modules/tags/xml/services.xml @@ -71,7 +71,7 @@ <nature>include</nature> </WHEREAMIUSED> </SERVICE> - <SERVICE> + <!--<SERVICE> <id>delete_tag_to_res</id> <name>_DELETE_TAG_TO_RES</name> <comment>_DELETE_TAG_TO_RES_DESC</comment> @@ -90,6 +90,15 @@ <page>details.php</page> <nature>include</nature> </WHEREAMIUSED> + </SERVICE>--> + <SERVICE> + <id>private_tag</id> + <name>_PRIVATE_TAGS</name> + <comment>_PRIVATE_TAGS_DESC</comment> + <servicepage></servicepage> + <servicetype>use</servicetype> + <system_service>false</system_service> + <enabled>true</enabled> </SERVICE> <!--<SERVICE> <id>new_tags_in_library_rights</id> diff --git a/sql/160_to_161.sql b/sql/160_to_161.sql index f715e33e0cdc2de4346d36e911fd63a81450e454..56a618bad5e1424f5ff0bb0b86574efd37bf884a 100644 --- a/sql/160_to_161.sql +++ b/sql/160_to_161.sql @@ -11,4 +11,72 @@ CREATE FUNCTION order_alphanum(text) RETURNS text AS $$ E'(^|\\D)(\\d{4,6}($|\\D))', E'\\1000\\2', 'g'), E'(^|\\D)(\\d{7}($|\\D))', E'\\100\\2', 'g'), E'(^|\\D)(\\d{8}($|\\D))', E'\\10\\2', 'g'); -$$ LANGUAGE SQL; \ No newline at end of file +$$ LANGUAGE SQL; + + + + +/* MIGRATION NOUVEL STRUCT MOTS CLEES*/ +CREATE SEQUENCE tag_id_seq + INCREMENT 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 7 + CACHE 1; + +ALTER TABLE tags ADD tag_id bigint NOT NULL DEFAULT nextval('tag_id_seq'::regclass); + +CREATE SEQUENCE tmp_tag_id_seq + INCREMENT 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 7 + CACHE 1; + +CREATE TABLE tmp_tags +( + tag_id bigint NOT NULL DEFAULT nextval('tmp_tag_id_seq'::regclass), + tag_label character varying(255) NOT NULL +) +WITH ( + OIDS=FALSE +); + +INSERT INTO tmp_tags (tag_label) +SELECT distinct(lower(tag_label)) from tags; + +CREATE TABLE tag_res +( + res_id bigint NOT NULL, + tag_id bigint NOT NULL, + CONSTRAINT tags_entities_pkey PRIMARY KEY (res_id,tag_id) +) +WITH ( + OIDS=FALSE +); + +INSERT INTO tag_res (res_id,tag_id) +SELECT tags.res_id, tmp_tags.tag_id FROM tags, tmp_tags WHERE tmp_tags.tag_label = lower(tags.tag_label); + +TRUNCATE TABLE tags; +ALTER TABLE tags DROP CONSTRAINT IF EXISTS tagsjoin_pkey; +ALTER TABLE tags DROP COLUMN IF EXISTS res_id; + +INSERT INTO tags (tag_label, coll_id, tag_id) +SELECT tag_label, 'letterbox_coll', tag_id FROM tmp_tags; + + +DROP TABLE tmp_tags; +DROP SEQUENCE IF EXISTS tmp_tag_id_seq; + +CREATE TABLE tags_entities +( + tag_id bigint, + entity_id character varying(32), + CONSTRAINT tags_entities_pkey PRIMARY KEY (tag_id,entity_id) +) +WITH ( + OIDS=FALSE +); + + diff --git a/sql/structure.sql b/sql/structure.sql index dcaa2061e3f3715d3d22518193b0f4da5f935184..e2c70dd69125b0dda2810bb95998620bceb28e01 100644 --- a/sql/structure.sql +++ b/sql/structure.sql @@ -1753,15 +1753,42 @@ WITH ( OIDS=FALSE ); +CREATE SEQUENCE tag_id_seq + INCREMENT 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 7 + CACHE 1; + CREATE TABLE tags ( + tag_id bigint NOT NULL DEFAULT nextval('tag_id_seq'::regclass), tag_label character varying(50) NOT NULL, coll_id character varying(50) NOT NULL, - res_id bigint NOT NULL, - CONSTRAINT tagsjoin_pkey PRIMARY KEY (tag_label, coll_id, res_id ) + CONSTRAINT tag_id_pkey PRIMARY KEY (tag_id) ) WITH (OIDS=FALSE); +CREATE TABLE tag_res +( + res_id bigint NOT NULL, + tag_id bigint NOT NULL, + CONSTRAINT tags_entities_pkey PRIMARY KEY (res_id,tag_id) +) +WITH ( + OIDS=FALSE +); + +CREATE TABLE tags_entities +( + tag_id bigint, + entity_id character varying(32), + CONSTRAINT tags_entities_pkey PRIMARY KEY (tag_id,entity_id) +) +WITH ( + OIDS=FALSE +); + CREATE SEQUENCE res_id_seq INCREMENT 1 MINVALUE 1