function processPreview($request)
 {
     // Ticket Check
     if (!$GLOBALS['xoopsGTicket']->check(true, 'pico')) {
         redirect_header(XOOPS_URL . '/', 3, $GLOBALS['xoopsGTicket']->getErrors());
     }
     // initialize
     $cat_data = $this->currentCategoryObj->getData();
     $myts =& PicoTextSanitizer::getInstance();
     // assigning other than preview/request
     // parent::execute( $request ) ;
     // permission check (can_edit) done
     // request
     $request = pico_get_requests4content($this->mydirname, $errors = array(), $cat_data['post_auto_approved'], $cat_data['isadminormod'], $this->assign['content']['id']);
     $request['body_raw'] = $request['body'];
     $request['subject_raw'] = $request['subject'];
     $request4assign = array_map('htmlspecialchars_ent', $request);
     $this->assign['request'] = $request4assign;
     // override content data for edit
     $this->assign['content'] = $request4assign + $this->assign['content'];
     $this->assign['content']['filter_infos'] = pico_main_get_filter_infos($request['filters'], $cat_data['isadminormod']);
     $this->assign['content']['body_raw'] = $request['body'];
     $this->assign['content']['extra_fields'] = $request['extra_fields'];
     $this->assign['content']['ef'] = pico_common_unserialize($request['extra_fields']);
     // temporary $contentObj
     $tmpContentObj = new PicoContent($this->mydirname, 0, $this->currentCategoryObj, true);
     // preview
     $this->assign['preview'] = array('errors' => $errors, 'htmlheader' => $request['htmlheader'], 'subject' => $myts->makeTboxData4Show($request['subject'], 1, 1), 'body' => $tmpContentObj->filterBody($this->assign['content']));
 }
