/** * Empties a folder * * @access private * @return string JSON either error or status * @since IPB 3.0.0.2008-06-25 */ private function _emptyFolder() { //----------------------------------------- // INIT //----------------------------------------- $folderID = IPSText::alphanumericalClean($this->request['folderID']); $memberID = intval($this->request['memberID']); $memberData = IPSMember::load($memberID, 'extendedProfile'); $status = 'ok'; $mtids = array(); //----------------------------------------- // Check //----------------------------------------- if (!$memberData['member_id'] or !$folderID) { $this->returnJsonError('noSuchFolder'); } //----------------------------------------- // First off, get dir data //----------------------------------------- $folders = $this->messengerFunctions->explodeFolderData($memberData['pconversation_filters']); //----------------------------------------- // "New" folder? //----------------------------------------- if ($folderID == 'new') { /* Just mark them as read */ $this->DB->update('message_topic_user_map', array('map_has_unread' => 0), 'map_user_id=' . $memberID . " AND map_user_banned=0 AND map_user_active=1"); } else { /* Delete all PMs -you- sent regardless of which folder they're in */ $messages = $this->messengerFunctions->getPersonalTopicsList($memberID, $folderID, array('offsetStart' => 0, 'offsetEnd' => 100000)); /* Just grab IDs */ $mtids = array_keys($messages); //----------------------------------------- // Got anything? //----------------------------------------- if (!count($mtids)) { $this->returnJsonError('nothingToRemove'); } //----------------------------------------- // Delete the messages //----------------------------------------- try { $this->messengerFunctions->deleteTopics($memberData['member_id'], $mtids); } catch (Exception $error) { $this->returnJsonError($error->getMessage()); } } //----------------------------------------- // Reset total message count //----------------------------------------- $totalMsgs = $this->messengerFunctions->resetMembersTotalTopicCount($memberData['member_id']); //----------------------------------------- // Update directory counts //----------------------------------------- $newDirs = $this->messengerFunctions->resetMembersFolderCounts($memberData['member_id']); $folders = $this->messengerFunctions->explodeFolderData($newDirs); $this->returnJsonArray(array('status' => $status, 'totalMsgs' => $totalMsgs, 'newDirs' => $newDirs, 'affectedDirCount' => $folders[$folderID]['count'])); }
/** * Multi Files Messages * * @access private * @return string returns HTML */ private function _multiFile() { //----------------------------------------- // INIT //----------------------------------------- $method = $this->request['method']; $folderID = $this->request['folderID']; $cfolderID = $this->request['cFolderID']; $sort = $this->request['sort']; $start = intval($this->request['st']); $ids = array(); //----------------------------------------- // Auth OK? //----------------------------------------- if ($this->request['auth_key'] != $this->member->form_hash) { $this->messengerFunctions->_currentFolderID = $cfolderID; return $this->_showFolder($this->lang->words['err_auth']); } //----------------------------------------- // Grab IDs //----------------------------------------- if (is_array($_POST['msgid'])) { foreach ($_POST['msgid'] as $id => $value) { $id = intval($id); $ids[$id] = $id; } } //----------------------------------------- // What are we doing? //----------------------------------------- try { if ($method == 'delete') { $this->messengerFunctions->deleteTopics($this->memberData['member_id'], $ids); } else { if ($method == 'move') { $this->messengerFunctions->moveTopics($this->memberData['member_id'], $ids, $folderID); } else { if ($method == 'markread' or $method == 'markunread') { $_method = $method == 'markread' ? TRUE : FALSE; $this->messengerFunctions->toggleReadStatus($this->memberData['member_id'], $ids, $_method); } else { if ($method == 'notifyon' or $method == 'notifyoff') { $_method = $method == 'notifyon' ? TRUE : FALSE; $this->messengerFunctions->toggleNotificationStatus($this->memberData['member_id'], $ids, $_method); } } } } $this->registry->getClass('output')->silentRedirect($this->settings['base_url'] . 'app=members&module=messaging&section=view&do=showFolder&folderID=' . $cfolderID . '&sort=' . $sort . '&st=' . $start); } catch (Exception $error) { $msg = $error->getMessage(); $error = ''; switch ($msg) { default: $error = $this->lang->words['err_unspecifed']; break; case 'NO_IDS_SELECTED': $error = $this->lang->words['err_NO_IDS_SELECTED']; break; /* Move exceptions */ /* Move exceptions */ case 'NO_SUCH_FOLDER': $error = $this->lang->words['err_NO_SUCH_FOLDER']; break; case 'NO_IDS_TO_MOVE': $error = $this->lang->words['err_NO_IDS_TO_MOVE']; break; /* Delete exceptions */ /* Delete exceptions */ case 'NO_IDS_TO_DELETE': $error = $this->lang->words['err_NO_IDS_TO_DELETE']; break; } $this->messengerFunctions->_currentFolderID = $cfolderID; return $this->_showFolder($error); } }
/** * Removes a folder * * @return string JSON either error or status * @since IPB 3.0.0.2008-06-25 */ protected function _removeFolder() { //----------------------------------------- // INIT //----------------------------------------- $folderID = IPSText::alphanumericalClean($this->request['folderID']); $memberID = intval($this->request['memberID']); $memberData = IPSMember::load($memberID, 'extendedProfile'); $status = 'ok'; IPSDebug::fireBug('info', array('Received folder id:' . $folderID)); IPSDebug::fireBug('info', array('Received member id:' . $memberID)); //----------------------------------------- // First off, get dir data //----------------------------------------- $folders = $this->messengerFunctions->explodeFolderData($memberData['pconversation_filters']); //----------------------------------------- // Check //----------------------------------------- if (!$memberData['member_id'] or !$folderID) { IPSDebug::fireBug('error', array('Missing member id or folder id')); $this->returnJsonError('noSuchFolder'); } //----------------------------------------- // Now ensure we actually have that folder //----------------------------------------- if (!$folders[$folderID]) { IPSDebug::fireBug('error', array('Specified folder does not exist')); $this->returnJsonError('noSuchFolder'); } //----------------------------------------- // Protected folder? //----------------------------------------- /* Protected? */ if ($folders[$folderID]['protected']) { $this->returnJsonError('cannotDeleteUndeletable'); } //----------------------------------------- // .. and it has no messages // Change May 9 2011 - JS alert already warns that // all messages in folder will be deleted, so just empty and delete // @link http://community.invisionpower.com/tracker/issue-29857-cannot-delete-pm-folder //----------------------------------------- //if ( $folders[ $folderID ]['count'] > 0 ) //{ // $this->returnJsonError( 'cannotDeleteHasMessages' ); //} $messages = $this->messengerFunctions->getPersonalTopicsList($memberID, $folderID, array('offsetStart' => 0, 'offsetEnd' => 100000)); /* Just grab IDs */ $mtids = array_keys($messages); try { $this->messengerFunctions->deleteTopics($memberData['member_id'], $mtids); } catch (Exception $error) { if ($error->getMessage() != 'NO_IDS_TO_DELETE') { $this->returnJsonError($error->getMessage()); } } //----------------------------------------- // OK, remove it. //----------------------------------------- unset($folders[$folderID]); ///----------------------------------------- // Collapse //----------------------------------------- $newDirs = $this->messengerFunctions->implodeFolderData($folders); //----------------------------------------- // Save... //----------------------------------------- IPSMember::save($memberID, array('extendedProfile' => array('pconversation_filters' => $newDirs))); //----------------------------------------- // Return... //----------------------------------------- $this->returnJsonArray(array('status' => $status, 'newDirs' => $newDirs)); }