Esempio n. 1
0
 function processing()
 {
     global $sModule;
     global $sFfmpegPath;
     global $sModulesPath;
     global $sFilesPath;
     $iFilesCount = getSettingValue($sModule, "processCount");
     if (!is_numeric($iFilesCount)) {
         $iFilesCount = 2;
     }
     $iFailedTimeout = getSettingValue($sModule, "failedTimeout");
     if (!is_numeric($iFailedTimeout)) {
         $iFailedTimeout = 1;
     }
     $iFailedTimeout *= 86400;
     $sDbPrefix = DB_PREFIX . ucfirst($sModule);
     $iCurrentTime = time();
     do {
         //remove all tokens older than 10 minutes
         if (!getResult("DELETE FROM `" . $sDbPrefix . "Tokens` WHERE `Date`<'" . ($iCurrentTime - 600) . "'")) {
             break;
         }
         if (!getResult("UPDATE `" . $sDbPrefix . "Files` SET `Date`='" . $iCurrentTime . "', `Status`='" . STATUS_FAILED . "' WHERE `Status`='" . STATUS_PROCESSING . "' AND `Date`<'" . ($iCurrentTime - $iFailedTimeout) . "'")) {
             break;
         }
         $rResult = getResult("SELECT * FROM `" . $sDbPrefix . "Files` WHERE `Status`='" . STATUS_PENDING . "' ORDER BY `ID` LIMIT " . $iFilesCount);
         if (!$rResult) {
             break;
         }
         for ($i = 0; $i < mysql_num_rows($rResult); $i++) {
             $aFile = mysql_fetch_assoc($rResult);
             if (convertVideo($aFile['ID'])) {
                 $sType = 'bx_videos';
                 //album counter & cover update
                 if (getSettingValue($sModule, "autoApprove") == TRUE_VAL) {
                     $oAlbum = new BxDolAlbums($sType);
                     $oAlbum->updateObjCounterById($aFile['ID']);
                     if (getParam($oAlbum->sAlbumCoverParam) == 'on') {
                         $oAlbum->updateLastObjById($aFile['ID']);
                     }
                 }
                 //tags & categories parsing
                 $oTag = new BxDolTags();
                 $oTag->reparseObjTags($sType, $aFile['ID']);
                 $oCateg = new BxDolCategories($aFile['Owner']);
                 $oCateg->reparseObjTags($sType, $aFile['ID']);
             } else {
                 if (!getResult("UPDATE `" . $sDbPrefix . "Files` SET `Status`='" . STATUS_FAILED . "' WHERE `ID`='" . $aFile['ID'] . "'")) {
                     break;
                 }
             }
         }
     } while (false);
 }
Esempio n. 2
0
 function processing()
 {
     $aIds = array();
     if ($this->_oModule->_oDb->publish($aIds)) {
         foreach ($aIds as $iId) {
             //--- Entry -> Publish for Alerts Engine ---//
             $oAlert = new BxDolAlerts($this->_oModule->_oConfig->getAlertsSystemName(), 'publish', $iId);
             $oAlert->alert();
             //--- Entry -> Publish for Alerts Engine ---//
             //--- Reparse Global Tags ---//
             $oTags = new BxDolTags();
             $oTags->reparseObjTags($this->_oModule->_oConfig->getTagsSystemName(), $iId);
             //--- Reparse Global Tags ---//
             //--- Reparse Global Categories ---//
             $oCategories = new BxDolCategories();
             $oCategories->reparseObjTags($this->_oModule->_oConfig->getCategoriesSystemName(), $iId);
             //--- Reparse Global Categories ---//
         }
     }
 }
Esempio n. 3
0
 function reparseCategories($iSiteId)
 {
     bx_import('BxDolCategories');
     $o = new BxDolCategories();
     $o->reparseObjTags('bx_sites', $iSiteId);
 }
