- Timestamp:
- 06/30/11 19:00:36 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/expressoMail1_2/MailArchiver/2.2/reports/inc/class.functions.inc.php
r4033 r4644 24 24 'array_invert' => True, 25 25 'Paginate_user' => True, 26 'Paginate_cota' => True, 27 'Paginate_shareAccount' => True, 28 'Paginate_institutionalAccount' => True, 26 29 'Paginate_user_logon' => True, 27 30 'get_list_all' => True, … … 854 857 } 855 858 859 function get_list_cota_sector($query, $contexts,$sizelimit) 860 { 861 $dn = $GLOBALS['phpgw_info']['server']['ldap_root_dn']; 862 $passwd = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; 863 $ldap_conn = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); 864 ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3); 865 ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0); 866 ldap_bind($ldap_conn,$dn,$passwd); 867 868 $filter="(|(phpgwAccountType=u)(|(phpgwAccountType=s)))"; 869 $justthese = array("uidnumber", "uid", "cn", "mail","accountstatus","dn","createtimestamp","telephoneNumber"); 870 871 $tmp = array(); 872 873 foreach ($contexts as $index=>$context) 874 { 875 876 $search = ldap_search($ldap_conn, $query, $filter, $justthese, 0, $sizelimit); 877 $info = ldap_get_entries($ldap_conn, $search); 878 879 for ($i=0; $i < $info['count']; $i++) 880 { 881 $tmp[$info[$i]['uid'][0]]['account_id'] = $info[$i]['uidnumber'][0]; 882 $tmp[$info[$i]['uid'][0]]['account_lid'] = $info[$i]['uid'][0]; 883 $tmp[$info[$i]['uid'][0]]['account_cn'] = $info[$i]['cn'][0]; 884 $tmp[$info[$i]['uid'][0]]['account_mail']= $info[$i]['mail'][0]; 885 $tmp[$info[$i]['uid'][0]]['account_phone']= $info[$i]['telephonenumber'][0]; 886 $tmp[$info[$i]['uid'][0]]['account_accountstatus']= $info[$i]['accountstatus'][0]; 887 $tmp[$info[$i]['uid'][0]]['createtimestamp']= $info[$i]['createtimestamp'][0]; 888 $sort[] = $info[$i]['uid'][0]; 889 } 890 } 891 892 ldap_close($ldap_conn); 893 894 if (count($sort)) 895 { 896 natcasesort($sort); 897 foreach ($sort as $user_uid) 898 $return[$user_uid] = $tmp[$user_uid]; 899 } 900 901 return $return; 902 903 } 904 905 906 function get_list_shareAccounts_sector($query, $contexts,$sizelimit) 907 { 908 $dn = $GLOBALS['phpgw_info']['server']['ldap_root_dn']; 909 $passwd = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; 910 $ldap_conn = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); 911 ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3); 912 ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0); 913 ldap_bind($ldap_conn,$dn,$passwd); 914 915 $filter="(phpgwAccountType=s)"; 916 $justthese = array("uid", "cn", "mail","accountstatus"); 917 918 $tmp = array(); 919 920 foreach ($contexts as $index=>$context) 921 { 922 923 $search = ldap_search($ldap_conn, $query, $filter, $justthese, 0, $sizelimit); 924 $info = ldap_get_entries($ldap_conn, $search); 925 926 for ($i=0; $i < $info['count']; $i++) 927 { 928 $tmp[$info[$i]['uid'][0]]['account_lid'] = $info[$i]['uid'][0]; 929 $tmp[$info[$i]['uid'][0]]['account_cn'] = $info[$i]['cn'][0]; 930 $tmp[$info[$i]['uid'][0]]['account_mail']= $info[$i]['mail'][0]; 931 $tmp[$info[$i]['uid'][0]]['account_accountstatus']= $info[$i]['accountstatus'][0]; 932 $sort[] = $info[$i]['uid'][0]; 933 } 934 } 935 936 ldap_close($ldap_conn); 937 938 if (count($sort)) 939 { 940 natcasesort($sort); 941 foreach ($sort as $user_uid) 942 $return[$user_uid] = $tmp[$user_uid]; 943 } 944 945 return $return; 946 } 947 948 function get_list_institutionalAccounts_sector($query, $contexts,$sizelimit) 949 { 950 $dn = $GLOBALS['phpgw_info']['server']['ldap_root_dn']; 951 $passwd = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; 952 $ldap_conn = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); 953 ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3); 954 ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0); 955 ldap_bind($ldap_conn,$dn,$passwd); 956 957 $filter="(phpgwAccountType=i)"; 958 $justthese = array("uid", "cn", "mail","accountstatus","mailForwardingAddress"); 959 960 $tmp = array(); 961 962 foreach ($contexts as $index=>$context) 963 { 964 965 $search = ldap_search($ldap_conn, $query, $filter, $justthese, 0, $sizelimit); 966 $info = ldap_get_entries($ldap_conn, $search); 967 968 for ($i=0; $i < $info['count']; $i++) 969 { 970 $tmp[$info[$i]['uid'][0]]['account_cn'] = $info[$i]['cn'][0]; 971 $tmp[$info[$i]['uid'][0]]['account_mail']= $info[$i]['mail'][0]; 972 $tmp[$info[$i]['uid'][0]]['account_accountstatus']= $info[$i]['accountstatus'][0]; 973 $tmp[$info[$i]['uid'][0]]['account_mailforwardingaddress']= $info[$i]['mailforwardingaddress']; 974 $sort[] = $info[$i]['uid'][0]; 975 } 976 } 977 978 ldap_close($ldap_conn); 979 980 if (count($sort)) 981 { 982 natcasesort($sort); 983 foreach ($sort as $user_uid) 984 $return[$user_uid] = $tmp[$user_uid]; 985 } 986 987 return $return; 988 } 989 856 990 function get_count_user_sector($query, $contexts,$sizelimit) 857 991 { … … 871 1005 $entries = ldap_get_entries($ldap_conn, $search); 872 1006 $contexts = array(); 873 for ($i=0; $i< $entries['count']; $i++){874 $contexts[] = $entries[$i]['dn'];875 1007 } 876 1008 } 1009 1010 $filter="(phpgwAccountType=u)"; 1011 $justthese = array("dn"); 1012 $search = ldap_search($ldap_conn, $context, $filter, $justthese, 0, $sizelimit); 1013 $entries = ldap_get_entries($ldap_conn, $search); 1014 $total_count = $entries["count"]; 1015 1016 ldap_close($ldap_conn); 1017 1018 return $total_count; 877 1019 } 878 $filter="(&(phpgwAccountType=u)(|(uid=*)))"; 879 $justthese = array("uidnumber"); 880 $total_count = 0; 881 1020 1021 function get_count_cota_sector($query, $contexts,$sizelimit) 1022 { 1023 $dn = $GLOBALS['phpgw_info']['server']['ldap_root_dn']; 1024 $passwd = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; 1025 $ldap_conn = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); 1026 ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3); 1027 ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0); 1028 ldap_bind($ldap_conn,$dn,$passwd); 1029 // counting users by sector. 882 1030 foreach ($contexts as $index=>$context) { 1031 if($context == $GLOBALS['phpgw_info']['server'] ["ldap_context"]) { 1032 $contexts[$index] = null; 1033 $justthese = array("dn"); 1034 $filter="(objectClass=OrganizationalUnit)"; 1035 $search = ldap_list($ldap_conn, $context, $filter, $justthese); 1036 $entries = ldap_get_entries($ldap_conn, $search); 1037 $contexts = array(); 1038 } 1039 } 1040 1041 $filter="(|(phpgwAccountType=u)(|(phpgwAccountType=s)))"; 1042 $justthese = array("dn"); 883 1043 $search = ldap_search($ldap_conn, $context, $filter, $justthese, 0, $sizelimit); 884 $total_count += ldap_count_entries($ldap_conn, $search); 885 } 1044 $entries = ldap_get_entries($ldap_conn, $search); 1045 $total_count = $entries["count"]; 1046 1047 ldap_close($ldap_conn); 1048 1049 return $total_count; 1050 } 1051 1052 function get_count_shareAccount_sector($query, $contexts,$sizelimit) 1053 { 1054 $dn = $GLOBALS['phpgw_info']['server']['ldap_root_dn']; 1055 $passwd = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; 1056 $ldap_conn = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); 1057 ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3); 1058 ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0); 1059 ldap_bind($ldap_conn,$dn,$passwd); 1060 // counting users by sector. 1061 foreach ($contexts as $index=>$context) { 1062 if($context == $GLOBALS['phpgw_info']['server'] ["ldap_context"]) { 1063 $contexts[$index] = null; 1064 $justthese = array("dn"); 1065 $filter="(objectClass=OrganizationalUnit)"; 1066 $search = ldap_list($ldap_conn, $context, $filter, $justthese); 1067 $entries = ldap_get_entries($ldap_conn, $search); 1068 $contexts = array(); 1069 } 1070 } 1071 1072 $filter="(phpgwAccountType=s)"; 1073 $justthese = array("dn"); 1074 $search = ldap_search($ldap_conn, $context, $filter, $justthese, 0, $sizelimit); 1075 $entries = ldap_get_entries($ldap_conn, $search); 1076 $total_count = $entries["count"]; 1077 1078 ldap_close($ldap_conn); 1079 1080 return $total_count; 1081 } 1082 1083 function get_count_institutionalAccount_sector($query, $contexts,$sizelimit) 1084 { 1085 $dn = $GLOBALS['phpgw_info']['server']['ldap_root_dn']; 1086 $passwd = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; 1087 $ldap_conn = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); 1088 ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3); 1089 ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0); 1090 ldap_bind($ldap_conn,$dn,$passwd); 1091 // counting users by sector. 1092 foreach ($contexts as $index=>$context) { 1093 if($context == $GLOBALS['phpgw_info']['server'] ["ldap_context"]) { 1094 $contexts[$index] = null; 1095 $justthese = array("dn"); 1096 $filter="(objectClass=OrganizationalUnit)"; 1097 $search = ldap_list($ldap_conn, $context, $filter, $justthese); 1098 $entries = ldap_get_entries($ldap_conn, $search); 1099 $contexts = array(); 1100 } 1101 } 1102 1103 $filter="(phpgwAccountType=i)"; 1104 $justthese = array("dn"); 1105 $search = ldap_search($ldap_conn, $context, $filter, $justthese, 0, $sizelimit); 1106 $entries = ldap_get_entries($ldap_conn, $search); 1107 $total_count = $entries["count"]; 1108 886 1109 ldap_close($ldap_conn); 1110 887 1111 return $total_count; 888 1112 } … … 897 1121 ldap_bind($ldap_conn,$dn,$passwd); 898 1122 899 $filter="( &(phpgwAccountType=u)(|(uid=*)))";1123 $filter="(phpgwAccountType=u)"; 900 1124 $justthese = array("uidnumber", "uid", "cn", "mail","accountstatus","dn","createtimestamp"); 901 1125 … … 1254 1478 ldap_bind($ldap_conn,$dn,$passwd); 1255 1479 1256 $filter="(&(phpgwAccountType=u) (|(uid=*)))";1480 $filter="(&(phpgwAccountType=u))"; 1257 1481 $justthese = array("uidnumber", "uid", "cn", "mail","accountstatus","dn","createtimestamp","telephoneNumber"); 1258 1482 … … 1318 1542 return $sOrder === "desc" ? array_reverse( $aList ) : $aList; 1319 1543 } 1544 1545 function Paginate_cota($type, $query, $contexts, $Field, $Order = 'asc', $Page = null, $PerPage = null ) 1546 { 1547 $dn = $GLOBALS['phpgw_info']['server']['ldap_root_dn']; 1548 $passwd = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; 1549 $ldap_conn = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); 1550 ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3); 1551 ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0); 1552 ldap_bind($ldap_conn,$dn,$passwd); 1553 1554 $filter="(|(phpgwAccountType=u)(|(phpgwAccountType=s)))"; 1555 $justthese = array("uidnumber", "uid", "cn", "mail","accountstatus","dn","createtimestamp","telephoneNumber"); 1556 1557 foreach ($contexts as $index=>$context) 1558 { 1559 $search=ldap_search($ldap_conn, $query, $filter, $justthese); 1560 1561 $rConnection = $ldap_conn; 1562 $rSearch = $search; 1563 $sOrder = $Order; 1564 $iPage = $Page; 1565 $iPerPage = $PerPage; 1566 $sField = $Field; 1567 1568 $iTotalEntries = ldap_count_entries( $rConnection, $rSearch ); 1569 1570 if ( $iPage === null || $iPerPage === null ) 1571 { 1572 # fetch all in one page 1573 $iStart = 0; 1574 $iEnd = $iTotalEntries - 1; 1575 } 1576 else 1577 { 1578 # calculate range of page 1579 $iFimPage = ( ceil( $iTotalEntries / $iPerPage ) - 1 ) * $iPage; 1580 1581 $iStart = ( ceil( ($iPage -1) * $iPerPage )); 1582 $iEnd = $iPage * $iPerPage; 1583 1584 1585 if ( $sOrder === "desc" ) 1586 { 1587 # revert range 1588 $iStart = $iTotalEntries - 1 - $iEnd; 1589 $iEnd = $iStart + $iPerPage - 1; 1590 } 1591 } 1592 1593 /********* Importante Mostra o resultado da paginação ********** 1594 var_dump( $iStart . " " . $iEnd ); 1595 ****************** Só descomentar ******************************/ 1596 1597 # fetch entries 1598 ldap_sort( $rConnection, $rSearch, $sField ); 1599 1600 $aList = array(); 1601 for ( 1602 $iCurrent = 0, $rEntry = ldap_first_entry( $rConnection, $rSearch ); 1603 $iCurrent <= $iEnd && is_resource( $rEntry ); 1604 $iCurrent++, $rEntry = ldap_next_entry( $rConnection, $rEntry ) 1605 ) 1606 { 1607 if ( $iCurrent >= $iStart ) 1608 { 1609 array_push( $aList, ldap_get_attributes( $rConnection, $rEntry )); 1610 } 1611 } 1612 } 1613 1614 ldap_close($ldap_conn); 1615 1616 # if order is desc revert page's entries 1617 return $sOrder === "desc" ? array_reverse( $aList ) : $aList; 1618 } 1619 1620 function Paginate_shareAccount($type, $query, $contexts, $Field, $Order = 'asc', $Page = null, $PerPage = null ) 1621 1622 { 1623 $dn = $GLOBALS['phpgw_info']['server']['ldap_root_dn']; 1624 $passwd = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; 1625 $ldap_conn = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); 1626 ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3); 1627 ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0); 1628 ldap_bind($ldap_conn,$dn,$passwd); 1629 1630 $filter="(phpgwAccountType=s)"; 1631 $justthese = array("uid", "cn", "mail","accountstatus"); 1632 1633 foreach ($contexts as $index=>$context) 1634 { 1635 $search=ldap_search($ldap_conn, $query, $filter, $justthese); 1636 1637 $rConnection = $ldap_conn; 1638 $rSearch = $search; 1639 $sOrder = $Order; 1640 $iPage = $Page; 1641 $iPerPage = $PerPage; 1642 $sField = $Field; 1643 1644 $iTotalEntries = ldap_count_entries( $rConnection, $rSearch ); 1645 1646 if ( $iPage === null || $iPerPage === null ) 1647 { 1648 # fetch all in one page 1649 $iStart = 0; 1650 $iEnd = $iTotalEntries - 1; 1651 } 1652 else 1653 { 1654 # calculate range of page 1655 $iFimPage = ( ceil( $iTotalEntries / $iPerPage ) - 1 ) * $iPage; 1656 1657 $iStart = ( ceil( ($iPage -1) * $iPerPage )); 1658 $iEnd = $iPage * $iPerPage; 1659 1660 if ( $sOrder === "desc" ) 1661 { 1662 # revert range 1663 $iStart = $iTotalEntries - 1 - $iEnd; 1664 $iEnd = $iStart + $iPerPage - 1; 1665 } 1666 } 1667 1668 # fetch entries 1669 ldap_sort( $rConnection, $rSearch, $sField ); 1670 1671 $aList = array(); 1672 for ( 1673 $iCurrent = 0, $rEntry = ldap_first_entry( $rConnection, $rSearch ); 1674 $iCurrent <= $iEnd && is_resource( $rEntry ); 1675 $iCurrent++, $rEntry = ldap_next_entry( $rConnection, $rEntry ) 1676 ) 1677 { 1678 if ( $iCurrent >= $iStart ) 1679 { 1680 array_push( $aList, ldap_get_attributes( $rConnection, $rEntry )); 1681 } 1682 } 1683 } 1684 1685 ldap_close($ldap_conn); 1686 1687 # if order is desc revert page's entries 1688 return $sOrder === "desc" ? array_reverse( $aList ) : $aList; 1689 } 1690 1691 function Paginate_institutionalAccount($type, $query, $contexts, $Field, $Order = 'asc', $Page = null, $PerPage = null ) 1692 { 1693 $dn = $GLOBALS['phpgw_info']['server']['ldap_root_dn']; 1694 $passwd = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; 1695 $ldap_conn = ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']); 1696 ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, 3); 1697 ldap_set_option($ldap_conn, LDAP_OPT_REFERRALS, 0); 1698 ldap_bind($ldap_conn,$dn,$passwd); 1699 1700 $filter="(phpgwAccountType=i)"; 1701 $justthese = array("uid", "cn", "mail","accountstatus","mailforwardingaddress"); 1702 1703 foreach ($contexts as $index=>$context) 1704 { 1705 $search=ldap_search($ldap_conn, $query, $filter, $justthese); 1706 1707 $rConnection = $ldap_conn; 1708 $rSearch = $search; 1709 $sOrder = $Order; 1710 $iPage = $Page; 1711 $iPerPage = $PerPage; 1712 $sField = $Field; 1713 1714 $iTotalEntries = ldap_count_entries( $rConnection, $rSearch ); 1715 1716 if ( $iPage === null || $iPerPage === null ) 1717 { 1718 # fetch all in one page 1719 $iStart = 0; 1720 $iEnd = $iTotalEntries - 1; 1721 } 1722 else 1723 { 1724 # calculate range of page 1725 $iFimPage = ( ceil( $iTotalEntries / $iPerPage ) - 1 ) * $iPage; 1726 1727 $iStart = ( ceil( ($iPage -1) * $iPerPage )); 1728 $iEnd = $iPage * $iPerPage; 1729 1730 if ( $sOrder === "desc" ) 1731 { 1732 # revert range 1733 $iStart = $iTotalEntries - 1 - $iEnd; 1734 $iEnd = $iStart + $iPerPage - 1; 1735 } 1736 } 1737 1738 # fetch entries 1739 ldap_sort( $rConnection, $rSearch, $sField ); 1740 1741 $aList = array(); 1742 for ( 1743 $iCurrent = 0, $rEntry = ldap_first_entry( $rConnection, $rSearch ); 1744 $iCurrent <= $iEnd && is_resource( $rEntry ); 1745 $iCurrent++, $rEntry = ldap_next_entry( $rConnection, $rEntry ) 1746 ) 1747 { 1748 if ( $iCurrent >= $iStart ) 1749 { 1750 array_push( $aList, ldap_get_attributes( $rConnection, $rEntry )); 1751 } 1752 } 1753 } 1754 1755 ldap_close($ldap_conn); 1756 1757 # if order is desc revert page's entries 1758 return $sOrder === "desc" ? array_reverse( $aList ) : $aList; 1759 } 1760 1320 1761 1321 1762 function get_list_ou_user_logon($query,$contexts,$sizelimit)
Note: See TracChangeset
for help on using the changeset viewer.