8 require_once(CH_DIRECTORY_PATH_CLASSES .
'ChWsbPageView.php');
9 require_once(CH_DIRECTORY_PATH_CLASSES .
'ChWsbAlbums.php');
10 require_once(
'ChFilesSearch.php');
27 'blocks' => array(
'adminShort'),
31 'blocks' => array(
'add',
'my'),
35 'blocks' => array(
'adminFull',
'my'),
38 'main_objects' => array(
39 'blocks' => array(
'adminAlbumShort'),
41 'link' =>
'browse/album/'
44 'blocks' => array(
'edit',
'albumObjects'),
48 'blocks' => array(
'organize',
'albumObjects'),
51 'add_objects' => array(
52 'blocks' => array(
'addObjects',
'albumObjects'),
55 'manage_objects' => array(
56 'blocks' => array(
'manageObjects',
'albumObjects'),
59 'manage_objects_disapproved' => array(
60 'blocks' => array(
'manageObjectsDisapproved',
'albumObjects'),
63 'manage_objects_pending' => array(
64 'blocks' => array(
'manageObjectsPending',
'albumObjects'),
71 parent::__construct(
'ch_files_albums_my');
72 $this->oTemplate = $oShared->_oTemplate;
73 $this->oConfig = $oShared->_oConfig;
74 $this->oDb = $oShared->_oDb;
76 $this->aAddParams = $aParams;
78 $this->oAlbum =
new ChWsbAlbums(
'ch_files', $this->iOwnerId);
79 $this->oAlbumPrivacy = $oShared->oAlbumPrivacy;
81 if (isset($this->aSystemBlocks[$this->aAddParams[0]]))
82 $this->aCurrentBlocks = $this->aSystemBlocks[$this->aAddParams[0]];
84 $this->aCurrentBlocks = $this->aSystemBlocks[
'main'];
85 $this->oTemplate->addCss(
'my.css');
87 $this->oSearch->aCurrent[
'restriction'][
'ownerId'] = array(
88 'value' => $this->iOwnerId,
91 'paramName' =>
'ownerId'
94 $oShared->checkDefaultAlbums($this->iOwnerId);
99 return !
empty($this->aCurrentBlocks) ? (int)$this->aCurrentBlocks[
'level'] : 0;
105 if(!in_array(
'my', $this->aCurrentBlocks[
'blocks']))
108 $this->oSearch->clearFilters(array(
'activeStatus',
'allow_view',
'album_status'), array(
'albumsObjects',
'albums'));
109 $this->oSearch->bAdminMode =
false;
110 $this->oSearch->aCurrent[
'view'] =
'full';
112 $this->oSearch->aCurrent[
'restriction'][
'activeStatus'][
'value'] =
'approved';
113 $iPerPage = isset(
$_GET[
'per_page']) ? (int)
$_GET[
'per_page'] : (
int)$this->oConfig->getGlParam(
'number_albums_browse');
114 $iPage = isset(
$_GET[
'page']) ? (int)
$_GET[
'page'] : $this->oSearch->aCurrent[
'paginate'][
'page'];
115 $sCode = $this->oSearch->getAlbumList(
$iPage,
$iPerPage, array(
'owner'=>$this->iOwnerId,
'show_empty' =>
true,
'hide_default' =>
true));
116 $iCount = $this->oSearch->aCurrent[
'paginate'][
'totalAlbumNum'];
119 $aLinkAddon = $this->oSearch->getLinkAddByPrams(array(
'r'));
120 $sLink = $sLinkJs = $sViewAllUrl = CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() .
'albums/my/' . $this->aAddParams[0];
121 if ($this->oConfig->isPermalinkEnabled) {
126 $sViewAllUrl .=
'&';
128 $sLinkJs .= $aLinkAddon[
'params'];
129 $sViewAllUrl .=
'per_page=' . $iCount;
131 'page_url' => $sLink,
135 'on_change_page' =>
'return !loadDynamicBlock(' . $iBoxId .
', \'' . $sLinkJs .
'&page={page}&per_page={per_page}\');',
136 'on_change_per_page' =>
'return !loadDynamicBlock(' . $iBoxId .
', \'' . $sLinkJs .
'&page=1&per_page=\' + this.value);'
138 $sPaginate = $oPaginate->getSimplePaginate($sViewAllUrl);
140 return array(
$sCode, array(), $sPaginate,
false);
145 if(!in_array(
'adminShort', $this->aCurrentBlocks[
'blocks']))
148 $iNumber = $this->oAlbum->getAlbumCount(array(
'owner' => $this->iOwnerId,
'show_empty' =>
true,
'hide_default' =>
true));
149 return array($this->oTemplate->getAdminAlbumShort($iNumber), $this->getTopMenu(
'main'), array());
154 if (in_array(
'adminAlbumShort', $this->aCurrentBlocks[
'blocks'])) {
155 $iNumber = $this->oAlbum->getObjCount(array(
'fileUri' => $this->aAddParams[1],
'owner' => $this->iOwnerId));
156 $sCode = $this->oTemplate->getAdminShort($iNumber, $this->aAddParams[1], $this->aAddParams[3]);
157 $aInfo = $this->oAlbum->getAlbumInfo(array(
'fileUri' => $this->aAddParams[1],
'owner' => $this->iOwnerId));
160 'fileStatCount' =>
_t(
'_sys_album_privacy_me_info'),
161 'fileStatAdd' =>
_t(
'_sys_album_edit_info', CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() .
'albums/my/edit/' . $this->aAddParams[1] .
'/owner/' . $this->aAddParams[3]),
162 'spec_class' =>
'sys_warning_text'
164 $sCode .= $this->oTemplate->parseHtmlByName(
'admin_short.html', $aDraw);
172 if(!in_array(
'adminFull', $this->aCurrentBlocks[
'blocks']))
175 return array($this->
getAdminPart(array(), array(
'section'=>
'manage',
'page_block_id' => $iBoxId)), $this->
getTopMenu(
'manage'), array(),
'');
180 if (!in_array(
'add', $this->aCurrentBlocks[
'blocks']))
183 $aPrivFieldView = $this->oAlbumPrivacy->getGroupChooser($this->iOwnerId, $this->oConfig->getUri(),
'album_view', array(),
_t(
'_' . $this->oConfig->getMainPrefix() .
'_album_view'));
184 $aForm = $this->oTemplate->getAlbumFormAddArray(array(
'allow_view' => $aPrivFieldView));
188 if (
$oForm->isSubmittedAndValid()) {
189 $aFields = array(
'caption',
'location',
'description',
'AllowAlbumView',
'owner');
192 if (isset($_POST[$sValue]))
193 $aData[$sValue] = $_POST[$sValue];
195 $iNewId = $this->oAlbum->addAlbum($aData);
197 $aNew = $this->oAlbum->getAlbumInfo(array(
'fileId' => $iNewId), array(
'Uri'));
198 $sUrlAdd = CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() .
'albums/my/add_objects/' . $aNew[
'Uri'] .
'/owner/' .
getUsername($this->iOwnerId);
199 $sCode =
MsgBox(
_t(
'_' . $this->oConfig->getMainPrefix() .
'_album_save_redirect')) . $this->oTemplate->getJsTimeOutRedirect($sUrlAdd, 3);
208 if(!in_array(
'addObjects', $this->aCurrentBlocks[
'blocks']))
211 $aAlbumInfo = $this->oAlbum->getAlbumInfo(array(
'fileUri' => $this->aAddParams[1],
'owner' => $this->iOwnerId));
212 if($aAlbumInfo[
'Owner'] != $this->iOwnerId)
216 if (!$this->oSearch->oModule->isAllowedAdd()) {
217 $sCode =
MsgBox(
_t(
'_' . $this->oConfig->getMainPrefix() .
'_access_denied'));
219 require_once(
'ChFilesUploader.php');
220 $sLink = CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() .
'albums/my/add_objects/' . rawurlencode($this->aAddParams[1]) .
'/'. $this->aAddParams[2] .
'/' . $this->aAddParams[3];
221 $aMenu = $this->oConfig->getUploaderSwitcher($sLink);
223 $sSubMenu = $this->oTemplate->getExtraSwitcher(
$aMenu,
'_' . $this->oConfig->getMainPrefix() .
'_choose_uploader', $iBoxId);
225 $oUploader->sWorkingFile = $sLink;
226 $sCode = $this->oTemplate->parseHtmlByName(
'default_margin.html', array(
'content' => $oUploader->GenMainAddFilesForm(array(
'album' => $this->aAddParams[1]))));
229 $GLOBALS[
'oTopMenu']->setCustomSubHeader($aAlbumInfo[
'Caption']);
235 if (in_array(
'manageObjects', $this->aCurrentBlocks[
'blocks'])) {
236 return array($this->
getAdminObjectPart(array(
'activeStatus'=>
'approved'), $iBoxId,
true), $this->
getTopMenu(
'manage_objects'), array(),
'');
242 if (in_array(
'manageObjectsDisapproved', $this->aCurrentBlocks[
'blocks'])) {
243 return array($this->
getAdminObjectPart(array(
'activeStatus'=>
'disapproved'), $iBoxId), $this->
getTopMenu(
'manage_objects_disapproved'), array(),
'');
249 if (in_array(
'manageObjectsPending', $this->aCurrentBlocks[
'blocks'])) {
250 return array($this->
getAdminObjectPart(array(
'activeStatus'=>
'pending'), $iBoxId), $this->
getTopMenu(
'manage_objects_pending'), array(),
'');
256 if (!in_array(
'edit', $this->aCurrentBlocks[
'blocks']))
259 $aInfo = $this->oAlbum->getAlbumInfo(array(
'fileUri' => $this->aAddParams[1],
'owner' => $this->iOwnerId));
260 if (
$aInfo[
'Owner'] != $this->iOwnerId)
263 $aPrivFieldView = $this->oAlbumPrivacy->getGroupChooser($this->iOwnerId, $this->oConfig->getUri(),
'album_view', array(),
_t(
'_' . $this->oConfig->getMainPrefix() .
'_album_view'));
264 $aPrivFieldView[
'value'] =
$aInfo[
'AllowAlbumView'];
269 'value' =>
$aInfo[
'Caption']
272 'name' =>
'Location',
273 'value' =>
$aInfo[
'Location']
275 'description' => array(
276 'name' =>
'Description',
277 'value' => strip_tags(
$aInfo[
'Description'])
279 'allow_view' => $aPrivFieldView,
283 'value' => (
int)
$aInfo[
'ID'],
288 'value' => $this->aAddParams[1],
293 'id' => $this->oConfig->getMainPrefix() .
'_upload_form',
295 'action' => $this->oConfig->getBaseUri().
'albums/my/edit/' . strip_tags($this->aAddParams[1] .
'/' . strip_tags($this->aAddParams[2]) .
'/' . strip_tags($this->aAddParams[3]))
298 $aForm = $this->oTemplate->getAlbumFormEditArray($aReInputs, $aReForm);
301 if (
$oForm->isSubmittedAndValid()) {
302 $aFields = array(
'Caption',
'Location',
'Description',
'AllowAlbumView');
305 if (isset($_POST[$sValue]))
306 $aData[$sValue] = $_POST[$sValue];
308 if ($this->oAlbum->updateAlbumById((
int)$_POST[
'ID'], $aData))
309 $sCode =
MsgBox(
_t(
'_ch_' . $this->oConfig->getUri() .
'_album_save_success'));
319 if (!in_array(
'organize', $this->aCurrentBlocks[
'blocks']))
322 $aInfo = $this->oAlbum->getAlbumInfo(array(
'fileUri' => $this->aAddParams[1],
'owner' => $this->iOwnerId));
323 if(
$aInfo[
'Owner'] != $this->iOwnerId)
326 $this->oSearch->clearFilters(array(
'activeStatus',
'allow_view',
'album_status'), array(
'albumsObjects',
'albums',
'icon'));
327 $this->oSearch->bAdminMode =
false;
328 $this->oSearch->aCurrent[
'view'] =
'short';
329 $this->oSearch->aCurrent[
'restriction'][
'album'][
'value'] = $this->aAddParams[1];
330 $this->oSearch->aCurrent[
'restriction'][
'albumType'][
'value'] = $this->oSearch->aCurrent[
'name'];
331 $this->oSearch->aCurrent[
'restriction'][
'ownerId'][
'value'] =
$this->iOwnerId;
332 $this->oSearch->aCurrent[
'sorting'] =
'album_order';
333 $this->oSearch->aCurrent[
'paginate'][
'perPage'] = 1000;
334 $aUnits = $this->oSearch->getSearchData();
335 if($this->oSearch->aCurrent[
'paginate'][
'totalNum'] > 0) {
336 $sMainUrl = CH_WSB_URL_ROOT . $this->oConfig->getBaseUri();
337 foreach ($aUnits
as $aData)
338 $sCode .= $this->oSearch->displaySearchUnit($aData);
341 'action_reverse' => array(
342 'value' =>
_t(
'_' . $this->oConfig->getMainPrefix() .
'_album_organize_reverse'),
345 'onclick' =>
'onclick=\'getHtmlData("unit_area", "' . $sMainUrl .
'album_reverse/' . $this->aAddParams[1] .
'"); return false;\''
348 $sAreaId =
'unit_area';
350 'ch_if:show_class' => array(
353 'content' =>
'ch-def-bc-margin'
356 'main_code_id' => $sAreaId,
359 'manage' => $this->oSearch->showAdminActionsPanel(
'', $aBtns,
'entry',
false,
false),
360 'ch_if:hidden' => array(
361 'condition' =>
false,
365 $sJsCode = $this->oTemplate->parseHtmlByName(
'js_organize.html', array(
367 'unit_area_id' => $sAreaId,
368 'album_name' => $this->aAddParams[1],
369 'add_params' => $this->aAddParams[2] .
'/' . $this->aAddParams[3]
371 $this->oTemplate->addJs(array(
'jquery.ui.core.min.js',
'jquery.ui.widget.min.js',
'jquery.ui.mouse.min.js',
'jquery.ui.sortable.min.js',
'jquery.ui.touch-punch.min.js'));
372 $sCode = $sJsCode . $this->oTemplate->parseHtmlByName(
'manage_form.html',
$aUnit);
382 if(!in_array(
'albumObjects', $this->aCurrentBlocks[
'blocks']))
385 $this->oSearch->clearFilters(array(
'allow_view',
'album_status'), array(
'albumsObjects',
'albums',
'icon'));
386 $this->oSearch->aCurrent[
'sorting'] =
'album_order';
387 $this->oSearch->bAdminMode =
false;
388 $this->oSearch->aCurrent[
'view'] =
'full';
390 $this->oSearch->aCurrent[
'restriction'][
'activeStatus'][
'value'] =
'approved';
391 $this->oSearch->aCurrent[
'restriction'][
'album'][
'value'] = $this->aAddParams[1];
392 $this->oSearch->aCurrent[
'restriction'][
'albumType'][
'value'] = $this->oSearch->aCurrent[
'name'];
393 $this->oSearch->aCurrent[
'restriction'][
'ownerId'][
'value'] =
$this->iOwnerId;
394 $this->oSearch->aCurrent[
'paginate'][
'perPage'] = $this->oConfig->getGlParam(
'number_all');
396 $sCode = $this->oSearch->displayResultBlock();
397 $iCount = $this->oSearch->aCurrent[
'paginate'][
'totalNum'];
398 $sBaseHref = CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() .
'albums/my/';
399 $sUri = implode(
'/', array_slice($this->aAddParams, 1, 3));
405 if ($iCount > $this->oSearch->aCurrent[
'paginate'][
'perPage']) {
406 $sViewAllUrl = $sBaseHref . $this->aAddParams[0] .
'/' . $sUri;
407 $sViewAllUrl .= ($this->oConfig->isPermalinkEnabled) ?
'?' :
'&';
408 $sPaginate = $this->oSearch->getBottomMenu($sViewAllUrl .
'per_page=' . $iCount);
413 'disapproved' => NULL,
416 $sLangKey =
'_' . $this->oConfig->getMainPrefix() .
'_count_status_info';
417 $sUnitKey =
'_' . $this->oConfig->getMainPrefix() .
'_album_manage_objects_';
418 $sHref = $sBaseHref .
'manage_objects_{section}/' . $sUri;
421 foreach ($aSections
as $sSection => $mixedStatus) {
422 $mixedStatus = is_null($mixedStatus) ? $sSection : $mixedStatus;
423 $aParams = array(
'albumUri' => $this->aAddParams[1],
'Approved' => $mixedStatus,
'medProfId' => $this->iOwnerId);
424 $iCount = $this->oDb->getFilesCountByParams($aParams);
426 $sLangUnitKey =
_t($sUnitKey . $sSection);
427 $sMessage .=
_t($sLangKey, $iCount, str_replace(
'{section}', $sSection, $sHref), $sLangUnitKey) .
' ';
431 $sInfo = $this->oTemplate->parseHtmlByName (
'pending_approval_plank.html',
$aVars);
432 return array($sInfo .
$sCode, array(), $sPaginate,
'');
439 if (strlen($this->aAddParams[1]) > 0) {
441 $sName = $this->aAddParams[1] .
'/' . strip_tags($this->aAddParams[2]) .
'/' . strip_tags($this->aAddParams[3]) .
'/';
444 $sHrefPref = CH_WSB_URL_ROOT . $this->oConfig->getBaseUri();
445 foreach ($this->aSystemBlocks
as $sKey => $aValue) {
446 $sAdd = $aValue[
'const'] ==
true ?
'' :
$sName;
447 $sOwnLink = isset($aValue[
'link']) ? $aValue[
'link'] :
'albums/my/' . $sKey .
'/';
448 if ($aValue[
'level'] == $iCheck)
449 $aTopMenu[
_t(
'_ch_' . $this->oConfig->getUri() .
'_album_' . $sKey)] = array(
450 'href' => $sHrefPref . $sOwnLink . $sAdd,
451 'active' => (
$sMode == $sKey )
459 $this->oSearch->bAdminMode =
true;
460 $iPerPage = isset(
$_GET[
'per_page']) ? (int)
$_GET[
'per_page'] : (
int)$this->oConfig->getGlParam(
'number_albums_browse');
461 $iPage = isset(
$_GET[
'page']) ? (int)
$_GET[
'page'] : $this->oSearch->aCurrent[
'paginate'][
'page'];
462 $aCondition[
'show_empty'] =
true;
463 $aCondition[
'hide_default'] =
true;
464 $aCondition[
'owner'] = $this->iOwnerId;
466 $iCount = $this->oSearch->aCurrent[
'paginate'][
'totalAlbumNum'];
470 'name' =>
'action_delete',
471 'value' =>
_t(
'_Delete'),
472 'onclick' =>
'onclick="return confirm(\'' .
ch_js_string(
_t(
'_Are_you_sure')) .
'\');
"',
477 if ($iCount > $iPerPage) {
478 $sSection = isset($aCustom['section']) ? strip_tags($aCustom['section']) : '';
479 $iId = isset($aCustom['page_block_id']) ? (int)$aCustom['page_block_id'] : 1;
480 $aLinkAddon = $this->oSearch->getLinkAddByPrams(array('r'));
481 $sLink = $sLinkJs = $sViewAllUrl = CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() . 'albums/my/' . $sSection;
482 if ($this->oConfig->isPermalinkEnabled) {
487 $sViewAllUrl .= '&';
489 $sLinkJs .= $aLinkAddon['params'];
490 $sViewAllUrl .= 'per_page=' . $iCount;
491 $oPaginate = new ChWsbPaginate(array(
492 'page_url' => $sLink,
494 'per_page' => $iPerPage,
496 'on_change_page' => 'return !loadDynamicBlock(' . $iId . ', \'' . $sLinkJs . '&page={page}&per_page={per_page}\');',
497 'on_change_per_page' => 'return !loadDynamicBlock(' . $iId . ', \'' . $sLinkJs . '&page=1&per_page=\' + this.value);'
499 $sPaginate = $oPaginate->getSimplePaginate($sViewAllUrl);
501 $sManage = $this->oSearch->showAdminActionsPanel($this->oSearch->aCurrent['name'] . '_admin_form', $aBtns);
503 'main_code' => $sCode,
504 'paginate' => $sPaginate,
505 'manage' => $sManage,
508 return $this->oTemplate->parseHtmlByName('manage_form_albums.html', $aUnit);
511 function getAdminObjectPart ($aCondition = array(), $iBoxId = 0, $bShowMove = false)
513 $aInfo = $this->oAlbum->getAlbumInfo(array('fileUri' => $this->aAddParams[1], 'owner' => $this->iOwnerId));
514 if($aInfo['Owner'] != $this->iOwnerId)
515 return MsgBox(_t('_Access denied'));
517 $GLOBALS['oTopMenu']->setCustomSubHeader($aInfo['Caption']);
519 $this->oSearch->clearFilters(array('activeStatus', 'allow_view', 'album_status'), array('albumsObjects', 'albums', 'icon'));
520 $this->oSearch->bAdminMode = true;
522 $this->oSearch->aCurrent['paginate']['perPage'] = (int)$this->oConfig->getGlParam('number_all');
523 $this->oSearch->aCurrent['sorting'] = 'album_order';
524 $this->oSearch->aCurrent['view'] = 'full';
526 $this->oSearch->aCurrent['restriction']['album']['value'] = $this->aAddParams[1];
527 $this->oSearch->aCurrent['restriction']['albumType']['value'] = $this->oSearch->aCurrent['name'];
528 $this->oSearch->aCurrent['restriction']['ownerId']['value'] = $this->iOwnerId;
530 if (is_array($aCondition)) {
531 foreach ($aCondition as $sKey => $sValue) {
532 if (isset($this->oSearch->aCurrent['restriction'][$sKey]))
533 $this->oSearch->aCurrent['restriction'][$sKey]['value'] = $sValue;
537 $aUserAlbums = $this->oAlbum->getAlbumList(array('owner' => $this->iOwnerId, 'show_empty' => true, 'hide_default' => true), 0, 0, true);
538 foreach ($aUserAlbums as $aValue) {
539 if ($aValue['Uri'] != $this->aAddParams[1]) {
541 'album_id' => $aValue['ID'],
542 'album_caption' => $aValue['Caption']
545 $aAlbumInfo = array('ID' => $aValue['ID']);
546 $this->oSearch->aCurrent['restriction']['allow_view']['value'] = array($aValue['AllowAlbumView']);
550 'action_delete_object' => _t('_Delete'),
553 if (count($aUserAlbums) > 1 && $bShowMove) {
554 $aBtns['action_move_to'] = _t('_sys_album_move_to_another');
555 $sMoveToAlbum = $this->oTemplate->parseHtmlByName('albums_select.html', array('ch_repeat:choose' => $aAlbums));
557 $sCode = $this->oSearch->displayResultBlock();
558 $iCount = $this->oSearch->aCurrent['paginate']['totalNum'];
561 $sCode = MsgBox(_t('_Empty'));
563 if ($iCount > $this->oSearch->aCurrent['paginate']['perPage']) {
564 $sViewAllUrl = CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() . 'albums/my/' . implode('/', array_slice($this->aAddParams, 0, 4));
565 $sViewAllUrl .= ($this->oConfig->isPermalinkEnabled) ? '?' : '&';
566 $sPaginate = $this->oSearch->getBottomMenu($sViewAllUrl . 'per_page=' . $iCount);
568 $sPaginate = str_replace('{id}', $iBoxId, $sPaginate);
571 $sManage = $this->oSearch->showAdminActionsPanel($this->oSearch->aCurrent['name'] . '_admin_form', $aBtns, 'entry', true, false, $sMoveToAlbum);
572 $aAlbumInfo = $this->oAlbum->getAlbumInfo(array('fileUri' => $this->aAddParams[1]), array('ID'));
574 'ch_if:show_class' => array(
575 'condition' => false,
578 'main_code_id' => 'unit_area',
579 'main_code' => $sCode,
580 'paginate' => $sPaginate,
581 'manage' => $sManage,
582 'ch_if:hidden' => array(
583 'condition' => (int)$aAlbumInfo['ID'] != 0,
585 'hidden_name' => 'album_id',
586 'hidden_value' => (int)$aAlbumInfo['ID']
590 return $this->oTemplate->parseHtmlByName('manage_form.html', $aUnit);