From c05afd3a46bafa20656ee2c0935743b2f19923cb Mon Sep 17 00:00:00 2001 From: yurabakhtin Date: Tue, 1 Mar 2016 13:09:10 +0300 Subject: [PATCH 01/89] New widget "Contact Form" --- inc/widgets/_widgets.funcs.php | 4 + .../views/_widget_list_available.view.php | 3 +- inc/widgets/widgets/_contact_form.widget.php | 202 ++++++++++++++++++ skins_fallback_v5/_msgform.disp.php | 100 +-------- skins_fallback_v6/_msgform.disp.php | 100 +-------- 5 files changed, 216 insertions(+), 193 deletions(-) create mode 100644 inc/widgets/widgets/_contact_form.widget.php diff --git a/inc/widgets/_widgets.funcs.php b/inc/widgets/_widgets.funcs.php index b11b175ff72..ecc7b1a726d 100644 --- a/inc/widgets/_widgets.funcs.php +++ b/inc/widgets/_widgets.funcs.php @@ -304,6 +304,10 @@ function insert_basic_widgets( $blog_id, $initial_install = false, $kind = '' ) add_basic_widget( $blog_id, 'Front Page Secondary Area', 'org_members', 'core', 10 ); + /* Contact Page Main Area */ + add_basic_widget( $blog_id, 'Contact Page Main Area', 'contact_form', 'core', 10 ); + + /* Mobile Footer */ add_basic_widget( $blog_id, 'Mobile: Footer', 'coll_longdesc', 'core', 10 ); add_basic_widget( $blog_id, 'Mobile: Footer', 'mobile_skin_switcher', 'core', 20 ); diff --git a/inc/widgets/views/_widget_list_available.view.php b/inc/widgets/views/_widget_list_available.view.php index eef8ccd9ee1..912b3c3b618 100644 --- a/inc/widgets/views/_widget_list_available.view.php +++ b/inc/widgets/views/_widget_list_available.view.php @@ -117,7 +117,8 @@ 'org_members', 'online_users', 'mobile_skin_switcher', - 'poll' + 'poll', + 'contact_form', ), ); diff --git a/inc/widgets/widgets/_contact_form.widget.php b/inc/widgets/widgets/_contact_form.widget.php new file mode 100644 index 00000000000..e742ee892f3 --- /dev/null +++ b/inc/widgets/widgets/_contact_form.widget.php @@ -0,0 +1,202 @@ +get_name(); + } + + + /** + * Get short description + */ + function get_desc() + { + return T_('Display contact form'); + } + + + /** + * Display the widget! + * + * @param array MUST contain at least the basic display params + */ + function display( $params ) + { + global $disp, $current_User, $DB, $cookie_name, $cookie_email; + + if( $disp != 'msgform' ) + { // Don't use this widget on $disp != 'msgform' + echo '

'.sprintf( T_('The widget %s should be used only on $disp = %s.'), ''.$this->get_name().'', 'msgform' ).'

'; + return false; + } + + $this->init_display( $params ); + + $blog_ID = isset( $this->disp_params['blog_ID'] ) ? intval( $this->disp_params['blog_ID'] ) : 0; + if( $blog_ID > 0 ) + { // Get Blog for widget setting + $BlogCache = & get_BlogCache(); + $widget_Blog = & $BlogCache->get_by_ID( $blog_ID, false, false ); + } + if( empty( $widget_Blog ) ) + { // Use current blog + global $Blog; + $widget_Blog = & $Blog; + } + + // Parameters + /* TODO: dh> params should get remembered, e.g. if somebody clicks on the + * login/logout link from the msgform page. + * BUT, for the logout link remembering it here is too late normally.. :/ + */ + $redirect_to = param( 'redirect_to', 'url', '' ); // pass-through (hidden field) + $recipient_id = param( 'recipient_id', 'integer', 0 ); + $post_id = param( 'post_id', 'integer', 0 ); + $comment_id = param( 'comment_id', 'integer', 0 ); + $subject = param( 'subject', 'string', '' ); + + // User's preferred name or the stored value in her cookie (from commenting): + $email_author = ''; + // User's email address or the stored value in her cookie (from commenting): + $email_author_address = ''; + if( is_logged_in() ) + { + $email_author = $current_User->get_preferred_name(); + $email_author_address = $current_User->email; + } + if( ! strlen( $email_author ) ) + { // Try to get params from $_COOKIE through the param() function + $email_author = param_cookie( $cookie_name, 'string', '' ); + $email_author_address = param_cookie( $cookie_email, 'string', '' ); + } + + $recipient_User = NULL; + // Get the name and email address of the recipient + if( empty( $recipient_id ) ) + { + $recipient_name = param( 'recipient_name', 'string', '' ); + $recipient_address = param( 'recipient_address', 'string', '' ); + } + else + { // If the email is to a registered user get the email address from the users table + $UserCache = & get_UserCache(); + $recipient_User = & $UserCache->get_by_ID( $recipient_id ); + + if( $recipient_User ) + { // recipient User found + $recipient_name = $recipient_User->get( 'preferredname' ); + $recipient_address = $recipient_User->get( 'email' ); + } + } + + if( empty( $recipient_address ) ) + { // We should never have called this in the first place! + // Could be that commenter did not provide an email, etc... + echo T_('No recipient specified!'); + return false; + } + + // Form to send email + if( ! empty( $widget_Blog ) && ( $widget_Blog->get_ajax_form_enabled() ) ) + { + if( empty( $subject ) ) + { + $subject = ''; + } + // init params + $json_params = array( + 'action' => 'get_msg_form', + 'subject' => $subject, + 'recipient_id' => $recipient_id, + 'recipient_name' => $recipient_name, + 'email_author' => $email_author, + 'email_author_address' => $email_author_address, + 'blog' => $widget_Blog->ID, + 'comment_id' => $comment_id, + 'redirect_to' => $redirect_to, + 'params' => $params ); + + // generate form wtih ajax request + display_ajax_form( $json_params ); + } + else + { + if( ! empty( $recipient_User ) ) + { // Get identity link for existed users + $recipient_link = $recipient_User->get_identity_link( array( 'link_text' => 'nickname' ) ); + } + else + { // Get login name for anonymous user + $gender_class = ''; + if( check_setting( 'gender_colored' ) ) + { // Set a gender class if the setting is ON + $gender_class = ' nogender'; + } + $recipient_link = ''.$recipient_name.''; + } + + require skin_template_path( '_contact_msg.form.php' ); + } + + return true; + } +} + +?> \ No newline at end of file diff --git a/skins_fallback_v5/_msgform.disp.php b/skins_fallback_v5/_msgform.disp.php index e364beb5d76..a8306e1dad8 100644 --- a/skins_fallback_v5/_msgform.disp.php +++ b/skins_fallback_v5/_msgform.disp.php @@ -21,102 +21,10 @@ */ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -global $cookie_name, $cookie_email; -global $DB; - -// Parameters -/* TODO: dh> params should get remembered, e.g. if somebody clicks on the - * login/logout link from the msgform page. - * BUT, for the logout link remembering it here is too late normally.. :/ - */ -$redirect_to = param( 'redirect_to', 'url', '' ); // pass-through (hidden field) -$recipient_id = param( 'recipient_id', 'integer', 0 ); -$post_id = param( 'post_id', 'integer', 0 ); -$comment_id = param( 'comment_id', 'integer', 0 ); -$subject = param( 'subject', 'string', '' ); - - -// User's preferred name or the stored value in her cookie (from commenting): -$email_author = ''; -// User's email address or the stored value in her cookie (from commenting): -$email_author_address = ''; -if( is_logged_in() ) -{ - $email_author = $current_User->get_preferred_name(); - $email_author_address = $current_User->email; -} -if( ! strlen( $email_author ) ) -{ // Try to get params from $_COOKIE through the param() function - $email_author = param_cookie( $cookie_name, 'string', '' ); - $email_author_address = param_cookie( $cookie_email, 'string', '' ); -} - -$recipient_User = NULL; -// Get the name and email address of the recipient -if( empty($recipient_id) ) -{ - $recipient_name = param( 'recipient_name', 'string', '' ); - $recipient_address = param( 'recipient_address', 'string', '' ); -} -else -{ // If the email is to a registered user get the email address from the users table - $UserCache = & get_UserCache(); - $recipient_User = & $UserCache->get_by_ID( $recipient_id ); - - if( $recipient_User ) - { // recipient User found - $recipient_name = $recipient_User->get('preferredname'); - $recipient_address = $recipient_User->get('email'); - } -} - -if( empty($recipient_address) ) -{ // We should never have called this in the first place! - // Could be that commenter did not provide an email, etc... - echo 'No recipient specified!'; - return; -} - -// Form to send email -if( !empty( $Blog ) && ( $Blog->get_ajax_form_enabled() ) ) -{ - if( empty( $subject ) ) - { - $subject = ''; - } - // init params - $json_params = array( - 'action' => 'get_msg_form', - 'subject' => $subject, - 'recipient_id' => $recipient_id, - 'recipient_name' => $recipient_name, - 'email_author' => $email_author, - 'email_author_address' => $email_author_address, - 'blog' => $Blog->ID, - 'comment_id' => $comment_id, - 'redirect_to' => $redirect_to, - 'params' => $params ); - - // generate form wtih ajax request - display_ajax_form( $json_params ); -} -else -{ - if( ! empty( $recipient_User ) ) - { // Get identity link for existed users - $recipient_link = $recipient_User->get_identity_link( array( 'link_text' => 'nickname' ) ); - } - else - { // Get login name for anonymous user - $gender_class = ''; - if( check_setting( 'gender_colored' ) ) - { // Set a gender class if the setting is ON - $gender_class = ' nogender'; - } - $recipient_link = ''.$recipient_name.''; - } - require skin_template_path( '_contact_msg.form.php' ); -} +// ------------------ "Contact Page Main Area" CONTAINER EMBEDDED HERE ------------------- +// Display container and contents: +skin_container( NT_('Contact Page Main Area') ); +// --------------------- END OF "Contact Page Main Area" CONTAINER ----------------------- ?> \ No newline at end of file diff --git a/skins_fallback_v6/_msgform.disp.php b/skins_fallback_v6/_msgform.disp.php index e364beb5d76..a8306e1dad8 100644 --- a/skins_fallback_v6/_msgform.disp.php +++ b/skins_fallback_v6/_msgform.disp.php @@ -21,102 +21,10 @@ */ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -global $cookie_name, $cookie_email; -global $DB; - -// Parameters -/* TODO: dh> params should get remembered, e.g. if somebody clicks on the - * login/logout link from the msgform page. - * BUT, for the logout link remembering it here is too late normally.. :/ - */ -$redirect_to = param( 'redirect_to', 'url', '' ); // pass-through (hidden field) -$recipient_id = param( 'recipient_id', 'integer', 0 ); -$post_id = param( 'post_id', 'integer', 0 ); -$comment_id = param( 'comment_id', 'integer', 0 ); -$subject = param( 'subject', 'string', '' ); - - -// User's preferred name or the stored value in her cookie (from commenting): -$email_author = ''; -// User's email address or the stored value in her cookie (from commenting): -$email_author_address = ''; -if( is_logged_in() ) -{ - $email_author = $current_User->get_preferred_name(); - $email_author_address = $current_User->email; -} -if( ! strlen( $email_author ) ) -{ // Try to get params from $_COOKIE through the param() function - $email_author = param_cookie( $cookie_name, 'string', '' ); - $email_author_address = param_cookie( $cookie_email, 'string', '' ); -} - -$recipient_User = NULL; -// Get the name and email address of the recipient -if( empty($recipient_id) ) -{ - $recipient_name = param( 'recipient_name', 'string', '' ); - $recipient_address = param( 'recipient_address', 'string', '' ); -} -else -{ // If the email is to a registered user get the email address from the users table - $UserCache = & get_UserCache(); - $recipient_User = & $UserCache->get_by_ID( $recipient_id ); - - if( $recipient_User ) - { // recipient User found - $recipient_name = $recipient_User->get('preferredname'); - $recipient_address = $recipient_User->get('email'); - } -} - -if( empty($recipient_address) ) -{ // We should never have called this in the first place! - // Could be that commenter did not provide an email, etc... - echo 'No recipient specified!'; - return; -} - -// Form to send email -if( !empty( $Blog ) && ( $Blog->get_ajax_form_enabled() ) ) -{ - if( empty( $subject ) ) - { - $subject = ''; - } - // init params - $json_params = array( - 'action' => 'get_msg_form', - 'subject' => $subject, - 'recipient_id' => $recipient_id, - 'recipient_name' => $recipient_name, - 'email_author' => $email_author, - 'email_author_address' => $email_author_address, - 'blog' => $Blog->ID, - 'comment_id' => $comment_id, - 'redirect_to' => $redirect_to, - 'params' => $params ); - - // generate form wtih ajax request - display_ajax_form( $json_params ); -} -else -{ - if( ! empty( $recipient_User ) ) - { // Get identity link for existed users - $recipient_link = $recipient_User->get_identity_link( array( 'link_text' => 'nickname' ) ); - } - else - { // Get login name for anonymous user - $gender_class = ''; - if( check_setting( 'gender_colored' ) ) - { // Set a gender class if the setting is ON - $gender_class = ' nogender'; - } - $recipient_link = ''.$recipient_name.''; - } - require skin_template_path( '_contact_msg.form.php' ); -} +// ------------------ "Contact Page Main Area" CONTAINER EMBEDDED HERE ------------------- +// Display container and contents: +skin_container( NT_('Contact Page Main Area') ); +// --------------------- END OF "Contact Page Main Area" CONTAINER ----------------------- ?> \ No newline at end of file From 701a713db6304339517ad1da91d06ad92ee1a4e9 Mon Sep 17 00:00:00 2001 From: yurabakhtin Date: Thu, 9 Jun 2016 11:55:17 +0300 Subject: [PATCH 02/89] Modify the column orders to sort by previous order as second --- inc/_core/ui/results/_results.class.php | 50 ++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/inc/_core/ui/results/_results.class.php b/inc/_core/ui/results/_results.class.php index 06b3c742393..a70679f8a84 100644 --- a/inc/_core/ui/results/_results.class.php +++ b/inc/_core/ui/results/_results.class.php @@ -1490,21 +1490,52 @@ function get_col_sort_values( $col_idx ) $col_sort_values['current_order'] = ''; } + // Get index and direction of the current and previous orders + $current_order_index = false; + $previous_order_index = false; + for( $i = 0; $i < strlen( $this->order ); $i++ ) + { + $order_char_i = substr( $this->order, $i, 1 ); + if( $order_char_i == 'A' || $order_char_i == 'D' ) + { + $current_order_index = $i; + $current_order_direction = $order_char_i; + } + if( $order_char_i == 'a' || $order_char_i == 'd' ) + { + $previous_order_index = $i; + $previous_order_direction = $order_char_i; + } + } + // Generate sort values to use for sorting on the current column: $order_asc = ''; $order_desc = ''; for( $i = 0; $i < $this->nb_cols; $i++ ) { - if( $i == $col_idx ) + if( $i == $col_idx ) { // Link ordering the current column $order_asc .= 'A'; $order_desc .= 'D'; } else { - $order_asc .= '-'; - $order_desc .= '-'; + if( $i === $current_order_index ) + { // Set an order direction of current order as lowercase char for next order column + $order_asc .= strtolower( $current_order_direction ); + $order_desc .= strtolower( $current_order_direction ); + } + elseif( $i === $previous_order_index && $col_idx === $current_order_index ) + { // Save an order direction of the previous, Used when user changes an order on the same column + $order_asc .= $previous_order_direction; + $order_desc .= $previous_order_direction; + } + else + { + $order_asc .= '-'; + $order_desc .= '-'; + } } } @@ -1594,6 +1625,7 @@ function get_order_field_list() $orders = array(); $this->order_callbacks = array(); + $second_orders = array(); for( $i = 0; $i <= strlen( $this->order ); $i++ ) { // For each position in order string: @@ -1603,11 +1635,17 @@ function get_order_field_list() switch( substr( $this->order, $i, 1 ) ) { case 'A': - $orders[] = preg_replace( '~(?cols[$i]['order'] ).' ASC'; + $orders[] = preg_replace( '~(?cols[$i]['order'] ).' ASC'; + break; + case 'a': + $second_orders[] = preg_replace( '~(?cols[$i]['order'] ).' ASC'; break; case 'D': - $orders[] = preg_replace( '~(asc|desc)?\s*,~i', ' DESC,', $this->cols[$i]['order'] ).' DESC'; + $orders[] = preg_replace( '~(asc|desc)?\s*,~i', ' DESC,', $this->cols[$i]['order'] ).' DESC'; + break; + case 'd': + $second_orders[] = preg_replace( '~(asc|desc)?\s*,~i', ' DESC,', $this->cols[$i]['order'] ).' DESC'; break; } } @@ -1652,7 +1690,7 @@ function get_order_field_list() } } } - $this->order_field_list = implode( ',', $orders ); + $this->order_field_list = implode( ', ', array_merge( $orders, $second_orders ) ); } return $this->order_field_list; // May be empty } From 7f47dd1fefb17d32e020080074a9118fa915914d Mon Sep 17 00:00:00 2001 From: yurabakhtin Date: Thu, 30 Jun 2016 10:04:25 +0300 Subject: [PATCH 03/89] Fix sorting of item types table --- inc/items/views/_itemtypes.view.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/inc/items/views/_itemtypes.view.php b/inc/items/views/_itemtypes.view.php index cb67741ec3f..b2f67b519ab 100644 --- a/inc/items/views/_itemtypes.view.php +++ b/inc/items/views/_itemtypes.view.php @@ -18,7 +18,7 @@ // Create query $SQL = new SQL(); -$SQL->SELECT( 't.*, IF( tb.itc_ityp_ID > 0, 1, 0 ) AS type_enabled' ); +$SQL->SELECT( 't.*, IF( tb.itc_ityp_ID > 0, 1, 0 ) AS type_enabled, IF( ityp_ID = '.$Blog->get_setting( 'default_post_type' ).', 1, 0 ) AS type_default' ); $SQL->FROM( 'T_items__type AS t' ); $SQL->FROM_add( 'LEFT JOIN T_items__type_coll AS tb ON itc_ityp_ID = ityp_ID AND itc_coll_ID = '.$Blog->ID ); @@ -117,7 +117,8 @@ function ityp_row_enabled( $enabled, $item_type_ID ) } $Results->cols[] = array( 'th' => sprintf( T_('Enabled in
%s'), $Blog->get( 'shortname' ) ), - 'order' => 'ityp_perm_level', + 'order' => 'type_enabled', + 'default_dir' => 'D', 'td' => '%ityp_row_enabled( #type_enabled#, #ityp_ID# )%', 'th_class' => 'shrinkwrap', 'td_class' => 'center', @@ -156,7 +157,8 @@ function ityp_row_default( $item_type_ID ) } $Results->cols[] = array( 'th' => sprintf( T_('Default for
%s'), $Blog->get( 'shortname' ) ), - 'order' => 'ityp_perm_level', + 'order' => 'type_default', + 'default_dir' => 'D', 'td' => '%ityp_row_default( #ityp_ID# )%', 'th_class' => 'shrinkwrap', 'td_class' => 'center', From d27318b72364d59bf880b594c6a4d09116f102df Mon Sep 17 00:00:00 2001 From: yurabakhtin Date: Mon, 24 Oct 2016 11:49:48 +0300 Subject: [PATCH 04/89] Fix sending email message to anonymous commentators --- inc/skins/_skin.funcs.php | 6 +----- inc/widgets/widgets/_contact_form.widget.php | 22 +++++++++++++------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/inc/skins/_skin.funcs.php b/inc/skins/_skin.funcs.php index 7bcc0cbe5f1..cc0951438fd 100644 --- a/inc/skins/_skin.funcs.php +++ b/inc/skins/_skin.funcs.php @@ -529,16 +529,12 @@ function skin_init( $disp ) elseif( !empty( $comment_id ) ) { // comment id is set, try to get comment author user $CommentCache = & get_CommentCache(); - $Comment = $CommentCache->get_by_ID( $comment_id, false ); - - if( $Comment = $CommentCache->get_by_ID( $comment_id, false ) ) + if( $Comment = & $CommentCache->get_by_ID( $comment_id, false ) ) { $recipient_User = & $Comment->get_author_User(); if( empty( $recipient_User ) && ( $Comment->allow_msgform ) && ( is_email( $Comment->get_author_email() ) ) ) { // set allow message form to email because comment author (not registered) accepts email $allow_msgform = 'email'; - param( 'recipient_address', 'string', $Comment->get_author_email() ); - param( 'recipient_name', 'string', $Comment->get_author_name() ); } } } diff --git a/inc/widgets/widgets/_contact_form.widget.php b/inc/widgets/widgets/_contact_form.widget.php index e742ee892f3..8cfc1594539 100644 --- a/inc/widgets/widgets/_contact_form.widget.php +++ b/inc/widgets/widgets/_contact_form.widget.php @@ -129,13 +129,8 @@ function display( $params ) $recipient_User = NULL; // Get the name and email address of the recipient - if( empty( $recipient_id ) ) - { - $recipient_name = param( 'recipient_name', 'string', '' ); - $recipient_address = param( 'recipient_address', 'string', '' ); - } - else - { // If the email is to a registered user get the email address from the users table + if( ! empty( $recipient_id ) ) + { // If the email is to a registered user get the email address from the users table $UserCache = & get_UserCache(); $recipient_User = & $UserCache->get_by_ID( $recipient_id ); @@ -145,6 +140,19 @@ function display( $params ) $recipient_address = $recipient_User->get( 'email' ); } } + elseif( ! empty( $comment_id ) ) + { // If the email is to anonymous user of comment + $CommentCache = & get_CommentCache(); + if( $Comment = & $CommentCache->get_by_ID( $comment_id, false ) ) + { + $recipient_User = & $Comment->get_author_User(); + if( empty( $recipient_User ) && ( $Comment->allow_msgform ) && ( is_email( $Comment->get_author_email() ) ) ) + { // Get recipient name and email from comment's author: + $recipient_name = $Comment->get_author_name(); + $recipient_address = $Comment->get_author_email(); + } + } + } if( empty( $recipient_address ) ) { // We should never have called this in the first place! From 7d71ddf6adf8d67eeaf809186b9450411f9368db Mon Sep 17 00:00:00 2001 From: yurabakhtin Date: Mon, 3 Jul 2017 17:25:16 +0300 Subject: [PATCH 05/89] Update collections list widget for more settings --- inc/collections/model/_blogcache.class.php | 77 +++++++++++++++++++ inc/users/model/_group.class.php | 4 + inc/widgets/model/_widget.class.php | 32 ++++++-- .../widgets/_colls_list_public.widget.php | 42 ++++++++-- 4 files changed, 141 insertions(+), 14 deletions(-) diff --git a/inc/collections/model/_blogcache.class.php b/inc/collections/model/_blogcache.class.php index fbab6e66bd0..2f7fd313ab6 100644 --- a/inc/collections/model/_blogcache.class.php +++ b/inc/collections/model/_blogcache.class.php @@ -198,6 +198,83 @@ function load_all( $order_by = '', $order_dir = '' ) } + /** + * Load a list of restricted collections into the cache + * + * @param string Filter: 'all', 'public', 'access', 'public_access', + * @param string Order By + * @param string Order Direction + * @return array of IDs + */ + function load_restricted_colls( $filter, $order_by = '', $order_dir = '' ) + { + global $DB, $Debuglog, $Settings; + + $Debuglog->add( 'Loading '.$this->objtype.'(restricted "'.$filter.'") into cache', 'dataobjects' ); + + if( $order_by == '' ) + { // Use default value from settings: + $order_by = $Settings->get( 'blogs_order_by' ); + } + + if( $order_dir == '' ) + { // Use default value from settings: + $order_dir = $Settings->get( 'blogs_order_dir' ); + } + + $SQL = new SQL( 'Load restricted collection list with filter "'.$filter.'"' ); + $SQL->SELECT( '*' ); + $SQL->FROM( $this->dbtablename ); + if( $filter == 'public' || $filter == 'public_access' ) + { // Restrict with public collections: + $public_SQL = $this->get_public_colls_SQL( $order_by, $order_dir ); + $SQL->WHERE( '( '.$public_SQL->get_where( '' ).' )' ); + } + if( $filter == 'access' || $filter == 'public_access' ) + { // Restrict with public collections: + $CollectionSettings = new CollectionSettings(); + $default_allow_access = isset( $CollectionSettings->_defaults['allow_access'] ) ? $CollectionSettings->_defaults['allow_access'] : 'public'; + + $SQL->FROM_add( 'LEFT JOIN T_coll_settings ON blog_ID = cset_coll_ID AND cset_name = "allow_access"' ); + $access_sql_where = '( cset_value = "public"'.( $default_allow_access == 'public' ? ' OR cset_value IS NULL' : '' ).' )'; + if( is_logged_in() ) + { // Allow the collections that available for logged in users: + $access_sql_where .= ' OR ( cset_value = "users"'.( $default_allow_access == 'users' ? ' OR cset_value IS NULL' : '' ).' )'; + // Allow the collections that available for members: + global $current_User; + $access_sql_where .= ' OR ( ( cset_value = "members"'.( $default_allow_access == 'members' ? ' OR cset_value IS NULL' : '' ).' ) AND ( + ( SELECT grp_ID + FROM T_groups + WHERE grp_ID = '.$current_User->grp_ID.' + AND grp_perm_blogs IN ( "viewall", "editall" ) ) OR + ( SELECT bloguser_user_ID + FROM T_coll_user_perms + WHERE bloguser_blog_ID = blog_ID + AND bloguser_ismember = 1 + AND bloguser_user_ID = '.$current_User->ID.' ) OR + ( SELECT bloggroup_group_ID + FROM T_coll_group_perms + WHERE bloggroup_blog_ID = blog_ID + AND bloggroup_ismember = 1 + AND ( bloggroup_group_ID = '.$current_User->grp_ID.' + OR bloggroup_group_ID IN ( SELECT sug_grp_ID FROM T_users__secondary_user_groups WHERE sug_user_ID = '.$current_User->ID.' ) ) + LIMIT 1 + ) + ) )'; + } + $SQL->WHERE_and( '( '.$access_sql_where.' )' ); + } + $SQL->ORDER_BY( gen_order_clause( $order_by, $order_dir, 'blog_', 'blog_ID' ) ); + + foreach( $DB->get_results( $SQL->get(), OBJECT, $SQL->title ) as $row ) + { // Instantiate a custom object + $this->instantiate( $row ); + } + + return $DB->get_col( NULL, 0 ); + } + + /** * Load a list of public blogs into the cache * diff --git a/inc/users/model/_group.class.php b/inc/users/model/_group.class.php index fea009da013..4b64eecdef2 100644 --- a/inc/users/model/_group.class.php +++ b/inc/users/model/_group.class.php @@ -528,6 +528,10 @@ function dbupdate() $GroupSettings = & $this->get_GroupSettings(); $GroupSettings->update( $this->ID ); + // BLOCK CACHE INVALIDATION: + // This Group has been modified, cached content depending on it should be invalidated: + BlockCache::invalidate_key( 'grp_ID', $this->ID ); + $DB->commit(); } diff --git a/inc/widgets/model/_widget.class.php b/inc/widgets/model/_widget.class.php index 1a5f877975b..8ea6a732084 100644 --- a/inc/widgets/model/_widget.class.php +++ b/inc/widgets/model/_widget.class.php @@ -809,7 +809,9 @@ function disp_title( $title = NULL, $display = true ) /** * List of collections/blogs * - * @param array MUST contain at least the basic display params + * @param string Filter: 'owner', 'public', 'access', 'public_access', 'all' + * @param string Order by + * @param string Order direction: 'ASC', 'DESC' */ function disp_coll_list( $filter = 'public', $order_by = 'ID', $order_dir = 'ASC' ) { @@ -827,13 +829,27 @@ function disp_coll_list( $filter = 'public', $order_by = 'ID', $order_dir = 'ASC */ $BlogCache = & get_BlogCache(); - if( $filter == 'owner' ) - { // Load blogs of same owner - $blog_array = $BlogCache->load_owner_blogs( $Blog->owner_user_ID, $order_by, $order_dir ); - } - else - { // Load all public blogs - $blog_array = $BlogCache->load_public( $order_by, $order_dir ); + switch( $filter ) + { + case 'owner': + // Load collections of same owner: + $blog_array = $BlogCache->load_owner_blogs( $Blog->owner_user_ID, $order_by, $order_dir ); + break; + + case 'all': + // Load all collections: + $blog_array = $BlogCache->load_all( $order_by, $order_dir ); + break; + + case 'access': + case 'public_access': + // Load restricted collections: + $blog_array = $BlogCache->load_restricted_colls( $filter, $order_by, $order_dir ); + break; + + default: // 'public' + // Load all public collections: + $blog_array = $BlogCache->load_public( $order_by, $order_dir ); } // 3.3? if( $this->disp_params['list_type'] == 'list' ) diff --git a/inc/widgets/widgets/_colls_list_public.widget.php b/inc/widgets/widgets/_colls_list_public.widget.php index ca20ebc3abe..566bcccc476 100644 --- a/inc/widgets/widgets/_colls_list_public.widget.php +++ b/inc/widgets/widgets/_colls_list_public.widget.php @@ -50,7 +50,7 @@ function get_help_url() */ function get_name() { - return T_('Public collections list'); + return T_('Collection list'); } @@ -68,7 +68,7 @@ function get_short_desc() */ function get_desc() { - return T_('Display list of all blogs marked as public.'); + return T_('Display list of collections.'); } @@ -103,6 +103,16 @@ function get_param_definitions( $params ) array( 'DESC', T_('Descending') ) ), 'defaultvalue' => 'ASC', ), + 'restrict_public' => array( + 'label' => T_('Restrict to public collections'), + 'type' => 'checkbox', + 'defaultvalue' => '1', + ), + 'restrict_access' => array( + 'label' => T_('Restrict to collections accessible by current user'), + 'type' => 'checkbox', + 'defaultvalue' => '0', + ), /* 3.3? this is borked 'list_type' => array( 'label' => T_( 'Display type' ), @@ -127,7 +137,24 @@ function display( $params ) { $this->init_display( $params ); - $this->disp_coll_list( 'public', $this->disp_params['order_by'], $this->disp_params['order_dir'] ); + if( $this->disp_params['restrict_public'] && $this->disp_params['restrict_access'] ) + { // Restrict to public collections and collections accessible by current user: + $filter = 'public_access'; + } + elseif( $this->disp_params['restrict_public'] ) + { // Restrict only to public collections: + $filter = 'public'; + } + elseif( $this->disp_params['restrict_access'] ) + { // Restrict only to collections accessible by current user: + $filter = 'access'; + } + else + { // Display ALL collections: + $filter = 'all'; + } + + $this->disp_coll_list( $filter, $this->disp_params['order_by'], $this->disp_params['order_dir'] ); return true; } @@ -140,11 +167,14 @@ function display( $params ) */ function get_cache_keys() { - global $Collection, $Blog; + global $current_User; return array( - 'wi_ID' => $this->ID, // Have the widget settings changed ? - 'set_coll_ID' =>'any', // Have the settings of ANY blog changed ? (ex: new skin here, new name on another) + 'wi_ID' => $this->ID, // Have the widget settings changed ? + 'set_coll_ID' =>'any', // Have the settings of ANY blog changed ? (ex: new skin here, new name on another) + 'loggedin' => ( is_logged_in() ? 1 : 0 ), // Is a user logged in at the time this widget is cached/displayed? + 'user_ID' => ( is_logged_in() ? $current_User->ID : 0 ), // Has the current User changed? + 'grp_ID' => ( is_logged_in() ? $current_User->grp_ID : 0 ), // Has a group of the current User changed? ); } } From f0e9f47d5ce2e0dae043a0be98518d92323d40d1 Mon Sep 17 00:00:00 2001 From: yurabakhtin Date: Tue, 4 Jul 2017 17:12:13 +0300 Subject: [PATCH 06/89] Move Private Message to collections --- inc/items/model/_item.class.php | 52 +++++++++++++++++ inc/items/views/_item_expert.form.php | 7 +++ inc/messaging/model/_message.class.php | 24 ++++++++ inc/messaging/model/_thread.class.php | 66 ++++++++++++++++++++++ inc/messaging/views/_message_list.view.php | 44 ++++++++++++++- inc/rest/_restapi.class.php | 1 + skins_fallback_v5/_edit.disp.php | 8 +++ skins_fallback_v6/_edit.disp.php | 8 +++ 8 files changed, 208 insertions(+), 2 deletions(-) diff --git a/inc/items/model/_item.class.php b/inc/items/model/_item.class.php index 7b892a73436..4ec894e6c67 100644 --- a/inc/items/model/_item.class.php +++ b/inc/items/model/_item.class.php @@ -642,6 +642,22 @@ function load_from_Request( $editing = false, $creating = false ) global $default_locale, $current_User, $localtimenow; global $item_typ_ID; + // Try to prefill Item/Post fields from source thread/message ONLY for new creating post: + if( empty( $this->ID ) && param( 'thrd_ID', 'integer', NULL ) !== NULL ) + { // If new post is moving from a private message: + $ThreadCache = & get_ThreadCache(); + $source_Thread = & $ThreadCache->get_by_ID( get_param( 'thrd_ID' ), false, false ); + if( $source_Thread && $source_Thread->can_be_moved_to_collection( $this->get_blog_ID() ) ) + { // If given Thread can be moved to current collection: + $source_Message = & $source_Thread->get_first_Message(); + $source_message_author_User = & $source_Message->get_author_User(); + $this->set( 'title', $source_Thread->get( 'title' ) ); + $this->set( 'content', $source_Message->get( 'text' ) ); + $this->set_creator_User( $source_message_author_User ); + $this->set_renderers( $source_Message->get_renderers() ); + } + } + // LOCALE: if( param( 'post_locale', 'string', NULL ) !== NULL ) { @@ -6090,6 +6106,9 @@ function dbinsert() // Update last touched date of this Item and also all categories of this Item $this->update_last_touched_date( false, false ); + + // Send notification after creating new post from thread: + $this->send_moved_thread_notification(); } if( ! $result ) @@ -7467,6 +7486,39 @@ function send_outbound_pings( $force_pings = false ) } + /** + * Send notification when new post is created from thread + */ + function send_moved_thread_notification() + { + $thrd_ID = param( 'thrd_ID', 'integer', NULL ); + + if( empty( $thrd_ID ) ) + { // Thread ID must be passed from a submitted form + return false; + } + + $ThreadCache = & get_ThreadCache(); + $source_Thread = & $ThreadCache->get_by_ID( $thrd_ID, false, false ); + if( ! $source_Thread || + ! $source_Thread->can_be_moved_to_collection( $this->get_blog_ID() ) ) + { // Wrong Thread, because it can not be moved to collection of this Item: + return false; + } + + $item_Blog = & $this->get_Blog(); + + // Insert new private message to inform author thread: + $notif_Message = new Message(); + $notif_Message->set( 'thread_ID', $thrd_ID ); + $notif_Message->set( 'text', sprintf( T_('Automatic notification: your question has been published to "%s": %s'), + $item_Blog->get( 'shortname' ), + $this->get_permanent_url() ) ); + + return $notif_Message->dbinsert_message(); + } + + /** * Callback user for footer() */ diff --git a/inc/items/views/_item_expert.form.php b/inc/items/views/_item_expert.form.php index 95155b1a6ff..40b82e299fc 100644 --- a/inc/items/views/_item_expert.form.php +++ b/inc/items/views/_item_expert.form.php @@ -90,6 +90,13 @@ $Form->hidden( 'p', $original_item_ID ); } + // Try to get the thread ID (For example, on moving a thread to collection): + $thrd_ID = get_param( 'thrd_ID' ); + if( ! empty( $thrd_ID ) ) + { + $Form->hidden( 'thrd_ID', $thrd_ID ); + } + $Form->hidden( 'redirect_to', $redirect_to ); // In case we send this to the blog for a preview : diff --git a/inc/messaging/model/_message.class.php b/inc/messaging/model/_message.class.php index d0db0f2243b..ff350058614 100644 --- a/inc/messaging/model/_message.class.php +++ b/inc/messaging/model/_message.class.php @@ -57,6 +57,13 @@ class Message extends DataObject */ var $Thread; + /** + * Author User of this Message + * + * @var instance of User class + */ + var $author_User; + /** * Constructor @@ -1410,6 +1417,23 @@ function get_files( $params = array(), $format = 'htmlbody' ) return $r; } + + + /** + * Get author User of this Message + * + * @return object User + */ + function & get_author_User() + { + if( ! isset( $this->author_User ) ) + { // Try to get author User only first time: + $UserCache = & get_UserCache(); + $this->author_User = & $UserCache->get_by_ID( $this->author_user_ID, false, false ); + } + + return $this->author_User; + } } ?> \ No newline at end of file diff --git a/inc/messaging/model/_thread.class.php b/inc/messaging/model/_thread.class.php index 0cd60135a8c..92f5db2e35a 100644 --- a/inc/messaging/model/_thread.class.php +++ b/inc/messaging/model/_thread.class.php @@ -581,6 +581,72 @@ function check_allow_reply() param_error( '', T_( 'The recipient(s) do not want you to contact them at this time.' ) ); return false; } + + + /** + * Get first Message of this Thread + * + * @return object Message + */ + function & get_first_Message() + { + if( ! isset( $this->first_Message ) ) + { // Initialize first Message: + if( empty( $this->ID ) ) + { // Thread must be store in DB: + $this->first_Message = false; + return $this->first_Message; + } + + global $DB; + + $MessageCache = get_MessageCache(); + $MessageCache->clear(); + + // Load only first Message: + $SQL = $MessageCache->get_SQL_object( 'Get first Message of Thread #'.$this->ID ); + $SQL->WHERE( 'msg_thread_ID = '.$this->ID ); + $SQL->ORDER_BY( 'msg_datetime ASC' ); + $SQL->LIMIT( 1 ); + $messages = $MessageCache->load_by_sql( $SQL ); + $this->first_Message = isset( $messages[0] ) ? $messages[0] : false; + } + + return $this->first_Message; + } + + + /** + * Check if this Thread can be moved to collection by current User + * + * @param integer Collection ID + * @return boolean + */ + function can_be_moved_to_collection( $blog_ID ) + { + global $current_User; + + if( ! is_logged_in() ) + { // Current User must be logged in: + return false; + } + + if( ! $this->check_thread_recipient( $current_User->ID ) && + ! $current_User->check_perm( 'perm_messaging', 'abuse' ) ) + { // Don't allow if current user is NOT a recipient of this Thread AND he has no permission to edit all threads: + return false; + } + + $first_Message = & $this->get_first_Message(); + $message_author_User = & $first_Message->get_author_User(); + + if( ! $message_author_User->check_perm( 'blog_post_statuses', 'edit', false, $blog_ID ) ) + { // Don't allow if first message's author has no permission to add a post with any status to the given collection: + return false; + } + + return true; + } } ?> \ No newline at end of file diff --git a/inc/messaging/views/_message_list.view.php b/inc/messaging/views/_message_list.view.php index 93421b32654..258e897507b 100644 --- a/inc/messaging/views/_message_list.view.php +++ b/inc/messaging/views/_message_list.view.php @@ -14,7 +14,7 @@ */ if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); -global $dispatcher, $action, $current_User, $Collection, $Blog, $perm_abuse_management, $Plugins, $edited_Message; +global $dispatcher, $action, $current_User, $Collection, $Blog, $perm_abuse_management, $Plugins, $edited_Message, $admin_url; // in front office there is no function call, $edited_Thread is available if( !isset( $edited_Thread ) ) @@ -391,6 +391,7 @@ function filter_messages( & $Form ) { // user want's to close this conversation ( there is only one recipient ) echo ' '.$block_text.''; } + echo ' '.get_icon( 'copy', 'imgtag', array( 'title' => T_('Move to a collection...') ) ).' '.T_('Move to a collection...').''; echo '

'; echo ''; } @@ -415,4 +416,43 @@ function filter_messages( & $Form ) echo $params['messages_list_end']; -?> \ No newline at end of file +// Initialize JavaScript to build and open window: +echo_modalwindow_js(); + +if( is_admin_page() ) +{ // New item URL for back-office: + $new_item_url = $admin_url.'?ctrl=items&action=new&thrd_ID='.$edited_Thread->ID.'&blog=\' + coll.id + \''; +} +else +{ // New item URL for front-office: + $new_item_url = '\' + coll.url + ( coll.url.indexOf( \'?\' ) > 0 ? \'&\' : \'?\' ) + \'disp=edit&thrd_ID='.$edited_Thread->ID; +} +?> + \ No newline at end of file diff --git a/inc/rest/_restapi.class.php b/inc/rest/_restapi.class.php index 253f6b26d05..4e8736a539d 100644 --- a/inc/rest/_restapi.class.php +++ b/inc/rest/_restapi.class.php @@ -560,6 +560,7 @@ private function controller_coll_() 'name' => $Blog->get( 'name' ), 'tagline' => $Blog->get( 'tagline' ), 'desc' => $Blog->get( 'longdesc' ), + 'url' => $Blog->get( 'url' ), ), 'array' ); } } diff --git a/skins_fallback_v5/_edit.disp.php b/skins_fallback_v5/_edit.disp.php index a28ba1e7c03..837ea3e6577 100644 --- a/skins_fallback_v5/_edit.disp.php +++ b/skins_fallback_v5/_edit.disp.php @@ -93,6 +93,14 @@ $Form->hidden( 'post_ID', $edited_Item->ID ); } } + + // Try to get the thread ID (For example, on moving a thread to collection): + $thrd_ID = get_param( 'thrd_ID' ); + if( ! empty( $thrd_ID ) ) + { + $Form->hidden( 'thrd_ID', $thrd_ID ); + } + $Form->hidden( 'redirect_to', $redirect_to ); // In case we send this to the blog for a preview : diff --git a/skins_fallback_v6/_edit.disp.php b/skins_fallback_v6/_edit.disp.php index 0441ae8e110..7d15dd35a5b 100644 --- a/skins_fallback_v6/_edit.disp.php +++ b/skins_fallback_v6/_edit.disp.php @@ -92,6 +92,14 @@ $Form->hidden( 'post_ID', $edited_Item->ID ); } } + + // Try to get the thread ID (For example, on moving a thread to collection): + $thrd_ID = get_param( 'thrd_ID' ); + if( ! empty( $thrd_ID ) ) + { + $Form->hidden( 'thrd_ID', $thrd_ID ); + } + $Form->hidden( 'redirect_to', $redirect_to ); // In case we send this to the blog for a preview : From 532c85ad573a7f9398e6972182bc5809f4085333 Mon Sep 17 00:00:00 2001 From: yurabakhtin Date: Wed, 5 Jul 2017 12:03:06 +0300 Subject: [PATCH 07/89] Restrict collections list of creating new post from thread with author and current user permissions --- inc/messaging/views/_message_list.view.php | 34 +++- inc/rest/_restapi.class.php | 183 +++++++++++++++------ 2 files changed, 160 insertions(+), 57 deletions(-) diff --git a/inc/messaging/views/_message_list.view.php b/inc/messaging/views/_message_list.view.php index 258e897507b..84efce24cde 100644 --- a/inc/messaging/views/_message_list.view.php +++ b/inc/messaging/views/_message_list.view.php @@ -427,29 +427,47 @@ function filter_messages( & $Form ) { // New item URL for front-office: $new_item_url = '\' + coll.url + ( coll.url.indexOf( \'?\' ) > 0 ? \'&\' : \'?\' ) + \'disp=edit&thrd_ID='.$edited_Thread->ID; } + +// Use current User and User of first Message to restrict collections list where new post can be created from Thread: +$restrict_users = $current_User->ID; +if( $first_Message = & $edited_Thread->get_first_Message() && + $first_message_User = & $first_Message->get_author_User() && + $first_message_User->ID != $current_User->ID ) +{ + $restrict_users .= ','.$first_message_User->ID; +} ?> "}r+="",n&&(r+='"),r+="",jQuery("body").append(r)}else jQuery("#modal_window .modal-body").html(a);"undefined"!=typeof i?jQuery("#"+i).load(function(){prepareModalWindow(jQuery(this).contents(),q,n,h),jQuery("#modal_window .loader_img").remove(),jQuery("#"+i).show()}):prepareModalWindow("#modal_window",q,n,h);var s={};modal_window_js_initialized&&(s="show"),jQuery("#modal_window").modal(s),""==j&&(jQuery("#modal_window .modal-dialog").css({display:"table",width:"auto"}),jQuery("#modal_window .modal-dialog .modal-content").css({display:"table-cell"})),jQuery("#modal_window").on("hidden",function(){jQuery(this).remove()}),modal_window_js_initialized=!0}function prepareModalWindow(a,b,c,d){c&&("undefined"!=typeof d&&d||(jQuery("legend",a).remove(),jQuery("#close_button",a).remove(),jQuery(".panel, .panel-body",a).removeClass("panel panel-default panel-body")),0==jQuery(b+" input[type=submit]",a).length?jQuery("#modal_window .modal-footer button[type=submit]").hide():(jQuery(b+" input[type=submit]",a).hide(),jQuery("#modal_window .modal-footer button[type=submit]").show()),jQuery(b,a).change(function(){var a=jQuery(this).find("input[type=submit]");a.length>0?(a.hide(),jQuery("#modal_window .modal-footer button[type=submit]").show()):jQuery("#modal_window .modal-footer button[type=submit]").hide()}),jQuery("#modal_window .modal-footer button[type=submit]").click(function(){jQuery(b+" input[type=submit]",a).click()})),jQuery(b+" a.btn",a).each(function(){jQuery("#modal_window .modal-footer").prepend(""),jQuery(this).remove()}),jQuery(b+" #current_modal_title",a).length>0&&jQuery("#modal_window .modal-title").html(jQuery(b+" #current_modal_title",a).html())}function closeModalWindow(a){return"undefined"==typeof a&&(a=window.document),jQuery("#modal_window",a).modal("hide"),!1}function setModalIFrameUnload(a){var b=jQuery("#"+a);b[0].contentWindow.onunload=function(){var a=b.closest(".modal-body"),c=jQuery('');jQuery(a).prepend(c)}}function user_crop_avatar(a,b,c){"undefined"==typeof c&&(c="avatar");var d=750,e=320,f=jQuery(window).width(),g=jQuery(window).height(),h=f,i=g,j=i/h;i=i>d?d:e>i?e:i,h=h>d?d:e>h?e:h;var k=10,l=10;k=h-2*k>e?10:0,l=i-2*l>e?10:0;var m=h>d?d:h,n=i>d?d:i;openModalWindow('',m+"px",n+"px",!0,evo_js_lang_crop_profile_pic,[evo_js_lang_crop,"btn-primary"],!0);var o=jQuery("div.modal-dialog div.modal-body").length?jQuery("div.modal-dialog div.modal-body"):jQuery("#overlay_page"),p={top:parseInt(o.css("paddingTop")),right:parseInt(o.css("paddingRight")),bottom:parseInt(o.css("paddingBottom")),left:parseInt(o.css("paddingLeft"))},q=(jQuery("div.modal-dialog div.modal-body").length?parseInt(o.css("min-height")):n-100)-(p.top+p.bottom),r=m-(p.left+p.right),s={user_ID:a,file_ID:b,aspect_ratio:j,content_width:r,content_height:q,display_mode:"js",crumb_user:evo_js_crumb_user};return evo_js_is_backoffice?(s.ctrl="user",s.user_tab="crop",s.user_tab_from=c):(s.blog=evo_js_blog,s.disp="avatar",s.action="crop"),jQuery.ajax({type:"POST",url:evo_js_user_crop_ajax_url,data:s,success:function(a){openModalWindow(a,m+"px",n+"px",!0,evo_js_lang_crop_profile_pic,[evo_js_lang_crop,"btn-primary"])}}),!1}function user_report(a,b){openModalWindow('',"auto","",!0,evo_js_lang_report_user,[evo_js_lang_report_this_user_now,"btn-danger"],!0);var c={action:"get_user_report_form",user_ID:a,crumb_user:evo_js_crumb_user};return evo_js_is_backoffice?(c.is_backoffice=1,c.user_tab=b):c.blog=evo_js_blog,jQuery.ajax({type:"POST",url:evo_js_user_report_ajax_url,data:c,success:function(a){openModalWindow(a,"auto","",!0,evo_js_lang_report_user,[evo_js_lang_report_this_user_now,"btn-danger"])}}),!1}function user_deldata(a,b){return openModalWindow('',"auto","",!0,evo_js_lang_delete_user_data,[evo_js_lang_delete_selected_data,"btn-danger"],!0),jQuery.ajax({type:"POST",url:evo_js_user_deldata_ajax_url,data:{ctrl:"user",user_tab:"deldata",user_tab_from:b,user_ID:a,display_mode:"js",crumb_user:evo_js_crumb_user},success:function(a){openModalWindow(a,"auto","",!0,evo_js_lang_delete_user_data,[evo_js_lang_delete_selected_data,"btn-danger"])}}),!1}function user_add_org(a){return openModalWindow('',"450px","",!0,evo_js_lang_add_user_to_organization,evo_js_lang_add,!0),jQuery.ajax({type:"POST",url:evo_js_user_org_ajax_url,data:{ctrl:"organizations",action:"add_user",org_ID:a,display_mode:"js",crumb_user:evo_js_crumb_organization},success:function(a){openModalWindow(a,"450px","",!0,evo_js_lang_add_user_to_organization,evo_js_lang_add),jQuery("input.autocomplete_login").trigger("added")}}),!1}function user_edit(a,b){return openModalWindow('',"450px","",!0,evo_js_lang_edit_membership,evo_js_lang_edit,!0),jQuery.ajax({type:"POST",url:evo_js_user_org_ajax_url,data:{ctrl:"organizations",action:"edit_user",org_ID:a,user_ID:b,display_mode:"js",crumb_user:evo_js_crumb_organization},success:function(a){openModalWindow(a,"450px","",!0,evo_js_lang_edit_membership,evo_js_lang_edit)}}),!1}function user_remove(a,b){return openModalWindow('',"450px","",!0,''+evo_js_lang_remove_user_membership+"",evo_js_lang_remove,!0),jQuery.ajax({type:"POST",url:evo_js_user_org_ajax_url,data:{ctrl:"organizations",action:"remove_user",org_ID:a,user_ID:b,display_mode:"js",crumb_user:evo_js_crumb_organization},success:function(a){openModalWindow(a,"450px","",!0,''+evo_js_lang_remove_user_membership+"",evo_js_lang_remove)}}),!1}function evo_rest_api_request(url,params_func,func_method,method){var params=params_func,func=func_method;"function"==typeof params_func&&(func=params_func,params={},method=func_method),"undefined"==typeof method&&(method="GET"),jQuery.ajax({contentType:"application/json; charset=utf-8",type:method,url:restapi_url+url,data:params}).then(function(data,textStatus,jqXHR){"object"==typeof jqXHR.responseJSON&&eval(func)(data,textStatus,jqXHR)})}function evo_link_fix_wrapper_height(){var a=jQuery("#attachments_fieldset_table").height(),b=jQuery("#attachments_fieldset_wrapper").height();b!=a&&jQuery("#attachments_fieldset_wrapper").height(jQuery("#attachments_fieldset_table").height())}function evo_link_change_position(a,b,c){var d=a,e=a.value;return jQuery.get(b+"anon_async.php?action=set_object_link_position&link_ID="+a.id.substr(17)+"&link_position="+e+"&crumb_link="+c,{},function(b,c){b=ajax_debug_clear(b),"OK"==b?(evoFadeSuccess(jQuery(d).closest("tr")),jQuery(d).closest("td").removeClass("error"),"cover"==e&&jQuery("select[name=link_position][id!="+a.id+"] option[value=cover]:selected").each(function(){jQuery(this).parent().val("aftermore"),evoFadeSuccess(jQuery(this).closest("tr"))})):(jQuery(d).val(b),evoFadeFailure(jQuery(d).closest("tr")),jQuery(d.form).closest("td").addClass("error"))}),!1}function evo_link_insert_inline(a,b,c){if("undefined"!=typeof b2evoCanvas){var d="["+a+":"+b;c.length&&(d+=":"+c),d+="]",textarea_wrap_selection(b2evoCanvas,d,"",0,window.document);var e=jQuery("#display_position_"+b);0!=e.length&&"inline"!=e.val()&&(deferInlineReminder=!0,e.val("inline").change(),deferInlineReminder=!1)}}function evo_link_delete(a,b,c,d){return evo_rest_api_request("links/"+c,{action:d},function(d){if("item"==b){var e=window.document.getElementById("itemform_post_content");if(null!=e){var f=new RegExp("\\[(image|file|inline|video|audio|thumbnail):"+c+":?[^\\]]*\\]","ig");textarea_str_replace(e,f,"",window.document)}}jQuery(a).closest("tr").remove(),evo_link_fix_wrapper_height()},"DELETE"),!1}function evo_link_change_order(a,b,c){return evo_rest_api_request("links/"+b+"/"+c,function(b){var d=jQuery(a).closest("tr");"move_up"==c?d.prev().before(d):d.next().after(d),evoFadeSuccess(d)},"POST"),!1}function evo_link_attach(a,b,c,d){return evo_rest_api_request("links",{action:"attach",type:a,object_ID:b, -root:c,path:d},function(a){var b=jQuery("#attachments_fieldset_table table",window.parent.document),c=(b.parent,jQuery(a.list_content));b.replaceWith(jQuery("table",c)).promise().done(function(a){setTimeout(function(){window.parent.evo_link_fix_wrapper_height()},10)})}),!1}function evo_link_ajax_loading_overlay(){var a=jQuery("#attachments_fieldset_table"),b=!1;return 0==a.find(".results_ajax_loading").length&&(b=jQuery('
 
'),a.css("position","relative"),b.css({width:a.width(),height:a.height()}),a.append(b)),b}function evo_link_refresh_list(a,b,c){var d=evo_link_ajax_loading_overlay();return d&&evo_rest_api_request("links",{action:"undefined"==typeof c?"refresh":"sort",type:a,object_ID:b},function(a){jQuery("#attachments_fieldset_table").html(a.html),d.remove(),evo_link_fix_wrapper_height()}),!1}b2evo_Callbacks.prototype={register_callback:function(a,b,c){"undefined"==typeof this.eventHandlers[a]&&(this.eventHandlers[a]=new Array),"undefined"!=typeof c&&c?this.eventHandlers[a][0]=b:this.eventHandlers[a][this.eventHandlers[a].length]=b},trigger_callback:function(event,args){if("undefined"==typeof this.eventHandlers[event])return null;for(var r=!1,cb_args="",cb_arguments=arguments,i=1;i-1?a[c]=window[a[c]]:" "==a[c]?a[c]="":a[c]=a[c].replace(/\\\|/g,"|");return jQuery(this).closest(".disabled[class*=_toolbar]").length>0?!1:(window[b].apply(null,a),!1)}),jQuery('input[type=checkbox][name="renderers[]"]').each(function(){a(jQuery(this))}),jQuery('input[type=checkbox][name="renderers[]"]').click(function(){a(jQuery(this))})}),jQuery(document).ready(function(){jQuery(".pblock").length?jQuery('
').prependTo(".pblock"):jQuery(".level2").length?jQuery(".level2").after('
'):jQuery(".navbar.level1").after('
'),jQuery('').appendTo("body").css({position:"absolute",left:"-1000em",top:"-1000em"})});var _b2evoCommunications=function(){var a,b,c=2500,d=250;return{Init:function(){var e=jQuery.fn.extend({delay:c,interval:d,dispatcher:b},arguments.length?arguments[0]:"");c=e.delay,d=e.interval,b=e.dispatcher,a=this,b2evoHelper.info("Communications object ready")},BufferedServerCall:function(){var b=jQuery.fn.extend({ticker_callback:function(){return!0},send_callback:function(){},delay:c,interval:d,buffer_name:""},arguments.length?arguments[0]:"");if(ticker_status=b.ticker_callback(b.delay))switch(ticker_status!==!0&&b2evoHelper.log("Ticker status : "+ticker_status),ticker_status){case"cancel":return void b2evoHelper.DisplayMessage('
'+T_("Update cancelled")+"
");case"pause":return b2evoHelper.DisplayMessage('
'+T_("Update Paused")+" : "+b2evoHelper.str_repeat(".",b.delay/b.interval)+"
"),void a.BufferedServerLoop(b);case"ignore":return void a.BufferedServerLoop(b);case"immediate":break;default:if(b.delay-=b.interval,b.delay>0)return b2evoHelper.DisplayMessage('
'+T_("Changes pending")+" : "+b2evoHelper.str_repeat(".",b.delay/b.interval)+"
"),void a.BufferedServerLoop(b);b2evoHelper.DisplayMessage('
'+T_("Saving changes")+"
"),b.send_callback()}},BufferedServerLoop:function(b){var c=jQuery(a).data("buffers");"undefined"==typeof c&&(c=Array()),c[b.buffer_name]=b,jQuery(a).data("buffers",c),window.setTimeout('b2evoCommunications.BufferedServerCallback( "'+b.buffer_name+'" )',b.interval)},BufferedServerCallback:function(b){var c=jQuery(a).data("buffers");a.BufferedServerCall(c[b])},SendAdminRequest:function(){var c=jQuery.fn.extend({ctrl:"",action:"",data:"",key:"",error:function(){return!1},ok:function(){return!1}},arguments.length?arguments[0]:""),d="ctrl="+c.ctrl+"&key="+c.key+"&action="+c.action+"&"+c.data;a.SendServerRequest({url:b,data:d,error:c.error,ok:c.ok})},SendServerRequest:function(){var a=jQuery.fn.extend({url:"",data:"",error:function(){return!1},ok:function(){return!1}},arguments.length?arguments[0]:"");if(a.url){a.url+=(a.url.indexOf("?")===!0?"&":"?")+"mode=js",a.data&&(a.url+="&"+a.data);var b=jQuery('');b.attr("src",a.url),b.load(a.ok()),b.error(a.error()),b.appendTo("body"),b2evoHelper.log("Sending request : "+a.url)}}}},b2evoCommunications=new _b2evoCommunications;jQuery(document).ready(function(){jQuery("[id^=fadeout-]").each(function(){evoFadeBg(this,new Array("#FFFF33"),{speed:3e3})})}),jQuery(document).on("change",".btn-file :file",function(){var a=jQuery(this).val().replace(/\\/g,"/").replace(/.*\//,"");jQuery(this).parent().next().html(a)});var edit_icon_tag="",delete_icon_tag="",current_widgets="",reorder_widgets_queue,reorder_delay=200,reorder_delay_remaining=0,crumb_url="";jQuery(document).ready(function(){if(0!=jQuery("#current_widgets").length){edit_icon_tag=jQuery(".edit_icon_hook").find("a").html(),delete_icon_tag=jQuery(".delete_icon_hook").find("a").html(),crumb_url=jQuery(".delete_icon_hook").find("a").attr("href"),"undefined"!=typeof crumb_url&&(crumb_url=crumb_url.match(/crumb_.*?$/)),jQuery(".new_widget").parent().parent().remove(),jQuery(".odd").addClass("widget_row").removeClass(".odd"),jQuery(".even").addClass("widget_row").removeClass(".even"),jQuery(".fieldset_title").each(function(){jQuery(this).droppable({accept:".draggable_widget",hoverClass:"droppable-hover",greedy:!0,tolerance:"pointer",delay:1e3,drop:function(a,b){jQuery(".fade_me").removeClass("fade_me"),jQuery(".available_widgets").removeClass("available_widgets_active"),jQuery(b.draggable).prependTo(jQuery("#container_"+jQuery(this).find(".container_name").html().replace(/ /g,"_").replace(/:/g,"-"))),jQuery(b.draggable).addClass("fade_me server_update"),jQuery(b.draggable).droppable("enable"),doFade(".fade_me"),colourWidgets(),sendWidgetOrder()}})}),jQuery(".widget_row td:nth-child(7)").each(function(){var a=jQuery(this).find("a").attr("href");a=a.match(/wi_ID=([0-9]+)/)[1],jQuery(this).parent().attr("id","wi_ID_"+a)});var a=new Array;jQuery(".widget_container_list").each(function(){var b=jQuery(this).attr("id");a[b]=new Array,jQuery("#"+b+" .widget_row").each(function(){var c=jQuery(this).attr("id");a[b][c]=new Array,a[b][c].name=jQuery("#"+c).find(".widget_name").parent().html(),a[b][c]["class"]=jQuery(this).attr("className"),a[b][c].enabled=jQuery("#"+c+" .widget_is_enabled").size(),a[b][c].cache=jQuery("#"+c+" .widget_cache_status [rel]").attr("rel")})});for(container in a){var b=!jQuery("#"+container).hasClass("no-drop");newContainer=jQuery('
    '),b||jQuery(newContainer).addClass("no-drop"),jQuery("#"+container).replaceWith(newContainer);for(widget in a[container])createWidget(widget,container,0,a[container][widget].name,a[container][widget]["class"],a[container][widget].enabled,a[container][widget].cache)}jQuery(".no-drop .draggable_widget").droppable("disable"),jQuery(".draggable_widget").bind("mousedown",function(){jQuery(this).hasClass("new_widget")||jQuery(".available_widgets_active").removeClass("available_widgets_active")}),colourWidgets(),convertAvailableList(),current_widgets=getWidgetOrder(),doFade(".fadeout-ffff00"),jQuery("#widget_button_check_all").click(function(){jQuery(this).closest("form").find("input[type=checkbox]").prop("checked",!0)}),jQuery("#widget_button_uncheck_all").click(function(){jQuery(this).closest("form").find("input[type=checkbox]").prop("checked",!1)}),jQuery("#widget_button_check_active").click(function(){jQuery(this).closest("form").find(".widget_checkbox.widget_checkbox_enabled input[type=checkbox]").prop("checked",!0),jQuery(this).closest("form").find(".widget_checkbox:not(.widget_checkbox_enabled) input[type=checkbox]").prop("checked",!1)}),jQuery("#widget_button_check_inactive").click(function(){jQuery(this).closest("form").find(".widget_checkbox.widget_checkbox_enabled input[type=checkbox]").prop("checked",!1),jQuery(this).closest("form").find(".widget_checkbox:not(.widget_checkbox_enabled) input[type=checkbox]").prop("checked",!0)}),jQuery(document).keyup(function(a){27==a.keyCode&&(closeWidgetSettings(),closeAvailableWidgets())})}});var modal_window_js_initialized=!1;jQuery(document).ready(function(){jQuery("img.loadimg").each(function(){jQuery(this).prop("complete")?(jQuery(this).removeClass("loadimg"),""==jQuery(this).attr("class")&&jQuery(this).removeAttr("class")):jQuery(this).on("load",function(){jQuery(this).removeClass("loadimg"),""==jQuery(this).attr("class")&&jQuery(this).removeAttr("class")})})}),jQuery(document).ready(function(){if(jQuery("#attachments_fieldset_table").length>0){var a=jQuery("#attachments_fieldset_table").height();a=a>320?320:97>a?97:a,jQuery("#attachments_fieldset_wrapper").height(a),jQuery("#attachments_fieldset_wrapper").resizable({minHeight:80,handles:"s",resize:function(a,b){jQuery("#attachments_fieldset_wrapper").resizable("option","maxHeight",jQuery("#attachments_fieldset_table").height())}}),jQuery(document).on("click","#attachments_fieldset_wrapper .ui-resizable-handle",function(){var a=jQuery("#attachments_fieldset_table").height(),b=jQuery("#attachments_fieldset_wrapper").height()+80;jQuery("#attachments_fieldset_wrapper").css("height",b>a?a:b)})}}); \ No newline at end of file +function pop_up_window(a,b,c,d,e){void 0===c&&(c=750),void 0===d&&(d=550);var f=(screen.width-c)/2,g=(screen.height-d)/2;return void 0===e&&(e="scrollbars=yes, status=yes, resizable=yes, menubar=yes"),e="width="+c+", height="+d+", left="+f+", top="+g+", "+e,opened=window.open(a,b,e),opened.focus(),"undefined"==typeof openedWindows?openedWindows=new Array(opened):openedWindows.push(opened),!1}function textarea_replace_selection(a,b,c){textarea_wrap_selection(a,b,"",1,c)}function textarea_wrap_selection(a,b,c,d,e){e=e||document;var f={element:a,before:b,after:c,replace:d,target_document:e};if(!b2evo_Callbacks.trigger_callback("wrap_selection_for_"+a.id,f)){if(window.opener&&void 0!==window.opener)try{if(window.opener.b2evo_Callbacks&&void 0!==window.opener.b2evo_Callbacks&&window.opener.b2evo_Callbacks.trigger_callback("wrap_selection_for_"+a.id,f))return}catch(a){}if(!(window.parent&&void 0!==window.parent&&window.parent.b2evo_Callbacks&&void 0!==window.parent.b2evo_Callbacks&&window.parent.b2evo_Callbacks.trigger_callback("wrap_selection_for_"+a.id,f)))if(e.selection)a.focus(),sel=e.selection.createRange(),sel.text=d?b+c:b+sel.text+c,a.focus();else if(a.selectionStart||"0"==a.selectionStart){var g,h,i,j=a.selectionStart,k=a.selectionEnd;"textarea"==a.type&&void 0!==a.scrollTop&&(h=a.scrollTop,i=a.scrollLeft),d?(a.value=a.value.substring(0,j)+b+c+a.value.substring(k,a.value.length),g=j+b.length+c.length):(a.value=a.value.substring(0,j)+b+a.value.substring(j,k)+c+a.value.substring(k,a.value.length),g=k+b.length+c.length),void 0!==h&&(a.scrollTop=h,a.scrollLeft=i),a.focus(),a.selectionStart=g,a.selectionEnd=g}else a.value+=b+c,a.focus()}}function textarea_str_replace(a,b,c,d){d=d||document;var e={element:a,search:b,replace:c,target_document:d};if(!b2evo_Callbacks.trigger_callback("str_replace_for_"+a.id,e)){if(window.opener&&void 0!==window.opener)try{if(window.opener.b2evo_Callbacks&&void 0!==window.opener.b2evo_Callbacks&&window.opener.b2evo_Callbacks.trigger_callback("str_replace_for_"+a.id,e))return}catch(a){}window.parent&&void 0!==window.parent&&window.parent.b2evo_Callbacks&&void 0!==window.parent.b2evo_Callbacks&&window.parent.b2evo_Callbacks.trigger_callback("str_replace_for_"+a.id,e)||(a.value=a.value.replace(b,c),a.focus())}}function toggle_filter_area(a){var b=jQuery("#clickdiv_"+a),c=jQuery("#clickimg_"+a);if(0==b.length||0==c.length)return alert("ID "+a+" not found!"),!1;if(c.hasClass("fa")||c.hasClass("glyphicon")){if(""!=c.data("toggle")&&void 0!=c.data("toggle")){var d=c.hasClass("fa")?"fa":"glyphicon";void 0==c.data("toggle-orig-class")&&c.data("toggle-orig-class",c.attr("class").replace(new RegExp("^"+d+" (.+)$","g"),"$1")),c.hasClass(c.data("toggle-orig-class"))?c.removeClass(c.data("toggle-orig-class")).addClass(d+"-"+c.data("toggle")):c.removeClass(d+"-"+c.data("toggle")).addClass(c.data("toggle-orig-class"))}}else{var e=c.css("background-position").match(/-*\d+/g);c.css("background-position",parseInt(e[0])+(b.is(":hidden")?-16:16)+"px "+parseInt(e[1])+"px")}return b.is(":hidden")?(b.slideDown(500),jQuery.post(htsrv_url+"anon_async.php?action=expand_filter&target="+a)):(b.slideUp(500),jQuery.post(htsrv_url+"anon_async.php?action=collapse_filter&target="+a)),!1}function b2evo_Callbacks(){this.eventHandlers=new Array}function evoAlert(a){var b=jQuery(".b2evo_alert");b.length>0&&b.remove(),jQuery("body").append('
    '+a+"
    "),setTimeout(function(){jQuery(".b2evo_alert").fadeOut({complete:function(){jQuery(this).remove()}})},3e3),evo_alert_events_initialized||(evo_alert_events_initialized=!0,jQuery(document).on("click",".b2evo_alert",function(){jQuery(this).remove()}))}function ajax_debug_clear(a){var b=//;return a=a.replace(b,""),a=a.replace(/(
    [\s\S]*)/i,""),jQuery.trim(a)}function ajax_response_is_correct(a){var b=//;return!!a.match(b)&&""!=(a=ajax_debug_clear(a))}function SendAdminRequest(a,b,c,d){if(void 0===d||d){var e=new Date;c+=(""!==c?"&":"")+"nocache_dummy="+e.getTime()}SendServerRequest(b2evo_dispatcher_url+"?ctrl="+a+"&action="+b+(c?"&"+c:""))}function SendServerRequest(a){a+=-1!=a.indexOf("?")?"&":"?",a+="display_mode=js";var b=a.split("?");a=b[0],b=b[1],jQuery.ajax({type:"POST",url:a,data:b,dataType:"script"})}function AttachServerRequest(a){jQuery('').appendTo("#"+a),jQuery("#"+a).attr("target","server_postback")}function DisplayServerMessages(a,b){jQuery("#server_messages").html(a),"object"==typeof b&&(jQuery("input.field_error, select.field_error, textarea.field_error").each(function(){jQuery(this).removeClass("field_error");var a=jQuery(this).next();a.hasClass("notes")&&"SPAN"==a.get(0).tagName&&a.remove()}),jQuery.each(b,function(a,b){jQuery("#"+a).addClass("field_error").after(' '+b+"")})),jQuery("#server_messages .log_success").animate({backgroundColor:"#88ff88"},"fast").animate({backgroundColor:"#ffffff"},"fast","",function(){jQuery(this).removeAttr("style")}),jQuery("#server_messages > .log_error").animate({backgroundColor:"#ff8888"},"fast").animate({backgroundColor:"#ffffff"},"fast","",function(){jQuery(this).removeAttr("style")})}function get_form(a){for(;"FORM"!=a.tagName;){if(void 0===a)return!1;a=a.parentNode}return a}function check(a,b){if(form_obj=get_form(a),!form_obj)return alert("Could not find form"),!1;for(i=0;i'),f=!0):a.elements.namedItem("actionArray[create]")?(jQuery(a).append(''),f=!0):(jQuery(a).append(''),f=!0),f&&void 0!==d)for(param in d)jQuery(a).append('');return void 0!==c&&"undefined"!=c&&(null==c&&(c=""),a.elements.blog.value=c),window.onbeforeunload=null,void 0!==e&&1==e&&a.reset(),a.submit(),!1}function b2edit_type(a,b,c){var d=!1;return bozo.nb_changes>0&&(d=!confirm(a)),b2edit_reload(document.getElementById("item_checkchanges"),b,null,{action:c},d)}function b2edit_confirm(a,b,c){return!(bozo.nb_changes>0&&!confirm(a))&&b2edit_reload(document.getElementById("item_checkchanges"),b,null,{action:c},!1)}function makeDragnDrop(a){makeDraggable(a),makeDroppable(a)}function makeDraggable(a){jQuery(a).draggable({helper:"clone",scroll:!0,scrollSensitivity:100,zIndex:999,opacity:.8,cursor:"move",cancel:"input,textarea,button,select,option,a,span.fa,span.widget_checkbox",start:function(){jQuery(this).hide()},stop:function(){jQuery(this).show()}}).addClass("draggable_widget")}function makeDroppable(a){jQuery(a).droppable({accept:".draggable_widget",hoverClass:"droppable-hover",greedy:!0,tolerance:"pointer",delay:1e3,drop:function(a,b){jQuery(".fade_me").removeClass("fade_me"),jQuery(".available_widgets").removeClass("available_widgets_active"),jQuery(this).hasClass("available_widgets")?jQuery(b.draggable).hasClass("new_widget")||jQuery(b.draggable).remove():jQuery(b.draggable).hasClass("new_widget")?addNewWidget(b.draggable,this):(jQuery(b.draggable).insertAfter(this),jQuery(b.draggable).addClass("fade_me server_update"),jQuery(b.draggable).droppable("enable")),doFade(".fade_me"),colourWidgets(),sendWidgetOrder()}})}function doFade(a){evoFadeSuccess(a)}function sendWidgetOrder(){reorder_delay_remaining<1&&jQuery("#server_messages").html('
    '),reorder_delay_remaining=reorder_delay,bufferedServerCall()}function sendWidgetOrderCallback(a){doFade(".server_updating"),jQuery(".server_updating").removeClass("server_updating"),colourWidgets()}function bufferedServerCall(){var a=getWidgetOrder();a!=current_widgets?(jQuery("#server_messages").html('
    • '+T_("Saving changes")+"
    "),current_widgets=a,a+="&"+crumb_url,jQuery(".pending_update").removeClass("pending_update").addClass("server_updating"),SendAdminRequest("widgets","re-order",a,!1)):(jQuery("#server_messages").html('
    • '+T_("Widget order unchanged")+"
    "),jQuery(".pending_update").removeClass("pending_update"),colourWidgets())}function getWidgetOrder(){var a=new Array;jQuery(".widget_container").each(function(){var b=jQuery(this).attr("id");a[b]="",jQuery("#"+b+" .draggable_widget").each(function(){jQuery(this).attr("id")&&"undefined"!=jQuery(this).attr("id")&&(a[b]+=jQuery(this).attr("id")+", ")})});var b="",c="";for(container in a)b+=container+"="+a[container]+"&",c+=container+",";return("undefined"!=typeof blog?"blog="+blog:"")+"&"+b+"container_list="+c}function colourWidgets(){jQuery(".draggable_widget").removeClass("odd"),jQuery(".draggable_widget").removeClass("even");var a=!1;jQuery("#current_widgets .draggable_widget").each(function(){a=!a,jQuery(this).addClass(a?"even":"odd")})}function deleteWidget(a){return jQuery("#wi_ID_"+a.substr(6,a.length)).animate({backgroundColor:"#f88"},"fast",function(){jQuery(this).remove(),colourWidgets(),sendWidgetOrder()}),!1}function editWidget(a){return jQuery("#server_messages").html(""),msg="wi_ID="+a.substr(6,a.length)+"&"+crumb_url,SendAdminRequest("widgets","edit",msg,!0),!1}function widgetSettings(a,b,c){jQuery("body").append('
    '),jQuery("#screen_mask").fadeTo(1,.5).fadeIn(200),jQuery("#widget_settings").html(a).addClass("widget_settings_active edit_widget_"+b+"_"+c),jQuery("#widget_settings").prepend(jQuery("#server_messages")),AttachServerRequest("widget_checkchanges");var d=jQuery("#widget_settings").find("h2.page-title:first");if(d.length>0){var e=jQuery("#widget_settings").find("span.pull-right:first"),f="";e.length>0&&(e.find("a.close_link").remove(),f=''+e.html()+"",e.remove()),jQuery("#widget_settings").prepend('"),d.remove(),jQuery("#widget_settings button.close").bind("click",closeWidgetSettings)}jQuery("#widget_settings a.close_link").bind("click",closeWidgetSettings)}function widgetSettingsCallback(a,b,c){jQuery("#wi_ID_"+a+" .widget_name").html(b),jQuery("#wi_ID_"+a+" .widget_cache_status").html(getWidgetCacheIcon("wi_ID_"+a,c))}function closeWidgetSettings(a){if(!jQuery("#widget_settings").is(":visible"))return!1;if("undefined"!=typeof bozo&&(void 0===a||"update"!=a)){if(bozo.validate_close()&&!confirm(bozo.validate_close()))return!1;bozo.reset_changes()}return jQuery("#widget_settings").hide(),jQuery("#server_messages").insertBefore(".available_widgets"),jQuery("#widget_settings").remove(),jQuery("#screen_mask").remove(),!1}function showMessagesWidgetSettings(a){return void 0!==a&&"success"==a&&"undefined"!=typeof bozo&&bozo.reset_changes(),jQuery("#widget_settings").animate({scrollTop:jQuery("#widget_settings").scrollTop()+ +jQuery("#server_messages").position().top-20},100),!1}function T_(a){return void 0===T_arr[a]?a:T_arr[a]}function convertAvailableList(){jQuery(".fieldset_title > span > a[id^='add_new']").attr("href","#").bind("click",function(a){jQuery("body").append('
    '),jQuery("#screen_mask").fadeTo(1,.5).fadeIn(200),offset=jQuery(this).offset();var b=offset.top,c=jQuery(document).height()-10-jQuery(".available_widgets").height();return c<20&&(c=20),b>c&&(b=c),jQuery(".available_widgets").addClass("available_widgets_active").attr("id","available_"+jQuery(this).attr("id")),!1}),jQuery(".available_widgets_toolbar > a").bind("click",function(a){return closeAvailableWidgets(),!1}),jQuery(".available_widgets li").each(function(){jQuery(this).addClass("new_widget");var a=jQuery(this).children("a").attr("href");a=a.substr(a.indexOf("&type")+1,a.length),jQuery(this).children("a:first").attr("href","#").bind("click",function(){return addNewWidget(this,a),!1})})}function closeAvailableWidgets(){if(!jQuery(".available_widgets").is(":visible"))return!1;jQuery(".available_widgets").removeClass("available_widgets_active"),jQuery("#screen_mask").remove()}function addNewWidget(a,b){closeAvailableWidgets();var c=jQuery(a).attr("id");jQuery(a).attr("id",c);var d=(jQuery(a).html(),jQuery(".available_widgets").attr("id"));d=d.substr(18,d.length).replace(/_/g," ").replace(/-/g,":"),SendAdminRequest("widgets","create",b+"&blog="+blog+"&container="+d,!0)}function addNewWidgetCallback(a,b,c,d,e){jQuery(".fade_me").removeClass("fade_me"),createWidget("wi_ID_"+a,b.replace(/ /g,"_").replace(/:/g,"-"),c,d,"",1,e),doFade("#wi_ID_"+a),reorder_delay_remaining>0?reorder_delay_remaining=0:current_widgets=getWidgetOrder()}function createWidget(a,b,c,d,e,f,g){var h=jQuery('
  • '+d+"
  • ");h.find("a.widget_name").click(function(){return editWidget(a)}),e&&jQuery(h).addClass(e),jQuery(h).prepend(jQuery('"+(f?enabled_icon_tag:disabled_icon_tag)+""));var i=jQuery(''+getWidgetCacheIcon(a,g)+"");jQuery(h).prepend(i);var j=jQuery('"+(f?deactivate_icon_tag:activate_icon_tag)+'"+edit_icon_tag+'"+delete_icon_tag+"");jQuery(h).prepend(j),jQuery(h).prepend(jQuery('')),jQuery("#container_"+b).append(h),makeDragnDrop("#"+a),colourWidgets()}function toggleWidget(a){return SendAdminRequest("widgets","toggle","wi_ID="+a.substr(6)+"&"+crumb_url,!0),!1}function doToggle(a,b){jQuery("#wi_ID_"+a+" .widget_state").html('"+(b?enabled_icon_tag:disabled_icon_tag)+""),b?jQuery("#wi_ID_"+a+" .widget_checkbox").addClass("widget_checkbox_enabled"):jQuery("#wi_ID_"+a+" .widget_checkbox").removeClass("widget_checkbox_enabled"),jQuery("#wi_ID_"+a+" .toggle_action").html(b?deactivate_icon_tag:activate_icon_tag),evoFadeBg(jQuery("#wi_ID_"+a),new Array("#FFFF33"),{speed:3e3})}function toggleCacheWidget(a,b){return SendAdminRequest("widgets","cache_"+b,"wi_ID="+a.substr(6)+"&"+crumb_url,!0),!1}function doToggleCache(a,b){jQuery("#wi_ID_"+a+" .widget_cache_status").html(getWidgetCacheIcon("wi_ID_"+a,b)),evoFadeBg(jQuery("#wi_ID_"+a),new Array("#FFFF33"),{speed:3e3})}function str_repeat(a,b){return new Array(b+1).join(a)}function getWidgetCacheIcon(a,b){switch(b){case"enabled":return'"+cache_enabled_icon_tag+"";case"disabled":return'"+cache_disabled_icon_tag+"";case"disallowed":return cache_disallowed_icon_tag;case"denied":return''+cache_denied_icon_tag+""}}function openModalWindow(a,b,c,d,e,f,g,h,i){var j=void 0===b||"auto"==b?"":"width:"+b+";",k=void 0===c||0==c||""==c?"":"height:"+c,l=k.match(/%$/i)?' style="height:100%;overflow:hidden;"':"",m=c.match(/px/i)?' style="min-height:'+(c.replace("px","")-157)+'px"':"",n=void 0===f||0!=f;if(void 0!==f&&""!=f)if("object"==typeof f)var o=f[0],p=f[1],q=void 0===f[2]?"form":f[2];else var o=f,p="btn-primary",q="form";if(void 0!==g&&g&&jQuery("#modal_window").remove(),0==jQuery("#modal_window").length){var r='",jQuery("body").append(r)}else jQuery("#modal_window .modal-body").html(a);"undefined"!=typeof i?jQuery("#"+i).load(function(){prepareModalWindow(jQuery(this).contents(),q,n,h),jQuery("#modal_window .loader_img").remove(),jQuery("#"+i).show()}):prepareModalWindow("#modal_window",q,n,h);var s={};modal_window_js_initialized&&(s="show"),jQuery("#modal_window").modal(s),""==j&&(jQuery("#modal_window .modal-dialog").css({display:"table",width:"auto"}),jQuery("#modal_window .modal-dialog .modal-content").css({display:"table-cell"})),jQuery("#modal_window").on("hidden",function(){jQuery(this).remove()}),modal_window_js_initialized=!0}function prepareModalWindow(a,b,c,d){c&&("undefined"!=typeof d&&d||(jQuery("legend",a).remove(),jQuery("#close_button",a).remove(),jQuery(".panel, .panel-body",a).removeClass("panel panel-default panel-body")),0==jQuery(b+" input[type=submit]",a).length?jQuery("#modal_window .modal-footer button[type=submit]").hide():(jQuery(b+" input[type=submit]",a).hide(),jQuery("#modal_window .modal-footer button[type=submit]").show()),jQuery(b,a).change(function(){var a=jQuery(this).find("input[type=submit]");a.length>0?(a.hide(),jQuery("#modal_window .modal-footer button[type=submit]").show()):jQuery("#modal_window .modal-footer button[type=submit]").hide()}),jQuery("#modal_window .modal-footer button[type=submit]").click(function(){jQuery(b+" input[type=submit]",a).click()})),jQuery(b+" a.btn",a).each(function(){jQuery("#modal_window .modal-footer").prepend(""),jQuery(this).remove()}),jQuery(b+" #current_modal_title",a).length>0&&jQuery("#modal_window .modal-title").html(jQuery(b+" #current_modal_title",a).html())}function closeModalWindow(a){return"undefined"==typeof a&&(a=window.document),jQuery("#modal_window",a).modal("hide"),!1}function setModalIFrameUnload(a){var b=jQuery("#"+a);b[0].contentWindow.onunload=function(){var a=b.closest(".modal-body"),c=jQuery('');jQuery(a).prepend(c)}}function user_crop_avatar(a,b,c){"undefined"==typeof c&&(c="avatar");var d=750,e=320,f=jQuery(window).width(),g=jQuery(window).height(),h=f,i=g,j=i/h;i=i>d?d:e>i?e:i,h=h>d?d:e>h?e:h;var k=10,l=10;k=h-2*k>e?10:0,l=i-2*l>e?10:0;var m=h>d?d:h,n=i>d?d:i;openModalWindow('',m+"px",n+"px",!0,evo_js_lang_crop_profile_pic,[evo_js_lang_crop,"btn-primary"],!0);var o=jQuery("div.modal-dialog div.modal-body").length?jQuery("div.modal-dialog div.modal-body"):jQuery("#overlay_page"),p={top:parseInt(o.css("paddingTop")),right:parseInt(o.css("paddingRight")),bottom:parseInt(o.css("paddingBottom")),left:parseInt(o.css("paddingLeft"))},q=(jQuery("div.modal-dialog div.modal-body").length?parseInt(o.css("min-height")):n-100)-(p.top+p.bottom),r=m-(p.left+p.right),s={user_ID:a,file_ID:b,aspect_ratio:j,content_width:r,content_height:q,display_mode:"js",crumb_user:evo_js_crumb_user};return evo_js_is_backoffice?(s.ctrl="user",s.user_tab="crop",s.user_tab_from=c):(s.blog=evo_js_blog,s.disp="avatar",s.action="crop"),jQuery.ajax({type:"POST",url:evo_js_user_crop_ajax_url,data:s,success:function(a){openModalWindow(a,m+"px",n+"px",!0,evo_js_lang_crop_profile_pic,[evo_js_lang_crop,"btn-primary"])}}),!1}function user_report(a,b){openModalWindow('',"auto","",!0,evo_js_lang_report_user,[evo_js_lang_report_this_user_now,"btn-danger"],!0);var c={action:"get_user_report_form",user_ID:a,crumb_user:evo_js_crumb_user};return evo_js_is_backoffice?(c.is_backoffice=1,c.user_tab=b):c.blog=evo_js_blog,jQuery.ajax({type:"POST",url:evo_js_user_report_ajax_url,data:c,success:function(a){openModalWindow(a,"auto","",!0,evo_js_lang_report_user,[evo_js_lang_report_this_user_now,"btn-danger"])}}),!1}function user_contact_groups(a){return openModalWindow('',"auto","",!0,evo_js_lang_contact_groups,evo_js_lang_save,!0),jQuery.ajax({type:"POST",url:evo_js_user_contact_groups_ajax_url,data:{action:"get_user_contact_form",blog:evo_js_blog,user_ID:a,crumb_user:evo_js_crumb_user},success:function(a){openModalWindow(a,"auto","",!0,evo_js_lang_contact_groups,evo_js_lang_save,!0)}}),!1}function evo_rest_api_request(url,params_func,func_method,method){var params=params_func,func=func_method;"function"==typeof params_func&&(func=params_func,params={},method=func_method),"undefined"==typeof method&&(method="GET"),jQuery.ajax({contentType:"application/json; charset=utf-8",type:method,url:restapi_url+url,data:params}).then(function(data,textStatus,jqXHR){"object"==typeof jqXHR.responseJSON&&eval(func)(data,textStatus,jqXHR)})}function evo_link_fix_wrapper_height(){var a=jQuery("#attachments_fieldset_table").height(),b=jQuery("#attachments_fieldset_wrapper").height();b!=a&&jQuery("#attachments_fieldset_wrapper").height(jQuery("#attachments_fieldset_table").height())}function evo_link_change_position(a,b,c){var d=a,e=a.value;return jQuery.get(b+"anon_async.php?action=set_object_link_position&link_ID="+a.id.substr(17)+"&link_position="+e+"&crumb_link="+c,{},function(b,c){b=ajax_debug_clear(b),"OK"==b?(evoFadeSuccess(jQuery(d).closest("tr")),jQuery(d).closest("td").removeClass("error"),"cover"==e&&jQuery("select[name=link_position][id!="+a.id+"] option[value=cover]:selected").each(function(){jQuery(this).parent().val("aftermore"),evoFadeSuccess(jQuery(this).closest("tr"))})):(jQuery(d).val(b),evoFadeFailure(jQuery(d).closest("tr")),jQuery(d.form).closest("td").addClass("error"))}),!1}function evo_link_insert_inline(a,b,c){if("undefined"!=typeof b2evoCanvas){var d="["+a+":"+b;c.length&&(d+=":"+c),d+="]",textarea_wrap_selection(b2evoCanvas,d,"",0,window.document);var e=jQuery("#display_position_"+b);0!=e.length&&"inline"!=e.val()&&(deferInlineReminder=!0,e.val("inline").change(),deferInlineReminder=!1)}}function evo_link_delete(a,b,c,d){return evo_rest_api_request("links/"+c,{action:d},function(d){if("item"==b){var e=window.document.getElementById("itemform_post_content");if(null!=e){var f=new RegExp("\\[(image|file|inline|video|audio|thumbnail):"+c+":?[^\\]]*\\]","ig");textarea_str_replace(e,f,"",window.document)}}jQuery(a).closest("tr").remove(),evo_link_fix_wrapper_height()},"DELETE"),!1}function evo_link_change_order(a,b,c){return evo_rest_api_request("links/"+b+"/"+c,function(b){var d=jQuery(a).closest("tr");"move_up"==c?d.prev().before(d):d.next().after(d),evoFadeSuccess(d)},"POST"),!1}function evo_link_attach(a,b,c,d){return evo_rest_api_request("links",{action:"attach",type:a,object_ID:b,root:c,path:d},function(a){var b=jQuery("#attachments_fieldset_table table",window.parent.document),c=(b.parent,jQuery(a.list_content));b.replaceWith(jQuery("table",c)).promise().done(function(a){setTimeout(function(){window.parent.evo_link_fix_wrapper_height()},10)})}),!1}function evo_link_ajax_loading_overlay(){var a=jQuery("#attachments_fieldset_table"),b=!1;return 0==a.find(".results_ajax_loading").length&&(b=jQuery('
     
    '),a.css("position","relative"),b.css({width:a.width(),height:a.height()}),a.append(b)),b}function evo_link_refresh_list(a,b,c){var d=evo_link_ajax_loading_overlay();return d&&evo_rest_api_request("links",{action:"undefined"==typeof c?"refresh":"sort",type:a,object_ID:b},function(a){jQuery("#attachments_fieldset_table").html(a.html),d.remove(),evo_link_fix_wrapper_height()}),!1}function ajax_debug_clear(a){var b=//;return a=a.replace(b,""),a=a.replace(/(
    [\s\S]*)/i,""),jQuery.trim(a)}function ajax_response_is_correct(a){var b=//,c=a.match(b);return c?(a=ajax_debug_clear(a),""!=a):!1}var modal_window_js_initialized=!1;jQuery(document).ready(function(){jQuery("img.loadimg").each(function(){jQuery(this).prop("complete")?(jQuery(this).removeClass("loadimg"),""==jQuery(this).attr("class")&&jQuery(this).removeAttr("class")):jQuery(this).on("load",function(){jQuery(this).removeClass("loadimg"),""==jQuery(this).attr("class")&&jQuery(this).removeAttr("class")})})}),jQuery(document).on("click","a.evo_post_flag_btn",function(){var a=jQuery(this),b=parseInt(a.data("id"));return b>0&&(a.data("status","inprogress"),jQuery("span",jQuery(this)).addClass("fa-x--hover"),evo_rest_api_request("collections/"+a.data("coll")+"/items/"+b+"/flag",function(b){b.flag?(a.find("span:first").show(),a.find("span:last").hide()):(a.find("span:last").show(),a.find("span:first").hide()),jQuery("span",a).removeClass("fa-x--hover"),setTimeout(function(){a.removeData("status")},500)})),!1}),jQuery(document).on("mouseover","a.evo_post_flag_btn",function(){"inprogress"!=jQuery(this).data("status")&&jQuery("span",jQuery(this)).addClass("fa-x--hover")}),jQuery(document).ready(function(){if(jQuery("#attachments_fieldset_table").length>0){var a=jQuery("#attachments_fieldset_table").height();a=a>320?320:97>a?97:a,jQuery("#attachments_fieldset_wrapper").height(a),jQuery("#attachments_fieldset_wrapper").resizable({minHeight:80,handles:"s",resize:function(a,b){jQuery("#attachments_fieldset_wrapper").resizable("option","maxHeight",jQuery("#attachments_fieldset_table").height())}}),jQuery(document).on("click","#attachments_fieldset_wrapper .ui-resizable-handle",function(){var a=jQuery("#attachments_fieldset_table").height(),b=jQuery("#attachments_fieldset_wrapper").height()+80;jQuery("#attachments_fieldset_wrapper").css("height",b>a?a:b)})}}); \ No newline at end of file +function openModalWindow(a,b,c,d,e,f,g,h,i){var j=void 0===b||"auto"==b?"":"width:"+b+";",k=void 0===c||0==c||""==c?"":"height:"+c,l=k.match(/%$/i)?' style="height:100%;overflow:hidden;"':"",m=c.match(/px/i)?' style="min-height:'+(c.replace("px","")-157)+'px"':"",n=void 0===f||0!=f;if(void 0!==f&&""!=f)if("object"==typeof f)var o=f[0],p=f[1],q=void 0===f[2]?"form":f[2];else var o=f,p="btn-primary",q="form";if(void 0!==g&&g&&jQuery("#modal_window").remove(),0==jQuery("#modal_window").length){var r='