示例#1
0
 function execute(&$request)
 {
     global $_QUERYPARAMS, $_USERGROUPS;
     k4_bread_crumbs($request['template'], $request['dba'], 'L_CALENDAR');
     # get the year month and day from request vars
     $year = isset($_REQUEST['y']) && intval($_REQUEST['y']) > 0 ? $_REQUEST['y'] : date('Y', time());
     $month = isset($_REQUEST['m']) && intval($_REQUEST['m']) > 0 ? $_REQUEST['m'] : date('n', time());
     $day = isset($_REQUEST['d']) && intval($_REQUEST['d']) > 0 ? $_REQUEST['j'] : 1;
     # new k4Calendar instance
     $c =& new K4Calendar($year, $month, $day);
     # The next and previous months, do this all first.
     $year = $month == 1 ? $year - 1 : $year;
     $html = $this->mini_month($c->getPrevMonth(), $year, $request);
     $request['template']->setVar('prev_month_cal', $html);
     $year = $month == 12 ? $year + 1 : $year;
     $html = $this->mini_month($c->getNextMonth(), $year, $request);
     $request['template']->setVar('next_month_cal', $html);
     # Get user birthdays
     $birthdays = $request['dba']->executeQuery("SELECT {$_QUERYPARAMS['user']}{$_QUERYPARAMS['userinfo']} FROM " . K4USERS . " u LEFT JOIN " . K4USERINFO . " ui ON u.id=ui.user_id WHERE ui.birthday LIKE '" . str_pad($month, 2, '0', STR_PAD_LEFT) . "/%'");
     $bdays = array();
     if ($birthdays->hasNext()) {
         while ($birthdays->next()) {
             $user = $birthdays->current();
             $parts = explode("/", $user['birthday']);
             $group = get_user_max_group($user, $_USERGROUPS);
             $user['group_color'] = !isset($group['color']) || $group['color'] == '' ? '000000' : $group['color'];
             $user['age'] = $year - intval($parts[2]);
             $user['U_MEMBERURL'] = K4Url::getMemberUrl($user['id']);
             $bdays[$parts[1]][] = $user;
         }
     }
     # Add the iterator to the template
     $c->month = $month;
     $c->year = $year;
     $iteration_c = new K4CalendarIterator($c->getData(), $c->getWeek($month, $day, $year), $bdays);
     $iteration_d = new FAArrayIterator($c->getWeekdays());
     //print_r($c->getWeekRange($month, $day, $year)); exit;
     $request['template']->setList('calendar', $iteration_c);
     $request['template']->setList('weekdays', $iteration_d);
     # url's, need fixing
     $request['template']->setVarArray(array('U_CALENDARPREVYEARURL' => K4Url::getGenUrl('calendar', 'y=' . $c->getPrevYear() . '&m=' . $c->getMonth()), 'U_CALENDARNEXTYEARURL' => K4Url::getGenUrl('calendar', 'y=' . $c->getNextYear() . '&m=' . $c->getMonth()), 'U_CALENDARPREVMONTHURL' => K4Url::getGenUrl('calendar', 'y=' . $c->getYear() . '&m=' . $c->getPrevMonth()), 'U_CALENDARNEXTMONTHURL' => K4Url::getGenUrl('calendar', 'y=' . $c->getYear() . '&m=' . $c->getNextMonth())));
     # The rest
     $request['template']->setVar('month_label', date('F', mktime(0, 0, 0, $c->getMonth(), 1, $c->getYear())));
     $request['template']->setVar('year_label', $c->getYear());
     $request['template']->setVar('month_next', $c->getNextMonth());
     $request['template']->setVar('month_prev', $c->getPrevMonth());
     $request['template']->setVar('year_next', $c->getNextYear());
     $request['template']->setVar('year_prev', $c->getPrevYear());
     $request['template']->setVar('nav_prev', $c->checkPrevYear());
     $request['template']->setVar('nav_next', $c->checkNextYear());
     $request['template']->setFile('content', 'calendar_index.html');
 }
 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;
     }
 }
 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;
     //	}
     //}
 }
 function current()
 {
     $temp = parent::current();
     $temp['posticon'] = @$temp['posticon'] != '' ? file_exists(BB_BASE_DIR . '/tmp/upload/posticons/' . @$temp['posticon']) ? @$temp['posticon'] : 'clear.gif' : 'clear.gif';
     $temp['post_id'] = 't' . $temp['post_id'];
     if ($temp['poster_id'] > 0) {
         $temp['post_display_user_ddmenu'] = 1;
         if (!isset($this->users[$temp['poster_id']])) {
             $user = $this->dba->getRow("SELECT " . $this->qp['user'] . $this->qp['userinfo'] . " FROM " . K4USERS . " u LEFT JOIN " . K4USERINFO . " ui ON u.id=ui.user_id WHERE u.id=" . intval($temp['poster_id']));
             if (is_array($user) && !empty($user)) {
                 $group = get_user_max_group($user, $this->groups);
                 $user['group_color'] = !isset($group['color']) || $group['color'] == '' ? '000000' : $group['color'];
                 $user['group_nicename'] = isset($group['nicename']) ? $group['nicename'] : '';
                 $user['group_avatar'] = isset($group['avatar']) ? $group['avatar'] : '';
                 $user['online'] = time() - ini_get('session.gc_maxlifetime') > $user['seen'] ? 'offline' : 'online';
                 $this->users[$user['id']] = $user;
             }
         } else {
             $user = $this->users[$temp['poster_id']];
         }
         if (is_array($user) && !empty($user)) {
             if ($user['flag_level'] > 0 && $_SESSION['user']->get('perms') >= MODERATOR) {
                 $temp['post_user_background'] = 'background-color: #FFFF00;';
             }
             foreach ($user as $key => $val) {
                 $temp['post_user_' . $key] = $val;
             }
             $temp['profilefields'] =& new FAArrayIterator(get_profile_fields($this->fields, $temp));
             $temp['post_user_title'] = $user['user_title'];
             $temp['post_user_user_title'] = get_user_title($user['user_title'], $user['num_posts']);
         }
         if (!isset($temp['post_user_online'])) {
             $temp['post_user_online'] = 'offline';
         }
         /* This array holds all of the userinfo for users that post to this topic */
         $this->users[$user['id']] = $user;
     } else {
         $temp['post_user_id'] = 0;
         $temp['post_user_name'] = $temp['poster_name'];
     }
     /* Deal with acronyms */
     replace_acronyms($temp['body_text']);
     /* word censors */
     replace_censors($temp['body_text']);
     replace_censors($temp['name']);
     /* Do any polls if they exist */
     do_post_polls($temp, $this->dba);
     /* do we have any attachments? */
     if (isset($temp['attachments']) && $temp['attachments'] > 0) {
         $temp['attachment_files'] = new K4AttachmentsIterator($this->dba, $this->user, $temp['post_id'], 0);
     }
     // url's
     $temp['U_TOPICURL'] = K4Url::getTopicUrl($temp['post_id']);
     $temp['U_POSTURL'] = K4Url::getPostUrl($temp['post_id']);
     $temp['U_MEMBERURL'] = K4Url::getMemberUrl($temp['poster_id']);
     if ($this->sr && $temp['num_replies'] > 0) {
         $this->result = $this->dba->executeQuery("SELECT * FROM " . K4POSTS . " WHERE parent_id = " . intval($temp['post_id']) . " AND row_type=" . REPLY . " " . ($this->post_id ? "AND post_id = " . $this->post_id : "") . " AND created >= " . 3600 * 24 * intval($temp['daysprune']) . " ORDER BY " . $temp['sortedby'] . " " . $temp['sortorder'] . " LIMIT " . intval($temp['start']) . "," . intval($temp['postsperpage']));
         $temp['replies'] = new RepliesIterator($this->user, $this->dba, $this->result, $this->qp, $this->users, $this->groups, $this->fields);
     }
     return $temp;
 }
 function current()
 {
     $temp = parent::current();
     $temp['posticon'] = isset($temp['posticon']) && @$temp['posticon'] != '' ? iif(file_exists(BB_BASE_DIR . '/tmp/upload/posticons/' . @$temp['posticon']), @$temp['posticon'], 'clear.gif') : 'clear.gif';
     $temp['post_id'] = 'r' . $temp['post_id'];
     if ($temp['poster_id'] > 0) {
         if (!isset($this->users[$temp['poster_id']])) {
             $temp['post_display_user_ddmenu'] = 1;
             // display a ddmenu
             $user = $this->dba->getRow("SELECT " . $this->qp['user'] . $this->qp['userinfo'] . " FROM " . K4USERS . " u LEFT JOIN " . K4USERINFO . " ui ON u.id=ui.user_id WHERE u.id=" . intval($temp['poster_id']));
             if (is_array($user) && !empty($user)) {
                 $group = get_user_max_group($user, $this->groups);
                 $user['group_color'] = !isset($group['color']) || $group['color'] == '' ? '000000' : $group['color'];
                 $user['group_nicename'] = $group['nicename'];
                 $user['group_avatar'] = $group['avatar'];
                 $user['online'] = time() - ini_get('session.gc_maxlifetime') > $user['seen'] ? 'offline' : 'online';
                 $this->users[$user['id']] = $user;
             }
         } else {
             $temp['post_display_user_ddmenu'] = $this->result->hasPrev() ? 0 : 1;
             // use a different ddmenu
             $user = $this->users[$temp['poster_id']];
         }
         if (is_array($user) && !empty($user)) {
             if ($user['flag_level'] > 0 && $_SESSION['user']->get('perms') >= MODERATOR) {
                 $temp['post_user_background'] = 'background-color: #FFFF00;';
             }
             foreach ($user as $key => $val) {
                 $temp['post_user_' . $key] = $val;
             }
             $temp['profilefields'] = new FAArrayIterator(get_profile_fields($this->fields, $temp));
             $temp['post_user_title'] = $user['user_title'];
             $temp['post_user_user_title'] = get_user_title($user['user_title'], $user['num_posts']);
         }
         if (!isset($temp['post_user_online'])) {
             $temp['post_user_online'] = 'offline';
         }
     } else {
         $temp['post_user_id'] = 0;
         $temp['post_user_name'] = $temp['poster_name'];
     }
     /* do we have any attachments? */
     if (isset($temp['attachments']) && $temp['attachments'] > 0) {
         $temp['attachment_files'] = new K4AttachmentsIterator($this->dba, $this->user, $temp['post_id'], $temp['post_id']);
     }
     /* Deal with acronyms */
     replace_acronyms($temp['body_text']);
     /* word censors!! */
     replace_censors($temp['body_text']);
     replace_censors($temp['name']);
     /* Do any polls if they exist */
     do_post_polls($temp, $this->dba);
     /* Should we free the result? */
     if (!$this->hasNext()) {
         $this->result->free();
     }
     return $temp;
 }
