Changeset 1369147
- Timestamp:
- 03/11/2016 11:43:15 AM (10 years ago)
- Location:
- wtg-portal-manager/trunk
- Files:
-
- 7 edited
-
classes/class-configuration.php (modified) (3 diffs)
-
classes/class-requests.php (modified) (3 diffs)
-
classes/class-twitter.php (modified) (1 diff)
-
classes/class-wtgportalmanager.php (modified) (7 diffs)
-
readme.txt (modified) (2 diffs)
-
views/buildpages.php (modified) (1 diff)
-
wtg-portal-manager.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wtg-portal-manager/trunk/classes/class-configuration.php
r1359302 r1369147 158 158 159 159 /** 160 * INTRO 161 * 162 * GUIDE 160 * This function returns official post formats found 161 * in the WordPress core and custom ones. 162 * 163 * The things is WP does not currently allow custom ones 164 * properly. 165 * 166 * The data is used as page purposes in plugins like 167 * WTG Portal Manager. The purpose of a page allows us 168 * to apply functionality and not just layout. Default 169 * content is one use. 163 170 * 164 171 * @author Ryan R. Bayne 165 172 * @package WebTechGlobal WordPress Plugins 166 * @version 1. 0173 * @version 1.1 167 174 */ 168 175 public function postformats() { … … 260 267 'description' => __( 'This format will turn an array of product features into a list. Different levels of detail available so create a good array.', 'wtgportalmanager' ) 261 268 ); 262 269 263 270 $pf['updates'] = array( 264 271 'title' => __( 'Updates', 'wtgportalmanager' ), … … 297 304 ); 298 305 306 // Added March 2016 307 $pf['information'] = array( 308 'title' => __( 'Information', 'wtgportalmanager' ), 309 'wpsupported' => false, 310 'description' => __( 'General information, other, misc or holding page.', 'wtgportalmanager' ) 311 ); 312 313 // Added March 2016 314 $pf['steps'] = array( 315 'title' => __( 'Steps', 'wtgportalmanager' ), 316 'wpsupported' => false, 317 'description' => __( 'Meant for a list of step by step instructions with the intention of offering some sort of functionality per step and tracking the users progress.', 'wtgportalmanager' ) 318 ); 319 320 // Added March 2016 321 $pf['datatable'] = array( 322 'title' => __( 'Data Table', 'wtgportalmanager' ), 323 'wpsupported' => false, 324 'description' => __( 'Use for a view that focuses on offering a table of data. The intention is to offer highly interactive tables supported with Ajax.', 'wtgportalmanager' ) 325 ); 326 327 // Added March 2016 328 $pf['index'] = array( 329 'title' => __( 'Index', 'wtgportalmanager' ), 330 'wpsupported' => false, 331 'description' => __( 'Use for organized lists of related links with format applicable to the main subject if there is one. The intential of this format is to automatically administrate the index when pages are deleted or created with certain parents or even keywords.', 'wtgportalmanager' ) 332 ); 333 334 // Added March 2016 335 $pf['people'] = array( 336 'title' => __( 'People', 'wtgportalmanager' ), 337 'wpsupported' => false, 338 'description' => __( 'Use for to maintain a list of users related to something. It could be a list of donators, contributors or reference to developers who took part in a project. The key functionality is that WordPress user data is used to fill the 339 content.', 'wtgportalmanager' ) 340 ); 341 299 342 return $pf; 300 343 } -
wtg-portal-manager/trunk/classes/class-requests.php
r1365903 r1369147 628 628 * @package WTG Portal Manager 629 629 * @since 0.0.1 630 * @version 1. 0630 * @version 1.1 631 631 */ 632 632 public function createnewportalpage() { … … 638 638 639 639 if( $format == $_POST['pagepurpose'] ) { 640 $readable_purpose = $meta['title']; 641 } 642 643 } 644 645 // Get current portals name to use as the title. 646 $project_name = $this->DB->get_project_name( $project_id ); 647 648 // Build Page Title 649 $title = $project_name . ' ' . $readable_purpose; 650 651 // Create post object. 652 $my_post = array( 653 'post_title' => wp_strip_all_tags( $title ), 654 'post_content' => __( 'Under Construction', 'wtgportalmanager' ), 655 'post_status' => 'publish', 656 'post_author' => get_current_user_id(), 657 'post_type' => 'page' 658 ); 659 660 // Insert the post into the database. 661 $post_id = wp_insert_post( $my_post ); 662 663 if( !$post_id || !is_numeric( $post_id ) ) { 664 // Failure Output 665 $this->UI->create_notice( __( "WordPress could not create a new post using wp_insert_post(). Please 666 try again then report this issue to WebTechGlobal. Please note that wp_insert_post() is also used to 667 create pages in WP.", 'wtgportalmanager' ), 668 'success', 669 'Small', 670 __( 'WP Function Failed', 'wtgportalmanager' ) 671 ); 672 return false; 673 } 674 675 // Join Page To Portal 676 $this->WTGPORTALMANAGER->create_page_relationship( $project_id, $post_id ); 677 678 // Pages Purpose (Format) Meta 679 $this->DB->update_page_purpose( $project_id, $post_id, $_POST['pagepurpose'] ); 680 681 // Final Output - Create link to the new page in admin. 682 $link = get_edit_post_link( $post_id ); 683 $link = "<a href='$link' title='Edit post' target='_blank'>clicking here</a>"; 684 $message = sprintf( __( "A new page has been added to your current active portal. You can 685 now edit your post by %s", 'wtgportalmanager' ), $link ); 686 $this->UI->create_notice( $message, 687 'success', 688 'Small', 689 __( 'Page Relationship Created', 'wtgportalmanager' ) 690 ); 691 } 692 693 /** 694 * Create relationship between current portal and page (not post) 695 * 696 * @author Ryan R. Bayne 697 * @package WTG Portal Manager 698 * @since 0.0.1 699 * @version 1.0 700 */ 701 public function addpagerelationship() { 702 $project_id = $this->DB->get_active_project_id(); 703 $this->WTGPORTALMANAGER->create_page_relationship( $project_id, $_POST['addpageid'] ); 704 $this->DB->update_page_purpose( $project_id, $_POST['addpageid'], $_POST['pagepurpose'] ); 705 $this->UI->create_notice( 706 __( "Your page has been added to your current active portal.", 'wtgportalmanager' ), 707 'success', 708 'Small', 709 __( 'Page Relationship Created', 'wtgportalmanager' ) 710 ); 711 } 712 713 /** 714 * Handle requests made using the form that lists all 715 * related pages i.e. delete the relationship. 716 * 717 * @author Ryan R. Bayne 718 * @package WTG Portal Manager 719 * @since 0.0.1 720 * @version 1.0 721 */ 722 public function listrelatedpages() { 723 724 } 725 726 /** 727 * Sets the current portals main category. 728 * 729 * @author Ryan R. Bayne 730 * @package WTG Portal Manager 731 * @since 0.0.1 732 * @version 1.0 733 */ 734 public function maincategory() { 735 $this->WTGPORTALMANAGER->update_main_category( $this->DB->get_active_project_id(), $_POST['selectedcategory'] ); 736 $this->UI->create_notice( __( "The main category allows your portal to have a blog and the selected category will be focused on.", 'wtgportalmanager' ), 'success', 'Small', __( 'Main Category Set', 'wtgportalmanager' ) ); 737 } 738 739 /** 740 * Handle request to delete the relationship between 741 * portal and categories. 742 * 743 * @author Ryan R. Bayne 744 * @package WTG Portal Manager 745 * @since 0.0.1 746 * @version 1.0 747 */ 748 public function portalcategories() { 749 750 } 751 752 /** 753 * Create relationship between category and portal. 754 * 755 * @author Ryan R. Bayne 756 * @package WTG Portal Manager 757 * @since 0.0.1 758 * @version 1.0 759 */ 760 public function addcategories() { 761 $this->WTGPORTALMANAGER->add_portal_subcategory( $this->DB->get_active_project_id(), $_POST['selectedsubcategory'] ); 762 $this->UI->create_notice( __( "The new category is now available within your portal.", 'wtgportalmanager' ), 'success', 'Small', __( 'Category Added', 'wtgportalmanager' ) ); 763 } 764 765 /** 766 * Create relationship between users WP menu and portal. 767 * 768 * @author Ryan R. Bayne 769 * @package WTG Portal Manager 770 * @since 0.0.1 771 * @version 1.0 772 */ 773 public function addmenu() { 774 // 'selectedmenu' => string '2' (length=1) 775 // 'ismainmenu0' => string 'ismain' (length=6) 776 } 777 778 /** 779 * Handles request to delete relationship between menu and portal. 780 * 781 * @author Ryan R. Bayne 782 * @package WTG Portal Manager 783 * @since 0.0.1 784 * @version 1.0 785 */ 786 public function menulist() { 787 788 } 789 790 /** 791 * Adds a sidebar to this plugins options. This plugin 792 * needs to register the sidebar for use by dynamic_sidebars() 793 * which must be in theme sidebar.php 794 * 795 * @author Ryan R. Bayne 796 * @package WTG Portal Manager 797 * @since 0.0.1 798 * @version 1.0 799 */ 800 public function createsidebar() { 801 802 // Install sidebars option. This can be removed after March 2016. 803 if( !is_array( get_option( 'wtgportalmanager_sidebars' ) ) ) { 804 add_option( 'wtgportalmanager_sidebars', array(), false ); 805 } 806 807 $this->WTGPORTALMANAGER->insert_sidebar( $_POST['newsidebarname'] ); 808 809 $this->UI->create_notice( 810 __( "A new sidebar has been stored in this plugins 811 options (WP currently offers no alternative solution). As a result the new 812 sidebar will only be available while this plugin is active.", 'wtgportalmanager' ), 813 'success', 814 'Small', 815 __( 'Sidebar Registered', 'wtgportalmanager' ) 816 ); 817 } 818 819 /** 820 * Save the main sidebar ID. 821 * 822 * @author Ryan R. Bayne 823 * @package WTG Portal Manager 824 * @since 0.0.1 825 * @version 1.0 826 */ 827 public function setsidebars() { 828 // get the integration data I have setup in array - it is a long term array for all my plugins 829 $themes_integration_array = $this->WTGPORTALMANAGER->get_themes_integration_info(); 830 831 // loop current themes sidebars 832 foreach( $themes_integration_array['sidebars'] as $themes_dynamic_sidebars ) 833 { 834 835 // forms menu names and ID equal the post meta_key used to store sidebar ID's 836 $selected_sidebar_id = $_POST[ $themes_dynamic_sidebars['metakey'] ]; 837 838 // set new portal -> sidebar relationship which adds post meta_key used in sidebar.php to the portal meta_key 839 $this->WTGPORTALMANAGER->set_sidebar_relationship( $this->DB->get_active_project_id(), $themes_dynamic_sidebars['metakey'], $selected_sidebar_id ); 840 841 // add post meta to all posts that do not have it but do have a relationship with the current portal 842 // get post ID's by querying post, page, maincategory, subcategory meta_keys in portal table 843 844 } 845 846 $this->UI->create_notice( __( "Your current portals sidebars have been set. This change is applied instantly. Please view your portal as a none registered viewer to test.", 'wtgportalmanager' ), 'success', 'Small', __( 'Main Sidebar Set', 'wtgportalmanager' ) ); 847 } 848 849 /** 850 * Activates or disables API's 851 * 852 * @author Ryan R. Bayne 853 * @package WTG Portal Manager 854 * @since 0.0.1 855 * @version 1.0 856 */ 857 public function setupdefaulttwitter() { 858 global $wtgportalmanager_settings; 859 860 $wtgportalmanager_settings['api']['twitter']['active'] = $_POST['twitterapiswitch']; 861 //$wtgportalmanager_settings['api']['twitter']['apps']['default'] = $_POST['cache_expire']; 862 863 $wtgportalmanager_settings['api']['twitter']['apps']['default']['consumer_key'] = $_POST['consumer_key']; 864 $wtgportalmanager_settings['api']['twitter']['apps']['default']['consumer_secret'] = $_POST['consumer_secret']; 865 $wtgportalmanager_settings['api']['twitter']['apps']['default']['access_token'] = $_POST['access_token']; 866 $wtgportalmanager_settings['api']['twitter']['apps']['default']['token_secret'] = $_POST['access_token_secret']; 867 $wtgportalmanager_settings['api']['twitter']['apps']['default']['screenname'] = $_POST['screenname']; 868 869 $this->WTGPORTALMANAGER->update_settings( $wtgportalmanager_settings ); 870 $this->UI->create_notice( __( "Please check features related to the API 871 you disabled or activated and ensure they are working as normal.", 'wtgportalmanager' ), 872 'success', 'Small', __( 'API Updated', 'wtgportalmanager' ) ); 873 } 874 875 /** 876 * Store Twitter API settings for the current portal only. 877 * 878 * @author Ryan R. Bayne 879 * @package WTG Portal Manager 880 * @since 0.0.1 881 * @version 1.1 882 * 883 * @todo do these values require encryption? 884 */ 885 public function setupportaltwitter() { 886 global $wtgportalmanager_settings; 887 888 // Allow use of the Twitter API globally. 889 $wtgportalmanager_settings['api']['twitter']['active'] = true; 890 $this->WTGPORTALMANAGER->update_settings( $wtgportalmanager_settings ); 891 892 // Store Twitter API credentials for the current portal. 893 $this->WTGPORTALMANAGER->update_portals_twitter_api( 894 WTGPORTALMANAGER_PROJECT_ID, 895 $_POST['consumer_key'], 896 $_POST['consumer_secret'], 897 $_POST['access_token'], 898 $_POST['access_token_secret'], 899 $_POST['screenname'] 900 ); 901 902 $this->UI->create_notice( __( "You have updated the current portals 903 Twitter App credentials.", 'wtgportalmanager' ), 904 'success', 'Small', __( 'Portals Twitter Updated', 'wtgportalmanager' ) ); 905 } 906 907 /** 908 * Saves global forum configuration. 909 * 910 * @author Ryan R. Bayne 911 * @package WTG Portal Manager 912 * @since 0.0.1 913 * @version 1.0 914 */ 915 public function configureforum() { 916 global $wtgportalmanager_settings; 917 918 // sanitize path 919 $forum_path_modified = sanitize_text_field( $_POST['forumpath'] ); 920 $forum_path_modified = stripslashes_deep( $forum_path_modified ); 921 $forum_path_modified = trailingslashit( $forum_path_modified ); 922 923 // now determine if phpBB actually exists 924 $does_phpbb_exist = $this->PHPBB->phpbb_exists( $forum_path_modified ); 925 if( !$does_phpbb_exist ) { 926 $this->UI->create_notice( __( "Your forum installation could not be located on the path you gave. Please ensure your forum is supported and remember to visit the forum for advice.", 'wtgportalmanager' ), 'success', 'Small', __( 'Forum Not Found', 'wtgportalmanager' ) ); 927 return; 928 } 929 930 // include the phpBB config file - we need database prefix for queries 931 require( $forum_path_modified . 'config.php' ); 932 933 // add config to settings 934 $wtgportalmanager_settings['forumconfig']['path'] = $forum_path_modified; 935 $wtgportalmanager_settings['forumconfig']['status'] = $_POST['globalforumswitch']; 936 $wtgportalmanager_settings['forumconfig']['tableprefix'] = $table_prefix; 937 $wtgportalmanager_settings['forumconfig']['admrelativepath'] = $phpbb_adm_relative_path; 938 $wtgportalmanager_settings['forumconfig']['phpbbversion'] = $this->PHPBB->version(); 939 940 // ensure compatible phpBB version installed 941 if( $wtgportalmanager_settings['forumconfig']['phpbbversion'] < '3.1' ) { 942 $this->UI->create_notice( __( "This plugin does not support your current phpBB version which is " . $wtgportalmanager_settings['forumconfig']['phpbbversion'], 'wtgportalmanager' ), 'success', 'Small', __( 'Forum Version Not Supported', 'wtgportalmanager' ) ); 943 return; 944 } 945 946 $this->WTGPORTALMANAGER->update_settings( $wtgportalmanager_settings ); 947 948 $this->UI->create_notice( __( "You have saved your forums configuration and can now begin displaying forum data in your portals.", 'wtgportalmanager' ), 'success', 'Small', __( 'Forum Configuration Saved', 'wtgportalmanager' ) ); 949 } 950 951 /** 952 * Handle request to save the main forum settings for the current portal. 953 * 954 * @author Ryan R. Bayne 955 * @package WTG Portal Manager 956 * @since 0.0.1 957 * @version 1.0 958 */ 959 public function setupportalforum() { 960 $got_forum_row = $this->PHPBB->get_forum( $_POST['mainforumid'] ); 961 962 // ensure forum ID is valid (numeric validation already done before arriving here using my own security approach) 963 if( !$got_forum_row || empty( $got_forum_row ) ) { 964 $this->UI->create_notice( __( "The forum ID you entered does not match any forums in your phpBB database. Nothing was saved, please try again.", 'wtgportalmanager' ), 'error', 'Small', __( 'Forum Not Found', 'wtgportalmanager' ) ); 965 return; 966 } 967 968 $this->WTGPORTALMANAGER->update_portals_forumsettings( WTGPORTALMANAGER_PROJECT_ID, $_POST['portalforumswitch'], $_POST['mainforumid'] ); 969 $this->UI->create_notice( __( "You have saved your portals forum settings. If you set the switch to enabled then the next step is to ensure your portal is displaying information using forum data.", 'wtgportalmanager' ), 'success', 'Small', __( 'Forum Settings Saved', 'wtgportalmanager' ) ); 970 } 971 972 /** 973 * Handles request from form for selecting portals sources of information 974 * for display on the Updates page. 975 * 976 * @author Ryan R. Bayne 977 * @package WTG Portal Manager 978 * @since 0.0.1 979 * @version 1.2 980 */ 981 public function selectupdatesources() { 982 $this->DB->update_project_meta( WTGPORTALMANAGER_PROJECT_ID, 'updatepagesources', $_POST['informationsources'] ); 983 $this->UI->create_notice( __( "Sources of information for your Updates page were saved. You should check your current portals Updates page and ensure it is displaying what you expect.", 'wtgportalmanager' ), 'success', 'Small', __( 'Update Sources Saved', 'wtgportalmanager' ) ); 984 } 985 986 /** 987 * Handles request of selecting portals sources of information 988 * for display on the Activity page. 989 * 990 * @author Ryan R. Bayne 991 * @package WTG Portal Manager 992 * @since 0.0.1 993 * @version 1.2 994 */ 995 public function selectactivitysources() { 996 $this->DB->update_project_meta( WTGPORTALMANAGER_PROJECT_ID, 'activitypagesources', $_POST['informationsources'] ); 997 $this->UI->create_notice( 998 __( "Sources of information for your Activity page were saved. You should 999 check your current portals Updates page and ensure it is displaying what you expect.", 'wtgportalmanager' ), 1000 'success', 1001 'Small', 1002 __( 'Activity Sources Saved', 'wtgportalmanager' ) 1003 ); 1004 } 1005 1006 /** 1007 * Debug mode switch. 1008 * 1009 * @author Ryan R. Bayne 1010 * @package WebTechGlobal WordPress Plugins 1011 * @version 1.0 1012 */ 1013 public function debugmodeswitch() { 1014 $debug_status = get_option( 'webtechglobal_displayerrors' ); 1015 if($debug_status){ 1016 update_option( 'webtechglobal_displayerrors',false ); 1017 $new = 'disabled'; 1018 1019 $this->UI->create_notice( __( "Error display mode has been $new." ), 'success', 'Tiny', 1020 __( 'Debug Mode Switch', 'wtgportalmanager' ) ); 1021 1022 wp_redirect( get_bloginfo( 'url' ) . '/wp-admin/admin.php?page=' . $_GET['page'] ); 1023 exit; 1024 } else { 1025 update_option( 'webtechglobal_displayerrors',true ); 1026 $new = 'enabled'; 1027 1028 $this->UI->create_notice( __( "Error display mode has been $new." ), 'success', 'Tiny', 1029 __( 'Debug Mode Switch', 'wtgportalmanager' ) ); 1030 1031 wp_redirect( get_bloginfo( 'url' ) . '/wp-admin/admin.php?page=' . $_GET['page'] ); 1032 exit; 1033 } 1034 } 1035 1036 /** 1037 * Destroy the relationship between a page and project. 1038 * 1039 * @author Ryan R. Bayne 1040 * @package WebTechGlobal WordPress Plugins 1041 * @since 0.1.1 1042 * @version 1.0 1043 */ 1044 public function removeprojectpage() { 1045 global $wpdb; 1046 1047 if( !isset( $_GET['removedid']) ) { 1048 $this->UI->create_notice( __( "No valid page ID in the URL." ), 'error', 'Tiny', 1049 __( 'Portal Not Changed', 'wtgportalmanager' ) ); 1050 return; 1051 } 1052 1053 if( !is_numeric( $_GET['removedid'] ) ) { 1054 $this->UI->create_notice( __( "Invalid page ID in the URL, please ry again." ), 'error', 'Tiny', 1055 __( 'No Changes To Portal', 'wtgportalmanager' ) ); 1056 return; 1057 } 1058 1059 $this->DB->undo_project_page( WTGPORTALMANAGER_PROJECT_ID, $_GET['removedid'] ); 1060 1061 $this->UI->create_notice( __( "Page removed from portal. It will no longer be displayed in the portals 1062 meny or in the porals admin option." ), 'success', 'Tiny', 1063 __( 'Portal Changed', 'wtgportalmanager' ) ); 1064 } 1065 1066 /** 1067 * Developer tools options form submission. 1068 * 1069 * @author Ryan R. Bayne 1070 * @package WebTechGlobal WordPress Plugins 1071 * @since 0.0.11 1072 * @version 1.2 1073 */ 1074 public function developertoolssetup() { 1075 global $wp_roles; 1076 1077 // Does developer role exist? 1078 $developer_role_status = false; 1079 foreach( $wp_roles->roles as $role_name => $role_array ) { 1080 if( $role_name == 'developer' ) { 1081 $developer_role_status = true; 1082 } 1083 } 1084 1085 // Do we need to install developer role? 1086 $developer_role_result = null; 1087 if( !$developer_role_status ) { 1088 1089 // Collect capabilities from $_POST for developer role. 1090 $added_caps = array(); 1091 foreach( $_POST['addrolecapabilities'] as $numeric_key => $role_name ) { 1092 $added_caps[ $role_name ] = true; 1093 } 1094 1095 // Add the developer role. 1096 $developer_role_result = add_role( 1097 'developer', 1098 'Developer', 1099 $added_caps 1100 ); 1101 } 1102 1103 if ( null !== $developer_role_result ) { 1104 1105 $description = __( "Multitool installed the Developer Role 1106 to your blog. The role and its abilities will apply to all 1107 WebTechGlobal plugins you have installed.", 'wtgportalmanager' ); 1108 $title = __( 'Developer Role Installed', 'wtgportalmanager' ); 1109 $this->UI->create_notice( 1110 $description, 1111 'success', 1112 'Small', 1113 $title 1114 ); 1115 1116 } else { 1117 1118 $description = __( "The developer role appears to have 1119 been installed already. No changes to your roles were made.", 'wtgportalmanager' ); 1120 $title = __( 'No Role Changes', 'wtgportalmanager' ); 1121 $this->UI->create_notice( 1122 $description, 1123 'info', 1124 'Small', 1125 $title 1126 ); 1127 1128 } 1129 } 1130 1131 /** 1132 * Create a page for the current portal. 1133 * 1134 * @author Ryan R. Bayne 1135 * @package WebTechGlobal WordPress Plugins 1136 * @version 1.0 1137 * 1138 * @todo use array of formats and custom formats to valid the $_GET['format'] value. 1139 */ 1140 public function quickcreateportalpage() { 1141 $project_id = $this->DB->get_active_project_id(); 1142 1143 // Convert users page purpose selection to readable format. 1144 $readable_purpose = ''; 1145 foreach( $this->CONFIG->postformats() as $format => $meta ) { 1146 1147 if( $format == $_GET['format'] ) { 640 1148 $readable_purpose = $meta['title']; 641 1149 } … … 665 1173 666 1174 // Pages Purpose (Format) Meta 667 $this->DB->update_page_purpose( $project_id, $post_id, $_POST['pagepurpose'] );668 669 // Final Output670 $this->UI->create_notice( __( "A new page has been added to your current671 active portal.", 'wtgportalmanager' ),672 'success',673 'Small',674 __( 'Page Relationship Created', 'wtgportalmanager' )675 );676 }677 678 /**679 * Create relationship between current portal and page (not post)680 *681 * @author Ryan R. Bayne682 * @package WTG Portal Manager683 * @since 0.0.1684 * @version 1.0685 */686 public function addpagerelationship() {687 $project_id = $this->DB->get_active_project_id();688 $this->WTGPORTALMANAGER->create_page_relationship( $project_id, $_POST['addpageid'] );689 $this->DB->update_page_purpose( $project_id, $_POST['addpageid'], $_POST['pagepurpose'] );690 $this->UI->create_notice( __( "A new page has been added to your current active portal.", 'wtgportalmanager' ), 'success', 'Small', __( 'Page Relationship Created', 'wtgportalmanager' ) );691 }692 693 /**694 * Handle requests made using the form that lists all695 * related pages i.e. delete the relationship.696 *697 * @author Ryan R. Bayne698 * @package WTG Portal Manager699 * @since 0.0.1700 * @version 1.0701 */702 public function listrelatedpages() {703 704 }705 706 /**707 * Sets the current portals main category.708 *709 * @author Ryan R. Bayne710 * @package WTG Portal Manager711 * @since 0.0.1712 * @version 1.0713 */714 public function maincategory() {715 $this->WTGPORTALMANAGER->update_main_category( $this->DB->get_active_project_id(), $_POST['selectedcategory'] );716 $this->UI->create_notice( __( "The main category allows your portal to have a blog and the selected category will be focused on.", 'wtgportalmanager' ), 'success', 'Small', __( 'Main Category Set', 'wtgportalmanager' ) );717 }718 719 /**720 * Handle request to delete the relationship between721 * portal and categories.722 *723 * @author Ryan R. Bayne724 * @package WTG Portal Manager725 * @since 0.0.1726 * @version 1.0727 */728 public function portalcategories() {729 730 }731 732 /**733 * Create relationship between category and portal.734 *735 * @author Ryan R. Bayne736 * @package WTG Portal Manager737 * @since 0.0.1738 * @version 1.0739 */740 public function addcategories() {741 $this->WTGPORTALMANAGER->add_portal_subcategory( $this->DB->get_active_project_id(), $_POST['selectedsubcategory'] );742 $this->UI->create_notice( __( "The new category is now available within your portal.", 'wtgportalmanager' ), 'success', 'Small', __( 'Category Added', 'wtgportalmanager' ) );743 }744 745 /**746 * Create relationship between users WP menu and portal.747 *748 * @author Ryan R. Bayne749 * @package WTG Portal Manager750 * @since 0.0.1751 * @version 1.0752 */753 public function addmenu() {754 // 'selectedmenu' => string '2' (length=1)755 // 'ismainmenu0' => string 'ismain' (length=6)756 }757 758 /**759 * Handles request to delete relationship between menu and portal.760 *761 * @author Ryan R. Bayne762 * @package WTG Portal Manager763 * @since 0.0.1764 * @version 1.0765 */766 public function menulist() {767 768 }769 770 /**771 * Adds a sidebar to this plugins options. This plugin772 * needs to register the sidebar for use by dynamic_sidebars()773 * which must be in theme sidebar.php774 *775 * @author Ryan R. Bayne776 * @package WTG Portal Manager777 * @since 0.0.1778 * @version 1.0779 */780 public function createsidebar() {781 782 // Install sidebars option. This can be removed after March 2016.783 if( !is_array( get_option( 'wtgportalmanager_sidebars' ) ) ) {784 add_option( 'wtgportalmanager_sidebars', array(), false );785 }786 787 $this->WTGPORTALMANAGER->insert_sidebar( $_POST['newsidebarname'] );788 789 $this->UI->create_notice(790 __( "A new sidebar has been stored in this plugins791 options (WP currently offers no alternative solution). As a result the new792 sidebar will only be available while this plugin is active.", 'wtgportalmanager' ),793 'success',794 'Small',795 __( 'Sidebar Registered', 'wtgportalmanager' )796 );797 }798 799 /**800 * Save the main sidebar ID.801 *802 * @author Ryan R. Bayne803 * @package WTG Portal Manager804 * @since 0.0.1805 * @version 1.0806 */807 public function setsidebars() {808 // get the integration data I have setup in array - it is a long term array for all my plugins809 $themes_integration_array = $this->WTGPORTALMANAGER->get_themes_integration_info();810 811 // loop current themes sidebars812 foreach( $themes_integration_array['sidebars'] as $themes_dynamic_sidebars )813 {814 815 // forms menu names and ID equal the post meta_key used to store sidebar ID's816 $selected_sidebar_id = $_POST[ $themes_dynamic_sidebars['metakey'] ];817 818 // set new portal -> sidebar relationship which adds post meta_key used in sidebar.php to the portal meta_key819 $this->WTGPORTALMANAGER->set_sidebar_relationship( $this->DB->get_active_project_id(), $themes_dynamic_sidebars['metakey'], $selected_sidebar_id );820 821 // add post meta to all posts that do not have it but do have a relationship with the current portal822 // get post ID's by querying post, page, maincategory, subcategory meta_keys in portal table823 824 }825 826 $this->UI->create_notice( __( "Your current portals sidebars have been set. This change is applied instantly. Please view your portal as a none registered viewer to test.", 'wtgportalmanager' ), 'success', 'Small', __( 'Main Sidebar Set', 'wtgportalmanager' ) );827 }828 829 /**830 * Activates or disables API's831 *832 * @author Ryan R. Bayne833 * @package WTG Portal Manager834 * @since 0.0.1835 * @version 1.0836 */837 public function setupdefaulttwitter() {838 global $wtgportalmanager_settings;839 840 $wtgportalmanager_settings['api']['twitter']['active'] = $_POST['twitterapiswitch'];841 //$wtgportalmanager_settings['api']['twitter']['apps']['default'] = $_POST['cache_expire'];842 843 $wtgportalmanager_settings['api']['twitter']['apps']['default']['consumer_key'] = $_POST['consumer_key'];844 $wtgportalmanager_settings['api']['twitter']['apps']['default']['consumer_secret'] = $_POST['consumer_secret'];845 $wtgportalmanager_settings['api']['twitter']['apps']['default']['access_token'] = $_POST['access_token'];846 $wtgportalmanager_settings['api']['twitter']['apps']['default']['token_secret'] = $_POST['access_token_secret'];847 $wtgportalmanager_settings['api']['twitter']['apps']['default']['screenname'] = $_POST['screenname'];848 849 $this->WTGPORTALMANAGER->update_settings( $wtgportalmanager_settings );850 $this->UI->create_notice( __( "Please check features related to the API851 you disabled or activated and ensure they are working as normal.", 'wtgportalmanager' ),852 'success', 'Small', __( 'API Updated', 'wtgportalmanager' ) );853 }854 855 /**856 * Store Twitter API settings for the current portal only.857 *858 * @author Ryan R. Bayne859 * @package WTG Portal Manager860 * @since 0.0.1861 * @version 1.1862 *863 * @todo do these values require encryption?864 */865 public function setupportaltwitter() {866 global $wtgportalmanager_settings;867 868 // Allow use of the Twitter API globally.869 $wtgportalmanager_settings['api']['twitter']['active'] = true;870 $this->WTGPORTALMANAGER->update_settings( $wtgportalmanager_settings );871 872 // Store Twitter API credentials for the current portal.873 $this->WTGPORTALMANAGER->update_portals_twitter_api(874 WTGPORTALMANAGER_PROJECT_ID,875 $_POST['consumer_key'],876 $_POST['consumer_secret'],877 $_POST['access_token'],878 $_POST['access_token_secret'],879 $_POST['screenname']880 );881 882 $this->UI->create_notice( __( "You have updated the current portals883 Twitter App credentials.", 'wtgportalmanager' ),884 'success', 'Small', __( 'Portals Twitter Updated', 'wtgportalmanager' ) );885 }886 887 /**888 * Saves global forum configuration.889 *890 * @author Ryan R. Bayne891 * @package WTG Portal Manager892 * @since 0.0.1893 * @version 1.0894 */895 public function configureforum() {896 global $wtgportalmanager_settings;897 898 // sanitize path899 $forum_path_modified = sanitize_text_field( $_POST['forumpath'] );900 $forum_path_modified = stripslashes_deep( $forum_path_modified );901 $forum_path_modified = trailingslashit( $forum_path_modified );902 903 // now determine if phpBB actually exists904 $does_phpbb_exist = $this->PHPBB->phpbb_exists( $forum_path_modified );905 if( !$does_phpbb_exist ) {906 $this->UI->create_notice( __( "Your forum installation could not be located on the path you gave. Please ensure your forum is supported and remember to visit the forum for advice.", 'wtgportalmanager' ), 'success', 'Small', __( 'Forum Not Found', 'wtgportalmanager' ) );907 return;908 }909 910 // include the phpBB config file - we need database prefix for queries911 require( $forum_path_modified . 'config.php' );912 913 // add config to settings914 $wtgportalmanager_settings['forumconfig']['path'] = $forum_path_modified;915 $wtgportalmanager_settings['forumconfig']['status'] = $_POST['globalforumswitch'];916 $wtgportalmanager_settings['forumconfig']['tableprefix'] = $table_prefix;917 $wtgportalmanager_settings['forumconfig']['admrelativepath'] = $phpbb_adm_relative_path;918 $wtgportalmanager_settings['forumconfig']['phpbbversion'] = $this->PHPBB->version();919 920 // ensure compatible phpBB version installed921 if( $wtgportalmanager_settings['forumconfig']['phpbbversion'] < '3.1' ) {922 $this->UI->create_notice( __( "This plugin does not support your current phpBB version which is " . $wtgportalmanager_settings['forumconfig']['phpbbversion'], 'wtgportalmanager' ), 'success', 'Small', __( 'Forum Version Not Supported', 'wtgportalmanager' ) );923 return;924 }925 926 $this->WTGPORTALMANAGER->update_settings( $wtgportalmanager_settings );927 928 $this->UI->create_notice( __( "You have saved your forums configuration and can now begin displaying forum data in your portals.", 'wtgportalmanager' ), 'success', 'Small', __( 'Forum Configuration Saved', 'wtgportalmanager' ) );929 }930 931 /**932 * Handle request to save the main forum settings for the current portal.933 *934 * @author Ryan R. Bayne935 * @package WTG Portal Manager936 * @since 0.0.1937 * @version 1.0938 */939 public function setupportalforum() {940 $got_forum_row = $this->PHPBB->get_forum( $_POST['mainforumid'] );941 942 // ensure forum ID is valid (numeric validation already done before arriving here using my own security approach)943 if( !$got_forum_row || empty( $got_forum_row ) ) {944 $this->UI->create_notice( __( "The forum ID you entered does not match any forums in your phpBB database. Nothing was saved, please try again.", 'wtgportalmanager' ), 'error', 'Small', __( 'Forum Not Found', 'wtgportalmanager' ) );945 return;946 }947 948 $this->WTGPORTALMANAGER->update_portals_forumsettings( WTGPORTALMANAGER_PROJECT_ID, $_POST['portalforumswitch'], $_POST['mainforumid'] );949 $this->UI->create_notice( __( "You have saved your portals forum settings. If you set the switch to enabled then the next step is to ensure your portal is displaying information using forum data.", 'wtgportalmanager' ), 'success', 'Small', __( 'Forum Settings Saved', 'wtgportalmanager' ) );950 }951 952 /**953 * Handles request from form for selecting portals sources of information954 * for display on the Updates page.955 *956 * @author Ryan R. Bayne957 * @package WTG Portal Manager958 * @since 0.0.1959 * @version 1.2960 */961 public function selectupdatesources() {962 $this->DB->update_project_meta( WTGPORTALMANAGER_PROJECT_ID, 'updatepagesources', $_POST['informationsources'] );963 $this->UI->create_notice( __( "Sources of information for your Updates page were saved. You should check your current portals Updates page and ensure it is displaying what you expect.", 'wtgportalmanager' ), 'success', 'Small', __( 'Update Sources Saved', 'wtgportalmanager' ) );964 }965 966 /**967 * Handles request of selecting portals sources of information968 * for display on the Activity page.969 *970 * @author Ryan R. Bayne971 * @package WTG Portal Manager972 * @since 0.0.1973 * @version 1.2974 */975 public function selectactivitysources() {976 $this->DB->update_project_meta( WTGPORTALMANAGER_PROJECT_ID, 'activitypagesources', $_POST['informationsources'] );977 $this->UI->create_notice(978 __( "Sources of information for your Activity page were saved. You should979 check your current portals Updates page and ensure it is displaying what you expect.", 'wtgportalmanager' ),980 'success',981 'Small',982 __( 'Activity Sources Saved', 'wtgportalmanager' )983 );984 }985 986 /**987 * Debug mode switch.988 *989 * @author Ryan R. Bayne990 * @package WebTechGlobal WordPress Plugins991 * @version 1.0992 */993 public function debugmodeswitch() {994 $debug_status = get_option( 'webtechglobal_displayerrors' );995 if($debug_status){996 update_option( 'webtechglobal_displayerrors',false );997 $new = 'disabled';998 999 $this->UI->create_notice( __( "Error display mode has been $new." ), 'success', 'Tiny',1000 __( 'Debug Mode Switch', 'wtgportalmanager' ) );1001 1002 wp_redirect( get_bloginfo( 'url' ) . '/wp-admin/admin.php?page=' . $_GET['page'] );1003 exit;1004 } else {1005 update_option( 'webtechglobal_displayerrors',true );1006 $new = 'enabled';1007 1008 $this->UI->create_notice( __( "Error display mode has been $new." ), 'success', 'Tiny',1009 __( 'Debug Mode Switch', 'wtgportalmanager' ) );1010 1011 wp_redirect( get_bloginfo( 'url' ) . '/wp-admin/admin.php?page=' . $_GET['page'] );1012 exit;1013 }1014 }1015 1016 /**1017 * Destroy the relationship between a page and project.1018 *1019 * @author Ryan R. Bayne1020 * @package WebTechGlobal WordPress Plugins1021 * @since 0.1.11022 * @version 1.01023 */1024 public function removeprojectpage() {1025 global $wpdb;1026 1027 if( !isset( $_GET['removedid']) ) {1028 $this->UI->create_notice( __( "No valid page ID in the URL." ), 'error', 'Tiny',1029 __( 'Portal Not Changed', 'wtgportalmanager' ) );1030 return;1031 }1032 1033 if( !is_numeric( $_GET['removedid'] ) ) {1034 $this->UI->create_notice( __( "Invalid page ID in the URL, please ry again." ), 'error', 'Tiny',1035 __( 'No Changes To Portal', 'wtgportalmanager' ) );1036 return;1037 }1038 1039 $this->DB->undo_project_page( WTGPORTALMANAGER_PROJECT_ID, $_GET['removedid'] );1040 1041 $this->UI->create_notice( __( "Page removed from portal. It will no longer be displayed in the portals1042 meny or in the porals admin option." ), 'success', 'Tiny',1043 __( 'Portal Changed', 'wtgportalmanager' ) );1044 }1045 1046 /**1047 * Developer tools options form submission.1048 *1049 * @author Ryan R. Bayne1050 * @package WebTechGlobal WordPress Plugins1051 * @since 0.0.111052 * @version 1.21053 */1054 public function developertoolssetup() {1055 global $wp_roles;1056 1057 // Does developer role exist?1058 $developer_role_status = false;1059 foreach( $wp_roles->roles as $role_name => $role_array ) {1060 if( $role_name == 'developer' ) {1061 $developer_role_status = true;1062 }1063 }1064 1065 // Do we need to install developer role?1066 $developer_role_result = null;1067 if( !$developer_role_status ) {1068 1069 // Collect capabilities from $_POST for developer role.1070 $added_caps = array();1071 foreach( $_POST['addrolecapabilities'] as $numeric_key => $role_name ) {1072 $added_caps[ $role_name ] = true;1073 }1074 1075 // Add the developer role.1076 $developer_role_result = add_role(1077 'developer',1078 'Developer',1079 $added_caps1080 );1081 }1082 1083 if ( null !== $developer_role_result ) {1084 1085 $description = __( "Multitool installed the Developer Role1086 to your blog. The role and its abilities will apply to all1087 WebTechGlobal plugins you have installed.", 'wtgportalmanager' );1088 $title = __( 'Developer Role Installed', 'wtgportalmanager' );1089 $this->UI->create_notice(1090 $description,1091 'success',1092 'Small',1093 $title1094 );1095 1096 } else {1097 1098 $description = __( "The developer role appears to have1099 been installed already. No changes to your roles were made.", 'wtgportalmanager' );1100 $title = __( 'No Role Changes', 'wtgportalmanager' );1101 $this->UI->create_notice(1102 $description,1103 'info',1104 'Small',1105 $title1106 );1107 1108 }1109 }1110 1111 /**1112 * Create a page for the current portal.1113 *1114 * @author Ryan R. Bayne1115 * @package WebTechGlobal WordPress Plugins1116 * @version 1.01117 *1118 * @todo use array of formats and custom formats to valid the $_GET['format'] value.1119 */1120 public function quickcreateportalpage() {1121 $project_id = $this->DB->get_active_project_id();1122 1123 // Convert users page purpose selection to readable format.1124 $readable_purpose = '';1125 foreach( $this->CONFIG->postformats() as $format => $meta ) {1126 1127 if( $format == $_GET['format'] ) {1128 $readable_purpose = $meta['title'];1129 }1130 1131 }1132 1133 // Get current portals name to use as the title.1134 $project_name = $this->DB->get_project_name( $project_id );1135 1136 // Build Page Title1137 $title = $project_name . ' ' . $readable_purpose;1138 1139 // Create post object.1140 $my_post = array(1141 'post_title' => wp_strip_all_tags( $title ),1142 'post_content' => __( 'Under Construction', 'wtgportalmanager' ),1143 'post_status' => 'publish',1144 'post_author' => get_current_user_id(),1145 'post_type' => 'page'1146 );1147 1148 // Insert the post into the database.1149 $post_id = wp_insert_post( $my_post );1150 1151 // Join Page To Portal1152 $this->WTGPORTALMANAGER->create_page_relationship( $project_id, $post_id );1153 1154 // Pages Purpose (Format) Meta1155 1175 $this->DB->update_page_purpose( $project_id, $post_id, $_GET['format'] ); 1156 1176 -
wtg-portal-manager/trunk/classes/class-twitter.php
r1359302 r1369147 70 70 * @version 1.0 71 71 * 72 * @returns boolean false if no defualt credentials stored. 73 * 72 74 * @todo Change storage of default API credentials to the options table and serialize values. 73 75 */ 74 76 public function get_default_credentials() { 75 77 global $wtgportalmanager_settings; 76 return $wtgportalmanager_settings['api']['twitter']['apps']['default']; 78 if( isset( $wtgportalmanager_settings['api']['twitter']['apps']['default'] ) ) { 79 return $wtgportalmanager_settings['api']['twitter']['apps']['default']; 80 } 81 return false; 77 82 } 78 83 -
wtg-portal-manager/trunk/classes/class-wtgportalmanager.php
r1365903 r1369147 177 177 * @package WTG Portal Manager 178 178 * @since 0.0.1 179 * @version 1. 2179 * @version 1.3 180 180 * 181 181 * @todo create an option for the cache period … … 185 185 */ 186 186 public function portal_updates_shortcode( $atts ) { 187 187 188 188 // if we do not have a portal ID - we will assume we are on a view that does not 189 189 // yet support it i.e. category with a list of posts. … … 202 202 203 203 // check for a cached list of items 204 //delete_transient( 'wtgportalmanager_updatepage' . WTGPORTALMANAGER_PUBLIC_PROJECTID ); var_dump( 'Transient cache deleted during testing on line ' . __LINE__ ); 204 205 $cached_query = get_transient( 'wtgportalmanager_updatepage' . WTGPORTALMANAGER_PUBLIC_PROJECTID ); 205 206 if( $cached_query !== false ) { … … 271 272 // Establish a set of Twitter API credentials. 272 273 $portals_api_credentials = self::get_portals_twitter_api( WTGPORTALMANAGER_PUBLIC_PROJECTID ); 273 274 274 275 // Establish if any values are going to cause a problem. 275 276 $problem_found = false; 276 277 if( is_array( $portals_api_credentials ) ) { 277 278 279 // Replace portals configuration with the credentials passed to this method. 280 if( isset( $atts['usertimeline'] ) && is_string( $atts['usertimeline'] ) ) { 281 $portals_api_credentials['screenname'] = $atts['usertimeline']; 282 } 283 278 284 // usertimeline 279 if( ! isset( $portals_api_credentials['screenname'] ) || !is_string( $portals_api_credentials['screenname'] )) {285 if( !$portals_api_credentials['screenname'] || $portals_api_credentials['screenname'] == '' ) { 280 286 $problem_found = 'screenname'; 281 287 } … … 300 306 $problem_found = 'token_secret'; 301 307 } 308 } 309 else { 310 $problem_found = 'The current portal does not have any Twitter credentials.'; 302 311 } 303 312 304 313 // If the $api_credentials giving are not valid then use default to help reduce problems. 305 314 if( $problem_found !== false ) { … … 311 320 312 321 // Write over defaults with the credentials passed to this method. 313 322 if( isset( $atts['usertimeline'] ) && is_string( $atts['usertimeline'] ) ) { 323 $default_api_credentials['screenname'] = $atts['usertimeline']; 324 } 325 314 326 // usertimeline 315 327 if( !$default_api_credentials['screenname'] ) { $invalid_default_credentials = 'screenname'; } … … 3320 3332 break; 3321 3333 case 'updates': 3322 $default_content = "[portalupdate projectid=$project_idusertimeline=WebTechGlobal]";3334 $default_content = "[portalupdate usertimeline=WebTechGlobal]"; 3323 3335 break; 3324 3336 case 2: -
wtg-portal-manager/trunk/readme.txt
r1365903 r1369147 37 37 1. High customization per portal is the goal, more to come soon! 38 38 39 = Work In Progress = 40 * Current Portal Selection menu on main page defaults to the first item. 41 * Too many configuration values are being stored in the settings array. Starting with sidebars move them to individual options. 42 * Serialize API credentials using key stored in plugin. 43 * Need a way to delete values in a form and reset it. 44 * Add functionality to the portal information in head of pages i.e. link to the portal, quick tools. 45 * Allow more than one Twitter account to be used on Updates list. 46 * Default values on Create Portal menus might be the cause of security warnings. 47 * Developer widget - will include portal ID and functionality for quickly changing portal. 48 * Setup a Trello account for this project. 49 39 50 == Installation == 40 51 … … 89 100 This method is safer than using any other source for the files. 90 101 91 == Changelog == 102 == Changelog == 103 = 1.0.6 = 104 * Feature Changes 105 * Incorrect text replaced on Create New Portal Page form. 106 * New page purposes added: information, steps, datatable, index and people. 107 * Added link to notice for creation of new portal page. 108 * Technical Changes 109 * A shortcode like [portalupdate timeline="WebTechGlobal"] now works better as the timeline value over-rides all others. 110 92 111 = 1.0.5 = 93 112 * Feature Changes -
wtg-portal-manager/trunk/views/buildpages.php
r1365903 r1369147 133 133 * @author Ryan Bayne 134 134 * @package WTG Portal Manager 135 * @version 1. 0135 * @version 1.1 136 136 */ 137 137 public function postbox_buildpages_createnewportalpage( $data, $box ) { 138 139 $this->UI->postbox_content_header( $box['title'], $box['args']['formid'], __( 'Add an existing page to your active portal. A relationship between page and portal will be created - allowing other options for that page.', 'wtgportalmanager' ), false ); 138 $this->UI->postbox_content_header( $box['title'], $box['args']['formid'], 139 __( 'Create a new page with a specific purpose for the current portal. It 140 will be instantly associated with your portal and added to the portals menu.', 'wtgportalmanager' ), false ); 140 141 $this->Forms->form_start( $box['args']['formid'], $box['args']['formid'], $box['title'] ); 141 142 ?> -
wtg-portal-manager/trunk/wtg-portal-manager.php
r1365903 r1369147 2 2 /* 3 3 Plugin Name: WTG Portal Manager Beta 4 Version: 1.0. 54 Version: 1.0.6 5 5 Plugin URI: http://www.webtechglobal.co.uk/ 6 6 Description: Every service and product can have a portal on your WordPress site. … … 42 42 43 43 // define constants, feel free to add some of your own... 44 if(!defined( "WTGPORTALMANAGER_VERSION") ){define( "WTGPORTALMANAGER_VERSION", '1.0. 5' );}44 if(!defined( "WTGPORTALMANAGER_VERSION") ){define( "WTGPORTALMANAGER_VERSION", '1.0.6' );} 45 45 if(!defined( "WTGPORTALMANAGER_NAME") ){define( "WTGPORTALMANAGER_NAME", 'WTG Portal Manager' );} 46 46 if(!defined( "WTGPORTALMANAGER__FILE__") ){define( "WTGPORTALMANAGER__FILE__", __FILE__);}
Note: See TracChangeset
for help on using the changeset viewer.