Plugin Directory

Changeset 2149004


Ignore:
Timestamp:
08/31/2019 05:29:28 PM (7 years ago)
Author:
Will Brownsberger
Message:

4.5.1.0 in progress

Location:
wp-issues-crm/trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • wp-issues-crm/trunk/js/email-deliver.js

    r2008825 r2149004  
    1111    wpIssuesCRM.loadOutboxListeners = function() {
    1212        //  bind listener for queue hold button (already loaded );
    13         $( "#control-process-email-button" ).on ( "click", function() {
    14             var newMailerStatus = $( this ).hasClass ( "mailer_held" ); // if held, new status is true, mailer_ok
     13        $( "#control-process-email-button" ).on ( "click", function() { 
     14            var newMailerStatus = $( this ).hasClass ( "mailer_held" ) ? 1 : 0; // if held, new status is true, mailer_ok
    1515            wpIssuesCRM.ajaxPost( 'email_deliver', 'set_mailer_status',  0, newMailerStatus,  function( response ) {
    16                 if ( true === response ) {
     16                if ( response > 0 ) {
    1717                    $ ( "#control-process-email-button" ).removeClass ( "mailer_held" ).addClass( "mailer_ok" );
    1818                } else {
     
    3838    wpIssuesCRM.getMailerStatus = function () {
    3939        wpIssuesCRM.ajaxPost( 'email_deliver', 'get_mailer_status',  0, '',  function( response ) {
    40             if ( response ) {
     40            if ( response > 0 ) {
    4141                $( "#control-process-email-button").removeClass ( "mailer_held" ).addClass( "mailer_ok" );
    4242            } else {
     
    5353        if ( controlProcessEmailButton.hasClass ("mailer_ok" ) ) {
    5454            controlProcessEmailButton.text("Suspend Mailer").attr("title", "Immediately interrupt and hold mailer.");
    55         } else {
     55        } else { 
    5656            controlProcessEmailButton.text("Release Mailer").attr("title", "Release mailer to run when next scheduled.");
    5757        }
  • wp-issues-crm/trunk/js/email-inbox.js

    r2147379 r2149004  
    238238
    239239            // enable or disable assignment selection button
    240             if ( !( ['CATEGORY_ASSIGNED', 'CATEGORY_READY'].indexOf(inboxParms.tab) > -1 ) || !wpIssuesCRMSettings.canSendEmail ){
     240            if ( !( ['CATEGORY_ASSIGNED', 'CATEGORY_READY'].indexOf(inboxParms.tab) > -1 ) || !wpIssuesCRMSettings.canViewAllEmail ){
    241241                $( '#wic-filter-assigned-button' ).prop( 'disabled',true ).addClass('ui-state-disabled');
    242242            } else {
  • wp-issues-crm/trunk/js/email-message.js

    r2147379 r2149004  
    912912        }
    913913        // enable/disable staff reassignment button based on user capability and message count; is enabled in all tabs
    914         if ( ! wpIssuesCRMSettings.canSendEmail || wpIssuesCRM.currentMessageVars.countMessages > 1 ){
     914        if ( ! wpIssuesCRMSettings.canViewAllEmail || wpIssuesCRM.currentMessageVars.countMessages > 1 ){
    915915            $( '#assigned-case-popup-button' ).prop( 'disabled',true ).addClass('ui-state-disabled').attr("title","Cannot assign/reassign.");
    916916        } else {
  • wp-issues-crm/trunk/js/email-settings.js

    r2096077 r2149004  
    173173    */
    174174    function sanitizePipeSeparated ( element ) {
    175         var pipeSeparated = [ 'streets', 'states', 'apartments', 'special_streets', 'post_titles', 'pre_titles', 'disqualifiers', 'imc_qualifiers', 'closings', 'non_names' ];
     175        var pipeSeparated = [ 'streets', 'states', 'apartments', 'special_streets', 'post_titles', 'pre_titles', 'disqualifiers', 'imc_qualifiers', 'closings', 'non_names', 'team_list' ];
    176176        elementObject = $ ( element )
    177177        if ( pipeSeparated.indexOf ( elementObject.attr( "id") ) > -1 ) {
    178178            var uncleanString = elementObject.val();
    179             var cleanString = uncleanString.replace (new RegExp (/[^|A-Za-z0-9 -]/, 'g' ), '' );
     179            var cleanString = 'team_list' == elementObject.attr( "id") ?
     180                 uncleanString.replace (new RegExp ( /[^|%@.+_A-Za-z0-9-]/, 'g' ), '' ):
     181                 uncleanString.replace (new RegExp ( /[^|A-Za-z0-9 -]/, 'g' ), '' );
    180182            var termsArray = cleanString.split ( '|' );
    181183            var trimmedArray = [];
     
    193195
    194196
     197
     198
    195199}( window.wpIssuesCRM = window.wpIssuesCRM || {}, jQuery )); // end  namespace enclosure   
  • wp-issues-crm/trunk/php/admin/class-wic-admin-access.php

    r2147428 r2149004  
    9999            'email_attachment'                  => 'email',
    100100            'email_block'                       => 'email',
    101             'email_compose'                     => 'email',
     101            'email_compose'                     => 'send_email',
    102102            'email_connect'                     => 'email',
    103103            // 'email_cron'                     secured with cron key
     
    133133            //'email_oauth_synch'               not taking ajax calls,
    134134            //'email_oauth_update'              not taking ajax calls,
    135             'email_process'                     => 'email',
    136             'email_send'                        => 'email', // note: that list_send capability is checked within the send function
     135            'email_process'                     => 'send_email',
     136            'email_send'                        => 'send_email', // note: that list_send capability is checked within the send function
    137137            'email_settings'                    => 'email',
    138138            'email_subject' => array(
  • wp-issues-crm/trunk/php/admin/class-wic-admin-settings.php

    r2146005 r2149004  
    8686      add_settings_field(
    8787            'access_level_required_email', // field id
     88            'Access all email', // field label
     89            array( $this, 'access_level_required_email_callback' ), // field call back
     90            'wp_issues_crm_settings_page', // page
     91            'security_settings' // settings section within page
     92       );
     93
     94      add_settings_field(
     95            'access_level_required_send_email', // field id
    8896            'Send email', // field label
    89             array( $this, 'access_level_required_email_callback' ), // field call back
     97            array( $this, 'access_level_required_send_email_callback' ), // field call back
    9098            'wp_issues_crm_settings_page', // page
    9199            'security_settings' // settings section within page
     
    755763    }   
    756764
     765    // setting field call back 
     766    public function access_level_required_send_email_callback() {
     767        global $wic_db_dictionary;
     768        $option_array = $wic_db_dictionary->lookup_option_values( 'capability_levels' );       
     769       
     770        $value = isset ( $this->plugin_options['access_level_required_send_email'] ) ? $this->plugin_options['access_level_required_send_email'] : 'edit_theme_options';
     771
     772        $args = array (
     773            'field_label'       => '',
     774            'option_array'      => $option_array,
     775            'input_class'       => '',
     776            'field_slug_css'    => '',
     777            'hidden'            => '',
     778            'field_slug'        => 'wp_issues_crm_plugin_options_array[access_level_required_send_email]',
     779            'value'             => $value ,     
     780        );     
     781        echo WIC_Control_Select::create_control( $args );
     782    }   
     783
    757784
    758785    // setting field call back 
     
    14981525      if( isset( $input['access_level_required_email'] ) ) {
    14991526            $new_input['access_level_required_email'] = sanitize_text_field( $input['access_level_required_email'] );
    1500       }   
     1527      }
     1528      if( isset( $input['access_level_required_send_email'] ) ) {
     1529            $new_input['access_level_required_send_email'] = sanitize_text_field( $input['access_level_required_send_email'] );
     1530      }           
    15011531      if( isset( $input['access_level_required_list_send'] ) ) {
    15021532            $new_input['access_level_required_list_send'] = sanitize_text_field( $input['access_level_required_list_send'] );
  • wp-issues-crm/trunk/php/admin/class-wic-admin-setup.php

    r2145245 r2149004  
    286286                    'maxFileSize' => WIC_Entity_Upload_Upload::get_safe_file_size(),
    287287                    'dearToken' => WIC_Entity_Email_Send::dear_token,
    288                     'canSendEmail' => current_user_can (WIC_Admin_Access::check_required_capability ('email')),
     288                    'canViewAllEmail' => current_user_can (WIC_Admin_Access::check_required_capability ('email')),
     289                    'canSendEmail' => current_user_can (WIC_Admin_Access::check_required_capability ('send_email')),
    289290                    'canViewOthersAssigned' => current_user_can (WIC_Admin_Access::check_required_capability ('view_edit_unassigned')),
    290291                )
  • wp-issues-crm/trunk/php/entity/class-wic-entity-email-deliver-activesync.php

    r2019577 r2149004  
    108108            $current_id = $outbox_message->ID;     
    109109            // test to see if OK to continue running
    110             if ( ! get_option ( 'wp-issues-crm-mailer-ok-to-go', true ) ) {
     110            // in php string 0 is false https://www.php.net/manual/en/language.types.boolean.php#language.types.boolean.casting
     111            if ( ! get_option ( 'wp-issues-crm-mailer-ok-to-go', 1 ) ) {
    111112                WIC_Entity_Email_Cron::log_mail ( 'Ending WIC_Entity_Email_Deliver_Activesync::process_message_queue -- mailer suspended.');
    112113                return true; // don't retry
  • wp-issues-crm/trunk/php/entity/class-wic-entity-email-deliver.php

    r2043247 r2149004  
    210210    */ 
    211211    public static function get_mailer_status( $dummy1, $dummy2 ) {
    212         return array ( 'response_code' => true, 'output' => get_option ( 'wp-issues-crm-mailer-ok-to-go', true ) );  // start with mailer released if have not set option
     212        return array ( 'response_code' => true, 'output' => get_option ( 'wp-issues-crm-mailer-ok-to-go', 1 ) );  // start with mailer released if have not set option
    213213    }
    214214
    215215    public static function set_mailer_status( $dummy, $new_status ) {
    216         update_option ( 'wp-issues-crm-mailer-ok-to-go', $new_status );
    217         return array ( 'response_code' => true, 'output' =>  $new_status );
     216        // use 1/0 -- note that in update_option if value = false and no option https://core.trac.wordpress.org/ticket/40007
     217        update_option ( 'wp-issues-crm-mailer-ok-to-go', $new_status ? 1 : 0 );
     218        return self::get_mailer_status( '', '' ); // return truth, not theory, about value!
    218219    }
    219220
     
    286287            $current_id = $outbox_message->ID;     
    287288            // test to see if OK to continue running
    288             if ( ! get_option ( 'wp-issues-crm-mailer-ok-to-go', true ) ) {
     289            // in php string 0 is false https://www.php.net/manual/en/language.types.boolean.php#language.types.boolean.casting
     290            if ( ! get_option ( 'wp-issues-crm-mailer-ok-to-go', 1 ) ) {
    289291                WIC_Entity_Email_Cron::log_mail ( 'Ending WIC_Entity_Email_Deliver::process_message_queue -- mailer suspended.');
    290292                $mail->smtpClose();
  • wp-issues-crm/trunk/php/entity/class-wic-entity-email-inbox.php

    r2147085 r2149004  
    7878        $word_minimum_threshold = isset ( $form_variables_object->word_minimum_threshold ) ? $form_variables_object->word_minimum_threshold : 200;
    7979        $mapped_threshold = isset ( $form_variables_object->mapped_threshold ) ? $form_variables_object->mapped_threshold : 85;
     80        // get pipe seperated list of team from emails
     81        $team_list = isset ( $form_variables_object->team_list ) ? $form_variables_object->team_list : '';
     82        $team_list_array = $team_list ? explode ( '|', $team_list ): array();
    8083        // get current folder
    8184        $folder = WIC_Entity_Email_Account::get_folder();
     
    147150
    148151        /*
    149         * add tab selection terms -- CATEGORY_ADVOCACY, CATEGORY_ASSIGNED, CATEGORY_READY special, dynamically applied
     152        *
     153        * this is a hook to allow substitution of category definitions without reparsing the inbox
     154        *
     155        * the following is an example that could be placed in a local plugin -- always include leading and trailing white spaces around the defined term
     156        define ('WP_ISSUES_CRM_LOCAL_CATEGORY_REWRITE', "
     157            IF( category = 'CATEGORY_PROMOTIONS',
     158                'CATEGORY_PERSONAL',
     159                IF(
     160                    category = 'CATEGORY_FORUMS',
     161                        'CATEGORY_SOCIAL',
     162                        category
     163                )
     164            )
     165        ");
     166        */
     167        $category_phrase = defined ( 'WP_ISSUES_CRM_LOCAL_CATEGORY_REWRITE' ) ? WP_ISSUES_CRM_LOCAL_CATEGORY_REWRITE : ' category ';
     168        /*
     169        * add tab selection terms -- CATEGORY_TEAM, CATEGORY_ADVOCACY, CATEGORY_ASSIGNED, CATEGORY_READY special, dynamically applied
    150170        *
    151171        * assigned_subject is the subject from $assigned_subject_join subselection query below
     
    160180        *    if ! $user_can_see_all, just choosing between two allowed tabs --
    161181        *       CATEGORY_ASSIGNED or if a response has been drafted in CATEGORY_READY
     182        *
     183        *   CATEGORY_TEAM is an overriding category -- it doesn't matter what the underlying category is; if from team, in team tab and not elsewhere
     184        *       EXCEPT that subject being assigned overrides email being team
    162185        */
     186        $team_list_criterion = '';
     187        if ( $team_list_array ) {
     188            $team_list_criterion = '( ';
     189            foreach ( $team_list_array as $email_criterion ) {
     190                // cannot use wpdb prepare -- % gets replaced with hash; so hard resanitize the $email_criterion directly
     191                // ?? https://stackoverflow.com/questions/53831586/using-like-statement-with-wpdb-prepare-showing-hashes-where-wildcard-character
     192                $email_criterion_resanitized = preg_replace ( '/[^%@.+_A-Za-z0-9-]/', '', $email_criterion );
     193                $team_list_criterion .=  " from_email LIKE '$email_criterion_resanitized' OR ";
     194            }
     195            $team_list_criterion .=  " $category_phrase = 'CATEGORY_TEAM' OR 1 = 0 )"; // (short) legacy of built in category_team
     196        }
     197
    163198        $category_where = $user_can_see_all ?
     199            (
     200            'CATEGORY_TEAM' == $data->tab ? " $team_list_criterion AND assigned_subject is null AND " :
    164201            $wpdb->prepare (
    165202                    " IF(
    166203                        assigned_subject is NULL,
    167                         IF( mapped_issue > 0, 'CATEGORY_ADVOCACY', category ),
     204                        IF( mapped_issue > 0, 'CATEGORY_ADVOCACY', $category_phrase ),
    168205                        IF( subject_is_final, 'CATEGORY_READY', 'CATEGORY_ASSIGNED' )
    169                     ) = %s AND ",
     206                    ) = %s AND ( NOT $team_list_criterion OR assigned_subject IS NOT NULL ) AND ",
    170207                    array ( $data->tab )
    171                 ) :
     208                )
     209            )
     210            :
     211            // note that if ! $user_can_see_all, $absolute_user_where_limit also applies, limiting displayed messages to assigned
    172212            $wpdb->prepare (
    173213                    " IF( inbox_defined_reply_is_final , 'CATEGORY_READY', 'CATEGORY_ASSIGNED' ) = %s AND ",
     
    235275        * if ! $user_can_see all, only seeing ready and assigned tabs and only for current user is inbox_defined_staff, only first two cases apply
    236276        */
    237         $tabs_array = WIC_Entity_Email_Account::get_tabs();
     277        $tabs_array = WIC_Entity_Email_Account::get_tabs(); 
    238278        $tabs_summary_sql = '';
    239         foreach ( $tabs_array  as $tab ) {
     279        foreach ( $tabs_array  as $tab ) { 
    240280            $category = 'CATEGORY_' . strtoupper( $tab );
    241281            if ( ! $user_can_see_all && ! in_array( $category, array( 'CATEGORY_READY', 'CATEGORY_ASSIGNED' ) ) ) {
    242282                continue;               
    243283            }
    244             // this logic, covers all four possible combinations for counts, the default covering all tabs other than the synthetic ready, advocacy and assigned
     284            // this logic covers all five possible combinations for counts, the default covering all tabs other than the synthetic team, ready, advocacy and assigned
    245285            $tabs_summary_sql .= ", SUM(IF(" ;
    246286            switch ( $category) {
     
    260300                    );
    261301                    break;
     302                case 'CATEGORY_TEAM':
     303                    $tabs_summary_sql .= (
     304                        "  assigned_subject is null AND $team_list_criterion, "
     305                    );
     306                    break;             
    262307                // in the latter two cases, mapped_issue cannot be null because it is a not null field
    263308                case 'CATEGORY_ADVOCACY':
    264309                    $tabs_summary_sql .=
    265                         " assigned_subject IS NULL AND ( mapped_issue > 0 OR category = '$category' ), ";
     310                        " assigned_subject IS NULL AND  NOT $team_list_criterion AND ( mapped_issue > 0 OR $category_phrase = '$category' ), ";
    266311                    break;
    267312                default:
    268313                    $tabs_summary_sql .=
    269                         " assigned_subject IS NULL AND ( mapped_issue = 0 AND category = '$category' ), ";             
     314                        " assigned_subject IS NULL AND NOT $team_list_criterion AND ( mapped_issue = 0 AND $category_phrase = '$category' ), ";             
    270315            }
    271316            $tabs_summary_sql .= "1, 0)) as $category";
  • wp-issues-crm/trunk/sql/wic_data_dictionary_and_field_groups.sql

    r2096077 r2149004  
    148148('email_settings', 'non_constituent_responder', 'non_constituent_response_subject_line', 'text', 'Non Constituent Response Subject Line', 20, 0, 0, '', 0, 0, 0, '', 1, '', '', '', '', 0, 0, 1, 0, 0),
    149149('email_settings', 'non_constituent_responder', 'non_constituent_response_message', 'textarea', 'Non Constituent Response Text (should include signature -- no signature will be added)', 30, 0, 0, '', 0, 0, 0, '', 1, '', '', '', '', 0, 0, 1, 0, 0),
     150('email_settings', 'team_definition', 'team_list', 'textarea', 'Put these emails in the Team Tab.', 10, 0, 0, '', 0, 0, 0, '', 1, '', '', '', '', 0, 0, 1, 0, 0),
    150151('email_compose', 'compose_options', 'compose_to', 'multi_email', '', 10, 0, 0, '', 0, 0, 0, '', 1, '', '', '', '', 0, 0, 1, 0, 0),
    151152('email_compose', 'compose_options', 'compose_cc', 'multi_email', '', 20, 0, 0, '', 0, 0, 0, '', 1, '', '', '', '', 0, 0, 1, 0, 0),
     
    390391( 'email_settings', 'gmail_oauth', 'Gmail', 'WP Issues CRM can read and send mail through the Gmail API.  Gmail heavily filters incoming email, especially if forwarded, and so may not be suitable as a general purpose constituent inbox where responsiveness is a priority.', 3, 1, 0),
    391392( 'email_settings', 'user_sig', 'Signature', '', 20, 1, 0),
     393( 'email_settings', 'team_definition', 'Team Emails', 'Incoming emails from addresses that you list here will appear in the Team tab.  You can use % as a wildcard for any string of characters.   For example %masenate% would include any email address with masenate in the middle. Separate terms with the pipe "|" character.
     394For example:  mybestfriend@gmail.com|staffmember1@jones.com|%masenate%|%belmontma.gov.  Comparisons are not case sensitive.', 30, 1, 0),
    392395( 'email_settings', 'imap_message_grouping', 'Grouping', 'WP Issues CRM groups messages for bulk handling following conservative rules.  In addition to requiring a
    393396 subject line which you have affirmatively trained, it also checks for consistency of message content. Note that matches are updated dynamically as you make new replies.', 30, 1, 0),
  • wp-issues-crm/trunk/wp-issues-crm.php

    r2147450 r2149004  
    3939// set database version global;
    4040global $wp_issues_crm_db_version;
    41 $wp_issues_crm_db_version = '4.5.0.1';
     41$wp_issues_crm_db_version = '4.5.0.1.1';
    4242/*
    4343* set js_css version global -- three possibilities:
Note: See TracChangeset for help on using the changeset viewer.