示例#6
0
 function current()
 {
     $temp = parent::current();
     $group = get_user_max_group($temp, $this->groups);
     $temp['group_color'] = !isset($group['color']) || $group['color'] == '' ? '000000' : $group['color'];
     $temp['group_nicename'] = $group['nicename'];
     $temp['group_avatar'] = $group['avatar'];
     $temp['font_weight'] = isset($group['min_perm']) && $group['min_perm'] > MEMBER ? 'bold' : 'normal';
     $temp['warn_color'] = get_warning_color($temp['warn_level']);
     // urls
     $temp['U_MEMBERURL'] = K4Url::getMemberUrl($temp['user_id']);
     if (!$this->hasNext()) {
         $this->result->free();
     }
     return $temp;
 }
 function &current()
 {
     $temp = parent::current();
     $temp['posticon'] = @$temp['posticon'] != '' ? iif(file_exists(FORUM_BASE_DIR . '/tmp/upload/posticons/' . @$temp['posticon']), @$temp['posticon'], 'clear.gif') : 'clear.gif';
     if ($temp['poster_id'] > 0) {
         if (!isset($this->users[$temp['poster_id']])) {
             $user = $this->dba->getRow("SELECT " . $this->qp['user'] . $this->qp['userinfo'] . " FROM " . USERS . " u LEFT JOIN " . USERINFO . " ui ON u.id=ui.user_id WHERE u.id=" . intval($temp['poster_id']));
             $group = get_user_max_group($user, $this->groups);
             $user['group_color'] = !isset($group['color']) || $group['color'] == '' ? '000000' : $group['color'];
             $user['group_nicename'] = $group['nicename'];
             $user['group_avatar'] = $group['avatar'];
             $this->users[$user['id']] = $user;
         } else {
             $user = $this->users[$temp['poster_id']];
         }
         foreach ($user as $key => $val) {
             $temp['post_user_' . $key] = $val;
         }
     }
     $bbcode =& new BBCodex($this->user, $temp['body_text'], $temp['forum_id'], TRUE, TRUE, TRUE, TRUE);
     $temp['reverted_body_text'] = $bbcode->revert();
     /* Should we free the result? */
     if ($this->row == $this->size - 1) {
         $this->result->freeResult();
     }
     return $temp;
 }
 function current()
 {
     $temp = parent::current();
     //		if($temp['post_id'] == 0) {
     $post = $this->dba->getRow("SELECT * FROM " . K4POSTS . " WHERE post_id = " . intval($temp['post_id']));
     if ($post['row_type'] & TOPIC) {
         $temp['topic_name'] = $post['name'];
         $temp['url'] = 'viewtopic.php?id=' . $topic['post_id'];
         $temp['topic_id'] = $post['post_id'];
         $this->topics[$temp['post_id']] = $post;
     } else {
         $temp['topic_name'] = !isset($this->topics[$post['parent_id']]) ? $this->dba->getValue("SELECT name FROM " . K4POSTS . " WHERE post_id = " . intval($post['parent_id'])) : $this->topics[$post['parent_id']]['name'];
         $this->topics[$post['parent_id']]['name'] = $temp['topic_name'];
         $temp['url'] = 'findpost.php?id=' . $post['post_id'];
         $temp['topic_id'] = $post['parent_id'];
     }
     $temp = array_merge($temp, $post);
     //		} else {
     //			$reply				= $this->dba->getRow("SELECT * FROM ". K4POSTS ." WHERE post_id = ". intval($temp['post_id']));
     //			$temp['post_id']	= $reply['post_id'];
     //			$temp['views']		= '--';
     //			$temp['url']		= 'findpost.php?id='. $reply['post_id'];
     //			$temp['topic_name'] = !isset($this->topics[$reply['post_id']]) ? $this->dba->getValue("SELECT name FROM ". K4POSTS ." WHERE post_id = ". intval($reply['post_id'])) : $this->topics[$reply['post_id']]['name'];
     //
     //			$temp				= array_merge($temp, $reply);
     //		}
     if ($temp['poster_id'] > 0) {
         $user = !isset($this->users[$temp['poster_id']]) ? $this->dba->getRow("SELECT " . $this->qp['user'] . $this->qp['userinfo'] . " FROM " . K4USERS . " u LEFT JOIN " . K4USERINFO . " ui ON u.id=ui.user_id WHERE u.id=" . intval($temp['poster_id'])) : $this->users[$temp['poster_id']];
         $group = get_user_max_group($user, $this->groups);
         $user['group_color'] = !isset($group['color']) || $group['color'] == '' ? '000000' : $group['color'];
         $user['group_nicename'] = $group['nicename'];
         $user['group_avatar'] = $group['avatar'];
         $user['online'] = time() - ini_get('session.gc_maxlifetime') > $user['seen'] ? 'offline' : 'online';
         foreach ($user as $key => $val) {
             $temp['poster_' . $key] = $val;
         }
         $this->users[$temp['poster_id']] = $user;
     }
     $temp['body_text'] = isset($temp['body_text']) ? preg_replace("~<!--(.+?)-->~is", "", $temp['body_text']) : '';
     $temp['forum_name'] = isset($this->forums['f' . $temp['forum_id']]) ? $this->forums['f' . $temp['forum_id']]['name'] : '';
     /* Should we free the result? */
     if (!$this->hasNext()) {
         $this->result->free();
     }
     return $temp;
 }