function smarty_function_pico_category_search($params, &$smarty)
{
    $dir = @$params['dir'] . @$params['dirname'];
    $cat_title = @$params['title'] . @$params['cat_title'];
    $var_name = @$params['item'] . @$params['assign'];
    if (empty($var_name)) {
        echo 'error ' . __FUNCTION__ . ' [specify item]';
        return;
    }
    if (empty($dir)) {
        $dir = $smarty->get_template_vars('mydirname');
    }
    if (empty($dir)) {
        echo 'error ' . __FUNCTION__ . ' [specify dirname]';
        return;
    }
    $mydirnames = explode(',', $dir);
    $db =& Database::getInstance();
    $myts =& MyTextSanitizer::getInstance();
    $module_handler =& xoops_gethandler('module');
    $config_handler =& xoops_gethandler('config');
    $categories4assign = array();
    foreach ($mydirnames as $mydirname) {
        $module =& $module_handler->getByDirname($mydirname);
        $configs = $config_handler->getConfigList($module->getVar('mid'));
        $sql = "SELECT * FROM " . $db->prefix($mydirname . "_categories") . " c WHERE c.cat_title='" . mysql_real_escape_string($cat_title) . "'";
        $result = $db->query($sql);
        while ($cat_row = $db->fetchArray($result)) {
            $category4assign = array('mod_mid' => $module->getVar('mid'), 'mod_dirname' => $mydirname, 'mod_name' => $module->getVar('name'), 'id' => intval($cat_row['cat_id']), 'link' => pico_common_make_category_link4html($configs, $cat_row), 'title' => $myts->makeTboxData4Show($cat_row['cat_title']), 'desc' => $myts->displayTarea($cat_row['cat_desc'], 1), 'paths_raw' => pico_common_unserialize($cat_row['cat_path_in_tree']), 'paths_value' => array_values(pico_common_unserialize($cat_row['cat_path_in_tree'])), 'redundants' => pico_common_unserialize($cat_row['cat_redundants'])) + $cat_row;
            $categories4assign[] = $category4assign;
        }
    }
    $smarty->assign($var_name, $categories4assign);
}
예제 #3
0
function smarty_function_pico_subcattree( $params , &$smarty )
{
	$mydirname = @$params['dir'] . @$params['dirname'] ;
	$cat_id = @$params['id'] + @$params['cat_id'] ;
	$var_name = @$params['item'] . @$params['assign'] ;

	if( empty( $var_name ) ) {
		echo 'error '.__FUNCTION__.' [specify item]';
		return ;
	}

	if( empty( $mydirname ) ) $mydirname = $smarty->get_template_vars( 'mydirname' ) ;
	if( empty( $mydirname ) ) {
		echo 'error '.__FUNCTION__.' [specify dirname]';
		return ;
	}

	$db =& Database::getInstance() ;
	$sql = "SELECT c.cat_redundants FROM ".$db->prefix($mydirname."_categories")." c WHERE c.cat_id=$cat_id" ;
	list( $redundants_serialized ) = $db->fetchRow( $db->query( $sql ) ) ;
	$redundants = pico_common_unserialize( $redundants_serialized ) ;
	if( empty( $redundants ) ) $redundants = array() ;

	$smarty->assign( $var_name , $redundants ) ;
}
예제 #4
0
function smarty_function_pico_ef_list($params, &$smarty)
{
    $mydirname = @$params['dir'] . @$params['dirname'];
    $cat_ids = @$params['id'] . @$params['cat_id'];
    $sortby = empty($params['sortby']) ? '' : $params['sortby'];
    $order = empty($params['order']) ? '' : $params['order'];
    $limit_params = @$params['limit'];
    $template = @$params['template'];
    $var_name = @$params['item'] . @$params['assign'];
    //errors
    if (empty($mydirname)) {
        $mydirname = $smarty->get_template_vars('mydirname');
    }
    if (empty($mydirname)) {
        echo 'error ' . __FUNCTION__ . ' [specify dirname]';
        return;
    }
    $error_vals = array('created_time_formatted', 'modified_time_formatted', 'expiring_time_formatted');
    if (in_array($sortby, $error_vals)) {
        echo 'error ' . __FUNCTION__ . ' [please use unixtime format]';
        return;
    }
    //fetch and unserialize
    require_once XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/blocks/blocks.php';
    $contents = b_pico_list_show(array($mydirname, $cat_ids, '', $limit_params, $template, 'disable_renderer' => true));
    $default_vals = array('link', 'poster_uname', 'modifier_uname', 'votes_avg', 'subject', 'body', 'tags_array', 'cat_title', 'can_vote', 'id', 'created_time_formatted', 'modified_time_formatted', 'expiring_time_formatted', 'subject_raw', 'body_raw', 'isadminormod', 'public', 'can_read', 'can_readfull', 'can_edit', 'can_delete', 'content_id', 'permission_id', 'vpath', 'cat_id', 'weight', 'created_time', 'modified_time', 'expiring_time', 'last_cached_time', 'poster_uid', 'poster_ip', 'modifier_uid', 'modifier_ip', 'subject_waiting', 'locked', 'visible', 'approval', 'use_cache', 'allow_comment', 'show_in_navi', 'show_in_menu', 'viewed', 'votes_sum', 'votes_count', 'comments_count', 'htmlheader', 'htmlheader_waiting', 'body_waiting', 'body_cached', 'filters', 'tags', 'extra_fields', 'redundants', 'for_search');
    foreach ($contents['contents'] as $k => $v) {
        $unserialized_ef = pico_common_unserialize($v['extra_fields']);
        $contents['contents'][$k]['extra_fields_items'] = $unserialized_ef;
        if (in_array($sortby, $default_vals)) {
            $contents['contents'][$k]['extra_fields_sortby'] = $v[$sortby];
        } elseif (strpos($sortby, 'dateof_') === 0) {
            $udate = pico_common_get_server_timestamp(strtotime($unserialized_ef[$sortby]));
            $contents['contents'][$k]['extra_fields_sortby'] = $udate;
        } else {
            $contents['contents'][$k]['extra_fields_sortby'] = $unserialized_ef[$sortby];
        }
        $contents['contents'][$k]['extra_fields_count'] = count($unserialized_ef);
    }
    //	$contents['contents']['count'] = count( $contents['contents'] ) ;
    //sort
    foreach ($contents['contents'] as $key => $row) {
        $extra_fields_sortby[$key] = $row['extra_fields_sortby'];
    }
    if ($order == 'SORT_DESC' || $order == 'DESC') {
        array_multisort($extra_fields_sortby, SORT_DESC, $contents['contents']);
    } else {
        array_multisort($extra_fields_sortby, SORT_ASC, $contents['contents']);
    }
    // assign or display
    if ($var_name) {
        $smarty->assign($var_name, $contents['contents']);
        $smarty->assign($var_name . '_count', count($contents['contents']));
    } else {
        echo '<pre>';
        var_dump(@$contents['contents']);
        echo '</pre>';
    }
}
 function queryPermissions($mydirname)
 {
     $ret = array();
     if ($this->uid > 0) {
         $user_handler =& xoops_gethandler('user');
         $user =& $user_handler->get($this->uid);
     }
     $is_module_admin = false;
     if (is_object(@$user)) {
         // is_module_admin
         $module_handler =& xoops_gethandler('module');
         $moduleObj =& $module_handler->getByDirname($mydirname);
         if (is_object($moduleObj) && $user->isAdmin($moduleObj->getVar('mid'))) {
             $is_module_admin = true;
         }
     }
     if (is_object(@$user)) {
         $groups = $user->getGroups();
         if (!empty($groups)) {
             $whr = "`uid`={$this->uid} || `groupid` IN (" . implode(",", $groups) . ")";
         } else {
             $whr = "`uid`={$this->uid}";
         }
     } else {
         $whr = "`groupid`=" . intval(XOOPS_GROUP_ANONYMOUS);
     }
     $sql = "SELECT cat_id,permissions FROM " . $this->db->prefix($mydirname . "_category_permissions") . " WHERE ({$whr})";
     $result = $this->db->query($sql);
     if ($result) {
         while (list($cat_id, $serialized_permissions) = $this->db->fetchRow($result)) {
             $permissions = pico_common_unserialize($serialized_permissions);
             if (is_array(@$ret[$cat_id])) {
                 foreach ($permissions as $perm_name => $value) {
                     @($ret[$cat_id][$perm_name] |= $value);
                 }
             } else {
                 $ret[$cat_id] = $permissions;
             }
         }
     }
     if (empty($ret)) {
         return array(0 => array(), 'is_module_admin' => $is_module_admin);
     } else {
         return $ret + array('is_module_admin' => $is_module_admin);
     }
 }
 function syncContentEfSortables($content_id)
 {
     // store it into the table `content_ef_sortables`
     $sortables = array_map('trim', explode(',', $this->mod_config['extra_fields_sortables']));
     if (!empty($sortables)) {
         $db =& Database::getInstance();
         list($ef_serialized) = $db->fetchRow($db->query("SELECT extra_fields FROM " . $db->prefix($this->mydirname . "_contents") . " WHERE content_id=" . $content_id));
         $ef = pico_common_unserialize($ef_serialized);
         $fields = array();
         $values = array();
         foreach ($sortables as $key => $field) {
             if ($key > 9) {
                 break;
             }
             $fields[] = "`ef{$key}`";
             $values[] = "'" . mysql_real_escape_string(@$ef[$field]) . "'";
         }
         $db->queryF("REPLACE " . $db->prefix("{$this->mydirname}_content_ef_sortables") . " (`content_id`," . implode(',', $fields) . ") VALUES ({$content_id}," . implode(',', $values) . ")");
     }
 }
