/**
  * Get definitions for editable params
  *
  * @see Plugin::GetDefaultSettings()
  * @param local params like 'for_editing' => true
  */
 function get_param_definitions($params)
 {
     load_funcs('files/model/_image.funcs.php');
     /**
      * @var ItemTypeCache
      */
     $ItemTypeCache =& get_ItemTypeCache();
     $item_type_options = array('' => T_('All')) + $ItemTypeCache->get_option_array();
     $r = array_merge(array('title' => array('label' => T_('Block title'), 'note' => T_('Title to display in your skin.'), 'size' => 40, 'defaultvalue' => T_('Recent photos')), 'item_visibility' => array('label' => T_('Item visibility'), 'note' => T_('What post statuses should be included in the list?'), 'type' => 'radio', 'field_lines' => true, 'options' => array(array('public', T_('show public images (cacheable)')), array('all', T_('show all images the current user is allowed to see (not cacheable)'))), 'defaultvalue' => 'all'), 'item_type' => array('label' => T_('Post type'), 'note' => T_('What kind of items do you want to list?'), 'type' => 'select', 'options' => $item_type_options, 'defaultvalue' => '1'), 'thumb_size' => array('label' => T_('Thumbnail size'), 'note' => T_('Cropping and sizing of thumbnails'), 'type' => 'select', 'options' => get_available_thumb_sizes(), 'defaultvalue' => 'crop-80x80'), 'thumb_layout' => array('label' => T_('Layout'), 'note' => T_('How to lay out the thumbnails'), 'type' => 'select', 'options' => array('grid' => T_('Grid'), 'list' => T_('List'), 'flow' => T_('Flowing Blocks')), 'defaultvalue' => 'flow'), 'disp_image_title' => array('label' => T_('Display image title'), 'note' => T_('Check this to display image title. This falls back to post title if image title is not set.'), 'type' => 'checkbox', 'defaultvalue' => false), 'grid_nb_cols' => array('label' => T_('Columns'), 'note' => T_('Number of columns in grid mode.'), 'size' => 4, 'defaultvalue' => 2), 'limit' => array('label' => T_('Max items'), 'note' => T_('Maximum number of items to display.'), 'size' => 4, 'defaultvalue' => 3), 'order_by' => array('label' => T_('Order by'), 'note' => T_('How to sort the items'), 'type' => 'select', 'options' => get_available_sort_options(), 'defaultvalue' => 'datestart'), 'order_dir' => array('label' => T_('Direction'), 'note' => T_('How to sort the items'), 'type' => 'radio', 'options' => array(array('ASC', T_('Ascending')), array('DESC', T_('Descending'))), 'defaultvalue' => 'DESC'), 'blog_ID' => array('label' => T_('Collection'), 'note' => T_('ID of the collection to use, leave empty for the current collection.'), 'size' => 4, 'type' => 'integer', 'allow_empty' => true)), parent::get_param_definitions($params));
     return $r;
 }
 /**
  * Get definitions for editable params
  *
  * @see Plugin::GetDefaultSettings()
  * @param local params like 'for_editing' => true
  */
 function get_param_definitions($params)
 {
     load_funcs('files/model/_image.funcs.php');
     /**
      * @var ItemTypeCache
      */
     $ItemTypeCache =& get_ItemTypeCache();
     $item_type_options = array('' => T_('All')) + $ItemTypeCache->get_option_array();
     $r = array_merge(array('title' => array('label' => T_('Block title'), 'note' => T_('Title to display in your skin.'), 'size' => 40, 'defaultvalue' => T_('Recent photos')), 'item_type' => array('label' => T_('Item type'), 'note' => T_('What kind of items do you want to list?'), 'type' => 'select', 'options' => $item_type_options, 'defaultvalue' => '1'), 'thumb_size' => array('label' => T_('Thumbnail size'), 'note' => T_('Cropping and sizing of thumbnails'), 'type' => 'select', 'options' => get_available_thumb_sizes(), 'defaultvalue' => 'crop-80x80'), 'thumb_layout' => array('label' => T_('Layout'), 'note' => T_('How to lay out the thumbnails'), 'type' => 'select', 'options' => array('grid' => T_('Grid'), 'list' => T_('List')), 'defaultvalue' => 'grid'), 'disp_image_title' => array('label' => T_('Display image title'), 'note' => T_('Check this to display image title. This falls back to post title if image title is not set.'), 'type' => 'checkbox', 'defaultvalue' => false), 'grid_nb_cols' => array('label' => T_('Columns'), 'note' => T_('Number of columns in grid mode.'), 'size' => 4, 'defaultvalue' => 2), 'limit' => array('label' => T_('Max items'), 'note' => T_('Maximum number of items to display.'), 'size' => 4, 'defaultvalue' => 3), 'order_by' => array('label' => T_('Order by'), 'note' => T_('How to sort the items'), 'type' => 'select', 'options' => get_available_sort_options(), 'defaultvalue' => 'datestart'), 'order_dir' => array('label' => T_('Direction'), 'note' => T_('How to sort the items'), 'type' => 'radio', 'options' => array(array('ASC', T_('Ascending')), array('DESC', T_('Descending'))), 'defaultvalue' => 'DESC'), 'blog_ID' => array('label' => T_('Blogs'), 'note' => T_('IDs of the blogs to use, leave empty for the current blog. Separate multiple blogs by commas.'), 'size' => 4)), parent::get_param_definitions($params));
     return $r;
 }
