当前位置: 首页>>代码示例>>PHP>>正文


PHP Globals::setGlobal方法代码示例

本文整理汇总了PHP中Globals::setGlobal方法的典型用法代码示例。如果您正苦于以下问题:PHP Globals::setGlobal方法的具体用法?PHP Globals::setGlobal怎么用?PHP Globals::setGlobal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Globals的用法示例。


在下文中一共展示了Globals::setGlobal方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1:

 function &current()
 {
     $temp = parent::current();
     if ($temp['invisible'] == 1) {
         Globals::setGlobal('num_online_invisible', Globals::getGlobal('num_online_invisible') + 1);
     }
     if ($temp['user_id'] != 0) {
         $group = get_user_max_group($temp, $this->groups);
         $temp['color'] = !isset($group['color']) || $group['color'] == '' ? '000000' : $group['color'];
         $temp['font_weight'] = @$group['min_perm'] > MEMBER ? 'bold' : 'normal';
     }
     /* Should we free the result? */
     if ($this->row == $this->size - 1) {
         $this->result->freeResult();
     }
     if ($temp['name'] != '' && (isset($temp['invisible']) && $temp['invisible'] == 0 || !isset($temp['invisible']))) {
         return $temp;
     }
 }
开发者ID:BackupTheBerlios,项目名称:k4bb,代码行数:19,代码来源:online_users.class.php

示例2: current

 function current()
 {
     $temp = parent::current();
     if ($temp['invisible'] == 1) {
         Globals::setGlobal('num_online_invisible', Globals::getGlobal('num_online_invisible') + 1);
     }
     if ($temp['user_id'] >= 0) {
         $group = get_user_max_group($temp, $this->groups);
         $temp['color'] = !isset($group['color']) || $group['color'] == '' ? '000000' : $group['color'];
         $temp['font_weight'] = @$group['min_perm'] > MEMBER ? 'bold' : 'normal';
     }
     /* Should we free the result? */
     if (!$this->hasNext()) {
         $this->result->free();
     }
     $temp['U_MEMBERURL'] = K4Url::getMemberUrl($temp['user_id']);
     //if($temp['name'] != '') {
     //	if(((isset($temp['invisible']) && $temp['invisible'] == 0) || !isset($temp['invisible']))) {
     return $temp;
     //	}
     //}
 }
开发者ID:BackupTheBerlios,项目名称:k4bb-svn,代码行数:22,代码来源:online_users.class.php