Esempio n. 4
0
 function _actDelete($aIds)
 {
     if (!$this->_isDeleteAllowed(true)) {
         return false;
     }
     if (is_int($aIds) || is_string($aIds)) {
         $aIds = array((int) $aIds);
     }
     $bResult = $this->_oDb->deleteEntries($aIds);
     if ($bResult) {
         $oTags = new BxDolTags();
         $oCategories = new BxDolCategories();
         $oSubscription = BxDolSubscription::getInstance();
         foreach ($aIds as $iId) {
             //--- Entry -> Delete for Alerts Engine ---//
             $oAlert = new BxDolAlerts($this->_oConfig->getAlertsSystemName(), 'delete', $iId, BxDolTextData::getAuthorId());
             $oAlert->alert();
             //--- Entry -> Delete for Alerts Engine ---//
             //--- Reparse Global Tags ---//
             $oTags->reparseObjTags($this->_oConfig->getTagsSystemName(), $iId);
             //--- Reparse Global Tags ---//
             //--- Reparse Global Categories ---//
             $oCategories->reparseObjTags($this->_oConfig->getCategoriesSystemName(), $iId);
             //--- Reparse Global Categories ---//
             //--- Remove all subscriptions ---//
             $oSubscription->unsubscribe(array('type' => 'object_id', 'unit' => $this->_oConfig->getSubscriptionsSystemName(), 'object_id' => $iId));
             //--- Remove all subscriptions ---//
         }
     }
     return $bResult;
 }
 function savePage()
 {
     $aDiff = $this->getDiffValues(0);
     list($aUpd, $aMedia) = $this->oPF->getPageFromValues($aDiff);
     $sDelimeter = getParam('ml_clonetwo_multi_divider');
     $sDelimeter = $sDelimeter ? $sDelimeter : ';';
     if ($aDiff['title']) {
         $aUpd['uri'] = uriGenerate($aDiff['title'], 'ml_clonetwo_main', 'title');
     }
     $sTitle = $aDiff['title'] ? $aDiff['title'] : db_value("SELECT `title` FROM `ml_clonetwo_main` WHERE `id` = {$this->iPageID} LIMIT 1");
     if (!empty($aMedia)) {
         foreach ($aMedia as $sKey => $sValue) {
             $aMediaData = explode($sDelimeter, $aUpd[$sValue]);
             switch ($sKey) {
                 case 'photo':
                     $sTable = 'ml_clonetwo_images';
                     $iIdField = 'entry_id';
                     $iMedIdField = 'media_id';
                     if ($_POST['thumb_radio']) {
                         db_res("UPDATE `ml_clonetwo_main` SET `thumb` = {$_POST['thumb_radio']} WHERE `id` = {$this->iPageID} LIMIT 1");
                     }
                     if (!empty($_POST[$sValue . '_check_photos'])) {
                         foreach ($_POST[$sValue . '_check_photos'] as $sValue) {
                             if ($sValue) {
                                 db_res("DELETE FROM `{$sTable}` WHERE `{$iIdField}` = {$this->iPageID} AND `{$iMedIdField}` = {$sValue} LIMIT 1");
                             }
                         }
                     }
                     if (BxDolRequest::serviceExists("photos", "perform_photo_upload", 'Uploader')) {
                         $i = 0;
                         foreach ($aMediaData as $sData) {
                             $aInfo = array('medTitle' => $_POST[$sValue . '_title_photos'][$i] ? $_POST[$sValue . '_title_photos'][$i] : $_FILES[$sValue]['name'][$i], 'Categories' => array($aUpd['title'] . ' ' . _t("_bx_{$sKey}s")), 'album' => _t('_ml_clonetwo_photo_album', $aUpd['title']));
                             if ($sData) {
                                 $this->looper();
                                 $iMediaId = BxDolService::call("photos", "perform_photo_upload", array($GLOBALS['dir']['tmp'] . $sData, $aInfo, false), 'Uploader');
                                 if ($iMediaId) {
                                     @unlink($GLOBALS['dir']['tmp'] . $sData);
                                     if (db_value("SHOW TABLES LIKE '{$sTable}'")) {
                                         db_res("INSERT INTO `{$sTable}` SET `{$iIdField}` = {$this->iPageID}, `{$iMedIdField}` = {$iMediaId}");
                                     }
                                     if (!db_value("SELECT `thumb` FROM `ml_clonetwo_main` WHERE `id` = {$this->iPageID} LIMIT 1") && $i == 0) {
                                         db_res("UPDATE `ml_clonetwo_main` SET `thumb` = {$iMediaId} WHERE `id` = {$this->iPageID} LIMIT 1");
                                     }
                                 }
                             }
                             $i++;
                         }
                     }
                     break;
                 case 'video':
                     $sTable = 'ml_clonetwo_videos';
                     $iIdField = 'entry_id';
                     $iMedIdField = 'media_id';
                     if (!empty($_POST[$sValue . '_check_videos'])) {
                         foreach ($_POST[$sValue . '_check_videos'] as $sValue) {
                             if ($sValue) {
                                 db_res("DELETE FROM `{$sTable}` WHERE `{$iIdField}` = {$this->iPageID} AND `{$iMedIdField}` = {$sValue} LIMIT 1");
                             }
                         }
                     }
                     if (BxDolRequest::serviceExists("videos", "perform_video_upload", 'Uploader')) {
                         $i = 0;
                         if ($sData) {
                             foreach ($aMediaData as $sData) {
                                 $aInfo = array('medTitle' => $_POST[$sValue . '_title_videos'][$i] ? $_POST[$sValue . '_title_videos'][$i] : $_FILES[$sValue]['name'][$i], 'Categories' => array($aUpd['title'] . ' ' . _t("_bx_{$sKey}s")), 'album' => _t('_ml_clonetwo_photo_album', $aUpd['title']));
                                 $this->looper();
                                 $iMediaId = BxDolService::call("videos", "perform_video_upload", array($GLOBALS['dir']['tmp'] . $sData, $aInfo, false), 'Uploader');
                                 if ($iMediaId) {
                                     @unlink($GLOBALS['dir']['tmp'] . $sData);
                                     if (db_value("SHOW TABLES LIKE '{$sTable}'")) {
                                         db_res("INSERT INTO `{$sTable}` SET `{$iIdField}` = {$this->iPageID}, `{$iMedIdField}` = {$iMediaId}");
                                     }
                                 }
                             }
                             $i++;
                         }
                     }
                     break;
                 case 'sound':
                     $sTable = 'ml_clonetwo_sounds';
                     $iIdField = 'entry_id';
                     $iMedIdField = 'media_id';
                     if (!empty($_POST[$sValue . '_check_sounds'])) {
                         foreach ($_POST[$sValue . '_check_sounds'] as $sValue) {
                             if ($sValue) {
                                 db_res("DELETE FROM `{$sTable}` WHERE `{$iIdField}` = {$this->iPageID} AND `{$iMedIdField}` = {$sValue} LIMIT 1");
                             }
                         }
                     }
                     if (BxDolRequest::serviceExists("sounds", "perform_music_upload", 'Uploader')) {
                         $i = 0;
                         if ($sData) {
                             foreach ($aMediaData as $sData) {
                                 $aInfo = array('medTitle' => $_POST[$sValue . '_title_sounds'][$i] ? $_POST[$sValue . '_title_sounds'][$i] : $_FILES[$sValue]['name'][$i], 'Categories' => array($aUpd['title'] . ' ' . _t("_bx_{$sKey}s")), 'album' => _t('_ml_clonetwo_photo_album', $aUpd['title']));
                                 $this->looper();
                                 $iMediaId = BxDolService::call("sounds", "perform_music_upload", array($GLOBALS['dir']['tmp'] . $sData, $aInfo, false), 'Uploader');
                                 if ($iMediaId) {
                                     @unlink($GLOBALS['dir']['tmp'] . $sData);
                                     if (db_value("SHOW TABLES LIKE '{$sTable}'")) {
                                         db_res("INSERT INTO `{$sTable}` SET `{$iIdField}` = {$this->iPageID}, `{$iMedIdField}` = {$iMediaId}");
                                     }
                                 }
                             }
                             $i++;
                         }
                     }
                     break;
                 case 'file':
                     $sTable = 'ml_clonetwo_files';
                     $iIdField = 'entry_id';
                     $iMedIdField = 'media_id';
                     if (!empty($_POST[$sValue . '_check_files'])) {
                         foreach ($_POST[$sValue . '_check_files'] as $sValue) {
                             if ($sValue) {
                                 db_res("DELETE FROM `{$sTable}` WHERE `{$iIdField}` = {$this->iPageID} AND `{$iMedIdField}` = {$sValue} LIMIT 1");
                             }
                         }
                     }
                     if (BxDolRequest::serviceExists("files", "perform_file_upload", 'Uploader')) {
                         $i = 0;
                         if ($sData) {
                             foreach ($aMediaData as $sData) {
                                 $aInfo = array('medTitle' => $_POST[$sValue . '_title_files'][$i] ? $_POST[$sValue . '_title_files'][$i] : $_FILES[$sValue]['name'][$i], 'Categories' => array($aUpd['title'] . ' ' . _t("_bx_{$sKey}s")), 'album' => _t('_ml_clonetwo_photo_album', $aUpd['title']));
                                 $this->looper();
                                 $iMediaId = BxDolService::call("files", "perform_file_upload", array($GLOBALS['dir']['tmp'] . $sData, $aInfo, false), 'Uploader');
                                 if ($iMediaId) {
                                     @unlink($GLOBALS['dir']['tmp'] . $sData);
                                     if (db_value("SHOW TABLES LIKE '{$sTable}'")) {
                                         db_res("INSERT INTO `{$sTable}` SET `{$iIdField}` = {$this->iPageID}, `{$iMedIdField}` = {$iMediaId}");
                                     }
                                 }
                             }
                             $i++;
                         }
                     }
                     break;
                 case 'youtube':
                     $i = 0;
                     $sTable = 'ml_clonetwo_youtube';
                     $iUIdField = 'id';
                     $iIdField = 'id_entry';
                     $sUrlField = 'url';
                     $sTitleField = 'title';
                     if (!empty($_POST[$sValue . '_check_youtube'])) {
                         foreach ($_POST[$sValue . '_check_youtube'] as $sValue) {
                             if ($sValue) {
                                 db_res("DELETE FROM `{$sTable}` WHERE `{$iIdField}` = {$this->iPageID} AND `{$iUIdField}` = {$sValue} LIMIT 1");
                             }
                         }
                     }
                     foreach ($aMediaData as $sData) {
                         if ($sData) {
                             $sTitle = $_POST[$sValue . '_title_youtube'][$i];
                             if (db_value("SHOW TABLES LIKE '{$sTable}'") && $sData) {
                                 db_res("INSERT INTO `{$sTable}` SET `{$iIdField}` = {$this->iPageID}, `{$sUrlField}` = '{$sData}', `{$sTitleField}` = '{$sTitle}'");
                             }
                         }
                         $i++;
                     }
                     break;
                 case 'rss':
                     $i = 0;
                     $sTable = 'ml_clonetwo_rss';
                     $iUIdField = 'id';
                     $iIdField = 'id_entry';
                     $sUrlField = 'url';
                     $sTitleField = 'name';
                     if (!empty($_POST[$sValue . '_check_rss'])) {
                         foreach ($_POST[$sValue . '_check_rss'] as $sValue) {
                             if ($sValue) {
                                 db_res("DELETE FROM `{$sTable}` WHERE `{$iIdField}` = {$this->iPageID} AND `{$iUIdField}` = {$sValue} LIMIT 1");
                             }
                         }
                     }
                     foreach ($aMediaData as $sData) {
                         if ($sData) {
                             $sTitle = $_POST[$sValue . '_title_rss'][$i];
                             if (db_value("SHOW TABLES LIKE '{$sTable}'") && $sData) {
                                 db_res("INSERT INTO `{$sTable}` SET `{$iIdField}` = {$this->iPageID}, `{$sUrlField}` = '{$sData}', `{$sTitleField}` = '{$sTitle}'");
                             }
                         }
                         $i++;
                     }
                     break;
             }
         }
     }
     $oModuleDb = new BxDolModuleDb();
     $aModule = $oModuleDb->getModuleByUri('clonetwo');
     $iProfileId = getLoggedId();
     bx_import('BxDolTags');
     $o = new BxDolTags();
     $o->reparseObjTags('ml_clonetwo', $this->iPageID);
     bx_import('BxDolCategories');
     $o = new BxDolCategories();
     $o->reparseObjTags('ml_clonetwo', $this->iPageID);
     $this->oPC->updatePage($this->iPageID, $aUpd);
 }
