Changeset 6687
- Timestamp:
- 10/02/08 11:17:43 (2 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/centreon/www/include/common/common-Func-ACL.php
r6646 r6687 247 247 * 248 248 * @param{TAB}int{TAB}$argument1{TAB}Mon premier argument 249 * @param{TAB}string{TAB}$argument2{TAB}Mon deuxi ème argument249 * @param{TAB}string{TAB}$argument2{TAB}Mon deuxiᅵme argument 250 250 * @return{TAB}int{TAB}Ma valeur de retour 251 251 */ … … 330 330 * 331 331 * @param{TAB}int{TAB}$argument1{TAB}Mon premier argument 332 * @param{TAB}string{TAB}$argument2{TAB}Mon deuxi ème argument332 * @param{TAB}string{TAB}$argument2{TAB}Mon deuxiᅵme argument 333 333 * @return{TAB}int{TAB}Ma valeur de retour 334 334 */ … … 369 369 * 370 370 * @param{TAB}int{TAB}$argument1{TAB}Mon premier argument 371 * @param{TAB}string{TAB}$argument2{TAB}Mon deuxi ème argument371 * @param{TAB}string{TAB}$argument2{TAB}Mon deuxiᅵme argument 372 372 * @return{TAB}int{TAB}Ma valeur de retour 373 373 */ … … 407 407 * 408 408 * @param{TAB}int{TAB}$argument1{TAB}Mon premier argument 409 * @param{TAB}string{TAB}$argument2{TAB}Mon deuxi ème argument409 * @param{TAB}string{TAB}$argument2{TAB}Mon deuxiᅵme argument 410 410 * @return{TAB}int{TAB}Ma valeur de retour 411 411 */ … … 431 431 * 432 432 * @param{TAB}int{TAB}$argument1{TAB}Mon premier argument 433 * @param{TAB}string{TAB}$argument2{TAB}Mon deuxi ème argument433 * @param{TAB}string{TAB}$argument2{TAB}Mon deuxiᅵme argument 434 434 * @return{TAB}int{TAB}Ma valeur de retour 435 435 */ … … 478 478 * 479 479 * @param{TAB}int{TAB}$argument1{TAB}Mon premier argument 480 * @param{TAB}string{TAB}$argument2{TAB}Mon deuxi ème argument480 * @param{TAB}string{TAB}$argument2{TAB}Mon deuxiᅵme argument 481 481 * @return{TAB}int{TAB}Ma valeur de retour 482 482 */ … … 528 528 * 529 529 * @param{TAB}int{TAB}$argument1{TAB}Mon premier argument 530 * @param{TAB}string{TAB}$argument2{TAB}Mon deuxi ème argument530 * @param{TAB}string{TAB}$argument2{TAB}Mon deuxiᅵme argument 531 531 * @return{TAB}int{TAB}Ma valeur de retour 532 532 */ … … 581 581 * 582 582 * @param{TAB}int{TAB}$argument1{TAB}Mon premier argument 583 * @param{TAB}string{TAB}$argument2{TAB}Mon deuxi ème argument583 * @param{TAB}string{TAB}$argument2{TAB}Mon deuxiᅵme argument 584 584 * @return{TAB}int{TAB}Ma valeur de retour 585 585 */ … … 616 616 * 617 617 * @param{TAB}int{TAB}$argument1{TAB}Mon premier argument 618 * @param{TAB}string{TAB}$argument2{TAB}Mon deuxi ème argument618 * @param{TAB}string{TAB}$argument2{TAB}Mon deuxiᅵme argument 619 619 * @return{TAB}int{TAB}Ma valeur de retour 620 620 */ … … 640 640 * 641 641 * @param{TAB}int{TAB}$argument1{TAB}Mon premier argument 642 * @param{TAB}string{TAB}$argument2{TAB}Mon deuxi ème argument642 * @param{TAB}string{TAB}$argument2{TAB}Mon deuxiᅵme argument 643 643 * @return{TAB}int{TAB}Ma valeur de retour 644 644 */ … … 664 664 * 665 665 * @param{TAB}int{TAB}$argument1{TAB}Mon premier argument 666 * @param{TAB}string{TAB}$argument2{TAB}Mon deuxi ème argument666 * @param{TAB}string{TAB}$argument2{TAB}Mon deuxiᅵme argument 667 667 * @return{TAB}int{TAB}Ma valeur de retour 668 668 */ … … 688 688 * 689 689 * @param{TAB}int{TAB}$argument1{TAB}Mon premier argument 690 * @param{TAB}string{TAB}$argument2{TAB}Mon deuxi ème argument690 * @param{TAB}string{TAB}$argument2{TAB}Mon deuxiᅵme argument 691 691 * @return{TAB}int{TAB}Ma valeur de retour 692 692 */ … … 712 712 * 713 713 * @param{TAB}int{TAB}$argument1{TAB}Mon premier argument 714 * @param{TAB}string{TAB}$argument2{TAB}Mon deuxi ème argument714 * @param{TAB}string{TAB}$argument2{TAB}Mon deuxiᅵme argument 715 715 * @return{TAB}int{TAB}Ma valeur de retour 716 716 */ … … 743 743 * 744 744 * @param{TAB}int{TAB}$argument1{TAB}Mon premier argument 745 * @param{TAB}string{TAB}$argument2{TAB}Mon deuxi ème argument745 * @param{TAB}string{TAB}$argument2{TAB}Mon deuxiᅵme argument 746 746 * @return{TAB}int{TAB}Ma valeur de retour 747 747 */ … … 767 767 * 768 768 * @param{TAB}int{TAB}$argument1{TAB}Mon premier argument 769 * @param{TAB}string{TAB}$argument2{TAB}Mon deuxi ème argument769 * @param{TAB}string{TAB}$argument2{TAB}Mon deuxiᅵme argument 770 770 * @return{TAB}int{TAB}Ma valeur de retour 771 771 */ … … 791 791 return array(); 792 792 } 793 794 /* 795 * function getActionsACLList 796 * This function is designed to return a list of actions allowed for an user 797 * 798 * <code> 799 * $authorized_actions = array(); 800 * $authorized_actions = getActionsACLList($GroupListofUser); 801 * </code> 802 * 803 * Input is a list of ACL groups of user 804 * @param array ( [0] => Group1 [1] => Groupx ) 805 * 806 * Output is a list of actions allowed for a user like: 807 * @return array ( [0] => service_notifications [1] => service_schedule_check [2] => service_schedule_downtime [3] => ... ) 808 */ 809 function getActionsACLList($GroupListofUser){ 810 global $pearDB; 811 812 $i = 0; 813 $idsRequest = ""; 814 # Formating a variable in order to include on the request 815 foreach($GroupListofUser as $id) { 816 $idsRequest .= "`acl_group_id` = ".$id.""; 817 if($i < count($GroupListofUser)-1) { 818 $idsRequest .= " OR "; 819 } 820 $i++; 821 } 822 823 if($idsRequest != "") 824 { 825 # Request in order to list the 'acl_action_id' linked with groups of user 826 $request = "SELECT acl_action_id FROM `acl_group_actions_relations` WHERE ".$idsRequest; 827 $DBRESULT =& $pearDB->query($request); 828 if (PEAR::isError($DBRESULT)) print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 829 830 $idsActions = array(); 831 while ($rule =& $DBRESULT->fetchRow()){ 832 $idsActions[] = $rule["acl_action_id"]; 833 } 834 835 $i = 0; 836 $idsRequest = ""; 837 # Formating a variable in order to include on the request 838 foreach($idsActions as $id) { 839 $idsRequest .= "`acl_action_id` = ".$id.""; 840 if($i <= count($GroupListofUser)) { 841 $idsRequest .= " OR "; 842 } 843 $i++; 844 } 845 unset($idsActions); 846 847 # Request in order to list Actions Access enabled 848 $request = "SELECT acl_action_id FROM `acl_actions` WHERE acl_action_activate = '1' AND ($idsRequest)"; 849 $DBRESULT =& $pearDB->query($request); 850 if (PEAR::isError($DBRESULT)) print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 851 $idsActions = array(); 852 while ($rule =& $DBRESULT->fetchRow()){ 853 $idsActions[] = $rule["acl_action_id"]; 854 } 855 856 $i = 0; 857 $idsRequest = ""; 858 # Formating a variable in order to include on the request 859 foreach($idsActions as $id) { 860 $idsRequest .= "`acl_action_rule_id` = ".$id.""; 861 if($i < count($idsActions)-1) { 862 $idsRequest .= " OR "; 863 } 864 $i++; 865 } 866 867 if(isset($idsRequest) && $idsRequest != "") { 868 # Request in order to list the 'acl_action_name' linked with rules of user 869 $request = "SELECT acl_action_name FROM `acl_actions_rules` WHERE $idsRequest"; 870 $DBRESULT =& $pearDB->query($request); 871 if (PEAR::isError($DBRESULT)) print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 872 873 $authorized_actions = array(); 874 while ($actions =& $DBRESULT->fetchRow()){ 875 $authorized_actions[] = $actions["acl_action_name"]; 876 } 877 return $authorized_actions; 878 } 879 } 880 return NULL; 881 } 882 883 /* 884 * function verifyActionsACLofUser 885 * This function is designed to verify if user is allowed to perform an action 886 * 887 * <code> 888 * // Un exemple with the action "host_comment" 889 * $authorized_actions = false; 890 * $authorized_actions = getActionsACLList("host_comment"); 891 * print $authorized_actions; // (print true or false if user is allowed or not) 892 * </code> 893 * 894 * Input is the name of the action, names are in the "DB-Func.php" of the "Actions Access" configuration interface (function listActions()). 895 * @param string "service_checks" 896 * 897 * Output is true or false 898 * @return string true/false 899 */ 900 function verifyActionsACLofUser($action_name){ 901 global $pearDB; 902 $GroupListofUser = array(); 903 $authorized_actions = array(); 904 $authorisation = false; 905 906 $GroupListofUser = getGroupListofUser($pearDB); 907 $authorized_actions = getActionsACLList($GroupListofUser); 908 if(count($authorized_actions) == 0) $actions = true; 909 910 if(isset($authorized_actions)) { 911 foreach($authorized_actions as $list) { 912 if($list == $action_name) $authorisation = true; 913 } 914 } 915 916 return $authorisation; 917 } 793 918 ?>