예제 #3
0
 /**
  * Get definitions for editable params
  *
  * @see Plugin::GetDefaultSettings()
  * @param local params like 'for_editing' => true
  */
 function get_param_definitions($params)
 {
     load_funcs('files/model/_image.funcs.php');
     /**
      * @var ItemTypeCache
      */
     $ItemTypeCache =& get_ItemTypeCache();
     $item_type_options = array('#' => T_('Default'), '' => T_('All')) + $ItemTypeCache->get_option_array();
     $r = array_merge(array('title' => array('label' => T_('Block title'), 'note' => T_('Title to display in your skin.'), 'size' => 60, 'defaultvalue' => T_('Items')), 'title_link' => array('label' => T_('Link to blog'), 'note' => T_('Link the block title to the blog?'), 'type' => 'checkbox', 'defaultvalue' => false), 'item_type' => array('label' => T_('Item type'), 'note' => T_('What kind of items do you want to list?'), 'type' => 'select', 'options' => $item_type_options, 'defaultvalue' => '#'), 'thumb_size' => array('label' => T_('Thumbnail size'), 'note' => T_('Cropping and sizing of thumbnails'), 'type' => 'select', 'options' => get_available_thumb_sizes(), 'defaultvalue' => 'crop-80x80'), 'follow_mainlist' => array('label' => T_('Follow Main List'), 'note' => T_('Do you want to restrict to contents related to what is displayed in the main area?'), 'type' => 'radio', 'options' => array(array('no', T_('No')), array('tags', T_('By tags'))), 'defaultvalue' => 'no'), 'blog_ID' => array('label' => T_('Blog'), 'note' => T_('ID of the blog to use, leave empty for the current blog.'), 'size' => 4), 'item_group_by' => array('label' => T_('Group by'), 'note' => T_('Do you want to group the Items?'), 'type' => 'radio', 'options' => array(array('none', T_('None')), array('chapter', T_('By category/chapter'))), 'defaultvalue' => 'none'), 'order_by' => array('label' => T_('Order by'), 'note' => T_('How to sort the items'), 'type' => 'select', 'options' => get_available_sort_options(), 'defaultvalue' => 'datestart'), 'order_dir' => array('label' => T_('Direction'), 'note' => T_('How to sort the items'), 'type' => 'radio', 'options' => array(array('ASC', T_('Ascending')), array('DESC', T_('Descending'))), 'defaultvalue' => 'DESC'), 'limit' => array('label' => T_('Max items'), 'note' => T_('Maximum number of items to display.'), 'size' => 4, 'defaultvalue' => 20), 'disp_title' => array('label' => T_('Titles'), 'note' => T_('Display title.'), 'type' => 'checkbox', 'defaultvalue' => true), 'item_title_link_type' => array('label' => T_('Link titles'), 'note' => T_('Where should titles be linked to?'), 'type' => 'select', 'options' => array('auto' => T_('Automatic'), 'permalink' => T_('Item permalink'), 'linkto_url' => T_('Item URL'), 'none' => T_('Nowhere')), 'defaultvalue' => 'auto'), 'attached_pics' => array('label' => T_('Attached pictures'), 'note' => '', 'type' => 'radio', 'options' => array(array('none', T_('None')), array('first', T_('Display first')), array('all', T_('Display all'))), 'defaultvalue' => 'none'), 'item_pic_link_type' => array('label' => T_('Link pictures'), 'note' => T_('Where should pictures be linked to?'), 'type' => 'select', 'options' => array('auto' => T_('Automatic'), 'permalink' => T_('Item permalink'), 'linkto_url' => T_('Item URL'), 'none' => T_('Nowhere')), 'defaultvalue' => 'auto'), 'disp_excerpt' => array('label' => T_('Excerpt'), 'note' => T_('Display excerpt for each item.'), 'type' => 'checkbox', 'defaultvalue' => false), 'disp_teaser' => array('label' => T_('Content teaser'), 'type' => 'checkbox', 'defaultvalue' => false, 'note' => T_('Display content teaser for each item.')), 'disp_teaser_maxwords' => array('label' => T_('Max Words'), 'type' => 'integer', 'defaultvalue' => 20, 'note' => T_('Max number of words for the teasers.'))), parent::get_param_definitions($params));
     // pre_dump( $r['item_type']['options'] );
     return $r;
 }
 /**
  * Get definitions for editable params
  *
  * @see Plugin::GetDefaultSettings()
  * @param local params like 'for_editing' => true
  */
 function get_param_definitions($params)
 {
     load_funcs('files/model/_image.funcs.php');
     /**
      * @var ItemTypeCache
      */
     $ItemTypeCache =& get_ItemTypeCache();
     $item_type_options = array('#' => T_('Default'), '' => T_('All')) + $ItemTypeCache->get_option_array();
     $r = array_merge(array('title' => array('label' => T_('Block title'), 'note' => T_('Title to display in your skin.'), 'size' => 60, 'defaultvalue' => T_('Items')), 'title_link' => array('label' => T_('Link to blog'), 'note' => T_('Link the block title to the blog?'), 'type' => 'checkbox', 'defaultvalue' => false), 'item_visibility' => array('label' => T_('Item visibility'), 'note' => T_('What post statuses should be included in the list?'), 'type' => 'radio', 'field_lines' => true, 'options' => array(array('public', T_('show public posts')), array('all', T_('show all posts the current user is allowed to see'))), 'defaultvalue' => 'all'), 'item_type' => array('label' => T_('Post type'), 'note' => T_('What kind of items do you want to list?'), 'type' => 'select', 'options' => $item_type_options, 'defaultvalue' => '#'), 'follow_mainlist' => array('label' => T_('Follow Main List'), 'note' => T_('Do you want to restrict to contents related to what is displayed in the main area?'), 'type' => 'radio', 'options' => array(array('no', T_('No')), array('tags', T_('By tags'))), 'defaultvalue' => 'no'), 'blog_ID' => array('label' => T_('Collections'), 'note' => T_('List collection IDs separated by \',\', \'*\' for all collections, \'-\' for current collection without aggregation or leave empty for current collection including aggregation.'), 'size' => 4, 'type' => 'text', 'valid_pattern' => array('pattern' => '/^(\\d+(,\\d+)*|-|\\*)?$/', 'error' => T_('Invalid list of Collection IDs.')), 'defaultvalue' => ''), 'cat_IDs' => array('label' => T_('Categories'), 'note' => T_('List category IDs separated by ,'), 'size' => 15, 'type' => 'text', 'valid_pattern' => array('pattern' => '/^(\\d+(,\\d+)*|-|\\*)?$/', 'error' => T_('Invalid list of Category IDs.'))), 'item_group_by' => array('label' => T_('Group by'), 'note' => T_('Do you want to group the Items?'), 'type' => 'radio', 'options' => array(array('none', T_('None')), array('chapter', T_('By category/chapter'))), 'defaultvalue' => 'none'), 'order_by' => array('label' => T_('Order by'), 'note' => T_('How to sort the items'), 'type' => 'select', 'options' => get_available_sort_options(), 'defaultvalue' => 'datestart'), 'order_dir' => array('label' => T_('Direction'), 'note' => T_('How to sort the items'), 'type' => 'radio', 'options' => array(array('ASC', T_('Ascending')), array('DESC', T_('Descending'))), 'defaultvalue' => 'DESC'), 'limit' => array('label' => T_('Max items'), 'note' => T_('Maximum number of items to display.'), 'size' => 4, 'defaultvalue' => 20), 'disp_title' => array('label' => T_('Titles'), 'note' => T_('Display title.'), 'type' => 'checkbox', 'defaultvalue' => true), 'item_title_link_type' => array('label' => T_('Link titles to'), 'note' => T_('Where should titles be linked to?'), 'type' => 'select', 'options' => array('auto' => T_('Automatic'), 'permalink' => T_('Item permalink'), 'linkto_url' => T_('Item URL'), 'none' => T_('Nowhere')), 'defaultvalue' => 'permalink'), 'attached_pics' => array('label' => T_('Attached pictures'), 'note' => '', 'type' => 'radio', 'options' => array(array('none', T_('None')), array('first', T_('Display first picture')), array('all', T_('Display all pictures'))), 'defaultvalue' => 'none'), 'disp_first_image' => array('label' => T_('First picture'), 'note' => '', 'type' => 'radio', 'options' => array(array('special', T_('Special placement before title')), array('normal', T_('No special treatment (same as other pictures)'))), 'defaultvalue' => 'normal'), 'max_pics' => array('label' => T_('Max pictures'), 'note' => T_('Maximum number of pictures to display after the title.'), 'size' => 4, 'type' => 'integer', 'defaultvalue' => '', 'allow_empty' => true), 'thumb_size' => array('label' => T_('Image size'), 'note' => T_('Cropping and sizing of thumbnails'), 'type' => 'select', 'options' => get_available_thumb_sizes(), 'defaultvalue' => 'crop-80x80'), 'item_pic_link_type' => array('label' => T_('Link pictures'), 'note' => T_('Where should pictures be linked to?'), 'type' => 'select', 'options' => array('auto' => T_('Automatic'), 'permalink' => T_('Item permalink'), 'linkto_url' => T_('Item URL'), 'none' => T_('Nowhere')), 'defaultvalue' => 'auto'), 'disp_excerpt' => array('label' => T_('Excerpt'), 'note' => T_('Display excerpt for each item.'), 'type' => 'checkbox', 'defaultvalue' => false), 'disp_teaser' => array('label' => T_('Content teaser'), 'type' => 'checkbox', 'defaultvalue' => false, 'note' => T_('Display content teaser for each item.')), 'disp_teaser_maxwords' => array('label' => T_('Max Words'), 'type' => 'integer', 'defaultvalue' => 20, 'note' => T_('Max number of words for the teasers.'))), parent::get_param_definitions($params));
     if (isset($r['allow_blockcache'])) {
         // Disable "allow blockcache" because this widget uses the selected items
         $r['allow_blockcache']['defaultvalue'] = false;
         $r['allow_blockcache']['disabled'] = 'disabled';
         $r['allow_blockcache']['note'] = T_('This widget cannot be cached in the block cache.');
     }
     return $r;
 }