Esempio n. 6
0
 function reparseCategories($iEntryId)
 {
     $iEntryId = (int) $iEntryId;
     bx_import('BxDolCategories');
     $o = new BxDolCategories();
     $o->reparseObjTags($this->_sPrefix, $iEntryId);
 }
Esempio n. 7
0
 function actionEdit($iFileId)
 {
     $bAjax = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' ? TRUE : FALSE;
     $iFileId = (int) $iFileId > 0 ? (int) $iFileId : (int) bx_get('fileId');
     if (!$iFileId || !$bAjax) {
         return;
     }
     $aManageArray = array('medTitle', 'medTags', 'medDesc', 'medProfId', 'Categories', 'AllowDownload', 'medUri');
     $aInfo = $this->_oDb->getFileInfo(array('fileId' => $iFileId), false, $aManageArray);
     $sLangPref = '_' . $this->_oConfig->getMainPrefix();
     if (!$this->isAllowedEdit($aInfo)) {
         $sCode = MsgBox(_t($sLangPref . '_access_denied')) . $sJsCode;
     } else {
         $oCategories = new BxDolCategories();
         $oCategories->getTagObjectConfig();
         $aCategories = $oCategories->getGroupChooser($this->_oConfig->getMainPrefix(), $this->_iProfileId, true);
         $aCategories['value'] = explode(CATEGORIES_DIVIDER, $aInfo['Categories']);
         $aAllowDownload = $this->oPrivacy->getGroupChooser($this->_iProfileId, $this->_oConfig->getUri(), 'download');
         $aAllowDownload['value'] = $aInfo['AllowDownload'];
         $sUrlPref = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri();
         $aForm = array('form_attrs' => array('id' => $sLangPref . '_upload_form', 'method' => 'post', 'action' => $sUrlPref . 'edit/' . $iFileId, 'onsubmit' => "return bx_ajax_form_check(this)"), 'params' => array('db' => array('submit_name' => 'do_submit'), 'checker_helper' => 'BxSupportCheckerHelper'), 'inputs' => array('header' => array('type' => 'block_header', 'caption' => _t('_Info')), 'title' => array('type' => 'text', 'name' => 'medTitle', 'caption' => _t('_Title'), 'required' => true, 'checker' => array('func' => 'length', 'params' => array(3, 128), 'error' => _t('_td_err_incorrect_length')), 'value' => $aInfo['medTitle']), 'tags' => array('type' => 'text', 'name' => 'medTags', 'caption' => _t('_Tags'), 'info' => _t('_Tags_desc'), 'value' => $aInfo['medTags']), 'description' => array('type' => 'textarea', 'name' => 'medDesc', 'caption' => _t('_Description'), 'value' => $aInfo['medDesc']), 'categories' => $aCategories, 'AllowDownload' => $aAllowDownload, 'fileId' => array('type' => 'hidden', 'name' => 'fileId', 'value' => $iFileId), 'medProfId' => array('type' => 'hidden', 'name' => 'medProfId', 'value' => $this->_iProfileId), 'do_submit' => array('type' => 'hidden', 'name' => 'do_submit', 'value' => 1), 'submit' => array('type' => 'submit', 'name' => 'submit_press', 'value' => _t('_Submit'), 'colspan' => true)));
         $oForm = new BxTemplFormView($aForm);
         $oForm->initChecker($aInfo);
         if ($oForm->isSubmittedAndValid()) {
             $aValues = array();
             array_pop($aManageArray);
             foreach ($aManageArray as $sKey) {
                 if ($sKey != 'Categories') {
                     $aValues[$sKey] = $_POST[$sKey];
                 } else {
                     $aValues[$sKey] = implode(CATEGORIES_DIVIDER, $_POST[$sKey]);
                 }
             }
             if ($this->_oDb->updateData($iFileId, $aValues)) {
                 $sType = $this->_oConfig->getMainPrefix();
                 bx_import('BxDolCategories');
                 $oTag = new BxDolTags();
                 $oTag->reparseObjTags($sType, $iFileId);
                 $oCateg = new BxDolCategories();
                 $oCateg->reparseObjTags($sType, $iFileId);
                 $sCode = $GLOBALS['oFunctions']->msgBox(_t($sLangPref . '_save_success'), 3, 'window.location="' . $sUrlPref . 'view/' . $aInfo['medUri'] . '";');
             } else {
                 $sCode = $GLOBALS['oFunctions']->msgBox(_t('_sys_save_nothing'));
             }
         } else {
             $sCode = $this->_oTemplate->parseHtmlByName('default_padding.html', array('content' => $oForm->getCode()));
             $sCode = $this->_oTemplate->parseHtmlByName('popup.html', array('title' => $aInfo['medTitle'], 'content' => $sCode));
             $sCode = $GLOBALS['oFunctions']->transBox($sCode, TRUE);
         }
     }
     header('Content-type:text/html;charset=utf-8');
     echo $sCode;
     exit;
 }
