コード例 #1
0
    /**
     * Hooks into list table cell.
     *
     * Executed on all, so need to only apply to messages.
     *
     * @since 0.1
     */
    function wp_list_table_cell($cell_data)
    {
        global $wp_crm, $wpdb;
        if ($cell_data['table_scope'] != 'wp_crm_contact_messages') {
            return $cell_data;
        }
        $object = $cell_data['object'];
        $user_id = $object['user_id'];
        if ($associated_object = $object['associated_object']) {
            $associated_object = get_post($associated_object);
            //** Only allow specific post types to be "associated "*/
            if (apply_filters('wp_crm_associated_post_types', false, $associated_object->post_type)) {
                $post_type = get_post_type_object($associated_object->post_type);
            } else {
                unset($associated_object);
            }
        }
        switch ($cell_data['column_name']) {
            case 'user_card':
                $r .= WP_CRM_F::render_user_card(array('user_id' => $user_id));
                break;
            case 'messages':
                $total_messages = $object['total_messages'];
                $additional_messages = $total_messages - 1;
                ob_start();
                ?>

            <ul>
              <li><?php 
                echo CRM_UD_F::parse_urls(nl2br($object['text']), 100, '_blank');
                ?>
</li>

              <?php 
                if ($associated_object) {
                    ?>
              <li><?php 
                    echo sprintf(__('Related %s:', 'wp_crm'), $post_type->labels->singular_name);
                    ?>
 <a href="<?php 
                    echo admin_url("post.php?post={$associated_object->post_ID}&action=edit");
                    ?>
" target="_blank"><?php 
                    echo $associated_object->post_title;
                    ?>
</a></li>
              <?php 
                }
                ?>

              <li><?php 
                echo human_time_diff(strtotime($object['time']));
                ?>
 <?php 
                _e('ago');
                ?>
.
                <?php 
                if ($additional_messages) {
                    echo '<a href="' . admin_url("admin.php?page=wp_crm_add_new&user_id={$user_id}") . '">' . $additional_messages . ' ' . __('other messages.') . '</a>';
                }
                ?>
              </li>
            </ul>

            <?php 
                $row_actions = array('trash_message' => __('Trash'));
                if ($object['status'] != 'archived') {
                    $row_actions['archive_message'] = __('Archive', 'wp_crm');
                }
                //** Only allow Trashing of recently registered users */
                $week_ago = date('Y-m-d', strtotime('-3 days'));
                if ($wpdb->get_var("SELECT ID FROM {$wpdb->users} WHERE ID = {$user_id} AND user_registered  > '{$week_ago}'") && get_user_meta($user_id, 'wpc_cm_generated_account')) {
                    $row_actions['trash_message_and_user'] = __('Trash Message and User', 'wp_crm');
                    $verify_actions['trash_message_and_user'] = true;
                }
                $row_actions = apply_filters('wp_crm_message_quick_actions', $row_actions);
                $verify_actions = apply_filters('wp_crm_message_quick_actions_verification', $verify_actions);
                ?>
            <?php 
                if ($row_actions) {
                    ?>
            <div class="row-actions">
               <?php 
                    foreach ($row_actions as $action => $title) {
                        ?>
                  <span  wp_crm_action="<?php 
                        echo $action;
                        ?>
" <?php 
                        echo $verify_actions[$action] ? 'verify_action="true"' : '';
                        ?>
 object_id="<?php 
                        echo $object['ID'];
                        ?>
" class="<?php 
                        echo $action;
                        ?>
 wp_crm_message_quick_action"><?php 
                        echo $title;
                        ?>
</span>
               <?php 
                    }
                    ?>
              </div>
              <?php 
                }
                ?>


           <?php 
                $content = ob_get_contents();
                ob_end_clean();
                $r .= $content;
                break;
            case 'other_messages':
                break;
        }
        return $r;
    }