示例#9
0
 function current()
 {
     $temp = parent::current();
     /* Set the topic icons */
     //$temp['posticon']		= $temp['posticon'] != '' ? iif(file_exists(BB_BASE_DIR .'/tmp/upload/posticons/'. $temp['posticon']), $temp['posticon'], 'clear.gif') : 'clear.gif';
     //$temp['topicicon']		= topic_image($temp, $this->user, $this->img_dir, $last_seen);
     if ($temp['row_type'] == TOPIC) {
         $temp['topic_name'] = $temp['name'];
         $temp['url'] = 'viewtopic.php?id=' . $temp['post_id'];
         $this->topic_names[$temp['post_id']] = $temp['name'];
     } else {
         $temp['views'] = '--';
         $temp['url'] = 'findpost.php?id=' . $temp['post_id'];
         $temp['topic_name'] = !isset($this->topic_names[$temp['post_id']]) ? $this->dba->getValue("SELECT name FROM " . K4POSTS . " WHERE post_id = " . intval($temp['post_id'])) : $this->topic_names[$temp['post_id']];
         $this->topic_names[$temp['post_id']] = $temp['topic_name'];
     }
     if ($temp['poster_id'] > 0) {
         $user = !isset($this->users[$temp['poster_id']]) ? $this->dba->getRow("SELECT " . $this->qp['user'] . $this->qp['userinfo'] . " FROM " . K4USERS . " u LEFT JOIN " . K4USERINFO . " ui ON u.id=ui.user_id WHERE u.id=" . intval($temp['poster_id'])) : $this->users[$temp['poster_id']];
         $group = get_user_max_group($user, $this->groups);
         $user['group_color'] = !isset($group['color']) || $group['color'] == '' ? '000000' : $group['color'];
         $user['group_nicename'] = $group['nicename'];
         $user['group_avatar'] = $group['avatar'];
         $user['online'] = time() - ini_get('session.gc_maxlifetime') > $user['seen'] ? 'offline' : 'online';
         foreach ($user as $key => $val) {
             $temp['poster_' . $key] = $val;
         }
         $this->users[$temp['poster_id']] = $user;
     }
     $temp['body_text'] = preg_replace("~<!--(.+?)-->~is", "", $temp['body_text']);
     $temp['forum_name'] = isset($this->forums[$temp['forum_id']]['name']) ? $this->forums[$temp['forum_id']]['name'] : '--';
     $temp['number'] = $this->increment;
     /* Should we free the result? */
     if (!$this->hasNext()) {
         $this->result->free();
     }
     $this->increment++;
     return $temp;
 }
 function current()
 {
     $temp = parent::current();
     //if( ($temp['folder_id'] == PM_SENTITEMS && $temp['member_id'] != $this->user->get('id')) || ($temp['member_id'] == $this->user->get('id')) ) {
     $temp['posticon'] = isset($temp['posticon']) && @$temp['posticon'] != '' ? iif(file_exists(BB_BASE_DIR . '/tmp/upload/posticons/' . @$temp['posticon']), @$temp['posticon'], 'clear.gif') : 'clear.gif';
     if ($temp['poster_id'] > 0) {
         if (!isset($this->users[$temp['poster_id']])) {
             $user = $this->dba->getRow("SELECT " . $this->qp['user'] . $this->qp['userinfo'] . " FROM " . K4USERS . " u LEFT JOIN " . K4USERINFO . " ui ON u.id=ui.user_id WHERE u.id=" . intval($temp['poster_id']));
             if (is_array($user) && !empty($user)) {
                 $group = get_user_max_group($user, $this->groups);
                 $user['group_color'] = !isset($group['color']) || $group['color'] == '' ? '000000' : $group['color'];
                 $user['group_nicename'] = $group['nicename'];
                 $user['group_avatar'] = $group['avatar'];
                 $user['online'] = time() - ini_get('session.gc_maxlifetime') > $user['seen'] ? 'offline' : 'online';
                 $this->users[$user['id']] = $user;
             }
         } else {
             $user = $this->users[$temp['poster_id']];
         }
         if (is_array($user) && !empty($user)) {
             if ($user['flag_level'] > 0 && $_SESSION['user']->get('perms') >= MODERATOR) {
                 $temp['post_user_background'] = 'background-color: #FFFF00;';
             }
             foreach ($user as $key => $val) {
                 $temp['post_user_' . $key] = $val;
             }
             $temp['profilefields'] =& new FAArrayIterator(get_profile_fields($this->fields, $temp));
         }
         if (!isset($temp['post_user_online'])) {
             $temp['post_user_online'] = 'offline';
         }
     } else {
         $temp['post_user_id'] = 0;
         $temp['post_user_name'] = $temp['poster_name'];
     }
     //		/* do we have any attachments? */
     //		if(isset($temp['attachments']) && $temp['attachments'] > 0) {
     //			$temp['attachment_files']		= &new K4AttachmentsIterator($this->dba, $this->user, $temp['post_id'], $temp['post_id']);
     //		}
     if ($temp['member_has_read'] == 0) {
         $this->dba->executeUpdate("UPDATE " . K4USERS . " SET new_pms=new_pms-1 WHERE id = " . intval($_SESSION['user']->get('id')));
         $this->dba->executeUpdate("UPDATE " . K4PRIVMESSAGES . " SET member_has_read = 1 WHERE pm_id = " . intval($temp['pm_id']));
     }
     /* Deal with acronyms */
     replace_acronyms($temp['body_text']);
     /* word censors!! */
     replace_censors($temp['body_text']);
     replace_censors($temp['name']);
     /* Should we free the result? */
     if (!$this->hasNext()) {
         $this->result->free();
     }
     return $temp;
     //}
 }