Esempio n. 8
0
 /**
  * Function will edit poll's information ;
  *
  * @param   : $iPollId       (integer) - poll's Id ;
  * @param   : $sPollQuestion (string)  - poll's qiestion ;
  * @param   : $sPollAnswers  (string)  - poll's answers list ;
  * @param   : $bActive       (boolean) - is active or not ;
  * @param   : $bApprove      (boolean) - approve or not ;
  * @return  : (integer) - number of affected rows ;
  */
 function editPoll($iPollId, $sPollQuestion, $sPollAnswers, $sCategory, $bActive = true, $bApprove = false, $sTags = null, $iCommentGroupValue = 3, $iVoteGroupValue = 3, $iViewGroupValue = 3)
 {
     if (!$sPollQuestion or !$sPollAnswers) {
         $this->sActionAnswer = MsgBox(POLL_EMPTY_FIELDS);
     } else {
         // check poll's owner Id;
         $aPoolInfo = $this->_oDb->getPollInfo($iPollId);
         if ($this->aPollSettings['admin_mode'] or $this->aPollSettings['member_id'] and $aPoolInfo[0]['id_profile'] == $this->aPollSettings['member_id']) {
             $aPoolInfo = array('question' => $sPollQuestion, 'answers' => $sPollAnswers, 'status' => $bActive ? 'active' : null, 'Id' => $iPollId, 'tags' => $sTags, 'allow_comment' => $iCommentGroupValue, 'allow_vote' => $iVoteGroupValue, 'category' => $sCategory, 'allow_view' => $iViewGroupValue);
             if ($this->aPollSettings['admin_mode']) {
                 $aPoolInfo['approve'] = $bApprove ? true : false;
             }
             $this->_oDb->editPoll($aPoolInfo);
             $this->sActionAnswer = MsgBox(POLL_EDITED);
             // create system event
             $oZ = new BxDolAlerts('bx_poll', 'edit', $iPollId);
             $oZ->alert();
             // reparse poll's tags;
             $oTag = new BxDolTags();
             $oTag->reparseObjTags('bx_poll', $iPollId);
             $oCateg = new BxDolCategories();
             $oCateg->reparseObjTags('bx_poll', $iPollId);
         } else {
             $this->sActionAnswer = MsgBox(POLL_NOT_ALLOW);
         }
     }
 }
Esempio n. 9
0
 /**
  * Fired when post status is changed to approved or disapproved
  */
 function onPostApproveDisapprove($iBPostID, $isApprove)
 {
     $aPostInfo = $this->_oDb->getPostInfo($iBPostID);
     if (!$aPostInfo) {
         return;
     }
     //reparse tags
     bx_import('BxDolTags');
     $oTags = new BxDolTags();
     $oTags->reparseObjTags('blog', $iBPostID);
     //reparse categories
     bx_import('BxDolCategories');
     $oCategories = new BxDolCategories($aPostInfo['OwnerID']);
     $oCategories->reparseObjTags('bx_blogs', $iBPostID);
     $oZ = new BxDolAlerts('bx_blogs', $isApprove ? 'approve' : 'disapprove', $iBPostID, $this->_iVisitorID);
     $oZ->alert();
 }
Esempio n. 10
0
 function deletePoll($iId)
 {
     $aPoll = $this->_oDb->getPollInfo($iId);
     if (empty($aPoll) || !is_array($aPoll)) {
         return false;
     }
     $aPoll = array_shift($aPoll);
     if (!isLogged() || !isAdmin() && $aPoll['id_profile'] != getLoggedId()) {
         return false;
     }
     $this->_oDb->deletePoll($iId);
     $oTag = new BxDolTags();
     $oTag->reparseObjTags('bx_poll', $iId);
     $oCateg = new BxDolCategories();
     $oCateg->reparseObjTags('bx_poll', $iId);
     //delete all subscriptions
     $oSubscription = BxDolSubscription::getInstance();
     $oSubscription->unsubscribe(array('type' => 'object_id', 'unit' => 'bx_poll', 'object_id' => $iId));
     // create system event
     $oZ = new BxDolAlerts('bx_poll', 'delete_poll', $iId);
     $oZ->alert();
     return true;
 }
Esempio n. 11
0
 function insertSharedMediaToDb($sExt, $aFileInfo)
 {
     if (getParam('bx_files_activation') == 'on') {
         $bAutoActivate = true;
         $sStatus = 'approved';
     } else {
         $bAutoActivate = false;
         $sStatus = 'pending';
     }
     $sFileTitle = addslashes($aFileInfo['medTitle']);
     $sFileDesc = addslashes($aFileInfo['medDesc']);
     $sFileTags = addslashes($aFileInfo['medTags']);
     $iAllowDownload = (int) $aFileInfo['AllowDownload'];
     $sCategory = implode(CATEGORIES_DIVIDER, $aFileInfo['Categories']);
     $sAlbum = isset($aFileInfo['album']) ? $aFileInfo['album'] : getParam('sys_album_default_name');
     $sMedUri = uriGenerate($sFileTitle, $this->oModule->_oDb->sFileTable, $this->oModule->_oDb->aFileFields['medUri']);
     $sDimension = (int) $aFileInfo['medSize'];
     $sExtDb = trim($sExt, '.');
     $sCurTime = time();
     $iInsertedID = $this->oModule->_oDb->insertData(array('medProfId' => $this->_iOwnerId, 'medExt' => $sExtDb, 'medTitle' => $sFileTitle, 'medUri' => $sMedUri, 'medDesc' => $sFileDesc, 'medTags' => $sFileTags, 'Categories' => $sCategory, 'medSize' => $sDimension, 'Approved' => $sStatus, 'medDate' => $sCurTime, 'AllowDownload' => $iAllowDownload));
     if (0 < $iInsertedID) {
         $oTag = new BxDolTags();
         $oTag->reparseObjTags('bx_files', $iInsertedID);
         $oCateg = new BxDolCategories();
         $oCateg->reparseObjTags('bx_files', $iInsertedID);
         $this->addObjectToAlbum($this->oModule->oAlbums, $sAlbum, $iInsertedID, $bAutoActivate);
         return $iInsertedID;
     } else {
         return 0;
     }
 }
 function showFinishPage($iEntryId, $sUri, $sTitle, $sStatus)
 {
     global $site;
     if ($iEntryId) {
         if ($sStatus == 'approved') {
             bx_import('BxDolTags');
             $o = new BxDolTags();
             $o->reparseObjTags('ml_clonetwo', $iEntryId);
             $iEntryId = (int) $iEntryId;
             bx_import('BxDolCategories');
             $o = new BxDolCategories();
             $o->reparseObjTags('ml_clonetwo', $iEntryId);
         }
         $sTitle = addslashes($sTitle);
         db_res("INSERT INTO `ml_clonetwo_forum` SET `forum_uri` = '{$sUri}', `cat_id` = 1, `forum_title` = '{$sTitle}', `forum_desc` = '" . getNickName($this->_iProfileId) . "', `forum_last` = UNIX_TIMESTAMP(), `forum_type` = 'public', `entry_id` = '{$iEntryId}'");
         header("location:{$site['url']}m/clonetwo/view/{$sUri}");
         exit;
     }
 }
