public function performActionAdd() { $sAction = 'add'; $sMsg = $this->_oModule->isAllowedAdd(); if ($sMsg !== CHECK_ACTION_RESULT_ALLOWED) { $this->_echoResultJson(array('msg' => $sMsg), true); return; } $oForm = BxDolForm::getObjectInstance('bx_sites', 'bx_sites_site_add'); if (!$oForm) { $this->_echoResultJson(array('msg' => _t('_sys_txt_error_occured')), true); return; } $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction; $oForm->initChecker(); if (!$oForm->isSubmittedAndValid()) { $sContent = BxTemplFunctions::getInstance()->popupBox('bx-sites-site-create-popup', _t('_bx_sites_grid_browse_popup_create'), $this->_oModule->_oTemplate->parseHtmlByName('block_create.html', array('form_id' => $oForm->aFormAttrs['id'], 'form' => $oForm->getCode(true), 'object' => $this->_sObject, 'action' => $sAction))); $this->_echoResultJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false))), true); return; } $sDomain = $oForm->getCleanValue('domain'); if ($this->_oModule->_oDb->isAccount(array('domain' => $sDomain))) { $this->_echoResultJson(array('msg' => _t('_bx_sites_txt_err_site_exists')), true); return; } $iAccountId = $oForm->insert(array('owner_id' => bx_get_logged_profile_id(), 'created' => time(), 'status' => BX_SITES_ACCOUNT_STATUS_UNCONFIRMED)); if (!$iAccountId) { $this->_echoResultJson(array('msg' => _t('_bx_sites_txt_err_site_creation')), true); return; } $oAccount = $this->_oModule->getObject('Account'); $oAccount->onAccountCreated($iAccountId); $sUrl = $this->_oModule->startSubscription($iAccountId); $this->_echoResultJson(array('eval' => 'window.open(\'' . $sUrl . '\', \'_self\');', 'popup_not_hide' => 1), true); }
public function createAccountForm() { // check access if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = BxDolAccount::isAllowedCreate(0))) { return MsgBox($sMsg); } // check and display form $oForm = $this->getObjectFormAdd(); if (!$oForm) { return MsgBox(_t('_sys_txt_error_occured')); } $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=create-account'); $oForm->initChecker(self::$PROFILE_FIELDS); if (!$oForm->isSubmittedAndValid()) { $sCode = $oForm->getCode(); bx_alert('account', 'add_form', 0, 0, array('form_object' => &$oForm, 'form_code' => &$sCode)); return $sCode; } // insert data into database $aValsToAdd = array('email_confirmed' => 0); $iAccountId = $oForm->insert($aValsToAdd); if (!$iAccountId) { if (!$oForm->isValid()) { return $oForm->getCode(); } else { return MsgBox(_t('_sys_txt_error_account_creation')); } } $iProfileId = $this->onAccountCreated($iAccountId, $oForm->isSetPendingApproval()); // perform action BxDolAccount::isAllowedCreate($iProfileId, true); $this->_iProfileId = bx_get_logged_profile_id(); // redirect $this->_redirectAndExit(getParam('sys_redirect_after_account_added'), true, array('account_id' => $iAccountId, 'profile_id' => $iProfileId)); }
/** * @return add data html */ public function addDataForm() { $sMsg = $this->_oModule->isAllowedAdd(); if ($sMsg !== CHECK_ACTION_RESULT_ALLOWED) { return MsgBox($sMsg); } bx_import('BxDolForm'); $oForm = BxDolForm::getObjectInstance('bx_sites', 'bx_sites_site_add'); if (!$oForm) { return MsgBox(_t('_sys_txt_error_occured')); } unset($oForm->aInputs['submit_block'][1]); $oForm->initChecker(); if (!$oForm->isSubmittedAndValid()) { return $oForm->getCode(); } $sDomain = $oForm->getCleanValue('domain'); if ($this->_oModule->_oDb->isAccount(array('domain' => $sDomain))) { return MsgBox(_t('_bx_sites_txt_err_site_exists')); } $iAccountId = $oForm->insert(array('owner_id' => bx_get_logged_profile_id(), 'created' => time(), 'status' => BX_SITES_ACCOUNT_STATUS_UNCONFIRMED)); if (!$iAccountId) { return MsgBox(_t('_bx_sites_txt_err_site_creation')); } $oAccount = $this->_oModule->getObject('Account'); $oAccount->onAccountCreated($iAccountId); $sUrl = $this->_oModule->startSubscription($iAccountId); header('Location: ' . $sUrl); exit; }
public function __construct($aObject, $oTemplate = false) { parent::__construct($aObject, $oTemplate); $CNF = $this->_oModule->_oConfig->CNF; $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT); $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT); if ($iProfileId) { $this->_oProfile = BxDolProfile::getInstance($iProfileId); } if (!$this->_oProfile && $iContentId) { $this->_oProfile = BxDolProfile::getInstanceByContentAndType($iContentId, $this->MODULE); } if ($this->_oProfile) { $this->_aProfileInfo = $this->_oProfile->getInfo(); $this->_aContentInfo = $this->_oModule->_oDb->getContentInfoById($this->_aProfileInfo['content_id']); $this->addMarkers($this->_aProfileInfo); $this->addMarkers(array('profile_id' => $this->_oProfile->id())); if (isLogged()) { $oConn = BxDolConnection::getObjectInstance('sys_profiles_friends'); if ($oConn->isConnectedNotMutual(bx_get_logged_profile_id(), $this->_oProfile->id())) { $this->addMarkers(array('title_add_friend' => _t($CNF['T']['menu_item_title_befriend_sent']), 'title_remove_friend' => _t($CNF['T']['menu_item_title_unfriend_cancel_request']))); } elseif ($oConn->isConnectedNotMutual($this->_oProfile->id(), bx_get_logged_profile_id())) { $this->addMarkers(array('title_add_friend' => _t($CNF['T']['menu_item_title_befriend_confirm']), 'title_remove_friend' => _t($CNF['T']['menu_item_title_unfriend_reject_request']))); } else { $this->addMarkers(array('title_add_friend' => _t($CNF['T']['menu_item_title_befriend']), 'title_remove_friend' => _t($CNF['T']['menu_item_title_unfriend']))); } } } }
protected function _delete($mixedId) { $oModule = BxDolModule::getInstance($this->MODULE); if ($sErrorMsg = $oModule->deleteConvo($mixedId)) { return false; } return $oModule->_oDb->moveConvo((int) $mixedId, bx_get_logged_profile_id(), BX_CNV_FOLDER_TRASH); }
public function __construct($aObject, $oTemplate = false) { parent::__construct($aObject, $oTemplate); $CNF =& $this->_oModule->_oConfig->CNF; $aInformers = array(); // get profile info $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT); $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT); if ($iProfileId) { $this->_oProfile = BxDolProfile::getInstance($iProfileId); } if (!$this->_oProfile && $iContentId) { $this->_oProfile = BxDolProfile::getInstanceByContentAndType($iContentId, $this->MODULE); } if ($this->_oProfile) { $this->_aProfileInfo = $this->_oProfile->getInfo(); $this->_aContentInfo = $this->_oModule->_oDb->getContentInfoById($this->_aProfileInfo['content_id']); } if (!$this->_aContentInfo || !$this->_oProfile) { return; } // select view profile submenu $oMenuSubmenu = BxDolMenu::getObjectInstance('sys_site_submenu'); $oMenuSubmenu->setObjectSubmenu($CNF['OBJECT_MENU_SUBMENU_VIEW_ENTRY'], array('title' => $this->_oProfile->getDisplayName(), 'link' => $this->_oProfile->getUrl(), 'icon' => $CNF['ICON'])); // add replaceable markers $this->addMarkers($this->_aProfileInfo); // every content field can be used as marker $this->addMarkers(array('profile_id' => $this->_oProfile->id())); // profile id field $this->addMarkers(array('display_name' => $this->_oProfile->getDisplayName())); // profile display name $this->addMarkers(array('profile_link' => $this->_oProfile->getUrl())); // profile link // display message if profile isn't active if (bx_get_logged_profile_id() == $this->_oProfile->id() && !empty($CNF['INFORMERS']['status'])) { $sStatus = $this->_aContentInfo['profile_status']; if (isset($CNF['INFORMERS']['status']['map'][$sStatus])) { $aInformers[] = array('name' => $CNF['INFORMERS']['status']['name'], 'msg' => _t($CNF['INFORMERS']['status']['map'][$sStatus]), 'type' => BX_INFORMER_ALERT); } } // display message if it is possible to switch to this profile $oProfile = $this->_aContentInfo ? BxDolProfile::getInstanceByContentTypeAccount($this->_aContentInfo['id'], $this->MODULE) : false; if ($oProfile) { $oProfile->checkSwitchToProfile($this->_oTemplate); } // add informers if ($aInformers) { $oInformer = BxDolInformer::getInstance($this->_oTemplate); if ($oInformer) { foreach ($aInformers as $a) { $oInformer->add($a['name'], $this->_replaceMarkers($a['msg']), $a['type']); } } } }
public function createAccountForm() { // check access if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = BxDolAccount::isAllowedCreate(0))) { return MsgBox($sMsg); } // check and display form $oForm = BxDolForm::getObjectInstance('sys_account', 'sys_account_create'); if (!$oForm) { return MsgBox(_t('_sys_txt_error_occured')); } $oForm->initChecker(); if (!$oForm->isSubmittedAndValid()) { $sCode = $oForm->getCode(); bx_alert('account', 'add_form', 0, 0, array('form_object' => &$oForm, 'form_code' => &$sCode)); return $sCode; } // insert data into database $aValsToAdd = array('email_confirmed' => 0); $iAccountId = $oForm->insert($aValsToAdd); if (!$iAccountId) { if (!$oForm->isValid()) { return $oForm->getCode(); } else { return MsgBox(_t('_sys_txt_error_account_creation')); } } // alert bx_alert('account', 'add', $iAccountId, 0); // if email_confirmation procedure is enabled - send email confirmation letter $oAccount = BxDolAccount::getInstance($iAccountId); if (getParam('sys_email_confirmation') && $oAccount && !$oAccount->isConfirmed()) { $oAccount->sendConfirmationEmail($iAccountId); } // add account and content association bx_import('BxDolProfile'); $iProfileId = BxDolProfile::add(BX_PROFILE_ACTION_MANUAL, $iAccountId, $iAccountId, BX_PROFILE_STATUS_PENDING, 'system'); $oProfile = BxDolProfile::getInstance($iProfileId); // approve profile if auto-approval is enabled and profile status is 'pending' $sStatus = $oProfile->getStatus(); $isAutoApprove = $oForm->isSetPendingApproval() ? false : true; if ($sStatus == BX_PROFILE_STATUS_PENDING && $isAutoApprove) { $oProfile->approve(BX_PROFILE_ACTION_AUTO); } // perform action BxDolAccount::isAllowedCreate($iProfileId, true); // alert bx_alert('account', 'added', $iAccountId); // login to the created account automatically bx_login($iAccountId); $this->_iProfileId = bx_get_logged_profile_id(); // redirect $this->_redirectAndExit(getParam('sys_redirect_after_account_added'), true, array('account_id' => $iAccountId, 'profile_id' => $iProfileId)); }
public function __construct() { parent::__construct(); $this->_oQuery = new BxDolLiveUpdatesQuery(); $this->_iInterval = (int) $this->_oQuery->getParam('sys_live_updates_interval'); $this->_iCacheTTL = 86400; $this->_sCacheKey = 'sys_live_updates_' . bx_get_logged_profile_id(); $this->_sJsClass = 'BxDolLiveUpdates'; $this->_sJsObject = 'oLiveUpdates'; $this->_aSystemsActive = array(); $this->_aSystems = $this->_getCachedSystems(); }
public function insert($aValsToAdd = array(), $isIgnore = false) { $CNF =& $this->_oModule->_oConfig->CNF; if (isset($CNF['FIELD_AUTHOR']) && empty($aValsToAdd[$CNF['FIELD_AUTHOR']])) { $aValsToAdd[$CNF['FIELD_AUTHOR']] = bx_get_logged_profile_id(); } if (isset($CNF['FIELD_ADDED']) && empty($aValsToAdd[$CNF['FIELD_ADDED']])) { $aValsToAdd[$CNF['FIELD_ADDED']] = time(); } if (isset($CNF['FIELD_CHANGED']) && empty($aValsToAdd[$CNF['FIELD_CHANGED']])) { $aValsToAdd[$CNF['FIELD_CHANGED']] = time(); } return parent::insert($aValsToAdd, $isIgnore); }
public function insert($aValsToAdd = array(), $isIgnore = false) { $aValsToAdd['last_reply_timestamp'] = time(); $aValsToAdd['last_reply_profile_id'] = bx_get_logged_profile_id(); $bSaveToDrafts = bx_get('draft_save'); $iContentId = bx_get('draft_id'); $bDraft = $iContentId ? BX_CNV_FOLDER_DRAFTS == $this->_oModule->_oDb->getConversationFolder($iContentId, bx_get_logged_profile_id()) : false; if ($iContentId) { if (!$bDraft) { return 0; } if (!parent::update($iContentId, $aValsToAdd, $isIgnore)) { return 0; } } else { $iContentId = parent::insert($aValsToAdd, $isIgnore); if (!$iContentId) { return 0; } } if ($bSaveToDrafts) { if (!$bDraft) { $this->_oModule->_oDb->conversationToFolder($iContentId, BX_CNV_FOLDER_DRAFTS, bx_get_logged_profile_id(), 0); } // draft is saved via ajax call only, upon successfull draft saving content id is returned echo $iContentId; exit; } else { bx_import('BxDolProfile'); // check for spam $bSpam = false; bx_alert('system', 'check_spam', 0, getLoggedId(), array('is_spam' => &$bSpam, 'content' => $this->getCleanValue('text'), 'where' => $this->MODULE)); $iFolder = $bSpam ? BX_CNV_FOLDER_SPAM : BX_CNV_FOLDER_INBOX; // place conversation to "inbox" (or "spam" - in case of spam) folder $aRecipients = array_unique(array_merge($this->getCleanValue('recipients'), array(bx_get_logged_profile_id())), SORT_NUMERIC); foreach ($aRecipients as $iProfile) { $oProfile = BxDolProfile::getInstance($iProfile); if (!$oProfile) { continue; } if ($bDraft && $oProfile->id() == bx_get_logged_profile_id()) { $this->_oModule->_oDb->moveConvo($iContentId, $oProfile->id(), $iFolder); } else { $this->_oModule->_oDb->conversationToFolder($iContentId, $iFolder, $oProfile->id(), $oProfile->id() == bx_get_logged_profile_id() ? 0 : -1); } } } return $iContentId; }
/** * Comments are enabled for collaborators only */ public function isEnabled() { if (!parent::isEnabled()) { return false; } $oModule = BxDolModule::getInstance('bx_convos'); if (!$oModule->_oDb->getContentInfoById((int) $this->getId())) { return false; } $aCollaborators = $oModule->_oDb->getCollaborators((int) $this->getId()); if (!isset($aCollaborators[bx_get_logged_profile_id()])) { return false; } return true; }
public function __construct($aObject, $oTemplate = false) { $this->MODULE = 'bx_convos'; parent::__construct($aObject, $oTemplate); $CNF =& $this->_oModule->_oConfig->CNF; $this->_oModule->_oDb->updateReadComments(bx_get_logged_profile_id(), $this->_aContentInfo[$CNF['FIELD_ID']], $this->_aContentInfo[$CNF['FIELD_COMMENTS']]); $iFolder = $this->_oModule->_oDb->getConversationFolder($this->_aContentInfo[$CNF['FIELD_ID']], bx_get_logged_profile_id()); if (BX_CNV_FOLDER_DRAFTS == $iFolder) { // if draft is opened - redirect to compose page $sUrl = BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_ADD_ENTRY']); $sUrl = bx_append_url_params($sUrl, array('draft_id' => $this->_aContentInfo[$CNF['FIELD_ID']])); header('Location: ' . BX_DOL_URL_ROOT . $sUrl); exit; } //$this->_oModule->setModuleSubmenu ($iFolder); $this->_oModule->_oTemplate->addJs('main.js'); $this->_oModule->_oTemplate->addCss(array('main-media-tablet.css', 'main-media-desktop.css')); }
/** * get number of received unconfirmed connections (friend requests) * @param $sConnectionsObject connections object to get unconfirmed connections from * @param $mixedId id to get connections for, if omitted then logged-in profile id is used * @return number */ public function serviceGetUnconfirmedConnectionsNum($sConnectionsObject, $mixedId = 0) { $oConnection = BxDolConnection::getObjectInstance($sConnectionsObject); if (!$oConnection) { return 0; } if (!$mixedId) { $mixedId = bx_get_logged_profile_id(); } $i = 0; $a = $oConnection->getConnectedInitiators($mixedId, 0); // get received friend requests foreach ($a as $iId) { if (BxDolProfile::getInstance($iId)) { ++$i; } } return $i; }
/** * Handle uploads here. * @param $mixedFiles as usual $_FILES['some_name'] array, but maybe some other params depending on the uploader * @return nothing, but if some files failed to upload, the actual error message can be determined by calling BxDolUploader::getUploadErrorMessages() */ public function handleUploads($iProfileId, $mixedFiles, $isMultiple = true, $iContentId = false, $bPrivate = true) { $oStorage = BxDolStorage::getObjectInstance($this->_sStorageObject); $iProfileId = bx_get_logged_profile_id(); if (!$isMultiple) { $this->cleanupGhostsForProfile($iProfileId, $iContentId); } if (bx_get('qqfile')) { $iId = $oStorage->storeFileFromXhr(bx_get('qqfile'), $bPrivate, $iProfileId, $iContentId); } else { $iId = $oStorage->storeFileFromForm($_FILES['qqfile'], $bPrivate, $iProfileId, $iContentId); } if ($iId) { $aResponse = array('success' => 1); } else { $this->appendUploadErrorMessage(_t('_sys_uploader_err_msg', isset($_FILES['qqfile']['name']) ? $_FILES['qqfile']['name'] : bx_get('qqfile'), $oStorage->getErrorString())); $aResponse = array('error' => $this->getUploadErrorMessages()); } echo htmlspecialchars(json_encode($aResponse), ENT_NOQUOTES); }
public function getMenuItems() { $a = parent::getMenuItems(); if (!isLogged()) { return $a; } foreach ($a as $k => $r) { if ('account' != $r['name']) { continue; } $oProfile = BxDolProfile::getInstance(bx_get_logged_profile_id()); $sUrlIcon = $oProfile->getThumb(); if (!$sUrlIcon) { break; } $a[$k]['bx_if:image'] = array('condition' => true, 'content' => array('icon_url' => $sUrlIcon)); $a[$k]['bx_if:icon']['condition'] = false; } return $a; }
protected function setMembership($mixedProfileId, $iAclLevelId) { bx_import('BxDolAcl'); if (!is_array($mixedProfileId)) { $mixedProfileId = array($mixedProfileId); } $iPerformerId = bx_get_logged_profile_id(); $aCheck = checkActionModule($iPerformerId, 'set acl level', 'system', false); if (!isAdmin() && $aCheck[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED) { return $aCheck[CHECK_ACTION_MESSAGE]; } $iSet = 0; $oAcl = BxDolAcl::getInstance(); foreach ($mixedProfileId as $iProfileId) { if (!$oAcl->setMembership($iProfileId, $iAclLevelId, 0, true)) { continue; } $iSet += 1; checkActionModule($iPerformerId, 'set acl level', 'system', true); // perform action } return count($mixedProfileId) != $iSet ? _t('_error occured') : ''; }
/** * page code function */ function PageCompMainCode() { ob_start(); $sTranscoderObjectPoster = 'sample_video_poster'; $sTranscoderObjectMP4 = 'sample_video_mp4'; $sTranscoderObjectWebM = 'sample_video_webm'; $sStorageObjectOrig = 'sample_transcoder_video_orig'; $iProfileId = bx_get_logged_profile_id(); if (!$iProfileId) { echo "You aren't logged in."; exit; } $iPrunedFiles = BxDolTranscoder::pruning(); if ($iPrunedFiles) { echo "iPrunedFiles: {$iPrunedFiles}"; exit; } $oTranscoderPoster = BxDolTranscoderVideo::getObjectInstance($sTranscoderObjectPoster); $oTranscoderMP4 = BxDolTranscoderVideo::getObjectInstance($sTranscoderObjectMP4); $oTranscoderWebM = BxDolTranscoderVideo::getObjectInstance($sTranscoderObjectWebM); if (!$oTranscoderPoster || !$oTranscoderMP4 || !$oTranscoderWebM) { echo "Transcoder object is not available: " . $sTranscoderObjectPoster . ', ' . $sTranscoderObjectMP4 . ', ' . $sTranscoderObjectWebM; exit; } echo "registerHandlers poster: [" . $oTranscoderPoster->registerHandlers() . "] <br />\n"; echo "registerHandlers mp4: [" . $oTranscoderMP4->registerHandlers() . "] <br />\n"; echo "registerHandlers webm: [" . $oTranscoderWebM->registerHandlers() . "] <hr class='bx-def-hr' />\n"; $oStorageOrig = BxDolStorage::getObjectInstance($sStorageObjectOrig); if (!$oStorageOrig) { echo "Storage object is not available: " . $sStorageObjectOrig; exit; } if (isset($_POST['upload'])) { $iId = $oStorageOrig->storeFileFromForm($_FILES['file'], true, $iProfileId); if ($iId) { $iCount = $oStorageOrig->afterUploadCleanup($iId, $iProfileId); echo "<h2>Uploaded file id: " . $iId . "(deleted ghosts:" . $iCount . ") </h2>"; // force transcode echo "Force transcode: <br />"; echo "poster: " . $oTranscoderPoster->getFileUrl($iId) . '<br />'; echo "mp4: " . $oTranscoderMP4->getFileUrl($iId) . '<br />'; echo "webm: " . $oTranscoderWebM->getFileUrl($iId) . '<hr class="bx-def-hr" />'; } else { echo "<h2>Error uploading file: " . $oStorage->getErrorString() . '</h2><hr class="bx-def-hr" />'; } } elseif (isset($_POST['delete'])) { foreach ($_POST['file_id'] as $iFileId) { $bRet = $oStorageOrig->deleteFile($iFileId, $iProfileId); if ($bRet) { echo "<h2>Deleted file id: " . $iFileId . '</h2><hr class="bx-def-hr" />'; } else { echo "<h2>File deleting error: " . $oStorageOrig->getErrorString() . '</h2><hr class="bx-def-hr" />'; } } } else { $a = $oStorageOrig->getFilesAll(); foreach ($a as $r) { $sUrlPoster = $oTranscoderPoster->getFileUrl($r['id']); $sUrlMP4 = $oTranscoderMP4->getFileUrl($r['id']); $sUrlWebM = $oTranscoderWebM->getFileUrl($r['id']); echo '<h3>' . $r['file_name'] . '</h3>'; echo BxTemplFunctions::getInstance()->videoPlayer($sUrlPoster, $sUrlMP4, $sUrlWebM, false, 'height:200px;'); echo '<hr class="bx-def-hr" />'; } } $a = $oStorageOrig->getFilesAll(); ?> <h2>Files List</h2> <form method="POST"> <?php foreach ($a as $r) { ?> <input type="checkbox" name="file_id[]" value="<?php echo $r['id']; ?> " /> <?php echo $r['file_name']; ?> <br /> <?php } ?> <input type="submit" name="delete" value="Delete" class="bx-btn bx-btn-small bx-def-margin-sec-top" style="float:none;" /> </form> <hr class="bx-def-hr" /> <h2>Upload</h2> <form enctype="multipart/form-data" method="POST"> <input type="file" name="file" /> <br /> <input type="submit" name="upload" value="Upload" class="bx-btn bx-btn-small bx-def-margin-sec-top" style="float:none;" /> </form> <?php $s = ob_get_clean(); return DesignBoxContent("Sample video transcoder", $s, BX_DB_PADDING_DEF); }
function getMessageLabel($r, $oProfileLast = null) { $oModule = BxDolModule::getInstance($this->MODULE); if (!$oProfileLast) { $oProfileLast = BxDolProfile::getInstance($r['last_reply_profile_id']); if (!$oProfileLast) { $oProfileLast = BxDolProfileUndefined::getInstance(); } } if (!isset($r['unread_messages'])) { $r['unread_messages'] = $r['comments'] - $r['read_comments']; } $bReadByAll = true; $aCollaborators = $oModule->_oDb->getCollaborators($r['id']); foreach ($aCollaborators as $iReadComments) { if ($r['comments'] - $iReadComments) { $bReadByAll = false; break; } } if (!isset($r['unread_messages'])) { $r['unread_messages'] = $r['comments'] - $r['read_comments']; } $aVars = array('bx_if:unread_messages' => array('condition' => $r['unread_messages'] > 0, 'content' => array('unread_messages' => $r['unread_messages'])), 'bx_if:viewer_is_last_replier' => array('condition' => !$bReadByAll && $oProfileLast->id() == bx_get_logged_profile_id(), 'content' => array()), 'bx_if:is_read_by_all' => array('condition' => $bReadByAll, 'content' => array())); return $this->parseHtmlByName('message_label.html', $aVars); }
/** * Only collaborators can view convo */ public function checkAllowedView($aDataEntry, $isPerformAction = false) { if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = parent::checkAllowedView($aDataEntry, $isPerformAction))) { return $sMsg; } $aCollaborators = $this->_oDb->getCollaborators($aDataEntry[$this->_oConfig->CNF['FIELD_ID']]); return isset($aCollaborators[bx_get_logged_profile_id()]) ? CHECK_ACTION_RESULT_ALLOWED : _t('_sys_txt_access_denied'); }
public function deleteDataForm($iContentId, $sDisplay = false) { $CNF =& $this->_oModule->_oConfig->CNF; if (false === $sDisplay) { $sDisplay = $CNF['OBJECT_FORM_ENTRY_DISPLAY_DELETE']; } // get content data and profile info list($oProfile, $aContentInfo) = $this->_getProfileAndContentData($iContentId); if (!$aContentInfo) { return MsgBox(_t('_sys_txt_error_entry_is_not_defined')); } // check access if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->_oModule->checkAllowedDelete($aContentInfo))) { return MsgBox($sMsg); } // check and display form $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ENTRY'], $sDisplay, $this->_oModule->_oTemplate); if (!$oForm) { return MsgBox(_t('_sys_txt_error_occured')); } $oForm->initChecker($aContentInfo); if (!$oForm->isSubmittedAndValid()) { return $oForm->getCode(); } if ($sError = $this->deleteData($aContentInfo[$CNF['FIELD_ID']], $aContentInfo, $oProfile, $oForm)) { return MsgBox($sError); } // perform action $this->_oModule->checkAllowedDelete($aContentInfo, true); // redirect $this->_redirectAndExit($CNF['URL_HOME'], true, array('account_id' => getLoggedId(), 'profile_id' => bx_get_logged_profile_id())); }
protected function _getActionAddFriend($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array()) { if ($this->_bOwner || $aRow['id'] == bx_get_logged_profile_id()) { return ''; } bx_import('BxDolConnection'); $oConn = BxDolConnection::getObjectInstance($this->_sObjectConnections); if ($oConn->isConnected($aRow['id'], bx_get_logged_profile_id()) || $oConn->isConnected(bx_get_logged_profile_id(), $aRow['id'])) { return ''; } return parent::_getActionDefault($sType, $sKey, $a, $isSmall, $isDisabled, $aRow); }
/** * Check whether the viewer can make requested action. * * @param integer $iObjectId object ID the action to be performed with. * @param integer $iViewerId viewer ID. * @return boolean result of operation. */ function check($iObjectId, $iViewerId = 0) { if (empty($iViewerId)) { $iViewerId = bx_get_logged_profile_id(); } $aObject = $this->_oDb->getObjectInfo($this->getFieldName($this->_aObject['action']), $iObjectId); if (empty($aObject) || !is_array($aObject)) { return false; } if ($aObject['group_id'] == BX_DOL_PG_HIDDEN) { return false; } if (isAdmin() || $iViewerId == $aObject['owner_id']) { return true; } $aGroup = $this->_oDb->getGroupsBy(array('type' => 'id', 'id' => $aObject['group_id'])); if (!empty($aGroup) && is_array($aGroup) && (int) $aGroup['active'] == 1 && !empty($aGroup['check'])) { $sCheckMethod = $this->getCheckMethod($aGroup['check']); if (method_exists($this, $sCheckMethod) && $this->{$sCheckMethod}($aObject['owner_id'], $iViewerId)) { return true; } } return $this->isDynamicGroupMember($aObject['group_id'], $aObject['owner_id'], $iViewerId, $iObjectId); }
public function getProfileId() { return isLogged() ? bx_get_logged_profile_id() : 0; }
/** * Display informer message if it is possible to switch to this profile */ public function checkSwitchToProfile($oTemplate = null, $iViewerAccountId = false, $iViewerProfileId = false) { if (false === $iViewerAccountId) { $iViewerAccountId = getLoggedId(); } if (false === $iViewerProfileId) { $iViewerProfileId = bx_get_logged_profile_id(); } if (!$iViewerAccountId || !$iViewerProfileId) { return; } if ($iViewerAccountId != $this->getAccountId() || $iViewerProfileId == $this->id()) { return; } bx_import('BxDolInformer'); bx_import('BxDolPermalinks'); $oInformer = BxDolInformer::getInstance($oTemplate); if ($oInformer) { $oInformer->add('sys-switch-profile-context', _t('_sys_txt_account_profile_context_change_suggestion', BxDolPermalinks::getInstance()->permalink('page.php?i=account-profile-switcher', array('switch_to_profile' => $this->id()))), BX_INFORMER_INFO); } }
/** * Internal functions */ protected function _getAuthorId() { return isMember() ? bx_get_logged_profile_id() : 0; }
/** * Only collaborators can view convo */ public function checkAllowedView($aDataEntry, $isPerformAction = false) { if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = parent::checkAllowedView($aDataEntry, $isPerformAction))) { return $sMsg; } return $this->isCollaborator($aDataEntry, bx_get_logged_profile_id()) ? CHECK_ACTION_RESULT_ALLOWED : _t('_sys_txt_access_denied'); }
public function checkMyself($iContentId) { $iLogged = (int) bx_get_logged_profile_id(); if (empty($iLogged)) { return false; } $oProfile = BxDolProfile::getInstanceByContentAndType((int) $iContentId, $this->_oConfig->getName()); if (!$oProfile) { return false; } return $oProfile->id() == $iLogged; }
function __construct(&$aModule) { parent::__construct($aModule); $this->_iProfileId = bx_get_logged_profile_id(); }
function _deleteFile($iFileId) { $CNF =& $this->_oModule->_oConfig->CNF; if (!$iFileId) { return true; } bx_import('BxDolStorage'); if (!($oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']))) { return false; } if (!$oStorage->getFile($iFileId)) { return true; } $iProfileId = bx_get_logged_profile_id(); return $oStorage->deleteFile($iFileId, $iProfileId); }
public function serviceAccountProfileSwitcher($iAccountId = false) { bx_import('BxDolProfileQuery'); $oProfilesQuery = BxDolProfileQuery::getInstance(); $aProfiles = $oProfilesQuery->getProfilesByAccount($iAccountId ? $iAccountId : getLoggedId()); if (!$aProfiles) { return false; } $iLoggedPofileId = bx_get_logged_profile_id(); $aVars = array('bx_repeat:row' => array()); foreach ($aProfiles as $aProfile) { if ($aProfile['type'] == 'system') { // skip system account profile continue; } $aVars['bx_repeat:row'][] = array('class' => $iLoggedPofileId == $aProfile['id'] ? '' : 'bx-def-color-bg-box', 'bx_if:active' => array('condition' => $iLoggedPofileId == $aProfile['id'], 'content' => array('id' => $aProfile['id'])), 'bx_if:inactive' => array('condition' => $iLoggedPofileId != $aProfile['id'], 'content' => array('id' => $aProfile['id'], 'url_switch' => BxDolPermalinks::getInstance()->permalink('page.php?i=account-profile-switcher', array('switch_to_profile' => $aProfile['id'])))), 'unit' => BxDolService::call($aProfile['type'], 'profile_unit', array($aProfile['content_id']))); } if (!$aVars['bx_repeat:row']) { bx_import('BxDolMenu'); $oMenu = BxDolMenu::getObjectInstance('sys_add_profile'); return array('content' => $oMenu ? $oMenu->getCode() : MsgBox(_t('_sys_txt_empty')), 'menu' => 'sys_add_profile'); } bx_import('BxDolTemplate'); $oTemplate = BxDolTemplate::getInstance(); $oTemplate->addCss('account.css'); return array('content' => $oTemplate->parseHtmlByName('profile_switch_row.html', $aVars), 'menu' => 'sys_add_profile'); }