示例#11
0
 function Execute(&$template, $request, &$dba, &$session, &$user)
 {
     global $_USERGROUPS, $_QUERYPARAMS, $_URL;
     /**
      * Are we looking at the list of user groups?
      */
     if (!isset($request['id']) || intval($request['id']) == 0) {
         $groups = isset($user['usergroups']) && $user['usergroups'] != '' ? iif(!unserialize($user['usergroups']), force_usergroups($user), unserialize($user['usergroups'])) : array();
         $query = "SELECT * FROM " . USERGROUPS . " WHERE display_legend = 1";
         if ($user['perms'] < ADMIN) {
             foreach ($groups as $id) {
                 if (isset($_USERGROUPS[$id])) {
                     $query .= ' OR id = ' . intval($id);
                 }
             }
         } else {
             $query = "SELECT * FROM " . USERGROUPS;
         }
         $groups = $dba->executeQuery($query);
         $template->setList('usergroups', $groups);
         $template = BreadCrumbs($template, $template->getVar('L_USERGROUPS'));
         $template->setFile('content', 'usergroups.html');
         /**
          * Are we looking at a specific user group?
          */
     } else {
         /* Is this user group set? */
         if (!isset($_USERGROUPS[intval($request['id'])])) {
             $template = BreadCrumbs($template, $template->getVar('L_INFORMATION'));
             $template->setInfo('content', $template->getVar('L_GROUPDOESNTEXIST'));
         }
         $group = $_USERGROUPS[intval($request['id'])];
         /**
          * If the group admin has yet to be set, set it to our administrator
          */
         if ($group['mod_name'] == '' || $group['mod_id'] == 0) {
             /* Get our administrator */
             $admin = $dba->getRow("SELECT * FROM " . USERS . " WHERE perms >= " . intval(ADMIN) . " ORDER BY perms,id ASC LIMIT 1");
             $dba->executeUpdate("UPDATE " . USERGROUPS . " SET mod_name = '" . $dba->quote($admin['name']) . "', mod_id = " . intval($admin['id']) . " WHERE id = " . intval($group['id']));
             /* Change the file modification time of our cache file */
             if (!@touch(CACHE_FILE, time() - 86460)) {
                 @unlink(CACHE_FILE);
             }
             /* Add this info to the group array so that we can access it later */
             $group['mod_name'] = $admin['name'];
             $group['mod_id'] = $admin['id'];
         }
         /* Get our admins max user group.. it _should_ be the administrators group */
         $g = get_user_max_group($dba->getRow("SELECT " . $_QUERYPARAMS['user'] . $_QUERYPARAMS['userinfo'] . " FROM " . USERS . " u LEFT JOIN " . USERINFO . " ui ON u.id=ui.user_id WHERE u.id = " . intval($group['mod_id'])), $_USERGROUPS);
         /* Set his group's color */
         $group['mod_color'] = !isset($g['color']) || $g['color'] == '' ? '000000' : $g['color'];
         /* Add this group's info to the database */
         foreach ($group as $key => $val) {
             $template->setVar('group_' . $key, $val);
         }
         /* Create the Pagination */
         $resultsperpage = 10;
         $num_results = $dba->getValue("SELECT COUNT(*) FROM " . USERS . " WHERE usergroups LIKE '%;i:" . intval($group['id']) . ";%' AND id <> " . intval($group['mod_id']));
         $perpage = isset($request['limit']) && ctype_digit($request['limit']) && intval($request['limit']) > 0 ? intval($request['limit']) : $resultsperpage;
         $num_pages = ceil($num_results / $perpage);
         $page = isset($request['page']) && ctype_digit($request['page']) && intval($request['page']) > 0 ? intval($request['page']) : 1;
         $pager =& new TPL_Paginator($_URL, $num_results, $page, $perpage);
         if ($num_results > $perpage) {
             $template->setPager('users_pager', $pager);
         }
         /* Outside valid page range, redirect */
         if (!$pager->hasPage($page) && $num_results > $resultsperpage) {
             $template->setInfo('content', $template->getVar('L_PASTPAGELIMIT'));
             $template->setRedirect('usergroups.php?id=' . $group['id'] . '&limit=' . $perpage . '&page=' . $num_pages, 3);
         }
         /* Get the members for this usergroup */
         $start = ($page - 1) * $perpage;
         /* Get the members of this usergroup */
         $result =& $dba->executeQuery("SELECT " . $_QUERYPARAMS['user'] . $_QUERYPARAMS['userinfo'] . " FROM " . USERS . " u LEFT JOIN " . USERINFO . " ui ON u.id=ui.user_id WHERE u.usergroups LIKE '%;i:" . intval($group['id']) . ";%' AND u.id <> " . intval($group['mod_id']) . " LIMIT " . intval($start) . ", " . intval($perpage));
         $users =& new UsersIterator($result);
         $template->setVar('num_group_members', $num_results);
         if ($user['id'] == $group['mod_id']) {
             $template->show('add_user');
         }
         $template = BreadCrumbs($template, $group['name']);
         $template->setList('users_in_usergroup', $users);
         $template->setFile('content', 'lookup_usergroup.html');
     }
     return TRUE;
 }
 function execute(&$request)
 {
     global $_USERGROUPS, $_QUERYPARAMS;
     if (!isset($_REQUEST['id']) || intval($_REQUEST['id']) == 0) {
         k4_bread_crumbs($request['template'], $request['dba'], 'L_INFORMATION');
         $action = new K4InformationAction(new K4LanguageElement('L_GROUPDOESNTEXIST'), 'content', FALSE);
         return $action->execute($request);
     }
     if (!isset($_USERGROUPS[intval($_REQUEST['id'])])) {
         k4_bread_crumbs($request['template'], $request['dba'], 'L_INFORMATION');
         $action = new K4InformationAction(new K4LanguageElement('L_GROUPDOESNTEXIST'), 'content', FALSE);
         return $action->execute($request);
     }
     if (!isset($_REQUEST['user_id']) || intval($_REQUEST['user_id']) == 0) {
         /* set the breadcrumbs bit */
         k4_bread_crumbs($request['template'], $request['dba'], 'L_INFORMATION');
         $action = new K4InformationAction(new K4LanguageElement('L_USERDOESNTEXIST'), 'content', TRUE);
         return $action->execute($request);
         return TRUE;
     }
     $group = $_USERGROUPS[intval($_REQUEST['id'])];
     $member = $request['dba']->getRow("SELECT " . $_QUERYPARAMS['user'] . $_QUERYPARAMS['userinfo'] . " FROM " . K4USERS . " u LEFT JOIN " . K4USERINFO . " ui ON u.id=ui.user_id WHERE u.id = '" . intval($_REQUEST['user_id']) . "'");
     if (!$member || !is_array($member) || empty($member)) {
         /* set the breadcrumbs bit */
         k4_bread_crumbs($request['template'], $request['dba'], 'L_INFORMATION');
         $action = new K4InformationAction(new K4LanguageElement('L_USERDOESNTEXIST'), 'content', TRUE);
         return $action->execute($request);
     }
     /* Should we set the group moderator? */
     if ($group['mod_name'] == '' || $group['mod_id'] == 0) {
         $admin = $request['dba']->getRow("SELECT * FROM " . K4USERS . " WHERE perms >= " . intval(ADMIN) . " ORDER BY perms,id ASC LIMIT 1");
         $request['dba']->executeUpdate("UPDATE " . K4USERGROUPS . " SET mod_name = '" . $request['dba']->quote($admin['name']) . "', mod_id = " . intval($admin['id']) . " WHERE id = " . intval($group['id']));
         reset_cache('usergroups');
         $group['mod_name'] = $admin['name'];
         $group['mod_id'] = $admin['id'];
     }
     if ($group['mod_id'] == $member['id']) {
         /* set the breadcrumbs bit */
         k4_bread_crumbs($request['template'], $request['dba'], 'L_INFORMATION');
         $action = new K4InformationAction(new K4LanguageElement('L_YOUAREMODERATOR'), 'content', TRUE);
         return $action->execute($request);
     }
     $result = explode('|', trim($member['usergroups'], '|'));
     $groups = $member['usergroups'] != '' ? iif(!$result, force_usergroups($member), $result) : array();
     $groups = array_values($groups);
     $in_group = FALSE;
     $i = 0;
     foreach ($groups as $id) {
         if (isset($_USERGROUPS[$id]) && $id == $group['id']) {
             $in_group = TRUE;
             // remove the person from the user group
             unset($groups[$i]);
         }
         $i++;
     }
     $groups = array_values($groups);
     if (!$in_group) {
         /* set the breadcrumbs bit */
         k4_bread_crumbs($request['template'], $request['dba'], 'L_INFORMATION');
         $action = new K4InformationAction(new K4LanguageElement('L_NOTBELONGSTOGROUP'), 'content', TRUE);
         return $action->execute($request);
     }
     $newgroup = get_user_max_group(array('usergroups' => '|' . implode('|', $groups) . '|'), $_USERGROUPS);
     $perms = 5;
     if (isset($newgroup['max_perms'])) {
         if ($request['user']->get('perms') > $newgroup['max_perms']) {
             $perms = $newgroup['max_perms'];
         } else {
             if ($request['user']->get('perms') < $newgroup['min_perms']) {
                 $perms = $newgroup['min_perms'];
             }
         }
     }
     /* Add this user to the group and change his perms if we need to */
     $request['dba']->executeUpdate("UPDATE " . K4USERS . " SET usergroups='" . $request['dba']->quote('|' . implode('|', $groups) . '|') . "', perms=" . intval($perms) . " WHERE id = " . intval($member['id']));
     k4_bread_crumbs($request['template'], $request['dba'], 'L_REMOVEUSER');
     $action = new K4InformationAction(new K4LanguageElement('L_REMOVEDUSERFROMGROUP', $member['name'], $group['name']), 'content', FALSE, 'usergroups.php?id=' . intval($group['id']), 3);
     return $action->execute($request);
     return TRUE;
 }
 function current()
 {
     $temp = parent::current();
     $temp['posticon'] = isset($temp['posticon']) && $temp['posticon'] != '' ? file_exists(BB_BASE_DIR . '/tmp/upload/posticons/' . $temp['posticon']) ? $temp['posticon'] : 'clear.gif' : 'clear.gif';
     if ($temp['poster_id'] > 0) {
         if (!isset($this->users[$temp['poster_id']])) {
             $user = $this->dba->getRow("SELECT " . $this->qp['user'] . $this->qp['userinfo'] . " FROM " . K4USERS . " u LEFT JOIN " . K4USERINFO . " ui ON u.id=ui.user_id WHERE u.id=" . intval($temp['poster_id']));
             $group = get_user_max_group($user, $this->groups);
             $user['group_color'] = !isset($group['color']) || $group['color'] == '' ? '000000' : $group['color'];
             $user['group_nicename'] = $group['nicename'];
             $user['group_avatar'] = $group['avatar'];
             $this->users[$user['id']] = $user;
         } else {
             $user = $this->users[$temp['poster_id']];
         }
         foreach ($user as $key => $val) {
             $temp['post_user_' . $key] = $val;
         }
     }
     $temp['reverted_body_text'] = $this->bbcode->revert($temp['body_text']);
     if ($temp['is_poll'] == 1) {
         $temp['reverted_body_text'] = do_post_poll_urls($temp['reverted_body_text'], $this->dba, $this->url, $this->poll_text);
     }
     do_post_polls($temp, $this->dba, $this->url, $this->poll_text);
     return $temp;
 }