Esempio n. 13
0
 function deletePoll($iId)
 {
     $aPoll = $this->_oDb->getPollInfo($iId);
     if (empty($aPoll) || !is_array($aPoll)) {
         return false;
     }
     $aPoll = array_shift($aPoll);
     if (!isLogged() || !isAdmin() && $aPoll['id_profile'] != getLoggedId()) {
         return false;
     }
     $this->_oDb->deletePoll($iId);
     $oTag = new BxDolTags();
     $oTag->reparseObjTags('bx_poll', $iId);
     $oCateg = new BxDolCategories();
     $oCateg->reparseObjTags('bx_poll', $iId);
     // create system event
     $oZ = new BxDolAlerts('bx_poll', 'delete_poll', $iId);
     $oZ->alert();
     return true;
 }
Esempio n. 14
0
    /**
     * Generate Form for NewPost/EditPost
     *
     * @param $iPostID - Post ID
     * @return HTML presentation of data
     */
    function AddNewPostForm($iPostID = 0, $bBox = true)
    {
        $this->CheckLogged();
        if ($iPostID == 0) {
            if (!$this->isAllowedPostAdd()) {
                return $this->_oTemplate->displayAccessDenied();
            }
        } else {
            $iOwnerID = (int) $this->_oDb->getPostOwnerByID($iPostID);
            if (!$this->isAllowedPostEdit($iOwnerID)) {
                return $this->_oTemplate->displayAccessDenied();
            }
        }
        $sPostCaptionC = _t('_Title');
        $sPostTextC = _t('_Post') . ' ' . _t('_Text');
        $sAssociatedImageC = _t('_associated_image');
        $sAddBlogC = $iPostID ? _t('_Submit') : _t('_Add Post');
        $sTagsC = _t('_Tags');
        $sNewPostC = _t('_New Post');
        $sEditPostC = _t('_bx_blog_Edit_post');
        $sDelImgC = _t('_Delete image');
        $sErrorC = _t('_Error Occured');
        $sCaptionErrorC = _t('_bx_blog_Caption_error');
        $sTextErrorC = _t('_bx_blog_Text_error');
        $sTagsInfoC = _t('_sys_tags_note');
        $sLink = $this->genBlogFormUrl();
        $sAddingForm = '';
        $oCategories = new BxDolCategories();
        $oCategories->getTagObjectConfig();
        $aAllowView = $this->oPrivacy->getGroupChooser($this->_iVisitorID, 'bx_blogs', 'view', array(), _t('_bx_blog_privacy_view'));
        $aAllowRate = $this->oPrivacy->getGroupChooser($this->_iVisitorID, 'bx_blogs', 'rate', array(), _t('_bx_blog_privacy_rate'));
        $aAllowComment = $this->oPrivacy->getGroupChooser($this->_iVisitorID, 'bx_blogs', 'comment', array(), _t('_bx_blog_privacy_comment'));
        $sAction = $iPostID == 0 ? 'new_post' : 'edit_post';
        //adding form
        $aForm = array('form_attrs' => array('name' => 'CreateBlogPostForm', 'action' => $sLink, 'method' => 'post', 'enctype' => 'multipart/form-data'), 'params' => array('db' => array('table' => $this->_oConfig->sSQLPostsTable, 'key' => 'PostID', 'submit_name' => 'add_button')), 'inputs' => array('PostCaption' => array('type' => 'text', 'name' => 'PostCaption', 'caption' => $sPostCaptionC, 'required' => true, 'checker' => array('func' => 'length', 'params' => array(3, 255), 'error' => $sCaptionErrorC), 'db' => array('pass' => 'Xss')), 'Tags' => array('type' => 'text', 'name' => 'Tags', 'caption' => $sTagsC, 'info' => $sTagsInfoC, 'required' => false, 'db' => array('pass' => 'Xss')), 'PostText' => array('type' => 'textarea', 'html' => 2, 'name' => 'PostText', 'caption' => $sPostTextC, 'required' => true, 'checker' => array('func' => 'length', 'params' => array(3, 65535), 'error' => $sTextErrorC), 'db' => array('pass' => 'XssHtml')), 'Categories' => $oCategories->getGroupChooser('bx_blogs', $this->_iVisitorID, true), 'File' => array('type' => 'file', 'name' => 'BlogPic[]', 'caption' => $sAssociatedImageC), 'AssociatedImage' => array('type' => 'hidden'), 'allowView' => $aAllowView, 'allowRate' => $aAllowRate, 'allowComment' => $aAllowComment, 'hidden_action' => array('type' => 'hidden', 'name' => 'action', 'value' => $sAction), 'add_button' => array('type' => 'submit', 'name' => 'add_button', 'value' => $sAddBlogC)));
        if ($iPostID > 0) {
            $aBlogPost = $this->_oDb->getJustPostInfo($iPostID);
            $sPostCaption = $aBlogPost['PostCaption'];
            $sPostText = $aBlogPost['PostText'];
            $sPostTags = $aBlogPost['Tags'];
            $sPostPicture = $aBlogPost['PostPhoto'];
            if ($sPostPicture != '') {
                $sBlogsImagesUrl = BX_BLOGS_IMAGES_URL;
                $sPostPictureTag = <<<EOF
<div class="marg_both_left" id="edit_post_image_{$iPostID}">
\t<img alt="" style="width: 110px; height: 110px; background-image: url({$sBlogsImagesUrl}big_{$sPostPicture});" src="{$sSpacerName}" />
\t<a href="{$sLink}?action=del_img&amp;post_id={$iPostID}" onclick="BlogpostImageDelete('{$sLink}?action=del_img&post_id={$iPostID}&mode=ajax', 'edit_post_image_{$iPostID}');return false;" >{$sDelImgC}</a>
</div>
EOF;
                $aForm['inputs']['AssociatedImage']['type'] = 'custom';
                $aForm['inputs']['AssociatedImage']['content'] = $sPostPictureTag;
                $aForm['inputs']['AssociatedImage']['caption'] = $sAssociatedImageC;
            }
            $aCategories = explode(';', $aBlogPost['Categories']);
            $aForm['inputs']['PostCaption']['value'] = $sPostCaption;
            $aForm['inputs']['PostText']['value'] = $sPostText;
            $aForm['inputs']['Tags']['value'] = $sPostTags;
            $aForm['inputs']['Categories']['value'] = $aCategories;
            $aForm['inputs']['allowView']['value'] = $aBlogPost['allowView'];
            $aForm['inputs']['allowRate']['value'] = $aBlogPost['allowRate'];
            $aForm['inputs']['allowComment']['value'] = $aBlogPost['allowComment'];
            $aForm['inputs']['hidden_postid'] = array('type' => 'hidden', 'name' => 'EditPostID', 'value' => $iPostID);
            if ($aBlogPost['PostPhoto'] != '' && file_exists(BX_BLOGS_IMAGES_PATH . 'small_' . $aBlogPost['PostPhoto'])) {
                $GLOBALS['oTopMenu']->setCustomSubIconUrl(BX_BLOGS_IMAGES_URL . 'small_' . $aBlogPost['PostPhoto']);
            } else {
                $GLOBALS['oTopMenu']->setCustomSubIconUrl($this->_oTemplate->getIconUrl('bx_blogs.png'));
            }
            $GLOBALS['oTopMenu']->setCustomSubHeader($sPostCaption);
        }
        if (empty($aForm['inputs']['allowView']['value']) || !$aForm['inputs']['allowView']['value']) {
            $aForm['inputs']['allowView']['value'] = BX_DOL_PG_ALL;
        }
        if (empty($aForm['inputs']['allowRate']['value']) || !$aForm['inputs']['allowRate']['value']) {
            $aForm['inputs']['allowRate']['value'] = BX_DOL_PG_ALL;
        }
        if (empty($aForm['inputs']['allowComment']['value']) || !$aForm['inputs']['allowComment']['value']) {
            $aForm['inputs']['allowComment']['value'] = BX_DOL_PG_ALL;
        }
        $oForm = new BxTemplFormView($aForm);
        $oForm->initChecker();
        if ($oForm->isSubmittedAndValid()) {
            $this->CheckLogged();
            $iOwnID = $this->_iVisitorID;
            $sCurTime = time();
            $sPostUri = uriGenerate(bx_get('PostCaption'), $this->_oConfig->sSQLPostsTable, 'PostUri');
            $sAutoApprovalVal = getParam('blogAutoApproval') == 'on' ? "approval" : "disapproval";
            /*$aCategories = array();
            		foreach (bx_get('Category') as $sKey => $sVal) {
            			if ($sVal != '') {
            				$aCategories[] = process_db_input($sVal);
            			}
            		}
            		$sCategories = implode(CATEGORIES_DIVIDER, $aCategories);*/
            $aValsAdd = array('PostDate' => $sCurTime, 'PostStatus' => $sAutoApprovalVal);
            if ($iPostID == 0) {
                $aValsAdd['OwnerID'] = $iOwnID;
                $aValsAdd['PostUri'] = $sPostUri;
            }
            $iBlogPostID = -1;
            if ($iPostID > 0) {
                unset($aValsAdd['PostDate']);
                $oForm->update($iPostID, $aValsAdd);
                $this->isAllowedPostEdit($iOwnerID, true);
                $iBlogPostID = $iPostID;
            } else {
                $iBlogPostID = $oForm->insert($aValsAdd);
                $this->isAllowedPostAdd(true);
            }
            if ($iBlogPostID) {
                $this->iLastPostedPostID = $iBlogPostID;
                if ($_FILES) {
                    for ($i = 0; $i < count($_FILES['BlogPic']['tmp_name']); $i++) {
                        if ($_FILES['BlogPic']['error'][$i]) {
                            continue;
                        }
                        if (0 < $_FILES['BlogPic']['size'][$i] && 0 < strlen($_FILES['BlogPic']['name'][$i]) && 0 < $iBlogPostID) {
                            $sTmpFile = $_FILES['BlogPic']['tmp_name'][$i];
                            if (file_exists($sTmpFile) == false) {
                                break;
                            }
                            $aSize = getimagesize($sTmpFile);
                            if (!$aSize) {
                                @unlink($sTmpFile);
                                break;
                            }
                            switch ($aSize[2]) {
                                case IMAGETYPE_JPEG:
                                case IMAGETYPE_GIF:
                                case IMAGETYPE_PNG:
                                    $sOriginalFilename = $_FILES['BlogPic']['name'][$i];
                                    $sExt = strrchr($sOriginalFilename, '.');
                                    $sFileName = 'blog_' . $iBlogPostID . '_' . $i;
                                    @unlink($sFileName);
                                    move_uploaded_file($sTmpFile, BX_BLOGS_IMAGES_PATH . $sFileName . $sExt);
                                    @unlink($sTmpFile);
                                    if (strlen($sExt)) {
                                        imageResize(BX_BLOGS_IMAGES_PATH . $sFileName . $sExt, BX_BLOGS_IMAGES_PATH . 'small_' . $sFileName . $sExt, $this->iIconSize / 1, $this->iIconSize / 1);
                                        imageResize(BX_BLOGS_IMAGES_PATH . $sFileName . $sExt, BX_BLOGS_IMAGES_PATH . 'big_' . $sFileName . $sExt, $this->iThumbSize, $this->iThumbSize);
                                        imageResize(BX_BLOGS_IMAGES_PATH . $sFileName . $sExt, BX_BLOGS_IMAGES_PATH . 'orig_' . $sFileName . $sExt, $this->iImgSize, $this->iImgSize);
                                        chmod(BX_BLOGS_IMAGES_PATH . 'small_' . $sFileName . $sExt, 0644);
                                        chmod(BX_BLOGS_IMAGES_PATH . 'big_' . $sFileName . $sExt, 0644);
                                        chmod(BX_BLOGS_IMAGES_PATH . 'orig_' . $sFileName . $sExt, 0644);
                                        $this->_oDb->performUpdatePostWithPhoto($iBlogPostID, $sFileName . $sExt);
                                        @unlink(BX_BLOGS_IMAGES_PATH . $sFileName . $sExt);
                                    }
                                    break;
                                default:
                                    @unlink($sTempFileName);
                                    return false;
                            }
                        }
                    }
                }
                //reparse tags
                bx_import('BxDolTags');
                $oTags = new BxDolTags();
                $oTags->reparseObjTags('blog', $iBlogPostID);
                //reparse categories
                $oCategories = new BxDolCategories();
                $oCategories->reparseObjTags('bx_blogs', $iBlogPostID);
                $sAlertAction = $iPostID == 0 ? 'create' : 'edit_post';
                bx_import('BxDolAlerts');
                $oZ = new BxDolAlerts('bx_blogs', $sAlertAction, $iBlogPostID, $this->_iVisitorID);
                $oZ->alert();
                return $this->GenPostPage($iBlogPostID);
            } else {
                return MsgBox($sErrorC);
            }
        } else {
            $sAddingForm = $oForm->getCode();
        }
        $sCaption = $iPostID ? $sEditPostC : $sNewPostC;
        $sAddingFormVal = '<div class="blogs-view usualTextMarg">' . $sAddingForm . '</div>';
        return $bBox ? DesignBoxContent($sCaption, '<div class="blogs-view usualTextMarg">' . $sAddingForm . '</div>', 1) : $sAddingFormVal;
    }