コード例 #2
0
 /**
  * Returns a JSON response, and dies.
  *
  * Designed for AJAX functions.
  *
  * @todo Create option to disable database logging
  * @param bool $success 
  * @param string $message
  * @since 1.1
  * @return string 
  */
 function json($success, $message)
 {
     if ($success) {
         $r_success = 'true';
     }
     if (!$success) {
         $r_success = 'false';
     }
     $return = array('success' => $r_success, 'message' => $message);
     // Log in database
     CRM_UD_F::log(__("Automatically logged failed JSON response: ", 'wpp') . $message);
     echo json_encode($return);
     die;
 }
コード例 #3
0
            <li>
              <input type="checkbox" value="<?php 
    echo $key;
    ?>
" <?php 
    CRM_UD_UI::checked_in_array($key, $wp_crm['configuration']['overview_table_options']['main_view']);
    ?>
 name="wp_crm[configuration][overview_table_options][main_view][]" id="<?php 
    echo $key . $rand;
    ?>
" />
              <label for="<?php 
    echo $key . $rand;
    ?>
"><?php 
    echo $attribute_data['title'] ? $attribute_data['title'] : CRM_UD_F::de_slug($key);
    ?>
 <?php 
    echo !empty($attribute_data['quick_description']) ? '<span class="description">' . $attribute_data['quick_description'] . '</span>' : '';
    ?>
</label>
            </li>
          <?php 
}
?>
          </ul>

          </div>
        </td>
      </tr>
コード例 #4
0
ファイル: class_functions.php プロジェクト: sekurtz1/wp-crm
 /**
  * Checks for updates against TwinCitiesTech.com Server
  *
  * @since 0.01
  */
 static function feature_check($return = false)
 {
     global $wp_crm;
     $blogname = get_bloginfo('url');
     $blogname = urlencode(str_replace(array('http://', 'https://'), '', $blogname));
     $system = 'wp_crm';
     $wp_crm_version = get_option("wp_crm_version");
     $check_url = "http://updates.usabilitydynamics.com/?system={$system}&site={$blogname}&system_version={$wp_crm_version}";
     $response = @wp_remote_get($check_url);
     if (!$response) {
         return;
     }
     if (is_object($response) && !empty($response->errors)) {
         foreach ($response->errors as $update_errrors) {
             $error_string .= implode(",", $update_errrors);
             CRM_UD_F::log("Feature Update Error: " . $error_string);
         }
         if ($return) {
             return sprintf(__('An error occurred during premium feature check: <b> %s </b>.', 'wp_crm'), $error_string);
         }
         return;
     }
     if ($response['response']['code'] != '200') {
         return;
     }
     $response = @json_decode($response['body']);
     if (is_object($response->available_features)) {
         $response->available_features = CRM_UD_F::objectToArray($response->available_features);
         $wp_crm_settings = get_option('wp_crm_settings');
         $wp_crm_settings['available_features'] = CRM_UD_F::objectToArray($response->available_features);
         update_option('wp_crm_settings', $wp_crm_settings);
     }
     if ($response->features == 'eligible') {
         //** Try to create directory if it doesn't exist */
         if (!is_dir(WP_CRM_Premium)) {
             @mkdir(WP_CRM_Premium, 0755);
         }
         //** Save code */
         if (is_dir(WP_CRM_Premium) && is_object($response->code)) {
             foreach ($response->code as $code) {
                 $filename = $code->filename;
                 $php_code = $code->code;
                 $version = $code->version;
                 $default_headers = array('Name' => __('Feature Name', 'wp_crm'), 'Version' => __('Version', 'wp_crm'), 'Description' => __('Description', 'wp_crm'));
                 $current_file = @get_file_data(WP_CRM_Premium . "/" . $filename, $default_headers, 'plugin');
                 if (@version_compare($current_file['Version'], $version) == '-1') {
                     $this_file = WP_CRM_Premium . "/" . $filename;
                     $fh = @fopen($this_file, 'w');
                     if ($fh) {
                         fwrite($fh, $php_code);
                         fclose($fh);
                         if ($current_file['Version']) {
                             CRM_UD_F::log(sprintf(__('WP-CRM Premium Feature: %s updated to version %s from %s.', 'wp_crm'), $code->name, $version, $current_file['Version']));
                         } else {
                             CRM_UD_F::log(sprintf(__('WP-CRM Premium Feature: %s updated to version %s.', 'wp_crm'), $code->name, $version));
                         }
                         $updated_features[] = $code->name;
                     }
                 } else {
                 }
             }
         }
     }
     //** Update settings */
     WP_CRM_F::settings_action(true);
     if ($return && !empty($wp_crm['configuration']['disable_automatic_feature_update']) && $wp_crm['configuration']['disable_automatic_feature_update'] == 'true') {
         return __('Update ran successfully but no features were downloaded because the setting is disabled.', 'wp_crm');
     } elseif ($return) {
         return __('Update ran successfully.', 'wp_crm');
     }
 }