示例#14
0
 function execute(&$request)
 {
     global $_USERGROUPS, $_QUERYPARAMS, $_URL;
     /**
      * Are we looking at the list of user groups?
      */
     if (!isset($_REQUEST['id']) || intval($_REQUEST['id']) == 0) {
         $result = explode('|', $request['user']->get('usergroups'));
         $groups = $request['user']->get('usergroups') && $request['user']->get('usergroups') != '' ? iif(!$result, force_usergroups($request['user']->getInfoArray()), $result) : array();
         $query = "SELECT * FROM " . K4USERGROUPS . " WHERE display_legend = 1";
         if ($request['user']->get('perms') < ADMIN) {
             foreach ($groups as $id) {
                 if (isset($_USERGROUPS[$id])) {
                     $query .= ' OR id = ' . intval($id);
                 }
             }
         } else {
             $query = "SELECT * FROM " . K4USERGROUPS;
         }
         $groups = $request['dba']->executeQuery($query);
         $request['template']->setList('usergroups', $groups);
         k4_bread_crumbs($request['template'], $request['dba'], 'L_USERGROUPS');
         $request['template']->setFile('content', 'usergroups.html');
         /**
          * Are we looking at a specific user group?
          */
     } else {
         /* Is this user group set? */
         if (!isset($_USERGROUPS[intval($_REQUEST['id'])])) {
             k4_bread_crumbs($request['template'], $request['dba'], 'L_INFORMATION');
             $action = new K4InformationAction(new K4LanguageElement('L_GROUPDOESNTEXIST'), 'content', FALSE);
             return $action->execute($request);
         }
         $group = $_USERGROUPS[intval($_REQUEST['id'])];
         /**
          * If the group admin has yet to be set, set it to our administrator
          */
         if ($group['mod_name'] == '' || $group['mod_id'] == 0) {
             /* Get our administrator */
             $admin = $request['dba']->getRow("SELECT * FROM " . K4USERS . " WHERE perms >= " . intval(ADMIN) . " ORDER BY perms,id ASC LIMIT 1");
             $request['dba']->executeUpdate("UPDATE " . K4USERGROUPS . " SET mod_name = '" . $request['dba']->quote($admin['name']) . "', mod_id = " . intval($admin['id']) . " WHERE id = " . intval($group['id']));
             reset_cache('usergroups');
             /* Add this info to the group array so that we can access it later */
             $group['mod_name'] = $admin['name'];
             $group['mod_id'] = $admin['id'];
         }
         /* Get our admins max user group.. it _should_ be the administrators group */
         $g = get_user_max_group($request['dba']->getRow("SELECT " . $_QUERYPARAMS['user'] . $_QUERYPARAMS['userinfo'] . " FROM " . K4USERS . " u LEFT JOIN " . K4USERINFO . " ui ON u.id=ui.user_id WHERE u.id = " . intval($group['mod_id'])), $_USERGROUPS);
         /* Set his group's color */
         $group['mod_color'] = !isset($g['color']) || $g['color'] == '' ? '000000' : $g['color'];
         /* Add this group's info to the database */
         foreach ($group as $key => $val) {
             $request['template']->setVar('group_' . $key, $val);
         }
         /* Create the Pagination */
         $resultsperpage = 10;
         $num_results = $request['dba']->getValue("SELECT COUNT(*) FROM " . K4USERS . " WHERE usergroups LIKE '%|" . intval($group['id']) . "|%' AND id <> " . intval($group['mod_id']));
         $perpage = isset($_REQUEST['limit']) && ctype_digit($_REQUEST['limit']) && intval($_REQUEST['limit']) > 0 ? intval($_REQUEST['limit']) : $resultsperpage;
         $num_pages = ceil($num_results / $perpage);
         $page = isset($_REQUEST['page']) && ctype_digit($_REQUEST['page']) && intval($_REQUEST['page']) > 0 ? intval($_REQUEST['page']) : 1;
         $pager =& new FAPaginator($_URL, $num_results, $page, $perpage);
         if ($num_results > $perpage) {
             $request['template']->setPager('users_pager', $pager);
             /* Create a friendly url for our pager jump */
             $page_jumper = new FAUrl($_URL->__toString());
             $page_jumper->args['limit'] = $perpage;
             $page_jumper->args['page'] = FALSE;
             $page_jumper->anchor = FALSE;
             $request['template']->setVar('pagejumper_url', preg_replace('~&amp;~i', '&', $page_jumper->__toString()));
         }
         /* Outside valid page range, redirect */
         if (!$pager->hasPage($page) && $num_pages > 0) {
             $action = new K4InformationAction(new K4LanguageElement('L_PASTPAGELIMIT'), 'content', FALSE, 'usergroups.php?id=' . $group['id'] . '&limit=' . $perpage . '&page=' . $num_pages, 3);
             return $action->execute($request);
         }
         /* Get the members for this usergroup */
         $start = ($page - 1) * $perpage;
         /* Get the members of this usergroup */
         if ($num_results > 0) {
             $result = $request['dba']->executeQuery("SELECT " . $_QUERYPARAMS['user'] . $_QUERYPARAMS['userinfo'] . " FROM " . K4USERS . " u LEFT JOIN " . K4USERINFO . " ui ON u.id=ui.user_id WHERE u.usergroups LIKE '%|" . intval($group['id']) . "|%' AND u.id <> " . intval($group['mod_id']) . " LIMIT " . intval($start) . ", " . intval($perpage));
             $users =& new UsersIterator($result);
             $request['template']->setList('users_in_usergroup', $users);
         }
         $request['template']->setVar('num_group_members', $num_results);
         if ($request['user']->get('id') == $group['mod_id']) {
             $request['template']->setVisibility('add_user', TRUE);
             $request['template']->setVar('is_mod', 1);
         }
         k4_bread_crumbs($request['template'], $request['dba'], $group['name']);
         $request['template']->setFile('content', 'lookup_usergroup.html');
     }
     return TRUE;
 }