Esempio n. 15
0
 function adminDisapproveFile($iFileId)
 {
     $iFileId = (int) $iFileId;
     $aInfo = $this->_oDb->getFileInfo(array('fileId' => $iFileId), true, array('Approved'));
     $this->_oDb->disapproveFile($iFileId);
     if ($aInfo['Approved'] == 'approved') {
         $this->oAlbums->updateObjCounterById($iFileId, false);
         bx_import('BxDolCategories');
         //tags & categories parsing
         $oTag = new BxDolTags();
         $oTag->reparseObjTags($this->_oConfig->getMainPrefix(), $iFileId);
         $oCateg = new BxDolCategories();
         $oCateg->reparseObjTags($this->_oConfig->getMainPrefix(), $iFileId);
     }
 }
Esempio n. 16
0
 function getEditForm($aValues, $aAddFields = array())
 {
     $oCategories = new BxDolCategories();
     if (isset($this->_aForm['inputs']['categories'])) {
         //--- convert post form to edit one ---//
         $this->_aForm['inputs']['categories'] = $oCategories->getGroupChooser($this->_oModule->_oConfig->getCategoriesSystemName(), $this->_iOwnerId, true, $aValues['categories']);
     }
     if (!empty($aValues) && is_array($aValues)) {
         foreach ($aValues as $sKey => $sValue) {
             if (array_key_exists($sKey, $this->_aForm['inputs'])) {
                 if ($this->_aForm['inputs'][$sKey]['type'] == 'checkbox') {
                     $this->_aForm['inputs'][$sKey]['checked'] = (int) $sValue == 1 ? true : false;
                 } else {
                     if ($this->_aForm['inputs'][$sKey]['type'] == 'select_box' && $this->_aForm['inputs'][$sKey]['name'] == 'Categories') {
                         $aCategories = preg_split('/[' . $oCategories->sTagsDivider . ']/', $sValue, 0, PREG_SPLIT_NO_EMPTY);
                         $this->_aForm['inputs'][$sKey]['value'] = $aCategories;
                     } else {
                         $this->_aForm['inputs'][$sKey]['value'] = $sValue;
                     }
                 }
             }
         }
         unset($this->_aForm['inputs']['author_id']);
         $this->_aForm['inputs']['id'] = array('type' => 'hidden', 'name' => 'id', 'value' => $aValues['id'], 'db' => array('pass' => 'Int'));
         $this->_aForm['inputs']['post']['value'] = _t("_td_edit");
     }
     $oForm = new BxTemplFormView($this->_aForm);
     $oForm->initChecker();
     if ($oForm->isSubmittedAndValid()) {
         $iDateNow = mktime();
         $iDatePublish = $oForm->getCleanValue('when');
         if ($iDatePublish > $iDateNow) {
             $iStatus = BX_TD_STATUS_PENDING;
         } else {
             if ($iDatePublish <= $iDateNow && $this->_oModule->_oConfig->isAutoapprove()) {
                 $iStatus = BX_TD_STATUS_ACTIVE;
             } else {
                 $iStatus = BX_TD_STATUS_INACTIVE;
             }
         }
         $aDefFields = array('date' => $iDateNow, 'status' => $iStatus);
         $oForm->update($aValues['id'], array_merge($aDefFields, $aAddFields));
         //--- 'System' -> Edit for Alerts Engine ---//
         bx_import('BxDolAlerts');
         $oAlert = new BxDolAlerts($this->_oModule->_oConfig->getAlertsSystemName(), 'edit', $aValues['id'], $this->_iOwnerId);
         $oAlert->alert();
         //--- 'System' -> Edit for Alerts Engine ---//
         //--- Reparse Global Tags ---//
         $oTags = new BxDolTags();
         $oTags->reparseObjTags($this->_oModule->_oConfig->getTagsSystemName(), $aValues['id']);
         //--- Reparse Global Tags ---//
         //--- Reparse Global Categories ---//
         $oCategories->reparseObjTags($this->_oModule->_oConfig->getCategoriesSystemName(), $aValues['id']);
         //--- Reparse Global Categories ---//
         header('Location: ' . $oForm->aFormAttrs['action']);
     } else {
         return $oForm->getCode();
     }
 }