function pico_get_content_history_profile($mydirname, $content_history_id, $content_id = null)
{
    $db =& Database::getInstance();
    if (empty($content_history_id) && !empty($content_id)) {
        // fetch from contents table as the latest content_history
        $history_row = $db->fetchArray($db->query("SELECT o.*,up.uname AS poster_uname,mp.uname AS modifier_uname FROM " . $db->prefix($mydirname . "_contents") . " o LEFT JOIN " . $db->prefix("users") . " up ON o.poster_uid=up.uid LEFT JOIN " . $db->prefix("users") . " mp ON o.modifier_uid=mp.uid WHERE o.content_id={$content_id}"));
    } else {
        // get $history_row and $content_id
        $history_row = $db->fetchArray($db->query("SELECT oh.*,up.uname AS poster_uname,mp.uname AS modifier_uname FROM " . $db->prefix($mydirname . "_content_histories") . " oh LEFT JOIN " . $db->prefix("users") . " up ON oh.poster_uid=up.uid LEFT JOIN " . $db->prefix("users") . " mp ON oh.modifier_uid=mp.uid WHERE oh.content_history_id={$content_history_id}"));
        if (empty($history_row['content_id'])) {
            die('Invalid content_history_id');
        }
        $content_id = intval($history_row['content_id']);
    }
    // get and process $cat_id
    $cat_id = pico_common_get_cat_id_from_content_id($mydirname, $content_id);
    // unserialize and visualize extra_fields
    $ef4display = print_r(pico_common_unserialize($history_row['extra_fields']), true);
    return array($cat_id, $content_id, "content_id: {$history_row['content_id']}\nsubject:    {$history_row['subject']}\ncat_id:     {$history_row['cat_id']}\nvpath:      {$history_row['vpath']}\ncreated:    " . formatTimestamp($history_row['created_time'], 'm') . " ({$history_row['poster_ip']}) {$history_row['poster_uname']}({$history_row['poster_uid']})\nmodified:   " . formatTimestamp($history_row['modified_time'], 'm') . " ({$history_row['modifier_ip']}) {$history_row['modifier_uname']}({$history_row['modifier_uid']})\nfilters:    {$history_row['filters']}\ntags:    {$history_row['tags']}\n\nhtmlheader:\n{$history_row['htmlheader']}\n\nbody:\n{$history_row['body']}\n\nextra_fields:\n{$ef4display}\n");
}
function pico_main_get_category_permissions_of_current_user($mydirname, $uid = null)
{
    $db =& Database::getInstance();
    if ($uid > 0) {
        $user_handler =& xoops_gethandler('user');
        $user =& $user_handler->get($uid);
    } else {
        $user = @$GLOBALS['xoopsUser'];
    }
    if (is_object($user)) {
        $uid = intval($user->getVar('uid'));
        $groups = $user->getGroups();
        if (!empty($groups)) {
            $whr = "`uid`={$uid} || `groupid` IN (" . implode(",", $groups) . ")";
        } else {
            $whr = "`uid`={$uid}";
        }
    } else {
        $whr = "`groupid`=" . intval(XOOPS_GROUP_ANONYMOUS);
    }
    $sql = "SELECT c.cat_id,cp.permissions FROM " . $db->prefix($mydirname . "_categories") . " c LEFT JOIN " . $db->prefix($mydirname . "_category_permissions") . " cp ON c.cat_permission_id=cp.cat_id  WHERE ({$whr})";
    $result = $db->query($sql);
    if ($result) {
        while (list($cat_id, $serialized_permissions) = $db->fetchRow($result)) {
            $permissions = pico_common_unserialize($serialized_permissions);
            if (is_array(@$ret[$cat_id])) {
                foreach ($permissions as $perm_name => $value) {
                    @($ret[$cat_id][$perm_name] |= $value);
                }
            } else {
                $ret[$cat_id] = $permissions;
            }
        }
    }
    if (empty($ret)) {
        return array(0 => array());
    } else {
        return $ret;
    }
}
예제 #9
0
function smarty_function_pico_ef_get( $params , &$smarty )
{
	$mydirname = @$params['dir'] . @$params['dirname'] ;
	$content_id = @$params['id'] . @$params['content_id'] ;
	$var_name = @$params['item'] . @$params['assign'] ;

	if( empty( $mydirname ) ) $mydirname = $smarty->get_template_vars( 'mydirname' ) ;
	if( empty( $mydirname ) ) {
		echo 'error '.__FUNCTION__.' [specify dirname]';
		return ;
	}

	$content = b_pico_content_show( array( $mydirname , $content_id , '' , 'disable_renderer' => true ) ) ;
	$ef = pico_common_unserialize( $content['content']['extra_fields'] ) ;
	if( $var_name ) {
		// just assign
		$smarty->assign( $var_name , $ef ) ;
	} else {
		// display
		echo '<pre>' ;
		var_dump( @$ef ) ;
		echo '</pre>' ;
	}
}
예제 #10
0
    }
    redirect_header(XOOPS_URL . "/modules/{$mydirname}/admin/index.php?page=contents&amp;cat_id={$cat_id}", 3, _MD_A_PICO_MSG_CONTENTSEXPORTED);
    exit;
}
//
// form stage
//
// category options as array
$cat_options = pico_common_get_cat_options($mydirname);
// fetch contents
if ($cat_id == SPECIAL_CAT_ID_DELETED) {
    $ors = $db->query("SELECT oh.*,up.uname AS poster_uname,um.uname AS modifier_uname,c.cat_title,c.cat_depth_in_tree,1 AS is_deleted  FROM " . $db->prefix($mydirname . "_content_histories") . " oh LEFT JOIN " . $db->prefix("users") . " up ON oh.poster_uid=up.uid LEFT JOIN " . $db->prefix("users") . " um ON oh.modifier_uid=um.uid LEFT JOIN " . $db->prefix($mydirname . "_categories") . " c ON oh.cat_id=c.cat_id LEFT JOIN " . $db->prefix($mydirname . "_contents") . " o ON o.content_id=oh.content_id WHERE o.content_id IS NULL GROUP BY oh.content_id ORDER BY oh.modified_time DESC");
} else {
    $whr_cat_id = $cat_id == SPECIAL_CAT_ID_ALL ? "1" : "o.cat_id={$cat_id}";
    $ors = $db->query("SELECT o.*,up.uname AS poster_uname,um.uname AS modifier_uname,c.cat_title,c.cat_depth_in_tree,0 AS is_deleted  FROM " . $db->prefix($mydirname . "_contents") . " o LEFT JOIN " . $db->prefix("users") . " up ON o.poster_uid=up.uid LEFT JOIN " . $db->prefix("users") . " um ON o.modifier_uid=um.uid LEFT JOIN " . $db->prefix($mydirname . "_categories") . " c ON o.cat_id=c.cat_id WHERE ({$whr_cat_id}) ORDER BY c.cat_depth_in_tree,o.weight,o.content_id");
}
$contents4assign = array();
while ($content_row = $db->fetchArray($ors)) {
    $wrap_full_path = XOOPS_TRUST_PATH . _MD_PICO_WRAPBASE . '/' . $mydirname . str_replace('..', '', $content_row['vpath']);
    $content4assign = array('id' => intval($content_row['content_id']), 'link' => pico_common_make_content_link4html($xoopsModuleConfig, $content_row), 'cat_title' => $myts->makeTboxData4Show($content_row['cat_title'], 1, 1), 'created_time_formatted' => formatTimestamp($content_row['created_time'], 'm'), 'modified_time_formatted' => formatTimestamp($content_row['modified_time'], 'm'), 'expiring_time_formatted' => formatTimestamp(@$content_row['expiring_time'], 'm'), 'poster_uname' => $content_row['poster_uid'] ? $myts->makeTboxData4Show($content_row['poster_uname']) : _MD_PICO_REGISTERED_AUTOMATICALLY, 'modifier_uname' => $content_row['modifier_uid'] ? $myts->makeTboxData4Show($content_row['modifier_uname']) : _MD_PICO_REGISTERED_AUTOMATICALLY, 'subject' => $myts->makeTboxData4Edit($content_row['subject']), 'vpath' => htmlspecialchars($content_row['vpath']), 'wrap_file' => is_file($wrap_full_path) ? array('mtime_formatted' => formatTimestamp(filemtime($wrap_full_path), 'm'), 'size' => filesize($wrap_full_path)) : false, 'histories' => $content_row['is_deleted'] ? pico_get_content_histories4assign($mydirname, intval($content_row['content_id'])) : array(), 'ef' => pico_common_unserialize($content_row['extra_fields']));
    $contents4assign[] = $content4assign + $content_row;
}
//
// display stage
//
xoops_cp_header();
include dirname(__FILE__) . '/mymenu.php';
$tpl =& new XoopsTpl();
$tpl->assign(array('mydirname' => $mydirname, 'mod_name' => $xoopsModule->getVar('name'), 'mod_url' => XOOPS_URL . '/modules/' . $mydirname, 'mod_imageurl' => XOOPS_URL . '/modules/' . $mydirname . '/' . $xoopsModuleConfig['images_dir'], 'mod_config' => $xoopsModuleConfig, 'cat_id' => $cat_id, 'cat_link' => pico_common_make_category_link4html($xoopsModuleConfig, $cat_id, $mydirname), 'cat_title' => htmlspecialchars($cat_title, ENT_QUOTES), 'cat_options' => $cat_options + array(SPECIAL_CAT_ID_ALL => _MD_PICO_ALLCONTENTS, SPECIAL_CAT_ID_DELETED => _MD_PICO_DELETEDCONTENTS), 'cat_options4move' => $cat_options, 'module_options' => $exportable_modules, 'contents' => $contents4assign, 'gticket_hidden' => $xoopsGTicket->getTicketHtml(__LINE__, 1800, 'pico_admin')));
$tpl->display('db:' . $mydirname . '_admin_contents.html');
xoops_cp_footer();
function smarty_modifier_pico_extra_fields( $key = '' , $content_row )
{
	$extra_fields = pico_common_unserialize( @$content_row['extra_fields'] ) ;
	return empty( $key ) ? $extra_fields : @$extra_fields[ $key ] ;
}
예제 #12
0
 function PicoCategory($mydirname, $cat_id, $permissions, $allow_makenew = false, $parentObj = null)
 {
     $this->mydirname = $mydirname;
     $db =& Database::getInstance();
     // get this "category" from given $cat_id
     $sql = "SELECT * FROM " . $db->prefix($mydirname . "_categories") . " WHERE cat_id={$cat_id}";
     if (!($crs = $db->query($sql))) {
         die(_MD_PICO_ERR_SQL . __LINE__);
     }
     if ($db->getRowsNum($crs) <= 0) {
         if ($allow_makenew && is_object($parentObj)) {
             $cat_row = $this->getBlankCategoryRow($parentObj);
         } else {
             $this->errorno = 1;
             // the category does not exist
             return;
         }
     } else {
         $cat_row = $db->fetchArray($crs);
     }
     $this->permission = @$permissions[@$cat_row['cat_permission_id']];
     $this->isadmin = $permissions['is_module_admin'];
     $this->isadminormod = !empty($this->permission['is_moderator']) || $this->isadmin;
     $this->data = array('id' => intval($cat_row['cat_id']), 'isadmin' => $this->isadmin, 'isadminormod' => $this->isadminormod, 'depth_in_tree' => $cat_row['cat_depth_in_tree'] + 1, 'can_read' => $this->isadminormod || !empty($this->permission), 'can_readfull' => $this->isadminormod || @$this->permission['can_readfull'], 'can_post' => $this->isadminormod || @$this->permission['can_post'], 'can_edit' => $this->isadminormod || @$this->permission['can_edit'], 'can_delete' => $this->isadminormod || @$this->permission['can_delete'], 'post_auto_approved' => $this->isadminormod || @$this->permission['post_auto_approved'], 'can_makesubcategory' => $this->isadminormod || @$this->permission['can_makesubcategory'], 'cat_options' => pico_common_unserialize($cat_row['cat_options']), 'paths_raw' => pico_common_unserialize($cat_row['cat_path_in_tree']), 'redundants' => pico_common_unserialize($cat_row['cat_redundants'])) + $cat_row;
     // array guarantee
     foreach (array('cat_options', 'paths_raw', 'redundants') as $key) {
         if (!is_array($this->data[$key])) {
             $this->data[$key] = array();
         }
     }
     // set mod_config
     $this->setOverriddenModConfig();
 }
 function setOverriddenModConfig()
 {
     $module_handler =& xoops_gethandler('module');
     $module =& $module_handler->getByDirname($this->mydirname);
     $config_handler =& xoops_gethandler('config');
     $this->mod_config = $config_handler->getConfigList($module->getVar('mid'));
     $this->mod_name = $module->getVar('name', 'n');
     if (empty($this->mod_config['inherit_configs'])) {
         // 1.7/1.8 compatible (overridding by the single generation)
         foreach ($this->data['cat_options'] as $key => $val) {
             if (isset($this->mod_config[$key])) {
                 $this->mod_config[$key] = $val;
             }
         }
     } else {
         // options(mod_config) overridden by every parents hierarchically
         foreach ($this->data['redundants']['parents_options'] as $cat_id => $serialized_options) {
             $options = @pico_common_unserialize($serialized_options);
             if (!is_array($options)) {
                 continue;
             }
             foreach ($options as $key => $val) {
                 if (isset($this->mod_config[$key])) {
                     $this->mod_config[$key] = $val;
                 }
             }
         }
     }
 }