예제 #5
0
 /**
  * Get definitions for widget specific editable params
  *
  * @see Plugin::GetDefaultSettings()
  * @param local params like 'for_editing' => true
  */
 function get_widget_param_definitions($params)
 {
     global $posttypes_specialtypes;
     // Initialize an array for the field "Post type":
     $ItemTypeCache =& get_ItemTypeCache();
     $item_types = $ItemTypeCache->get_option_array();
     $item_type_options = array('#' => T_('Default'), '' => T_('All'));
     foreach ($item_types as $item_type_ID => $item_type_name) {
         if (in_array($item_type_ID, $posttypes_specialtypes)) {
             // Exclude special item types:
             continue;
         }
         $item_type_options[$item_type_ID] = $item_type_name;
     }
     $r = array('title' => array('label' => T_('Block title'), 'note' => T_('Title to display in your skin.'), 'size' => 60, 'defaultvalue' => ''), 'title_link' => array('label' => T_('Link to blog'), 'note' => T_('Link the block title to the blog?'), 'type' => 'checkbox', 'defaultvalue' => false), 'item_visibility' => array('label' => T_('Item visibility'), 'note' => T_('What post statuses should be included in the list?'), 'type' => 'radio', 'field_lines' => true, 'options' => array(array('public', T_('show public posts')), array('all', T_('show all posts the current user is allowed to see'))), 'defaultvalue' => 'all'), 'item_type' => array('label' => T_('Post type'), 'note' => T_('What kind of items do you want to list?'), 'type' => 'select', 'options' => $item_type_options, 'defaultvalue' => '#'), 'blog_ID' => array('label' => T_('Collection'), 'note' => T_('ID of the collection to use, leave empty for the current collection.'), 'size' => 4, 'type' => 'integer', 'allow_empty' => true), 'cat_IDs' => array('label' => T_('Categories'), 'note' => T_('List category IDs separated by ,'), 'size' => 15, 'type' => 'text', 'valid_pattern' => array('pattern' => '/^(\\d+(,\\d+)*|-|\\*)?$/', 'error' => T_('Invalid list of Category IDs.'))), 'displaycaption' => array('label' => T_('Display caption'), 'note' => T_('Display caption on top of calendar'), 'type' => 'checkbox', 'defaultvalue' => true), 'linktomontharchive' => array('label' => T_('Link caption to archives'), 'note' => T_('The month in the caption can be clicked to see all posts for this month'), 'type' => 'checkbox', 'defaultvalue' => true), 'headerdisplay' => array('label' => 'Column headers', 'note' => T_('How do you want to display the days of the week in the column headers?'), 'type' => 'select', 'options' => array('e' => 'F', 'D' => 'Fri', 'l' => 'Friday', '' => T_('No header')), 'defaultvalue' => 'D'), 'navigation' => array('label' => 'Navigation arrows', 'note' => T_('Where do you want to display the navigation arrows?'), 'type' => 'select', 'options' => array('caption' => T_('Top'), 'tfoot' => T_('Bottom'), '' => T_('No navigation')), 'defaultvalue' => 'tfoot'), 'browseyears' => array('label' => T_('Navigate years'), 'note' => T_('Display double arrows for yearly navigation?'), 'type' => 'checkbox', 'defaultvalue' => true));
     return $r;
 }