Esempio n. 17
0
 function initMusicFile($iMusicID, $sTitle, $sCategories, $sTags, $sDesc)
 {
     $sMedUri = uriGenerate($sTitle, $this->oModule->_oDb->sFileTable, $this->oModule->_oDb->aFileFields['medUri']);
     $bRes = $this->oModule->_oDb->updateData($iMusicID, array('Categories' => $sCategories, 'medTitle' => $sTitle, 'medTags' => $sTags, 'medDesc' => $sDesc, 'medUri' => $sMedUri));
     $oTag = new BxDolTags();
     $oTag->reparseObjTags('bx_sounds', $iMusicID);
     $oCateg = new BxDolCategories();
     $oCateg->reparseObjTags('bx_sounds', $iMusicID);
     $bRes = true;
     //TODO chech why if false
     return $bRes;
 }
 function transferContent()
 {
     $sSql = "SELECT \r\n        \t\t\t`ta`.`ArticlesID` AS `id`,\r\n        \t\t\t`ta`.`ownerID` AS `author_id`,\r\n        \t\t\t`ta`.`Title` AS `caption`,\r\n        \t\t\t`ta`.`Text` AS `content`,\r\n        \t\t\t`ta`.`ArticleUri` AS `uri`,\r\n        \t\t\t'' AS `tags`,        \t\t\t\r\n        \t\t\t`tac`.`CategoryName` AS `categories`,\r\n        \t\t\t'0' AS `comment`,\r\n        \t\t\t'0' AS `vote`,\r\n        \t\t\tUNIX_TIMESTAMP(`Date`) AS `date`,\r\n        \t\t\t'0' AS `status`,\r\n        \t\t\t'0' AS `featured`,\r\n        \t\t\t'0' AS `rate`,\r\n        \t\t\t'0' AS `rate_count`,\r\n        \t\t\t'0' AS `view_count`,\r\n        \t\t\t'0' AS `cmts_count`\r\n        \t\tFROM `Articles` AS `ta` \r\n        \t\tLEFT JOIN `ArticlesCategory` AS `tac` ON `ta`.`CategoryID`=`tac`.`CategoryID`\r\n        \t\tORDER BY `Date` ASC";
     $rResult = mysql_query($sSql, $this->rOldDb);
     $iCount = mysql_num_rows($rResult);
     $oCategories = new BxDolCategories();
     while ($aItem = mysql_fetch_assoc($rResult)) {
         $aItem['uri'] = uriGenerate($aItem['caption'], $this->oDolModule->_oDb->getPrefix() . 'entries', 'uri');
         if ($this->existsItem($aItem['id'], $aItem['uri'])) {
             $this->setResultStatus('Duplicate data. Article with similar info already exists.');
             return MIGRATION_FAILED;
         }
         $sSql = "INSERT INTO `" . $this->oDolModule->_oDb->getPrefix() . "entries` SET";
         foreach ($aItem as $sKey => $sValue) {
             $sSql .= " `" . $sKey . "`='" . $this->oMigrationModule->_oDb->escape($sValue) . "',";
         }
         $iResult = (int) $this->oDolModule->_oDb->query(substr($sSql, 0, -1));
         if ($iResult <= 0) {
             $this->setResultStatus('Database error. Cannot insert item in the database.');
             return MIGRATION_FAILED;
         }
         $oCategories->reparseObjTags($this->_sType, $this->oDolModule->_oDb->lastId());
     }
     $this->setResultStatus('The transfer was successfully completed. (' . $iCount . ' items)');
     return MIGRATION_SUCCESSFUL;
 }
 function insertSharedMediaToDb($sExt, $aFileInfo, $iAuthorId = 0, $aExtraData = array())
 {
     if (!$iAuthorId) {
         $iAuthorId = $this->_iOwnerId;
     }
     if (getParam($this->oModule->_oConfig->aGlParams['auto_activation']) == 'on') {
         $bAutoActivate = true;
         $sStatus = 'approved';
     } else {
         $bAutoActivate = false;
         $sStatus = 'pending';
     }
     $sFileTitle = $aFileInfo['medTitle'];
     $sFileDesc = $aFileInfo['medDesc'];
     $sFileTags = $aFileInfo['medTags'];
     $sCategory = implode(CATEGORIES_DIVIDER, $aFileInfo['Categories']);
     $sDimension = isset($aFileInfo['dimension']) ? $aFileInfo['dimension'] : (int) $aFileInfo['medSize'];
     $sAlbum = mb_strlen($_POST['extra_param_album']) > 0 ? $_POST['extra_param_album'] : getParam('sys_album_default_name');
     $sAlbum = isset($aFileInfo['album']) ? $aFileInfo['album'] : $sAlbum;
     $sMedUri = uriGenerate($sFileTitle, $this->oModule->_oDb->sFileTable, $this->oModule->_oDb->aFileFields['medUri']);
     $sExtDb = trim($sExt, '.');
     $sCurTime = time();
     $aData = array('medProfId' => $iAuthorId, 'medExt' => $sExtDb, 'medTitle' => $sFileTitle, 'medUri' => $sMedUri, 'medDesc' => $sFileDesc, 'medTags' => $sFileTags, 'Categories' => $sCategory, 'medSize' => $sDimension, 'Approved' => $sStatus, 'medDate' => $sCurTime);
     $aData = array_merge($aData, $aExtraData);
     $iInsertedID = $this->oModule->_oDb->insertData($aData);
     if (0 < $iInsertedID) {
         $oTag = new BxDolTags();
         $oTag->reparseObjTags($this->oModule->_oConfig->sPrefix, $iInsertedID);
         $oCateg = new BxDolCategories();
         $oCateg->reparseObjTags($this->oModule->_oConfig->sPrefix, $iInsertedID);
         $aAlbumParams = isset($aFileInfo['albumPrivacy']) ? array('privacy' => $aFileInfo['albumPrivacy']) : array();
         $this->addObjectToAlbum($this->oModule->oAlbums, $sAlbum, $iInsertedID, $bAutoActivate, $iAuthorId, $aAlbumParams);
         return $iInsertedID;
     }
     return 0;
 }
