/**
  * Stores post prefs for share links
  * 
  * @return	@e void		[Outputs JSON to browser AJAX call]
  */
 protected function _savePostPrefs()
 {
     IPSMember::setToMemberCache($this->memberData, array('postSocialPrefs' => array('facebook' => intval($_POST['facebook']), 'twitter' => intval($_POST['twitter']))));
     $this->returnJsonArray(array('status' => 'ok'));
 }
 /**
  * Resets a user(s) new message count
  *
  * @param	mixed		Either INT member ID or ARRAY of member IDs
  * @return 	boolean
  */
 public function resetMembersNewTopicCount($member)
 {
     //-----------------------------------------
     // Load members...
     //-----------------------------------------
     if (is_array($member)) {
         $members = IPSMember::load($member, 'extendedProfile');
     } else {
         $_member = IPSMember::load($member, 'extendedProfile');
         $members = array($_member['member_id'] => $_member);
     }
     //-----------------------------------------
     // Loop 'em
     //-----------------------------------------
     foreach ($members as $id => $data) {
         $count = intval($this->getPersonalTopicsCount($id, 'new'));
         $lastReset = intval(IPSMember::getFromMemberCache($data, 'msgAlertReset'));
         $msgAlertCount = intval($this->getPersonalTopicsCount($id, 'new', $lastReset));
         //-----------------------------------------
         // Parse folder data
         //-----------------------------------------
         $rebuild = $this->explodeFolderData($data['pconversation_filters']);
         $rebuild['new']['count'] = $count;
         $msg_show_notification = $count ? $data['msg_show_notification'] : 0;
         IPSMember::save($id, array('extendedProfile' => array('pconversation_filters' => $this->implodeFolderData($rebuild)), 'core' => array('msg_count_new' => $msgAlertCount, 'msg_show_notification' => $msg_show_notification)));
         IPSMember::setToMemberCache($data, array('msgAlertReset' => IPS_UNIX_TIME_NOW));
         /* Reset our counter */
         if ($id == $this->memberData['member_id']) {
             $this->memberData['msg_count_new'] = $msgAlertCount;
         }
     }
     return TRUE;
 }
