public function save($post) { $helperFile = Core::make('helper/concrete/file'); $db = Database::get(); $cnvID = $db->GetOne('select cnvID from btCoreConversation where bID = ?', array($this->bID)); if (!$cnvID) { $conversation = Conversation::add(); $b = $this->getBlockObject(); $xc = $b->getBlockCollectionObject(); $conversation->setConversationPageObject($xc); } else { $conversation = Conversation::getByID($cnvID); } $values = $post + array('attachmentOverridesEnabled' => null, 'attachmentsEnabled' => null, 'itemsPerPage' => null, 'maxFilesGuest' => null, 'maxFilesRegistered' => null, 'maxFileSizeGuest' => null, 'maxFileSizeRegistered' => null, 'enableOrdering' => null, 'enableCommentRating' => null, 'notificationOverridesEnabled' => null, 'subscriptionEnabled' => null, 'fileExtensions' => null); if ($values['attachmentOverridesEnabled']) { $conversation->setConversationAttachmentOverridesEnabled(intval($values['attachmentOverridesEnabled'])); } else { $conversation->setConversationAttachmentOverridesEnabled(0); } if ($values['attachmentsEnabled']) { $conversation->setConversationAttachmentsEnabled(intval($values['attachmentsEnabled'])); } if (!$values['itemsPerPage']) { $values['itemsPerPage'] = 0; } if ($values['maxFilesGuest']) { $conversation->setConversationMaxFilesGuest(intval($values['maxFilesGuest'])); } if ($values['maxFilesRegistered']) { $conversation->setConversationMaxFilesRegistered(intval($values['maxFilesRegistered'])); } if ($values['maxFileSizeGuest']) { $conversation->setConversationMaxFileSizeGuest(intval($values['maxFileSizeGuest'])); } if ($values['maxFileSizeRegistered']) { $conversation->setConversationMaxFilesRegistered(intval($values['maxFileSizeRegistered'])); } if (!$values['enableOrdering']) { $values['enableOrdering'] = 0; } if (!$values['enableCommentRating']) { $values['enableCommentRating'] = 0; } if ($values['notificationOverridesEnabled']) { $conversation->setConversationNotificationOverridesEnabled(true); $users = array(); if (is_array($this->post('notificationUsers'))) { foreach ($this->post('notificationUsers') as $uID) { $ui = \UserInfo::getByID($uID); if (is_object($ui)) { $users[] = $ui; } } } $conversation->setConversationSubscribedUsers($users); $conversation->setConversationSubscriptionEnabled(intval($values['subscriptionEnabled'])); } else { $conversation->setConversationNotificationOverridesEnabled(false); $conversation->setConversationSubscriptionEnabled(0); } if ($values['fileExtensions']) { $receivedExtensions = preg_split('{,}', strtolower($values['fileExtensions']), null, PREG_SPLIT_NO_EMPTY); $fileExtensions = $helperFile->serializeUploadFileExtensions($receivedExtensions); $conversation->setConversationFileExtensions($fileExtensions); } $values['cnvID'] = $conversation->getConversationID(); parent::save($values); }
public function getConversationObject() { return Conversation::getByID($this->cnvID); }
public function getLandingPageConversations($cID) { $db = Database::connection(); $res = $db->GetRow("select cnvID from Conversations where cID = ?", $cID); if ($res) { $cnv = Conversation::getByID($res['cnvID']); $ml = new MessageList(); $ml->filterByConversation($cnv); $ml->filterByNotDeleted(); $ml->filterByApproved(); $ml->sortByDateDescending(); $messages = $ml->get(); } return $messages; }
<?php defined('C5_EXECUTE') or die("Access Denied."); use Concrete\Core\Conversation\Conversation; $val = Loader::helper('validation/token'); $helperFile = Loader::helper('concrete/file'); $file = new stdClass(); // json return value holder $error = array(); $pageObj = Page::getByID($_POST['cID']); $areaObj = Area::get($pageObj, $_POST['blockAreaHandle']); $blockObj = Block::getByID($_POST['bID'], $pageObj, $areaObj); $conversation = Conversation::getByID($blockObj->getController()->cnvID); if (!is_object($conversation)) { $error[] = t('Invalid Conversation.'); $file->error = $error; echo Loader::helper('json')->encode($file); exit; } if ($conversation->getConversationAttachmentOverridesEnabled() > 0) { // check individual conversation for allowing attachments. if ($conversation->getConversationAttachmentsEnabled != 1) { $error[] = t('This conversation does not allow file attachments.'); $file->error = $error; echo Loader::helper('json')->encode($file); exit; } } else { if (!!Config::get('concrete.conversations.attachments_enabled')) { // check global config settings for whether or not file attachments should be allowed. $error[] = t('This conversation does not allow file attachments.');
public function save($post) { $helperFile = Loader::helper('concrete/file'); $db = Loader::db(); $cnvID = $db->GetOne('select cnvID from btCoreConversation where bID = ?', array($this->bID)); if (!$cnvID) { $conversation = Conversation::add(); $b = $this->getBlockObject(); $xc = $b->getBlockCollectionObject(); $conversation->setConversationPageObject($xc); } else { $conversation = Conversation::getByID($cnvID); } $values = $post; if ($values['attachmentOverridesEnabled']) { $conversation->setConversationAttachmentOverridesEnabled(intval($values['attachmentOverridesEnabled'])); } else { $conversation->setConversationAttachmentOverridesEnabled(0); } if ($values['attachmentsEnabled']) { $conversation->setConversationAttachmentsEnabled(intval($values['attachmentsEnabled'])); } if (!$values['itemsPerPage']) { $values['itemsPerPage'] = 0; } if ($values['maxFilesGuest']) { $conversation->setConversationMaxFilesGuest(intval($values['maxFilesGuest'])); } if ($values['maxFilesRegistered']) { $conversation->setConversationMaxFilesRegistered(intval($values['maxFilesRegistered'])); } if ($values['maxFileSizeGuest']) { $conversation->setConversationMaxFileSizeGuest(intval($values['maxFileSizeGuest'])); } if ($values['maxFileSizeRegistered']) { $conversation->setConversationMaxFilesRegistered(intval($values['maxFileSizeRegistered'])); } if (!$values['enableOrdering']) { $values['enableOrdering'] = 0; } if (!$values['attachmentsEnabled']) { $conversation->setConversationAttachmentsEnabled(intval($values['attachmentsEnabled'])); } if (!$values['enableCommentRating']) { $values['enableCommentRating'] = 0; } if ($values['fileExtensions']) { $receivedExtensions = preg_split('{,}', strtolower($values['fileExtensions']), null, PREG_SPLIT_NO_EMPTY); $conversation->setConversationFileExtensions($helperFile->serializeUploadFileExtensions($receivedExtensions)); } $values['cnvID'] = $conversation->getConversationID(); parent::save($values); }