Alex Trofimov vor 12 Jahren
Ursprung
Commit
9971431692

+ 2 - 20
modules/boonex/notes/classes/BxNotesConfig.php

@@ -44,6 +44,8 @@ class BxNotesConfig extends BxDolModuleConfig
         'OBJECT_FORM_ENTRY_DISPLAY_ADD' => 'bx_notes_note_add',
         'OBJECT_FORM_ENTRY_DISPLAY_EDIT' => 'bx_notes_note_edit',
         'OBJECT_FORM_ENTRY_DISPLAY_DELETE' => 'bx_notes_note_delete',
+        'OBJECT_MENU_ACTIONS_VIEW_ENTRY' => 'bx_notes_view',
+        'OBJECT_MENU_ACTIONS_MY_ENTRIES' => 'bx_notes_my',
         'OBJECT_MENU_SUBMENU' => 'bx_notes_submenu',
         'OBJECT_MENU_SUBMENU_VIEW_ENTRY' => 'bx_notes_view_submenu',
         'OBJECT_MENU_SUBMENU_VIEW_ENTRY_MAIN_SELECTION' => 'notes-home',
@@ -59,26 +61,6 @@ class BxNotesConfig extends BxDolModuleConfig
         ),
     );
 
-    public static $FIELD_ID = 'id';
-    public static $FIELD_AUTHOR = 'author';
-    public static $FIELD_ADDED = 'added';
-    public static $FIELD_CHANGED = 'changed';
-    public static $FIELD_TITLE = 'title';
-    public static $FIELD_TEXT = 'text';
-    public static $FIELD_TEXT_ID = 'note-text';
-    public static $FIELD_SUMMARY = 'summary';
-    public static $FIELD_SUMMARY_ID = 'note-summary';
-    public static $FIELD_ALLOW_VIEW_TO = 'allow_view_to';
-    public static $FIELD_PHOTO = 'pictures';
-    public static $FIELD_THUMB = 'thumb';
-
-    public static $OBJECT_STORAGE = 'bx_notes_photos';
-    public static $OBJECT_IMAGES_TRANSCODER_PREVIEW = 'bx_notes_preview';
-    public static $OBJECT_VIEWS = 'bx_notes';
-    public static $OBJECT_VOTES = 'bx_notes';
-    public static $OBJECT_COMMENTS = 'bx_notes';
-    public static $OBJECT_PRIVACY_VIEW = 'bx_notes_allow_view_to';
-
     /**
      * Constructor
      */

+ 5 - 5
modules/boonex/notes/classes/BxNotesFormsEntryHelper.php

@@ -100,7 +100,7 @@ class BxNotesFormsEntryHelper extends BxDolProfileForms
 
         // update data in the DB
         $aTrackTextFieldsChanges = null;