Beispiel #3
0
 /**
  * View new posts since your last visit
  *
  * @return	@e void
  */
 public function viewNewContent()
 {
     IPSSearchRegistry::set('in.search_app', $this->request['search_app']);
     /* Fetch member cache to see if we have a value set */
     $vncPrefs = IPSMember::getFromMemberCache($this->memberData, 'vncPrefs');
     /* Guests */
     if (!$this->memberData['member_id'] and (!$this->request['period'] or $this->request['period'] == 'unread')) {
         $this->request['period'] = 'today';
     }
     /* In period */
     if ($vncPrefs === null or !isset($vncPrefs[IPSSearchRegistry::get('in.search_app')]['view']) or !empty($this->request['period']) and isset($this->request['change'])) {
         $vncPrefs[IPSSearchRegistry::get('in.search_app')]['view'] = !empty($this->request['period']) ? $this->request['period'] : $this->settings['default_vnc_method'];
     }
     /* Follow filter enabled */
     if ($vncPrefs === null or !isset($vncPrefs[IPSSearchRegistry::get('in.search_app')]['view']) or isset($this->request['followedItemsOnly'])) {
         $vncPrefs[IPSSearchRegistry::get('in.search_app')]['vncFollowFilter'] = !empty($this->request['followedItemsOnly']) ? 1 : 0;
     }
     /* User mode */
     if ($vncPrefs === null or !isset($vncPrefs[IPSSearchRegistry::get('in.search_app')]['view']) or isset($this->request['userMode'])) {
         $vncPrefs[IPSSearchRegistry::get('in.search_app')]['userMode'] = !empty($this->request['userMode']) ? $this->request['userMode'] : '';
     }
     /* Set filters up */
     IPSSearchRegistry::set('forums.vncForumFilters', $vncPrefs['forums']['vnc_forum_filter']);
     IPSSearchRegistry::set('in.period', $vncPrefs[IPSSearchRegistry::get('in.search_app')]['view']);
     IPSSearchRegistry::set('in.vncFollowFilterOn', $vncPrefs[IPSSearchRegistry::get('in.search_app')]['vncFollowFilter']);
     IPSSearchRegistry::set('in.userMode', $vncPrefs[IPSSearchRegistry::get('in.search_app')]['userMode']);
     /* Update member cache */
     if (isset($this->request['period']) and isset($this->request['change'])) {
         IPSMember::setToMemberCache($this->memberData, array('vncPrefs' => $vncPrefs));
     }
     IPSDebug::addMessage(var_export($vncPrefs, true));
     IPSDebug::addMessage('Using: ' . IPSSearchRegistry::get('in.period'));
     /* Can we do this? */
     if (IPSLib::appIsSearchable(IPSSearchRegistry::get('in.search_app'), 'vnc') || IPSLib::appIsSearchable(IPSSearchRegistry::get('in.search_app'), 'active')) {
         /* Can't do a specific unread search, so */
         if (IPSSearchRegistry::get('in.period') == 'unread' && !IPSLib::appIsSearchable(IPSSearchRegistry::get('in.search_app'), 'vncWithUnreadContent')) {
             IPSSearchRegistry::set('in.period', 'lastvisit');
         }
         /* Perform the search */
         $this->searchController->viewNewContent();
         /* Get count */
         $count = $this->searchController->getResultCount();
         /* Get results which will be array of IDs */
         $results = $this->searchController->getResultSet();
         /* Get templates to use */
         $template = $this->searchController->fetchTemplates();
         /* Fetch sort details */
         $sortDropDown = $this->searchController->fetchSortDropDown();
         /* Fetch sort details */
         $sortIn = $this->searchController->fetchSortIn();
         /* Reset for template */
         $this->_resetRequestParameters();
         if (IPSSearchRegistry::get('in.start') > 0 and !count($results)) {
             $new_url = 'app=core&module=search&do=viewNewContent&period=' . IPSSearchRegistry::get('in.period') . '&userMode=' . IPSSearchRegistry::get('in.userMode') . '&search_app=' . IPSSearchRegistry::get('in.search_app') . '&sid=' . $this->request['_sid'];
             $new_url .= '&st=' . (IPSSearchRegistry::get('in.start') - IPSSearchRegistry::get('opt.search_per_page')) . '&search_app_filters[' . IPSSearchRegistry::get('in.search_app') . '][searchInKey]=' . $this->request['search_app_filters'][IPSSearchRegistry::get('in.search_app')]['searchInKey'];
             $this->registry->output->silentRedirect($this->settings['base_url'] . $new_url);
         }
         /* Parse result set */
         $results = $this->registry->output->getTemplate($template['group'])->{$template}['template']($results, IPSSearchRegistry::get('opt.searchType') == 'titles' || IPSSearchRegistry::get('opt.noPostPreview') ? 1 : 0);
         /* Build pagination */
         $links = $this->registry->output->generatePagination(array('totalItems' => $count, 'itemsPerPage' => IPSSearchRegistry::get('opt.search_per_page'), 'currentStartValue' => IPSSearchRegistry::get('in.start'), 'baseUrl' => 'app=core&module=search&do=viewNewContent&period=' . IPSSearchRegistry::get('in.period') . '&userMode=' . IPSSearchRegistry::get('in.userMode') . '&search_app=' . IPSSearchRegistry::get('in.search_app') . '&sid=' . $this->request['_sid'] . $this->_returnSearchAppFilters()));
         /* Showing */
         $showing = array('start' => IPSSearchRegistry::get('in.start') + 1, 'end' => IPSSearchRegistry::get('in.start') + IPSSearchRegistry::get('opt.search_per_page') > $count ? $count : IPSSearchRegistry::get('in.start') + IPSSearchRegistry::get('opt.search_per_page'));
     } else {
         $count = 0;
         $results = array();
     }
     /* Add Debug message */
     IPSDebug::addMessage("View New Content Matches: " . $count);
     /* Check for sortIn */
     if (count($sortIn) && !$this->request['search_app_filters'][$this->request['search_app']]['searchInKey']) {
         $this->request['search_app_filters'][$this->request['search_app']]['searchInKey'] = $sortIn[0][0];
     }
     /* Output */
     $this->title = $this->lang->words['new_posts_title'];
     $this->registry->output->addNavigation($this->lang->words['new_posts_title'], '');
     $this->output .= $this->registry->output->getTemplate('search')->newContentView($results, $links, $count, $sortDropDown, $sortIn, IPSSearchRegistry::get('set.resultCutToDate'));
 }
Beispiel #4
0
 /**
  * Save the form to configure VNC forum filters
  *
  * @return	@e void
  */
 public function saveForm()
 {
     $vncPrefs = IPSMember::getFromMemberCache($this->memberData, 'vncPrefs');
     /* Filter forums for VNC */
     if (!empty($this->request['saveVncFilters'])) {
         $this->request['saveVncFilters'] = rtrim($this->request['saveVncFilters'], ',');
         if ($this->request['saveVncFilters'] == 'all') {
             unset($vncPrefs['forums']['vnc_forum_filter']);
         } else {
             if (strpos($this->request['saveVncFilters'], ',') !== false) {
                 $vncPrefs['forums']['vnc_forum_filter'] = explode(',', $this->request['saveVncFilters']);
             } else {
                 if (!empty($this->request['saveVncFilters'])) {
                     $vncPrefs['forums']['vnc_forum_filter'] = array($this->request['saveVncFilters']);
                 }
             }
         }
     }
     IPSMember::setToMemberCache($this->memberData, array('vncPrefs' => $vncPrefs));
     $this->returnJsonArray(array('ok' => true));
 }