示例#15
0
 function &current()
 {
     $temp = parent::current();
     $temp['posticon'] = @$temp['posticon'] != '' ? iif(file_exists(FORUM_BASE_DIR . '/tmp/upload/posticons/' . @$temp['posticon']), @$temp['posticon'], 'clear.gif') : 'clear.gif';
     if ($temp['poster_id'] > 0) {
         $user = $this->dba->getRow("SELECT " . $this->qp['user'] . $this->qp['userinfo'] . " FROM " . USERS . " u LEFT JOIN " . USERINFO . " ui ON u.id=ui.user_id WHERE u.id=" . intval($temp['poster_id']));
         $group = get_user_max_group($user, $this->groups);
         $user['group_color'] = !isset($group['color']) || $group['color'] == '' ? '000000' : $group['color'];
         $user['group_nicename'] = $group['nicename'];
         $user['group_avatar'] = $group['avatar'];
         $user['online'] = time() - ini_get('session.gc_maxlifetime') > $user['seen'] ? 'offline' : 'online';
         foreach ($user as $key => $val) {
             $temp['post_user_' . $key] = $val;
         }
         $fields = array();
         foreach ($this->fields as $field) {
             if ($field['display_topic'] == 1) {
                 if (isset($temp['post_user_' . $field['name']]) && $temp['post_user_' . $field['name']] != '') {
                     switch ($field['inputtype']) {
                         default:
                         case 'text':
                         case 'textarea':
                         case 'select':
                             $field['value'] = $temp['post_user_' . $field['name']];
                             break;
                         case 'multiselect':
                         case 'radio':
                         case 'check':
                             $field['value'] = implode(", ", iif(!unserialize($temp['post_user_' . $field['name']]), array(), unserialize($temp['post_user_' . $field['name']])));
                             break;
                     }
                     $fields[] = $field;
                 }
             }
         }
         $temp['profilefields'] =& new FAArrayIterator($fields);
         /* This array holds all of the userinfo for users that post to this topic */
         $this->users[$user['id']] = $user;
     }
     /* Do we have any replies? */
     $num_replies = @(($temp['row_right'] - $temp['row_left'] - 1) / 2);
     if ($this->sr && $num_replies > 0) {
         $this->result =& $this->dba->executeQuery("SELECT " . $this->qp['info'] . $this->qp['reply'] . " FROM " . REPLIES . " r LEFT JOIN " . INFO . " i ON i.id=r.reply_id WHERE r.topic_id = " . intval($temp['id']) . " AND i.created >= " . 3600 * 24 * intval($temp['daysprune']) . " ORDER BY i." . $temp['sortedby'] . " " . $temp['sortorder'] . " LIMIT " . intval($temp['start']) . ", " . intval($temp['postsperpage']));
         $temp['replies'] =& new RepliesIterator($this->result, $this->qp, $this->dba, $this->users, $this->groups, $this->fields);
     }
     return $temp;
 }
