Make WordPress Core

Changeset 6473


Ignore:
Timestamp:
12/23/2007 01:35:44 AM (17 years ago)
Author:
ryan
Message:

Add xmlrpc_call actions. Cleanup some whitespace.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xmlrpc.php

    r6418 r6473  
    231231            return($this->error);
    232232        }
     233
     234        do_action("xmlrpc_call", "wp.getPage");
    233235
    234236        // Lookup page info.
     
    314316        }
    315317
     318        do_action("xmlrpc_call", "wp.getPages");
     319
    316320        // Lookup info on pages.
    317321        $pages = get_pages();
     
    352356        }
    353357
     358        do_action("xmlrpc_call", "wp.newPage");
     359
    354360        // Set the user context and check if they are allowed
    355361        // to add new pages.
     
    381387            return($this->error);
    382388        }
     389
     390        do_action("xmlrpc_call", "wp.deletePage");
    383391
    384392        // Get the current page based on the page_id and
     
    424432        }
    425433
     434        do_action("xmlrpc_call", "wp.editPage");
     435
    426436        // Get the page data and make sure it is a page.
    427437        $actual_page = wp_get_single_post($page_id, ARRAY_A);
     
    471481            return($this->error);
    472482        }
     483
     484        do_action("xmlrpc_call", "wp.getPageList");
    473485
    474486        // Get list of pages ids and titles
     
    516528        }
    517529
     530        do_action("xmlrpc_call", "wp.getAuthors");
     531
    518532        return(get_users_of_blog());
    519533    }
     
    534548            return($this->error);
    535549        }
     550
     551        do_action("xmlrpc_call", "wp.newCategory");
    536552
    537553        // Set the user context and make sure they are
     
    589605        }
    590606
     607        do_action("xmlrpc_call", "wp.deleteCategory");
     608
    591609        set_current_user(0, $username);
    592610        if( !current_user_can("manage_categories") ) {
     
    614632            return($this->error);
    615633        }
     634
     635        do_action("xmlrpc_call", "wp.suggestCategories");
    616636
    617637        $category_suggestions = array();
     
    645665        }
    646666
     667        do_action("xmlrpc_call", "blogger.getUsersBlogs");
     668
    647669        set_current_user(0, $user_login);
    648670        $is_admin = current_user_can('level_8');
     
    670692            return $this->error;
    671693        }
     694
     695        do_action("xmlrpc_call", "blogger.getUserInfo");
    672696
    673697        $user_data = get_userdatabylogin($user_login);
     
    699723        }
    700724
     725        do_action("xmlrpc_call", "blogger.getPost");
     726
    701727        $post_data = wp_get_single_post($post_ID, ARRAY_A);
    702728
     
    732758        }
    733759
     760        do_action("xmlrpc_call", "blogger.getRecentPosts");
     761
    734762        $posts_list = wp_get_recent_posts($num_posts);
    735763
     
    780808      }
    781809
     810      do_action("xmlrpc_call", "blogger.getTemplate");
     811
    782812      set_current_user(0, $user_login);
    783813      if ( !current_user_can('edit_themes') ) {
     
    805835        $this->escape($args);
    806836
    807       $blog_ID    = (int) $args[1];
    808       $user_login = $args[2];
    809       $user_pass  = $args[3];
    810       $content    = $args[4];
    811       $template   = $args[5]; /* could be 'main' or 'archiveIndex', but we don't use it */
    812 
    813       if (!$this->login_pass_ok($user_login, $user_pass)) {
    814         return $this->error;
    815       }
    816 
    817       set_current_user(0, $user_login);
    818       if ( !current_user_can('edit_themes') ) {
    819         return new IXR_Error(401, __('Sorry, this user can not edit the template.'));
    820       }
    821 
    822       /* warning: here we make the assumption that the blog's URL is on the same server */
    823       $filename = get_option('home') . '/';
    824       $filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename);
    825 
    826       if ($f = fopen($filename, 'w+')) {
    827         fwrite($f, $content);
    828         fclose($f);
    829       } else {
    830         return new IXR_Error(500, __('Either the file is not writable, or something wrong happened. The file has not been updated.'));
    831       }
    832 
    833       return true;
     837        $blog_ID    = (int) $args[1];
     838        $user_login = $args[2];
     839        $user_pass  = $args[3];
     840        $content    = $args[4];
     841        $template   = $args[5]; /* could be 'main' or 'archiveIndex', but we don't use it */
     842
     843        if (!$this->login_pass_ok($user_login, $user_pass)) {
     844            return $this->error;
     845        }
     846
     847        do_action("xmlrpc_call", "blogger.setTemplate");
     848
     849        set_current_user(0, $user_login);
     850        if ( !current_user_can('edit_themes') ) {
     851            return new IXR_Error(401, __('Sorry, this user can not edit the template.'));
     852        }
     853
     854        /* warning: here we make the assumption that the blog's URL is on the same server */
     855        $filename = get_option('home') . '/';
     856        $filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename);
     857
     858        if ($f = fopen($filename, 'w+')) {
     859            fwrite($f, $content);
     860            fclose($f);
     861        } else {
     862            return new IXR_Error(500, __('Either the file is not writable, or something wrong happened. The file has not been updated.'));
     863        }
     864
     865        return true;
    834866    }
    835867
     
    849881            return $this->error;
    850882        }
    851        
     883
     884        do_action("xmlrpc_call", "blogger.newPost");
     885
    852886        $cap = ($publish) ? 'publish_posts' : 'edit_posts';
    853887        $user = set_current_user(0, $user_login);
     
    896930            return $this->error;
    897931        }
    898        
     932
     933        do_action("xmlrpc_call", "blogger.editPost");
     934
    899935        $actual_post = wp_get_single_post($post_ID,ARRAY_A);
    900936       
     
    943979            return $this->error;
    944980        }
    945        
     981
     982        do_action("xmlrpc_call", "blogger.deletePost");
     983
    946984        $actual_post = wp_get_single_post($post_ID,ARRAY_A);
    947985       
     
    9821020            return $this->error;
    9831021        }
    984        
     1022
     1023        do_action("xmlrpc_call", "metaWeblog.newPost");
     1024
    9851025        $cap = ($publish) ? 'publish_posts' : 'edit_posts';
    9861026        $user = set_current_user(0, $user_login);
     
    11951235       
    11961236        if (!$this->login_pass_ok($user_login, $user_pass)) {
    1197         return $this->error;
    1198         }
     1237            return $this->error;
     1238        }
     1239
     1240        do_action("xmlrpc_call", "metaWeblog.editPost");
    11991241
    12001242        $user = set_current_user(0, $user_login);
     
    14061448            return $this->error;
    14071449        }
    1408        
     1450
     1451        do_action("xmlrpc_call", "metaWeblog.getPost");
     1452
    14091453        $postdata = wp_get_single_post($post_ID, ARRAY_A);
    14101454       
     
    14831527        }
    14841528
     1529        do_action("xmlrpc_call", "metaWeblog.getRecentPosts");
     1530
    14851531        $posts_list = wp_get_recent_posts($num_posts);
    14861532
     
    15701616        }
    15711617
     1618        do_action("xmlrpc_call", "metaWeblog.getCategories");
     1619
    15721620        $categories_struct = array();
    15731621
     
    16091657        if ( !$this->login_pass_ok($user_login, $user_pass) )
    16101658            return $this->error;
     1659
     1660        do_action("xmlrpc_call", "metaWeblog.newMediaObject");
    16111661
    16121662        set_current_user(0, $user_login);
     
    17261776        }
    17271777
     1778        do_action("xmlrpc_call", "mt.getCategoryList");
     1779
    17281780        $categories_struct = array();
    17291781
     
    17541806            return $this->error;
    17551807        }
     1808
     1809        do_action("xmlrpc_call", "mt.getPostCategories");
    17561810
    17571811        $categories = array();
     
    17861840        }
    17871841
     1842        do_action("xmlrpc_call", "mt.setPostCategories");
     1843
    17881844        set_current_user(0, $user_login);
    17891845        if ( !current_user_can('edit_post', $post_ID) )
     
    18021858    /* mt.supportedMethods ...returns an array of methods supported by this server */
    18031859    function mt_supportedMethods($args) {
     1860
     1861        do_action("xmlrpc_call", "mt.supportedMethods");
    18041862
    18051863        $supported_methods = array();
     
    18251883
    18261884        $post_ID = intval($args);
     1885
     1886        do_action("xmlrpc_call", "mt.getTrackbackPings");
    18271887
    18281888        $actual_post = wp_get_single_post($post_ID, ARRAY_A);
     
    18681928        }
    18691929
     1930        do_action("xmlrpc_call", "mt.publishPost");
     1931
    18701932        set_current_user(0, $user_login);
    18711933        if ( !current_user_can('edit_post', $post_ID) )
     
    18951957    function pingback_ping($args) {
    18961958        global $wpdb;
     1959
     1960        do_action("xmlrpc_call", "pingback.ping");
    18971961
    18981962        $this->escape($args);
     
    20582122        global $wpdb;
    20592123
     2124        do_action("xmlrpc_call", "pingback.extensions.getPingsbacks");
     2125
    20602126        $this->escape($args);
    20612127
Note: See TracChangeset for help on using the changeset viewer.