2012-06-04 16:58:40 +02:00
< ? php
/*
FusionPBX
Version : MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 ( the " License " ); you may not use this file except in compliance with
the License . You may obtain a copy of the License at
http :// www . mozilla . org / MPL /
Software distributed under the License is distributed on an " AS IS " basis ,
WITHOUT WARRANTY OF ANY KIND , either express or implied . See the License
for the specific language governing rights and limitations under the
License .
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane < markjcrane @ fusionpbx . com >
2024-09-06 01:10:04 +02:00
Portions created by the Initial Developer are Copyright ( C ) 2008 - 2024
2012-06-04 16:58:40 +02:00
the Initial Developer . All Rights Reserved .
Contributor ( s ) :
Mark J Crane < markjcrane @ fusionpbx . com >
*/
2016-08-05 04:00:23 +02:00
2022-10-11 00:35:14 +02:00
//includes files
2023-06-15 19:28:23 +02:00
require_once dirname ( __DIR__ , 2 ) . " /resources/require.php " ;
2016-08-05 04:00:23 +02:00
require_once " resources/check_auth.php " ;
require_once " resources/paging.php " ;
//check permissions
if ( permission_exists ( 'contact_view' )) {
//access granted
}
else {
echo " access denied " ;
exit ;
}
2013-05-10 02:40:24 +02:00
//add multi-lingual support
2015-01-18 11:06:08 +01:00
$language = new text ;
$text = $language -> get ();
2013-05-10 02:40:24 +02:00
2023-05-31 17:11:50 +02:00
//set additional variables
$show = $_GET [ " show " ] ? ? '' ;
//set from session variables
$list_row_edit_button = ! empty ( $_SESSION [ 'theme' ][ 'list_row_edit_button' ][ 'boolean' ]) ? $_SESSION [ 'theme' ][ 'list_row_edit_button' ][ 'boolean' ] : 'false' ;
2019-11-05 15:37:39 +01:00
//get posted data
2023-05-31 17:11:50 +02:00
if ( ! empty ( $_POST [ 'contacts' ])) {
2019-11-05 15:37:39 +01:00
$action = $_POST [ 'action' ];
$search = $_POST [ 'search' ];
$contacts = $_POST [ 'contacts' ];
}
2012-06-04 16:58:40 +02:00
2019-11-30 22:18:00 +01:00
//process the http post data by action
2023-05-31 17:11:50 +02:00
if ( ! empty ( $action ) && ! empty ( $contacts )) {
2019-11-30 19:12:41 +01:00
switch ( $action ) {
case 'delete' :
if ( permission_exists ( 'contact_delete' )) {
2019-11-30 22:18:00 +01:00
$obj = new contacts ;
2019-11-30 19:12:41 +01:00
$obj -> delete ( $contacts );
}
break ;
2019-11-05 15:37:39 +01:00
}
2019-11-30 19:12:41 +01:00
2023-05-31 17:11:50 +02:00
header ( 'Location: contacts.php' . ( ! empty ( $search ) ? '?search=' . urlencode ( $search ) : null ));
2019-11-30 19:12:41 +01:00
exit ;
2019-11-05 15:37:39 +01:00
}
2012-06-04 16:58:40 +02:00
2015-02-25 23:46:58 +01:00
//retrieve current user's assigned groups (uuids)
2014-10-18 08:49:34 +02:00
foreach ( $_SESSION [ 'groups' ] as $group_data ) {
$user_group_uuids [] = $group_data [ 'group_uuid' ];
}
2015-10-20 09:39:54 +02:00
//add user's uuid to group uuid list to include private (non-shared) contacts
2014-10-18 09:14:41 +02:00
$user_group_uuids [] = $_SESSION [ " user_uuid " ];
2012-06-04 16:58:40 +02:00
2018-01-10 21:37:26 +01:00
//get contact settings - sync sources
2022-04-12 00:28:48 +02:00
$sql = " select contact_uuid, contact_setting_value " ;
$sql .= " from v_contact_settings " ;
$sql .= " where domain_uuid = :domain_uuid " ;
2015-02-25 23:46:58 +01:00
$sql .= " and contact_setting_category = 'sync' " ;
$sql .= " and contact_setting_subcategory = 'source' " ;
$sql .= " and contact_setting_name = 'array' " ;
$sql .= " and contact_setting_value <> '' " ;
$sql .= " and contact_setting_value is not null " ;
2021-06-30 21:13:37 +02:00
if ( ! permission_exists ( 'contact_domain_view' )) {
2019-07-26 17:41:41 +02:00
$sql .= " and ( " ; //only contacts assigned to current user's group(s) and those not assigned to any group
$sql .= " contact_uuid in ( " ;
2015-02-25 23:46:58 +01:00
$sql .= " select contact_uuid from v_contact_groups " ;
2019-07-26 17:41:41 +02:00
$sql .= " where " ;
2023-05-31 17:11:50 +02:00
if ( ! empty ( $user_group_uuids )) {
2019-07-26 17:41:41 +02:00
foreach ( $user_group_uuids as $index => $user_group_uuid ) {
if ( is_uuid ( $user_group_uuid )) {
$sql_where_or [] = " group_uuid = :group_uuid_ " . $index ;
$parameters [ 'group_uuid_' . $index ] = $user_group_uuid ;
}
}
2023-05-31 17:11:50 +02:00
if ( ! empty ( $sql_where_or )) {
2019-07-26 17:41:41 +02:00
$sql .= " ( " . implode ( ' or ' , $sql_where_or ) . " ) " ;
}
unset ( $sql_where_or , $index , $user_group_uuid );
}
$sql .= " and domain_uuid = :domain_uuid " ;
$sql .= " ) " ;
$sql .= " or " ;
$sql .= " contact_uuid not in ( " ;
2015-02-25 23:46:58 +01:00
$sql .= " select contact_uuid from v_contact_groups " ;
2019-07-26 17:41:41 +02:00
$sql .= " where group_uuid = :group_uuid " ;
$sql .= " and domain_uuid = :domain_uuid " ;
$sql .= " ) " ;
$sql .= " ) " ;
2015-02-25 23:46:58 +01:00
}
2019-07-26 17:41:41 +02:00
$parameters [ 'domain_uuid' ] = $_SESSION [ 'domain_uuid' ];
2023-05-31 17:11:50 +02:00
$parameters [ 'group_uuid' ] = $_SESSION [ 'group_uuid' ] ? ? '' ;
2019-07-26 17:41:41 +02:00
$database = new database ;
2023-06-01 19:50:12 +02:00
$result = $database -> select ( $sql , $parameters , 'all' );
2023-05-31 17:11:50 +02:00
if ( ! empty ( $result )) {
2015-02-25 23:46:58 +01:00
foreach ( $result as $row ) {
$contact_sync_sources [ $row [ 'contact_uuid' ]][] = $row [ 'contact_setting_value' ];
2014-11-25 09:35:53 +01:00
}
2015-02-25 23:46:58 +01:00
}
2019-07-26 17:41:41 +02:00
unset ( $sql , $parameters , $result );
2014-11-25 09:35:53 +01:00
2019-11-05 15:37:39 +01:00
//get variables used to control the order
2023-05-31 17:11:50 +02:00
$order_by = $_GET [ " order_by " ] ? ? '' ;
$order = $_GET [ " order " ] ? ? '' ;
2019-11-05 15:37:39 +01:00
//add the search term
2024-07-21 04:23:17 +02:00
$search = strtolower ( trim ( $_GET [ " search " ]) ? ? '' );
2023-05-05 18:46:37 +02:00
if ( ! empty ( $search )) {
2023-06-03 01:54:00 +02:00
if ( is_numeric ( $search )) {
$sql_search = " and contact_uuid in ( " ;
2019-11-05 15:37:39 +01:00
$sql_search .= " select contact_uuid from v_contact_phones " ;
2024-07-12 10:48:44 +02:00
$sql_search .= " where ( " ;
$sql_search .= " concat(phone_country_code, phone_number) like :search " ;
$sql_search .= " or phone_number like :search " ;
$sql_search .= " ) " ;
2019-11-05 15:37:39 +01:00
$sql_search .= " ) " ;
}
else {
2020-05-06 20:13:12 +02:00
//open container
2024-07-21 04:23:17 +02:00
$sql_search = " and ( " ;
2020-05-06 20:13:12 +02:00
//search contact
2024-07-21 04:23:17 +02:00
$sql_search .= " contact_uuid in ( " ;
$sql_search .= " select contact_uuid from v_contacts " ;
$sql_search .= " where domain_uuid = :domain_uuid " ;
$sql_search .= " and ( " ;
$sql_search .= " lower(contact_organization) like :search or " ;
$sql_search .= " lower(contact_name_given) like :search or " ;
$sql_search .= " lower(contact_name_family) like :search or " ;
$sql_search .= " lower(contact_nickname) like :search or " ;
$sql_search .= " lower(contact_title) like :search or " ;
$sql_search .= " lower(contact_category) like :search or " ;
$sql_search .= " lower(contact_role) like :search or " ;
$sql_search .= " lower(contact_url) like :search or " ;
$sql_search .= " lower(contact_time_zone) like :search or " ;
$sql_search .= " lower(contact_note) like :search or " ;
$sql_search .= " lower(contact_type) like :search " ;
$sql_search .= " ) " ;
$sql_search .= " ) " ;
//search contact emails
if ( permission_exists ( 'contact_email_view' )) {
$sql_search .= " or contact_uuid in ( " ;
$sql_search .= " select contact_uuid from v_contact_emails " ;
2020-05-06 20:13:12 +02:00
$sql_search .= " where domain_uuid = :domain_uuid " ;
$sql_search .= " and ( " ;
2024-07-21 04:23:17 +02:00
$sql_search .= " lower(email_address) like :search or " ;
$sql_search .= " lower(email_description) like :search " ;
2020-05-06 20:13:12 +02:00
$sql_search .= " ) " ;
$sql_search .= " ) " ;
2024-07-21 04:23:17 +02:00
}
2020-05-06 20:13:12 +02:00
//search contact notes
2024-07-21 04:23:17 +02:00
if ( permission_exists ( 'contact_note_view' )) {
$sql_search .= " or contact_uuid in ( " ;
$sql_search .= " select contact_uuid from v_contact_notes " ;
$sql_search .= " where domain_uuid = :domain_uuid " ;
$sql_search .= " and lower(contact_note) like :search " ;
2020-05-06 20:13:12 +02:00
$sql_search .= " ) " ;
2024-07-21 04:23:17 +02:00
}
//close container
$sql_search .= " ) " ;
2019-11-05 15:37:39 +01:00
}
$parameters [ 'search' ] = '%' . $search . '%' ;
}
2015-02-25 23:46:58 +01:00
//build query for paging and list
2019-07-26 17:41:41 +02:00
$sql = " select count(*) " ;
2015-02-25 23:46:58 +01:00
$sql .= " from v_contacts as c " ;
2022-01-20 23:54:42 +01:00
$sql .= " where true " ;
2023-05-31 17:11:50 +02:00
if ( $show != " all " || ! permission_exists ( 'contact_all' )) {
2022-01-20 23:54:42 +01:00
$sql .= " and (domain_uuid = :domain_uuid or domain_uuid is null) " ;
$parameters [ 'domain_uuid' ] = $_SESSION [ 'domain_uuid' ];
}
2021-06-30 21:13:37 +02:00
if ( ! permission_exists ( 'contact_domain_view' )) {
2019-07-26 17:41:41 +02:00
$sql .= " and ( " ; //only contacts assigned to current user's group(s) and those not assigned to any group
$sql .= " contact_uuid in ( " ;
2015-02-25 23:46:58 +01:00
$sql .= " select contact_uuid from v_contact_groups " ;
2019-07-26 17:41:41 +02:00
$sql .= " where " ;
2023-05-31 17:11:50 +02:00
if ( ! empty ( $user_group_uuids )) {
2019-07-26 17:41:41 +02:00
foreach ( $user_group_uuids as $index => $user_group_uuid ) {
if ( is_uuid ( $user_group_uuid )) {
$sql_where_or [] = " group_uuid = :group_uuid_ " . $index ;
$parameters [ 'group_uuid_' . $index ] = $user_group_uuid ;
}
}
2023-05-31 17:11:50 +02:00
if ( ! empty ( $sql_where_or )) {
2019-07-26 17:41:41 +02:00
$sql .= " ( " . implode ( ' or ' , $sql_where_or ) . " ) " ;
}
unset ( $sql_where_or , $index , $user_group_uuid );
}
$sql .= " and domain_uuid = :domain_uuid " ;
$sql .= " ) " ;
$sql .= " or contact_uuid in ( " ;
2016-01-19 05:46:49 +01:00
$sql .= " select contact_uuid from v_contact_users " ;
2019-07-26 17:41:41 +02:00
$sql .= " where user_uuid = :user_uuid " ;
$sql .= " and domain_uuid = :domain_uuid " ;
2016-01-19 05:46:49 +01:00
$sql .= " " ;
2019-07-26 17:41:41 +02:00
$sql .= " ) " ;
$sql .= " ) " ;
$parameters [ 'user_uuid' ] = $_SESSION [ 'user_uuid' ];
2015-02-25 23:46:58 +01:00
}
2023-05-31 17:11:50 +02:00
$sql .= $sql_search ? ? '' ;
2019-07-26 17:41:41 +02:00
$database = new database ;
2023-05-31 17:11:50 +02:00
$num_rows = $database -> select ( $sql , $parameters ? ? null , 'column' );
2012-06-04 16:58:40 +02:00
2015-02-25 23:46:58 +01:00
//prepare to page the results
2023-05-31 17:11:50 +02:00
$rows_per_page = ( ! empty ( $_SESSION [ 'domain' ][ 'paging' ][ 'numeric' ])) ? $_SESSION [ 'domain' ][ 'paging' ][ 'numeric' ] : 50 ;
2022-01-20 23:54:42 +01:00
$param = " &search= " . urlencode ( $search );
2023-05-31 17:11:50 +02:00
if ( $show == " all " && permission_exists ( 'contact_all' )) {
2022-01-20 23:54:42 +01:00
$param .= " &show=all " ;
}
2023-05-31 17:11:50 +02:00
$page = $_GET [ 'page' ] ? ? '' ;
2023-05-05 18:46:37 +02:00
if ( empty ( $page )) { $page = 0 ; $_GET [ 'page' ] = 0 ; }
2019-11-05 15:37:39 +01:00
list ( $paging_controls , $rows_per_page ) = paging ( $num_rows , $param , $rows_per_page ); //bottom
list ( $paging_controls_mini , $rows_per_page ) = paging ( $num_rows , $param , $rows_per_page , true ); //top
2015-02-25 23:46:58 +01:00
$offset = $rows_per_page * $page ;
2012-06-04 16:58:40 +02:00
2015-02-25 23:46:58 +01:00
//get the list
2022-04-12 00:28:48 +02:00
$sql = " select *, " ;
$sql .= " (select a.contact_attachment_uuid from v_contact_attachments as a where a.contact_uuid = c.contact_uuid and a.attachment_primary = 1) as contact_attachment_uuid " ;
$sql .= " from v_contacts as c " ;
$sql .= " where true " ;
2023-05-31 17:11:50 +02:00
if ( $show != " all " || ! permission_exists ( 'contact_all' )) {
2022-04-12 00:28:48 +02:00
$sql .= " and (domain_uuid = :domain_uuid or domain_uuid is null) " ;
$parameters [ 'domain_uuid' ] = $_SESSION [ 'domain_uuid' ];
}
if ( ! permission_exists ( 'contact_domain_view' )) {
$sql .= " and ( " ; //only contacts assigned to current user's group(s) and those not assigned to any group
$sql .= " contact_uuid in ( " ;
$sql .= " select contact_uuid from v_contact_groups " ;
$sql .= " where " ;
2023-05-31 17:11:50 +02:00
if ( ! empty ( $user_group_uuids )) {
2022-04-12 00:28:48 +02:00
foreach ( $user_group_uuids as $index => $user_group_uuid ) {
if ( is_uuid ( $user_group_uuid )) {
$sql_where_or [] = " group_uuid = :group_uuid_ " . $index ;
$parameters [ 'group_uuid_' . $index ] = $user_group_uuid ;
}
}
2023-05-31 17:11:50 +02:00
if ( ! empty ( $sql_where_or )) {
2022-04-12 00:28:48 +02:00
$sql .= " ( " . implode ( ' or ' , $sql_where_or ) . " ) " ;
}
unset ( $sql_where_or , $index , $user_group_uuid );
}
$sql .= " and domain_uuid = :domain_uuid " ;
$sql .= " ) " ;
$sql .= " or contact_uuid in ( " ;
$sql .= " select contact_uuid from v_contact_users " ;
$sql .= " where user_uuid = :user_uuid " ;
$sql .= " and domain_uuid = :domain_uuid " ;
$sql .= " " ;
$sql .= " ) " ;
$sql .= " ) " ;
$parameters [ 'user_uuid' ] = $_SESSION [ 'user_uuid' ];
}
2023-05-31 17:11:50 +02:00
$sql .= $sql_search ? ? '' ;
2022-04-12 00:28:48 +02:00
$database = new database ;
2023-05-31 17:11:50 +02:00
if ( ! empty ( $order_by )) {
2019-07-26 17:41:41 +02:00
$sql .= order_by ( $order_by , $order );
$sql .= " , contact_organization asc " ;
2015-02-25 23:46:58 +01:00
}
else {
2023-05-31 17:11:50 +02:00
$contact_default_sort_column = ! empty ( $_SESSION [ 'contacts' ][ 'default_sort_column' ][ 'text' ]) ? $_SESSION [ 'contacts' ][ 'default_sort_column' ][ 'text' ] : " last_mod_date " ;
$contact_default_sort_order = ! empty ( $_SESSION [ 'contacts' ][ 'default_sort_order' ][ 'text' ]) ? $_SESSION [ 'contacts' ][ 'default_sort_order' ][ 'text' ] : " desc " ;
2019-07-26 17:41:41 +02:00
$sql .= order_by ( $contact_default_sort_column , $contact_default_sort_order );
2015-10-20 10:05:03 +02:00
if ( $db_type == " pgsql " ) {
2019-07-26 17:41:41 +02:00
$sql .= " nulls last " ;
2015-10-20 10:05:03 +02:00
}
2015-02-25 23:46:58 +01:00
}
2019-07-26 17:41:41 +02:00
$sql .= limit_offset ( $rows_per_page , $offset );
$database = new database ;
2023-05-31 17:11:50 +02:00
$contacts = $database -> select ( $sql , $parameters ? ? null , 'all' );
2019-07-26 17:41:41 +02:00
unset ( $sql , $parameters );
2015-02-25 23:46:58 +01:00
2019-11-05 15:37:39 +01:00
//create token
$object = new token ;
$token = $object -> create ( $_SERVER [ 'PHP_SELF' ]);
2019-03-29 01:53:01 +01:00
2019-11-05 15:37:39 +01:00
//includes and title
$document [ 'title' ] = $text [ 'title-contacts' ];
require_once " resources/header.php " ;
//contact attachment layer
echo " <style> \n " ;
2019-03-29 01:53:01 +01:00
echo " #contact_attachment_layer { \n " ;
echo " z-index: 999999; \n " ;
2024-09-27 20:25:05 +02:00
echo " position: fixed; \n " ;
2019-03-29 01:53:01 +01:00
echo " left: 0px; \n " ;
echo " top: 0px; \n " ;
echo " right: 0px; \n " ;
echo " bottom: 0px; \n " ;
echo " text-align: center; \n " ;
echo " vertical-align: middle; \n " ;
echo " } \n " ;
echo " </style> \n " ;
echo " <div id='contact_attachment_layer' style='display: none;'></div> \n " ;
2015-02-25 23:46:58 +01:00
//show the content
2019-11-05 15:37:39 +01:00
echo " <div class='action_bar' id='action_bar'> \n " ;
2024-09-07 00:43:42 +02:00
echo " <div class='heading'><b> " . $text [ 'header-contacts' ] . " </b><div class='count'> " . number_format ( $num_rows ) . " </div></div> \n " ;
2019-11-05 15:37:39 +01:00
echo " <div class='actions'> \n " ;
2019-11-08 07:42:11 +01:00
if ( permission_exists ( 'contact_add' )) {
2020-01-24 05:24:10 +01:00
echo button :: create ([ 'type' => 'button' , 'label' => $text [ 'button-import' ], 'icon' => $_SESSION [ 'theme' ][ 'button_icon_import' ], 'collapse' => 'hide-sm-dn' , 'style' => 'margin-right: 15px;' , 'link' => 'contact_import.php' ]);
2019-11-08 07:42:11 +01:00
}
2015-02-25 23:46:58 +01:00
if ( permission_exists ( 'contact_add' )) {
2020-03-05 08:05:45 +01:00
echo button :: create ([ 'type' => 'button' , 'label' => $text [ 'button-add' ], 'icon' => $_SESSION [ 'theme' ][ 'button_icon_add' ], 'id' => 'btn_add' , 'collapse' => 'hide-sm-dn' , 'link' => 'contact_edit.php' ]);
2019-11-05 15:37:39 +01:00
}
if ( permission_exists ( 'contact_delete' ) && $contacts ) {
2022-01-13 19:37:59 +01:00
echo button :: create ([ 'type' => 'button' , 'label' => $text [ 'button-delete' ], 'icon' => $_SESSION [ 'theme' ][ 'button_icon_delete' ], 'id' => 'btn_delete' , 'name' => 'btn_delete' , 'style' => 'display: none;' , 'collapse' => 'hide-sm-dn' , 'onclick' => " modal_open('modal-delete','btn_delete'); " ]);
2015-02-25 23:46:58 +01:00
}
2019-11-05 15:37:39 +01:00
echo " <form id='form_search' class='inline' method='get'> \n " ;
2022-01-20 23:54:42 +01:00
if ( permission_exists ( 'contact_all' )) {
2023-05-31 17:11:50 +02:00
if ( $show == 'all' ) {
2022-01-20 23:54:42 +01:00
echo " <input type='hidden' name='show' value='all'> " ;
}
else {
2023-05-31 17:11:50 +02:00
echo button :: create ([ 'type' => 'button' , 'label' => $text [ 'button-show_all' ], 'icon' => $_SESSION [ 'theme' ][ 'button_icon_all' ], 'link' => '?type=&show=all' . ( ! empty ( $search ) ? " &search= " . urlencode ( $search ) : null )]);
2022-01-20 23:54:42 +01:00
}
}
2022-01-13 00:00:01 +01:00
echo " <input type='text' class='txt list-search' name='search' id='search' value= \" " . escape ( $search ) . " \" placeholder= \" " . $text [ 'label-search' ] . " \" onkeydown=''> " ;
echo button :: create ([ 'label' => $text [ 'button-search' ], 'icon' => $_SESSION [ 'theme' ][ 'button_icon_search' ], 'type' => 'submit' , 'id' => 'btn_search' , 'collapse' => 'hide-sm-dn' ]);
//echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','collapse'=>'hide-sm-dn','link'=>'contacts.php','style'=>($search == '' ? 'display: none;' : null)]);
2023-05-31 17:11:50 +02:00
if ( ! empty ( $paging_controls_mini )) {
2019-11-05 16:13:42 +01:00
echo " <span style='margin-left: 15px;'> " . $paging_controls_mini . " </span> " ;
2019-11-05 15:37:39 +01:00
}
echo " </form> \n " ;
echo " </div> \n " ;
echo " <div style='clear: both;'></div> \n " ;
echo " </div> \n " ;
2020-03-25 23:52:07 +01:00
if ( permission_exists ( 'contact_delete' ) && $contacts ) {
echo modal :: create ([ 'id' => 'modal-delete' , 'type' => 'delete' , 'actions' => button :: create ([ 'type' => 'button' , 'label' => $text [ 'button-continue' ], 'icon' => 'check' , 'id' => 'btn_delete' , 'style' => 'float: right; margin-left: 15px;' , 'collapse' => 'never' , 'onclick' => " modal_close(); list_action_set('delete'); list_form_submit('form_list'); " ])]);
}
2019-11-05 15:37:39 +01:00
echo $text [ 'description-contacts' ] . " \n " ;
echo " <br /><br /> \n " ;
echo " <form id='form_list' method='post'> \n " ;
echo " <input type='hidden' id='action' name='action' value=''> \n " ;
echo " <input type='hidden' name='search' value= \" " . escape ( $search ) . " \" > \n " ;
2024-09-06 01:10:04 +02:00
echo " <div class='card'> \n " ;
2019-11-05 15:37:39 +01:00
echo " <table class='list'> \n " ;
echo " <tr class='list-header'> \n " ;
if ( permission_exists ( 'contact_delete' )) {
echo " <th class='checkbox'> \n " ;
2023-05-31 17:11:50 +02:00
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' " . ( ! empty ( $contacts ) ? : " style='visibility: hidden;' " ) . " > \n " ;
2019-11-05 15:37:39 +01:00
echo " </th> \n " ;
2015-04-01 11:06:02 +02:00
}
2023-05-31 17:11:50 +02:00
if ( $show == " all " && permission_exists ( 'contact_all' )) {
2022-01-20 23:54:42 +01:00
echo th_order_by ( 'domain_name' , $text [ 'label-domain' ], $order_by , $order , $param , " class='shrink' " );
}
2013-05-10 02:40:24 +02:00
echo th_order_by ( 'contact_type' , $text [ 'label-contact_type' ], $order_by , $order );
echo th_order_by ( 'contact_organization' , $text [ 'label-contact_organization' ], $order_by , $order );
2019-11-05 15:37:39 +01:00
echo " <th class='shrink hide-xs'> </th> \n " ;
2013-05-10 02:40:24 +02:00
echo th_order_by ( 'contact_name_given' , $text [ 'label-contact_name_given' ], $order_by , $order );
echo th_order_by ( 'contact_name_family' , $text [ 'label-contact_name_family' ], $order_by , $order );
2019-11-05 15:37:39 +01:00
echo th_order_by ( 'contact_nickname' , $text [ 'label-contact_nickname' ], $order_by , $order , null , " class='hide-xs' " );
echo th_order_by ( 'contact_title' , $text [ 'label-contact_title' ], $order_by , $order , null , " class='hide-sm-dn' " );
echo th_order_by ( 'contact_role' , $text [ 'label-contact_role' ], $order_by , $order , null , " class='hide-sm-dn' " );
echo " <th class='shrink hide-sm-dn'> </th> \n " ;
2023-05-31 17:11:50 +02:00
if ( $list_row_edit_button == 'true' ) {
2019-11-05 15:37:39 +01:00
echo " <td class='action-button'> </td> \n " ;
}
2014-06-22 05:24:36 +02:00
echo " </tr> \n " ;
2012-06-04 16:58:40 +02:00
2023-05-31 17:11:50 +02:00
if ( ! empty ( $contacts )) {
2019-11-05 15:37:39 +01:00
$x = 0 ;
2018-07-02 18:44:14 +02:00
foreach ( $contacts as $row ) {
2020-04-01 01:32:12 +02:00
$list_row_url = " contact_view.php?id= " . urlencode ( $row [ 'contact_uuid' ]) . " &query_string= " . urlencode ( $_SERVER [ " QUERY_STRING " ]);
2025-02-21 00:30:09 +01:00
if ( $row [ 'domain_uuid' ] != $_SESSION [ 'domain_uuid' ] && permission_exists ( 'domain_select' )) {
$list_row_url .= '&domain_uuid=' . urlencode ( $row [ 'domain_uuid' ]) . '&domain_change=true' ;
}
2019-11-05 15:37:39 +01:00
echo " <tr class='list-row' href=' " . $list_row_url . " '> \n " ;
if ( permission_exists ( 'contact_delete' )) {
echo " <td class='checkbox'> \n " ;
2022-01-13 19:37:59 +01:00
echo " <input type='checkbox' name='contacts[ $x ][checked]' id='checkbox_ " . $x . " ' value='true' onclick= \" checkbox_on_change(this); if (!this.checked) { document.getElementById('checkbox_all').checked = false; } \" > \n " ;
2019-11-05 15:37:39 +01:00
echo " <input type='hidden' name='contacts[ $x ][uuid]' value=' " . escape ( $row [ 'contact_uuid' ]) . " ' /> \n " ;
echo " </td> \n " ;
}
2023-05-31 17:11:50 +02:00
if ( $show == " all " && permission_exists ( 'contact_all' )) {
2023-05-05 18:46:37 +02:00
if ( ! empty ( $_SESSION [ 'domains' ][ $row [ 'domain_uuid' ]][ 'domain_name' ])) {
2022-01-20 23:54:42 +01:00
$domain = $_SESSION [ 'domains' ][ $row [ 'domain_uuid' ]][ 'domain_name' ];
}
else {
$domain = $text [ 'label-global' ];
}
echo " <td> " . escape ( $domain ) . " </td> \n " ;
}
2019-11-05 15:37:39 +01:00
echo " <td> " . ucwords ( escape ( $row [ 'contact_type' ])) . " </td> \n " ;
echo " <td class='overflow'><a href=' " . $list_row_url . " '> " . escape ( $row [ 'contact_organization' ]) . " </a> </td> \n " ;
echo " <td class='shrink no-link hide-xs center'> " ;
2019-03-29 01:53:01 +01:00
if ( is_uuid ( $row [ 'contact_attachment_uuid' ])) {
2019-11-05 15:37:39 +01:00
echo " <i class='fas fa-portrait' style='cursor: pointer;' onclick= \" display_attachment(' " . escape ( $row [ 'contact_attachment_uuid' ]) . " '); \" ></i> " ;
2019-03-29 01:53:01 +01:00
}
echo " </td> \n " ;
2019-11-05 15:37:39 +01:00
echo " <td class='no-wrap'><a href=' " . $list_row_url . " '> " . escape ( $row [ 'contact_name_given' ]) . " </a> </td> \n " ;
echo " <td class='no-wrap'><a href=' " . $list_row_url . " '> " . escape ( $row [ 'contact_name_family' ]) . " </a> </td> \n " ;
echo " <td class='no-wrap hide-xs'> " . escape ( $row [ 'contact_nickname' ]) . " </td> \n " ;
echo " <td class='overflow hide-sm-dn'> " . escape ( $row [ 'contact_title' ]) . " </td> \n " ;
echo " <td class='overflow hide-sm-dn'> " . escape ( $row [ 'contact_role' ]) . " </td> \n " ;
echo " <td class='hide-sm-dn'> " ;
2023-05-31 17:11:50 +02:00
if ( ! empty ( $contact_sync_sources [ $row [ 'contact_uuid' ]])) {
2019-11-05 15:37:39 +01:00
foreach ( $contact_sync_sources [ $row [ 'contact_uuid' ]] as $contact_sync_source ) {
switch ( $contact_sync_source ) {
case 'google' : echo " <img src='resources/images/icon_gcontacts.png' style='width: 21px; height: 21px; border: none; padding-left: 2px;' alt=' " . $text [ 'label-contact_google' ] . " '> " ; break ;
2014-11-25 09:35:53 +01:00
}
}
2019-11-05 15:37:39 +01:00
}
else {
echo " " ;
}
2012-06-04 16:58:40 +02:00
echo " </td> \n " ;
2023-05-31 17:11:50 +02:00
if ( $list_row_edit_button == 'true' ) {
2019-11-05 15:37:39 +01:00
echo " <td class='action-button'> " ;
2020-04-01 01:32:12 +02:00
echo button :: create ([ 'type' => 'button' , 'title' => $text [ 'button-view' ], 'icon' => $_SESSION [ 'theme' ][ 'button_icon_view' ], 'link' => $list_row_url ]);
2019-11-05 15:37:39 +01:00
echo " </td> \n " ;
}
2012-06-04 16:58:40 +02:00
echo " </tr> \n " ;
2019-11-05 15:37:39 +01:00
$x ++ ;
}
unset ( $contacts );
}
2012-06-04 16:58:40 +02:00
2019-11-05 15:37:39 +01:00
echo " </table> \n " ;
2024-09-06 01:10:04 +02:00
echo " </div> \n " ;
2019-11-05 15:37:39 +01:00
echo " <br /> \n " ;
echo " <div align='center'> " . $paging_controls . " </div> \n " ;
2015-02-25 23:46:58 +01:00
2019-11-05 15:37:39 +01:00
echo " <input type='hidden' name=' " . $token [ 'name' ] . " ' value=' " . $token [ 'hash' ] . " '> \n " ;
2012-06-04 16:58:40 +02:00
2019-11-05 15:37:39 +01:00
echo " </form> \n " ;
2015-03-18 06:38:35 +01:00
2019-03-29 01:53:01 +01:00
//javascript
echo " <script> \n " ;
echo " function display_attachment(id) { \n " ;
echo " $ ('#contact_attachment_layer').load('contact_attachment.php?id=' + id + '&action=display', function() { \n " ;
echo " $ ('#contact_attachment_layer').fadeIn(200); \n " ;
echo " }); \n " ;
echo " } \n " ;
echo " </script> \n " ;
2012-06-04 16:58:40 +02:00
//include the footer
2013-07-06 08:29:50 +02:00
require_once " resources/footer.php " ;
2018-01-10 21:37:26 +01:00
2021-06-30 21:01:33 +02:00
?>
2025-02-21 00:30:09 +01:00