示例#16
0
 function &current()
 {
     $temp = parent::current();
     $group = get_user_max_group($temp, $this->groups);
     $temp['group_color'] = !isset($group['color']) || $group['color'] == '' ? '000000' : $group['color'];
     $temp['group_nicename'] = $group['nicename'];
     $temp['group_avatar'] = $group['avatar'];
     return $temp;
 }
示例#17
0
 function current()
 {
     $temp = parent::current();
     $group = get_user_max_group($temp, $this->groups);
     $temp['group_color'] = !isset($group['color']) || $group['color'] == '' ? '000000' : $group['color'];
     $temp['group_nicename'] = $group['nicename'];
     $temp['group_avatar'] = $group['avatar'];
     $temp['online'] = time() - ini_get('session.gc_maxlifetime') > $temp['seen'] ? 'offline' : 'online';
     // custom url's
     $temp['U_MEMBERURL'] = K4Url::getMemberUrl($temp['user_id']);
     /* Should we free the result? */
     if (!$this->hasNext()) {
         $this->result->free();
     }
     return $temp;
 }
示例#18
0
 function Execute(&$template, $request, &$dba, &$session, &$user)
 {
     global $_QUERYPARAMS, $_DATASTORE, $_USERGROUPS, $_USERFIELDS;
     /**
      * Error checking on this member
      */
     if (!isset($request['id']) || intval($request['id']) == 0) {
         /* set the breadcrumbs bit */
         $template = BreadCrumbs($template, $template->getVar('L_INFORMATION'));
         $template->setInfo('content', $template->getVar('L_USERDOESNTEXIST'), TRUE);
         return TRUE;
     }
     $member = $dba->getRow("SELECT " . $_QUERYPARAMS['user'] . $_QUERYPARAMS['userinfo'] . " FROM " . USERS . " u LEFT JOIN " . USERINFO . " ui ON u.id = ui.user_id WHERE u.id = " . intval($request['id']));
     if (!$member || !is_array($member) || empty($member)) {
         /* set the breadcrumbs bit */
         $template = BreadCrumbs($template, $template->getVar('L_INFORMATION'));
         $template->setInfo('content', $template->getVar('L_USERDOESNTEXIST'), TRUE);
         return TRUE;
     }
     $member['num_topics'] = $dba->getValue("SELECT COUNT(*) FROM " . TOPICS . " WHERE poster_id = " . intval($member['id']));
     $member['num_replies'] = $dba->getValue("SELECT COUNT(*) FROM " . REPLIES . " WHERE poster_id = " . intval($member['id']));
     /**
      * Get and set some user/forum statistics
      */
     $user_created = time() - iif($member['created'] != 0, $member['created'], time());
     $postsperday = $user_created != 0 ? round($member['num_posts'] / ($user_created / 86400), 3) : 0;
     $member['posts_per_day'] = sprintf($template->getVar('L_POSTSPERDAY'), $postsperday);
     $num_posts = $_DATASTORE['forumstats']['num_topics'] + $_DATASTORE['forumstats']['num_replies'];
     $member['posts_percent'] = $num_posts != 0 && $member['num_posts'] != 0 ? sprintf($template->getVar('L_OFTOTALPOSTS'), round($member['num_posts'] / $num_posts * 100, 3) . '%') : sprintf($template->getVar('L_OFTOTALPOSTS'), '0%');
     $group = get_user_max_group($member, $_USERGROUPS);
     $member['group_color'] = !isset($group['color']) || $group['color'] == '' ? '000000' : $group['color'];
     $member['online'] = time() - ini_get('session.gc_maxlifetime') > $member['seen'] ? 'offline' : 'online';
     $groups = $member['usergroups'] != '' ? iif(!unserialize($member['usergroups']), force_usergroups($member), unserialize($member['usergroups'])) : array();
     /**
      * Get and set the user groups for this member
      */
     $usergroups = array();
     foreach ($groups as $id) {
         if (isset($_USERGROUPS[$id]) && is_array($_USERGROUPS[$id]) && !empty($_USERGROUPS[$id])) {
             $usergroups[] = $_USERGROUPS[$id];
         }
     }
     $template->setList('member_usergroups', new FAArrayIterator($usergroups));
     foreach ($member as $key => $val) {
         $template->setVar('member_' . $key, $val);
     }
     /**
      * Get the custom user fields for this member
      */
     $fields = array();
     foreach ($_USERFIELDS as $field) {
         if ($field['display_profile'] == 1) {
             if (isset($member[$field['name']]) && $member[$field['name']] != '') {
                 switch ($field['inputtype']) {
                     default:
                     case 'text':
                     case 'textarea':
                     case 'select':
                         $field['value'] = $member[$field['name']];
                         break;
                     case 'multiselect':
                     case 'radio':
                     case 'check':
                         $field['value'] = implode(", ", iif(!unserialize($member[$field['name']]), array(), unserialize($member[$field['name']])));
                         break;
                 }
                 $fields[] = $field;
             }
         }
     }
     if (count($fields) > 0) {
         if ($fields % 2 == 1) {
             $fields[count($fields) - 1]['colspan'] = 2;
         }
         $template->setList('member_profilefields', new FAArrayIterator($fields));
     }
     /**
      * Set the info we need
      */
     $template = BreadCrumbs($template, $template->getVar('L_USERPROFILE'));
     $template->setFile('content', 'member_profile.html');
     return TRUE;
 }