-        if (!$oForm->update ($aContentInfo['id'], array(), $aTrackTextFieldsChanges)) {
+        if (!$oForm->update ($aContentInfo[$CNF['FIELD_ID']], array(), $aTrackTextFieldsChanges)) {
             if (!$oForm->isValid())
                 return $oForm->getCode();
             else
@@ -117,10 +117,10 @@ class BxNotesFormsEntryHelper extends BxDolProfileForms
         // create an alert
         //TODO: Pass a valid entry privacy view group.
         bx_import('BxDolPrivacy');
-        bx_alert($this->_oModule->getName(), 'edited', $aContentInfo['id'], false, array('privacy_view' => BX_DOL_PG_MEMBERS)); 
+        bx_alert($this->_oModule->getName(), 'edited', $aContentInfo[$CNF['FIELD_ID']], false, array('privacy_view' => BX_DOL_PG_MEMBERS)); 
 
         // redirect 
-        $this->_redirectAndExit('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo['id']);
+        $this->_redirectAndExit('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
     }
 
 
@@ -153,7 +153,7 @@ class BxNotesFormsEntryHelper extends BxDolProfileForms
         if (!$oForm->isSubmittedAndValid())
             return $oForm->getCode();
 
-        if (!$oForm->delete ($aContentInfo['id'])) {
+        if (!$oForm->delete ($aContentInfo[$CNF['FIELD_ID']])) {
             if (!$oForm->isValid())
                 return $oForm->getCode();
             else
@@ -164,7 +164,7 @@ class BxNotesFormsEntryHelper extends BxDolProfileForms
         $this->_oModule->isAllowedDelete($aContentInfo, true);
 
         // create an alert
-        bx_alert($this->_oModule->getName(), 'deleted', $aContentInfo['id']);
+        bx_alert($this->_oModule->getName(), 'deleted', $aContentInfo[$CNF['FIELD_ID']]);
 
         // redirect 
         $this->_redirectAndExit('page.php?i=' . $CNF['URI_HOME']);

+ 1 - 1
modules/boonex/notes/classes/BxNotesMenuView.php

@@ -25,7 +25,7 @@ class BxNotesMenuView extends BxNotesMenu
 
         $this->_aContentInfo = $this->_oModule->_oDb->getContentInfoById($iContentId);
         if ($this->_aContentInfo)
-            $this->addMarkers(array('content_id' => $this->_aContentInfo['id']));
+            $this->addMarkers(array('content_id' => (int)$iContentId));
     }
 }
 

+ 37 - 30
modules/boonex/notes/classes/BxNotesModule.php

@@ -124,14 +124,16 @@ class BxNotesModule extends BxDolModule {
         if (!$aContentInfo)
             return false;
 
+        $CNF = &$this->_oConfig->CNF;
+
         bx_import('BxDolPermalinks');
-        $sUrl = BxDolPermalinks::getInstance()->permalink('page.php?i=view-note&id=' . $aContentInfo['id']);
+        $sUrl = BxDolPermalinks::getInstance()->permalink('page.php?i=view-note&id=' . $aContentInfo[$CNF['FIELD_ID']]);
 
         $aCustomParams = false;
-        if ($aContentInfo[BxNotesConfig::$FIELD_THUMB]) {
+        if ($aContentInfo[$CNF['FIELD_THUMB']]) {
             bx_import('BxDolStorage');
-            $oStorage = BxDolStorage::getObjectInstance(BxNotesConfig::$OBJECT_STORAGE);
-            if ($oStorage && ($sImgUrl = $oStorage->getFileUrlById($aContentInfo[BxNotesConfig::$FIELD_THUMB]))) {
+            $oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']);
+            if ($oStorage && ($sImgUrl = $oStorage->getFileUrlById($aContentInfo[$CNF['FIELD_THUMB']]))) {
                 $aCustomParams = array (
                     'img_url' => $sImgUrl,
                     'img_url_encoded' => rawurlencode($sImgUrl),
@@ -142,16 +144,16 @@ class BxNotesModule extends BxDolModule {
         //TODO: Rebuild using menus engine when it will be ready for such elements like Vote, Share, etc.
         $sVotes = '';
         bx_import('BxDolVote');
-        $oVotes = BxDolVote::getObjectInstance(BxNotesConfig::$OBJECT_VOTES, $aContentInfo[BxNotesConfig::$FIELD_ID]);
+        $oVotes = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES'], $aContentInfo[$CNF['FIELD_ID']]);
         if ($oVotes)
             $sVotes = $oVotes->getElementBlock(array('show_do_vote_as_button' => true)); 
 
         $sShare = '';
-        if(BxDolRequest::serviceExists('bx_timeline', 'get_share_element_block'))
-        	$sShare = BxDolService::call('bx_timeline', 'get_share_element_block', array(bx_get_logged_profile_id(), 'bx_notes', 'added', $aContentInfo[BxNotesConfig::$FIELD_ID], array('show_do_share_as_button' => true)));
+        if (BxDolRequest::serviceExists('bx_timeline', 'get_share_element_block'))
+        	$sShare = BxDolService::call('bx_timeline', 'get_share_element_block', array(bx_get_logged_profile_id(), 'bx_notes', 'added', $aContentInfo[$CNF['FIELD_ID']], array('show_do_share_as_button' => true)));
 
         bx_import('BxTemplSocialSharing');
-		$sSocial = BxTemplSocialSharing::getInstance()->getCode($iContentId, 'bx_notes', BX_DOL_URL_ROOT . $sUrl, $aContentInfo['title'], $aCustomParams);
+		$sSocial = BxTemplSocialSharing::getInstance()->getCode($iContentId, 'bx_notes', BX_DOL_URL_ROOT . $sUrl, $aContentInfo[$CNF['FIELD_TITLE']], $aCustomParams);
 
         return $this->_oTemplate->parseHtmlByName('entry-share.html', array(
         	'vote' => $sVotes,
@@ -168,7 +170,7 @@ class BxNotesModule extends BxDolModule {
             return false;
 
 		bx_import('BxDolCmts');
-		$oCmts = BxDolCmts::getObjectInstance(BxNotesConfig::$OBJECT_COMMENTS, $iContentId);
+		$oCmts = BxDolCmts::getObjectInstance($this->_oConfig->CNF['OBJECT_COMMENTS'], $iContentId);
 		if(!$oCmts->isEnabled())
 			return false;
 
@@ -183,7 +185,8 @@ class BxNotesModule extends BxDolModule {
         $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
         if (!$aContentInfo)
             return false;
-        $oProfile = BxDolProfile::getInstance($aContentInfo[BxNotesConfig::$FIELD_AUTHOR]);
+
+        $oProfile = BxDolProfile::getInstance($aContentInfo[$this->_oConfig->CNF['FIELD_AUTHOR']]);
         if (!$oProfile) {
             bx_import('BxDolProfileUndefined');
             $oProfile = BxDolProfileUndefined::getInstance();
@@ -198,7 +201,7 @@ class BxNotesModule extends BxDolModule {
             return false;
 
         bx_import('BxTemplMenu');
-        $oMenu = BxTemplMenu::getObjectInstance('bx_notes_view');
+        $oMenu = BxTemplMenu::getObjectInstance($this->_oConfig->CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY']);
         return $oMenu ? $oMenu->getCode() : false;
     }
 
@@ -209,7 +212,7 @@ class BxNotesModule extends BxDolModule {
             return false;
 
         bx_import('BxTemplMenu');
-        $oMenu = BxTemplMenu::getObjectInstance('bx_notes_my');
+        $oMenu = BxTemplMenu::getObjectInstance($this->_oConfig->CNF['OBJECT_MENU_ACTIONS_MY_ENTRIES']);
         return $oMenu ? $oMenu->getCode() : false;
     }
 
@@ -235,49 +238,51 @@ class BxNotesModule extends BxDolModule {
     	if(empty($aContentInfo) || !is_array($aContentInfo))
     		return '';
 
+        $CNF = &$this->_oConfig->CNF;
+
     	bx_import('BxDolPermalinks');
-		$sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=view-note&id=' . $aContentInfo[BxNotesConfig::$FIELD_ID]);
+		$sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=view-note&id=' . $aContentInfo[$CNF['FIELD_ID']]);
 
 		//--- Image(s)
 	    $sImage = '';
-        if($aContentInfo[BxNotesConfig::$FIELD_THUMB]) {
+        if($aContentInfo[$CNF['FIELD_THUMB']]) {
         	bx_import('BxDolStorage');
-			$oStorage = BxDolStorage::getObjectInstance(BxNotesConfig::$OBJECT_STORAGE);
+			$oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']);
             if($oStorage)
-				$sImage = $oStorage->getFileUrlById($aContentInfo[BxNotesConfig::$FIELD_THUMB]);
+				$sImage = $oStorage->getFileUrlById($aContentInfo[$CNF['FIELD_THUMB']]);
         }
 
         //--- Votes
         bx_import('BxDolVote');
-        $oVotes = BxDolVote::getObjectInstance(BxNotesConfig::$OBJECT_VOTES, $aEvent['object_id']);
+        $oVotes = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES'], $aEvent['object_id']);
 
         $aVotes = array(); 
 		if ($oVotes && $oVotes->isEnabled())
 			$aVotes = array(
-				'system' => BxNotesConfig::$OBJECT_VOTES,
-				'object_id' => $aContentInfo[BxNotesConfig::$FIELD_ID],
+				'system' => $CNF['OBJECT_VOTES'],
+				'object_id' => $aContentInfo[$CNF['FIELD_ID']],
 				'count' => $aContentInfo['votes']
 			);
 
         //--- Comments
         bx_import('BxDolCmts');
-        $oCmts = BxDolCmts::getObjectInstance(BxNotesConfig::$OBJECT_COMMENTS, $aEvent['object_id']);
+        $oCmts = BxDolCmts::getObjectInstance($CNF['OBJECT_COMMENTS'], $aEvent['object_id']);
 
         $aComments = array(); 
 		if($oCmts->isEnabled())
 			$aComments = array(
-				'system' => BxNotesConfig::$OBJECT_COMMENTS,
-				'object_id' => $aContentInfo[BxNotesConfig::$FIELD_ID],
+				'system' => $CNF['OBJECT_COMMENTS'],
+				'object_id' => $aContentInfo[$CNF['FIELD_ID']],
 				'count' => $aContentInfo['comments']
 			);
 
     	return array(
-    		'owner_id' => $aContentInfo[BxNotesConfig::$FIELD_AUTHOR],
+    		'owner_id' => $aContentInfo[$CNF['FIELD_AUTHOR']],
     		'content' => array(
     			'sample' => _t('_bx_notes_txt_sample_single'),
     			'url' => $sUrl,
-    			'title' => $aContentInfo[BxNotesConfig::$FIELD_TITLE],
-    			'text' => $aContentInfo[BxNotesConfig::$FIELD_TEXT],
+    			'title' => $aContentInfo[$CNF['FIELD_TITLE']],
+    			'text' => $aContentInfo[$CNF['FIELD_TEXT']],
     			'images' => array(
     				array(
     					'url' => $sUrl,
@@ -359,8 +364,10 @@ class BxNotesModule extends BxDolModule {
      */
     function isAllowedView ($aDataEntry, $isPerformAction = false) {
 
+        $CNF = &$this->_oConfig->CNF;
+
         // moderator and owner always have access
-        if ($aDataEntry[BxNotesConfig::$FIELD_AUTHOR] == $this->_iProfileId || $this->_checkModeratorAccess($isPerformAction))
+        if ($aDataEntry[$CNF['FIELD_AUTHOR']] == $this->_iProfileId || $this->_checkModeratorAccess($isPerformAction))
             return CHECK_ACTION_RESULT_ALLOWED;
 
         // check ACL
@@ -370,8 +377,8 @@ class BxNotesModule extends BxDolModule {
 
         // check privacy 
     	bx_import('BxDolPrivacy');
-    	$oPrivacy = BxDolPrivacy::getObjectInstance(BxNotesConfig::$OBJECT_PRIVACY_VIEW);
-		if ($oPrivacy && !$oPrivacy->check($aDataEntry[BxNotesConfig::$FIELD_ID]))
+    	$oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_VIEW']);
+		if ($oPrivacy && !$oPrivacy->check($aDataEntry[$CNF['FIELD_ID']]))
             return _t('_sys_access_denied_to_private_content');
 
         return CHECK_ACTION_RESULT_ALLOWED;
@@ -400,7 +407,7 @@ class BxNotesModule extends BxDolModule {
      */
     function isAllowedEdit ($aDataEntry, $isPerformAction = false) {
         // moderator and owner always have access
-        if ($aDataEntry[BxNotesConfig::$FIELD_AUTHOR] == $this->_iProfileId || $this->_checkModeratorAccess($isPerformAction))
+        if ($aDataEntry[$this->_oConfig->CNF['FIELD_AUTHOR']] == $this->_iProfileId || $this->_checkModeratorAccess($isPerformAction))
             return CHECK_ACTION_RESULT_ALLOWED;
         return _t('_sys_txt_access_denied');
     }
@@ -415,7 +422,7 @@ class BxNotesModule extends BxDolModule {
 
         // check ACL
         $aCheck = checkActionModule($this->_iProfileId, 'delete note', $this->getName(), $isPerformAction);
-        if ($aDataEntry[BxNotesConfig::$FIELD_AUTHOR] == $this->_iProfileId && $aCheck[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED)
+        if ($aDataEntry[$this->_oConfig->CNF['FIELD_AUTHOR']] == $this->_iProfileId && $aCheck[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED)
             return CHECK_ACTION_RESULT_ALLOWED;
 
         return _t('_sys_txt_access_denied');

+ 2 - 1
modules/boonex/notes/classes/BxNotesSearchResult.php

@@ -54,6 +54,7 @@ class BxNotesSearchResult extends BxTemplSearchResult
         $oProfileAuthor = null;
 
         $oModuleMain = $this->getMain();
+        $CNF = &$oModuleMain->_oConfig->CNF;
 
         switch ($sMode) {
 
@@ -102,7 +103,7 @@ class BxNotesSearchResult extends BxTemplSearchResult
 
         // add conditions for private content
         bx_import('BxDolPrivacy');
-        $oPrivacy = BxDolPrivacy::getObjectInstance(BxNotesConfig::$OBJECT_PRIVACY_VIEW);
+        $oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_VIEW']);
         $a = $oPrivacy ? $oPrivacy->getContentPublicAsCondition($oProfileAuthor ? $oProfileAuthor->id() : 0) : array();
         if (isset($a['restriction']))
             $this->aCurrent['restriction'] = array_merge($this->aCurrent['restriction'], $a['restriction']);