예제 #6
0
 /**
  * Template function: display type of item
  *
  * @param string
  * @param string
  * @param string Output format, see {@link format_to_output()}
  */
 function type($before = '', $after = '', $format = 'htmlbody')
 {
     $ItemTypeCache =& get_ItemTypeCache();
     $Element =& $ItemTypeCache->get_by_ID($this->ptyp_ID, true, false);
     if (!$Element) {
         // No status:
         return;
     }
     $type_name = $Element->get('name');
     if ($format == 'raw') {
         $this->disp($type_name, 'raw');
     } else {
         echo $before . format_to_output($type_name, $format) . $after;
     }
 }
예제 #7
0
/**
 * wp.getPostFormats
 *
 * @see http://codex.wordpress.org/XML-RPC_wp#wp.getPostFormats
 *
 * Note: by default (no filter) we return supported formats only.
 *
 * @param xmlrpcmsg XML-RPC Message
 *					0 blogid (int): Unique identifier of the blog.
 *					1 username (string): User login.
 *					2 password (string): Password for said username.
 *					3 filter (struct):
 * 						- show-supported
 */
function wp_getpostformats($m)
{
    // CHECK LOGIN:
    /**
     * @var User
     */
    if (!($current_User =& xmlrpcs_login($m, 1, 2))) {
        // Login failed, return (last) error:
        return xmlrpcs_resperror();
    }
    // GET BLOG:
    /**
     * @var Blog
     */
    if (!($Blog =& xmlrpcs_get_Blog($m, 0))) {
        // Login failed, return (last) error:
        return xmlrpcs_resperror();
    }
    if (isset($m->params[3])) {
        $xcontent = $m->getParam(3);
        $contentstruct = xmlrpc_decode_recurse($xcontent);
    }
    global $posttypes_reserved_IDs, $posttypes_perms;
    // Compile an array of post type IDs to exclude:
    $exclude_posttype_IDs = $posttypes_reserved_IDs;
    foreach ($posttypes_perms as $l_permname => $l_posttype_IDs) {
        if (!$current_User->check_perm('blog_' . $l_permname, 'edit', false, $Blog->ID)) {
            // No permission to use this post type(s):
            $exclude_posttype_IDs = array_merge($exclude_posttype_IDs, $l_posttype_IDs);
        }
    }
    $saved_global = $posttypes_reserved_IDs;
    // save
    $posttypes_reserved_IDs = $exclude_posttype_IDs;
    $ItemTypeCache =& get_ItemTypeCache();
    $supported = $ItemTypeCache->get_option_array();
    ksort($supported);
    $posttypes_reserved_IDs = $saved_global;
    // restore
    $all = $ItemTypeCache->get_option_array();
    ksort($all);
    logIO("All item types:\n" . var_export($all, true));
    logIO("Supported item types:\n" . var_export($supported, true));
    $all_types = $supported_types = array();
    foreach ($all as $k => $v) {
        $all_types[strval($k)] = new xmlrpcval($v);
    }
    foreach ($supported as $k => $v) {
        $supported_types[strval($k)] = new xmlrpcval($v);
    }
    if (!empty($contentstruct) && is_array($contentstruct)) {
        // Make sure there's a filter 'show-supported' that evaluates to TRUE
        if (isset($contentstruct['show-supported']) && $contentstruct['show-supported']) {
            // Display both 'all' and 'supported' post types
            $types = array('all' => new xmlrpcval($all_types, 'struct'), 'supported' => php_xmlrpc_encode(array_keys($supported_types)));
            logIO('OK.');
            return new xmlrpcresp(new xmlrpcval($types, 'struct'));
        }
    }
    logIO('OK.');
    return new xmlrpcresp(new xmlrpcval($supported_types, 'struct'));
}
예제 #8
0
 /**
  * Get the ItemType object for the Item.
  *
  * @return object ItemType
  */
 function &get_ItemType()
 {
     if (empty($this->ItemType)) {
         $ItemTypeCache =& get_ItemTypeCache();
         $this->ItemType =& $ItemTypeCache->get_by_ID($this->ityp_ID, false, false);
     }
     return $this->ItemType;
 }