示例3: execute

 function execute(&$request)
 {
     global $_QUERYPARAMS, $_DATASTORE, $_SETTINGS;
     $this->dba = $request['dba'];
     /* set the breadcrumbs bit */
     k4_bread_crumbs($request['template'], $request['dba'], 'L_INFORMATION');
     /* Check the request ID */
     if (!isset($_REQUEST['forum_id']) || !$_REQUEST['forum_id'] || intval($_REQUEST['forum_id']) == 0) {
         $action = new K4InformationAction(new K4LanguageElement('L_FORUMDOESNTEXIST'), 'content', FALSE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_FORUMDOESNTEXIST');
     }
     /* Check the request ID */
     if (!isset($_REQUEST['forum_id']) || !$_REQUEST['forum_id'] || intval($_REQUEST['forum_id']) == 0) {
         $action = new K4InformationAction(new K4LanguageElement('L_FORUMDOESNTEXIST'), 'content', FALSE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_FORUMDOESNTEXIST');
     }
     $forum = $request['dba']->getRow("SELECT * FROM " . K4FORUMS . " WHERE forum_id = " . intval($_REQUEST['forum_id']));
     /* Check the forum data given */
     if (!$forum || !is_array($forum) || empty($forum)) {
         $action = new K4InformationAction(new K4LanguageElement('L_FORUMDOESNTEXIST'), 'content', FALSE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_FORUMDOESNTEXIST');
     }
     /* Make sure the we are trying to post into a forum */
     if (!($forum['row_type'] & FORUM) || $forum['forum_id'] == GARBAGE_BIN) {
         $action = new K4InformationAction(new K4LanguageElement('L_CANTPOSTTONONFORUM'), 'content', FALSE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_CANTPOSTTONONFORUM');
     }
     /* Do we have permission to post to this forum? */
     if ($request['user']->get('perms') < get_map('topics', 'can_add', array('forum_id' => $forum['forum_id']))) {
         $action = new K4InformationAction(new K4LanguageElement('L_PERMCANTPOST'), 'content', FALSE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_PERMCANTPOST');
     }
     /* General error checking */
     if (!isset($_REQUEST['name']) || $_REQUEST['name'] == '') {
         $action = new K4InformationAction(new K4LanguageElement('L_INSERTTOPICNAME'), 'content', TRUE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_INSERTTOPICNAME');
     }
     if (!$this->runPostFilter('name', new FALengthFilter(intval($_SETTINGS['topicmaxchars'])))) {
         $action = new K4InformationAction(new K4LanguageElement('L_TITLETOOSHORT', intval($_SETTINGS['topicminchars']), intval($_SETTINGS['topicmaxchars'])), 'content', TRUE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message(new K4LanguageElement('L_TITLETOOSHORT', intval($_SETTINGS['topicminchars']), intval($_SETTINGS['topicmaxchars'])));
     }
     if (!$this->runPostFilter('name', new FALengthFilter(intval($_SETTINGS['topicmaxchars']), intval($_SETTINGS['topicminchars'])))) {
         $action = new K4InformationAction(new K4LanguageElement('L_TITLETOOSHORT', intval($_SETTINGS['topicminchars']), intval($_SETTINGS['topicmaxchars'])), 'content', TRUE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message(new K4LanguageElement('L_TITLETOOSHORT', intval($_SETTINGS['topicminchars']), intval($_SETTINGS['topicmaxchars'])));
     }
     if (!isset($_REQUEST['message']) || $_REQUEST['message'] == '') {
         $action = new K4InformationAction(new K4LanguageElement('L_INSERTTOPICMESSAGE'), 'content', TRUE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_INSERTTOPICMESSAGE');
     }
     /* Get our topic */
     $draft = $request['dba']->getRow("SELECT * FROM " . K4POSTS . " WHERE post_id = " . intval($_REQUEST['post_id']) . " AND is_draft = 1 AND poster_id = " . intval($request['user']->get('id')));
     if (!$draft || !is_array($draft) || empty($draft)) {
         $action = new K4InformationAction(new K4LanguageElement('L_DRAFTDOESNTEXIST'), 'content', FALSE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_DRAFTDOESNTEXIST');
     }
     /* set the breadcrumbs bit */
     k4_bread_crumbs($request['template'], $request['dba'], 'L_POSTTOPIC', $forum);
     $created = time();
     /* Initialize the bbcode parser with the topic message */
     $_REQUEST['message'] = substr($_REQUEST['message'], 0, $_SETTINGS['postmaxchars']);
     /* Parse the bbcode */
     $body_text = $_REQUEST['message'];
     $submit_type = isset($_REQUEST['submit_type']) ? $_REQUEST['submit_type'] : 'post';
     if (!isset($_REQUEST['disable_bbcode']) || !$_REQUEST['disable_bbcode']) {
         $parser =& new BBParser();
         Globals::setGlobal('forum_id', $forum['forum_id']);
         Globals::setGlobal('maxpolloptions', $request['template']->getVar('maxpolloptions') > $forum['maxpolloptions'] ? $forum['maxpolloptions'] : $request['template']->getVar('maxpolloptions'));
         Globals::setGlobal('maxpollquestions', $request['template']->getVar('maxpollquestions') > $forum['maxpollquestions'] ? $forum['maxpollquestions'] : $request['template']->getVar('maxpollquestions'));
         if ($submit_type == 'post' || $submit_type == 'draft' || isset($_REQUEST['post'])) {
             $parser->register('BBPollNode');
         }
         $body_text = $parser->parse($body_text);
         $is_poll = Globals::getGlobal('is_poll');
     }
     // permissions are taken into account inside the poller
     //$poller		= &new K4BBPolls($body_text, $draft['body_text'], $forum, $draft['post_id']);
     /**
      * Figure out what type of topic type this is
      */
     $post_type = isset($_REQUEST['post_type']) && intval($_REQUEST['post_type']) != 0 ? $_REQUEST['post_type'] : TOPIC_NORMAL;
     if ($post_type == TOPIC_STICKY && $request['user']->get('perms') < get_map('sticky', 'can_add', array('forum_id' => $forum['forum_id']))) {
         $post_type = TOPIC_NORMAL;
     } else {
         if ($post_type == TOPIC_ANNOUNCE && $request['user']->get('perms') < get_map('announce', 'can_add', array('forum_id' => $forum['forum_id']))) {
             $post_type = TOPIC_NORMAL;
         }
     }
     $is_feature = isset($_REQUEST['is_feature']) && $_REQUEST['is_feature'] == 'yes' ? 1 : 0;
     if ($is_feature == 1 && $request['user']->get('perms') < get_map('feature', 'can_add', array('forum_id' => $forum['forum_id']))) {
         $is_feature = 0;
     }
     /* If we are submitting or saving a draft */
     if ($submit_type == 'post' || $submit_type == 'draft' || (isset($_REQUEST['post']) || isset($_REQUEST['draft']))) {
         /**
          * Build the queries to add the draft
          */
         $poster_name = $request['user']->get('id') <= 0 ? k4_htmlentities(isset($_REQUEST['poster_name']) ? $_REQUEST['poster_name'] : '', ENT_QUOTES) : $request['user']->get('name');
         $update_a = $request['dba']->prepareStatement("UPDATE " . K4POSTS . " SET name=?,body_text=?,posticon=?,disable_html=?,disable_bbcode=?,disable_emoticons=?,disable_sig=?,disable_areply=?,disable_aurls=?,is_draft=?,post_type=?,is_feature=?,is_poll=?,created=? WHERE post_id=?");
         /* Set the informtion */
         $update_a->setInt(1, $created);
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:k4bb-svn,代码行数:101,代码来源:topics.class.php

示例4: execute

 function execute(&$request)
 {
     global $_QUERYPARAMS, $_DATASTORE;
     /* set the breadcrumbs bit */
     k4_bread_crumbs($request['template'], $request['dba'], 'L_INFORMATION');
     /* Get our reply */
     $reply = $request['dba']->getRow("SELECT * FROM " . K4POSTS . " WHERE post_id = " . intval($_REQUEST['id']));
     if (!$reply || !is_array($reply) || empty($reply)) {
         $action = new K4InformationAction(new K4LanguageElement('L_REPLYDOESNTEXIST'), 'content', FALSE);
         return $action->execute($request);
     }
     $request['template']->setVar('attach_post_id', $reply['post_id']);
     $topic = $request['dba']->getRow("SELECT * FROM " . K4POSTS . " WHERE post_id = " . intval($reply['post_id']));
     if (!$topic || !is_array($topic) || empty($topic)) {
         $action = new K4InformationAction(new K4LanguageElement('L_TOPICDOESNTEXIST'), 'content', FALSE);
         return $action->execute($request);
     }
     $forum = $request['dba']->getRow("SELECT * FROM " . K4FORUMS . " WHERE forum_id = " . intval($reply['forum_id']));
     /* Check the forum data given */
     if (!$forum || !is_array($forum) || empty($forum)) {
         $action = new K4InformationAction(new K4LanguageElement('L_FORUMDOESNTEXIST'), 'content', FALSE);
         return $action->execute($request);
     }
     /* Make sure the we are trying to post into a forum */
     if (!($forum['row_type'] & FORUM) || $forum['forum_id'] == GARBAGE_BIN) {
         $action = new K4InformationAction(new K4LanguageElement('L_CANTPOSTTONONFORUM'), 'content', FALSE);
         return $action->execute($request);
     }
     /* Does this user have permission to edit theirreply if the topic is locked? */
     if ($topic['post_locked'] == 1 && get_map('closed', 'can_edit', array('forum_id' => $forum['forum_id'])) > $request['user']->get('perms')) {
         $action = new K4InformationAction(new K4LanguageElement('L_YOUNEEDPERMS'), 'content', FALSE);
         return $action->execute($request);
     }
     /* set the breadcrumbs bit */
     k4_bread_crumbs($request['template'], $request['dba'], 'L_EDITREPLY', $reply, $forum);
     if ($reply['poster_id'] == $request['user']->get('id')) {
         if (get_map('replies', 'can_edit', array('forum_id' => $forum['forum_id'])) > $request['user']->get('perms')) {
             $action = new K4InformationAction(new K4LanguageElement('L_YOUNEEDPERMS'), 'content', FALSE);
             return $action->execute($request);
         }
     } else {
         if (get_map('other_replies', 'can_edit', array('forum_id' => $forum['forum_id'])) > $request['user']->get('perms')) {
             $action = new K4InformationAction(new K4LanguageElement('L_YOUNEEDPERMS'), 'content', FALSE);
             return $action->execute($request);
         }
     }
     //$bbcode				= &new BBCodex($request['dba'], $request['user']->getInfoArray(), $reply['body_text'], $forum['forum_id'], TRUE, TRUE, TRUE, TRUE);
     $parser =& new BBParser();
     Globals::setGlobal('forum_id', $forum['forum_id']);
     Globals::setGlobal('maxpolloptions', $forum['maxpolloptions']);
     /* Get and set the emoticons and post icons to the template */
     $emoticons = $request['dba']->executeQuery("SELECT * FROM " . K4EMOTICONS . " WHERE clickable = 1");
     $posticons = $request['dba']->executeQuery("SELECT * FROM " . K4POSTICONS);
     $request['template']->setList('emoticons', $emoticons);
     $request['template']->setList('posticons', $posticons);
     $request['template']->setVar('emoticons_per_row', $request['template']->getVar('smcolumns'));
     $request['template']->setVar('emoticons_per_row_remainder', $request['template']->getVar('smcolumns') - 1);
     /* Get the posting options */
     topic_post_options($request['template'], $request['user'], $forum);
     post_attachment_options($request, $forum, $reply);
     $reply['body_text'] = $parser->revert($reply['body_text']);
     foreach ($reply as $key => $val) {
         $request['template']->setVar('post_' . $key, $val);
     }
     /* Assign the forum information to the template */
     foreach ($forum as $key => $val) {
         $request['template']->setVar('forum_' . $key, $val);
     }
     /* Set the the button display options */
     $request['template']->setVisibility('edit_reply', TRUE);
     $request['template']->setVisibility('post_id', TRUE);
     $request['template']->setVisibility('post_reply', FALSE);
     $request['template']->setVisibility('edit_post', TRUE);
     /* Set the form actiob */
     $request['template']->setVar('newreply_act', 'newreply.php?act=updatereply');
     /* Get 10 replies that are above this reply to set as a topic review */
     // TODO: work on this a bit.
     $result = $request['dba']->executeQuery("SELECT * FROM " . K4POSTS . " WHERE (post_id=" . intval($topic['post_id']) . " OR parent_id=" . intval($topic['post_id']) . ") ORDER BY created DESC LIMIT 10");
     $it =& new PostsIterator($request, $result);
     $request['template']->setList('topic_review', $it);
     /* set the breadcrumbs bit */
     k4_bread_crumbs($request['template'], $request['dba'], 'L_EDITREPLY', $topic, $forum);
     /* Create our editor */
     create_editor($request, $reply['body_text'], 'post', $forum);
     /* Set the post topic form */
     //$request['template']->setFile('preview', 'post_preview.html');
     $request['template']->setFile('content', 'newreply.html');
     $request['template']->setVar('L_TITLETOOSHORT', sprintf($request['template']->getVar('L_TITLETOOSHORT'), $request['template']->getVar('topicminchars'), $request['template']->getVar('topicmaxchars')));
     return TRUE;
 }
开发者ID:BackupTheBerlios,项目名称:k4bb-svn,代码行数:90,代码来源:replies.class.php

示例5: execute

 function execute(&$request)
 {
     if (USE_XMLHTTP) {
         if (!isset($_REQUEST['post_id']) || intval($_REQUEST['post_id']) == 0) {
             return xmlhttp_message('L_YOUNEEDPERMS');
         }
         // get the post
         $post = $request['dba']->getRow("SELECT * FROM " . K4POSTS . " WHERE post_id = " . intval($_REQUEST['post_id']));
         if (!is_array($post) || empty($post)) {
             return xmlhttp_message('L_POSTDOESNTEXIST');
         }
         if ($post['row_type'] & TOPIC) {
             if ($request['user']->get('id') == $post['poster_id'] && $request['user']->get('perms') < get_map($user, 'topics', 'can_edit', array('forum_id' => $post['forum_id']))) {
                 return xmlhttp_message('L_YOUNEEDPERMS');
             }
             if ($request['user']->get('id') != $post['poster_id'] && $request['user']->get('perms') < get_map($user, 'other_topics', 'can_edit', array('forum_id' => $post['forum_id']))) {
                 return xmlhttp_message('L_YOUNEEDPERMS');
             }
         } else {
             if ($post['row_type'] & REPLY) {
                 if ($request['user']->get('id') == $post['poster_id'] && $request['user']->get('perms') < get_map($user, 'replies', 'can_edit', array('forum_id' => $post['forum_id']))) {
                     return xmlhttp_message('L_YOUNEEDPERMS');
                 }
                 if ($request['user']->get('id') != $post['poster_id'] && $request['user']->get('perms') < get_map($user, 'other_replies', 'can_edit', array('forum_id' => $post['forum_id']))) {
                     return xmlhttp_message('L_YOUNEEDPERMS');
                 }
             } else {
                 return xmlhttp_message('L_YOUNEEDPERMS');
             }
         }
         if (!isset($_REQUEST['message']) || $_REQUEST['message'] == '') {
             return xmlhttp_message('L_INSERTPOSTMESSAGE');
         }
         global $_ALLFORUMS;
         Globals::setGlobal('forum_id', $post['forum_id']);
         Globals::setGlobal('maxpolloptions', $request['template']->getVar('maxpolloptions') > $_ALLFORUMS[$post['forum_id']]['maxpolloptions'] ? $_ALLFORUMS[$post['forum_id']]['maxpolloptions'] : $request['template']->getVar('maxpolloptions'));
         Globals::setGlobal('maxpollquestions', $request['template']->getVar('maxpollquestions') > $_ALLFORUMS[$post['forum_id']]['maxpollquestions'] ? $_ALLFORUMS[$post['forum_id']]['maxpollquestions'] : $request['template']->getVar('maxpollquestions'));
         $parser =& new BBParser();
         $parser->register('BBPollNode');
         $body_text = $parser->parse($_REQUEST['message']);
         $body_text = $parser->comparePolls($post['post_id'], $body_text, $post['body_text'], $request['dba']);
         $is_poll = Globals::getGlobal('is_poll');
         /* If this topic is a redirect/ connects to one, update the original */
         if ($post['row_type'] & TOPIC && ($post['moved_new_post_id'] > 0 || $post['moved_old_post_id'] > 0)) {
             $update = $request['dba']->prepareStatement("UPDATE " . K4POSTS . " SET body_text=?,edited_time=?,edited_username=?,edited_userid=?,is_poll=? WHERE post_id=?");
             $update->setString(1, $body_text);
             $update->setInt(2, time());
             $update->setString(3, $request['user']->get('name'));
             $update->setInt(4, $request['user']->get('id'));
             $update->setInt(5, $is_poll);
             $update->setInt(6, $post['moved_new_post_id'] > 0 ? $post['moved_new_post_id'] : $post['moved_old_post_id']);
             $update->executeUpdate();
         }
         /* Update the original */
         $update = $request['dba']->prepareStatement("UPDATE " . K4POSTS . " SET body_text=?,edited_time=?,edited_username=?,edited_userid=?,is_poll=? WHERE post_id=?");
         $update->setString(1, $body_text);
         $update->setInt(2, time());
         $update->setString(3, $request['user']->get('name'));
         $update->setInt(4, $request['user']->get('id'));
         $update->setInt(5, $is_poll);
         $update->setInt(6, $post['post_id']);
         $update->executeUpdate();
         xmlhttp_header();
         echo $body_text;
         xmlhttp_footer();
     }
     return TRUE;
 }
开发者ID:BackupTheBerlios,项目名称:k4bb-svn,代码行数:68,代码来源:misc.php

示例6: execute

 function execute(&$request)
 {
     global $_QUERYPARAMS, $_DATASTORE, $_SETTINGS;
     /* set the breadcrumbs bit */
     k4_bread_crumbs($request['template'], $request['dba'], 'L_INFORMATION');
     /* Check the request ID */
     if (!isset($_REQUEST['forum_id']) || !$_REQUEST['forum_id'] || intval($_REQUEST['forum_id']) == 0) {
         $action = new K4InformationAction(new K4LanguageElement('L_FORUMDOESNTEXIST'), 'content', FALSE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_FORUMDOESNTEXIST');
     }
     $forum = $request['dba']->getRow("SELECT * FROM " . K4FORUMS . " WHERE forum_id=" . intval($_REQUEST['forum_id']));
     /* Check the forum data given */
     if (!$forum || !is_array($forum) || empty($forum)) {
         $action = new K4InformationAction(new K4LanguageElement('L_FORUMDOESNTEXIST'), 'content', FALSE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_FORUMDOESNTEXIST');
     }
     /* Make sure the we are trying to edit in a forum */
     if (!($forum['row_type'] & FORUM) || $forum['forum_id'] == GARBAGE_BIN) {
         $action = new K4InformationAction(new K4LanguageElement('L_CANTEDITTONONFORUM'), 'content', FALSE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_CANTEDITTONONFORUM');
     }
     /* General error checking */
     if ($this->row_type & TOPIC) {
         if (!isset($_REQUEST['name']) || $_REQUEST['name'] == '') {
             $action = new K4InformationAction(new K4LanguageElement('L_INSERTTOPICNAME'), 'content', TRUE);
             return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_INSERTTOPICNAME');
         }
         $len = strlen($_REQUEST['name']);
         if ($len < intval($_SETTINGS['topicminchars']) || $len > intval($_SETTINGS['topicmaxchars'])) {
             $action = new K4InformationAction(new K4LanguageElement('L_TITLETOOSHORT', intval($_SETTINGS['topicminchars']), intval($_SETTINGS['topicmaxchars'])), 'content', TRUE);
             return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message(new K4LanguageElement('L_TITLETOOSHORT', intval($_SETTINGS['topicminchars']), intval($_SETTINGS['topicmaxchars'])));
         }
     }
     if (!isset($_REQUEST['message']) || $_REQUEST['message'] == '') {
         $action = new K4InformationAction(new K4LanguageElement('L_INSERTTOPICMESSAGE'), 'content', TRUE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_INSERTTOPICMESSAGE');
     }
     /* Get our post */
     $post = $request['dba']->getRow("SELECT * FROM " . K4POSTS . " WHERE post_id = " . intval($_REQUEST['post_id']));
     if (!is_array($post) || empty($post)) {
         $action = new K4InformationAction(new K4LanguageElement('L_POSTDOESNTEXIST'), 'content', FALSE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_POSTDOESNTEXIST');
     }
     $type = $this->row_type & TOPIC ? 'topics' : 'replies';
     /* Does this person have permission to edit this topic? */
     if ($post['poster_id'] == $request['user']->get('id')) {
         if (get_map($type, 'can_edit', array('forum_id' => $forum['forum_id'])) > $request['user']->get('perms')) {
             $action = new K4InformationAction(new K4LanguageElement('L_YOUNEEDPERMS'), 'content', FALSE);
             return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_YOUNEEDPERMS');
         }
     } else {
         if (get_map('other_' . $type, 'can_edit', array('forum_id' => $forum['forum_id'])) > $request['user']->get('perms')) {
             $action = new K4InformationAction(new K4LanguageElement('L_YOUNEEDPERMS'), 'content', FALSE);
             return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_YOUNEEDPERMS');
         }
     }
     if ($post['is_poll'] == 1) {
         // TODO: something here.
     }
     /* Does this user have permission to edit this topic if it is locked? */
     if ($post['post_locked'] == 1 && get_map('closed', 'can_edit', array('forum_id' => $forum['forum_id'])) > $request['user']->get('perms')) {
         $action = new K4InformationAction(new K4LanguageElement('L_YOUNEEDPERMS'), 'content', FALSE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_YOUNEEDPERMS');
     }
     /* set the breadcrumbs bit */
     k4_bread_crumbs($request['template'], $request['dba'], $this->row_type & TOPIC ? 'L_EDITTOPIC' : 'L_EDITREPLY', $post, $forum);
     /* Initialize the bbcode parser with the topic message */
     $_REQUEST['message'] = substr($_REQUEST['message'], 0, $_SETTINGS['postmaxchars']);
     /* Parse the bbcode */
     $body_text = $_REQUEST['message'];
     $submit_type = isset($_REQUEST['submit_type']) ? $_REQUEST['submit_type'] : 'post';
     if (!isset($_REQUEST['disable_bbcode']) || !$_REQUEST['disable_bbcode']) {
         $parser =& new BBParser();
         Globals::setGlobal('forum_id', $forum['forum_id']);
         Globals::setGlobal('maxpolloptions', $request['template']->getVar('maxpolloptions') > $forum['maxpolloptions'] ? $forum['maxpolloptions'] : $request['template']->getVar('maxpolloptions'));
         Globals::setGlobal('maxpollquestions', $request['template']->getVar('maxpollquestions') > $forum['maxpollquestions'] ? $forum['maxpollquestions'] : $request['template']->getVar('maxpollquestions'));
         if ($submit_type == 'post' || isset($_REQUEST['post'])) {
             $parser->register('BBPollNode');
         }
         $body_text = $parser->parse($body_text);
         if ($submit_type == 'post' || isset($_REQUEST['post'])) {
             $body_text = $parser->comparePolls($post['post_id'], $body_text, $post['body_text'], $request['dba']);
         }
         $is_poll = Globals::getGlobal('is_poll');
     }
     // permissions are taken into account inside the poller
     //$poller		= &new K4BBPolls($body_text, $topic['body_text'], $forum, $topic['post_id']);
     $request['template']->setVar('newtopic_action', 'newtopic.php?act=updatetopic');
     if ($this->row_type & TOPIC) {
         /* Get the topic type */
         $post_type = isset($_REQUEST['post_type']) && intval($_REQUEST['post_type']) != 0 ? $_REQUEST['post_type'] : TOPIC_NORMAL;
         /* Check the topic type and check if this user has permission to post that type of topic */
         if ($post_type == TOPIC_STICKY && $request['user']->get('perms') < get_map('sticky', 'can_add', array('forum_id' => $forum['forum_id']))) {
             $post_type = TOPIC_NORMAL;
         } else {
             if ($post_type == TOPIC_ANNOUNCE && $request['user']->get('perms') < get_map('announce', 'can_add', array('forum_id' => $forum['forum_id']))) {
                 $post_type = TOPIC_NORMAL;
             }
         }
         /* Is this a featured topic? */
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:k4bb-svn,代码行数:101,代码来源:posts.class.php

示例7: flatten

 function flatten($noparse = FALSE)
 {
     if ($noparse) {
         return $this->getUnparsed($noparse);
     }
     $body = parent::flatten($noparse);
     $question = trim($this->_attrib);
     $items = explode('[*]', $body);
     $param = $this->_attrib;
     $maxpolloptions = intval(Globals::getGlobal('maxpolloptions'));
     $forum_id = intval(Globals::getGlobal('forum_id'));
     if (!Globals::getGlobal('num_polls')) {
         Globals::setGlobal('num_polls', 0);
     }
     $can_poll = $forum_id > 0 && $_SESSION['user']->get('perms') >= get_map('bbcode', 'can_add', array('forum_id' => $forum_id));
     $ret = '';
     if (count($items) > 0 && $maxpolloptions > 0 && $can_poll && $question != '' && Globals::getGlobal('num_polls') <= Globals::getGlobal('maxpollquestions')) {
         global $_DBA;
         $question = $_DBA->quote(k4_htmlentities($question, ENT_QUOTES));
         $insert_question = $_DBA->executeUpdate("INSERT INTO " . K4POLLQUESTIONS . " (question, created, user_id, user_name) VALUES ('{$question}', " . time() . ", " . intval($_SESSION['user']->get('id')) . ", '" . $_DBA->quote($_SESSION['user']->get('name')) . "')");
         $question_id = $_DBA->getInsertId(K4POLLQUESTIONS, 'id');
         $buffer = '';
         $i = 0;
         foreach ($items as $item) {
             if ($i >= $maxpolloptions) {
                 break;
             }
             $item = trim(strip_tags(preg_replace("~(\r\n|\r|\n|\t|<br>|<br\\/>|<br \\/>)~i", "", $item)));
             if ($item != '') {
                 $_DBA->executeUpdate("INSERT INTO " . K4POLLANSWERS . " (question_id,answer) VALUES (" . intval($question_id) . ", '" . $_DBA->quote(k4_htmlentities($item, ENT_QUOTES)) . "')");
                 $i++;
             }
         }
         Globals::setGlobal('is_poll', TRUE);
         Globals::setGlobal('num_polls', Globals::getGlobal('num_polls') + 1);
         $ret = "[poll={$question_id}]";
     }
     return $ret;
 }
开发者ID:BackupTheBerlios,项目名称:k4bb-svn,代码行数:39,代码来源:bbparser.php

示例8: execute

 function execute(&$request)
 {
     /* set the breadcrumbs bit */
     k4_bread_crumbs($request['template'], $request['dba'], 'L_USERCONTROLPANEL');
     global $_SETTINGS;
     $check = new K4PMCheckPerms();
     $check->execute($request);
     if (get_map('pm_message', 'can_add', array()) > $request['user']->get('perms')) {
         no_perms_error($request);
         return TRUE;
     }
     $num_pms = $request['dba']->getValue("SELECT COUNT(*) FROM " . K4PRIVMESSAGES . " WHERE poster_id = " . intval($request['user']->get('id')));
     $max_pms = intval($request['template']->getVar('pmquota'));
     if ($num_pms >= $max_pms) {
         $action = new K4InformationAction(new K4LanguageElement('L_TOOMANYPMS', $num_pms, $max_pms), 'usercp_content', FALSE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message(new K4LanguageElement('L_TOOMANYPMS', $num_pms, $max_pms));
     }
     k4_bread_crumbs($request['template'], $request['dba'], 'L_USERCONTROLPANEL');
     $request['template']->setFile('content', 'usercp.html');
     /**
      * Get who the message is going to
      */
     if (!$this->runPostFilter('to', new FARequiredFilter())) {
         $action = new K4InformationAction(new K4LanguageElement('L_NEEDSENDPMTOSOMEONE'), 'usercp_content', TRUE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_NEEDSENDPMTOSOMEONE');
     }
     $users = isset($_REQUEST['to']) && $_REQUEST['to'] != '' ? explode(",", $_REQUEST['to']) : array($_REQUEST['to']);
     $users = isset($_REQUEST['cc']) && $_REQUEST['cc'] != '' ? array_merge($users, explode(",", $_REQUEST['to'])) : $users;
     $valid_users = array();
     $draft_users = array();
     foreach ($users as $username) {
         $username = trim($username);
         if (!in_array($username, $draft_users) && $username != $request['user']->get('name') && $username != '') {
             $user = $request['dba']->getRow("SELECT * FROM " . K4USERS . " WHERE name = '" . $request['dba']->quote(k4_htmlentities($username, ENT_QUOTES)) . "'");
             if (is_array($user) && !empty($user)) {
                 if (get_map('pm_message', 'can_view', array()) <= $user['perms']) {
                     $valid_users[] = $user;
                     $draft_users[] = $user['name'];
                 }
             }
         }
     }
     if (!is_array($valid_users) || empty($valid_users)) {
         $action = new K4InformationAction(new K4LanguageElement('L_PMNOVALIDRECIEVERS'), 'usercp_content', TRUE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_PMNOVALIDRECIEVERS');
     }
     /**
      * Check over posting inputs
      */
     /* General error checking */
     if (!$this->runPostFilter('name', new FARequiredFilter())) {
         $action = new K4InformationAction(new K4LanguageElement('L_INSERTTOPICNAME'), 'usercp_content', TRUE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_INSERTPMSUBJECT');
     }
     if (!$this->runPostFilter('name', new FALengthFilter(intval($_SETTINGS['topicmaxchars'])))) {
         $action = new K4InformationAction(new K4LanguageElement('L_PMSUBJECTTOOSHORT', intval($_SETTINGS['topicminchars']), intval($_SETTINGS['topicmaxchars'])), 'usercp_content', TRUE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message(new K4LanguageElement('L_PMSUBJECTTOOSHORT', intval($_SETTINGS['topicminchars']), intval($_SETTINGS['topicmaxchars'])));
     }
     if (!$this->runPostFilter('name', new FALengthFilter(intval($_SETTINGS['topicmaxchars']), intval($_SETTINGS['topicminchars'])))) {
         $action = new K4InformationAction(new K4LanguageElement('L_PMSUBJECTTOOSHORT', intval($_SETTINGS['topicminchars']), intval($_SETTINGS['topicmaxchars'])), 'usercp_content', TRUE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message(new K4LanguageElement('L_PMSUBJECTTOOSHORT', intval($_SETTINGS['topicminchars']), intval($_SETTINGS['topicmaxchars'])));
     }
     if (!isset($_REQUEST['message']) || $_REQUEST['message'] == '') {
         $action = new K4InformationAction(new K4LanguageElement('L_INSERTPMMESSAGE'), 'usercp_content', TRUE);
         return !USE_XMLHTTP ? $action->execute($request) : xmlhttp_message('L_INSERTPMMESSAGE');
     }
     /* Set the message created time */
     $created = time();
     $_REQUEST['message'] = substr($_REQUEST['message'], 0, $_SETTINGS['pmmaxchars']);
     /* Initialize the bbcode parser with the topic message */
     /*$bbcode	= &new BBCodex($request['dba'], $request['user']->getInfoArray(), $_REQUEST['message'], 0, 
     		iif((isset($_REQUEST['disable_html']) && $_REQUEST['disable_html']), FALSE, TRUE), 
     		iif((isset($_REQUEST['disable_bbcode']) && $_REQUEST['disable_bbcode']), FALSE, TRUE), 
     		iif((isset($_REQUEST['disable_emoticons']) && $_REQUEST['disable_emoticons']), FALSE, TRUE), 
     		iif((isset($_REQUEST['disable_aurls']) && $_REQUEST['disable_aurls']), FALSE, TRUE));*/
     /* Parse the bbcode */
     $body_text = $_REQUEST['message'];
     if (!isset($_REQUEST['disable_bbcode']) || !$_REQUEST['disable_bbcode']) {
         $parser =& new BBParser();
         Globals::setGlobal('forum_id', 0);
         Globals::setGlobal('maxpolloptions', 0);
         $body_text = $parser->parse($body_text);
     }
     $parent_id = 0;
     $message_id = 0;
     /**
      * Was this message originally a draft?
      */
     $draft_loaded = FALSE;
     if (isset($_REQUEST['draft']) && intval($_REQUEST['draft']) > 0) {
         $draft = $request['dba']->getRow("SELECT * FROM " . K4PRIVMESSAGES . " WHERE pm_id = " . intval($_REQUEST['draft']) . " AND is_draft = 1");
         if (is_array($draft) && !empty($draft)) {
             $draft_loaded = TRUE;
         }
     }
     if (isset($_REQUEST['reply']) && intval($_REQUEST['reply']) > 0 || $draft_loaded && $draft['message_id'] > 0) {
         $post_id = isset($_REQUEST['reply']) ? $_REQUEST['reply'] : $draft['message_id'];
         $message = $request['dba']->getRow("SELECT * FROM " . K4PRIVMESSAGES . " WHERE pm_id = " . intval($post_id));
         if (is_array($message) && !empty($message)) {
             $parent_id = intval($message['pm_id']);
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:k4bb-svn,代码行数:101,代码来源:privmessages.class.php


注:本文中的Globals::setGlobal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。