8 require_once(CH_DIRECTORY_PATH_CLASSES .
'ChWsbPageView.php');
9 require_once(CH_DIRECTORY_PATH_CLASSES .
'ChWsbAlbums.php');
10 require_once(
'ChPhotosSearch.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'),
67 'manage_profile_photos' => array(
68 'blocks' => array(
'organize',
'addObjects'),
76 parent::__construct(
'ch_photos_albums_my');
78 $this->oTemplate = $oShared->_oTemplate;
79 $this->oConfig = $oShared->_oConfig;
80 $this->oDb = $oShared->_oDb;
82 $this->aAddParams = $aParams;
84 $this->oAlbum =
new ChWsbAlbums(
'ch_photos', $this->iOwnerId);
85 $this->oAlbumPrivacy = $oShared->oAlbumPrivacy;
87 if (isset($this->aSystemBlocks[$this->aAddParams[0]]))
88 $this->aCurrentBlocks = $this->aSystemBlocks[$this->aAddParams[0]];
90 $this->aCurrentBlocks = $this->aSystemBlocks[
'main'];
91 $this->oTemplate->addCss(array(
'my.css',
'browse.css'));
93 $this->oSearch->aCurrent[
'restriction'][
'ownerId'] = array(
94 'value' => $this->iOwnerId,
97 'paramName' =>
'ownerId'
100 $oShared->checkDefaultAlbums($this->iOwnerId);
105 return !
empty($this->aCurrentBlocks) ? (int)$this->aCurrentBlocks[
'level'] : 0;
111 if (!in_array(
'my', $this->aCurrentBlocks[
'blocks']))
113 $this->oSearch->clearFilters(array(
'allow_view',
'album_status'), array(
'albumsObjects',
'albums'));
114 $this->oSearch->bAdminMode =
false;
115 $this->oSearch->aCurrent[
'view'] =
'full';
116 $this->oSearch->aCurrent[
'restriction'][
'activeStatus'][
'value'] =
'approved';
117 $iPerPage = isset(
$_GET[
'per_page']) ? (int)
$_GET[
'per_page'] : (
int)$this->oConfig->getGlParam(
'number_albums_browse');
118 $iPage = isset(
$_GET[
'page']) ? (int)
$_GET[
'page'] : $this->oSearch->aCurrent[
'paginate'][
'page'];
119 $sCode = $this->oSearch->getAlbumList(
$iPage,
$iPerPage, array(
'owner'=>$this->iOwnerId,
'show_empty' =>
true,
'hide_default' =>
true));
120 $iCount = $this->oSearch->aCurrent[
'paginate'][
'totalAlbumNum'];
123 $aLinkAddon = $this->oSearch->getLinkAddByPrams(array(
'r'));
124 $sLink = $sLinkJs = $sViewAllUrl = CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() .
'albums/my/' . $this->aAddParams[0];
125 if ($this->oConfig->isPermalinkEnabled) {
130 $sViewAllUrl .=
'&';
132 $sLinkJs .= $aLinkAddon[
'params'];
133 $sViewAllUrl .=
'per_page=' . $iCount;
135 'page_url' => $sLink,
139 'on_change_page' =>
'return !loadDynamicBlock(' . $iBoxId .
', \'' . $sLinkJs .
'&page={page}&per_page={per_page}\');',
140 'on_change_per_page' =>
'return !loadDynamicBlock(' . $iBoxId .
', \'' . $sLinkJs .
'&page=1&per_page=\' + this.value);'
142 $sPgn = $oPaginate->getSimplePaginate($sViewAllUrl);
144 return array(
$sCode, array(), $sPgn,
false);
149 if (in_array(
'adminShort', $this->aCurrentBlocks[
'blocks'])) {
150 $iNumber = $this->oAlbum->getAlbumCount(array(
'owner' => $this->iOwnerId,
'show_empty' =>
true,
'hide_default' =>
true));
151 return array($this->oTemplate->getAdminAlbumShort($iNumber), $this->getTopMenu(
'main'), array());
157 if (in_array(
'adminAlbumShort', $this->aCurrentBlocks[
'blocks'])) {
158 $iNumber = $this->oAlbum->getObjCount(array(
'fileUri' => $this->aAddParams[1],
'owner' => $this->iOwnerId));
159 $sCode = $this->oTemplate->getAdminShort($iNumber, $this->aAddParams[1], $this->aAddParams[3]);
160 $aInfo = $this->oAlbum->getAlbumInfo(array(
'fileUri' => $this->aAddParams[1],
'owner' => $this->iOwnerId));
163 'fileStatCount' =>
_t(
'_sys_album_privacy_me_info'),
164 'fileStatAdd' =>
_t(
'_sys_album_edit_info', CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() .
'albums/my/edit/' . $this->aAddParams[1] .
'/owner/' . $this->aAddParams[3]),
165 'spec_class' =>
'sys_warning_text'
167 $sCode .= $this->oTemplate->parseHtmlByName(
'admin_short.html', $aDraw);
175 if(!in_array(
'adminFull', $this->aCurrentBlocks[
'blocks']))
178 return array($this->
getAdminPart(array(), array(
'section'=>
'manage',
'page_block_id' => $iBoxId)), $this->
getTopMenu(
'manage'), array(),
'');
183 if (!in_array(
'add', $this->aCurrentBlocks[
'blocks']))
186 $aPrivFieldView = $this->oAlbumPrivacy->getGroupChooser($this->iOwnerId, $this->oConfig->getUri(),
'album_view');
187 $aForm = $this->oTemplate->getAlbumFormAddArray(array(
'allow_view' => $aPrivFieldView));
191 if (
$oForm->isSubmittedAndValid()) {
192 $aFields = array(
'caption',
'location',
'description',
'AllowAlbumView',
'owner');
195 if (isset($_POST[$sValue]))
196 $aData[$sValue] = $_POST[$sValue];
198 $iNewId = $this->oAlbum->addAlbum($aData);
200 $aNew = $this->oAlbum->getAlbumInfo(array(
'fileId' => $iNewId), array(
'Uri'));
201 $sUrlAdd = CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() .
'albums/my/add_objects/' . $aNew[
'Uri'] .
'/owner/' .
getUsername($this->iOwnerId);
202 $sCode =
MsgBox(
_t(
'_' . $this->oConfig->getMainPrefix() .
'_album_save_redirect')) . $this->oTemplate->getJsTimeOutRedirect($sUrlAdd, 3);
211 if (!in_array(
'addObjects', $this->aCurrentBlocks[
'blocks']))
214 $aAlbumInfo = $this->oAlbum->getAlbumInfo(array(
'fileUri' => $this->aAddParams[1],
'owner' => $this->iOwnerId));
215 if($aAlbumInfo[
'Owner'] != $this->iOwnerId)
219 if (!$this->oSearch->oModule->isAllowedAdd()) {
220 $sCode =
MsgBox(
_t(
'_' . $this->oConfig->getMainPrefix() .
'_access_denied'));
222 require_once(
'ChPhotosUploader.php');
223 $sLink = CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() .
'albums/my/add_objects/' . rawurlencode($this->aAddParams[1]) .
'/'. $this->aAddParams[2] .
'/' . $this->aAddParams[3];
224 $aMenu = $this->oConfig->getUploaderSwitcher($sLink);
226 $sSubMenu = $this->oTemplate->getExtraSwitcher(
$aMenu,
'_' . $this->oConfig->getMainPrefix() .
'_choose_uploader', $iBoxId);
228 $oUploader->sWorkingFile = $sLink;
229 $sCode = $this->oTemplate->parseHtmlByName(
'default_margin.html', array(
'content' => $oUploader->GenMainAddFilesForm(array(
'album' => $this->aAddParams[1]))));
232 $GLOBALS[
'oTopMenu']->setCustomSubHeader($aAlbumInfo[
'Caption']);
238 if(!in_array(
'manageObjects', $this->aCurrentBlocks[
'blocks']))
241 return array($this->
getAdminObjectPart(array(
'activeStatus'=>
'approved'), $iBoxId,
true), $this->
getTopMenu(
'manage_objects'), array(),
'');
246 if(!in_array(
'manageObjectsDisapproved', $this->aCurrentBlocks[
'blocks']))
249 return array($this->
getAdminObjectPart(array(
'activeStatus'=>
'disapproved'), $iBoxId), $this->
getTopMenu(
'manage_objects_disapproved'), array(),
'');
254 if(!in_array(
'manageObjectsPending', $this->aCurrentBlocks[
'blocks']))
257 return array($this->
getAdminObjectPart(array(
'activeStatus'=>
'pending'), $iBoxId), $this->
getTopMenu(
'manage_objects_pending'), array(),
'');
262 if (!in_array(
'edit', $this->aCurrentBlocks[
'blocks']))
265 $aInfo = $this->oAlbum->getAlbumInfo(array(
'fileUri' => $this->aAddParams[1],
'owner' => $this->iOwnerId));
266 if (
$aInfo[
'Owner'] != $this->iOwnerId)
269 $aPrivFieldView = $this->oAlbumPrivacy->getGroupChooser($this->iOwnerId, $this->oConfig->getUri(),
'album_view');
270 $aPrivFieldView[
'value'] =
$aInfo[
'AllowAlbumView'];
275 'value' =>
$aInfo[
'Caption']
278 'name' =>
'Location',
279 'value' =>
$aInfo[
'Location']
281 'description' => array(
282 'name' =>
'Description',
283 'value' => strip_tags(
$aInfo[
'Description'])
285 'allow_view' => $aPrivFieldView,
289 'value' => (
int)
$aInfo[
'ID'],
294 'value' => $this->aAddParams[1],
299 'id' => $this->oConfig->getMainPrefix() .
'_upload_form',
301 'action' => $this->oConfig->getBaseUri().
'albums/my/edit/' . strip_tags($this->aAddParams[1] .
'/' . strip_tags($this->aAddParams[2]) .
'/' . strip_tags($this->aAddParams[3]))
304 $aForm = $this->oTemplate->getAlbumFormEditArray($aReInputs, $aReForm);
307 if (
$oForm->isSubmittedAndValid()) {
308 $aFields = array(
'Caption',
'Location',
'Description',
'AllowAlbumView');
311 if (isset($_POST[$sValue]))
312 $aData[$sValue] = $_POST[$sValue];
314 if ($this->oAlbum->updateAlbumById((
int)$_POST[
'ID'], $aData))
315 $sKey = $this->oConfig->getMainPrefix() .
'_album_save_success';
328 if (!in_array(
'organize', $this->aCurrentBlocks[
'blocks']))
331 $aInfo = $this->oAlbum->getAlbumInfo(array(
'fileUri' => $this->aAddParams[1],
'owner' => $this->iOwnerId));
332 if(
$aInfo[
'Owner'] != $this->iOwnerId)
335 $this->oSearch->clearFilters(array(
'activeStatus',
'allow_view',
'album_status'), array(
'albumsObjects',
'albums'));
336 $this->oSearch->bAdminMode =
false;
337 $this->oSearch->aCurrent[
'view'] =
'short';
339 $this->oSearch->aCurrent[
'restriction'][
'album'][
'value'] = $this->aAddParams[1];
340 $this->oSearch->aCurrent[
'restriction'][
'albumType'][
'value'] = $this->oSearch->aCurrent[
'name'];
341 $this->oSearch->aCurrent[
'restriction'][
'ownerId'][
'value'] =
$this->iOwnerId;
342 $this->oSearch->aCurrent[
'sorting'] =
'album_order';
343 $this->oSearch->aCurrent[
'paginate'][
'perPage'] = 1000;
344 $aUnits = $this->oSearch->getSearchData();
345 if ($this->oSearch->aCurrent[
'paginate'][
'totalNum'] > 0) {
346 $sMainUrl = CH_WSB_URL_ROOT . $this->oConfig->getBaseUri();
347 foreach ($aUnits
as $aData)
348 $sCode .= $this->oSearch->displaySearchUnit($aData);
350 'action_reverse' => array(
351 'value' =>
_t(
'_' . $this->oConfig->getMainPrefix() .
'_album_organize_reverse'),
354 'onclick' =>
'onclick=\'getHtmlData("unit_area", "' . $sMainUrl .
'album_reverse/' . $this->aAddParams[1] .
'"); return false;\''
357 $sAreaId =
'unit_area';
358 $sManage = $this->oSearch->showAdminActionsPanel(
'', $aBtns,
'entry',
false,
false);
360 if(strpos(
$aInfo[
'Uri'],
's-photos') !==
false) {
363 if(strpos(
$aInfo[
'Uri'],
's-cover-photos') !==
false) {
367 'ch_if:showmessage' => array(
368 'condition' =>
$sMessage !=
'' ?
true :
false,
369 'content' => array(
'message' =>
$sMessage)
371 'main_code_id' => $sAreaId,
374 'manage' => $sManage,
375 'ch_if:hidden' => array(
376 'condition' =>
false,
380 $sJsCode = $this->oTemplate->parseHtmlByName(
'js_organize.html', array(
382 'unit_area_id' => $sAreaId,
383 'album_name' => $this->aAddParams[1],
384 'add_params' => $this->aAddParams[2] .
'/' . $this->aAddParams[3]
386 $this->oTemplate->addCss(
'organize.css');
387 $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'));
388 $sCode = $sJsCode . $this->oTemplate->parseHtmlByName(
'manage_form.html',
$aUnit);
398 if(!in_array(
'albumObjects', $this->aCurrentBlocks[
'blocks']))
401 $this->oSearch->clearFilters(array(
'allow_view',
'album_status'), array(
'albumsObjects',
'albums'));
402 $this->oSearch->aCurrent[
'sorting'] =
'album_order';
403 $this->oSearch->bAdminMode =
false;
404 $this->oSearch->aCurrent[
'view'] =
'full';
406 $this->oSearch->aCurrent[
'restriction'][
'activeStatus'][
'value'] =
'approved';
407 $this->oSearch->aCurrent[
'restriction'][
'album'][
'value'] = $this->aAddParams[1];
408 $this->oSearch->aCurrent[
'restriction'][
'albumType'][
'value'] = $this->oSearch->aCurrent[
'name'];
409 $this->oSearch->aCurrent[
'restriction'][
'ownerId'][
'value'] =
$this->iOwnerId;
410 $this->oSearch->aCurrent[
'paginate'][
'perPage'] = $this->oConfig->getGlParam(
'number_all');
412 $sCode = $this->oSearch->displayResultBlock();
413 $iCount = $this->oSearch->aCurrent[
'paginate'][
'totalNum'];
414 $sBaseHref = CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() .
'albums/my/';
415 $sUri = implode(
'/', array_slice($this->aAddParams, 1, 3));
421 if ($iCount > $this->oSearch->aCurrent[
'paginate'][
'perPage']) {
422 $sViewAllUrl = $sBaseHref . $this->aAddParams[0] .
'/' . $sUri;
423 $sViewAllUrl .= ($this->oConfig->isPermalinkEnabled) ?
'?' :
'&';
424 $sPaginate = $this->oSearch->getBottomMenu($sViewAllUrl .
'per_page=' . $iCount);
429 'disapproved' => NULL,
432 $sLangKey =
'_' . $this->oConfig->getMainPrefix() .
'_count_status_info';
433 $sUnitKey =
'_' . $this->oConfig->getMainPrefix() .
'_album_manage_objects_';
434 $sHref = $sBaseHref .
'manage_objects_{section}/' . $sUri;
437 foreach ($aSections
as $sSection => $mixedStatus) {
438 $mixedStatus = is_null($mixedStatus) ? $sSection : $mixedStatus;
439 $aParams = array(
'albumUri' => $this->aAddParams[1],
'Approved' => $mixedStatus,
'medProfId' => $this->iOwnerId);
440 $iCount = $this->oDb->getFilesCountByParams($aParams);
442 $sLangUnitKey =
_t($sUnitKey . $sSection);
443 $sMessage .=
_t($sLangKey, $iCount, str_replace(
'{section}', $sSection, $sHref), $sLangUnitKey) .
' ';
447 $sInfo = $this->oTemplate->parseHtmlByName(
'pending_approval_plank.html', array(
'msg' =>
$sMessage));
448 $sCode = $this->oTemplate->parseHtmlByName(
'default_margin_thd.html', array(
'content' =>
$sCode));
449 return array($sInfo .
$sCode, array(), $sPaginate,
'');
457 if (!is_null($this->aCurrentBlocks[
'nomenu']))
460 if (strlen($this->aAddParams[1]) > 0) {
462 $sName = $this->aAddParams[1] .
'/' . strip_tags($this->aAddParams[2]) .
'/' . strip_tags($this->aAddParams[3]) .
'/';
465 $sHrefPref = CH_WSB_URL_ROOT . $this->oConfig->getBaseUri();
466 foreach ($this->aSystemBlocks
as $sKey => $aValue) {
467 $sAdd = $aValue[
'const'] ==
true ?
'' :
$sName;
468 $sOwnLink = isset($aValue[
'link']) ? $aValue[
'link'] :
'albums/my/' . $sKey .
'/';
469 if ($aValue[
'level'] == $iCheck)
470 $aTopMenu[
_t(
'_ch_' . $this->oConfig->getUri() .
'_album_' . $sKey)] = array(
471 'href' => $sHrefPref . $sOwnLink . $sAdd,
472 'active' => (
$sMode == $sKey )
480 $this->oSearch->clearFilters(array(
'allow_view',
'album_status'), array(
'albumsObjects',
'albums'));
481 $iPerPage = isset(
$_GET[
'per_page']) ? (int)
$_GET[
'per_page'] : (
int)$this->oConfig->getGlParam(
'number_albums_browse');
482 $iPage = isset(
$_GET[
'page']) ? (int)
$_GET[
'page'] : $this->oSearch->aCurrent[
'paginate'][
'page'];
483 $this->oSearch->bAdminMode =
true;
484 $aCondition[
'show_empty'] =
true;
485 $aCondition[
'hide_default'] =
true;
486 $aCondition[
'owner'] = $this->iOwnerId;
490 $iCount = $this->oSearch->aCurrent[
'paginate'][
'totalAlbumNum'];
494 'name' =>
'action_delete',
495 'value' =>
_t(
'_Delete'),
496 'onclick' =>
'onclick="return confirm(\'' .
ch_js_string(
_t(
'_Are_you_sure')) .
'\');
"',
500 if ($iCount > $iPerPage) {
501 $sSection = isset($aCustom['section']) ? strip_tags($aCustom['section']) : '';
502 $iId = isset($aCustom['page_block_id']) ? (int)$aCustom['page_block_id'] : 1;
503 $aLinkAddon = $this->oSearch->getLinkAddByPrams(array('r'));
504 $sLink = $sLinkJs = $sViewAllUrl = CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() . 'albums/my/' . $sSection;
505 if ($this->oConfig->isPermalinkEnabled) {
510 $sViewAllUrl .= '&';
512 $sLinkJs .= $aLinkAddon['params'];
513 $sViewAllUrl .= 'per_page=' . $iCount;
514 $oPaginate = new ChWsbPaginate(array(
515 'page_url' => $sLink,
517 'per_page' => $iPerPage,
519 'on_change_page' => 'return !loadDynamicBlock(' . $iId . ', \'' . $sLinkJs . '&page={page}&per_page={per_page}\');',
520 'on_change_per_page' => 'return !loadDynamicBlock(' . $iId . ', \'' . $sLinkJs . '&page=1&per_page=\' + this.value);'
522 $sPaginate = $oPaginate->getSimplePaginate($sViewAllUrl);
524 $sManage = $this->oSearch->showAdminActionsPanel($this->oSearch->aCurrent['name'] . '_admin_form', $aBtns);
526 'main_code' => $sCode,
527 'paginate' => $sPaginate,
530 return $this->oTemplate->parseHtmlByName('manage_form_albums.html', $aUnit);
533 function getAdminObjectPart ($aCondition = array(), $iBoxId = 0, $bShowMove = false)
535 $aInfo = $this->oAlbum->getAlbumInfo(array('fileUri' => $this->aAddParams[1], 'owner' => $this->iOwnerId));
536 if($aInfo['Owner'] != $this->iOwnerId)
537 return MsgBox(_t('_Access denied'));
539 $GLOBALS['oTopMenu']->setCustomSubHeader($aInfo['Caption']);
541 $this->oSearch->clearFilters(array('activeStatus', 'allow_view', 'album_status'), array('albumsObjects', 'albums'));
542 $this->oSearch->aCurrent['paginate']['perPage'] = (int)$this->oConfig->getGlParam('number_all');
543 $this->oSearch->bAdminMode = true;
544 $this->oSearch->aCurrent['sorting'] = 'album_order';
545 $this->oSearch->aCurrent['view'] = 'full';
547 $aMainParams = array(
548 'album' => $this->aAddParams[1],
549 'albumType' => $this->oSearch->aCurrent['name'],
550 'ownerId' => $this->iOwnerId
553 $this->oSearch->fillFilters(array_merge($aCondition, $aMainParams));
554 //manage inputs sections
556 'action_delete_object' => _t('_Delete'),
559 $aUserAlbums = $this->oAlbum->getAlbumList(array('owner' => $this->iOwnerId, 'show_empty' => true, 'hide_default' => true), 0, 0, true);
560 foreach ($aUserAlbums as $aValue) {
561 if ($aValue['Uri'] != $this->aAddParams[1]) {
563 'album_id' => $aValue['ID'],
564 'album_caption' => $aValue['Caption']
567 $aAlbumInfo = array('ID' => $aValue['ID']);
568 $this->oSearch->aCurrent['restriction']['allow_view']['value'] = array($aValue['AllowAlbumView']);
573 if (count($aUserAlbums) > 1 && $bShowMove) {
574 $aBtns['action_move_to'] = _t('_sys_album_move_to_another');
575 $sMoveToAlbum = $this->oTemplate->parseHtmlByName('albums_select.html', array('ch_repeat:choose' => $aAlbums));
578 $sCode = $this->oSearch->displayResultBlock();
579 $iCount = $this->oSearch->aCurrent['paginate']['totalNum'];
582 $sCode = MsgBox(_t('_Empty'));
584 if ($iCount > $this->oSearch->aCurrent['paginate']['perPage']) {
585 $sViewAllUrl = CH_WSB_URL_ROOT . $this->oConfig->getBaseUri() . 'albums/my/' . implode('/', array_slice($this->aAddParams, 0, 4));
586 $sViewAllUrl .= ($this->oConfig->isPermalinkEnabled) ? '?' : '&';
587 $sPaginate = $this->oSearch->getBottomMenu($sViewAllUrl . 'per_page=' . $iCount);
589 $sPaginate = str_replace('{id}', $iBoxId, $sPaginate);
592 $sManage = $this->oSearch->showAdminActionsPanel($this->oSearch->aCurrent['name'] . '_admin_form', $aBtns, 'entry', true, false, $sMoveToAlbum);
594 'main_code_id' => 'unit_area',
595 'main_code' => $sCode,
596 'paginate' => $sPaginate,
597 'manage' => $sManage,
598 'ch_if:hidden' => array(
599 'condition' => (int)$aAlbumInfo['ID'] != 0,
601 'hidden_name' => 'album_id',
602 'hidden_value' => (int)$aAlbumInfo['ID']
606 return $this->oTemplate->parseHtmlByName('manage_form.html', $aUnit);