예제 #14
0
	$wrap_full_path = XOOPS_TRUST_PATH._MD_PICO_WRAPBASE.'/'.$mydirname.str_replace('..','',$content_row['vpath']) ;

	$content4assign = array(
		'id' => intval( $content_row['content_id'] ) ,
		'link' => pico_common_make_content_link4html( $xoopsModuleConfig , $content_row ) ,
		'cat_title' => $myts->makeTboxData4Show( $content_row['cat_title'] , 1 , 1 ) ,
		'created_time_formatted' => formatTimestamp( $content_row['created_time'] , 'm' ) ,
		'modified_time_formatted' => formatTimestamp( $content_row['modified_time'] , 'm' ) ,
		'expiring_time_formatted' => formatTimestamp( @$content_row['expiring_time'] , 'm' ) ,
		'poster_uname' => $content_row['poster_uid'] ? $myts->makeTboxData4Show( $content_row['poster_uname'] ) : _MD_PICO_REGISTERED_AUTOMATICALLY ,
		'modifier_uname' => $content_row['modifier_uid'] ? $myts->makeTboxData4Show( $content_row['modifier_uname'] ) : _MD_PICO_REGISTERED_AUTOMATICALLY ,
		'subject' => $myts->makeTboxData4Edit( $content_row['subject'] ) ,
		'vpath' => htmlspecialchars( $content_row['vpath'] ) ,
		'wrap_file' => is_file( $wrap_full_path ) ? array( 'mtime_formatted' => formatTimestamp( filemtime( $wrap_full_path ) , 'm' ) , 'size' => filesize( $wrap_full_path ) ) : false ,
		'histories' => $content_row['is_deleted'] ? pico_get_content_histories4assign( $mydirname , intval( $content_row['content_id'] ) ) : array() ,
		'ef' => pico_common_unserialize( $content_row['extra_fields'] ) ,
	) ;
	$contents4assign[] = $content4assign + $content_row ;
}