コード例 #5
0
echo isset($user_id) ? "&user_id={$user_id}" : '';
echo !empty($redirect_to) ? "&redirect_to={$redirect_to}" : "";
?>
" method="post" id="crm_user">
  <input type="hidden" id="user_id" name="wp_crm[user_data][user_id][0][value]" value="<?php 
echo isset($user_id) ? $user_id : '';
?>
" />
  <?php 
wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
wp_nonce_field('wp_crm_update_user', 'wp_crm_update_user', false);
?>

  <?php 
if (!CRM_UD_F::is_older_wp_version('3.4')) {
    ?>
  <div id="poststuff" class="crm-wp-v34">
    <div id="post-body" class="metabox-holder <?php 
    echo 2 == $screen_layout_columns ? 'columns-2' : 'columns-1';
    ?>
">
      <div id="postbox-container-1" class="postbox-container">
        <?php 
    do_meta_boxes($current_screen->id, 'side', $object);
    ?>
      </div>
      <div id="postbox-container-2" class="postbox-container">
        <?php 
    do_meta_boxes($current_screen->id, 'normal', $object);
    ?>
コード例 #6
0
/**
 * WP-CRM Actions and Hooks File
 *
 * Do not modify arrays found in these files, use the filters to modify them in your functions.php file
 * Sets up default settings and loads a few actions.
 *
 * Copyright 2011 Usability Dynamics, Inc. <*****@*****.**>
 *
 * @link http://twincitiestech.com/plugins/
 * @version 0.1
 * @author Usability Dynamics, Inc. <*****@*****.**>
 * @package WP-CRM
*/
// Load settings out of database to overwrite defaults from action_hooks.
$wp_crm_db = get_option('wp_crm_settings');
/*
  Default configuration
*/
$wp_crm['version'] = '0.1';
$wp_crm['configuration'] = array('default_user_capability' => 'prospect', 'default_user_capability_permissions_base' => 'subscriber', 'create_individual_pages_for_crm_capabilities' => 'true');
$wp_crm['configuration']['mail'] = array('sender_name' => get_bloginfo(), 'send_email' => get_bloginfo('admin_email'));
$wp_crm['configuration']['input_types'] = array('text' => __('Single Line Text', 'wp_crm'), 'checkbox' => __("Checkbox", 'wp_crm'), 'textarea' => __("Textarea", 'wp_crm'), 'dropdown' => __("Dropdown", 'wp_crm'), 'password' => __("Password", 'wp_crm'), 'date' => __("Date Picker", 'wp_crm'));
/*
  Permissions to be utilized through the plugin. 
  These are automatically added to admin in WPP_C::init();
*/
$wp_crm['capabilities'] = array('Manage Settings' => __('View and edit plugin settings.', 'wp_crm'), 'View Overview' => __('View individual prospects and the overview page.', 'wp_crm'), 'View Profiles' => __('View a user\'s profile.', 'wp_crm'), 'Add User Messages' => __('Add to correspondence thread on a user\'s profile.', 'wp_crm'), 'Send Group Message' => __('Send a group message to users.', 'wp_crm'), 'Perform Advanced Functions' => __('Perform advanced functions such as mergins users.', 'wp_crm'), 'Change Passwords' => __('Change passwords of other users. This is only checked if the user can edit users in the first place.', 'wp_crm'), 'Change Color Scheme' => __('Change color scheme. This is only checked if the user can edit users in the first place.', 'wp_crm'));
//** Overwrite $wp_crm with database setting */
if (!empty($wp_crm_db)) {
    $wp_crm = CRM_UD_F::array_merge_recursive_distinct($wp_crm, $wp_crm_db);
}
コード例 #7
0
    /**
     * Contact for the contact message overview page
     *
     * @version 1.0
     * Copyright 2011 Andy Potanin, Usability Dynamics, Inc.  <*****@*****.**>
     */
    static function crm_page_wp_crm_contact_messages()
    {
        global $current_screen, $screen_layout_columns;
        $wp_list_table = new WP_CMR_List_Table("table_scope=wp_crm_contact_messages&per_page=25&ajax_action=wp_crm_messages_table");
        //** Load items into table class */
        $wp_list_table->all_items = class_contact_messages::get_messages();
        //** Items are only loaded, prepare_items() only paginates them */
        $wp_list_table->prepare_items();
        $wp_list_table->data_tables_script();
        ?>
    <div class="wp_crm_overview_wrapper wrap">
      <div class="wp_crm_ajax_result"></div>
      <h2><?php 
        _e('Contact Messages', ud_get_wp_crm()->domain);
        ?>
</h2>
      <form id="wp-crm-filter" action="#" method="POST">
        <?php 
        if (!CRM_UD_F::is_older_wp_version('3.4')) {
            ?>
          <div id="poststuff">
          <div id="post-body" class="metabox-holder <?php 
            echo 2 == $screen_layout_columns ? 'columns-2' : 'columns-1';
            ?>
">
            <div id="post-body-content">
              <?php 
            $wp_list_table->display();
            ?>
            </div>
            <div id="postbox-container-1" class="postbox-container">
              <div id="side-sortables" class="meta-box-sortables ui-sortable">
                <?php 
            do_meta_boxes($current_screen->id, 'normal', $wp_list_table);
            ?>
              </div>
            </div>
          </div>
        </div><!-- /poststuff -->
        <?php 
        } else {
            ?>
          <div id="poststuff" class="<?php 
            echo $current_screen->id;
            ?>
_table metabox-holder <?php 
            echo 2 == $screen_layout_columns ? 'has-right-sidebar' : '';
            ?>
">
          <div class="wp_crm_sidebar inner-sidebar">
            <div class="meta-box-sortables ui-sortable">
              <?php 
            do_meta_boxes($current_screen->id, 'normal', $wp_list_table);
            ?>
            </div>
          </div>
          <div id="post-body">
            <div id="post-body-content">
              <?php 
            $wp_list_table->display();
            ?>
            </div><!-- /.post-body-content -->
          </div><!-- /.post-body -->
          <br class="clear"/>
        </div><!-- /#poststuff -->
        <?php 
        }
        ?>
      </form>
    </div><!-- /.wp_crm_overview_wrapper -->
  <?php 
    }
コード例 #8
0
 /**
  * Runs pre-header functions on admin-side only - ran on ALL admin pages
  *
  * Checks if plugin has been updated.
  *
  * @since 0.1
  *
  */
 function admin_init()
 {
     global $wp_rewrite, $wp_roles, $wp_crm, $wpdb, $current_user;
     //** Check if current page is profile page, and load global variable */
     WP_CRM_F::maybe_load_profile();
     do_action('wp_crm_metaboxes');
     //** Add overview table rows. Static because admin_menu is not loaded on ajax calls. */
     add_filter("manage_toplevel_page_wp_crm_columns", array('WP_CRM_Core', "overview_columns"));
     add_action('admin_print_scripts-' . $wp_crm['system']['pages']['settings'], create_function('', "wp_enqueue_script('jquery-ui-tabs');wp_enqueue_script('jquery-cookie');"));
     add_action('load-crm_page_wp_crm_add_new', array('WP_CRM_Core', 'wp_crm_save_user_data'));
     // Add metaboxes
     if (is_array($wp_crm['system']['pages'])) {
         $sidebar_boxes = array('special_actions');
         foreach ($wp_crm['system']['pages'] as $screen) {
             if (!class_exists($screen)) {
                 continue;
             }
             $location_prefixes = array('side_', 'normal_', 'advanced_');
             foreach (get_class_methods($screen) as $box) {
                 // Set context and priority if specified for box
                 $context = 'normal';
                 if (strpos($box, "side_") === 0 || in_array($box, $sidebar_boxes)) {
                     $context = 'side';
                 }
                 if (strpos($box, "advanced_") === 0) {
                     $context = 'advanced';
                 }
                 // Get name from slug
                 $label = CRM_UD_F::slug_to_label(str_replace($location_prefixes, '', $box));
                 add_meta_box($box, $label, array($screen, $box), $screen, $context, 'default');
             }
         }
     }
     //** Handle actions */
     if (isset($_REQUEST['wp_crm_action'])) {
         $_wpnonce = $_REQUEST['_wpnonce'];
         switch ($_REQUEST['wp_crm_action']) {
             case 'delete_user':
                 $user_id = $_REQUEST['user_id'];
                 if (wp_verify_nonce($_wpnonce, 'wp-crm-delete-user-' . $user_id)) {
                     //** Get IDs of users posts */
                     $post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_author = %d", $user_id));
                     //** Delete user and reassign all their posts to the current user */
                     if (wp_delete_user($user_id, $current_user->data->ID)) {
                         //** Trash all posts */
                         if (is_array($post_ids)) {
                             foreach ($post_ids as $trash_post) {
                                 wp_trash_post($trash_post);
                             }
                         }
                         wp_redirect(admin_url('admin.php?page=wp_crm&message=user_deleted'));
                     }
                 }
                 break;
         }
     }
     if ($wp_crm['configuration']['replace_default_user_page'] == 'true') {
         add_filter('admin_user_info_links', array('WP_CRM_Core', 'admin_user_info_links'), 10, 2);
     }
     add_filter('admin_title', array('WP_CRM_F', 'admin_title'));
 }
コード例 #9
0
ファイル: class_functions.php プロジェクト: Finzy/stageDB
 /**
  * Get user data structure.  May be depreciated.
  *
  * @since 0.1
  *
  */
 static function user_object_structure($args = '')
 {
     global $wp_crm, $wpdb;
     $defaults = array('table_cols' => 'false', 'root_only' => 'false');
     $args = wp_parse_args($args, $defaults);
     foreach ($wpdb->get_results("SHOW COLUMNS FROM {$wpdb->users}") as $column) {
         $a[$column->Field] = CRM_UD_F::de_slug($column->Field);
         $table_cols[] = $column->Field;
     }
     if (!empty($wp_crm['data_structure']) && is_array($wp_crm['data_structure']['attributes'])) {
         foreach ($wp_crm['data_structure']['attributes'] as $attribute => $attribute_data) {
             $a[$attribute] = $attribute_data['title'];
             if ($args['root_only'] == 'true') {
                 continue;
             }
             if (!empty($attribute_data['options'])) {
                 foreach (explode(',', $attribute_data['options']) as $this_option) {
                     $a[$attribute . '_' . CRM_UD_F::create_slug($this_option)] = $this_option;
                 }
             }
         }
     }
     if ($args['table_cols'] == 'true') {
         return $table_cols;
     }
     return $a;
 }