Esempio n. 20
0
 function actionEdit($iFileId)
 {
     $iFileId = (int) $iFileId > 0 ? (int) $iFileId : (int) $_POST['fileId'];
     if ($iFileId == 0) {
         exit;
     }
     $this->aPageTmpl['name_index'] = 44;
     $sJsCode = '<script language="javascript">window.setTimeout(function () { window.parent.opener.location = window.parent.opener.location; window.parent.close(); }, 3000); </script>';
     $aManageArray = array('medTitle', 'medTags', 'medDesc', 'medProfId', 'Categories', 'AllowDownload');
     $aInfo = $this->_oDb->getFileInfo(array('fileId' => $iFileId), false, $aManageArray);
     if (!$this->isAllowedEdit($aInfo)) {
         $sCode = MsgBox(_t('_' . $this->_oConfig->getMainPrefix() . '_access_denied')) . $sJsCode;
     } else {
         $oCategories = new BxDolCategories();
         $oCategories->getTagObjectConfig();
         $aCategories = $oCategories->getGroupChooser($this->_oConfig->getMainPrefix(), $this->_iProfileId, true);
         $aCategories['value'] = explode(CATEGORIES_DIVIDER, $aInfo['Categories']);
         $aAllowDownload = $this->oPrivacy->getGroupChooser($this->_iProfileId, $this->_oConfig->getUri(), 'download');
         $aAllowDownload['value'] = $aInfo['AllowDownload'];
         $aForm = array('form_attrs' => array('id' => $this->_oConfig->getMainPrefix() . '_upload_form', 'method' => 'post', 'action' => BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'edit/' . $iFileId), 'params' => array('db' => array('submit_name' => 'submit'), 'checker_helper' => 'BxSupportCheckerHelper'), 'inputs' => array('header' => array('type' => 'block_header', 'caption' => _t('_Info')), 'title' => array('type' => 'text', 'name' => 'medTitle', 'caption' => _t('_Title'), 'required' => true, 'value' => $aInfo['medTitle'], 'checker' => array('func' => 'length', 'params' => array(3, 128), 'error' => _t('_td_err_incorrect_length'))), 'tags' => array('type' => 'text', 'name' => 'medTags', 'caption' => _t('_Tags'), 'info' => _t('_Tags_desc'), 'value' => $aInfo['medTags']), 'description' => array('type' => 'textarea', 'name' => 'medDesc', 'caption' => _t('_Description'), 'required' => true, 'value' => $aInfo['medDesc'], 'checker' => array('func' => 'length', 'params' => array(3, 65536), 'error' => _t('_td_err_incorrect_length'))), 'categories' => $aCategories, 'AllowDownload' => $aAllowDownload, 'fileId' => array('type' => 'hidden', 'name' => 'fileId', 'value' => $iFileId), 'medProfId' => array('type' => 'hidden', 'name' => 'medProfId', 'value' => $this->_iProfileId), 'submit' => array('type' => 'submit', 'name' => 'submit', 'value' => _t('_Submit'), 'colspan' => true)));
         $oForm = new BxTemplFormView($aForm);
         $oForm->initChecker();
         if ($oForm->isSubmittedAndValid()) {
             $aValues = array();
             foreach ($aManageArray as $sKey) {
                 if ($sKey != 'Categories') {
                     $aValues[$sKey] = $_POST[$sKey];
                 } else {
                     $aValues[$sKey] = implode(CATEGORIES_DIVIDER, $_POST[$sKey]);
                 }
             }
             if ($this->_oDb->updateData($iFileId, $aValues)) {
                 $sType = $this->_oConfig->getMainPrefix();
                 bx_import('BxDolCategories');
                 $oTag = new BxDolTags();
                 $oTag->reparseObjTags($sType, $iFileId);
                 $oCateg = new BxDolCategories();
                 $oCateg->reparseObjTags($sType, $iFileId);
                 $sCode = MsgBox(_t('_' . $this->_oConfig->getMainPrefix() . '_save_success')) . $sJsCode;
             }
         } else {
             $sCode = $oForm->getCode();
             $this->aPageTmpl['css_name'] = array('forms_adv.css', 'explanation.css');
         }
     }
     $this->aPageTmpl['header'] = _t('_Edit');
     $this->_oTemplate->pageCode($this->aPageTmpl, array('page_main_code' => $sCode));
 }