//
// display stage
//

xoops_cp_header();
include dirname(__FILE__) . '/mymenu.php';
$tpl = new XoopsTpl() ;
$tpl->assign( array(
	'mydirname' => $mydirname ,
	'mod_name' => $xoopsModule->getVar('name') ,
function pico_convert_serialized_data($mydirname)
{
    $db =& Database::getInstance();
    // update data in content_extras
    $sql = "SELECT content_extra_id,data FROM " . $db->prefix($mydirname . "_content_extras") . " WHERE data NOT LIKE 'array%'";
    $result = $db->query($sql);
    if ($db->getRowsNum($result) > 0) {
        while (list($id, $data) = $db->fetchRow($result)) {
            $data4sql = mysql_real_escape_string(pico_common_serialize(pico_common_unserialize($data)));
            $db->queryF("UPDATE " . $db->prefix($mydirname . "_content_extras") . " SET data='{$data4sql}' WHERE content_extra_id={$id}");
        }
    }
    // update extra_fields in contents
    $sql = "SELECT content_id,extra_fields FROM " . $db->prefix($mydirname . "_contents") . " WHERE extra_fields NOT LIKE 'array%' OR extra_fields IS NULL";
    $result = $db->query($sql);
    if ($db->getRowsNum($result) > 0) {
        while (list($id, $data) = $db->fetchRow($result)) {
            $data4sql = mysql_real_escape_string(pico_common_serialize(pico_common_unserialize($data)));
            $db->queryF("UPDATE " . $db->prefix($mydirname . "_contents") . " SET extra_fields='{$data4sql}' WHERE content_id={$id}");
        }
    }
}
예제 #16
0
 function filterBody($content4assign)
 {
     $db =& Database::getInstance();
     // marking for compiling errors
     if ($content4assign['last_cached_time'] < $content4assign['modified_time']) {
         if ($content4assign['body_cached'] == _MD_PICO_ERR_COMPILEERROR) {
             return $content4assign['body_cached'];
         } else {
             $db->queryF("UPDATE " . $db->prefix($this->mydirname . "_contents") . " SET body_cached='" . mysql_real_escape_string(_MD_PICO_ERR_COMPILEERROR) . "' WHERE content_id=" . intval($content4assign['content_id']));
         }
     }
     // wraps special check (compare filemtime with modified_time )
     /*if( strstr( $content4assign['filters'] , 'wraps' ) && $content4assign['vpath'] ) {
     		$wrap_full_path = XOOPS_TRUST_PATH._MD_PICO_WRAPBASE.'/'.$this->mydirname.str_replace('..','',$content4assign['vpath']) ;
     		if( @filemtime( $wrap_full_path ) > @$content4assign['modified_time'] ) {
     			$db->queryF( "UPDATE ".$db->prefix($this->mydirname."_contents")." SET modified_time='".filemtime( $wrap_full_path )."' WHERE content_id=".intval($content4assign['content_id']) ) ;
     		}
     	}*/
     // process each filters
     $text = $content4assign['body_raw'];
     $filters = explode('|', $content4assign['filters']);
     foreach (array_keys($filters) as $i) {
         $filter = trim($filters[$i]);
         if (empty($filter)) {
             continue;
         }
         // xcode special check
         if ($filter == 'xcode') {
             $nl2br = $smiley = 0;
             for ($j = $i + 1; $j < $i + 3; $j++) {
                 if (@$filters[$j] == 'nl2br') {
                     $nl2br = 1;
                     $filters[$j] = '';
                 } else {
                     if (@$filters[$j] == 'smiley') {
                         $smiley = 1;
                         $filters[$j] = '';
                     }
                 }
             }
             require_once dirname(dirname(__FILE__)) . '/class/pico.textsanitizer.php';
             $myts =& PicoTextSanitizer::getInstance();
             $text = $myts->displayTarea($text, 1, $smiley, 1, 1, $nl2br);
             $text = $myts->pageBreak($this->mydirname, $text, $content4assign);
             continue;
         }
         $func_name = 'pico_' . $filter;
         $file_path = dirname(dirname(__FILE__)) . '/filters/pico_' . $filter . '.php';
         if (!function_exists($func_name)) {
             require_once $file_path;
         }
         $text = $func_name($this->mydirname, $text, $content4assign);
     }
     // store the result into body_cached and for_search field just after modification of the content
     // if( empty( $content4assign['for_search'] ) ) {
     if ($content4assign['last_cached_time'] < $content4assign['modified_time']) {
         $for_search = $content4assign['subject_raw'] . ' ' . strip_tags($text) . ' ' . implode(' ', array_values(pico_common_unserialize(@$content4assign['extra_fields'])));
         $db->queryF("UPDATE " . $db->prefix($this->mydirname . "_contents") . " SET body_cached='" . mysql_real_escape_string($text) . "', for_search='" . mysql_real_escape_string($for_search) . "', last_cached_time=UNIX_TIMESTAMP() WHERE content_id=" . intval($content4assign['content_id']));
     }
     return $text;
 }
예제 #17
0
	$groups4assign[] = array(
		'gid' => $gid ,
		'name' => $group->getVar('name') ,
		'perms' => $gpermissions ,
	) ;
}


// create user form
$users4assign = array() ;
$cprs = $db->query( "SELECT u.uid,u.uname,cp.permissions FROM ".$db->prefix($mydirname."_category_permissions")." cp LEFT JOIN ".$db->prefix("users")." u ON cp.uid=u.uid WHERE cp.cat_id=$cat_permission_id AND cp.groupid IS NULL ORDER BY u.uid ASC" ) ;
$user_trs = '' ;
while( list( $uid , $uname , $serialized_upermissions ) = $db->fetchRow( $cprs ) ) {

	$uid = intval( $uid ) ;
	$upermissions = pico_common_unserialize( $serialized_upermissions ) ;

	$users4assign[] = array(
		'uid' => $uid ,
		'name' => htmlspecialchars( $uname , ENT_QUOTES ) ,
		'perms' => $upermissions ,
	) ;
}


// create new user form
$new_users4assign = array() ;
for( $i = 0 ; $i < 5 ; $i ++ ) {
	$new_users4assign[] = array(
		'nid' => $i ,
		'perms' => array( 'can_read' => 1 ) ,
예제 #18
0
파일: extras.php 프로젝트: nunoluciano/uxcl
$whr_txt = $txt ? "ce.data LIKE '%".addslashes($txt)."%'" : '1' ;

// pre query
list( $hit ) = $db->fetchRow( $db->query( "SELECT COUNT(*) FROM ".$db->prefix($mydirname."_content_extras")." ce LEFT JOIN ".$db->prefix($mydirname."_contents")." o ON o.content_id=ce.content_id WHERE $whr_extra_id AND $whr_content_id AND $whr_txt" ) ) ;

// pagenav
$pagenav = '' ;
$pagenav_obj = new XoopsPageNav( $hit , $num , $pos , 'pos', "page=extras&amp;num=$num&amp;content_id=$content_id&amp;order=".urlencode($order)."&amp;txt=".urlencode($txt) ) ;
$pagenav = $pagenav_obj->renderNav() ;

// main query
$ers = $db->query( "SELECT ce.*,o.vpath,o.subject AS content_subject FROM ".$db->prefix($mydirname."_content_extras")." ce LEFT JOIN ".$db->prefix($mydirname."_contents")." o ON o.content_id=ce.content_id WHERE $whr_extra_id AND $whr_content_id AND $whr_txt ORDER BY $order LIMIT $pos,$num" ) ;

$extras4assign = array() ;
while( $extra_row = $db->fetchArray( $ers ) ) {
	$data = pico_common_unserialize( $extra_row['data'] ) ;
	if( empty( $data ) ) $data = $extra_row['data'] ;
	$extra4assign = array(
		'id' => intval( $extra_row['content_extra_id'] ) ,
		'link' => pico_common_make_content_link4html( $xoopsModuleConfig , $extra_row ) ,
		'extra_type_formatted' => str_replace( '::' , '<br />' , htmlspecialchars( $extra_row['extra_type'] , ENT_QUOTES ) ) ,
		'created_time_formatted' => formatTimestamp( $extra_row['created_time'] ) ,
		'data' => $data ,
		'data_summary_short_raw' => xoops_substr( pico_admin_make_summary4extras( $data ) , 0 , 100 ) ,
		'data_summary_raw' => pico_admin_make_summary4extras( $data ) ,
	) ;
	$extras4assign[] = $extra4assign + $extra_row ;
}


//