예제 #9
0
global $dispatcher;
// get reserved ids
global $special_range;
$special_range = ItemType::get_special_range();
// Check minimum permission:
$current_User->check_perm('options', 'view', true);
// We should activate toolbar menu items for this controller
$activate_collection_toolbar = true;
$tab = param('tab', 'string', 'settings', true);
$tab3 = param('tab3', 'string', 'types', true);
$AdminUI->set_path('collections', $tab, $tab3);
// Get action parameter from request:
param_action();
if (param('ityp_ID', 'integer', '', true)) {
    // Load itemtype from cache:
    $ItemtypeCache =& get_ItemTypeCache();
    if (($edited_Itemtype =& $ItemtypeCache->get_by_ID($ityp_ID, false)) === false) {
        // We could not find the post type to edit:
        unset($edited_Itemtype);
        forget_param('ityp_ID');
        $Messages->add(sprintf(T_('Requested «%s» object does not exist any longer.'), 'Itemtype'), 'error');
        $action = 'nil';
    }
}
switch ($action) {
    case 'new':
        // Check permission:
        $current_User->check_perm('options', 'edit', true);
        if (!isset($edited_Itemtype)) {
            // We don't have a model to use, start with blank object:
            $edited_Itemtype = new ItemType();
예제 #10
0
/**
 * Assert that the supplied post type can be used by the current user in
 * the post's extra categories' context.
 *
 * @param integer Item type ID
 * @param array The extra cats of the post.
 */
function check_perm_posttype($item_typ_ID, $post_extracats)
{
    global $Blog, $current_User;
    $ItemTypeCache =& get_ItemTypeCache();
    $ItemType =& $ItemTypeCache->get_by_ID($item_typ_ID);
    if (ItemType::is_reserved($ItemType->ID)) {
        // Don't allow to use a reserved post type:
        debug_die('This post type is reserved and cannot be used. Please choose another one.');
    }
    if (!$Blog->is_item_type_enabled($ItemType->ID)) {
        // Don't allow to use a not enabled post type:
        debug_die('This post type is not enabled. Please choose another one.');
    }
    // Check permission:
    $current_User->check_perm('cats_item_type_' . $ItemType->perm_level, 'edit', true, $post_extracats);
}
예제 #11
0
/**
 * Edit an Item and return an XML-RPC response
 *
 * @param Item
 * @param array Item properties
 * @param object Blog where we are going to create a new Item
 * @return xmlrpcmsg
 */
function xmlrpcs_edit_item(&$edited_Item, $params)
{
    global $current_User, $Messages, $DB;
    $params = array_merge(array('title' => NULL, 'content' => NULL, 'date' => '', 'main_cat_ID' => NULL, 'extra_cat_IDs' => NULL, 'cat_IDs' => array(), 'status' => '', 'tags' => NULL, 'excerpt' => NULL, 'item_typ_ID' => NULL, 'comment_status' => '', 'urltitle' => NULL, 'featured' => NULL, 'custom_fields' => NULL, 'order' => NULL, 'parent_ID' => NULL, 'author_ID' => NULL, 'locale' => ''), $params);
    $Blog =& $edited_Item->get_Blog();
    logIO('Requested Blog: ' . $Blog->ID . ' - ' . $Blog->name);
    if (empty($Blog)) {
        // Blog does not exist:
        return xmlrpcs_resperror();
    }
    if (is_array($params['cat_IDs']) && count($params['cat_IDs']) > 0) {
        // Let's use first cat for MAIN and others for EXTRA
        $params['main_cat_ID'] = array_shift($params['cat_IDs']);
        $params['extra_cat_IDs'] = $params['cat_IDs'];
    }
    if (!is_null($params['main_cat_ID']) && is_array($params['extra_cat_IDs'])) {
        // Check new categories
        logIO('Main cat ID: ' . $params['main_cat_ID']);
        logIO('Extra cat IDs: ' . implode(', ', $params['extra_cat_IDs']));
        // Check if category exists and can be used
        if (!xmlrpcs_check_cats($params['main_cat_ID'], $Blog, $params['extra_cat_IDs'])) {
            // Permission denied
            return xmlrpcs_resperror(3);
            // User error 3
        }
        /*
         * CHECK PERMISSION: (we need perm on all categories, especially if they are in different blogs)
         * NOTE: extra_cat_IDs array now includes main_cat_ID too, so we are actually checking ALL categories below
         */
        if (!$current_User->check_perm('cats_post!' . $params['status'], 'edit', false, $params['extra_cat_IDs'])) {
        }
    }
    if (!is_null($params['item_typ_ID'])) {
        if (!preg_match('~^[0-9]+$~', $params['item_typ_ID'])) {
            // Only accept numeric values, switch to default value
            $params['item_typ_ID'] = NULL;
        }
        $ItemTypeCache =& get_ItemTypeCache();
        $ItemType =& $ItemTypeCache->get_by_ID($params['item_typ_ID'], false, false);
        // Check permission for this post type
        if ($ItemType && !$current_User->check_perm('cats_item_type_' . $ItemType->perm_level, 'edit', false, $params['extra_cat_IDs'])) {
            // Permission denied
            return xmlrpcs_resperror(3);
            // User error 3
        }
    }
    logIO('Post type: ' . $params['item_typ_ID']);
    logIO('Permission granted.');
    // CHECK HTML SANITY:
    if (($params['title'] = check_html_sanity($params['title'], 'xmlrpc_posting')) === false) {
        return xmlrpcs_resperror(21, $Messages->get_string('Invalid post title, please correct these errors:', ''));
    }
    if (($params['content'] = check_html_sanity($params['content'], 'xmlrpc_posting')) === false) {
        return xmlrpcs_resperror(22, $Messages->get_string('Invalid post contents, please correct these errors:' . "\n", '', "  //  \n", 'xmlrpc'));
    }
    if (!is_null($params['title'])) {
        $edited_Item->set('title', $params['title']);
    }
    if (!is_null($params['content'])) {
        $edited_Item->set('content', $params['content']);
    }
    if (!is_null($params['urltitle'])) {
        $edited_Item->set('urltitle', $params['urltitle']);
    }
    if (!is_null($params['main_cat_ID']) && !is_null($params['extra_cat_IDs'])) {
        $edited_Item->set('main_cat_ID', $params['main_cat_ID']);
        $edited_Item->set('extra_cat_IDs', $params['extra_cat_IDs']);
    }
    if (!is_null($params['item_typ_ID'])) {
        $edited_Item->set('ityp_ID', $params['item_typ_ID']);
    }
    if (!is_null($params['featured'])) {
        $edited_Item->set('featured', $params['featured']);
    }
    if (!is_null($params['order'])) {
        if (!(empty($params['order']) && !$edited_Item->order)) {
            // Do not allow 0 order if there was no order set before
            $edited_Item->set('order', $params['order']);
        }
    }
    if (!is_null($params['parent_ID'])) {
        $edited_Item->set('parent_ID', $params['parent_ID']);
    }
    if (!is_null($params['author_ID']) && $params['author_ID'] != $this->creator_user_ID) {
        // We have already checked perms to edit items created by other users
        $edited_Item->set('lastedit_user_ID', $params['parent_ID']);
    }
    if (!is_null($params['tags'])) {
        $edited_Item->set_tags_from_string($params['tags']);
    }
    if (!is_null($params['excerpt'])) {
        $edited_Item->set('excerpt', $params['excerpt']);
    }
    if (!empty($params['comment_status']) && $edited_Item->allow_comment_statuses()) {
        // Comment status
        $edited_Item->set('comment_status', $params['comment_status']);
    }
    if (!empty($params['status'])) {
        $edited_Item->set('status', $params['status']);
    }
    if (!empty($params['date'])) {
        $edited_Item->set('issue_date', $params['date']);
    }
    if (!empty($params['locale'])) {
        $edited_Item->set('locale', $params['locale']);
    }
    logIO(var_export($edited_Item->dbchanges, true));
    // UPDATE POST IN DB:
    $edited_Item->dbupdate();
    if ($DB->error) {
        return xmlrpcs_resperror(99, 'Error while updating item: ' . $DB->last_error);
    }
    if (!is_null($params['custom_fields'])) {
        // TODO sam2kb> Add custom fields
        if (is_array($params['custom_fields']) && count($params['custom_fields']) > 0) {
            logIO('Modifying custom fields...');
            foreach ($params['custom_fields'] as $field) {
                // id, key, value
                logIO('Custom field: ' . var_export($field, true));
            }
        } else {
            logIO('Deleting custom fields...');
        }
    }
    // Execute or schedule notifications & pings:
    logIO('Handling notifications...');
    $edited_Item->handle_post_processing(false);
    logIO('OK.');
    return new xmlrpcresp(new xmlrpcval(1, 'boolean'));
}
예제 #12
0
 /**
  * We want to preview a single post, we are going to fake a lot of things...
  */
 function preview_from_request()
 {
     global $current_User;
     if (empty($current_User)) {
         // dh> only logged in user's can preview. Alternatively we need those checks where $current_User gets used below.
         return;
     }
     global $DB, $localtimenow, $Messages, $BlogCache;
     global $Plugins;
     $item_typ_ID = param('item_typ_ID', 'integer', NULL);
     $ItemTypeCache =& get_ItemTypeCache();
     $ItemType =& $ItemTypeCache->get_by_ID($item_typ_ID, false, false);
     if ($ItemType && $ItemType->get('allow_html')) {
         // HTML is allowed for this post
         $text_format = 'html';
     } else {
         // HTML is disallowed for this post
         $text_format = 'htmlspecialchars';
     }
     $preview_userid = param('preview_userid', 'integer', true);
     $post_status = param('post_status', 'string', true);
     $post_locale = param('post_locale', 'string', $current_User->locale);
     $content = param('content', $text_format, true);
     $post_title = param('post_title', $text_format, true);
     $post_titletag = param('titletag', 'string', true);
     $post_excerpt = param('post_excerpt', 'string', true);
     $post_url = param('post_url', 'string', '');
     check_categories_nosave($post_category, $post_extracats);
     $renderers = param('renderers', 'array:string', array('default'));
     if (!is_array($renderers)) {
         // dh> workaround for param() bug. See rev 1.93 of /inc/_misc/_misc.funcs.php
         $renderers = array('default');
     }
     if ($post_category == 0) {
         $post_category = $this->Blog->get_default_cat_ID();
     }
     $comment_Blog =& $BlogCache->get_by_ID(get_catblog($post_category));
     if ($comment_Blog->get_setting('allow_comments') != 'never' && ($ItemType && $ItemType->get('use_comments') && ($ItemType->get('allow_disabling_comments') || $ItemType->get('allow_closing_comments')))) {
         // param is required
         $post_comment_status = param('post_comment_status', 'string', true);
     } else {
         $post_comment_status = $comment_Blog->get_setting('allow_comments');
     }
     // Get issue date, using the user's locale (because it's entered like this in the form):
     locale_temp_switch($current_User->locale);
     param_date('item_issue_date', T_('Please enter a valid issue date.'), false);
     // TODO: dh> get_param() is always true here, also on invalid dates:
     if (strlen(get_param('item_issue_date'))) {
         // only set it, if a date was given:
         param_time('item_issue_time');
         $item_issue_date = form_date(get_param('item_issue_date'), get_param('item_issue_time'));
         // TODO: cleanup...
     } else {
         $item_issue_date = date('Y-m-d H:i:s', $localtimenow);
     }
     locale_restore_previous();
     $item_st_ID = param('item_st_ID', 'integer', NULL);
     $item_assigned_user_ID = param('item_assigned_user_ID', 'integer', NULL);
     $item_deadline = param('item_deadline', 'string', NULL);
     $item_priority = param('item_priority', 'integer', NULL);
     // QUESTION: can this be also empty/NULL?
     // Do some optional filtering on the content
     // Typically stuff that will help the content to validate
     // Useful for code display.
     // Will probably be used for validation also.
     $Plugins_admin =& get_Plugins_admin();
     $params = array('object_type' => 'Item', 'object_Blog' => &$comment_Blog);
     $Plugins_admin->filter_contents($post_title, $content, $renderers, $params);
     $post_title = format_to_post($post_title);
     $content = format_to_post($content);
     $post_ID = param('post_ID', 'integer', 0);
     $post_parent_ID = intval(param('post_parent_ID', 'integer', 0));
     $this->sql = "SELECT\n\t\t\t{$post_ID} AS post_ID,\n\t\t\t{$post_parent_ID} AS post_parent_ID,\n\t\t\t{$preview_userid} AS post_creator_user_ID,\n\t\t\t{$preview_userid} AS post_lastedit_user_ID,\n\t\t\t'{$item_issue_date}' AS post_datestart,\n\t\t\t'{$item_issue_date}' AS post_datecreated,\n\t\t\t'{$item_issue_date}' AS post_datemodified,\n\t\t\t'{$item_issue_date}' AS post_last_touched_ts,\n\t\t\t0 AS post_dateset,\n\t\t\t'" . $DB->escape($post_status) . "' AS post_status,\n\t\t\t'" . $DB->escape($post_locale) . "' AS post_locale,\n\t\t\t'" . $DB->escape($content) . "' AS post_content,\n\t\t\t'" . $DB->escape($post_title) . "' AS post_title,\n\t\t\t'" . $DB->escape($post_titletag) . "' AS post_titletag,\n\t\t\t'" . $DB->escape($post_excerpt) . "' AS post_excerpt,\n\t\t\tNULL AS post_excerpt_autogenerated,\n\t\t\tNULL AS post_urltitle,\n\t\t\tNULL AS post_canonical_slug_ID,\n\t\t\tNULL AS post_tiny_slug_ID,\n\t\t\t'" . $DB->escape($post_url) . "' AS post_url,\n\t\t\t{$post_category} AS post_main_cat_ID,\n\t\t\t'' AS post_flags,\n\t\t\t'noreq' AS post_notifications_status,\n\t\t\tNULL AS post_notifications_ctsk_ID,\n\t\t\t" . bpost_count_words($content) . " AS post_wordcount,\n\t\t\t" . $DB->quote($post_comment_status) . " AS post_comment_status,\n\t\t\t'" . $DB->escape(implode('.', $renderers)) . "' AS post_renderers,\n\t\t\t" . $DB->quote($item_assigned_user_ID) . " AS post_assigned_user_ID,\n\t\t\t" . $DB->quote($item_typ_ID) . " AS post_ityp_ID,\n\t\t\t" . $DB->quote($item_st_ID) . " AS post_pst_ID,\n\t\t\t" . $DB->quote($item_deadline) . " AS post_datedeadline,\n\t\t\t" . $DB->quote($item_priority) . " AS post_priority,";
     $this->sql .= $DB->quote(param('item_order', 'double', NULL)) . ' AS post_order' . ",\n" . $DB->quote(param('item_featured', 'integer', NULL)) . ' AS post_featured' . "\n";
     $this->total_rows = 1;
     $this->total_pages = 1;
     $this->page = 1;
     // ATTENTION: we skip the parent on purpose here!! fp> refactor
     DataObjectList2::query(false, false, false, 'PREVIEW QUERY');
     // Clear cache to view new updated data of the post:
     $this->Cache->clear();
     $Item =& $this->Cache->instantiate($this->rows[0]);
     // set Item settings
     $Item->set_setting('hide_teaser', param('item_hideteaser', 'integer', 0));
     $Item->set_setting('metadesc', param('metadesc', 'string', true));
     $Item->set_setting('metakeywords', param('metakeywords', 'string', true));
     // set custom Item settings
     $custom_fields = $Item->get_type_custom_fields();
     foreach ($custom_fields as $custom_field) {
         // For each custom double field:
         $param_type = $custom_field['type'] == 'varchar' ? 'string' : $custom_field['type'];
         $Item->set_setting('custom_' . $custom_field['type'] . '_' . $custom_field['ID'], param('item_' . $custom_field['type'] . '_' . $custom_field['ID'], $param_type, NULL));
     }
     // Trigger plugin event, allowing to manipulate or validate the item before it gets previewed
     $Plugins->trigger_event('AppendItemPreviewTransact', array('Item' => &$Item));
     if ($Messages->has_errors()) {
         $errcontent = $Messages->display(T_('Invalid post, please correct these errors:'), '', false);
         $Item->content = $errcontent . "\n<hr />\n" . $content;
     }
     // little funky fix for IEwin, rawk on that code
     global $Hit;
     if ($Hit->is_winIE() && !isset($IEWin_bookmarklet_fix)) {
         // QUESTION: Is this still needed? What about $IEWin_bookmarklet_fix? (blueyed)
         $Item->content = preg_replace('/\\%u([0-9A-F]{4,4})/e', "'&#'.base_convert('\\1',16,10). ';'", $Item->content);
     }
 }
예제 #13
0
 /**
  * Get a member param by its name
  *
  * @param mixed Name of parameter
  * @return mixed Value of parameter
  */
 function get($parname)
 {
     switch ($parname) {
         case 't_author':
             // Text: author
             $this->get_creator_User();
             return $this->creator_User->get('preferredname');
         case 't_assigned_to':
             // Text: assignee
             if (!$this->get_assigned_User()) {
                 return '';
             }
             return $this->assigned_User->get('preferredname');
         case 't_status':
             // Text status:
             $post_statuses = get_visibility_statuses();
             return $post_statuses[$this->status];
         case 't_extra_status':
             $ItemStatusCache =& get_ItemStatusCache();
             if (!($Element =& $ItemStatusCache->get_by_ID($this->pst_ID, true, false))) {
                 // No status:
                 return '';
             }
             return $Element->get_name();
         case 't_type':
             // Item type (name):
             if (empty($this->ptyp_ID)) {
                 return '';
             }
             $ItemTypeCache =& get_ItemTypeCache();
             $type_Element =& $ItemTypeCache->get_by_ID($this->ptyp_ID);
             return $type_Element->get_name();
         case 't_priority':
             return $this->priorities[$this->priority];
         case 'pingsdone':
             // Deprecated by fp 2006-08-21
             return $this->post_notifications_status == 'finished';
         case 'excerpt':
             return $this->get_excerpt2();
     }
     return parent::get($parname);
 }